/* ═══════════════════════════════════════════════════════════════
   Personal AI · styles
   Tokens first; light is the default, dark via [data-theme="dark"].
   MOBILE FIRST: base rules are the phone layout. Bigger screens add to it
   with min-width queries at the end (381px, 561px tablet, 961px desktop, 1181px wide).
   No blur filters or always-on animations (keeps scrolling smooth).
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #f7f7f5;
  --bg-2: #f2f2ef;
  --surface: #ffffff;
  --surface-2: #f6f6f4;
  --surface-3: #eeeeeb;
  --border: #e9e9e5;
  --border-2: #dcdcd7;
  --text: #18181b;
  --text-2: #5d5d66;
  --text-3: #93939c;
  --bubble: #efefec;

  --accent: #18181b;
  --accent-hover: #000000;
  --accent-ink: #18181b;
  --accent-soft: #efefec;
  --on-accent: #ffffff;
  --mark-bg: #0a0a0b;
  --mark-fg: #ffffff;
  --mark-edge: rgba(0, 0, 0, 0.25);

  --pos: #198754;
  --neg: #d13a4a;
  --warn: #b26b00;

  --k-out: #e0533d;
  --k-in: #239063;
  --k-transfer: #0891b2;
  --k-log: #cc8a00;
  --k-event: #2563eb;
  --k-task: #67707e;
  --k-done: #239063;
  --k-bell: #e4741b;
  --k-note: #0f9a8a;

  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05), 0 2px 6px -2px rgba(24, 24, 27, 0.06);
  --shadow-md: 0 2px 4px rgba(24, 24, 27, 0.04), 0 8px 24px -8px rgba(24, 24, 27, 0.12);
  --shadow-lg: 0 4px 8px rgba(24, 24, 27, 0.04), 0 24px 56px -16px rgba(24, 24, 27, 0.22);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --topbar-h: 56px;
  --overview-w: 360px;
  --col: 760px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111113;
  --bg-2: #0d0d0f;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --surface-3: #2a2a2f;
  --border: #26262b;
  --border-2: #34343a;
  --text: #ededef;
  --text-2: #a5a5ae;
  --text-3: #6f6f78;
  --bubble: #232328;

  --accent: #ededef;
  --accent-hover: #ffffff;
  --accent-ink: #ededef;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --on-accent: #111113;
  --mark-edge: rgba(255, 255, 255, 0.14);

  --pos: #3dc287;
  --neg: #f2697a;
  --warn: #f0a33a;

  --k-out: #f07a63;
  --k-in: #3dc287;
  --k-transfer: #3cc0dc;
  --k-log: #e8b23a;
  --k-event: #6a9cf5;
  --k-task: #9aa3b2;
  --k-done: #3dc287;
  --k-bell: #f39a4f;
  --k-note: #3cc4b2;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.3), 0 24px 56px -16px rgba(0, 0, 0, 0.7);

  color-scheme: dark;
}

/* ─── Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overscroll-behavior: none; }
/* The page itself never moves; only the panes scroll (sign-in and setup pages scroll normally). */
body { position: fixed; inset: 0; overflow: hidden; }
body:has(.welcome:not(.hidden)), body:has(.onboarding:not(.hidden)) { position: static; overflow: auto; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* No zoom: scrolling only (no pinch, no double-tap) on every element. */
*, *::before, *::after { touch-action: pan-x pan-y; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  /* Native feel: app chrome is not selectable and long-press does not pop the browser menu. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* Content people may want to copy stays selectable. */
input, textarea, select, .answer-text, .msg-body, .item-text, .item-title, .menu-email {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
img, svg { -webkit-user-drag: none; user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
button:disabled { cursor: default; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.hidden { display: none !important; }

.ic {
  display: block; width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--text-2); }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font: 500 11px/1 var(--font); color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px;
}

/* ─── Brand ─── */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { display: none; font-weight: 650; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.welcome-copy .brand-name { display: inline; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: inline-grid; place-items: center; color: var(--mark-fg);
  background: var(--mark-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 0 1px var(--mark-edge), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.brand-mark .ic { width: 18px; height: 18px; }
.ic.logo { stroke: none; }
.brand-mark.lg { width: 44px; height: 44px; border-radius: 13px; }
.brand-mark.lg .ic { width: 28px; height: 28px; }
.brand-mark.xl { width: 52px; height: 52px; border-radius: 15px; }
.brand-mark.xl .ic { width: 34px; height: 34px; }

/* ─── Buttons & controls ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r);
  font-weight: 600; font-size: 15px; letter-spacing: -0.005em; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-accent) transparent var(--on-accent) var(--on-accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  display: inline-grid; place-items: center; color: var(--text-2);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 13.5px; font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}
.chip .ic { width: 15px; height: 15px; }
.chip:hover { border-color: var(--border-2); color: var(--text); }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
/* Suggestion chips in a reply can be long: wrap inside the screen instead of widening the chat. */
.chip-wrap .chip { white-space: normal; height: auto; min-height: 36px; padding-block: 7px; max-width: 100%; text-align: left; overflow-wrap: anywhere; line-height: 1.35; }
body.chat-busy .chip, body.chat-busy .starter, body.chat-busy .cat-bar { opacity: 0.55; pointer-events: none; }

.mini-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.mini-btn .ic { width: 14px; height: 14px; }
.mini-btn:hover { background: var(--surface-2); }
.mini-btn:disabled { opacity: 0.5; }

.input, .select {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-2); color: var(--text); font-size: 16px; /* iOS zooms into smaller fields */
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: var(--ring); }
.select {
  appearance: none; cursor: pointer; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2393939c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input::placeholder, textarea::placeholder { color: var(--text-3); }

/* ─── Boot ─── */
.boot { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 16px; background: var(--bg); z-index: 50; }
.boot-note { font-size: 14px; color: var(--text-2); }
.boot .brand-mark { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.92); opacity: 0.7; } }

/* ═══════════════════════════════════════
   WELCOME
   ═══════════════════════════════════════ */
.welcome {
  min-height: 100dvh; display: grid; place-items: start center; padding: max(48px, env(safe-area-inset-top)) 20px 32px;
  background:
    radial-gradient(900px 500px at 85% 10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(700px 500px at 0% 100%, color-mix(in srgb, var(--k-note) 6%, transparent), transparent 70%),
    var(--bg);
}
.welcome-inner {
  width: 100%; max-width: 520px;
  display: grid; grid-template-columns: 1fr; gap: 40px; align-items: center;
  animation: rise 0.6s var(--ease) both;
}
.welcome-copy .brand { margin-bottom: 28px; }
.welcome-title { font-size: clamp(36px, 5vw, 52px); line-height: 1.06; font-weight: 680; letter-spacing: -0.035em; margin-bottom: 18px; }
.welcome-tagline { font-size: 17px; line-height: 1.6; color: var(--text-2); max-width: 470px; margin-bottom: 32px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 400px; }
.auth-form .btn { height: 48px; margin-top: 4px; }
.link-btn { align-self: flex-start; font-size: 13.5px; font-weight: 550; color: var(--text-2); padding: 4px 0; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; margin: 2px 0; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border-2); }
.btn-google { height: 48px; gap: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow-sm); font-size: 15px; }
.btn-google:hover:not(:disabled) { box-shadow: var(--shadow-md); border-color: var(--text-3); }
.btn-google.loading::after { border-color: var(--text-2) transparent var(--text-2) var(--text-2); }
.welcome-points { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 36px; color: var(--text-2); font-size: 14px; }
.welcome-points li { display: flex; align-items: center; gap: 10px; }
.welcome-points .ic { width: 16px; height: 16px; color: var(--accent); stroke-width: 2.2; }

.welcome-demo { position: relative; display: none; }
.demo-window {
  background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
}
.demo-msg { display: flex; }
.demo-msg.user { justify-content: flex-end; }
.demo-msg.user span { background: var(--bubble); padding: 9px 14px; border-radius: 16px 16px 4px 16px; font-size: 14px; }
.demo-card {
  display: flex; align-items: center; gap: 12px; width: 84%;
  border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; background: var(--surface);
}
.demo-stat { flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px 16px; }
.demo-stat-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.demo-stat-value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.demo-bars { display: flex; align-items: flex-end; gap: 3px; height: 40px; width: 100%; margin-top: 8px; }
.demo-bars i { flex: 1; background: color-mix(in srgb, var(--accent) 25%, transparent); border-radius: 3px 3px 1px 1px; }
.demo-bars i:nth-child(8) { background: var(--accent); }

/* ═══════════════════════════════════════
   ONBOARDING
   ═══════════════════════════════════════ */
.onboarding {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  display: grid; place-items: center; padding: 24px 16px; background: var(--bg);
}
.onboarding-card {
  width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 22px 18px;
  animation: rise 0.45s var(--ease) both;
}
.onboard-step { display: flex; flex-direction: column; }
.onboarding-card h2 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.onboard-desc { font-size: 14.5px; color: var(--text-2); line-height: 1.55; margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; }
.onboard-tz { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin: 14px 0 24px; }
.onboard-tz .ic { width: 16px; height: 16px; color: var(--text-3); }
.onboard-tz strong { color: var(--text); font-weight: 600; }

/* ═══════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════ */
.app {
  height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--bg);
  grid-template-rows: calc(var(--topbar-h) + env(safe-area-inset-top)) minmax(0, 1fr) auto; /* top bar · view · tab bar */
}

.topbar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border); background: var(--bg);
}
/* Phone: a plain search icon. Desktop: a full search field (see min-width: 961px). */
.search-trigger {
  display: flex; align-items: center; justify-content: center; justify-self: end; gap: 10px;
  width: 40px; height: 40px; padding: 0; border-radius: 10px;
  background: none; border: 1px solid transparent; color: var(--text-2);
  font-size: 14px; transition: border-color 0.15s;
}
.search-trigger .ic { width: 18px; height: 18px; }
.search-trigger-text, .search-trigger .kbd { display: none; }
.search-trigger .kbd { margin-left: auto; }
.topbar-actions { display: flex; align-items: center; gap: 4px; justify-self: end; }

.theme-sun { display: none; }
:root[data-theme="dark"] .theme-sun { display: block; }
:root[data-theme="dark"] .theme-moon { display: none; }

.offline-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; margin-right: 4px;
  border-radius: 99px; font-size: 12px; font-weight: 600;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.offline-pill .ic { width: 14px; height: 14px; }

.account-menu { position: relative; margin-left: 4px; }
.avatar-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; }
.avatar-btn:hover .avatar { box-shadow: 0 0 0 3px var(--surface-3); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  display: grid; place-items: center; font-size: 13px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent-ink); transition: box-shadow 0.15s;
}
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 240px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg);
  animation: pop 0.14s var(--ease) both; transform-origin: top right;
}
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-name { font-weight: 600; font-size: 14px; }
.menu-email { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 10px; border-radius: 8px; font-size: 14px; color: var(--text); }
.menu-item .ic { width: 16px; height: 16px; color: var(--text-2); }
.menu-item:hover { background: var(--surface-2); }

.app-body { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }
/* Phone: one view at a time, switched by the tab bar. */
.view-chat .overview, .view-overview .chat { display: none; }

/* ═══════════════════════════════════════
   CHAT
   ═══════════════════════════════════════ */
.chat { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.feed {
  flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left));
}

/* Empty state */
.empty-chat {
  margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 24px 0; animation: rise 0.5s var(--ease) both;
}
.empty-chat .brand-mark { margin-bottom: 20px; }
.empty-title { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.2; }
.empty-sub { color: var(--text-2); margin-top: 6px; margin-bottom: 28px; }
.starter-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; width: 100%; }
.starter {
  display: flex; align-items: center; gap: 12px; padding: 14px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s var(--ease);
}
.starter:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.starter:nth-child(n + 5) { display: none; }
.starter-text { display: flex; flex-direction: column; min-width: 0; }
.starter-text strong { font-size: 13.5px; font-weight: 600; }
.starter-text span { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Messages */
.msg { display: flex; gap: 10px; animation: rise 0.28s var(--ease) both; }
.msg-col { display: flex; flex-direction: column; min-width: 0; max-width: 100%; }
.msg-body { min-width: 0; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg.user .msg-col { align-items: flex-end; max-width: 88%; }
.msg.user .msg-body {
  background: var(--bubble); padding: 10px 15px; border-radius: 18px 18px 6px 18px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.ai .msg-col { flex: 1; padding-top: 3px; }
.msg-avatar {
  width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.msg-avatar .ic { width: 15px; height: 15px; stroke-width: 2; }
.msg-meta {
  display: flex; align-items: center; gap: 4px; margin-top: 2px; min-height: 24px; margin-bottom: -8px;
  font-size: 11.5px; color: var(--text-3); opacity: 0; transition: opacity 0.15s;
}
.msg:hover .msg-meta, .msg:focus-within .msg-meta { opacity: 1; }
.msg-act { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; color: var(--text-3); }
.msg-act .ic { width: 14px; height: 14px; }
.msg-act:hover { background: var(--surface-3); color: var(--text); }

/* Typing */
.typing-dots { display: flex; gap: 4px; align-items: center; height: 28px; padding: 0 4px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: dot 1.1s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

.jump-latest {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 5;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); color: var(--text-2);
}
.jump-latest:hover { color: var(--text); }

/* Composer */
.composer-wrap { padding: 4px max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left)); }
.quick-row { display: flex; gap: 6px; margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin-left: -2px; }
.quick-row::-webkit-scrollbar { display: none; }
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 6px 6px 16px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 24px; box-shadow: var(--shadow-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within { border-color: var(--text-3); box-shadow: var(--shadow-md), var(--ring); }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: none; background: transparent; outline: none;
  font-size: 16px; line-height: 1.5; padding: 8px 0; max-height: 200px; min-height: 40px;
}
.composer-side { display: flex; align-items: center; gap: 8px; }
.char-count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); transition: background-color 0.15s, transform 0.1s;
}
.send-btn .ic { width: 18px; height: 18px; stroke-width: 2.2; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-3); }
.composer-hint { display: none; justify-content: center; gap: 16px; margin-top: 8px; font-size: 11.5px; color: var(--text-3); }
.composer-hint span { display: inline-flex; align-items: center; gap: 4px; }
.composer-hint .kbd { height: 18px; min-width: 18px; font-size: 10.5px; }

/* ─── Chat results (renderers.js) ─── */
.result-title { display: flex; align-items: center; gap: 8px; font-weight: 600; line-height: 1.4; }
.result-icon { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.result-icon .ic { width: 13px; height: 13px; stroke-width: 2.4; }
.t-pos { background: color-mix(in srgb, var(--pos) 14%, transparent); color: var(--pos); }
.t-neg { background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); }
.t-accent { background: var(--accent-soft); color: var(--accent-ink); }
.result-sub { margin: 2px 0 0 30px; font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.hint { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); margin-top: 10px; }
.hint .ic { width: 14px; height: 14px; }
.clarify { display: flex; flex-direction: column; gap: 12px; }

.item-list {
  display: flex; flex-direction: column; margin-top: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs); overflow: hidden;
}
.item-list > .item-row + .item-row { border-top: 1px solid var(--border); }
.item-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-width: 0; }
.item-row.deleted .item-title { text-decoration: line-through; color: var(--text-2); }

.item-icon {
  --k: var(--k-task);
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  color: var(--k); background: color-mix(in srgb, var(--k) 12%, transparent);
}
.item-icon .ic { width: 17px; height: 17px; stroke-width: 2; }
.k-out { --k: var(--k-out); } .k-in { --k: var(--k-in); } .k-transfer { --k: var(--k-transfer); }
.k-log { --k: var(--k-log); } .k-event { --k: var(--k-event); } .k-task { --k: var(--k-task); }
.k-done { --k: var(--k-done); } .k-bell { --k: var(--k-bell); } .k-note { --k: var(--k-note); }

.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item-title { font-weight: 550; font-size: 14.5px; overflow-wrap: anywhere; line-height: 1.35; }
.item-title::first-letter { text-transform: uppercase; }
.item-meta { font-size: 12.5px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta .dot { opacity: 0.7; margin: 0 5px; }
.item-cat { color: var(--text-2); }
.item-tags { color: var(--accent-ink); opacity: 0.85; }
.overdue { color: var(--neg); font-weight: 550; }
.item-text { font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; line-height: 1.5; }
.item-right { display: flex; align-items: center; gap: 6px; flex: none; }
.item-amount { font-weight: 600; font-size: 14.5px; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
.item-amount.in { color: var(--pos); }
.item-amount.muted { color: var(--text-2); font-weight: 550; }
.when-pill { font-size: 12px; font-weight: 550; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 7px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.badge.missed { color: var(--neg); background: color-mix(in srgb, var(--neg) 12%, transparent); }
.row-action {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-3); border: 1px solid var(--border); background: var(--surface); opacity: 0; transition: opacity 0.15s;
}
.row-action .ic { width: 15px; height: 15px; stroke-width: 2.2; }
.row-action:hover { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 40%, var(--border)); }
.item-row:hover .row-action, .row-action:focus-visible { opacity: 1; }
@media (hover: none) { .row-action, .msg-meta { opacity: 1; } }

.sum-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
/* Records an answer is based on (ANSWER route) */
.basis { margin-top: 12px; }
.basis-title { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
details.basis > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; }
details.basis > summary::-webkit-details-marker { display: none; }
details.basis > summary::before { content: "▸"; font-size: 10px; transition: transform 0.15s; }
details.basis[open] > summary::before { transform: rotate(90deg); }
.sum-pill { font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 5px 10px; }
.sum-pill strong { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; margin-left: 2px; }
.sum-pill strong.pos { color: var(--pos); }

.stats { display: flex; flex-direction: column; gap: 12px; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metrics .metric:last-child { grid-column: span 2; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; box-shadow: var(--shadow-xs); }
.metric-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.metric-value { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breakdown { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; box-shadow: var(--shadow-xs); }
.breakdown-row { display: grid; grid-template-columns: minmax(70px, 120px) 1fr auto; gap: 12px; align-items: center; padding: 6px 0; font-size: 13.5px; }
.breakdown-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-name::first-letter { text-transform: uppercase; }
.breakdown-val { font-variant-numeric: tabular-nums; font-weight: 550; text-align: right; white-space: nowrap; }
.bar-track { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.acct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.acct-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.acct-tile .acct-name { font-size: 12px; color: var(--text-3); text-transform: capitalize; }
.acct-tile .acct-amount { font-weight: 650; font-variant-numeric: tabular-nums; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; font-size: 14px; color: var(--text-2); }
.total-row strong { font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.msg.is-error .msg-avatar { background: color-mix(in srgb, var(--neg) 12%, transparent); color: var(--neg); }
.error-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--neg) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--neg) 22%, transparent);
  color: var(--text); font-size: 14px;
}
.error-box > .ic { color: var(--neg); width: 17px; height: 17px; }
.error-box > span { flex: 1; min-width: 160px; }

/* ═══════════════════════════════════════
   OVERVIEW
   ═══════════════════════════════════════ */
.overview {
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; background: var(--bg);
  padding: 14px max(12px, env(safe-area-inset-right)) 20px max(12px, env(safe-area-inset-left));
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px 16px; box-shadow: var(--shadow-xs); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; min-height: 22px; }
.card-head h3 { font-size: 13.5px; font-weight: 650; letter-spacing: -0.005em; }
.card-sub { font-size: 12.5px; color: var(--text-3); }
.card-total { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.count-pill { font-size: 12px; font-weight: 600; min-width: 22px; height: 20px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.count-pill:empty { display: none; }
.mini-label { font-size: 12px; font-weight: 600; color: var(--text-3); margin: 14px 0 4px; }

.kpi { display: flex; flex-direction: column; gap: 10px; }
.kpi-main { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 680; letter-spacing: -0.03em; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-side { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi-side > div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.kpi-side > div { display: flex; flex-direction: column; }
.kpi-side strong { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

.spark {
  position: relative; display: flex; align-items: flex-end; gap: 2px; height: 72px; margin-top: 16px;
  border-bottom: 1px solid var(--border-2);
}
.spark-col { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 4px 4px 0 0; cursor: default; }
.spark-col i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--accent) 32%, var(--surface)); transition: background-color 0.12s; }
.spark-col.today i { background: var(--accent); }
.spark-col.future i { background: transparent; }
.spark-col:hover { background: var(--surface-2); }
.spark-col:hover i { background: var(--accent); }
.spark-avg { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--text-3); opacity: 0.6; pointer-events: none; z-index: 1; }
.spark-axis { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.spark-axis span { display: inline-flex; align-items: center; gap: 6px; }
.avg-key { display: inline-block; width: 12px; border-top: 1px dashed var(--text-3); }

.cat-bars { display: flex; flex-direction: column; }
.cat-bar {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; width: calc(100% + 16px);
  padding: 9px 8px; margin: 0 -8px; border-radius: 8px; text-align: left; font-size: 13px;
  transition: background-color 0.12s;
}
.cat-bar:hover { background: var(--surface-2); }
.cat-bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.cat-bar-name::first-letter { text-transform: uppercase; }
.cat-bar-value { font-variant-numeric: tabular-nums; font-weight: 550; color: var(--text-2); }

.item-list.compact { margin: 0 -8px; background: none; border: none; box-shadow: none; border-radius: 0; gap: 0; overflow: visible; }
.item-list.compact > .item-row + .item-row { border-top: none; }
.item-list.compact .item-row { padding: 9px 8px; border-radius: 10px; gap: 10px; transition: background-color 0.12s; }
.item-list.compact .item-row:hover { background: var(--surface-2); }
.item-list.compact .item-icon { width: 30px; height: 30px; border-radius: 9px; }
.item-list.compact .item-icon .ic { width: 15px; height: 15px; }
.item-list.compact .item-title { font-size: 13.5px; }
.item-list.compact .item-meta { font-size: 12px; }
.item-list.compact .item-amount { font-size: 13.5px; }

.acct-list { display: flex; flex-direction: column; }
.acct-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; font-size: 13.5px; }
.acct-row + .acct-row { border-top: 1px solid var(--border); }
.acct-badge { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--text-2); }
.acct-row .acct-name { text-transform: capitalize; }
.acct-row .acct-amount { font-weight: 600; font-variant-numeric: tabular-nums; }

.empty { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-3); padding: 4px 0; }
.empty .ic { width: 16px; height: 16px; }

.banner {
  background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--r-lg); padding: 12px 10px 12px 14px;
}
.banner-row { display: flex; gap: 12px; align-items: flex-start; }
.banner-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-ink); }
.banner-icon .ic { width: 16px; height: 16px; }
.banner-body { flex: 1; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.notify-text { font-size: 13px; line-height: 1.5; color: var(--text-2); }
.notify-text strong { color: var(--text); font-weight: 600; }

/* Skeletons (until the first snapshot) */
.skel { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel + .skel { margin-top: 8px; }
.skel-row { height: 36px; }
.skel-kpi { height: 44px; width: 60%; }
.skel-chart { height: 64px; margin-top: 16px !important; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── Tab bar (phones; hidden on desktop) ─── */
.tabbar {
  display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 7px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.tab .ic { width: 21px; height: 21px; }
.tab.active { color: var(--accent-ink); }
.tab.active .ic { stroke-width: 2.2; }
/* View switch: a short fade, like switching tabs in a native app. */
.view-chat .chat, .view-overview .overview { animation: fade 0.18s ease both; }

/* ═══════════════════════════════════════
   PALETTE · TOOLTIP · TOASTS
   ═══════════════════════════════════════ */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start;
  padding: 8vh 16px 16px; background: rgba(16, 16, 20, 0.28); animation: fade 0.12s ease both;
}
:root[data-theme="dark"] .palette-backdrop { background: rgba(0, 0, 0, 0.55); }
.palette {
  width: 100%; max-width: 600px; max-height: 76vh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop 0.16s var(--ease) both;
}
.palette-search { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 54px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette-search input { flex: 1; min-width: 0; height: 100%; border: none; background: transparent; outline: none; font-size: 16px; color: var(--text); }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 10px; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--text); }
.palette-item .ic { width: 17px; height: 17px; color: var(--text-3); }
.palette-item.active { background: var(--surface-3); }
.palette-item.active .ic { color: var(--text); }
.palette-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-label::first-letter { text-transform: uppercase; }
.palette-hint { display: none; margin-left: auto; font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.palette-foot { display: none; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-3); background: var(--surface-2); }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

.tooltip {
  position: fixed; left: 0; top: 0; z-index: 300; pointer-events: none;
  padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 550; white-space: nowrap;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-md); font-variant-numeric: tabular-nums;
}

.toast-container {
  position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + var(--topbar-h) + 8px);
  z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 32px));
  padding: 11px 16px 11px 14px; border-radius: 12px; font-size: 14px; font-weight: 500;
  background: #1c1c20; color: #f4f4f5; box-shadow: var(--shadow-lg); pointer-events: auto;
  opacity: 0; transform: translateY(-8px) scale(0.98); transition: opacity 0.22s var(--ease), transform 0.22s var(--ease);
}
:root[data-theme="dark"] .toast { background: #2a2a30; border: 1px solid #36363d; }
.toast.show { opacity: 1; transform: none; }
.toast .ic { width: 17px; height: 17px; color: #4fd197; }
.toast.error .ic { color: #ff7a88; }

/* ─── Motion ─── */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media (hover: hover) and (pointer: fine) {
  .send-btn:not(:disabled) { box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent); }
}

/* Inputs that sit inside a framed control show focus on the frame instead. */
.palette-search input:focus-visible, .composer textarea:focus-visible { outline: none; }

/* Voice input */
.mic-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  color: var(--text-2); transition: background-color 0.15s, color 0.15s;
}
.mic-btn .ic { width: 24px; height: 24px; stroke-width: 2; }
/* One button at a time: mic while the box is empty, send once there is text
   (the mic stays while listening, so it can be stopped). No mic → send always shows. */
.composer:not(.has-text) .mic-btn:not(.hidden) + .send-btn { display: none; }
.composer.has-text .mic-btn:not(.listening) { display: none; }
.mic-btn:hover { background: var(--surface-3); color: var(--text); }
.mic-btn.listening { background: var(--neg); color: #fff; animation: mic-pulse 1.4s ease-out infinite; }
@keyframes mic-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--neg) 45%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
.composer-side { gap: 4px; }

/* ═══════════════════════════════════════
   NATIVE APP FEEL (touch)
   ═══════════════════════════════════════ */
/* Press feedback instead of hover on touch screens. */
@media (hover: none) {
  .btn, .chip, .mini-btn, .icon-btn, .avatar-btn, .send-btn, .mic-btn, .tab, .starter, .menu-item,
  .palette-item, .row-action, .msg-act, .cat-bar, .item-list.compact .item-row, .jump-latest, .search-trigger {
    transition: transform 0.12s var(--ease), background-color 0.12s, opacity 0.12s;
  }
  .btn:active:not(:disabled), .chip:active, .mini-btn:active, .starter:active, .send-btn:active:not(:disabled),
  .mic-btn:active, .row-action:active, .jump-latest:active { transform: scale(0.96); }
  .icon-btn:active, .avatar-btn:active, .msg-act:active, .search-trigger:active { background: var(--surface-3); transform: scale(0.92); }
  .menu-item:active, .palette-item:active, .cat-bar:active, .item-list.compact .item-row:active { background: var(--surface-3); }
  .tab:active .ic { transform: scale(0.88); }
  .tab .ic { transition: transform 0.12s var(--ease); }
  /* Hover styles stick after a tap on touch screens: neutralise the lifts. */
  .starter:hover { transform: none; box-shadow: var(--shadow-xs); }
}

/* Touch screens: scrollbars hidden like in native apps; momentum scrolling stays. */
@media (pointer: coarse) {
  .feed, .overview, .palette-list { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .feed::-webkit-scrollbar, .overview::-webkit-scrollbar, .palette-list::-webkit-scrollbar { display: none; }
}

/* iOS zooms into a focused field under 16px (iPads too, which are wider than 960px). */
@media (pointer: coarse) {
  input, textarea, select, .composer textarea, .palette-search input, .input, .select { font-size: 16px; }
}

/* ═══════════════════════════════════════
   BIGGER SCREENS (mobile first: these only add to the phone layout above)
   ═══════════════════════════════════════ */

/* ≥ 381px: normal phones */
@media (min-width: 381px) {
  .topbar .brand-name { display: inline; }
  .kpi-value { font-size: 30px; }
  .chip { padding: 0 14px; }
}

/* ≥ 561px: large phones in landscape, small tablets */
@media (min-width: 561px) {
  .empty-title { font-size: 28px; }
  .starter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .starter:nth-child(n + 5) { display: flex; }
  .msg { gap: 12px; }
  .msg.user .msg-col { max-width: min(80%, 560px); }
  .msg-avatar { width: 28px; height: 28px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metrics .metric:last-child { grid-column: auto; }
  .onboarding-card { padding: 28px; }
  .welcome-copy .brand { margin-bottom: 40px; }
  .palette-backdrop { padding-top: 12vh; }
  .palette-hint { display: block; }
  .palette-foot { display: flex; }
}

/* ≥ 961px: desktop. Chat and overview side by side, no tab bar, denser controls. */
@media (min-width: 961px) {
  body { position: static; overflow: visible; }

  .welcome { place-items: center; padding: 32px 20px; }
  .welcome-inner { grid-template-columns: 1.05fr 1fr; max-width: 1080px; gap: 64px; }
  .welcome-demo { display: block; }

  .app { grid-template-rows: var(--topbar-h) minmax(0, 1fr); }
  .tabbar { display: none; }
  .topbar { grid-template-columns: 1fr minmax(0, 440px) 1fr; gap: 16px; padding: 0 16px 0 20px; }
  .search-trigger {
    justify-content: flex-start; justify-self: stretch; width: 100%; height: 36px; padding: 0 8px 0 12px;
    background: var(--surface); border-color: var(--border); color: var(--text-3); box-shadow: var(--shadow-xs);
  }
  .search-trigger:hover { border-color: var(--border-2); color: var(--text-2); }
  .search-trigger .ic { width: 16px; height: 16px; }
  .search-trigger-text { display: inline; }
  .search-trigger .kbd { display: inline-flex; }

  .app-body { grid-template-columns: minmax(0, 1fr) var(--overview-w); }
  .view-chat .overview, .view-overview .chat { display: flex; }
  .view-chat .chat, .view-overview .overview { animation: none; }
  .overview { gap: 12px; padding: 16px 16px 24px; border-left: 1px solid var(--border); background: var(--bg-2); }

  .feed { gap: 16px; padding: 28px max(20px, calc((100% - var(--col)) / 2)) 20px; }
  .composer-wrap { padding: 4px max(20px, calc((100% - var(--col)) / 2)) 14px; }
  .composer { padding: 8px 8px 8px 16px; border-radius: 22px; }
  .composer-hint { display: flex; }
  .jump-latest { bottom: 150px; }

  .icon-btn, .avatar-btn, .send-btn, .mic-btn { width: 36px; height: 36px; }
  .chip { height: 32px; padding: 0 12px; font-size: 13px; }
  .chip-wrap .chip { height: auto; min-height: 32px; padding-block: 5px; }
  .mini-btn { height: 26px; padding: 0 10px; }
  .row-action { width: 28px; height: 28px; }
  .msg-act { width: 24px; height: 24px; }
  .starter { padding: 12px; }
  .menu-item { height: 36px; }
  .palette-item { height: 40px; }
  .item-list.compact .item-row { padding: 7px 8px; }
  .cat-bar { padding: 6px 8px; }
  .spark { height: 64px; }

  .toast-container { left: auto; right: 20px; top: auto; bottom: 20px; align-items: flex-end; }
  .toast { transform: translateY(8px) scale(0.98); }
  .toast.show { transform: none; }
}

/* Desktop with a mouse: fields use the smaller desktop text (touch screens keep 16px against iOS zoom). */
@media (min-width: 961px) and (pointer: fine) {
  .input, .select, .composer textarea { font-size: 15px; }
  .composer textarea { min-height: 36px; padding: 7px 0; }
  .palette-search input { font-size: 15.5px; }
}

/* ≥ 1181px: wide desktop */
@media (min-width: 1181px) {
  :root { --overview-w: 392px; }
  .starter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
