:root {
  --bg: #f7f7f5; --card: #ffffff; --ink: #1c1c1a; --muted: #6b6b66; --line: #e6e5e0;
  --accent: #2f5bd3; --accent-ink: #fff; --user: #eef2fd;
  --claude: #c8643b; --agy: #2f7d5b; --grok: #5b4bc4;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161616; --card: #202020; --ink: #ecebe6; --muted: #9a9a94; --line: #2e2e2c; --user: #1f2a44; --accent: #6d8ff0; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 17px; line-height: 1.35; margin: 0; flex: 1; min-width: 0; word-break: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.icon-btn { border: 0; background: none; padding: 8px; margin: -8px; font-size: 20px; line-height: 1; min-width: 40px; min-height: 40px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #aaa; display: inline-block; }
.dot.on { background: #2fa36b; } .dot.off { background: #d0533b; }
.status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 12px 12px 180px; }

/* login */
.login { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; text-align: center; }
.login h2 { font-size: 22px; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.field { width: 100%; font-size: 16px; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.primary { width: 100%; margin-top: 12px; padding: 13px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 600; }
.primary:disabled { opacity: .5; }
.err { color: #d0533b; font-size: 14px; min-height: 20px; margin-top: 10px; }

/* thread list */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.item .t { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .d { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { text-align: center; color: var(--muted); margin-top: 22vh; font-size: 14px; line-height: 1.7; }

/* rounds */
.round { margin: 6px 0 22px; }
.user-msg { margin-left: auto; max-width: 92%; width: fit-content; background: var(--user); border-radius: var(--radius) var(--radius) 4px var(--radius); padding: 10px 13px; white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.6; }
.user-imgs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 6px; }
.user-imgs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.round-label { font-size: 12px; color: var(--muted); margin: 14px 2px 8px; }

.tabs { display: flex; gap: 6px; margin: 10px 0 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 10px; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.tab.active { border-color: currentColor; font-weight: 600; }
.tab[data-m=claude] { color: var(--claude); } .tab[data-m=agy] { color: var(--agy); } .tab[data-m=grok] { color: var(--grok); }
.answers { display: block; }
.ans { display: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.ans.active { display: block; }
.ans-head { display: none; font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.ans[data-m=claude] .ans-head { color: var(--claude); } .ans[data-m=agy] .ans-head { color: var(--agy); } .ans[data-m=grok] .ans-head { color: var(--grok); }
@media (min-width: 900px) {
  .tabs { display: none; }
  .answers { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 12px; align-items: start; }
  .ans { display: block; }
  .ans-head { display: block; }
}
.pending { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--muted); border-radius: 50%; animation: s 0.9s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }

/* markdown */
.md { font-size: 15px; line-height: 1.7; word-break: break-word; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.35; margin: 1.1em 0 .5em; }
.md h1 { font-size: 1.25em; } .md h2 { font-size: 1.15em; } .md h3, .md h4 { font-size: 1.05em; }
.md ul, .md ol { padding-left: 1.3em; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 14px; margin: .8em 0; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; min-width: 70px; }
.md th { background: color-mix(in srgb, var(--line) 45%, transparent); }
.md pre { background: color-mix(in srgb, var(--line) 40%, transparent); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.md code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; }
.md blockquote { margin: .6em 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.md img { max-width: 100%; }

.copy { margin-top: 10px; border: 1px solid var(--line); background: none; border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--muted); }
.files { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.file { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.file input { width: 18px; height: 18px; flex: none; }
.file a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .sz { color: var(--muted); font-size: 12px; flex: none; }
.mail-btn { align-self: flex-start; border: 1px solid var(--line); background: none; border-radius: 8px; padding: 6px 10px; font-size: 13px; }

/* composer */
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--bg); border-top: 1px solid var(--line);
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px); }
.composer-in { max-width: 1180px; margin: 0 auto; }
.chips { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 11px; font-size: 13px; white-space: nowrap; color: var(--muted); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row textarea { flex: 1; resize: none; max-height: 40dvh; min-height: 44px; font-size: 16px; line-height: 1.45; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
.attach, .send { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 20px; display: grid; place-items: center; }
.send { background: var(--accent); color: var(--accent-ink); border: 0; font-size: 18px; }
.send:disabled { opacity: .45; }
.thumbs { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.thumb { position: relative; }
.thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); font-size: 12px; line-height: 22px; padding: 0; }
.hint { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); }
@media (min-width: 600px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h3 { margin: 0 0 6px; font-size: 17px; }
.sheet p { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.ghost { width: 100%; margin-top: 8px; padding: 12px; border: 0; background: none; color: var(--muted); font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 150px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: 90vw; }
.fchip { height: 56px; max-width: 180px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: 13px; }
.fchip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ufile { display: inline-flex; align-items: center; gap: 6px; max-width: 92%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 14px; text-decoration: none; color: var(--ink); word-break: break-all; }
.ufile .sz { color: var(--muted); font-size: 12px; flex: none; }
.user-imgs { align-items: center; }
