*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  color-scheme: dark light;
  /* Darkhorse Labs: pure monochrome (black, white, neutral grays). Dark is the default; light is also grays. */
  --bg: #0b0b0b;
  --surface: #121212;
  --surface-alt: #1b1b1b;
  --border: #2e2e2e;
  --shadow: none;
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.6);
  --text: #e6e6e6;
  --text-muted: #9a9a9a;
  --accent: #f0f0f0;
  --accent-dim: #d0d0d0;
  --on-accent: #0b0b0b;
  --link: #f0f0f0;
  --user-bg: #1a1a1a;
  --coach-bg: #121212;
  --danger: #e0e0e0;
  --ok: #bdbdbd;
  --scan: rgba(255, 255, 255, 0.035);
  --logo-base: #0f0f0f;
  --logo-f1: #2a2a2a; --logo-f2: #1f1f1f; --logo-f3: #343434; --logo-f4: #262626; --logo-f5: #181818; --logo-f6: #202020;
  --logo-rim: #4a4a4a;
  --logo-edge: #ffffff;
  --logo-eye: #ffffff;
  --logo-glow: #ffffff;
  --wm-light: #8c8c8c;
  --radius: 8px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f2;
    --surface: #ffffff;
    --surface-alt: #ececec;
    --border: #cfcfcf;
    --shadow: none;
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --text: #141414;
    --text-muted: #555555;
    --accent: #1a1a1a;
    --accent-dim: #2b2b2b;
    --on-accent: #ffffff;
    --link: #141414;
    --user-bg: #e6e6e6;
    --coach-bg: #ffffff;
    --danger: #1a1a1a;
    --ok: #404040;
    --scan: rgba(0, 0, 0, 0.04);
    --logo-base: #141414;
    --logo-f1: #333333; --logo-f2: #262626; --logo-f3: #444444; --logo-f4: #2e2e2e; --logo-f5: #1d1d1d; --logo-f6: #2a2a2a;
    --logo-rim: #000000;
    --logo-edge: #ffffff;
    --logo-eye: #ffffff;
    --logo-glow: #7a7a7a;
    --wm-light: #6b6b6b;
  }
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; overflow: hidden; }
/* #app is the responsive shell: column on mobile (nav = bottom bar), row on desktop (nav = left rail).
   The shell exactly fills the viewport; scrolling happens inside designated areas (chat messages,
   section pages, auth box) so the page itself never produces a scrollbar. */
#app { height: 100vh; height: 100dvh; overflow: hidden; max-width: 100vw; display: flex; flex-direction: column; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
a { color: var(--accent); text-decoration: none; }

/* Auth */
.auth-container { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 24px; padding-top: calc(24px + env(safe-area-inset-top, 0px)); }
.auth-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.auth-box h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.auth-box .tagline { font-size: 12px; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 28px; }
.auth-box input { width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 14px; margin-bottom: 12px; outline: none; }
.auth-box input:focus { border-color: var(--accent-dim); }
.auth-box button { width: 100%; padding: 10px; background: var(--accent-dim); border: none; border-radius: 8px; color: var(--on-accent); font-family: var(--font); font-size: 14px; font-weight: 500; cursor: pointer; margin-top: 4px; }
.auth-box button:hover { background: var(--accent); }
.auth-box .toggle { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.auth-box .toggle span { color: var(--accent); cursor: pointer; }
.auth-box .error { color: var(--danger); font-size: 13px; margin-bottom: 8px; }

/* Landing */
.landing { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.landing-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 32px; padding-top: calc(20px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--border); }
.landing-header .logo { font-size: 18px; font-weight: 600; }
.landing-header .user-info { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.landing-header .logout-btn { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); padding: 4px 12px; font-size: 12px; cursor: pointer; font-family: var(--font); }
.landing-header .logout-btn:hover { color: var(--text); border-color: var(--text-muted); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 48px 32px; max-width: 800px; margin: 0 auto; width: 100%; flex: 1; align-content: center; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; cursor: pointer; transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--accent-dim); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.tile p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.tile .tile-tag { display: inline-block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }

/* Chat layout â€” fills the shell's content area (beside the rail on desktop, above the bar on mobile). */
.chat-app { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; order: 1; position: relative; overflow: hidden; }
/* Chat history is a slide-over DRAWER at every width (not a permanent panel) so the conversation
   gets the full width. Opened via the history (â˜°) button; closed by the overlay. */
.sidebar { position: absolute; top: 0; left: 0; bottom: 0; width: 300px; max-width: 85vw; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transform: translateX(-100%); transition: transform 0.2s ease; z-index: 20; box-shadow: var(--shadow-lg); }
.sidebar.open { transform: translateX(0); }
.sidebar-header { padding: 16px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.sidebar-header .back-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px; font-family: var(--font); }
.sidebar-header .back-btn:hover { color: var(--text); }
.new-chat-btn { background: var(--accent-dim); border: none; border-radius: 8px; color: var(--on-accent); padding: 8px 14px; font-size: 13px; cursor: pointer; font-family: var(--font); }
.new-chat-btn:hover { background: var(--accent); }
.conv-list { flex: 1; overflow-y: auto; padding: 8px; }
.conv-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; justify-content: space-between; }
.conv-item:hover { background: var(--surface-alt); color: var(--text); }
.conv-item.active { background: var(--surface-alt); color: var(--text); }
.conv-item .delete-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 2px 4px; opacity: 0.6; font-family: var(--font); }
.conv-item .delete-btn:hover { color: var(--danger); opacity: 1; }
.conv-actions { display: flex; gap: 2px; flex-shrink: 0; }
.conv-item .rename-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; opacity: 0.6; font-family: var(--font); }
.conv-item .rename-btn:hover { color: var(--accent); opacity: 1; }
.conv-title { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.sidebar-overlay { display: none; position: absolute; inset: 0; background: rgba(0,0,0,0.4); z-index: 19; }
.sidebar-overlay.open { display: block; }

/* Chat area */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; max-width: 100%; }
.chat-messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.message { max-width: 80%; padding: 14px 18px; border-radius: var(--radius); font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; animation: fadeIn 0.2s ease; }
.message.historical { animation: none; }
.message.user { align-self: flex-end; background: var(--user-bg); border: 1px solid #2e2e2e; box-shadow: var(--shadow); }
.message.assistant { align-self: flex-start; background: var(--coach-bg); border: 1px solid var(--border); box-shadow: var(--shadow); }
.message .label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; color: var(--text-muted); }
.message.user .label { color: var(--accent); }
.typing-indicator { align-self: flex-start; padding: 14px 18px; background: var(--coach-bg); border: 1px solid var(--border); border-radius: var(--radius); display: flex; gap: 5px; }
.typing-indicator > span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: blink 1.4s infinite both; }
.typing-indicator > span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator > span:nth-child(3) { animation-delay: 0.4s; }
.typing-indicator .typing-note { align-self: center; margin-left: 8px; font-size: 12px; font-style: italic; color: var(--text-muted); }
.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 14px; }

.chat-input-area { padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; box-shadow: var(--shadow); }
.chat-form:focus-within { border-color: var(--accent-dim); }
.chat-form textarea { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-family: var(--font); font-size: 14.5px; line-height: 1.5; resize: none; max-height: 140px; min-width: 0; }
.chat-form textarea::placeholder { color: var(--text-muted); }
/* send-btn sizing is handled by .input-btn (see input-bar controls below). */

@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 700px) {
  .tiles { grid-template-columns: 1fr; padding: 24px 16px; }
  .message { max-width: 92%; }
  .chat-messages { padding: 16px; }
  .chat-input-area { padding: 10px 12px; }
  .conv-item .delete-btn, .conv-item .rename-btn { opacity: 1; }
}

/* Profile/Settings */
.settings-container { max-width: 480px; margin: 0 auto; padding: 32px 24px; padding-top: calc(32px + env(safe-area-inset-top, 0px)); padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
.settings-container h2 { font-size: 18px; font-weight: 600; margin-bottom: 24px; }
.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; box-shadow: var(--shadow); }
.settings-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.settings-section input { width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 14px; margin-bottom: 12px; outline: none; }
.settings-section input:focus { border-color: var(--accent-dim); }
.settings-section textarea { width: 100%; padding: 10px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 14px; margin-bottom: 12px; outline: none; resize: vertical; line-height: 1.5; }
.settings-section textarea:focus { border-color: var(--accent-dim); }
.field-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.settings-section button { padding: 8px 16px; background: var(--accent-dim); border: none; border-radius: 8px; color: var(--on-accent); font-family: var(--font); font-size: 13px; cursor: pointer; }
.settings-section button:hover { background: var(--accent); }
.settings-back { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 0; margin-bottom: 20px; font-family: var(--font); }
.settings-back:hover { color: var(--text); }
.settings-msg { font-size: 13px; margin-top: 8px; }
.settings-msg.ok { color: #bdbdbd; }
.settings-msg.err { color: var(--danger); }

/* Health Sync Status */
.sync-status { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-weight: 500; }
.sync-status.connected { border-color: #3a3a3a; background: rgba(120, 120, 120, 0.1); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; }
.sync-dot.green { background: #bdbdbd; box-shadow: 0 0 6px rgba(189, 189, 189, 0.4); }

/* Onboarding buttons */
.ob-primary-btn { flex: 1; padding: 12px; background: var(--accent-dim); border: none; border-radius: 8px; color: var(--on-accent); font-size: 14px; font-weight: 500; cursor: pointer; font-family: var(--font); }
.ob-primary-btn:hover { background: var(--accent); }
.ob-secondary-btn { flex: 1; padding: 12px; background: transparent; border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); font-size: 14px; cursor: pointer; font-family: var(--font); }
.ob-secondary-btn:hover { border-color: var(--text-muted); color: var(--text); }

/* Image upload */
/* img-btn (attach) sizing is handled by .input-btn (see input-bar controls). */
.img-preview { padding: 8px 12px; }
.img-chip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.img-chip > img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.img-chip span { font-size: 11px; color: var(--text-muted); line-height: 1.4; flex: 1; min-width: 120px; }
.img-chip button { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 0 4px; }
.img-chip button:hover { color: var(--danger); }
.img-thumb { position: relative; display: inline-flex; }
.img-thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.img-thumb button { position: absolute; top: -6px; right: -6px; background: var(--surface); border: 1px solid var(--border); border-radius: 50%; width: 18px; height: 18px; font-size: 13px; line-height: 1; padding: 0; display: flex; align-items: center; justify-content: center; }

/* Attachments shown inside a sent message */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.msg-thumb { width: 120px; max-width: 60%; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); object-fit: cover; }
.msg-file { display: inline-flex; align-items: center; font-size: 12px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; color: var(--text-muted); }
.file-thumb { width: auto; font-size: 12px; background: var(--surface-alt); align-items: center; padding: 6px 10px; color: var(--text); }

/* Inline exercise demonstration image rendered from a tool-returned URL */
.exercise-media { display: block; max-width: 100%; width: 320px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; background: #fff; }
.exercise-media-fig { margin: 12px 0 4px; }
.exercise-media-fig figcaption { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
@media (max-width: 640px) { .exercise-media { width: 100%; } }

/* --- Quorum (smart chat) --- */

/* Markdown body for assistant replies. Override the container's pre-wrap so block elements
   control spacing instead of raw newlines. */
.message.assistant .md-body { white-space: normal; }
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body h2 { font-size: 16px; font-weight: 600; margin: 14px 0 6px; }
.md-body h3 { font-size: 14.5px; font-weight: 600; margin: 12px 0 5px; }
.md-body h4, .md-body h5 { font-size: 13.5px; font-weight: 600; margin: 10px 0 4px; color: var(--text); }
.md-body p { margin: 0 0 10px; }
.md-body ul, .md-body ol { margin: 4px 0 10px; padding-left: 22px; }
.md-body li { margin: 2px 0; }
.md-body code { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.md-body strong { color: var(--text); font-weight: 600; }
.md-body a { color: var(--accent); text-decoration: underline; }

/* Expert badge on assistant replies â€” subtle pill showing which expert answered. */
.message.assistant .label.expert-badge {
  display: inline-flex; align-items: center;
  background: var(--accent-dim); color: #e6e6e6;
  padding: 2px 9px; border-radius: 999px;
  text-transform: none; letter-spacing: 0.02em; font-size: 10.5px;
}
.message.assistant .label.expert-badge::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); margin-right: 6px;
}

/* Smart empty state with example prompt chips. */
.empty-state.smart-empty { flex-direction: column; gap: 10px; text-align: center; padding: 24px; max-width: 540px; margin: 0 auto; }
.empty-state.smart-empty h3 { font-size: 18px; font-weight: 600; color: var(--text); }
.empty-state.smart-empty p { font-size: 13.5px; color: var(--text-muted); line-height: 1.5; max-width: 420px; }
.example-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.example-chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); padding: 7px 14px; font-size: 13px; cursor: pointer;
  font-family: var(--font); transition: border-color 0.15s, background 0.15s;
}
.example-chip:hover { border-color: var(--accent-dim); background: var(--surface-alt); }

/* Make the landing tiles wrap nicely now that there are three. */
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr; } }

/* --- Clip / Save button on Quorum replies --- */
.msg-actions { margin-top: 10px; display: flex; gap: 8px; }
.clip-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); padding: 4px 10px; font-size: 12px; cursor: pointer;
  font-family: var(--font); transition: color 0.15s, border-color 0.15s;
}
.clip-btn:hover { color: var(--text); border-color: var(--accent-dim); }
/* Per-message "Read aloud" button; lights up while that message is being spoken. */
.clip-btn.speak-btn.speaking { color: var(--accent); border-color: var(--accent-dim); }

/* --- Saved items view (Notes) --- */
.saved-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.saved-item.dragging { opacity: 0.5; }
.saved-drag { color: var(--text-muted); cursor: grab; font-size: 16px; line-height: 1; letter-spacing: -2px; user-select: none; flex-shrink: 0; opacity: 0.55; }
.saved-drag:hover { opacity: 1; color: var(--text); }
.saved-drag:active { cursor: grabbing; }
.saved-item-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; }
.saved-item-head:hover { background: var(--surface-alt); }
.saved-kind { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); white-space: nowrap; }
.saved-title { flex: 1; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 0 4px; opacity: 0.6; font-family: var(--font); }
.saved-del:hover { color: var(--danger); opacity: 1; }
.saved-edit { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 0 4px; opacity: 0.6; font-family: var(--font); }
.saved-edit:hover { color: var(--accent); opacity: 1; }
.saved-edit-title { width: 100%; padding: 8px 12px; margin-bottom: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 600; outline: none; }
.saved-edit-text { width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 13.5px; line-height: 1.6; resize: vertical; outline: none; }
.saved-edit-text:focus, .saved-edit-title:focus { border-color: var(--accent-dim); }
.saved-edit-actions { display: flex; gap: 8px; margin-top: 10px; }
.saved-edit-actions button { flex: 0 0 auto; padding: 8px 16px; }
.saved-content { padding: 0 16px 16px; font-size: 14px; line-height: 1.6; border-top: 1px solid var(--border); }
.saved-content.md-body { padding-top: 12px; }


/* --- Inline charts (bar / donut) rendered from a quorum-chart block --- */
.chart-fig { margin: 14px 0; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
/* Bar chart */
.chart-bars { display: flex; flex-direction: column; gap: 8px; }
.chart-bar-row { display: grid; grid-template-columns: minmax(80px, 28%) 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; }
.chart-bar-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { background: var(--surface-alt); border-radius: 999px; height: 14px; overflow: hidden; }
.chart-bar-fill { display: block; height: 100%; border-radius: 999px; transition: width 0.3s; }
.chart-bar-val { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Donut chart */
.chart-canvas { display: block; margin: 0 auto 12px; }
.chart-legend { display: flex; flex-direction: column; gap: 6px; }
.chart-legend-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: 12.5px; }
.chart-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.chart-legend-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-legend-val { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- Input-bar controls: attach, mic (dictate), send --- */
/* All share a uniform, comfortably-sized hit target so the voice controls (mic + speaker) sit
   together as a clear pair next to the text field, not a tiny afterthought in the header. */
.input-btn { background: none; border: none; cursor: pointer; display: flex; flex-shrink: 0; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; padding: 0; color: var(--text-muted); transition: color 0.12s, background 0.12s; }
.input-btn svg { width: 22px; height: 22px; }
.input-btn:hover:not(:disabled) { color: var(--text); background: var(--surface-alt); }
.input-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.send-btn { color: var(--accent); }
.send-btn:hover:not(:disabled) { color: var(--on-accent); background: var(--accent); }
.mic-btn { color: var(--accent); }
.mic-btn.recording { color: var(--bg); background: var(--text); animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(160,160,160,0.5); } 50% { box-shadow: 0 0 0 6px rgba(160,160,160,0); } }

/* Content area pages fill the shell's remaining space and scroll internally. */
.section-page { order: 1; flex: 1 1 auto; min-height: 0; min-width: 0; overflow-y: auto; }
.settings-container.has-tabs { padding-bottom: 32px; }

/* --- Brand: plain wordmark, no decorative glyphs or punctuation --- */
.brand { display: inline-flex; align-items: center; }
.brand .acorn-mark { display: none; }
.brand .brand-name { font-weight: 650; letter-spacing: -0.025em; color: var(--text); }
.brand.brand-sm .brand-name { font-size: 20px; }

/* Persistent workspace column: familiar inbox-style utility header over the active screen. */
.app-workspace { order: 1; flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.workspace-header { flex: 0 0 auto; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 30; }
.workspace-head-inner { min-height: 58px; padding: 8px 20px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.workspace-heading, .workspace-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.workspace-title { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.utility-btn { min-width: 38px; height: 38px; padding: 0 10px; border: none; border-radius: 9px; background: transparent; color: var(--text-muted); cursor: pointer; font-family: var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.utility-btn[hidden] { display: none !important; }
.utility-btn:hover { color: var(--text); background: var(--surface-alt); }
.utility-btn.voice-toggle.on { color: var(--accent); background: var(--surface-alt); }
.utility-btn svg { width: 20px; height: 20px; }
.history-utility { font-size: 20px; padding: 0; }
.settings-utility span { font-size: 13px; font-weight: 500; }
.profile-menu-wrap { position: relative; }
.profile-button { width: 36px; height: 36px; padding: 0; border: none; border-radius: 50%; background: var(--accent); color: var(--on-accent); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font); font-size: 13px; font-weight: 700; }
.profile-button:hover { box-shadow: 0 0 0 3px rgba(255,255,255,0.14); }
.profile-menu { position: absolute; top: calc(100% + 9px); right: 0; width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 80; }
.profile-menu[hidden] { display: none; }
.profile-summary { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.profile-summary strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-summary span { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-menu button { width: 100%; padding: 11px 16px; border: none; background: transparent; color: var(--text); cursor: pointer; font-family: var(--font); font-size: 13px; display: flex; align-items: center; gap: 10px; text-align: left; }
.profile-menu button:hover { background: var(--surface-alt); }
.workspace-loading { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 14px; }

/* Desktop: center + cap the working column so wide screens feel balanced and focused. */
@media (min-width: 820px) {
  .history-utility { display: none; }
  .chat-messages { max-width: 860px; width: 100%; margin: 0 auto; }
  .chat-input-area { max-width: 860px; width: 100%; margin: 0 auto; }
}

/* Phones: no bottom bar. Slim header on top, the chat fills the rest, composer pinned at the bottom. */
@media (max-width: 819px) {
  .workspace-head-inner { min-height: 54px; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
  .settings-utility span { display: none; }
  .utility-btn { width: 38px; padding: 0; }
  .profile-menu { right: -2px; width: min(240px, calc(100vw - 24px)); }
}

/* The active content region fills the workspace below the utility header. */
.app-screen { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* Hide any legacy landing hero. */
.landing-hero { display: none; }

/* --- Image lightbox (open/zoom/pan/download any chat image) --- */
.lightbox-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(8,8,8,0.92); display: flex; flex-direction: column; }
.lightbox-bar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.lightbox-label { color: #ececec; font-size: 13px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-actions { display: flex; gap: 6px; flex-shrink: 0; }
.lightbox-btn { width: 40px; height: 40px; border: none; border-radius: 10px; background: rgba(255,255,255,0.12); color: #fff; font-size: 20px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font); }
.lightbox-btn:hover { background: rgba(255,255,255,0.22); }
.lightbox-stage { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; }
.lightbox-img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center center; user-select: none; -webkit-user-drag: none; will-change: transform; }

/* With 5 nav items the mobile bottom bar gets tighter â€” shrink labels/padding so they still fit. */

/* Recoverable send-failure banner (dropped connection) â€” message is preserved, one-tap recovery */
.send-failure { align-self: stretch; background: #1b1b1b; border: 1px solid #2e2e2e; border-radius: 10px; padding: 10px 12px; margin: 4px 0; display: flex; flex-direction: column; gap: 8px; }
.send-failure-msg { font-size: 13px; color: #cfcfcf; line-height: 1.4; }
.send-failure-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.send-failure-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: var(--font); font-size: 12.5px; font-weight: 600; padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.send-failure-btn:hover { background: var(--surface-alt); }
.send-failure-btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.send-failure-btn.primary:hover { filter: brightness(1.05); }
/* "reconnectingâ€¦" note surfaced on the typing indicator during a retry */
.typing-indicator[data-note]::after { content: attr(data-note); display: block; font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ---- Step list (live + collapsed) ---- */
.steps-live, .steps-done { align-self: flex-start; max-width: 85%; margin: 4px 0; font-size: 12.5px; color: var(--text-muted); }
.steps-list { list-style: none; margin: 0; padding: 0; }
.step-row { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; line-height: 1.4; overflow-wrap: anywhere; }
.step-icon { flex: 0 0 14px; text-align: center; color: var(--accent); font-size: 11px; }
.step-row a { color: var(--accent); text-decoration: underline; }
.steps-live .step-row:last-child { color: var(--text); }
.steps-toggle { background: none; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-family: var(--font); font-size: 12px; color: var(--text-muted); cursor: pointer; }
.steps-toggle:hover { color: var(--text); background: var(--surface-alt); }
.steps-toggle::after { content: " \25B8"; }
.steps-done.open .steps-toggle::after { content: " \25BE"; }
.steps-body { margin-top: 6px; padding: 6px 10px; border-left: 2px solid var(--border); }
.steps-body[hidden] { display: none; }

/* ---- Go deeper + diagrams ---- */
.deeper-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.svg-diagram { margin: 10px 0; }
.svg-diagram img { display: block; max-width: 100%; height: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.svg-save { display: inline-block; margin-top: 6px; font-size: 12.5px; }
.svg-pending { color: var(--text-muted); font-style: italic; }
.svg-fallback { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: var(--surface-alt); border-radius: 8px; padding: 8px; }

/* =====================================================================================
   CALM layer: a quiet, humble IDE feel. Neutral surfaces, monochrome only, thin borders,
   no loud colors. Loaded last so it wins over the base rules above. 16px base type; 44px tap
   targets on touch; readable dark and light; reduced motion respected (see end of file).
   ===================================================================================== */
button, input, select, textarea { font-family: var(--font); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a, .md-body a, .step-row a, .saved-kind, .steps-done a, .crew-row a { color: var(--link); }
.md-body a { text-decoration: underline; text-underline-offset: 2px; }

/* Type: quiet headers */
.auth-box h1 { font-size: 22px; font-weight: 600; letter-spacing: 0; }
.auth-box .tagline { font-size: 13px; color: var(--text-muted); font-weight: 400; letter-spacing: 0; text-transform: none; }
.brand .brand-name { font-weight: 600; letter-spacing: 0; }
.workspace-title { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.message { font-size: 16px; line-height: 1.6; }
.message .label { display: block; font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text-muted); margin-bottom: 4px; }
.message.assistant .label.expert-badge { background: none; color: var(--text-muted); padding: 0; border-radius: 0; font-size: 12px; font-weight: 500; }
.message.assistant .label.expert-badge::before { display: none; }
.md-body h2 { font-size: 18px; font-weight: 600; } .md-body h3 { font-size: 16.5px; font-weight: 600; } .md-body h4, .md-body h5 { font-size: 16px; font-weight: 600; }
.md-body code { font-size: 14px; }
.chat-form textarea, .auth-box input, .settings-section input, .settings-section textarea, .nav-search, .saved-edit-title, .saved-edit-text { font-size: 16px; }

/* Controls: compact by default, 44px on touch */
:root { --tap: 36px; }
@media (pointer: coarse), (max-width: 819px) { :root { --tap: 44px; } }
.auth-box input, .settings-section input, .nav-search { min-height: var(--tap); }
.auth-box button, .settings-section button, .ob-primary-btn, .ob-secondary-btn, .new-chat-btn, .send-failure-btn, .utility-btn, .settings-back { min-height: var(--tap); }
.auth-box button, .settings-section button, .ob-primary-btn, .new-chat-btn, .send-failure-btn.primary { background: var(--accent-dim); color: var(--on-accent); font-weight: 500; font-size: 15px; border-radius: 8px; }
.auth-box button:hover, .settings-section button:hover, .ob-primary-btn:hover, .new-chat-btn:hover { background: var(--accent); }
.ob-secondary-btn, .send-failure-btn { color: var(--text); border-color: var(--border); font-size: 15px; font-weight: 500; }
.ob-secondary-btn:hover { border-color: var(--text-muted); color: var(--text); }
.msg-actions { gap: 4px 14px; flex-wrap: wrap; align-items: center; }
/* Small text links under replies (Read aloud, Go deeper, mockup Before/After/Download) */
.clip-btn, .clip-btn.text-link { background: none; border: none; padding: 2px 0; min-height: 0; font-size: 13px; font-weight: 400; color: var(--text-muted); border-radius: 4px; cursor: pointer; text-decoration: none; }
.clip-btn:hover, .clip-btn.text-link:hover { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.clip-btn.speak-btn.speaking { color: var(--link); background: none; border: none; }
.clip-btn[aria-pressed="true"] { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
@media (pointer: coarse) { .clip-btn, .clip-btn.text-link { min-height: 44px; padding: 0 6px; display: inline-flex; align-items: center; } }
.utility-btn { min-width: var(--tap); height: var(--tap); }
.profile-button { width: 32px; height: 32px; background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); font-size: 13px; font-weight: 500; }
.profile-button:hover { box-shadow: none; border-color: var(--text-muted); }
@media (pointer: coarse) { .profile-button { width: 44px; height: 44px; } }
.conv-item { min-height: var(--tap); font-size: 14px; color: var(--text-muted); border-radius: 6px; }
.conv-item:hover { color: var(--text); }
.conv-item .delete-btn, .conv-item .rename-btn { min-width: 32px; min-height: 32px; opacity: 0.5; font-size: 15px; }
.conv-item .delete-btn:hover { color: var(--danger); opacity: 1; }
.conv-item.active { background: var(--surface-alt); color: var(--text); box-shadow: none; }
@media (pointer: coarse), (max-width: 819px) { .conv-item .delete-btn, .conv-item .rename-btn { min-width: 44px; min-height: 44px; opacity: 1; } }
.lightbox-btn { width: var(--tap); height: var(--tap); }
.input-btn { width: var(--tap); height: var(--tap); border-radius: 8px; color: var(--text-muted); }
.input-btn:hover:not(:disabled) { background: var(--surface-alt); color: var(--text); }
.send-btn { background: none; color: var(--accent); }
.send-btn:hover:not(:disabled) { background: var(--surface-alt); color: var(--link); }
.send-btn:disabled { background: none; color: var(--text-muted); }
.mic-btn { color: var(--text-muted); }
.chat-form { border: 1px solid var(--border); border-radius: 10px; padding: 4px 6px; box-shadow: none; align-items: flex-end; background: var(--surface); }
.chat-form:focus-within { border-color: var(--accent); }
.chat-form textarea { padding: 8px 6px; min-height: var(--tap); }
.settings-msg.ok { color: var(--ok); } .settings-msg.err, .auth-box .error { color: var(--danger); font-size: 14px; }
.saved-del:hover { color: var(--danger); }
.send-failure { background: var(--surface-alt); border-color: var(--border); }
.send-failure-msg { color: var(--text); font-size: 15px; }
.send-failure-btn.primary:hover { background: var(--accent); }
.exercise-media { background: #fff; }
.field-label { font-size: 14px; color: var(--text-muted); }
.settings-section { box-shadow: none; }
.settings-section h3 { font-size: 13px; color: var(--text-muted); border-left: none; padding-left: 0; font-weight: 500; letter-spacing: 0.02em; }
.sync-status.connected { border-color: var(--ok); }

/* Layout: conversations sidebar (drawer on phones, fixed column on desktop), chat as the main pane, composer at the bottom */
.workspace-header { background: var(--bg); border-bottom: 1px solid var(--border); }
.workspace-head-inner { min-height: 44px; padding: 4px 16px; padding-top: calc(4px + env(safe-area-inset-top, 0px)); }
.chat-input-area { border-top: none; padding-top: 4px; }
@media (max-width: 700px) {
  .chat-messages { padding: 12px; }
  .message { max-width: 100%; padding: 8px 10px; }
  .message.user { max-width: 92%; }
  .chat-input-area { padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
}

/* Messages: flat, no loud bubbles. Yours has a faint fill; replies sit on the page. */
.chat-messages { gap: 12px; }
.message { box-shadow: none; border-radius: 8px; padding: 8px 12px; max-width: 100%; }
.message.user { align-self: flex-end; max-width: 80%; background: var(--user-bg); border: 1px solid var(--border); border-left: 1px solid var(--border); }
.message.assistant { align-self: stretch; background: transparent; border: none; padding-left: 0; padding-right: 0; }
.typing-indicator { background: transparent; border: none; padding: 4px 0; }
.typing-indicator > span { background: var(--text-muted); }
.typing-indicator .typing-note { font-size: 13px; }

/* Empty state: one quiet line of examples */
.empty-line { font-size: 14px; color: var(--text-muted); line-height: 1.8; max-width: none; }
.example-link { background: none; border: none; padding: 0; font-size: 14px; color: var(--link); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.example-link:hover { color: var(--text); }
@media (pointer: coarse) { .example-link { min-height: 44px; padding: 0 4px; } }

.steps-done { align-self: flex-start; max-width: 100%; font-size: 13px; margin: 2px 0; }
.steps-toggle { background: none; border: none; border-radius: 4px; padding: 2px 0; font-size: 13px; font-weight: 400; color: var(--text-muted); cursor: pointer; min-height: 0; }
.steps-toggle::before { content: ""; }
.steps-toggle:hover { color: var(--text); background: none; border: none; }
.steps-body { border-left: 1px solid var(--border); margin-top: 2px; padding: 2px 10px; }
.step-row { padding: 1px 0; font-size: 13px; }
.step-icon { color: var(--text-muted); }

/* Deliverable cards: flat and subtle */
.dl-card { margin: 10px 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-left: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.dl-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 !important; padding: 7px 12px; font-size: 12.5px !important; font-weight: 500 !important; letter-spacing: 0.02em; text-transform: none; color: var(--text-muted); background: transparent; border-bottom: 1px solid var(--border); }
.dl-count { font-size: 12.5px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text-muted); }
.dl-list { list-style: none; margin: 0 !important; padding: 2px 8px !important; }
.dl-list .dl-item { margin: 0; border-bottom: 1px solid var(--border); }
.dl-list .dl-item:last-child { border-bottom: none; }
.dl-steps .dl-list { counter-reset: dl; }
.dl-steps .dl-item label { counter-increment: dl; display: flex; align-items: flex-start; gap: 10px; min-height: var(--tap); padding: 8px 4px; cursor: pointer; }
.dl-steps .dl-item label::before { content: counter(dl) "."; flex: 0 0 22px; color: var(--text-muted); font-size: 14px; order: 1; text-align: right; }
.dl-check { order: 0; flex: 0 0 20px; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent-dim); cursor: pointer; }
.dl-steps .dl-text { order: 2; flex: 1; min-width: 0; }
.dl-item.done .dl-text { text-decoration: line-through; color: var(--text-muted); }
.dl-parts .dl-item { padding: 8px 4px; display: block; }
.dl-parts .dl-item::before { content: "\2022  "; color: var(--text-muted); }
.dl-btn { min-height: 0; padding: 2px 8px; background: none; color: var(--link); border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; font-weight: 400; letter-spacing: 0; text-transform: none; cursor: pointer; }
.dl-btn:hover { background: var(--surface-alt); }
@media (pointer: coarse) { .dl-btn { min-height: 44px; padding: 0 12px; } }
.dl-cost .md-body, .dl-safety .md-body, .dl-assumptions .md-body, .dl-note { padding: 8px 12px; }
.dl-note { font-size: 15px; color: var(--text-muted); }
.dl-cost, .dl-safety, .dl-assumptions { border-left: 1px solid var(--border); }
.dl-safety .dl-title { color: var(--text); }
.dl-assumptions .md-body { color: var(--text-muted); font-size: 15px; }
.dl-card .md-body p:last-child { margin-bottom: 0; }

/* Charts, layouts, mockups */
.chart-card, .svg-diagram { margin: 10px 0; }
.chart-card img, .svg-diagram img { width: 100%; max-width: 640px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.svg-save { display: inline-flex; align-items: center; font-size: 13px; font-weight: 400; color: var(--link); }
@media (pointer: coarse) { .svg-save { min-height: 44px; } }
.svg-pending { color: var(--text-muted); font-size: 14px; }
.svg-fallback { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); font-size: 13px; max-height: 240px; overflow: auto; }
.layout-fig { margin: 10px 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.layout-frame { display: block; width: 100%; border: 0; background: #fff; }
.layout-actions { display: flex; gap: 8px; padding: 6px 10px; background: var(--surface); border-top: 1px solid var(--border); }
.overlay-fig { margin: 10px 0; max-width: 720px; }
.overlay-canvas { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-alt); }
.overlay-actions { display: flex; gap: 14px; align-items: center; padding: 4px 0; }
.overlay-caption { font-size: 12.5px; color: var(--text-muted); }
.overlay-missing { margin: 8px 0; }

/* Photos */
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.photo-fig { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.photo-fig img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; cursor: zoom-in; background: var(--surface-alt); }
.photo-fig figcaption { padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.35; }
.photo-title { font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.photo-credit { color: var(--text-muted); overflow-wrap: anywhere; }
.photo-credit a { color: var(--link); }
.photo-fig.photo-missing { display: none; }

/* Print: only the chosen layout */
@media print {
  html, body, #app { height: auto !important; overflow: visible !important; background: #fff !important; }
  body.printing-layout #app * { visibility: hidden !important; }
  body.printing-layout .print-target, body.printing-layout .print-target * { visibility: visible !important; }
  body.printing-layout #app, body.printing-layout .app-workspace, body.printing-layout .app-screen, body.printing-layout .chat-app, body.printing-layout .chat-main, body.printing-layout .chat-messages { display: block !important; position: static !important; overflow: visible !important; height: auto !important; max-width: none !important; }
  body.printing-layout .print-target { position: absolute; left: 0; top: 0; width: 100%; border: none; }
  body.printing-layout .print-target .layout-frame { height: 1000px !important; }
  body.printing-layout .layout-actions { display: none !important; }
}

/* Motion: respect the system setting */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .crew-dot { animation: none; opacity: 0.7; }
}

/* Logo mark: quiet, small. */
.mark { display: inline-block; vertical-align: middle; border-radius: 6px; opacity: 0.9; }
.mark-lg { border-radius: 14px; }
.auth-mark { display: flex; justify-content: center; margin-bottom: 20px; }
.hero-mark { display: flex; justify-content: center; }
.smart-empty:empty { min-height: 1px; }

/* Interactive app blocks: quiet frame, starts only on Run. */
.app-fig { margin: 12px 0; border: 1px solid var(--border, rgba(127,127,127,.25)); border-radius: 8px; overflow: hidden; }
.app-bar { display: flex; gap: 14px; padding: 6px 10px; font-size: 13px; }
.app-stage:empty { display: none; }
.app-frame { display: block; width: 100%; height: 440px; border: 0; background: #fff; }
@media (max-width: 600px) { .app-frame { height: 380px; } }
@media (pointer: coarse) { .steps-toggle { min-height: 44px; padding: 0 4px; } }

/* Darkhorse Labs logo: crisp facets, a thin white edge light, a small eye. Colors are theme variables. */
.logo-svg { display: block; flex: none; }
.logo-base { fill: var(--logo-base); }
.logo-f1 { fill: var(--logo-f1); } .logo-f2 { fill: var(--logo-f2); } .logo-f3 { fill: var(--logo-f3); }
.logo-f4 { fill: var(--logo-f4); } .logo-f5 { fill: var(--logo-f5); } .logo-f6 { fill: var(--logo-f6); }
.logo-rim { stroke: var(--logo-rim); stroke-width: 0.7; stroke-linejoin: miter; }
.logo-edge { stroke: var(--logo-edge); stroke-width: 2.6; }
.logo-glow { stroke: var(--logo-glow); stroke-width: 2.4; opacity: 0.5; }
.logo-eye { fill: var(--logo-eye); }
.logo-eye-halo { opacity: 0.35; }
.logo-stop { stop-color: var(--logo-eye); }
.logo-hero { display: inline-flex; }
.logo-live, .act-logo { display: inline-flex; }
.logo-hero .logo-eye { animation: eyeGlow 8s ease-in-out infinite; }
.logo-hero .logo-eye-halo { animation: haloGlow 8s ease-in-out infinite; }
.logo-hero .logo-edge, .logo-hero .logo-glow { animation: edgeShimmer 8s ease-in-out infinite; }
.logo-live .logo-eye { animation: eyePulse 2.4s ease-in-out infinite; }
.logo-live .logo-eye-halo { animation: haloPulse 2.4s ease-in-out infinite; }
@keyframes eyeGlow { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes haloGlow { 0%, 100% { opacity: 0.1; } 50% { opacity: 0.7; } }
@keyframes edgeShimmer { 0%, 100% { opacity: 0.75; } 45% { opacity: 1; } 70% { opacity: 0.6; } }
@keyframes eyePulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@keyframes haloPulse { 0%, 100% { opacity: 0.1; } 50% { opacity: 0.8; } }
/* Wordmark */
.brand-lockup { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.wordmark { display: inline-flex; align-items: baseline; gap: 0.5em; font-family: var(--font); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; white-space: nowrap; color: var(--text); }
.wm-a { font-weight: 800; }
.wm-b { font-weight: 300; color: var(--wm-light); }
.wordmark-lg { font-size: 17px; letter-spacing: 0.3em; }
.sidebar-brand { display: inline-flex; align-items: center; overflow: hidden; }
.sidebar-brand .wordmark { font-size: 10px; letter-spacing: 0.16em; }
.auth-mark { flex-direction: column; align-items: center; gap: 14px; }
.empty-state.smart-empty { position: relative; max-width: 760px; width: 100%; align-items: center; justify-content: center; gap: 14px; padding: 8px 0; text-align: center; }
/* Very faint scanline + grid texture behind the new-chat logo only. */
.empty-state.smart-empty::before { content: ""; position: absolute; left: 50%; top: 50%; width: min(520px, 100%); height: 320px; transform: translate(-50%, -50%); pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(0deg, var(--scan) 0 1px, transparent 1px 4px), repeating-linear-gradient(90deg, var(--scan) 0 1px, transparent 1px 48px);
  -webkit-mask-image: radial-gradient(closest-side, #000 25%, transparent 100%); mask-image: radial-gradient(closest-side, #000 25%, transparent 100%); }
.empty-state.smart-empty > * { position: relative; z-index: 1; }
.sidebar-header .sidebar-title { flex: 1; min-width: 0; }
.empty-line { font-size: 14px; color: var(--text-muted); line-height: 1.6; max-width: none; margin: 0; }

/* Live activity: tiny logo line + a light streaming list. No boxes, borders, backgrounds or bars. */
.typing-indicator.act { display: block; align-self: flex-start; max-width: 100%; padding: 4px 0; }
.act-head { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }
.act-logo { display: inline-flex; }
.typing-indicator.act .typing-note { margin: 0; font-style: normal; font-size: 13px; color: var(--text-muted); }
.act-time { font-family: var(--mono); font-size: 12px; color: var(--text-muted); opacity: 0.7; font-variant-numeric: tabular-nums; }
.act-feed { list-style: none; margin: 4px 0 0 23px; padding: 0; max-height: 7.8em; overflow-y: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.6em); mask-image: linear-gradient(to bottom, transparent 0, #000 1.6em); }
.act-feed::-webkit-scrollbar { display: none; }
.act-feed:empty { display: none; }
.act-row, .steps-list .step-row { color: var(--text-muted); font-size: 12.5px; font-family: var(--mono); }
.act-row { animation: actIn 0.4s ease-out both; }
@keyframes actIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.act-row .step-icon, .steps-list .step-icon { color: var(--text-muted); opacity: 0.75; }
.act-row a, .steps-list a { color: var(--link); text-decoration: none; }
.act-row a:hover, .steps-list a:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
  .logo-hero .logo-eye, .logo-hero .logo-eye-halo, .logo-hero .logo-edge, .logo-hero .logo-glow, .logo-live .logo-eye, .logo-live .logo-eye-halo, .act-row, .micrec, .mic-btn.recording { animation: none !important; }
  .logo-hero .logo-eye, .logo-live .logo-eye { opacity: 1; }
  .logo-eye-halo { opacity: 0.35; }
}

/* Conversations sidebar: quiet groups, search, select mode, Notes/Settings links. */
@media (min-width: 820px) {
  .sidebar { position: static; transform: none; width: 260px; max-width: none; box-shadow: none; transition: none; z-index: auto; }
  .sidebar-overlay, .sidebar-overlay.open { display: none; }
}
.sidebar-header { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); gap: 8px; }
.conv-tools { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.conv-tools .nav-search { flex: 1 1 auto; min-width: 0; margin: 0; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 13px; outline: none; }
.conv-tools .nav-search:focus { border-color: var(--accent-dim); }
.text-link { background: none; border: none; padding: 4px 2px; font-family: var(--font); font-size: 12.5px; color: var(--link, var(--accent)); cursor: pointer; }
.text-link:hover { text-decoration: underline; }
.text-link:disabled { opacity: 0.45; cursor: default; text-decoration: none; }
.text-link.danger { color: var(--danger); }
.conv-group-head { display: block; width: 100%; padding: 10px 12px 4px; font-family: var(--font); font-size: 11px; letter-spacing: 0.02em; color: var(--text-muted); background: none; border: none; text-align: left; }
.conv-older-toggle { cursor: pointer; }
.conv-older-toggle:hover { color: var(--text); }
.conv-count { opacity: 0.7; }
.conv-empty { padding: 12px; font-size: 13px; color: var(--text-muted); }
.conv-check { margin: 0 8px 0 0; flex: 0 0 auto; accent-color: var(--accent-dim); }
.conv-item .pin-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px 4px; opacity: 0.5; font-family: var(--font); display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; }
.conv-item .pin-btn:hover, .conv-item .pin-btn.on { color: var(--accent); opacity: 1; }
.conv-item .pin-btn.on svg { fill: currentColor; }
@media (hover: hover) and (pointer: fine) {
  .conv-item .rename-btn, .conv-item .delete-btn, .conv-item .pin-btn:not(.on) { opacity: 0; }
  .conv-item:hover .rename-btn, .conv-item:hover .delete-btn, .conv-item:hover .pin-btn,
  .conv-item:focus-within .rename-btn, .conv-item:focus-within .delete-btn, .conv-item:focus-within .pin-btn { opacity: 0.7; }
  .conv-item .pin-btn.on { opacity: 0.9; }
}
@media (pointer: coarse), (max-width: 819px) { .conv-item .pin-btn { min-width: 44px; min-height: 44px; } }
.conv-select-bar { padding: 6px 14px; border-top: 1px solid var(--border); }
.conv-select-bar[hidden] { display: none; }
.sidebar-foot { display: flex; align-items: center; gap: 18px; padding: 8px 14px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); }
.sidebar-foot .text-link { color: var(--text-muted); font-size: 13px; }
.sidebar-foot .text-link:hover { color: var(--text); }
.back-utility { font-size: 18px; padding: 0; }

/* ---- Monochrome finish: links, selection, focus, controls ---- */
::selection { background: var(--text); color: var(--bg); }
a, .md-body a, .step-row a, .steps-done a, .crew-row a, .photo-credit a, .act-row a, .steps-list a, .svg-save, .example-link, .text-link { color: var(--link); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--text-muted); }
a:hover, .md-body a:hover, .act-row a:hover, .steps-list a:hover, .text-link:hover { text-decoration-color: var(--link); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; box-shadow: 0 0 0 4px var(--bg); }
input, textarea, select { caret-color: var(--text); accent-color: var(--accent-dim); }
.timestamp, .msg-time, .act-time, .dl-count, .conv-count, .chart-bar-val, .chart-legend-val, .overlay-caption, .photo-credit { font-family: var(--mono); }
.chart-bar-fill, .chart-swatch { outline: 1px solid var(--border); }
.overlay-actions .text-link, .overlay-actions button { color: var(--link); }
