/* ============================================================
   Mav — dashboard styles
   Tokens first (light + dark), then layout, then components.
   ============================================================ */

:root {
  color-scheme: light;
  /* Mav brand v2 — "Midnight & Emerald".
     Ink: blue-black. Paper: warm white. Emerald = the brand, actions.
     Amber "signal" = proactive moments only (briefing, alerts, Pro). */
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --bg-sunk: #f3f2ee;
  --bg-hover: #eeede8;
  --ink: #0e1013;
  --ink-2: #4a4f57;
  --ink-3: #8a9099;
  --line: #e6e5df;
  --line-2: #efeee9;
  --accent: #0f7a5c;
  --accent-hover: #0b6449;
  --accent-soft: #e4f2ec;
  --accent-ink: #0a4a38;
  --on-accent: #ffffff;
  --signal: #e8962e;
  --signal-soft: #fdf1e1;
  --warm: #c46a2c;
  --warm-soft: #fbeee3;
  --danger: #c2412d;
  --danger-soft: #fbe7e3;
  --err: var(--danger);
  --ok: #16a06a;
  --warn: #d48a1c;
  --off: #b9bdc4;
  --user-bubble: #f0efea;
  --code-bg: #f4f3ef;
  --ring: 0 0 0 1px rgba(14, 16, 19, 0.06);
  --shadow-sm: 0 0 0 1px rgba(14, 16, 19, 0.05), 0 1px 2px rgba(14, 16, 19, 0.05);
  --shadow:
    0 0 0 1px rgba(14, 16, 19, 0.05), 0 1px 2px rgba(14, 16, 19, 0.04),
    0 12px 32px -12px rgba(14, 16, 19, 0.14);
  --shadow-lg:
    0 0 0 1px rgba(14, 16, 19, 0.06), 0 2px 6px rgba(14, 16, 19, 0.06),
    0 32px 72px -20px rgba(14, 16, 19, 0.28);
  --brand-1: #12936e;
  --brand-2: #0a4a38;

  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 9px;
  --radius-xs: 6px;

  --font: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Instrument Serif", Georgia, serif;
  --mono: "Geist Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --dur-fast: 120ms;
  --dur: 180ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-w: 268px;
}

/* Dark theme ("Midnight"): by system preference unless the user forced light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0d10;
    --bg-elev: #13161a;
    --bg-sunk: #0f1215;
    --bg-hover: #1a1e23;
    --ink: #eef0f2;
    --ink-2: #aab1ba;
    --ink-3: #747c86;
    --line: #22272d;
    --line-2: #1a1e23;
    --accent: #34d39d;
    --accent-hover: #5ee0b4;
    --accent-soft: #0f2a21;
    --accent-ink: #9ff0d1;
    --on-accent: #04140e;
    --signal: #f5b04f;
    --signal-soft: #2e2213;
    --warm: #eda06c;
    --warm-soft: #2e2016;
    --danger: #f0806d;
    --danger-soft: #331b17;
    --ok: #34d39d;
    --warn: #f5b04f;
    --user-bubble: #1a1e23;
    --code-bg: #0f1215;
    --ring: 0 0 0 1px rgba(255, 255, 255, 0.06);
    --shadow-sm: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow:
      0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.4),
      0 12px 32px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg:
      0 0 0 1px rgba(255, 255, 255, 0.07), 0 2px 6px rgba(0, 0, 0, 0.5),
      0 32px 72px -20px rgba(0, 0, 0, 0.75);
    --brand-1: #34d39d;
    --brand-2: #0b5a43;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d10;
  --bg-elev: #13161a;
  --bg-sunk: #0f1215;
  --bg-hover: #1a1e23;
  --ink: #eef0f2;
  --ink-2: #aab1ba;
  --ink-3: #747c86;
  --line: #22272d;
  --line-2: #1a1e23;
  --accent: #34d39d;
  --accent-hover: #5ee0b4;
  --accent-soft: #0f2a21;
  --accent-ink: #9ff0d1;
  --on-accent: #04140e;
  --signal: #f5b04f;
  --signal-soft: #2e2213;
  --warm: #eda06c;
  --warm-soft: #2e2016;
  --danger: #f0806d;
  --danger-soft: #331b17;
  --ok: #34d39d;
  --warn: #f5b04f;
  --user-bubble: #1a1e23;
  --code-bg: #0f1215;
  --ring: 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-sm: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.4),
    0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg:
    0 0 0 1px rgba(255, 255, 255, 0.07), 0 2px 6px rgba(0, 0, 0, 0.5),
    0 32px 72px -20px rgba(0, 0, 0, 0.75);
  --brand-1: #34d39d;
  --brand-2: #0b5a43;
}

/* ---------- Base ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  height: 100%;
}
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: none;
}
a {
  color: var(--accent);
}
code,
kbd {
  font-family: var(--mono);
  font-size: 0.85em;
}
kbd {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 0.3em;
  color: var(--ink-2);
}
::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--ink-3);
}

/* Icons (inline SVG, injected by app.js) */
i[data-i] {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  font-style: normal;
}
i[data-i] svg {
  width: 100%;
  height: 100%;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}
.content {
  min-width: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}
.view {
  display: none;
  height: 100%;
  overflow-y: auto;
}
.view.is-active {
  display: block;
  animation: viewIn 220ms var(--ease-out);
}
.view-chat.is-active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.4rem 2rem 4rem;
}
.topbar {
  display: none;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 0.8rem 0.8rem;
  background: var(--bg-sunk);
  border-right: 1px solid var(--line);
  min-height: 0;
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.4rem 0.4rem;
}
.brand-name {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
}
.sidebar-close {
  display: none;
}
.orb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(
      circle at 32% 28%,
      rgba(255, 255, 255, 0.9),
      transparent 42%
    ),
    linear-gradient(145deg, #2f6f5e, #7cc4ac);
  box-shadow: 0 0 0 0 rgba(47, 111, 94, 0.35);
  animation: breathe 4s ease-in-out infinite;
}
body.is-thinking .orb {
  animation: pulse 1.1s ease-in-out infinite;
}
.new-chat {
  width: 100%;
  justify-content: flex-start;
}
.new-chat .kbd-hint {
  margin-left: auto;
  background: transparent;
  border-color: color-mix(in srgb, var(--on-accent) 35%, transparent);
  color: color-mix(in srgb, var(--on-accent) 80%, transparent);
  font-size: 0.72rem;
}
.side-search {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: border-color var(--dur-fast) var(--ease);
}
.side-search:hover {
  border-color: var(--ink-3);
  color: var(--ink-2);
}
.side-search kbd {
  margin-left: auto;
  font-size: 0.72rem;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 0.2rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.48rem 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  transition:
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.nav-item.is-active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.nav-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-3);
}
.recents {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 0.4rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}
.recents-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.recents-head input {
  margin-left: auto;
  width: 96px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-xs);
  padding: 0.15rem 0.4rem;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
  transition: all var(--dur-fast) var(--ease);
}
.recents-head input:focus,
.recents-head input:not(:placeholder-shown) {
  width: 130px;
  border-color: var(--line);
  background: var(--bg-elev);
}
.conv-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin: 0 -0.3rem;
  padding: 0 0.3rem;
}
.conv-group {
  font-size: 0.72rem;
  color: var(--ink-3);
  padding: 0.7rem 0.5rem 0.25rem;
  font-weight: 500;
}
.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.42rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink-2);
  font-size: 0.88rem;
  text-align: left;
}
.conv-item:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.conv-item.is-active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.conv-item .ctitle {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item .cpin {
  color: var(--ink-3);
  width: 13px;
  height: 13px;
}
.conv-item .cdel {
  display: none;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  place-items: center;
  color: var(--ink-3);
}
.conv-item:hover .cdel {
  display: grid;
}
.conv-item .cdel:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.conv-item .cdel i {
  width: 14px;
  height: 14px;
}
.conv-item.is-new {
  animation: flash 1.2s var(--ease);
}
/* A chat that is working server-side right now. */
.conv-item .cbusy {
  display: inline-grid;
  place-items: center;
  margin-right: 0.15rem;
}
.conv-item .cbusy .thinking-dots span {
  width: 4px;
  height: 4px;
}
.interrupted-note {
  border-left: 2px solid var(--warn, #c98a2f);
  color: var(--ink-2);
}
.conv-empty {
  font-size: 0.84rem;
  color: var(--ink-3);
  padding: 0.6rem 0.5rem;
}
.side-foot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
}
.engine-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--ink-2);
  text-align: left;
}
.engine-chip:hover {
  background: var(--bg-hover);
}
.engine-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-tools {
  display: flex;
  gap: 2px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--off);
  flex: none;
}
.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}
.dot.warn {
  background: var(--warn);
}
.dot.off {
  background: var(--danger);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn i[data-i] {
  width: 16px;
  height: 16px;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-ghost {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--ink-3);
}
.btn-ghost.danger,
.btn-danger {
  color: var(--danger);
}
.btn-danger {
  background: var(--danger-soft);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-sm {
  padding: 0.32rem 0.65rem;
  font-size: 0.82rem;
}
.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  transition:
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.icon-btn.is-on {
  color: var(--accent);
}
.link {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
}
.link:hover {
  text-decoration: underline;
}
.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.grow {
  flex: 1;
}
.hint,
small {
  color: var(--ink-3);
  font-size: 0.82rem;
}
.hint.warn {
  color: var(--warn);
}
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}
fieldset legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 0.2rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-sunk);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge.ok {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}
.badge.warn {
  background: var(--warm-soft);
  color: var(--warm);
  border-color: transparent;
}

/* Switch */
.switch {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background var(--dur) var(--ease);
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease-out);
}
.switch[aria-checked="true"] {
  background: var(--accent);
}
.switch[aria-checked="true"]::after {
  transform: translateX(16px);
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.segmented button {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  color: var(--ink-2);
}
.segmented button.is-active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* ---------- Headings / sections ---------- */
.hello {
  margin: 1.6rem 0 1.4rem;
  text-align: center;
}
.hello h1,
.view-head h1 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.015em;
}
.hello h1 {
  font-size: 2.3rem;
}
.hello p {
  color: var(--ink-2);
  margin-top: 0.2rem;
}
.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.view-head h1 {
  font-size: 1.9rem;
}
.view-head p {
  color: var(--ink-2);
  margin-top: 0.2rem;
  max-width: 60ch;
}
.section {
  margin: 2rem 0 1.4rem;
}
.section-head,
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.section-head h2,
.card-head h2 {
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
}
h3.sub {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  font-weight: 600;
  margin: 1.4rem 0 0.6rem;
}
.card h3.sub {
  margin-top: 0;
}
.card-sub {
  font-size: 0.8rem;
  color: var(--ink-3);
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.grid-2 .card {
  margin-bottom: 0;
}
.grid-2 + .card {
  margin-top: 1rem;
}

/* Onboarding banner */
.onboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-ink);
  margin-bottom: 0.6rem;
}
.onboard strong {
  display: block;
}
.onboard span {
  font-size: 0.88rem;
  opacity: 0.85;
}

/* ---------- Composer ---------- */
.composer {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.75rem 0.5rem 1rem;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow:
    var(--shadow),
    0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
.composer textarea {
  border: none;
  background: transparent;
  resize: none;
  font-size: 1rem;
  line-height: 1.5;
  max-height: 40vh;
  min-height: 1.5em;
  padding: 0.15rem 0 0.4rem;
  outline: none;
  color: var(--ink);
}
.composer textarea::placeholder {
  color: var(--ink-3);
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: -0.45rem;
}
.composer-hint {
  font-size: 0.74rem;
  color: var(--ink-3);
  margin-left: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.composer-hint kbd {
  font-size: 0.68rem;
}
.send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  transition:
    background var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}
.send:hover {
  background: var(--accent-hover);
}
.send:disabled {
  opacity: 0.4;
  cursor: default;
}
.send.stop {
  background: var(--ink);
  color: var(--bg);
}
.send i[data-i] {
  width: 17px;
  height: 17px;
}
.suggest {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem auto 0;
  max-width: 720px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  font-size: 0.86rem;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover {
  color: var(--ink);
  border-color: var(--ink-3);
  transform: translateY(-1px);
}
.chip i[data-i] {
  width: 15px;
  height: 15px;
  color: var(--ink-3);
}
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: 720px;
  margin: 0.5rem auto 0;
}
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.3rem 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
}
.att-chip button {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-3);
}
.att-chip button:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.att-chip.is-loading {
  opacity: 0.6;
}

/* ---------- Agent identity ---------- */
.agent-av {
  --agent: var(--accent);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  background:
    radial-gradient(
      circle at 30% 25%,
      rgba(255, 255, 255, 0.45),
      transparent 50%
    ),
    var(--agent);
  text-transform: uppercase;
}
.agent-av.sm {
  width: 18px;
  height: 18px;
  font-size: 0.6rem;
}
.agent-av.lg {
  width: 38px;
  height: 38px;
  font-size: 0.95rem;
}
.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.55rem 0.22rem 0.25rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-2);
  border: 1px solid transparent;
  transition: all var(--dur-fast) var(--ease);
}
.agent-pill:hover,
.agent-pill.is-open {
  background: var(--bg-hover);
  color: var(--ink);
}
.agent-pill .caret {
  width: 14px;
  height: 14px;
  color: var(--ink-3);
}
.agent-pill-lg {
  border-color: var(--line);
  background: var(--bg-elev);
  padding: 0.28rem 0.65rem 0.28rem 0.3rem;
}
.agent-pill-lg .agent-av {
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
}
.popover {
  position: fixed;
  z-index: 60;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
  animation: pop var(--dur) var(--ease-out);
}
.agent-menu {
  width: 320px;
  max-height: min(440px, 70vh);
  overflow-y: auto;
}
.agent-menu .menu-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--ink-3);
  padding: 0.45rem 0.6rem 0.3rem;
}
.agent-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  text-align: left;
}
.agent-opt:hover,
.agent-opt.is-focus {
  background: var(--bg-hover);
}
.agent-opt .meta {
  flex: 1;
  min-width: 0;
}
.agent-opt strong {
  display: block;
  font-size: 0.9rem;
}
.agent-opt span {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-3);
  line-height: 1.35;
}
.agent-opt .check {
  color: var(--accent);
  width: 16px;
  height: 16px;
  margin-top: 0.2rem;
}
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
}
.agent-card-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  text-align: left;
  transition: all var(--dur-fast) var(--ease);
}
.agent-card-btn:hover {
  border-color: color-mix(
    in srgb,
    var(--agent, var(--accent)) 60%,
    var(--line)
  );
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.agent-card-btn strong {
  display: block;
  font-size: 0.92rem;
}
.agent-card-btn span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.8rem;
  color: var(--ink-3);
  line-height: 1.35;
}

/* ---------- Chat ---------- */
.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  flex: none;
}
.chat-title-wrap {
  flex: 1;
  min-width: 0;
}
.chat-title {
  font-family: var(--display);
  font-size: 1.08rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.15rem 0.4rem;
  margin-left: -0.4rem;
  border-radius: var(--radius-xs);
  cursor: text;
  outline: none;
}
.chat-title:hover {
  background: var(--bg-hover);
}
.chat-title[contenteditable="true"] {
  background: var(--bg-elev);
  box-shadow: 0 0 0 2px var(--accent);
  text-overflow: clip;
}
.chat-title.is-generating {
  animation: shimmer 1.4s ease-in-out infinite;
}
.chat-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.chat-actions .agent-pill {
  margin-right: 0.3rem;
}
#pinBtn.is-on {
  color: var(--accent);
}
.messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1.6rem 1.2rem 1rem;
  scroll-behavior: smooth;
}
.thread {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.msg {
  display: flex;
  gap: 0.75rem;
  animation: rise var(--dur) var(--ease-out) both;
}
.msg.me {
  justify-content: flex-end;
}
.msg.me .bubble {
  background: var(--user-bubble);
  padding: 0.6rem 0.95rem;
  border-radius: 18px 18px 6px 18px;
  max-width: 80%;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.mav {
  align-items: flex-start;
}
.msg.mav .agent-av {
  margin-top: 0.1rem;
}
.msg.mav .body {
  flex: 1;
  min-width: 0;
}
.msg-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-3);
  margin-bottom: 0.2rem;
}
.msg-meta .who {
  font-weight: 600;
  color: var(--agent, var(--ink-2));
}
.msg.mav .bubble {
  word-break: break-word;
}
.msg-actions {
  display: flex;
  gap: 0.1rem;
  margin-top: 0.35rem;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions,
.msg.is-last .msg-actions {
  opacity: 1;
}
.msg-speed {
  align-self: center;
  margin-left: 0.4rem;
  font-size: 0.74rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-actions .icon-btn {
  width: 28px;
  height: 28px;
  color: var(--ink-3);
}
.msg-actions i[data-i] {
  width: 15px;
  height: 15px;
}
.msg.is-error .bubble {
  color: var(--danger);
}
.msg.is-streaming .bubble > :last-child::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  border-radius: 2px;
  animation: blink 1s steps(2) infinite;
}
.thinking-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-3);
  font-size: 0.88rem;
}
.thinking-dots {
  display: inline-flex;
  gap: 4px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: bounce 1.2s infinite;
}
.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}
.divider {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.78rem;
  color: var(--ink-3);
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.divider .agent-av {
  width: 16px;
  height: 16px;
  font-size: 0.55rem;
}
.recall-note {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  color: var(--ink-3);
  margin-top: 0.4rem;
}
.recall-note i[data-i] {
  width: 13px;
  height: 13px;
}

/* Empty chat state */
.empty-chat {
  max-width: 640px;
  margin: 8vh auto 0;
  text-align: center;
}
.empty-chat .agent-av {
  margin: 0 auto 0.8rem;
  width: 52px;
  height: 52px;
  font-size: 1.3rem;
}
.empty-chat h2 {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
}
.empty-chat p {
  color: var(--ink-2);
  margin: 0.3rem 0 1.2rem;
}
.empty-chat .suggest {
  margin-top: 0.4rem;
}

.composer-wrap {
  position: relative;
  padding: 0.4rem 1.2rem 1.1rem;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  flex: none;
}
.composer-wrap .attachments {
  margin: 0 0 0.4rem;
}
.slash-menu {
  position: absolute;
  bottom: calc(100% - 0.2rem);
  left: 1.2rem;
  right: 1.2rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.3rem;
  z-index: 20;
  animation: pop var(--dur) var(--ease-out);
}
.slash-item {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.88rem;
}
.slash-item code {
  color: var(--accent);
  font-weight: 500;
  min-width: 120px;
}
.slash-item span {
  color: var(--ink-3);
}
.slash-item.is-focus,
.slash-item:hover {
  background: var(--bg-hover);
}

/* ---------- Markdown ---------- */
.md-p {
  margin: 0 0 0.75em;
}
.bubble > :last-child {
  margin-bottom: 0;
}
.md-h {
  font-family: var(--display);
  font-weight: 600;
  margin: 1em 0 0.45em;
  line-height: 1.3;
}
h2.md-h {
  font-size: 1.25rem;
}
h3.md-h {
  font-size: 1.1rem;
}
h4.md-h,
h5.md-h,
h6.md-h {
  font-size: 1rem;
}
.bubble > .md-h:first-child {
  margin-top: 0;
}
.md-list {
  margin: 0 0 0.75em 1.3em;
}
.md-list li {
  margin: 0.2em 0;
}
.md-list .md-list {
  margin-bottom: 0;
}
.md-quote {
  border-left: 3px solid var(--line);
  padding: 0.1em 0 0.1em 0.9em;
  color: var(--ink-2);
  margin: 0 0 0.75em;
}
.md-hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1em 0;
}
.md-inline {
  background: var(--code-bg);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 0.05em 0.35em;
}
.code-block {
  position: relative;
  margin: 0 0 0.85em;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--ink-3);
  padding: 0.3rem 0.4rem 0.3rem 0.8rem;
  border-bottom: 1px solid var(--line-2);
  font-family: var(--mono);
}
.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font);
  font-size: 0.74rem;
  color: var(--ink-3);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
}
.code-copy:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.code-copy i[data-i] {
  width: 13px;
  height: 13px;
}
.md-code {
  margin: 0;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre;
}
.md-table-wrap {
  overflow-x: auto;
  margin: 0 0 0.85em;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.md-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
}
.md-table th,
.md-table td {
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
}
.md-table th {
  background: var(--bg-sunk);
  font-weight: 600;
}
.md-table tr:last-child td {
  border-bottom: none;
}
.md-center {
  text-align: center !important;
}
.md-right {
  text-align: right !important;
}
.md-img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: zoom-in;
  display: block;
  margin: 0.4em 0;
}

/* Inline chart card ([[chart:SYM:PERIOD]]) */
.md-chart {
  margin: 0.6em 0 0.9em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
}
.md-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem 0.35rem;
}
.md-chart-name {
  font-weight: 600;
  font-size: 0.92rem;
}
.md-chart-quote {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.md-chart-price {
  color: var(--ink);
  font-weight: 600;
}
.md-chart-chg.up {
  color: var(--ok);
}
.md-chart-chg.down {
  color: var(--danger);
}
.md-chart-plot {
  height: 148px;
  padding: 0 0.35rem;
}
.md-chart-load {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--ink-3);
  font-size: 0.85rem;
}
.md-chart-svg {
  width: 100%;
  height: 148px;
  display: block;
}
.md-chart-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.6rem 0.35rem 0.85rem;
  font-size: 0.72rem;
  color: var(--ink-3);
  font-family: var(--mono);
}
.chart-refresh {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  color: var(--ink-3);
}
.chart-refresh:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.chart-refresh i[data-i] {
  width: 14px;
  height: 14px;
}

/* Download card ([[file:PATH]]) */
.md-file {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.5em 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-sunk);
  text-decoration: none;
  color: inherit;
}
.md-file:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.md-file-ico {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.md-file-ico i[data-i] {
  width: 18px;
  height: 18px;
}
.md-file-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.md-file-main strong {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-file-main span {
  font-size: 0.74rem;
  color: var(--ink-3);
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.8);
  display: grid;
  place-items: center;
  cursor: zoom-out;
  animation: fade var(--dur) var(--ease);
}
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--radius-sm);
}

/* ---------- Home ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin: 1.6rem 0 1rem;
}
.list,
.inbox-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}
.empty {
  color: var(--ink-3);
  font-size: 0.88rem;
  padding: 0.6rem 0;
}
.empty-state {
  text-align: center;
  padding: 2.2rem 1rem;
  color: var(--ink-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-state strong {
  display: block;
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: 0.2rem;
}
.empty-state .btn {
  margin-top: 0.9rem;
}

/* ---------- Automations ---------- */
.jobs {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.job {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: opacity var(--dur) var(--ease);
}
.job.is-off {
  opacity: 0.65;
}
.job .jmain {
  flex: 1;
  min-width: 0;
}
.job .jtitle {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.job .jdesc {
  font-size: 0.86rem;
  color: var(--ink-2);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.job .jsched {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--ink-3);
}
.job .jsched .badge {
  font-weight: 500;
}
.job .jacts {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ---------- Drafts (proactivity) ---------- */
.drafts {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.draft {
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.draft .dhead {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.draft .dmeta {
  margin-left: auto;
  font-size: 0.76rem;
  color: var(--ink-3);
}
.draft .dbody {
  margin: 0.6rem 0;
  font-size: 0.9rem;
  color: var(--ink-2);
  white-space: pre-wrap;
}
.draft .dacts {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ---------- Interests ---------- */
.autonomy-card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.autonomy-card .ac-row {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}
.autonomy-card .ac-row p {
  margin: 0.2rem 0 0;
}
.autonomy-card .segmented {
  align-self: flex-start;
}
.selfinit {
  margin-bottom: 1rem;
}
.selfinit-card {
  border-color: var(--accent);
}
.selfinit-list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.selfinit-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  color: var(--ink-2);
}
.interest-add {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.interest-add input {
  flex: 1 1 200px;
}
.interests {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.icard {
  padding: 0.9rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease);
}
.icard:hover {
  border-color: var(--accent);
}
.icard.is-dislike {
  opacity: 0.85;
  border-left: 3px solid var(--warn, #c98a2f);
}
.icard.is-muted {
  opacity: 0.6;
}
.icard .ihead {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.icard .ihead strong {
  font-size: 0.98rem;
}
.icard .imeta {
  font-size: 0.76rem;
  color: var(--ink-3);
}
.icard .ibars {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.icard .ibar {
  position: relative;
  width: 120px;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.icard .ibar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 3px;
}
.icard .iconflict {
  margin-top: 0.6rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
  background: var(--accent-soft);
  border-radius: var(--radius-sm, 8px);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.icard .ievidence {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.icard .iev {
  font-size: 0.82rem;
  color: var(--ink-2);
}
.icard .iev .imeta {
  color: var(--ink-3);
}
.icard .iacts {
  margin-top: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.icard .isel {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 8px);
}

/* ---------- Template picker ---------- */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.7rem;
}
.tpl {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  text-align: left;
  padding: 0.9rem 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease);
}
.tpl:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.tpl .tpl-ico {
  font-size: 1.3rem;
}
.tpl strong {
  font-size: 0.94rem;
}
.tpl span:last-child {
  font-size: 0.8rem;
  color: var(--ink-2);
}
.spin {
  animation: spin 0.9s linear infinite;
}

/* ---------- Forms ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.field > label,
.field-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-2);
}
.field input,
.field select,
.field textarea,
.inline-form input,
.watch-add input,
.watch-add select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-form input:focus,
.watch-add input:focus,
.watch-add select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}
.field .row input {
  flex: 1;
  min-width: 180px;
  width: auto;
}
.field small.is-ok {
  color: var(--ok);
}
.field small.is-err {
  color: var(--danger);
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.days {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.days button {
  width: 42px;
  padding: 0.35rem 0;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-2);
}
.days button.is-on {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.inline-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.inline-form input {
  flex: 1;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0.2rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.2rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover {
  color: var(--ink);
}
.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.spanel,
.mpanel,
.rpanel {
  display: none;
}
.spanel.is-active,
.mpanel.is-active,
.rpanel.is-active {
  display: block;
  animation: fade var(--dur) var(--ease);
}
.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.panel-bar .hint {
  max-width: 60ch;
}
.status-text {
  font-size: 0.82rem;
  color: var(--ink-3);
}
.status-text.is-ok {
  color: var(--ok);
}
.status-text.is-err {
  color: var(--danger);
}

/* ---------- Lists (memory) ---------- */
.list li {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.75rem 0.2rem;
  border-bottom: 1px solid var(--line-2);
}
.list li:last-child {
  border-bottom: none;
}
.list .ltext {
  flex: 1;
  min-width: 0;
}
.list .ltext strong {
  display: block;
  font-weight: 500;
}
.list .ltext span {
  display: block;
  font-size: 0.84rem;
  color: var(--ink-2);
  margin-top: 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list .lmeta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.3rem;
  font-size: 0.76rem;
  color: var(--ink-3);
}
.list .icon-btn {
  width: 30px;
  height: 30px;
  color: var(--ink-3);
}
.list .icon-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.list .icon-btn i[data-i] {
  width: 15px;
  height: 15px;
}

/* ---------- Watch ---------- */
.watch-add {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.watch-add .segmented {
  align-self: flex-start;
}
.watch-fields {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.watch-fields input[type="text"] {
  flex: 1 1 280px;
}
.watch-fields input[type="number"] {
  flex: 0 0 200px;
}
.watch {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.7rem;
}
.wcard {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.wcard .wtop {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.wcard .wtop .icon-btn {
  margin-left: auto;
  width: 28px;
  height: 28px;
}
.wcard .wtarget {
  font-weight: 500;
  word-break: break-all;
}
.wcard .wstate {
  font-size: 0.82rem;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ---------- Settings ---------- */
.current-model {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.current-model .cm-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.current-model .cm-text {
  flex: 1;
  min-width: 0;
}
.current-model .cm-text strong {
  display: block;
  font-family: var(--mono);
  font-size: 0.95rem;
  word-break: break-all;
}
.current-model .cm-text span {
  font-size: 0.84rem;
  color: var(--ink-3);
}
.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.provider {
  text-align: left;
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: all var(--dur-fast) var(--ease);
}
.provider:hover {
  border-color: var(--ink-3);
}
.provider.is-sel {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.provider strong {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
}
.provider span {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-3);
  margin-top: 0.2rem;
  line-height: 1.35;
}
.provider .badge {
  font-size: 0.66rem;
  padding: 0.05rem 0.4rem;
}
.agent-cards,
.mcp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.7rem;
}
.acard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
}
.acard.is-off {
  opacity: 0.6;
}
.acard-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.acard-head strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acard p {
  font-size: 0.85rem;
  color: var(--ink-2);
  line-height: 1.4;
  min-height: 2.4em;
}
.acard .mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-3);
  word-break: break-all;
}
.acard-foot {
  display: flex;
  gap: 0.4rem;
  margin-top: auto;
  flex-wrap: wrap;
}
.oauth-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}
.oauth-badge svg {
  width: 0.85em;
  height: 0.85em;
}
.oauth-badge.is-ok {
  color: var(--ok, #16a34a);
  background: color-mix(in srgb, var(--ok, #16a34a) 14%, transparent);
}
.oauth-badge.is-auth {
  color: var(--warn, #d97706);
  background: color-mix(in srgb, var(--warn, #d97706) 16%, transparent);
}
.oauth-badge.is-err {
  color: var(--err, #dc2626);
  background: color-mix(in srgb, var(--err, #dc2626) 14%, transparent);
}
.code-editor {
  width: 100%;
  min-height: 52vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  padding: 1rem 1.1rem;
  resize: vertical;
  tab-size: 2;
}
.code-editor:focus {
  border-color: var(--accent);
}
.code-editor-json {
  min-height: 30vh;
  margin: 0.6rem 0;
}
.raw {
  margin-top: 1.2rem;
}
.raw summary {
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--ink-2);
  font-weight: 500;
}
.engine-card .engine-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.engine-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.02rem;
}
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem 1rem;
}
.kv div {
  display: flex;
  flex-direction: column;
  font-size: 0.86rem;
}
.kv div span:first-child {
  color: var(--ink-3);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kv div span:last-child {
  font-family: var(--mono);
  word-break: break-all;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line-2);
}
.setting-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.setting-row strong {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
}
.setting-row span {
  font-size: 0.84rem;
  color: var(--ink-3);
}
a.btn,
a.btn:hover {
  text-decoration: none;
}
/* A family member's app: the owner's settings are not shown. */
body[data-role="member"] .owner-only {
  display: none !important;
}
/* Other notification channels (ntfy, Gotify, Discord, Slack). */
.chan-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.25rem 0 0.75rem;
  border-bottom: 1px solid var(--line-2);
}
.chan {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  background: var(--bg-2, var(--line-2));
}
.chan strong {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chan-type {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.chan-acts {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.row.wrap {
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}
label.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}
.kvs {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.kv-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 0.4rem;
}

/* ---------- Palette ---------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 15, 14, 0.35);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  animation: fade var(--dur-fast) var(--ease);
}
.palette-box {
  width: min(620px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop var(--dur) var(--ease-out);
}
.palette-input {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-3);
}
.palette-input input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 1.02rem;
  color: var(--ink);
}
.palette-results {
  max-height: 52vh;
  overflow-y: auto;
  padding: 0.35rem;
}
.pal-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.92rem;
}
.pal-item:hover,
.pal-item.is-focus {
  background: var(--bg-hover);
}
.pal-item i[data-i] {
  color: var(--ink-3);
  width: 16px;
  height: 16px;
}
.pal-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pal-kind {
  font-size: 0.74rem;
  color: var(--ink-3);
}
.pal-group {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--ink-3);
  padding: 0.55rem 0.75rem 0.25rem;
}
.pal-empty {
  padding: 1.2rem;
  text-align: center;
  color: var(--ink-3);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(15, 15, 14, 0.4);
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: fade var(--dur-fast) var(--ease);
}
.modal-box {
  width: min(640px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop var(--dur) var(--ease-out);
}
.modal-box.is-small {
  width: min(440px, 100%);
}
.modal-box.is-wide {
  width: min(860px, 100%);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.6rem;
}
.modal-head h2 {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
}
.modal-body {
  padding: 0.4rem 1.2rem 1rem;
  overflow-y: auto;
}
.modal-body p {
  color: var(--ink-2);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.8rem 1.2rem 1.1rem;
  border-top: 1px solid var(--line-2);
}
.modal-foot:empty {
  display: none;
}
.modal-foot .left {
  margin-right: auto;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: rise var(--dur) var(--ease-out);
  max-width: min(520px, 92vw);
}
.toast.is-err {
  background: var(--danger);
  color: #fff;
}
.toast button {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}
.toast.is-leaving {
  animation: fadeout var(--dur) var(--ease) forwards;
}

/* ---------- Install banner ---------- */
.install-banner {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.8rem 0.9rem 0.8rem 1.1rem;
}
.install-text strong {
  display: block;
}
.install-text span {
  font-size: 0.84rem;
  color: var(--ink-3);
}

/* Demo mode ribbon */
body[data-mode="mock"] .engine-chip-text::after {
  content: " · demo";
  color: var(--warm);
}

/* ---------- Animations ---------- */
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes fadeout {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(-4px);
  }
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
@keyframes breathe {
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 0 6px rgba(47, 111, 94, 0);
  }
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(95, 179, 154, 0.55);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(95, 179, 154, 0);
  }
}
@keyframes shimmer {
  50% {
    opacity: 0.45;
  }
}
@keyframes flash {
  from {
    background: var(--accent-soft);
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    height: calc(100dvh - 52px);
  }
  .topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 52px;
    padding: 0 0.5rem;
    padding-top: env(safe-area-inset-top);
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }
  .topbar-title {
    flex: 1;
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.05rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 75;
    transform: translateX(-102%);
    transition: transform 240ms var(--ease-out);
    box-shadow: var(--shadow-lg);
    padding-top: calc(1rem + env(safe-area-inset-top));
  }
  body.drawer-open .sidebar {
    transform: none;
  }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 74;
    background: rgba(0, 0, 0, 0.35);
    animation: fade var(--dur) var(--ease);
  }
  .sidebar-close {
    display: inline-grid;
  }
  .page {
    padding: 1.2rem 1rem 3rem;
  }
  .hello {
    margin-top: 0.8rem;
  }
  .hello h1 {
    font-size: 1.8rem;
  }
  .view-head {
    flex-direction: column;
    align-items: stretch;
  }
  .view-head h1 {
    font-size: 1.55rem;
  }
  .grid-2,
  .field-grid {
    grid-template-columns: 1fr;
  }
  .chat-head {
    padding: 0.5rem 0.6rem;
  }
  .chat-head .chat-title-wrap {
    display: none;
  }
  .chat-actions {
    width: 100%;
  }
  .chat-actions .agent-pill {
    margin-right: auto;
  }
  .messages {
    padding: 1rem 0.8rem 0.6rem;
  }
  .composer-wrap {
    padding: 0.3rem 0.6rem calc(0.6rem + env(safe-area-inset-bottom));
  }
  .composer-hint {
    display: none;
  }
  .msg.me .bubble {
    max-width: 88%;
  }
  .watch-fields input[type="number"] {
    flex: 1 1 100%;
  }
  .job {
    flex-direction: column;
    align-items: stretch;
  }
  .job .jacts {
    justify-content: flex-end;
  }
  .kv-row {
    grid-template-columns: 1fr;
  }
  .install-banner {
    left: 1rem;
  }
  .new-chat .kbd-hint,
  .side-search kbd {
    display: none;
  }
}

@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;
  }
}

/* ================================================================
   Splash + UX motion (v1.7)
   ================================================================ */

/* Launch splash: the brand appears while the app boots, then fades away.
   Removed by JS on first paint; a no-JS / reduced-motion fallback keeps it out
   of the way. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition:
    opacity 0.55s var(--ease-out),
    visibility 0.55s;
}
.splash.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  animation: splashIn 0.6s var(--ease-out) both;
}
.splash-orb {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #fff 0 18%, transparent 42%),
    radial-gradient(circle at 65% 70%, var(--accent), var(--accent-hover));
  box-shadow:
    inset -4px -5px 10px rgba(0, 0, 0, 0.22),
    0 8px 28px rgba(47, 111, 94, 0.4);
  animation: orbPulse 1.6s var(--ease) infinite;
}
.splash-name {
  font-family: var(--display, "Fraunces", Georgia, serif);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.splash-tag {
  color: var(--ink-3);
  font-size: 0.84rem;
  margin-top: -0.3rem;
}
.splash-bar {
  margin-top: 0.5rem;
  width: 140px;
  height: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  overflow: hidden;
}
.splash-bar i {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: var(--accent);
  animation: splashBar 1.05s var(--ease) infinite;
}
@keyframes splashIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}
@keyframes orbPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
}
@keyframes splashBar {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

/* While loading, gently lift the app in as the splash fades. */
body.is-loading .app,
body.is-loading .topbar {
  opacity: 0;
}
.app,
.topbar {
  transition: opacity 0.5s var(--ease-out);
}

/* New assistant messages arrive with a soft rise (already the case); user
   bubbles pop slightly for a more tactile feel. */
.msg.me {
  animation: pop var(--dur) var(--ease-out) both;
}

/* Routines, drafts and cards lift on hover with a touch more life. */
.job,
.draft,
.card {
  transition:
    transform var(--dur-med) var(--ease),
    box-shadow var(--dur-med) var(--ease),
    border-color var(--dur-med) var(--ease);
}
.job:hover,
.draft:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Nav items slide a hair on hover. */
.nav-item {
  transition:
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.nav-item:hover {
  transform: translateX(2px);
}

/* The streaming caret breathes rather than blinks harshly. */
.msg.is-streaming .bubble > :last-child::after {
  animation: breathe 1.4s var(--ease) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .splash {
    display: none;
  }
  body.is-loading .app,
  body.is-loading .topbar {
    opacity: 1;
  }
}

/* ============================================================
   New-chat screen (ChatGPT-like): greeting, centred composer,
   suggestions and the proactive inbox.
   ============================================================ */
.chat .below {
  display: none;
}
.chat.is-empty {
  justify-content: center;
}
.chat.is-empty .chat-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  border-bottom-color: transparent;
  background: transparent;
  backdrop-filter: none;
}
.chat.is-empty .chat-title-wrap {
  visibility: hidden;
}
.chat.is-empty .messages {
  flex: 0 0 auto;
  overflow: visible;
  padding-bottom: 0.4rem;
}
.chat.is-empty .below {
  display: block;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.2rem 2rem;
}
.chat.is-empty .composer-foot {
  display: none;
}
.view-chat {
  position: relative;
}
.welcome {
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}
.welcome h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 2.2rem;
  letter-spacing: -0.015em;
}
.welcome-who {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.4rem;
  color: var(--ink-2);
  font-size: 0.92rem;
}
.composer-foot {
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-top: 0.45rem;
}
.composer-wrap .onboard {
  margin-bottom: 0.6rem;
}
.inbox {
  margin-top: 1.8rem;
}
.inbox-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.inbox-head h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  font-weight: 600;
}
.inbox-list {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.inbox-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line-2);
}
.inbox-item:last-child {
  border-bottom: none;
}
.inbox-ico {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  flex: none;
}
.inbox-ico i[data-i] {
  width: 16px;
  height: 16px;
}
.inbox-item .what {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
}
.inbox-item .what strong {
  display: block;
  font-weight: 600;
}
.inbox-item .what span {
  display: block;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-side {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
}
.inbox-side .t {
  font-size: 0.76rem;
  color: var(--ink-3);
  white-space: nowrap;
}

/* "Make this a routine?" card in the thread */
.offer {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-left: calc(28px + 0.75rem);
  padding: 0.75rem 0.9rem;
  border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent-soft) 50%, transparent);
  animation: rise var(--dur) var(--ease-out);
}
.offer-ico {
  color: var(--accent);
}
.offer-main {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
}
.offer-main strong {
  display: block;
}
.offer-main span {
  color: var(--ink-2);
}
.offer-acts {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}
.routine-av {
  --agent: var(--ink-3);
  color: #fff;
}
.routine-av i[data-i] {
  width: 11px;
  height: 11px;
}
.when-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.when-row .field {
  min-width: 140px;
}
.tab .count {
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-left: 0.2rem;
}
.code-editor.prose {
  font-family: var(--font);
  font-size: 0.95rem;
  min-height: 40vh;
}
.cm-icon.sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.cm-icon.sm i[data-i] {
  width: 15px;
  height: 15px;
}
.advanced {
  margin-top: 1rem;
}
.advanced > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.advanced > summary::before {
  content: "›";
  display: inline-block;
  transition: transform var(--dur) var(--ease);
  color: var(--ink-3);
}
.advanced[open] > summary::before {
  transform: rotate(90deg);
}
.advanced[open] > summary {
  margin-bottom: 1rem;
}
.kv-row input {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  background: var(--bg-elev);
}
.job .badge .thinking-dots span {
  width: 4px;
  height: 4px;
}
.empty-state .suggest {
  margin-top: 1rem;
}
@media (max-width: 900px) {
  .welcome h1 {
    font-size: 1.7rem;
  }
  .chat.is-empty .chat-head {
    position: static;
  }
  .inbox-side .t {
    display: none;
  }
  .offer {
    margin-left: 0;
    flex-wrap: wrap;
  }
  .chat-head .chat-actions {
    justify-content: flex-end;
  }
}
button.memory-updated {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
button.memory-updated:hover {
  text-decoration: underline;
}

/* "Restart to apply" bar (top of the content, on every page) */
.content {
  display: flex;
  flex-direction: column;
}
.content > .view {
  flex: 1;
  min-height: 0;
  height: auto;
}
.pending-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 1rem;
  background: var(--warm-soft);
  color: var(--ink);
  border-bottom: 1px solid color-mix(in srgb, var(--warm) 30%, var(--line));
  font-size: 0.88rem;
  flex: none;
  animation: rise var(--dur) var(--ease-out);
}
.pending-bar > i[data-i] {
  color: var(--warm);
  width: 16px;
  height: 16px;
}
.pending-bar span {
  flex: 1;
}

/* Update available (sidebar) */
.update-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}
.update-pill:hover {
  background: color-mix(in srgb, var(--accent) 22%, var(--accent-soft));
}
.update-pill i[data-i] {
  width: 15px;
  height: 15px;
}
.release-notes {
  max-height: 40vh;
  overflow-y: auto;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-sunk);
  font-size: 0.88rem;
  margin-bottom: 0.6rem;
}

/* Connections catalog */
.catalog-bar {
  margin: 1.6rem 0 0.6rem;
}
.catalog-bar h3.sub {
  margin: 0;
}
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.6rem;
}
.cat-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  text-align: left;
  transition: all var(--dur-fast) var(--ease);
}
.cat-item:hover {
  border-color: var(--ink-3);
  transform: translateY(-1px);
}
.cat-item.is-added {
  opacity: 0.75;
}
.cat-text {
  flex: 1;
  min-width: 0;
}
.cat-text strong {
  display: block;
  font-size: 0.92rem;
}
.cat-text span {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-3);
  line-height: 1.35;
  margin-top: 0.1rem;
}
.cat-item .badge {
  flex: none;
}
.onboard.soft {
  background: var(--bg-sunk);
  color: var(--ink-2);
  padding: 0.6rem 0.8rem;
  margin: 0;
}
#spanel-connections .mcp-cards .empty {
  padding: 0;
}

/* ---------- Debates ---------- */
.debates {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-top: 0.4rem;
}
.deb-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.deb-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.deb-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}
.deb-card-head strong {
  font-size: 0.98rem;
  font-weight: 600;
}
.deb-meta {
  flex: none;
  font-size: 0.76rem;
  color: var(--ink-3);
}
.deb-q {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.deb-foot {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.6rem;
}
.deb-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  background: var(--ac);
  border: 2px solid var(--bg-elev);
  margin-left: -6px;
}
.deb-avatar:first-child {
  margin-left: 0;
}
.deb-open {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.deb-thread {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: min(64vh, 620px);
  overflow-y: auto;
  padding: 0.1rem 0.2rem;
}
.deb-question {
  background: var(--bg-sunk);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
}
.deb-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.deb-question p {
  margin: 0.25rem 0 0;
  font-weight: 500;
}
.deb-msg {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.deb-who {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--ink-2);
}
.deb-who .deb-avatar {
  margin-left: 0;
  border-color: transparent;
}
.deb-who time {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 0.74rem;
}
.deb-body {
  margin-left: 1.9rem;
  border-left: 3px solid var(--ac);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.2rem 0.15rem 0.1rem;
  background: transparent;
}

/* ---------- Message queue (typed while Mav is answering) ---------- */
.queue-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  max-width: 720px;
  margin: 0.5rem auto 0;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  background: var(--bg-sunk);
  border: 1px solid var(--line);
}
.queue-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}
.queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 260px;
  padding: 0.2rem 0.3rem 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 0.8rem;
}
.queue-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-x {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-3);
}
.queue-x:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.queue-x i[data-i] {
  width: 13px;
  height: 13px;
}
.queue-send {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent-soft);
}
.queue-send:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.queue-send i[data-i] {
  width: 13px;
  height: 13px;
}

/* ---------- Live tool/MCP activity under a streaming answer ---------- */
/* Tool calls: one row per step, in order; a row opens to show details. */
.msg-tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0.1rem 0 0.55rem;
  max-width: 640px;
}
.msg-tools:empty {
  display: none;
}
.tool-step {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-sunk);
  font-size: 0.8rem;
  color: var(--ink-2);
  animation: tool-in 0.18s ease-out;
}
@keyframes tool-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
}
.tool-step > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 0.6rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.tool-step > summary::-webkit-details-marker {
  display: none;
}
.tool-step > summary:hover {
  color: var(--ink);
}
.tool-n {
  flex: none;
  min-width: 1.1rem;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.7rem;
  color: var(--ink-3);
  text-align: right;
}
.tool-ico i[data-i] {
  width: 13px;
  height: 13px;
  display: block;
}
.tool-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-meta {
  flex: none;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.7rem;
  color: var(--ink-3);
}
.tool-caret {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--ink-3);
  transition: transform 0.15s ease-out;
}
.tool-step[open] .tool-caret {
  transform: rotate(180deg);
}
.tool-step.is-run {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.tool-step.is-run .tool-ico i[data-i] {
  animation: blink 1s infinite;
}
.tool-step.is-done .tool-ico {
  color: var(--accent);
}
.tool-step.is-err {
  border-color: color-mix(in srgb, var(--danger, #c2412d) 40%, var(--line));
}
.tool-step.is-err .tool-ico {
  color: var(--danger, #c2412d);
}
.tool-body {
  padding: 0.2rem 0.75rem 0.7rem 2.2rem;
  display: grid;
  gap: 0.55rem;
  color: var(--ink-2);
}
.tool-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.9rem;
  margin: 0;
}
.tool-facts dt {
  color: var(--ink-3);
}
.tool-facts dd {
  margin: 0;
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}
.tool-sec-h {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.2rem;
}
.tool-pre {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.74rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.tool-pre.is-cmd {
  color: var(--accent-ink);
}
.tool-pre.is-err {
  color: var(--danger, #c2412d);
}
.tool-empty {
  margin: 0;
  color: var(--ink-3);
}
@media (max-width: 640px) {
  .tool-body {
    padding-left: 0.75rem;
  }
}

/* ---------- Sign-in gate ---------- */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}
.auth-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  text-align: center;
}
.auth-card h1 {
  margin: 8px 0 0;
  font-size: 28px;
}
.auth-card p {
  margin: 0;
  color: var(--ink-2);
}
.auth-orb {
  justify-self: center;
}
.auth-card .input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
}
.auth-card .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.auth-card .btn {
  justify-content: center;
}
.auth-error {
  color: var(--danger);
  font-size: 14px;
}
.auth-foot {
  font-size: 13px;
}

/* Briefing */
.chip-accent {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--accent);
  font-weight: 600;
}
#briefingTime {
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font: inherit;
}

/* ---------- Usage ---------- */
.usage-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.speed-head {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0.5rem 0 0.25rem;
}
@media (max-width: 640px) {
  .speed-head {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.usage-stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: grid;
  gap: 2px;
}
.usage-stat span {
  font-size: 0.8rem;
  color: var(--ink-3);
}
.usage-stat strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
.usage-meter {
  height: 8px;
  border-radius: 99px;
  background: var(--bg-sunk);
  overflow: hidden;
  margin-bottom: 6px;
}
.usage-meter i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width var(--dur-fast) var(--ease);
}
.usage-meter.is-high i {
  background: var(--warn);
}
.usage-meter.is-over i {
  background: var(--danger);
}
.usage-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  margin: 10px 0;
}
.usage-bars i {
  flex: 1;
  min-height: 2px;
  background: color-mix(in srgb, var(--accent) 70%, transparent);
  border-radius: 3px 3px 0 0;
}
.usage-bars i.is-zero {
  background: var(--line);
}
.usage-split {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 0.86rem;
  color: var(--ink-2);
}
.num-input {
  width: 90px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  font: inherit;
}
.num-input.wide {
  width: 220px;
  max-width: 100%;
}
@media (max-width: 640px) {
  .usage-stat strong {
    font-size: 1.1rem;
  }
}
@media (max-width: 640px) {
  #spanel-usage .setting-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #spanel-usage .setting-row .row {
    flex-wrap: wrap;
  }
}

/* ============================================================
   Brand v2 — "Midnight & Emerald"
   The mark: an emerald disc crossed by an amber arc — a day that
   keeps going while you sleep. Serif (Instrument) only for big,
   editorial moments; everything else is Geist.
   ============================================================ */
body {
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.006em;
}
/* The mark: an emerald disc and an amber dot — Mav has something for
   you. Flat, two shapes; the notch is a mask, so it works on any
   background. */
.orb,
.splash-orb {
  position: relative;
  background: none;
  border-radius: 0;
  box-shadow: none;
  animation: none;
}
.orb::before,
.splash-orb::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--brand-1);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cmask id='m'%3E%3Crect width='100' height='100' fill='white'/%3E%3Ccircle cx='82' cy='18' r='23'/%3E%3C/mask%3E%3Ccircle cx='44' cy='56' r='44' mask='url(%23m)'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cmask id='m'%3E%3Crect width='100' height='100' fill='white'/%3E%3Ccircle cx='82' cy='18' r='23'/%3E%3C/mask%3E%3Ccircle cx='44' cy='56' r='44' mask='url(%23m)'/%3E%3C/svg%3E") center / contain no-repeat;
}
.orb::after,
.splash-orb::after {
  content: "";
  position: absolute;
  left: 66%;
  top: 2%;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--signal);
}
.splash-orb::after,
body.is-thinking .orb::after {
  animation: mark-dot 1.2s ease-in-out infinite;
}
@keyframes mark-dot {
  50% {
    transform: scale(0.7);
    opacity: 0.6;
  }
}

/* Serif only where it is a moment. */
.view-head h1,
.welcome h1,
.empty-chat h2,
.auth-card h1 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.01em;
}
/* The wordmark: Geist, semibold, tight. */
.brand-name {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.3rem;
  letter-spacing: -0.04em;
}
.view-head h1 {
  font-size: clamp(2rem, 3vw, 2.5rem);
}
.welcome h1 {
  font-size: clamp(2.2rem, 4vw, 3rem);
  line-height: 1.05;
}
.chat-title,
.md-h,
.card-head h2,
.modal-head h2,
.topbar-title {
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* Buttons: crisp, with a hairline highlight. */
.btn {
  letter-spacing: -0.01em;
}
.btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 1px color-mix(in srgb, var(--accent) 70%, #000),
    0 1px 2px rgba(14, 16, 19, 0.12);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-ghost {
  box-shadow: var(--shadow-sm);
  border-color: transparent;
}

/* Surfaces: hairline rings instead of heavy borders. */
.card,
.composer,
.modal-box,
.usage-stat {
  border-color: transparent;
  box-shadow: var(--shadow);
}
.composer:focus-within {
  box-shadow:
    var(--shadow),
    0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Proactive moments wear the signal colour. */
.chip-accent {
  border-color: color-mix(in srgb, var(--signal) 45%, var(--line));
  color: color-mix(in srgb, var(--signal) 75%, var(--ink));
  background: var(--signal-soft);
}

/* Code in Geist Mono, quieter background. */
code,
pre,
kbd {
  font-family: var(--mono);
}

::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}


/* ============================================================
   First-run welcome (model → about you → routines → briefing)
   ============================================================ */
.ob-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
}
.ob-overlay[hidden] {
  display: none;
}
.ob-card {
  width: min(640px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  text-align: left;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-lg, 0 30px 80px rgba(0, 0, 0, 0.35));
  animation: splashIn 0.4s var(--ease-out, ease-out) both;
}
.ob-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0 26px;
}
.ob-progress {
  display: flex;
  gap: 6px;
}
.ob-progress i {
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.2s;
}
.ob-progress i.is-done {
  background: color-mix(in srgb, var(--brand-1) 55%, var(--line));
}
.ob-progress i.is-on {
  background: var(--brand-1);
}
.ob-step {
  padding: 18px 26px 6px;
  display: grid;
  align-content: start;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.ob-step[hidden] {
  display: none;
}
.ob-step h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.015em;
  font-size: 38px;
  line-height: 1.05;
  margin: 0;
}
.ob-lead {
  margin: 0;
  color: var(--ink-2);
}
.ob-orb {
  width: 56px;
  height: 56px;
}
.ob-ready {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.ob-ready i[data-i] {
  width: 18px;
  height: 18px;
  flex: none;
}
.ob-providers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.ob-prov {
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 2px;
}
.ob-prov span {
  font-size: 0.8rem;
  color: var(--ink-3);
}
.ob-prov.is-sel {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 1px var(--brand-1) inset;
}
.ob-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ob-overlay .field {
  display: grid;
  gap: 6px;
}
.ob-overlay .field input,
.ob-overlay .field select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm, 10px);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
.ob-overlay .field .row {
  display: flex;
  gap: 8px;
}
.ob-overlay .field small {
  color: var(--ink-3);
}
.ob-overlay .field small.is-ok {
  color: var(--brand-1);
}
.ob-overlay .field small.is-err {
  color: var(--danger);
}
.ob-routines {
  display: grid;
  gap: 8px;
}
.ob-routine {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}
.ob-routine.is-on {
  border-color: color-mix(in srgb, var(--brand-1) 60%, var(--line));
  background: var(--accent-soft);
}
.ob-routine input[type="checkbox"] {
  accent-color: var(--brand-1);
  width: 18px;
  height: 18px;
  flex: none;
}
.ob-routine input[type="time"] {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font: inherit;
}
.ob-ico {
  font-size: 1.3rem;
  width: 28px;
  text-align: center;
}
.ob-txt {
  flex: 1;
  display: grid;
  gap: 2px;
  min-width: 0;
}
.ob-txt span {
  font-size: 0.85rem;
  color: var(--ink-2);
}
.ob-foot {
  flex: none;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 26px 22px;
}
.ob-msg {
  flex: 1;
  font-size: 0.85rem;
  color: var(--ink-3);
}
.ob-msg.is-err {
  color: var(--danger);
}
body.has-onboarding {
  overflow: hidden;
}
@media (max-width: 560px) {
  .ob-grid {
    grid-template-columns: 1fr;
  }
  .ob-step h2 {
    font-size: 28px;
  }
}
@media (max-width: 560px) {
  #obBriefRow {
    flex-wrap: wrap;
  }
  #obBriefRow input[type="time"] {
    margin-left: 70px;
  }
}

/* Public demo: a card in the sidebar (desktop) and a pill (mobile). */
.demo-banner,
.demo-pill {
  display: flex;
  align-items: center;
  gap: 8px 10px;
  font-size: 0.82rem;
  color: var(--ink-2);
  background: var(--bg-elev);
  border: 1px solid color-mix(in srgb, var(--signal) 40%, var(--line));
}
.demo-banner {
  flex-wrap: wrap;
  flex: none;
  padding: 10px 12px;
  border-radius: 14px;
}
.demo-banner > span:not(.demo-dot) {
  flex: 1;
  min-width: 0;
}
.demo-pill {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 128px;
  z-index: 120;
  padding: 8px 10px 8px 14px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.demo-pill > span:not(.demo-dot) {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.demo-banner[hidden],
.demo-pill[hidden] {
  display: none;
}
.demo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
  flex: none;
}
.demo-banner a,
.demo-pill a {
  flex: none;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--brand-1);
  color: #04140e;
  font-weight: 600;
  text-decoration: none;
}
@media (min-width: 901px) {
  .demo-pill {
    display: none;
  }
}
