:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: #16171a;
  --surface-2: #1d1f24;
  --border: #2a2d33;
  --text: #e8eaee;
  --text-dim: #8b8f98;
  --accent: #ff9f43;
  --user: #2a4365;
  --assistant: #2b2b2b;
  --danger: #e06662;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  /* --app-h is set by viewport.ts (measured visualViewport.height). We fall
   * back to 100dvh for the brief interval before the script runs. */
  height: var(--app-h, 100dvh);
  overflow: hidden;
  box-sizing: border-box;
}

body.chat .app,
body.voice .voice-app {
  display: flex;
  flex-direction: column;
  height: 100%;
}
body.chat .app > *, body.voice .voice-app > * { flex-shrink: 0; }
body.chat .log, body.voice .voice-stage { flex-shrink: 1; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 8px;
}
.brand {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 16px;
}
.topbar a {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
}
.topbar a:hover { background: var(--border); }
.spacer { width: 36px; }

/* Chat */
.log {
  flex: 1;
  min-height: 0;        /* allow the scroll container to shrink inside flex */
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.msg {
  max-width: 86%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant, .msg.system { align-self: flex-start; align-items: flex-start; }
.bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--assistant);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.4;
  font-size: 15px;
}
.bubble pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble img, .bubble video { max-width: 100%; height: auto; }
.bubble table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.msg.user .bubble {
  background: var(--user);
}
.msg.system .bubble {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 13px;
}
.meta {
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Per-message replay button: small, sits inline with the timestamp under each
 * assistant bubble. Flips between a play triangle and a stop square while the
 * message is speaking; see tts.ts / play-button.ts. */
.play-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 2px;
  margin: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 120ms, background 120ms;
}
.play-btn:hover { color: var(--text); background: var(--surface-2); }
.play-btn[data-playing="1"],
.play-btn[data-state="playing"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
}
/* Cached audio: icon already filled via the SVG swap in play-button.ts;
 * give the button a subtle tint so "instant playback" is visually distinct
 * from the first-time "will synthesize" outline. */
.play-btn[data-state="cached"] {
  color: var(--text);
}
/* Stale cache: profile/language differ from current preference. Tiny dot
 * hint renders via ::after so existing SVG layout stays untouched. */
.play-btn[data-state="cached-stale"] {
  color: var(--text);
  position: relative;
}
.play-btn[data-state="cached-stale"]::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.play-btn[data-state="regenerating"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-2));
  animation: play-btn-spin 900ms linear infinite;
}
@keyframes play-btn-spin { to { transform: rotate(360deg); } }
.play-btn svg { display: block; }

/* Composer */
.composer {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
  /* The composer is not the bottommost element on chat (nav sits below),
   * but when the nav is hidden (none today, kept for safety) this still
   * sits inside the safe area. */
}
.composer textarea { font-size: 16px; } /* Prevent iOS zoom-on-focus */
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 15px;
  max-height: 160px;
  font-family: inherit;
  line-height: 1.4;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.composer button {
  border: none;
  background: var(--accent);
  color: #1a1a1a;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.composer button:hover { filter: brightness(1.05); }
.composer button:disabled { opacity: 0.6; cursor: not-allowed; }

/* Voice */
.voice-stage {
  flex: 1;
  min-height: 0;        /* same flex fix as .log */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  overflow-y: auto;
}
.record {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 150ms, background 150ms, border-color 150ms;
}
.record:hover { background: var(--surface-2); }
.record:active { transform: scale(0.97); }
.record[data-state="recording"] {
  border-color: var(--danger);
  background: rgba(224, 102, 98, 0.1);
  animation: pulse 1.4s ease-in-out infinite;
}
.record[data-state="uploading"] {
  border-color: var(--accent);
  cursor: progress;
}
.record[data-state="delay"] {
  border-color: var(--accent);
  background: rgba(255, 159, 67, 0.1);
}
.record-dot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--danger);
  transition: border-radius 150ms, transform 150ms, opacity 150ms;
}
.record-count {
  position: absolute;
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.record { position: relative; }
.record[data-state="idle"] .record-dot,
.record[data-state="done"] .record-dot,
.record[data-state="error"] .record-dot {
  background: var(--danger);
}
.record[data-state="recording"] .record-dot {
  border-radius: 8px;
  background: var(--danger);
}
.record[data-state="uploading"] .record-dot {
  background: var(--accent);
  animation: spin 1s linear infinite;
}
.record[data-state="delay"] .record-dot {
  opacity: 0;
}

.status { color: var(--text-dim); font-size: 14px; text-align: center; padding: 0 16px; }

/* Continuous (hands-free) mode. Issue m/mAi#111. The toggle lives as the
 * first chip in #mode-switch (replacing the former data-mode="auto" chip
 * per m's UI direction). Four visual phases via data-phase: off (muted),
 * passive (gentle pulse), active (strong red pulse), error (red). A dot
 * inside the chip carries the animation. */
.continuous-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;          /* match the SVG-icon chip footprint */
}
.continuous-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.continuous-chip .continuous-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  transition: background 120ms;
}
.continuous-chip[data-phase="passive"] {
  color: var(--accent);
}
.continuous-chip[data-phase="passive"] .continuous-dot {
  background: var(--accent);
  animation: continuous-pulse 1.8s ease-in-out infinite;
}
.continuous-chip[data-phase="active"] {
  background: rgba(224, 102, 98, 0.15);
  color: var(--danger);
}
.continuous-chip[data-phase="active"] .continuous-dot {
  background: var(--danger);
  animation: continuous-pulse 0.9s ease-in-out infinite;
}
.continuous-chip[data-phase="uploading"] {
  color: var(--accent);
}
.continuous-chip[data-phase="uploading"] .continuous-dot {
  background: var(--accent);
  animation: continuous-pulse 0.6s ease-in-out infinite;
}
.continuous-chip[data-phase="error"] {
  color: var(--danger);
}
.continuous-chip[data-phase="error"] .continuous-dot {
  background: var(--danger);
}
@keyframes continuous-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.25); }
}

/* Voice mode switch */
.mode-switch {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.mode-chip {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.mode-chip.active {
  background: var(--accent);
  color: #1a1a1a;
}
.mode-chip:not(.active):hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Confirm + delay panels */
.confirm-panel {
  width: min(520px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.confirm-panel textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: vertical;
  min-height: 96px;
}
.confirm-panel textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-primary, .btn-ghost {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}


/* Bottom navigation (shared across chat / voice / history). */
/* Nav is pinned to the bottom of the *visible* viewport (height comes from
 * JS via --app-h), with its own safe-area padding so it never hides under
 * the Android gesture bar. Layouts below reserve space via --nav-h. */
.bottom-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: var(--safe-bottom, 16px);
  position: relative;
}
.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 0 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.02em;
  font-weight: 500;
  /* Block the browser from claiming vertical drag for scroll/selection so the
   * slide-up gesture (otto#395) reaches pointermove. Without this the center
   * capture button worked because it already had touch-action:none — Chat and
   * Lists did not. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.bottom-nav .nav-item.active { color: var(--accent); }
.bottom-nav .nav-item:active { background: var(--surface-2); }

/* Wrapper for the center capture button + floating discard. */
.capture-wrap {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
}
.quick-discard {
  position: absolute;
  bottom: calc(100% + 14px);           /* clear of the capture button */
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  z-index: 300;                        /* above the toast */
}
/* [hidden] wins by !important so our display value below doesn't leak. */
.quick-discard[hidden] { display: none !important; }
.quick-discard:not([hidden]) { display: inline-flex; }
.quick-discard:hover { background: var(--surface-2); }

/* Center capture button */
.capture-btn {
  border: 0;
  background: var(--accent);
  color: #1a1a1a;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin: -16px 6px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(255, 159, 67, 0.35);
  cursor: pointer;
  transition: transform 120ms, background 120ms, box-shadow 120ms;
  touch-action: none;
}
.capture-btn:active { transform: scale(0.96); }
.capture-btn[data-state="recording"] {
  background: var(--danger);
  box-shadow: 0 4px 18px rgba(224, 102, 98, 0.55);
  animation: capture-pulse 1.4s ease-in-out infinite;
}
.capture-btn[data-state="uploading"] {
  background: var(--text-dim);
}
@keyframes capture-pulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(224, 102, 98, 0.35); }
  50%      { box-shadow: 0 4px 24px rgba(224, 102, 98, 0.9); }
}

/* Quick-record status toast — pinned to the top of the viewport so it
 * never covers the capture button or the discard pill. */
.quick-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  top: calc(env(safe-area-inset-top, 0) + 10px);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms, transform 120ms;
  z-index: 200;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.quick-toast[data-state="recording"] { border-color: var(--danger); }
.quick-toast[data-state="error"] { border-color: var(--danger); color: var(--danger); }
.quick-toast[data-state="done"] { border-color: var(--accent); color: var(--accent); }

/* Voice modal — bottom sheet. Native <dialog> centers by default, so we
 * pin to the bottom explicitly. Closed state stays `display: none` (scoped
 * to [open]) or the sheet would be visible on page load. */
.voice-modal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  margin: 0 auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow: hidden;
  transition: transform 180ms ease-out;
}
.voice-modal[open] {
  display: flex;
  flex-direction: column;
}
.voice-modal.dragging { transition: none; }
.voice-modal::backdrop { background: rgba(0, 0, 0, 0.55); }
.voice-modal-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 8px auto 0;
  flex-shrink: 0;
  touch-action: none;          /* let JS handle the drag */
  cursor: grab;
}
.voice-modal-handle-hit {
  /* Large tap target so the thin grab line is easy to hit with a thumb. */
  width: 100%;
  padding: 12px 0 6px;
  display: flex;
  justify-content: center;
  touch-action: none;
  cursor: grab;
}
.voice-modal-handle-hit:active { cursor: grabbing; }
.voice-modal .voice-stage {
  padding: 18px 24px 8px;
  flex: 1;
  overflow-y: auto;
}
.voice-modal-foot {
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.btn-wide {
  width: 100%;
  padding: 14px;
  font-size: 15px;
}

/* Icon-only buttons in topbars (reload, etc.) */
.icon-btn {
  background: var(--surface-2);
  border: 0;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: var(--border); }

.topbar-actions { display: inline-flex; gap: 6px; }
.btn-close-chevron {
  width: 100%;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mode-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 36px;
  padding: 0;
}
.mode-chip svg { display: block; }

.btn-primary.icon-only, .btn-ghost.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  min-width: 54px;
}
.day-divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 0 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* History list as collapsible sessions. */
.history-log {
  display: block;              /* override chat's flex column */
  padding: 10px;
}
.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 0;
}
.session {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}
.session[open] { background: var(--surface-2); }
.session-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.session-summary::-webkit-details-marker { display: none; }
.session-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.session-count { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.session-preview {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.session-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

/* Queue badge + panel on voice-app */
.queue-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1a1a;
  border: 0;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.queue-badge:hover { filter: brightness(1.05); }

.queue-panel {
  width: min(520px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.queue-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 14px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 102, 98, 0.5); }
  50%      { box-shadow: 0 0 0 16px rgba(224, 102, 98, 0); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Token dialog */
.token-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 320px;
}
.token-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.token-dialog h2 { margin: 0 0 6px; font-size: 18px; }
.token-dialog .hint { color: var(--text-dim); font-size: 13px; margin: 0 0 12px; }
.token-dialog input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: monospace;
}
.token-dialog .actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.token-dialog button {
  padding: 8px 16px;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 1000;
}

/* Voice Mode toggle (topbar). Same dimensions as other topbar icons. */
.voice-mode-btn {
  appearance: none;
  background: var(--surface-2);
  color: var(--text-dim);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color 120ms, background 120ms;
}
.voice-mode-btn:hover { background: var(--border); }
.voice-mode-btn .wave { opacity: 0; transition: opacity 120ms; }
.voice-mode-btn .off-slash { opacity: 1; transition: opacity 120ms; }
.voice-mode-btn[data-on="1"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
}
.voice-mode-btn[data-on="1"] .wave { opacity: 1; }
.voice-mode-btn[data-on="1"] .off-slash { opacity: 0; }

/* Speaking indicator: shows while TTS fetch + playback is in flight. Lives
 * right under the topbar so it doesn't reflow the chat log. */
.speaking {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.speaking[hidden] { display: none; }
.speaking .dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.speaking .dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: speaking-pulse 900ms infinite ease-in-out;
}
.speaking .dots span:nth-child(2) { animation-delay: 150ms; }
.speaking .dots span:nth-child(3) { animation-delay: 300ms; }
@keyframes speaking-pulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1.1); }
}

/* --- Lists-Tab (otto#385) --------------------------------------------------*/

/* 4-slot nav with the center capture still floating. */
.bottom-nav-4 {
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
}
/* Chat + Lists live in cols 1-2; capture in 3; History in col 4. Col 5 keeps
 * the layout symmetrical around the capture button. */
.bottom-nav-4 > .nav-item:nth-child(1) { grid-column: 1; }
.bottom-nav-4 > .nav-item:nth-child(2) { grid-column: 2; }
.bottom-nav-4 > .capture-wrap          { grid-column: 3; }
.bottom-nav-4 > .nav-item:nth-child(4) { grid-column: 4 / span 2; }

/* 5-slot nav (mAi#228) — Chat / Lists / [capture] / Today / Projax. */
.bottom-nav-5 {
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
}
.bottom-nav-5 > .nav-item:nth-child(1) { grid-column: 1; }
.bottom-nav-5 > .nav-item:nth-child(2) { grid-column: 2; }
.bottom-nav-5 > .capture-wrap          { grid-column: 3; }
.bottom-nav-5 > .nav-item:nth-child(4) { grid-column: 4; }
.bottom-nav-5 > .nav-item:nth-child(5) { grid-column: 5; }

/* Capture target selector inside the voice modal. */
.capture-target {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 12px 10px;
  scrollbar-width: none;
}
.capture-target::-webkit-scrollbar { display: none; }
.target-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}
.target-chip.active {
  background: var(--accent);
  color: #1a1a1a;
  border-color: transparent;
  font-weight: 600;
}

/* Overview page. */
.lists-log {
  padding: 12px 14px 90px;      /* bottom-nav room */
  overflow: auto;
  height: 100%;
  position: relative;
}
.lists-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 520px) {
  .lists-grid { grid-template-columns: repeat(4, 1fr); }
}
.list-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.list-card:active { background: var(--surface-2); }
.list-card-icon { font-size: 20px; }
.list-card-label { font-weight: 600; letter-spacing: 0.02em; }
.list-card-count {
  font-size: 13px;
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface-2);
}
.list-card-count[data-state="has"] { color: var(--accent); }
.list-card-count-word { display: none; }
@media (min-width: 360px) { .list-card-count-word { display: inline; } }
.list-card-chev { color: var(--text-dim); font-size: 18px; }

.lists-recent {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.lists-recent-head {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.task-row-recent { border-bottom: 1px solid var(--border); }
.task-row-recent:last-child { border-bottom: 0; }
.task-row-link {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  padding: 8px 2px;
  text-decoration: none;
  color: var(--text);
}
.task-row-recent .task-row-meta {
  display: inline-flex;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
}
.task-row-list {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 6px;
}

.lists-empty, .lists-error {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}
.lists-error { color: var(--danger); }

/* Detail page. */
body.list-detail .task-list {
  overflow: auto;
  padding: 0 12px 90px;
  position: relative;
}
.task-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.task-add-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  font-size: 15px;
}
.task-add-input:focus {
  outline: none;
  border-color: var(--accent);
}
.task-add button {
  border: 0;
  background: var(--accent);
  color: #1a1a1a;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
}
.filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}
.filter-chip.active {
  background: var(--accent);
  color: #1a1a1a;
  border-color: transparent;
  font-weight: 600;
}

.task-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.task-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  transition: transform 120ms;
  touch-action: pan-y;
}
.task-row[data-swipe="done"]   { background: rgba(68, 170, 100, 0.08); }
.task-row[data-swipe="delete"] { background: rgba(224, 102, 98, 0.08); }
.task-row-sent { opacity: 0.5; }
.task-row-done .task-row-summary {
  color: var(--text-dim);
  text-decoration: line-through;
}
.task-row-check {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
}
.task-check {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  position: relative;
}
.task-check:checked {
  background: var(--accent);
  border-color: transparent;
}
.task-check:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 12px;
  border-right: 2px solid #1a1a1a;
  border-bottom: 2px solid #1a1a1a;
  transform: rotate(45deg);
}
.task-row-summary { font-size: 15px; }
.task-row-meta {
  display: flex;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}
.task-row-due { color: var(--accent); }
.task-row-tag {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 6px;
}
.task-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.task-row-delete {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 6px;
  cursor: pointer;
}
.task-row-delete:hover { color: var(--danger); }
.task-row-promote {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  padding: 6px;
  border-radius: 6px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.task-row-promote:hover { color: var(--accent); background: var(--surface-2); }
.task-row-promote:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Templated checklist groups (otto#396). When 2+ open tasks share a
   `checklist:<prefix>-<date>` CATEGORY tag, list-detail.ts renders them
   under one of these collapsible headers. */
.checklist-group-header {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin: 12px 0 4px;
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}
.checklist-group-header:hover { filter: brightness(1.05); }
.checklist-group-icon { font-size: 16px; }
.checklist-group-title { font-weight: 600; }
.checklist-group-meta {
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.checklist-group-chevron {
  color: var(--text-dim);
  font-size: 14px;
  width: 16px;
  text-align: center;
}

.done-section { margin-top: 16px; }
.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 12px;
  padding: 8px 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.done-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Pull-to-refresh visual. */
.pull-indicator {
  position: absolute;
  top: -44px;
  left: 0;
  right: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 20px;
  pointer-events: none;
  transition: transform 180ms ease-out;
  z-index: 10;
}
.pull-indicator[data-state="ready"] { color: var(--accent); }
.pull-indicator[data-state="refreshing"] {
  animation: pull-spin 800ms linear infinite;
}
@keyframes pull-spin { to { transform: rotate(360deg); } }

/* Action chips under an assistant bubble (otto#390 Phase 2). Dezent: text-
 * link register, sits next to the play button, no pill background. Each chip
 * prefixed with a subtle ↵ so it reads as "tap to reply with this". */
.action-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 2px;
  padding: 0 2px;
  font-size: 12px;
  line-height: 1.4;
}
.action-chip {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 2px 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.action-chip::before {
  content: "↵ ";
  opacity: 0.6;
  margin-right: 2px;
}
.action-chip-task::before { content: "＋ "; }
.action-chip:hover:not([disabled]) { text-decoration: underline; }
.action-chip[data-state="done"] {
  color: var(--text-dim);
  opacity: 0.5;
  cursor: default;
  text-decoration: line-through;
}

/* Multi-question forms under an assistant bubble (otto#409). Same register
 * as action-chips: lives below the bubble text, visually part of the
 * bubble. Hard-coded UI strings are English per m's 2026-04-19 policy;
 * Otto-authored labels can be any language. */
.otto-form-wrap {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.4;
}
.otto-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.otto-form-title {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.otto-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.otto-form-label {
  font-size: 12px;
  color: var(--text-dim);
}
.otto-form-req {
  color: var(--accent);
}
.otto-form-help {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.85;
}
.otto-form select,
.otto-form input[type="text"],
.otto-form input[type="number"],
.otto-form input[type="date"],
.otto-form textarea {
  appearance: none;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}
.otto-form textarea {
  resize: vertical;
  min-height: 48px;
}
.otto-form input[aria-invalid="true"],
.otto-form select[aria-invalid="true"],
.otto-form textarea[aria-invalid="true"] {
  border-color: var(--accent);
}
.otto-form-field-error {
  font-size: 11px;
  color: var(--accent);
}
.otto-form-multiselect {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.otto-form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.otto-form-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.otto-form-toggle-label {
  font-size: 13px;
}
.otto-form-range-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.otto-form-range-wrap input[type="range"] {
  flex: 1;
}
.otto-form-range-value {
  min-width: 2.5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.otto-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}
.otto-form-submit {
  appearance: none;
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #1a1a1a;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.otto-form-submit:disabled {
  opacity: 0.6;
  cursor: default;
}
.otto-form-error {
  font-size: 12px;
  color: var(--accent);
}
/* Submitted-state: compact read-only summary. Each Q/A pair stacks
 * vertically (label above answer) so the bubble width is dictated by the
 * longer of the two, not their sum — same intent as #137 for normal
 * bubbles. */
.otto-form-submitted {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-dim);
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}
.otto-form-submitted-header {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.otto-form-summary {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  min-width: 0;
}
.otto-form-summary dt {
  color: var(--text-dim);
  margin: 4px 0 0;
}
.otto-form-summary dt:first-child {
  margin-top: 0;
}
.otto-form-summary dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* Swipe-to-reply: visual affordance while a bubble is being dragged, plus
 * the reply-quote strip pinned above the composer (otto#390). */
.msg.assistant .bubble {
  touch-action: pan-y;
  will-change: transform;
}
.msg.assistant .bubble[data-swipe-state="ready"] {
  box-shadow: 0 0 0 2px var(--accent);
}

.reply-quote {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 8px 6px;
  border-radius: 10px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  font-size: 13px;
  color: var(--text-dim);
}
/* `display: flex` above has higher specificity than the UA [hidden] rule,
 * so the reply-quote strip stayed visible after clearQuote() set hidden.
 * Explicit override so it actually disappears after send. */
.reply-quote[hidden] {
  display: none;
}
.reply-quote-mark {
  color: var(--accent);
  font-weight: 700;
}
.reply-quote-text {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-quote-clear {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.reply-quote-clear:hover { color: var(--text); }

/* Quote header above a bubble that carries in_reply_to. Clickable when the
 * referenced message lives in the current log — otherwise it's a silent
 * marker that m was answering something earlier. */
.reply-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 8px 4px;
  max-width: 85%;
  cursor: pointer;
  text-decoration: none;
}
.reply-header:hover .reply-header-text { text-decoration: underline; }
.reply-header-mark { color: var(--accent); }
.reply-header-role { opacity: 0.7; font-style: italic; }
.reply-header-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

/* Flash animation when scrolling to a linked bubble. */
.msg-flash .bubble {
  animation: msg-flash 900ms ease-out;
}
@keyframes msg-flash {
  0%   { box-shadow: 0 0 0 0 var(--accent); }
  30%  { box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 60%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Today dashboard (otto#394). Stacked cards, read-only. */
.today-log {
  padding: 14px 14px 90px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.today-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
}
.today-card-head {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.today-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.today-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 10px;
  font-size: 14px;
  line-height: 1.35;
}
.today-row-time {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  white-space: nowrap;
}
.today-row-title {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.today-row-src {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.7;
}
.today-row-task {
  grid-template-columns: auto 1fr auto;
}
.today-row-task:not([data-overdue="1"]) .today-row-mark { display: none; }
.today-row-mark {
  font-size: 13px;
  line-height: 1.35;
}
.today-row-task[data-overdue="1"] .today-row-title {
  color: var(--danger, #dc2626);
  font-weight: 500;
}
.today-row-task[data-overdue="1"] .today-row-due {
  color: var(--danger, #dc2626);
  opacity: 1;
}
.today-row-meta {
  display: inline-flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.today-row-list {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  opacity: 0.85;
}
.today-row-due {
  color: var(--accent);
  opacity: 0.85;
}
.today-row-tag {
  opacity: 0.7;
}
.today-empty {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  padding: 4px 0;
}
.today-fetched {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.6;
  text-align: center;
  padding-top: 4px;
}

/* Feature-Sweep — review queue (mAi#169). Stacked cards, three chips per
 * card, optional inline note input. Shares the topbar / log layout with
 * Today; the cards themselves are sweep-specific. */
.sweep-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}
.sweep-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sweep-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sweep-card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sweep-card-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-decoration: none;
}
.sweep-card-link:hover { color: var(--text); }
.sweep-card-repo { font-variant-numeric: tabular-nums; }
.sweep-card-state {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
}
.sweep-card-state-closed { background: rgba(220, 38, 38, 0.15); color: #fca5a5; }
.sweep-card-state-open { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.sweep-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.sweep-card-meta {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}
.sweep-reason, .sweep-label {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.sweep-reason { color: var(--accent); opacity: 0.9; }
.sweep-card-tldr {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.85;
}
.sweep-card-comment {
  border-left: 2px solid var(--border);
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sweep-card-comment-link {
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
}
.sweep-card-comment-link:hover { color: var(--accent); }
.sweep-card-comment-body {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
  white-space: pre-wrap;
}
.sweep-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sweep-chip {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.sweep-chip:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
}
.sweep-chip:disabled { opacity: 0.5; cursor: default; }
.sweep-chip-close { border-color: rgba(34, 197, 94, 0.4); }
.sweep-chip-rework { border-color: rgba(220, 38, 38, 0.4); }
.sweep-card-note {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sweep-card-note[hidden] { display: none; }
.sweep-card-note-input {
  flex: 1 1 200px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.sweep-card-status {
  font-size: 12px;
  color: var(--text-dim);
}
.sweep-card-status[data-tone="ok"] { color: #86efac; }
.sweep-card-status[data-tone="error"] { color: #fca5a5; }
.sweep-card-status[hidden] { display: none; }

/* Cross-head inbox (mAi#229). Two-pane: card list + detail drawer. */
.heads-inbox-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}
.hi-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hi-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.hi-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hi-card-head-id {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.hi-card-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.hi-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  letter-spacing: 0.03em;
}
.hi-badge-pending { background: rgba(220, 38, 38, 0.15); color: #fca5a5; }
.hi-badge-read    { background: rgba(96, 165, 250, 0.15); color: #93c5fd; }
.hi-priority {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.hi-priority-3 { background: rgba(251, 146, 60, 0.2); color: #fdba74; }
.hi-priority-4 { background: rgba(220, 38, 38, 0.25); color: #fca5a5; font-weight: 600; }
.hi-card-latest {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--text-dim);
}
.hi-card-latest-from {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}
.hi-card-latest-subject {
  flex: 1 1 200px;
  color: var(--text);
}
.hi-card-latest-time { font-variant-numeric: tabular-nums; }
.hi-card-open {
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.hi-card-open:hover { border-color: var(--accent); }

.hi-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hi-detail[hidden] { display: none; }
.hi-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.hi-detail-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  font-variant-numeric: tabular-nums;
}
.hi-detail-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.hi-detail-count {
  font-size: 11px;
  color: var(--text-dim);
}
.hi-detail-loading { color: var(--text-dim); padding: 12px; }
.hi-detail-list { display: flex; flex-direction: column; gap: 10px; }
.hi-msg {
  border-left: 2px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hi-msg-pending { border-left-color: rgba(220, 38, 38, 0.6); }
.hi-msg-read    { border-left-color: rgba(96, 165, 250, 0.6); }
.hi-msg-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
}
.hi-msg-from { font-variant-numeric: tabular-nums; color: var(--text); }
.hi-msg-type { background: var(--surface-2); padding: 1px 6px; border-radius: 999px; }
.hi-msg-status { opacity: 0.8; }
.hi-msg-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.hi-msg-subject {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}
.hi-msg-body {
  margin: 0;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow-y: auto;
}
.hi-msg-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.hi-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.hi-chip:hover:not(:disabled) { border-color: var(--accent); }
.hi-chip:disabled { opacity: 0.5; cursor: default; }
.hi-chip-forward { border-color: rgba(34, 197, 94, 0.4); }
.hi-chip-ack { border-color: rgba(96, 165, 250, 0.4); }
.hi-msg-status-line {
  font-size: 11px;
  color: var(--text-dim);
}
.hi-msg-status-line[data-tone="ok"] { color: #86efac; }
.hi-msg-status-line[data-tone="error"] { color: #fca5a5; }
.hi-msg-status-line[hidden] { display: none; }

/* Quick-menu bottom-sheet (otto#395). Inherits .voice-modal framing; adds
 * chip-grid layout for prompts / list-shortcuts. */
.quick-menu .quick-menu-chips {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 6px 12px 10px;
}
@media (max-width: 360px) {
  .quick-menu .quick-menu-chips { grid-template-columns: 1fr; }
}
.quick-menu-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  min-height: 52px;
  transition: background 120ms, border-color 120ms;
}
.quick-menu-chip:hover {
  background: var(--border);
  border-color: var(--accent);
}
.quick-menu-chip-emoji {
  font-size: 20px;
  flex: 0 0 auto;
}
.quick-menu-chip-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------------------
 * Tracker Quick-Log (otto#405, rescoped under mAi#142)
 *
 * Slide-up sheet with +/− actions + Weight input. Lives on the Lists-Nav
 * after mAi#142 (was Today-Nav). State comes from client/trackers.ts; the
 * Today-Card band and tracker-pill styles were removed with #142.
 *
 * Goal-ring colors come from inline stroke on the <svg>; .flash-* classes add
 * transient pulse/ok/err animations after an action.
 * ------------------------------------------------------------------------- */

/* Slide-up Sheet — compact, scrollable rows. Row target height ≈60-70px.
 * `.voice-modal` keeps `overflow: hidden` (border-radius clipping); the
 * inner `.tracker-sheet-rows` scrolls. Layout per row is a single flex line:
 * [emoji · title · count/label · actions], with optional full-width
 * sub-option strip wrapping below. */
.tracker-sheet .tracker-sheet-head {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 14px 2px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.tracker-sheet .tracker-sheet-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 10px 8px;
  flex: 1 1 auto;
  min-height: 0;              /* allow flex child to shrink below content */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Capture rows (Issue #138): Idee + Todo quick-capture at the top of the
 * Today Quick-Log sheet. Mirrors the value-tracker row layout (emoji ·
 * label · input · Log button) but without rings/counts — these aren't
 * trackers, just a shortcut to POST /mai-pwa/tasks (calendar=plan). */
.tracker-sheet .tracker-sheet-capture {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 10px 6px;
  flex-shrink: 0;
}
.capture-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  transition: border-color 160ms, background 160ms;
}
.capture-row.flash-ok  { border-color: #16a34a; }
.capture-row.flash-err { border-color: #dc2626; }
.capture-row-emoji {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
  flex: 0 0 auto;
}
.capture-row-label {
  font-weight: 500;
  font-size: 14px;
  flex: 0 0 auto;
  min-width: 44px;
}
.capture-row-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
}
.capture-row-input:focus {
  outline: none;
  border-color: var(--accent);
}
.capture-row-input:disabled {
  opacity: 0.6;
  cursor: progress;
}
.capture-row-log {
  min-width: 56px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  flex: 0 0 auto;
}
.capture-row-log:hover { filter: brightness(1.05); }
.capture-row-log:disabled { opacity: 0.6; cursor: progress; filter: none; }
.tracker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  transition: background 160ms, border-color 160ms, transform 120ms;
}
.tracker-row.highlight {
  border-color: var(--accent);
  background: var(--surface-2);
  transform: translateY(-1px);
}
.tracker-row.flash-pulse { animation: tracker-pulse 220ms ease-out; }
.tracker-row.flash-ok    { border-color: #16a34a; }
.tracker-row.flash-err   { border-color: #dc2626; }

@keyframes tracker-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.tracker-row-head {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;              /* allow title ellipsis */
}
.tracker-row-emoji {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}
.tracker-row-emoji-char {
  font-size: 17px;
  line-height: 1;
  position: relative;
  z-index: 1;
}
.tracker-row-ring {
  position: absolute;
  inset: -2px;
  width: 32px;
  height: 32px;
}
.tracker-row-title {
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tracker-row-count,
.tracker-row-value-label {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
}

.tracker-row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex: 0 0 auto;
}
.tracker-row-dec,
.tracker-row-plus {
  min-width: 44px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.tracker-row-plus {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  min-width: 56px;
}
.tracker-row-dec:hover  { background: var(--border); border-color: var(--accent); }
.tracker-row-plus:hover { filter: brightness(1.05); }

/* Sub-option expansion (Phone-Calls Outgoing/Incoming) — wraps below row */
.tracker-row-subs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 2px;
  flex-basis: 100%;
}
.tracker-row-sub {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tracker-row-sub:hover {
  background: var(--border);
  border-color: var(--accent);
}

/* Value tracker (Weight): input + Log button sit inline with head.
 * Wraps to its own line on narrow viewports so nothing gets squished. */
.tracker-row-valinput {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
}
@media (max-width: 420px) {
  .tracker-row-valinput { flex-basis: 100%; justify-content: flex-end; }
}
.tracker-value-input {
  height: 34px;
  width: 104px;
  min-width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
}
.tracker-value-input:focus {
  outline: none;
  border-color: var(--accent);
}
.tracker-value-log {
  min-width: 56px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.tracker-value-log:hover { filter: brightness(1.05); }

/* State tracker (Sober, Screen-free, …): one tap toggles today's boolean
 * flag. Solid accent fill when on, outline when off. No ring, no +/−. */
.tracker-row-state {
  padding: 0;
  background: transparent;
  border: none;
}
.tracker-state-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 160ms, border-color 160ms, color 160ms;
}
.tracker-state-toggle:hover {
  background: var(--border);
  border-color: var(--accent);
}
.tracker-row-state.on .tracker-state-toggle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tracker-row-state.on .tracker-state-toggle:hover { filter: brightness(1.05); }
.tracker-state-mark {
  margin-left: auto;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  width: 16px;
  text-align: center;
}

/* Detail panel (Issue #105): inline contact-picker + note for trackers with
 * prompt_value=true (phone-calls, meetings). Wraps below the row on its own
 * flex line. One active panel at a time; the dialog clears state on close. */
.tracker-row-details {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}
.tracker-row-details-head {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.tracker-contact-wrap {
  position: relative;
}
.tracker-detail-input {
  width: 100%;
  height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
.tracker-detail-input:focus {
  outline: none;
  border-color: var(--accent);
}
.tracker-contact-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
}
.tracker-contact-suggest[hidden] { display: none; }
.tracker-contact-suggest-row {
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.tracker-contact-suggest-row:last-child { border-bottom: 0; }
.tracker-contact-suggest-row:hover,
.tracker-contact-suggest-row:focus {
  background: var(--surface-2);
}
.tracker-details-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.tracker-detail-skip,
.tracker-detail-plain {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.tracker-detail-skip:hover,
.tracker-detail-plain:hover {
  background: var(--border);
  border-color: var(--accent);
}
.tracker-detail-log {
  height: 34px;
  padding: 0 14px;
  min-width: 56px;
}

/* Long-press Undo-Toast */
.tracker-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 20px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms, transform 180ms;
  z-index: 1001;
}
.tracker-toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.tracker-toast-label { font-variant-numeric: tabular-nums; }
.tracker-toast-undo {
  background: transparent;
  color: inherit;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.tracker-toast-undo:hover { background: rgba(255,255,255,0.12); }

/* Thread selector sheet + chat header chip (mAi#122). Inherits .voice-modal
 * framing via .thread-selector composition. Rows use the tracker-sheet scroll
 * pattern so the sheet clips its corners while the list scrolls. */
.thread-selector .thread-sheet-head {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.85;
  padding: 4px 4px 10px 4px;
}
.thread-selector .thread-sheet-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.thread-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  color: inherit;
  text-align: left;
  cursor: pointer;
  width: 100%;
  min-height: 48px;
}
.thread-row:hover { background: rgba(255,255,255,0.07); }
.thread-row.is-current {
  background: rgba(120,180,255,0.14);
  border-color: rgba(120,180,255,0.35);
}
.thread-row-emoji { font-size: 1.1rem; }
.thread-row-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}
.thread-row-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-row-purpose {
  font-size: 0.82rem;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-row-unread {
  background: #3b82f6;
  color: white;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}
.thread-row-spawning {
  font-size: 0.75rem;
  opacity: 0.7;
  font-style: italic;
}
.thread-row-loading, .thread-row-error {
  text-align: center;
  opacity: 0.6;
  padding: 20px;
  font-size: 0.9rem;
}
.thread-row-new {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px dashed rgba(120,180,255,0.4);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  width: 100%;
  font-weight: 500;
  margin-top: 6px;
}
.thread-row-new:hover { background: rgba(120,180,255,0.08); }
.thread-row-plus {
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0.8;
}
/* Steer-Tab heads section (mAi#160). Heads list under the user-thread rows
   with a small subhead, status pill, and pin toggle. */
.thread-sheet-subhead {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.55;
  margin: 12px 4px 4px;
}
.thread-row-head .thread-row-emoji { opacity: 0.85; }
.thread-row-head-status {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.thread-row-head-status.is-active {
  background: rgba(74,222,128,0.18);
  color: #86efac;
}
.thread-row-head-status.is-stopped {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.55);
}
.thread-row-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}
.thread-row-pin:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.thread-row-pin[data-head-pinned="1"] {
  opacity: 1;
  color: #fbbf24;
}
/* Per-row pencil that opens the inline label-override editor (mAi#167).
 * Lives inside the .thread-row button next to the unread badge. Tap is
 * intercepted in handleThreadLabelEditClick BEFORE the row's data-thread-id
 * scope-switch fires. */
.thread-row-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.thread-row:hover .thread-row-edit,
.thread-row-edit:hover { opacity: 1; }
.thread-row-edit:hover { background: rgba(255,255,255,0.08); }

/* Inline edit form replaces the .thread-row button when the pencil is
 * tapped (mAi#167). Reuses .thread-form-label styling but with a tighter
 * vertical rhythm so the row swap doesn't feel disruptive. */
.thread-row-edit-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  margin: 4px 0;
}
.thread-row-edit-form .thread-form-label { margin-bottom: 0; }

.thread-sheet-create {
  padding: 10px 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 8px;
}
.thread-form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}
.thread-form-label input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.3);
  color: inherit;
  font: inherit;
}
.thread-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.chat-thread-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
  margin: 6px 8px;
  min-height: 28px;
  max-width: 70%;
  overflow: hidden;
}
.chat-thread-chip:hover { background: rgba(255,255,255,0.1); }
.chat-thread-chip-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-notice {
  text-align: center;
  opacity: 0.6;
  padding: 12px;
  font-size: 0.9rem;
  font-style: italic;
}

/* Grouped sections inside the thread-selector / chat pull-up (mAi#162).
 * Wraps the two scope groups — "otto" (Main + Inbox + user threads + new)
 * and "Project Heads" (Steer-Tab list from mAi#160) — so the divider and
 * uppercase section labels are explicit instead of leaning on the single
 * .thread-sheet-subhead from mAi#160. Heads-row-internal styling (status
 * pill, pin star) is left to the .thread-row-head / .thread-row-pin rules
 * shipped with #160; this block is purely the outer grouping. */
.thread-section + .thread-section {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.thread-section { display: flex; flex-direction: column; gap: 6px; }
.thread-section-head {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.55;
  padding: 0 4px 4px 4px;
}

/* Chat pull-up sheet (mAi#139) — composes .voice-modal + .quick-menu, then
 * stacks two sections (Threads on top, collapsible Quick-Prompts below).
 * Reuses .thread-row styles and the .quick-menu-chip grid via .quick-menu. */
.chat-pull-up .chat-sheet-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-pull-up .chat-sheet-threads {
  flex: 1 1 auto;
  min-height: 0;
}
.chat-pull-up .chat-sheet-prompts {
  flex: 0 0 auto;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 10px;
  padding-top: 6px;
}
.chat-pull-up .chat-sheet-section-head {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.85;
  padding: 4px 4px 10px 4px;
}
.chat-pull-up .chat-sheet-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-weight: 600;
}
.chat-pull-up .chat-sheet-section-toggle:hover { opacity: 1; }
.chat-pull-up .chat-sheet-chevron {
  transition: transform 160ms ease;
  opacity: 0.7;
}
.chat-pull-up .chat-sheet-prompts[data-open="0"] .chat-sheet-chevron {
  transform: rotate(-90deg);
}
.chat-pull-up .chat-sheet-prompts[data-open="0"] .quick-menu-chips {
  display: none;
}
.chat-pull-up .chat-sheet-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-pull-up .chat-sheet-create {
  padding: 10px 4px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 8px;
}

/* Today-Nav slide-up sheet (mAi#146) — ambient quick-view of heutige
 * Termine + offene Tasks. Reuses .today-row / .today-list / .today-empty
 * markup from the Today-Tab so the preview looks like a compact Today. */
.today-quickview .today-sheet-section {
  padding: 6px 18px 2px;
}
.today-quickview .today-sheet-section + .today-sheet-section {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 6px;
  padding-top: 12px;
}
.today-quickview .today-card-head {
  margin: 0 0 8px;
}
.today-quickview .today-row[data-today-row] {
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
}
.today-quickview .today-row[data-today-row]:hover {
  background: var(--surface-2);
}
.today-quickview .today-sheet-error {
  color: var(--danger, #dc2626);
  font-size: 13px;
  padding: 6px 18px 0;
}

/* Combined "All lists" view (mAi#221). */
.lists-all-link {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  text-decoration: none;
  margin-bottom: 12px;
}
.lists-all-link:active { background: var(--surface-2); }
.lists-all-link-icon { font-size: 20px; }
.lists-all-link-label { font-weight: 600; letter-spacing: 0.02em; }
.lists-all-link-hint {
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface-2);
}
.lists-all-link-chev { color: var(--text-dim); font-size: 18px; }

body.lists-all .lists-all-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 0 4px;
}
body.lists-all .lists-all-search {
  padding: 6px 12px 2px;
}
body.lists-all .lists-all-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  font-size: 14px;
}
body.lists-all .lists-all-search input:focus {
  outline: none;
  border-color: var(--accent);
}
body.lists-all .filter-chips {
  border-bottom: 0;
  padding: 4px 12px;
}

body.lists-all .lists-all-log {
  padding: 0 12px 90px;
}
body.lists-all .lists-all-row {
  grid-template-columns: auto 1fr auto;
}
body.lists-all .task-row-list-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: none;
  letter-spacing: 0.02em;
}
body.lists-all .task-row-list-pill:hover { color: var(--text); }
.task-row-due-overdue {
  color: var(--danger, #dc2626) !important;
  font-weight: 600;
}

.lists-all-group {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 4px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 0;
  background: transparent;
}
.lists-all-group-overdue { color: var(--danger, #dc2626); }
.lists-all-group-count {
  background: var(--surface-2);
  padding: 0 6px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

/* Long-press visual feedback (mAi#222). A brief background flash tells m
   the long-press registered before the edit sheet opens. */
.task-row-pressing {
  background: var(--surface-2);
}

/* Bottom-sheet dialog for editing summary + due date (mAi#222). Mirrors the
   voice-modal pattern: pinned to the bottom, slides up over a backdrop. */
.edit-task-dialog {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  margin: 0 auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
}
.edit-task-dialog[open] {
  display: flex;
  flex-direction: column;
}
.edit-task-dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.edit-task-form {
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.edit-task-form h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.edit-task-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.edit-task-field > span {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.edit-task-field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  box-sizing: border-box;
}
.edit-task-field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}
.edit-task-due-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.edit-task-due-row input { flex: 1; min-width: 0; }
.edit-task-due-row .btn-ghost { flex-shrink: 0; padding: 9px 12px; }
.edit-task-error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.edit-task-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.edit-task-actions button:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* --- Projax surface (mAi#228) --------------------------------------------- */

.projax-log {
  padding: 12px 14px 90px;
  overflow: auto;
  height: 100%;
}

/* Filter row sits between topbar and main list, sticky to the top while
   the user scrolls the tree. */
.projax-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 14px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.projax-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.projax-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
}
.projax-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0b0d;
}
.projax-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Section per DAG root. */
.projax-section { margin: 0 0 18px; }
.projax-section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 6px;
  padding: 4px 0;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.projax-section-slug {
  font-weight: 700;
  color: var(--text);
}
.projax-section-title {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
}

.projax-rows { list-style: none; margin: 0; padding: 0; }
.projax-empty-row {
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 0;
}

/* Row card. */
.projax-row {
  margin: 4px 0;
}
.projax-row-link {
  display: block;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.projax-row-link:active { background: var(--surface-2); }
.projax-row-root .projax-row-link {
  background: var(--surface-2);
}

.projax-row-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.projax-row-multi {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
}
.projax-row-pin { font-size: 13px; }

.projax-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.projax-row-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Status pill + tag chips share a small-token look. */
.projax-status {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.projax-status-active   { background: #1d3a2a; color: #6cd49a; }
.projax-status-done     { background: #2a2f3a; color: #8aa1e3; }
.projax-status-archived { background: #2a2222; color: #d49a6c; }

.projax-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.projax-tag-mgmt-mai      { background: #2c2433; color: #c9a5f0; }
.projax-tag-mgmt-self     { background: #232b34; color: #9ad0f0; }
.projax-tag-mgmt-external { background: #2e2a22; color: #d9c98a; }
.projax-tag-pin           { background: #3a2f1d; color: #f0c46c; }

/* Detail page. */
.projax-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 12px;
}
.projax-card-head {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.projax-detail-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}
.projax-detail-alsoat {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.projax-detail-alsoat a {
  color: var(--accent);
  text-decoration: none;
}
.projax-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.projax-content {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.projax-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.projax-action {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}
.projax-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.projax-action.is-active {
  background: var(--accent);
  color: #0b0b0d;
  border-color: var(--accent);
}
.projax-action-link {
  color: var(--accent);
}
.projax-action-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.projax-action-status[data-tone="ok"]    { color: #6cd49a; }
.projax-action-status[data-tone="error"] { color: var(--danger); }

.projax-links { list-style: none; margin: 0; padding: 0; }
.projax-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.projax-link-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 90px;
}
.projax-link-id {
  color: var(--text);
  text-decoration: none;
  word-break: break-all;
}
.projax-link a.projax-link-id { color: var(--accent); }

/* --- Projax timeline (4c-B slice 3 / 4g icon-only refresh) ---
   The link is icon-only after 4g; m said the text label was too wide on
   mobile. Touch target stays >= 44x44 per Apple HIG; the icon sits
   centred inside the square. */
.projax-topbar-link {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg, #e6e6e0);
  text-decoration: none;
  border: 1px solid var(--border, #2c2c2c);
  border-radius: 6px;
  margin-right: 6px;
}
.projax-topbar-link:hover { color: var(--accent, #6fa7e8); border-color: var(--accent, #6fa7e8); }
.projax-topbar-link svg { flex-shrink: 0; }
.projax-topbar-link-icon {
  width: 44px; height: 44px;
  padding: 0;
}

.projax-timeline-log { padding: 8px 12px; }

.projax-spine { list-style: none; margin: 0; padding: 0; }
.projax-day {
  border-left: 2px solid var(--border, #2c2c2c);
  margin-left: 8px;
  padding: 6px 0 14px 14px;
  position: relative;
}
.projax-day-sticky-today { border-left-color: var(--accent, #6fa7e8); }
.projax-day-sticky-tomorrow { border-left-color: #6cd49a; }

.projax-day-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.projax-day-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.7em;
  text-transform: uppercase;
  font-weight: 600;
  background: var(--accent, #6fa7e8);
  color: var(--bg, #0e0e0e);
}
.projax-day-pill-tomorrow { background: #6cd49a; }
.projax-day-label { margin: 0; font-size: 0.95em; color: var(--muted, #8a8880); font-weight: 600; }
.projax-day-label small { font-weight: 400; }

.projax-day-rows { list-style: none; margin: 0; padding: 0; }
.projax-tl-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 5px 0;
  border-bottom: 1px dotted transparent;
  font-size: 0.92em;
}
.projax-tl-row:hover { background: var(--surface-hover, #1f1f1f); }
.projax-row-fade { opacity: 0.5; }
.projax-row-time {
  min-width: 44px;
  font-variant-numeric: tabular-nums;
  font-size: 0.82em;
  color: var(--muted, #8a8880);
}
.projax-row-kind {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65em;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--border, #2c2c2c);
  color: var(--muted, #8a8880);
}
.projax-row-kind-event    { background: #1a2540; color: #8eb5f0; }
.projax-row-kind-todo     { background: #3a2810; color: #f0c068; }
.projax-row-kind-doc      { background: #143020; color: #7adba0; }
.projax-row-kind-creation { background: #281a40; color: #b090ec; }

.projax-row-proj {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.82em;
  color: var(--accent, #6fa7e8);
  text-decoration: none;
}
.projax-row-proj:hover { text-decoration: underline; }
.projax-row-summary { flex: 1; min-width: 8em; }
.projax-row-loc { font-size: 0.85em; color: var(--muted, #8a8880); }
.projax-row-duration { font-size: 0.8em; color: var(--muted, #8a8880); }
.projax-row-recurring { color: var(--accent, #6fa7e8); cursor: help; font-size: 0.85em; }
.projax-row-creation-marker { font-style: italic; color: var(--muted, #8a8880); }
.projax-tl-row-todo-done .projax-row-summary {
  text-decoration: line-through; color: var(--muted, #8a8880);
}

.projax-row-per {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.82em;
  color: var(--accent, #6fa7e8);
}
.projax-row-ref-type {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.65em;
  background: var(--border, #2c2c2c);
  color: var(--muted, #8a8880);
}
.projax-row-ref-id {
  font-size: 0.82em;
  color: var(--muted, #8a8880);
  text-decoration: none;
  max-width: 18em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.projax-row-ref-id:hover { color: var(--accent, #6fa7e8); text-decoration: underline; }
.projax-row-note { font-size: 0.85em; color: var(--muted, #8a8880); font-style: italic; }
