/* Zell Chat — branding system. Primary #FF8800 (Zell orange), white mark. */
:root {
  --orange: #FF8800;
  --orange-600: #F07800;
  --orange-700: #D96C00;
  --orange-050: #FFF4E6;
  --orange-100: #FFE8CC;
  --ink: #1A1D21;
  --ink-2: #3A4048;
  --muted: #6B7480;
  --muted-2: #98A1AD;
  --line: #E7EAEE;
  --line-2: #EEF1F4;
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --shadow-sm: 0 1px 2px rgba(20,25,35,.06), 0 1px 3px rgba(20,25,35,.04);
  --shadow-md: 0 4px 16px rgba(20,25,35,.08), 0 2px 6px rgba(20,25,35,.05);
  --shadow-lg: 0 24px 60px rgba(20,25,35,.18);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --ease-in-out: cubic-bezier(.65, .05, .36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ══════════════════════════ LOGIN ══════════════════════════ */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.login-brand {
  position: relative;
  background: linear-gradient(150deg, #FF9A2E 0%, #FF8800 44%, #F07300 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px 60px;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  right: -180px; bottom: -180px;
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(255,255,255,.16) 0%, rgba(255,255,255,0) 62%);
  pointer-events: none;
}
.login-brand-mark { display: flex; align-items: center; gap: 14px; z-index: 1; }
.login-brand-mark img { width: 58px; height: 58px; }
.login-brand-mark .wordmark { display: inline-flex; align-items: baseline; gap: .24em; font-size: 31px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.login-brand-mark .wordmark span { font-weight: 500; opacity: .78; }
.login-brand-hero { z-index: 1; max-width: 460px; }
.login-brand-hero h1 { font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -.025em; margin: 0 0 18px; }
.login-brand-hero p { font-size: 17px; line-height: 1.55; margin: 0; color: rgba(255,255,255,.9); }
.login-brand-foot { z-index: 1; font-size: 13px; color: rgba(255,255,255,.75); }

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--surface);
}
.login-card { width: 100%; max-width: 380px; }
.login-card > .login-eyebrow { font-size: 13px; font-weight: 600; color: var(--orange-700); letter-spacing: .04em; text-transform: uppercase; margin: 0 0 8px; }
.login-card h2 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.login-card .login-sub { color: var(--muted); font-size: 15px; margin: 0 0 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 12px 14px;
  font-size: 15px; font-family: inherit; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-050); }
.btn-primary {
  width: 100%; padding: 13px 18px; margin-top: 6px;
  font-size: 15px; font-weight: 700; color: #fff;
  background: var(--orange); border: none; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); transition: background .15s, transform .05s;
}
.btn-primary:hover { background: var(--orange-600); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.login-error {
  display: none; margin-top: 16px; padding: 11px 14px;
  background: #FEF2F2; color: #B42318; border: 1px solid #FEE4E2;
  border-radius: var(--radius-sm); font-size: 14px;
}
.login-error.show { display: block; }

@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { padding: 40px 32px; min-height: 40vh; }
  .login-brand-hero h1 { font-size: 30px; }
}

/* ══════════════════════════ CHAT APP ══════════════════════════ */
.app { display: grid; grid-template-columns: 268px 1fr; height: 100dvh; transition: grid-template-columns .2s ease; }
.app.sb-collapsed { grid-template-columns: 0 1fr; }
.main { display: flex; flex-direction: column; height: 100dvh; min-width: 0; }

/* ── sidebar ── */
.sidebar { background: #FCFCFD; border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-head { padding: 15px 18px; }
.new-conv {
  display: flex; align-items: center; gap: 9px; margin: 0 12px 8px;
  padding: 11px 14px; font-size: 14px; font-weight: 600; color: #fff;
  background: var(--orange); border: none; border-radius: 11px; box-shadow: var(--shadow-sm);
  transition: background .15s;
}
.new-conv:hover { background: var(--orange-600); }
.new-conv svg { width: 16px; height: 16px; }
.conv-list { flex: 1; overflow-y: auto; padding: 6px 8px; }
.conv-list-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); padding: 8px 10px 6px; }
.conv {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; margin-bottom: 2px;
  border-radius: 9px; cursor: pointer; color: var(--ink-2); font-size: 13.5px;
  transition: background .12s;
}
.conv:hover { background: #F1F2F4; }
.conv.active { background: var(--orange-050); color: var(--orange-700); font-weight: 600; }
.conv .conv-ic { width: 15px; height: 15px; flex-shrink: 0; opacity: .6; }
.conv.active .conv-ic { opacity: 1; }
.conv .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .conv-del { width: 24px; height: 24px; border: none; background: none; color: var(--muted-2); border-radius: 6px; display: grid; place-items: center; opacity: 0; flex-shrink: 0; transition: opacity .12s, background .12s, color .12s; }
.conv:hover .conv-del { opacity: 1; }
.conv .conv-del:hover { background: #FEE4E2; color: #B42318; }
.conv .conv-del svg { width: 14px; height: 14px; }
.sidebar-foot { padding: 12px 18px; font-size: 11.5px; color: var(--muted-2); border-top: 1px solid var(--line-2); }
.conv-empty { padding: 18px 12px; font-size: 13px; color: var(--muted-2); text-align: center; }

/* icon-only button */
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid transparent; background: none; border-radius: 9px; color: var(--ink-2); transition: background .12s; }
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 19px; height: 19px; }
.toggle-sidebar-only { display: none; }

.appbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px; height: 62px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
  z-index: 10;
}
.appbar-mark { display: flex; align-items: center; gap: 11px; }
.appbar-logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--orange); display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(255,136,0,.35);
}
.appbar-logo img { width: 30px; height: 30px; }
.appbar-title { display: flex; flex-direction: column; line-height: 1.15; }
.appbar-title b { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.appbar-title small { font-size: 12px; color: var(--muted); }
.appbar-spacer { flex: 1; }
.appbar-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  transition: background .12s, border-color .12s;
}
.appbar-btn:hover { background: var(--bg); border-color: var(--muted-2); }
.appbar-btn svg { width: 15px; height: 15px; }

/* transcript */
.transcript { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.transcript-inner { max-width: 780px; margin: 0 auto; padding: 28px 22px 8px; }

.empty { padding: 44px 4px 8px; text-align: center; }
.empty-logo {
  width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 20px;
  background: var(--orange); display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(255,136,0,.32);
}
.empty-logo img { width: 52px; height: 52px; }
.empty h3 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 8px; }
.empty p { color: var(--muted); font-size: 15px; margin: 0 auto 26px; max-width: 440px; line-height: 1.5; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 560px; margin: 0 auto; text-align: left; }
.suggestion {
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; font-size: 14px; color: var(--ink-2); line-height: 1.4;
  transition: border-color .12s, box-shadow .12s, transform .06s;
}
.suggestion:hover { border-color: var(--orange); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.suggestion b { display: block; color: var(--ink); font-weight: 700; margin-bottom: 2px; font-size: 13px; }
@media (max-width: 560px) { .suggestions { grid-template-columns: 1fr; } }

/* messages */
.msg { margin-bottom: 22px; display: flex; flex-direction: column; }
.msg-user { align-items: flex-end; }
.msg-user .bubble {
  background: var(--orange); color: #fff;
  padding: 11px 16px; border-radius: 18px 18px 4px 18px;
  max-width: 82%; font-size: 15px; line-height: 1.5; white-space: pre-wrap;
  box-shadow: 0 2px 8px rgba(255,136,0,.28);
}
.msg-assistant { align-items: flex-start; }
.msg-assistant .who {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.msg-assistant .who .dot { width: 20px; height: 20px; border-radius: 6px; background: var(--orange); display: grid; place-items: center; }
.msg-assistant .who .dot img { width: 17px; height: 17px; }
.assistant-body { width: 100%; }

/* tool chips */
.tool {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 11px; margin: 3px 0; border-radius: 8px;
  background: var(--orange-050); border: 1px solid var(--orange-100);
  font-size: 12.5px; color: var(--orange-700); max-width: 100%;
}
.tool .tool-name { font-weight: 700; }
.tool .tool-sum { color: var(--ink-2); opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool.running { background: var(--orange-050); }
.tool .spin { width: 12px; height: 12px; border: 2px solid var(--orange-100); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-line { font-size: 12px; color: var(--muted-2); margin-top: 6px; }
.result-err { color: #B42318; }

/* markdown */
.md { font-size: 15px; line-height: 1.62; color: var(--ink); }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md .md-h { margin: 20px 0 10px; font-weight: 800; letter-spacing: -.01em; line-height: 1.3; }
.md h1.md-h { font-size: 21px; } .md h2.md-h { font-size: 18px; } .md h3.md-h { font-size: 16px; }
.md .md-ul, .md .md-ol { margin: 0 0 12px; padding-left: 22px; }
.md .md-ul li, .md .md-ol li { margin: 4px 0; }
.md a { color: var(--orange-700); text-decoration: none; border-bottom: 1px solid var(--orange-100); }
.md a:hover { border-bottom-color: var(--orange); }
.md strong { font-weight: 700; }
.md .md-code { background: var(--orange-050); color: var(--orange-700); padding: 1px 6px; border-radius: 5px; font-size: 13px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.md .md-pre { background: #1E2126; color: #E6E8EB; padding: 14px 16px; border-radius: 10px; overflow-x: auto; margin: 0 0 12px; }
.md .md-pre code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.55; background: none; color: inherit; padding: 0; }
.md .md-quote { border-left: 3px solid var(--orange); padding: 2px 0 2px 14px; margin: 0 0 12px; color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.md .md-table { border-collapse: collapse; width: 100%; margin: 0 0 14px; font-size: 14px; display: block; overflow-x: auto; }
.md .md-table th, .md .md-table td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.md .md-table th { background: var(--orange-050); font-weight: 700; color: var(--ink); white-space: nowrap; }
.md .md-table tr:nth-child(even) td { background: #FBFBFC; }

/* composer */
.composer-wrap { flex-shrink: 0; background: linear-gradient(to top, var(--bg) 60%, rgba(247,248,250,0)); padding: 8px 22px 20px; }
.composer { max-width: 780px; margin: 0 auto; }
.composer-box {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px;
  padding: 10px 10px 10px 16px; box-shadow: var(--shadow-md);
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-050), var(--shadow-md); }
.composer textarea {
  flex: 1; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 15px; line-height: 1.5; color: var(--ink);
  max-height: 180px; padding: 6px 0; background: none;
}
.composer textarea::placeholder { color: var(--muted-2); }
.send-btn {
  width: 38px; height: 38px; flex-shrink: 0; border: none; border-radius: 12px;
  background: var(--orange); color: #fff; display: grid; place-items: center;
  transition: background .15s, transform .05s;
}
.send-btn:hover { background: var(--orange-600); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { background: var(--line); color: var(--muted-2); cursor: default; }
.send-btn svg { width: 18px; height: 18px; }
.composer-foot { text-align: center; font-size: 11.5px; color: var(--muted-2); margin-top: 10px; }
.composer-foot .status-busy { color: var(--orange-700); font-weight: 600; }

/* brand in appbar: hidden on desktop (sidebar shows it), shown on mobile */
.appbar-mark-mobile { display: none; }

/* status pill (live activity during a turn — replaces inline tool chips) */
.status-pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 14px; margin: 2px 0; border-radius: 999px;
  background: var(--orange-050); border: 1px solid var(--orange-100);
  color: var(--orange-700); font-size: 13px; font-weight: 600;
}
.status-pill .spin { width: 13px; height: 13px; border: 2px solid var(--orange-100); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }

/* appbar button badge (notes count) */
.appbar-btn .badge { min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--orange); color: #fff; font-size: 10.5px; font-weight: 800; display: inline-grid; place-items: center; }

/* ── drawers (inspector + notes share the same shell) ── */
.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(460px, 96vw);
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 70;
  transform: translateX(100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
}
.app.insp-open .inspector { transform: none; }
.app.notes-open .notes-drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-head b { font-size: 15px; font-weight: 800; display: block; }
.drawer-head small { font-size: 12px; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; }

/* inspector content */
.insp-empty { padding: 40px 24px; text-align: center; color: var(--muted-2); font-size: 14px; line-height: 1.5; }
.insp-turn { padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.insp-q { font-size: 13.5px; font-weight: 700; color: var(--ink); margin-bottom: 12px; display: flex; gap: 7px; }
.insp-q .insp-q-badge { flex-shrink: 0; color: var(--orange); }
.insp-step { margin: 12px 0; }
.insp-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.insp-label svg { width: 12px; height: 12px; }
.insp-label .insp-err { color: #B42318; font-weight: 700; }
.insp-sql { background: #1E2126; color: #E6E8EB; padding: 11px 13px; border-radius: 9px 9px 0 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.insp-detail { font-size: 12px; color: var(--ink-2); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-word; white-space: pre-wrap; background: var(--bg); padding: 9px 11px; border-radius: 9px 9px 0 0; max-height: 150px; overflow: auto; }
.insp-result { background: #F4F5F7; border: 1px solid var(--line); border-top: none; border-radius: 0 0 9px 9px; padding: 9px 11px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }
.insp-result-head { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); margin: 6px 0 4px; }
.insp-none { font-size: 12.5px; color: var(--muted-2); font-style: italic; }

/* ── notes ── */
.note-card { background: #FCFCFD; border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; margin: 0 0 10px; }
.note-card .note-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.note-card .note-author { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.note-card .note-avatar { width: 20px; height: 20px; border-radius: 50%; background: var(--orange-100); color: var(--orange-700); font-size: 11px; font-weight: 800; display: grid; place-items: center; flex-shrink: 0; }
.note-card .note-time { font-size: 11.5px; color: var(--muted-2); margin-left: auto; }
.note-card .note-text { font-size: 13.5px; line-height: 1.5; color: var(--ink-2); white-space: pre-wrap; }
.note-card .note-on { font-size: 11.5px; color: var(--muted); font-style: italic; margin-bottom: 6px; }
.notes-group-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-2); padding: 14px 18px 6px; }
.notes-empty { padding: 36px 24px; text-align: center; color: var(--muted-2); font-size: 14px; line-height: 1.5; }
.note-compose { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.note-compose textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 14px; resize: none; outline: none; }
.note-compose textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-050); }
.btn-note { align-self: flex-end; padding: 9px 16px; font-size: 13.5px; font-weight: 700; color: #fff; background: var(--orange); border: none; border-radius: 9px; }
.btn-note:hover { background: var(--orange-600); }
.btn-note:disabled { opacity: .5; }

/* per-message note affordance in the transcript */
.msg-notes { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.msg-note { background: var(--orange-050); border: 1px solid var(--orange-100); border-radius: 10px; padding: 9px 12px; }
.msg-note .note-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.msg-note .note-author { font-size: 12px; font-weight: 700; color: var(--orange-700); }
.msg-note .note-time { font-size: 11px; color: var(--muted-2); margin-left: auto; }
.msg-note .note-text { font-size: 13px; line-height: 1.45; color: var(--ink-2); white-space: pre-wrap; }
.msg-actions { margin-top: 8px; }
.add-note-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 8px; transition: color .12s, border-color .12s, background .12s; }
.add-note-btn:hover { color: var(--orange-700); border-color: var(--orange-100); background: var(--orange-050); }
.add-note-btn svg { width: 13px; height: 13px; }
.note-inline-form { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; max-width: 520px; }
.note-inline-form textarea { border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 11px; font-family: inherit; font-size: 13.5px; resize: none; outline: none; }
.note-inline-form textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-050); }
.note-inline-actions { display: flex; gap: 8px; }
.note-inline-actions .btn-note { padding: 7px 13px; font-size: 13px; }
.note-inline-actions .btn-cancel { padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 8px; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 11px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── scrim (drawers + mobile sidebar) ── */
.scrim { position: fixed; inset: 0; background: rgba(20,25,35,.4); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 65; }
.app.insp-open .scrim, .app.notes-open .scrim { opacity: 1; pointer-events: auto; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 268px; z-index: 80; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.sb-open .sidebar { transform: none; }
  .app.sb-open .scrim { opacity: 1; pointer-events: auto; }
  .appbar-mark-mobile { display: flex; }
}

@media (max-width: 640px) {
  .transcript-inner { padding: 20px 16px 8px; }
  .composer-wrap { padding: 8px 14px 16px; }
  .appbar { padding: 0 12px; }
  .appbar-btn .label { display: none; }
}

/* ═══════════════════════ PRODUCT POLISH ═══════════════════════ */

/* ── Typography system: Space Grotesk display + Inter, tabular numbers ── */
.appbar-title b, .login-brand-mark span, .login-brand-hero h1, .login-card h2,
.empty h3, .md .md-h, .drawer-head b, .sidebar-head .appbar-title b {
  font-family: var(--font-display);
  letter-spacing: -.02em;
}
.md, .md-table, .bubble, .insp-result, .insp-sql, .note-text, .msg-note .note-text {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.md, .bubble, .note-text, .msg-note .note-text { overflow-wrap: break-word; }
.md-table th { letter-spacing: -.005em; }

/* smoother easing for the structural transitions */
.app { transition-timing-function: var(--ease); }
.sidebar, .drawer { transition-timing-function: var(--ease); }

/* ── Motion ── */
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes glowFloat { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-22px, -18px) scale(1.07); } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.msg-enter { animation: msgIn .3s var(--ease); }
.empty { animation: fadeIn .4s ease; }
.empty-logo { animation: floaty 4.5s ease-in-out infinite; }
.login-brand::after { animation: glowFloat 9s ease-in-out infinite; }
.login-card { animation: msgIn .45s var(--ease); }

/* micro-interactions */
.appbar-btn:active, .icon-btn:active { transform: translateY(1px); }
.suggestion:active { transform: translateY(0) scale(.99); }
.conv { transition: background .12s, transform .1s; }
.conv:active { transform: scale(.99); }
.new-conv:active { transform: translateY(1px); }
.add-note-btn:active, .btn-note:active { transform: translateY(1px); }
.send-btn svg { transition: transform .15s var(--ease); }
.send-btn:not(:disabled):hover svg { transform: translateX(1px) translateY(-1px); }

/* scrim gets a soft blur for depth */
.scrim { backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }

/* ── Appbar overflow menu (mobile) ── */
.appbar-more { position: relative; display: none; }
.more-menu {
  position: absolute; top: 44px; right: 0; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  box-shadow: var(--shadow-lg); z-index: 85; display: flex; flex-direction: column; gap: 2px;
  transform-origin: top right; animation: menuIn .14s var(--ease);
}
.more-menu[hidden] { display: none; }
.more-menu button {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 11px 13px; font-size: 14.5px; font-weight: 600; color: var(--ink-2);
  background: none; border: none; border-radius: 9px;
}
.more-menu button:hover { background: var(--bg); }
.more-menu button:active { background: var(--orange-050); }
.more-menu button svg { width: 17px; height: 17px; flex-shrink: 0; }

/* ── Mobile refinements (≤860px) ── */
@media (max-width: 860px) {
  /* prevent iOS zoom-on-focus: inputs ≥16px */
  .composer textarea, .field input, .note-compose textarea,
  .note-inline-form textarea, #conv-note-input { font-size: 16px; }

  /* safe-area insets (notch / home indicator) */
  .appbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .composer-wrap { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

  /* Login: show the full hero on mobile, app-like rounded banner */
  .login-wrap { grid-template-columns: 1fr; min-height: 100dvh; }
  .login-brand {
    min-height: auto; padding: 44px 26px 36px; gap: 22px;
    justify-content: flex-start; border-radius: 0 0 28px 28px;
  }
  .login-brand-mark img { width: 46px; height: 46px; }
  .login-brand-mark .wordmark { font-size: 26px; }
  .login-brand-hero h1 { font-size: 27px; margin-bottom: 12px; }
  .login-brand-hero p { font-size: 15px; }
  .login-brand-foot { display: none; }
  .login-panel { padding: 30px 22px calc(40px + env(safe-area-inset-bottom)); }
  .login-card { max-width: 440px; }
}

/* ── Compact appbar: collapse secondary actions into an overflow menu ── */
@media (max-width: 620px) {
  .appbar { gap: 4px; }
  #share, #toggle-inspector, .appbar > #logout { display: none; }
  .appbar-more { display: block; }
  .appbar-mark-mobile .appbar-title small { display: none; }
  .drawer { width: 100vw; border-left: none; }
}

/* ── Conversation loading state ── */
.transcript-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 90px 20px; color: var(--muted); font-size: 14px; animation: fadeIn .2s ease; }
.transcript-loading .spin-lg { width: 30px; height: 30px; border: 3px solid var(--orange-100); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── Accessibility: honor reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
