/* ===== Chat app shell ===== */
.app { height: 100dvh; overflow: hidden; display: grid; grid-template-columns: 272px 1fr; background: var(--bg); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .i { width: 18px; height: 18px; }
.only-m { display: none; }

/* Sidebar */
.side { display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; border-right: 1px solid var(--line); background: var(--bg-2); min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.app-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.app-brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); font-family: var(--mono); letter-spacing: 0; }
.app-brand .brand-mark { width: 34px; height: 34px; border-radius: 11px; font-size: 17px; }
.new-chat { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 550; box-shadow: var(--shadow-sm), var(--hi); }
.new-chat:hover { border-color: var(--line-2); }
.new-chat kbd { margin-left: auto; }
.new-chat .i { color: var(--muted); }
.side-label { margin: 16px 8px 6px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; color: var(--faint); }
.convs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; overflow: auto; }
.convs button { width: 100%; display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; text-align: left; }
.convs button:hover { background: var(--surface-2); }
.convs button[aria-current] { background: var(--surface); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.cv-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: radial-gradient(120% 120% at 20% 10%, #c79a6b, #6e4226); color: #fff; flex: none; }
.cv-ico .i { width: 15px; height: 15px; }
.cv-txt { min-width: 0; display: flex; flex-direction: column; }
.cv-txt strong { font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-txt small { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot { margin-top: auto; display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.side-btn { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-size: 13px; }
.side-btn:hover { background: var(--surface-2); color: var(--ink); }
.side-btn .i { color: var(--muted); }
.live-pill { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live-pill.on i { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }

/* Main */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.main::before { content: ""; position: absolute; inset: 0; background: radial-gradient(700px 400px at 50% -10%, var(--glow), transparent 70%); pointer-events: none; }
.main-top { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 20px; border-bottom: 1px solid transparent; }
.title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.mode-badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-family: var(--mono); }
.mode-badge.replay { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.mode-badge.live { background: var(--accent-soft); color: var(--accent); }
.mode-badge.live i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.thread { position: relative; flex: 1; overflow: auto; padding: 8px 24px 180px; scroll-behavior: smooth; }
.thread > * { max-width: 800px; margin-left: auto; margin-right: auto; }

/* Empty state */
#empty { min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; position: relative; }
.orb { width: 64px; height: 64px; border-radius: 22px; background: var(--grad); box-shadow: 0 20px 60px -10px var(--accent-line), inset 0 0 0 1px rgba(255,255,255,.25); margin-bottom: 24px; position: relative; }
.orb { display: grid; place-items: center; color: #fff; }
.orb .i { width: 30px; height: 30px; stroke-width: 2; }
#empty h1 { font-size: 36px; letter-spacing: -0.04em; margin: 0 0 10px; font-weight: 700; }
#empty p { margin: 0 0 28px; line-height: 1.7; }
.suggests { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.suggest { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); text-align: left; box-shadow: var(--shadow-sm), var(--hi); transition: transform .2s ease, box-shadow .2s ease, border-color .2s; }
.suggest:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.sg-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.suggest strong { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.suggest small { font-size: 12px; color: var(--muted); }
.sg-go { position: absolute; top: 14px; right: 14px; color: var(--faint); }

/* Messages */
.msg { display: flex; gap: 14px; margin-top: 24px; animation: enter .35s cubic-bezier(.2,.8,.2,1); }
.msg.user { justify-content: flex-end; }
.bubble-u { max-width: 72%; padding: 10px 16px; border-radius: 20px 20px 6px 20px; background: var(--ink); color: var(--bg); font-size: 15px; line-height: 1.6; }
.avatar { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--grad); color: var(--accent-ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); margin-top: 2px; }
.avatar .i { width: 16px; height: 16px; }
.bot-body { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.bot-body > * { min-width: 0; }

/* Process timeline */
.process { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm), var(--hi); overflow: hidden; }
.process summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; font-size: 13.5px; }
.process summary::-webkit-details-marker { display: none; }
.p-title { font-weight: 550; }
.p-meta { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.process .chev { color: var(--faint); transition: transform .2s; }
.process[open] .chev { transform: rotate(90deg); }
.p-ok { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.p-ok .i { width: 11px; height: 11px; stroke-width: 3; }
.process.failed .p-title { color: var(--bad); }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: rot .8s linear infinite; flex: none; }
.spin.sm { width: 12px; height: 12px; border-width: 1.5px; }
@keyframes rot { to { transform: rotate(360deg); } }
.steps { list-style: none; margin: 0; padding: 4px 14px 12px 14px; display: grid; gap: 0; position: relative; }
.steps li { position: relative; display: grid; grid-template-columns: 18px 64px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; font-size: 12.5px; animation: enter .3s both; }
.steps li + li::before { content: ""; position: absolute; left: 8.5px; top: -6px; height: 12px; width: 1px; background: var(--line-2); }
.st-ico { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); color: var(--accent); }
.st-ico .i { width: 11px; height: 11px; stroke-width: 2.6; }
.steps li.err .st-ico { color: var(--bad); }
.st-label { color: var(--muted); }
.steps code { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; }
.st-meta { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.pill { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* Source strip */
.src-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; mask-image: linear-gradient(90deg, #000 90%, transparent); }
.src-strip::-webkit-scrollbar { height: 4px; } .src-strip::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.src-card { flex: none; width: 196px; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: left; scroll-snap-align: start; box-shadow: var(--shadow-sm); animation: enter .3s both; transition: border-color .15s, transform .15s; }
.src-card:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.sc-top { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.sc-top b { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--accent); }
.sc-site { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); font-size: 9.5px; font-weight: 700; flex: none; }
.sc-title { font-size: 12.5px; line-height: 1.45; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.sc-date { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.sc-date.old, .insp-item .old { color: var(--warn); }
.src-card.more { width: 120px; align-items: center; justify-content: center; background: var(--surface-2); }
.src-card.more strong { font-size: 20px; letter-spacing: -0.03em; }
.src-card.more span { font-size: 11.5px; color: var(--muted); }

/* Thinking */
.thinking { display: grid; gap: 12px; }
.shimmer { font-size: 13.5px; background: linear-gradient(90deg, var(--muted) 0%, var(--ink) 40%, var(--muted) 80%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 2s linear infinite; }
@keyframes shine { to { background-position: -200% 0; } }
.skel { display: grid; gap: 8px; padding: 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); }
.skel i { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shine 1.4s linear infinite; }
.skel i:nth-child(1) { width: 40%; } .skel i:nth-child(2) { width: 85%; } .skel i:nth-child(3) { width: 65%; }

/* Answer */
.answer-text { margin: 0; font-size: 15.5px; line-height: 1.75; color: var(--ink); }
.answer-text.err { color: var(--bad); display: flex; gap: 6px; align-items: center; }
.answer-card .store-card { font-size: 14px; padding: 16px; }
.answer-card .ghost-row { opacity: .35; }
.answer-foot { display: grid; gap: 10px; }
.stats { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
.stats span { display: inline-flex; align-items: center; gap: 5px; }
.stats .i { color: var(--accent); }
.stats .w, .stats .w .i { color: var(--warn); }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }
.replay-note { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); }

/* Composer */
.composer { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 24px 18px; z-index: 3; background: linear-gradient(transparent, var(--bg) 40%); padding-top: 40px; }
.comp-box { max-width: 800px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 8px; border-radius: 22px; border: 1px solid var(--line-2); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(20px) saturate(1.4); box-shadow: var(--shadow-lg), var(--hi); transition: border-color .2s, box-shadow .2s; }
.comp-box:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-lg); }
.city-pill { display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 6px 0 12px; border-radius: 14px; background: var(--surface-2); color: var(--ink-2); font-size: 14px; flex: none; }
.city-pill .i { color: var(--accent); }
.city-pill select { border: 0; background: transparent; font-weight: 550; padding-right: 4px; cursor: pointer; }
.city-pill select:focus { outline: none; }
#q { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 15.5px; padding: 8px 6px; }
#q:focus { outline: none; }
#q::placeholder { color: var(--faint); }
.send { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; border: 0; background: var(--ink); color: var(--bg); flex: none; transition: transform .15s; }
.send:hover { transform: scale(1.04); }
.send .i { width: 18px; height: 18px; }
.comp-hint { max-width: 800px; margin: 10px auto 0; display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); }

/* Inspector */
.inspector { position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 100vw; z-index: 20; display: flex; flex-direction: column; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(24px) saturate(1.4); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.insp-open .inspector { transform: none; }
.inspector > header { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); font-size: 14px; }
.insp-body { flex: 1; overflow: auto; padding: 12px; display: grid; gap: 8px; align-content: start; }
.insp-item { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); transition: box-shadow .3s, border-color .3s; }
.insp-item.focus { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.insp-item header { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.insp-item header b { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--accent); }
.insp-item h4 { margin: 8px 0 6px; font-size: 13.5px; line-height: 1.45; font-weight: 600; }
.insp-item h4 a { color: var(--ink); }
.insp-item h4 a:hover { color: var(--accent); }
.insp-item h4 .i { width: 12px; height: 12px; color: var(--faint); }
.insp-item p { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.insp-item footer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.insp-item footer span { display: inline-flex; align-items: center; gap: 4px; }
.insp-item .used { font-family: var(--font); background: var(--accent-soft); color: var(--accent); padding: 1px 7px; border-radius: 999px; }

.scrim { display: none; }
.dlg { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); width: min(380px, calc(100vw - 32px)); padding: 20px; box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(6px); }
.dlg h3 { margin: 0 0 6px; font-size: 17px; }
.dlg input { width: 100%; margin: 14px 0; height: 42px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 15px; }
.dlg-row { display: flex; justify-content: flex-end; gap: 8px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Mobile */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .only-m { display: inline-grid; }
  .side { position: fixed; inset: 0 auto 0 0; width: 288px; z-index: 30; transform: translateX(-105%); transition: transform .3s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-lg); }
  .side-open .side { transform: none; }
  .side-open .scrim, .insp-open .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.3); }
  .side-open .scrim { z-index: 25; }
  .main-top { padding: 0 12px; }
  .top-actions .btn span { display: none; }
  #sources-btn { display: none; }
  .thread { padding: 8px 16px 170px; }
  #empty h1 { font-size: 28px; }
  .suggests { grid-template-columns: 1fr; }
  .composer { padding: 32px 12px calc(12px + env(safe-area-inset-bottom)); }
  .steps li { grid-template-columns: 18px 1fr auto; }
  .steps .st-label, .steps .pill { display: none; }
  .bubble-u { max-width: 88%; }
  .msg { gap: 10px; }
  .avatar { width: 26px; height: 26px; }
  .inspector { width: 100vw; }
}
