:root {
  --bg: #16171b;
  --bg-raised: #1e2025;
  --bg-hover: #292b32;
  --bg-sunken: #0d0e11;
  --border: #313339;
  --text: #e7e8ea;
  --text-dim: #9a9ca3;
  --accent: #7c9eff;
  --accent-dim: #3d4a75;
  --danger: #e2716b;
  --radius: 10px;
  --radius-composer: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --panel-bg: rgba(30, 32, 37, 0.82);
  --blur-chrome: saturate(180%) blur(20px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration-fast: 140ms;
  --duration-open: 560ms;

  /* ---- Shao Design System aliases (semantic names used by the settings ui_kit) ---- */
  --surface-app: var(--bg);
  --surface-raised: var(--bg-raised);
  --surface-hover: var(--bg-hover);
  --surface-sunken: var(--bg-sunken);
  --surface-selected: var(--accent-dim);
  --border-default: var(--border);
  --border-focus: var(--accent);
  --text-body: var(--text);
  --text-muted: var(--text-dim);
  --text-on-accent: #10121a;
  --text-danger: var(--danger);
  --action-primary: var(--accent);
  --action-primary-rest: var(--accent-dim);
  --action-danger: var(--danger);
  --font-ui: var(--font);
  --font-mono: var(--mono);
  --ease-standard: var(--ease);
  --radius-xs: 4px;
  --radius-sm: 5px;
  --radius-code: 8px;
  --radius-control: 9px;
  --radius-pill: 999px;
  --space-0: 0px; --space-1: 2px; --space-2: 4px; --space-3: 6px; --space-4: 8px;
  --space-5: 10px; --space-6: 12px; --space-7: 14px; --space-8: 18px; --space-9: 20px; --space-10: 24px;
  --text-2xs: 11.5px; --text-xs: 12px; --text-sm: 12.5px; --text-code: 13px; --text-note: 13px;
  --text-list: 13.5px; --text-control: 14px; --text-title: 18px; --text-display: 28px;
  --text-base: 15px; --text-composer: 15px;
  --weight-regular: 400; --weight-medium: 500; --weight-semibold: 600;
  --leading-body: 1.5; --leading-tight: 1.2; --tracking-wordmark: 0.02em;
  --settings-pane-width: 200px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#globe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  height: 100vh;
}

svg.lucide { width: 18px; height: 18px; stroke-width: 1.5; }

/* ---------- left edge: conversation flyout ---------- */
.flyout-edge {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 26px;
  z-index: 3;
  transition: width var(--duration-fast) var(--ease);
}
.flyout-edge.open { width: 292px; }

.flyout-hint {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  opacity: 1;
  transition: opacity 200ms var(--ease);
}
.flyout-edge.open .flyout-hint { opacity: 0; }
.flyout-hint span { height: 1px; background: var(--border); }
.flyout-hint span:nth-child(1) { width: 16px; }
.flyout-hint span:nth-child(2) { width: 10px; }
.flyout-hint span:nth-child(3) { width: 13px; }

.flyout-panel {
  position: absolute;
  inset: 12px auto 12px 12px;
  width: 260px;
  transform: translateX(-296px);
  opacity: 0;
  transition: transform 320ms var(--ease), opacity 220ms var(--ease);
  background: var(--panel-bg);
  backdrop-filter: var(--blur-chrome);
  -webkit-backdrop-filter: var(--blur-chrome);
  border: 1px solid var(--border);
  border-radius: var(--radius-composer);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 2px;
}
.flyout-edge.open .flyout-panel { transform: none; opacity: 1; }

.flyout-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 8px 10px;
  font-size: 11.5px;
  color: var(--text-dim);
}
.flyout-panel-header .key { font-family: var(--mono); }

.flyout-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.flyout-list-item { position: relative; }
.flyout-list-item .when {
  position: absolute;
  right: 10px;
  top: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

.flyout-panel-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
}

.convo-item {
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-dim);
  overflow: hidden;
  transition: background var(--duration-fast) var(--ease);
}
.convo-item .title {
  color: var(--text);
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 32px;
}
.convo-item .meta { font-size: 11.5px; margin-top: 2px; }
.convo-item:hover { background: var(--bg-hover); }
.convo-item.active { background: var(--accent-dim); }

/* ---------- right edge: app dock, hidden behind a hover rail ---------- */
.dock-edge {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 26px;
  z-index: 3;
}

.dock-hint {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  opacity: 1;
  transition: opacity 200ms var(--ease);
}
.dock-edge.open .dock-hint { opacity: 0; }
.dock-hint span { height: 1px; background: var(--border); }
.dock-hint span:nth-child(1) { width: 16px; }
.dock-hint span:nth-child(2) { width: 10px; }
.dock-hint span:nth-child(3) { width: 13px; }

.dock {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) translateX(24px);
  opacity: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  transition: opacity 220ms var(--ease), transform 280ms var(--ease);
}
.dock-edge.open .dock {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}

.dock-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.dock-label {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
  pointer-events: none;
  white-space: nowrap;
}
.dock-item:hover .dock-label { opacity: 1; transform: none; }
.dock-label .name { font-size: 12px; }
.dock-label .host { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }

.dock-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 32, 37, 0.72);
  backdrop-filter: var(--blur-chrome);
  -webkit-backdrop-filter: var(--blur-chrome);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.dock-item:hover .dock-icon { background: var(--bg-hover); color: var(--accent); }

.dock-divider {
  width: 42px;
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.dock-settings .dock-icon:hover { background: var(--bg-hover); color: var(--accent); }

/* ---------- top-right: connected widgets ---------- */
.widget-column {
  position: fixed;
  top: 68px;
  right: 78px;
  z-index: 2;
  width: 300px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  opacity: 1;
  transform: none;
  transition: opacity var(--duration-open) var(--ease), transform var(--duration-open) var(--ease);
}
.widget-column.minimized {
  width: 190px;
  opacity: 0.8;
}
.widget-column.minimized:hover { opacity: 1; }
.widget-column.minimized .widget-card { padding: 8px 12px; }

.widget-mini-row { display: flex; align-items: baseline; gap: 8px; }
.widget-mini-label { font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.5); flex: 0 0 auto; }
.widget-mini-value {
  font-size: var(--text-2xs);
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.widget-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  padding: 10px 14px 11px;
}
.widget-card-error { border-color: rgba(226, 113, 107, 0.3); }

.widget-card-head { display: flex; align-items: center; gap: var(--space-4); margin-bottom: 11px; }
.widget-card-label { flex: 1; font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.56); letter-spacing: 0.01em; }
.widget-card-badge {
  font-family: var(--mono);
  font-size: var(--text-2xs);
  color: var(--text-on-accent);
  background: var(--action-primary);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
}
.widget-card-count { font-family: var(--mono); font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.56); flex: 0 0 auto; }
.widget-card-empty { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.5); }
.widget-card-empty a { color: var(--accent); }

.widget-rule { height: 1px; background: rgba(255, 255, 255, 0.06); margin: 12px 0 10px; }

.widget-now-playing { display: flex; gap: 12px; align-items: center; }
.widget-art {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  flex: 0 0 auto;
  background-color: rgba(255, 255, 255, 0.07);
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.3);
}
.widget-now-playing-meta { min-width: 0; flex: 1; }
.widget-track { font-size: var(--text-control); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-artist { font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.56); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.widget-transport { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 11px; }
.widget-transport-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  padding: 4px;
  transition: color var(--duration-fast) var(--ease);
}
.widget-transport-btn:hover { color: var(--text); }

.widget-event-next { display: flex; align-items: baseline; gap: 10px; }
.widget-event-next-time { font-size: 24px; font-weight: var(--weight-medium); letter-spacing: -0.01em; line-height: 1; }
.widget-event-next-title { font-size: var(--text-control); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.widget-event-list { display: flex; flex-direction: column; gap: 7px; }
.widget-event-row { display: flex; gap: 10px; align-items: baseline; }
.widget-event-time { font-family: var(--mono); font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.56); width: 52px; flex: 0 0 auto; }
.widget-event-title { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.85); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.widget-weather-row { display: flex; align-items: baseline; gap: 10px; }
.widget-weather-icon { display: flex; align-items: center; color: rgba(255, 236, 190, 0.85); flex: 0 0 auto; }
.widget-weather-temp { font-size: 24px; font-weight: var(--weight-medium); letter-spacing: -0.01em; line-height: 1; }
.widget-weather-condition { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.7); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-weather-location { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.5); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.widget-lights-rooms { display: flex; flex-direction: column; gap: 10px; }
.widget-lights-room { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.widget-lights-bulb { display: flex; flex: 0 0 auto; color: rgba(255, 255, 255, 0.4); }
.widget-lights-bulb.on { color: rgba(255, 236, 190, 0.92); }
.widget-lights-room-main { flex: 1; min-width: 0; }
.widget-lights-room-name { font-size: var(--text-xs); color: rgba(255, 255, 255, 0.56); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-lights-room-name.on { color: var(--text); }
.widget-lights-bar { height: 3px; background: rgba(255, 255, 255, 0.08); border-radius: 2px; margin-top: 5px; }
.widget-lights-bar-fill { height: 3px; border-radius: 2px; background: rgba(255, 231, 173, 0.85); transition: width var(--duration-open) var(--ease); }
.widget-lights-level { font-family: var(--mono); font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.7); flex: 0 0 auto; width: 30px; text-align: right; }

.widget-lights-scenes { display: flex; gap: 6px; }
.widget-lights-scene {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  border-radius: var(--radius-pill);
  padding: 4px 0;
  font-family: var(--font);
  font-size: var(--text-2xs);
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.widget-lights-scene.on { border-color: rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.11); color: var(--text); }

.widget-card-expand {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  padding: 3px;
  flex: 0 0 auto;
  transition: color var(--duration-fast) var(--ease);
}
.widget-card-expand:hover { color: var(--text); }
.widget-card-expand :is(svg) { width: 14px; height: 14px; }

.hue-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.hue-modal {
  width: min(560px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  background: rgba(26, 28, 33, 0.94);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  padding: 18px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hue-modal-header { display: flex; align-items: center; gap: var(--space-4); flex: 0 0 auto; }
.hue-modal-title { flex: 1; font-size: var(--text-xs); color: rgba(255, 255, 255, 0.56); letter-spacing: 0.01em; }
.hue-modal-close {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  padding: 4px;
  transition: color var(--duration-fast) var(--ease);
}
.hue-modal-close:hover { color: var(--text); }

.hue-modal-body { display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.hue-modal-room { display: flex; flex-direction: column; gap: 10px; }
.hue-modal-room-name { font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.56); letter-spacing: 0.01em; }

.hue-modal-light { display: flex; align-items: center; gap: 11px; }
.hue-modal-light-bulb { display: flex; flex: 0 0 auto; color: rgba(255, 255, 255, 0.4); cursor: pointer; }
.hue-modal-light-bulb.on { color: rgba(255, 236, 190, 0.92); }
.hue-modal-light-name { flex: 1; min-width: 0; font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hue-modal-slider {
  width: 110px;
  flex: 0 0 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}
.hue-modal-slider::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: transparent; }
.hue-modal-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(255, 231, 173, 0.92);
  cursor: pointer;
  margin-top: -5px;
}
.hue-modal-slider::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); }
.hue-modal-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 231, 173, 0.92);
  cursor: pointer;
}

.hue-modal-swatches { display: flex; gap: 5px; flex: 0 0 auto; }
.hue-modal-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 0;
}

.hue-modal-scene-check { flex: 0 0 auto; accent-color: rgba(255, 231, 173, 0.92); cursor: pointer; }

.hue-modal-footer { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; border-top: 1px solid rgba(255, 255, 255, 0.07); padding-top: 14px; }
.hue-modal-scene-input { flex: 1; min-width: 0; }
.hue-modal-save-scene {
  border: none;
  background: var(--action-primary);
  color: var(--text-on-accent);
  cursor: pointer;
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-family: var(--font);
  font-size: var(--text-xs);
  flex: 0 0 auto;
  transition: opacity var(--duration-fast) var(--ease);
}
.hue-modal-save-scene:disabled { opacity: 0.4; cursor: not-allowed; }

.widget-supply-list { display: flex; flex-direction: column; gap: 8px; }
.widget-supply-row { display: flex; align-items: center; gap: 10px; }
.widget-supply-name { flex: 1; min-width: 0; font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-supply-qty { font-family: var(--mono); font-size: var(--text-2xs); color: var(--text-danger); flex: 0 0 auto; }
.widget-supply-mark-used {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: var(--text-2xs);
  padding: 2px 9px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background var(--duration-fast) var(--ease);
}
.widget-supply-mark-used:hover { background: rgba(255, 255, 255, 0.08); }

/* ---------- home stage ---------- */
.home {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 20px;
}

.menubar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 0 0 auto;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.menubar-left, .menubar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.wordmark { font-size: 15px; font-weight: 600; letter-spacing: 0.02em; }
.mono-hint { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }

.spacer { flex-grow: 1; flex-basis: 0; transition: flex-grow var(--duration-open) var(--ease); }
.spacer-bottom.open { flex-grow: 0; }
.spacer-top { flex-grow: 1; }
.spacer-hero { flex-grow: 0.9; flex-basis: 0; transition: flex-grow var(--duration-open) var(--ease); }
.hero.open ~ .spacer-hero { flex-grow: 0.52; }

/* ---------- hero: clock + model / status readouts ---------- */
.hero {
  width: 100%;
  max-width: 720px;
  margin: 0;
  flex: 0 0 auto;
  text-align: left;
  opacity: 1;
  transform: none;
  transform-origin: 50% 100%;
  pointer-events: auto;
  transition: opacity var(--duration-open) var(--ease), transform var(--duration-open) var(--ease), width var(--duration-open) var(--ease);
}
.hero.open {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  opacity: 0.34;
  transform: scale(0.72) translateY(12px);
  pointer-events: none;
}
/* The model picker is the one hero readout you can still act on once chat is
   open — re-enable just it, and bring the whole hero back to full legibility
   while it's being used, rather than leaving it dim and hard to read. */
.hero.open .hero-model { pointer-events: auto; }
.hero.open:has(.hero-model:hover, .hero-model-btn.open) {
  opacity: 1;
  transition: opacity 160ms var(--ease);
}
.hero-time { font-size: 72px; font-weight: var(--weight-medium); line-height: 1; letter-spacing: -0.02em; }
.hero-date { font-size: var(--text-xs); color: var(--text-dim); letter-spacing: 0.04em; margin-top: 8px; }
.hero-readouts {
  display: flex;
  justify-content: flex-start;
  gap: 1px;
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  background: rgba(30, 32, 37, 0.62);
  backdrop-filter: var(--blur-chrome);
  -webkit-backdrop-filter: var(--blur-chrome);
}
.hero-readout { flex: 1; min-width: 0; padding: 8px 12px; border-left: 1px solid var(--border); }
.hero-readout:first-child { border-left: none; }
.hero-readout-label { font-size: var(--text-2xs); color: var(--text-dim); }
.hero-readout-value {
  font-family: var(--mono);
  font-size: var(--text-2xs);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-model { position: relative; flex: 1.7; min-width: 0; }
.hero-model-btn {
  width: 100%;
  text-align: left;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: var(--font);
  background: transparent;
  color: inherit;
  transition: background var(--duration-fast) var(--ease);
}
.hero-model:hover .hero-model-btn,
.hero-model-btn.open { background: rgba(255, 255, 255, 0.07); }
.hero-model-btn .hero-readout-label { display: flex; align-items: center; gap: 5px; }
.hero-model-btn .chev { opacity: 0.8; font-family: var(--mono); }
.hero-model-btn .hero-readout-value { color: var(--text); }

.hero-model-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 236px;
  z-index: 6;
  background: rgba(26, 28, 33, 0.94);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hero-model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 7px 9px;
  font-family: var(--font);
  background: transparent;
  color: var(--text);
  transition: background var(--duration-fast) var(--ease);
}
.hero-model-option:hover { background: rgba(255, 255, 255, 0.06); }
.hero-model-option.on { background: rgba(255, 255, 255, 0.10); }
.hero-model-option-label { flex: 1; min-width: 0; font-family: var(--mono); font-size: var(--text-2xs); }
.hero-model-option .check { color: var(--accent); font-family: var(--mono); font-size: var(--text-2xs); flex: 0 0 auto; }

.stage {
  width: calc(100% - 340px);
  max-width: 720px;
  margin: 0;
  flex: 0 0 auto;
  transition: width var(--duration-open) var(--ease), margin var(--duration-open) var(--ease);
}
.stage.open {
  width: 100%;
  margin: 0 auto;
}

.prompt-heading {
  opacity: 1;
  max-height: 90px;
  overflow: hidden;
  transition: opacity 280ms var(--ease), max-height var(--duration-open) var(--ease), transform var(--duration-open) var(--ease);
  font-size: 28px;
  color: var(--text-dim);
  font-weight: 400;
}
.prompt-heading.collapsed {
  opacity: 0;
  max-height: 0;
  transform: translateY(-14px);
}

.thread {
  max-height: 0;
  opacity: 0;
  overflow-y: hidden;
  transform: translateY(18px);
  transition: max-height var(--duration-open) var(--ease), opacity 320ms var(--ease), transform var(--duration-open) var(--ease);
  margin-bottom: 0;
  padding: 0;
}
.thread.open {
  max-height: 56vh;
  opacity: 1;
  overflow-y: auto;
  transform: none;
  transition: max-height var(--duration-open) var(--ease), opacity 320ms var(--ease) 120ms, transform var(--duration-open) var(--ease);
  margin-bottom: 10px;
  padding: 10px 0;
}

.message-row {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 3px 18px;
}
.message-row.user { text-align: right; }
.message-row.assistant { text-align: left; }
.message-row.user .bubble {
  background: var(--accent);
  color: var(--text-on-accent);
  border-radius: 18px 18px 4px 18px;
  padding: 9px 14px;
  display: inline-block;
  max-width: 78%;
  text-align: left;
}
.message-row.assistant .bubble {
  background: var(--bg-hover);
  color: var(--text);
  border-radius: 18px 18px 18px 4px;
  padding: 9px 14px;
  display: inline-block;
  max-width: 78%;
  text-align: left;
}
.message-row.user .bubble a { color: var(--text-on-accent); text-decoration: underline; }
.message-row + .message-row { margin-top: 2px; }
.message-row.user + .message-row.assistant,
.message-row.assistant + .message-row.user { margin-top: 12px; }

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}
.message-row.user .message-meta { justify-content: flex-end; }
.message-row.assistant .message-meta { justify-content: flex-start; }
.message-meta .meta-model {
  font-family: var(--mono);
  opacity: 0.85;
}
.message-meta .meta-dot { opacity: 0.5; }

.bubble :is(p) { margin: 0 0 0.6em; }
.bubble :is(p):last-child { margin-bottom: 0; }
.bubble pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
}
.bubble code { font-family: var(--mono); font-size: 0.92em; }
.bubble :not(pre) > code { background: var(--bg-sunken); padding: 1px 5px; border-radius: 4px; }

.bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 {
  margin: 0.8em 0 0.4em;
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child { margin-top: 0; }
.bubble h1 { font-size: 1.3em; }
.bubble h2 { font-size: 1.15em; }
.bubble h3 { font-size: 1.05em; }
.bubble ul, .bubble ol { margin: 0 0 0.6em; padding-left: 1.4em; }
.bubble li { margin: 0.15em 0; }
.bubble li > p { margin: 0; }
.bubble blockquote {
  margin: 0 0 0.6em;
  padding: 2px 12px;
  border-left: 3px solid var(--accent-dim);
  color: var(--text-dim);
}
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }
.bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.bubble a:hover { opacity: 0.85; }
.bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 0.6em;
  font-size: var(--text-sm);
  display: block;
  overflow-x: auto;
}
.bubble th, .bubble td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.bubble th { background: var(--bg-sunken); font-weight: var(--weight-semibold); }

/* Syntax-highlight token colors (see marked-highlight setup in app.js/mobile.js) —
   hand-rolled against this file's existing tokens rather than importing a full hljs
   theme stylesheet, for tighter visual consistency with the rest of the app. */
.bubble .hljs-keyword, .bubble .hljs-selector-tag, .bubble .hljs-literal, .bubble .hljs-title.function_ { color: var(--accent); }
.bubble .hljs-string, .bubble .hljs-attr, .bubble .hljs-attribute { color: #9fd88d; }
.bubble .hljs-comment, .bubble .hljs-quote { color: var(--text-dim); font-style: italic; }
.bubble .hljs-number, .bubble .hljs-symbol { color: #e2b96b; }
.bubble .hljs-title.class_, .bubble .hljs-type { color: var(--text); font-weight: var(--weight-semibold); }

.cursor {
  display: inline-block;
  width: 7px;
  height: 1em;
  background: var(--text-dim);
  vertical-align: text-bottom;
  animation: blink 1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.tool-status {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.5; } }

.context-badge {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-block;
}
.context-badge .icon { margin-right: 4px; }
.context-detail {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.save-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  padding: 6px 10px;
  display: block;
}
.save-note + .save-note { margin-top: 4px; }
.save-note .icon { margin-right: 4px; }
.save-note strong { color: var(--accent); }

.save-note-error { border-color: var(--danger); }
.save-note-error strong { color: var(--danger); }

.error-note { color: var(--danger); font-size: 13px; margin-top: 6px; }

.composer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0 0 12px;
  transition: background var(--duration-open) var(--ease), border-radius var(--duration-open) var(--ease),
    padding var(--duration-open) var(--ease), border-color var(--duration-open) var(--ease);
}

.mention-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 260px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 6;
  background: rgba(26, 28, 33, 0.94);
  backdrop-filter: var(--blur-chrome);
  -webkit-backdrop-filter: var(--blur-chrome);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.mention-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 7px 8px;
  border-radius: 7px;
  font-family: var(--font);
}
.mention-option:hover, .mention-option.active { background: rgba(255, 255, 255, 0.08); }
.mention-option .slug { font-family: var(--mono); font-size: var(--text-2xs); flex: 1; min-width: 0; }
.mention-option .note { font-size: 11px; color: var(--text-dim); flex: 0 0 auto; }
.mention-option-new .slug, .mention-option-new .note { color: var(--accent); }
.mention-option-new:hover, .mention-option-new.active { background: var(--accent-dim); }
.mention-empty { padding: 8px; font-size: 12px; color: var(--text-dim); }
.composer.open {
  background: var(--panel-bg);
  backdrop-filter: var(--blur-chrome);
  -webkit-backdrop-filter: var(--blur-chrome);
  border-color: var(--border);
  border-radius: var(--radius-composer);
  padding: 8px 8px 8px 16px;
}

.composer textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 22px;
  line-height: 1.4;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  transition: font-size var(--duration-open) var(--ease);
}
.composer.open textarea { font-size: 14.5px; }
.composer textarea::placeholder { color: var(--text-dim); }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.send-btn {
  background: var(--accent);
  color: #10121a;
  border: none;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-btn:disabled { opacity: 0.4; cursor: default; }

.context-panels {
  display: flex;
  gap: 28px;
  margin-top: 34px;
}
.context-panels > .subjects-panel,
.context-panels > .recents-panel {
  margin-top: 0;
  flex: 1;
  min-width: 0;
}

.subjects-panel {
  max-height: 220px;
  opacity: 1;
  overflow: hidden;
  transition: opacity 260ms var(--ease), max-height var(--duration-open) var(--ease);
  margin-top: 34px;
}
.subjects-panel.collapsed { max-height: 0; opacity: 0; margin-top: 0; }
.subjects-panel-label { font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.subjects-list { display: flex; flex-direction: column; gap: 2px; }
.subject-btn {
  background: transparent;
  border: none;
  padding: 6px 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  color: var(--text);
  display: block;
  width: 100%;
}
.subject-btn .slug { font-family: var(--mono); font-size: 13px; }
.subject-btn .note { font-size: 11.5px; color: var(--text-dim); margin-left: 10px; }

.recents-panel {
  max-height: 220px;
  opacity: 1;
  overflow: hidden;
  transition: opacity 260ms var(--ease), max-height var(--duration-open) var(--ease);
}
.recents-panel.collapsed { max-height: 0; opacity: 0; }
.recents-panel-label { font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.recents-list { display: flex; flex-direction: column; gap: 2px; }
.recent-item {
  padding: 6px 0;
  cursor: pointer;
  overflow: hidden;
}
.recent-item .title {
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-item:hover .title { color: var(--accent); }
.recent-item .meta {
  display: flex;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 1px;
}
.recent-item .meta .when { font-family: var(--mono); }

.footer-bar {
  display: flex;
  justify-content: space-between;
  flex: 0 0 auto;
  margin-top: 14px;
}
.hint { font-size: 11.5px; color: var(--text-dim); }

/* ---------- login: lock screen over the globe ---------- */
.lock-body { overflow: hidden; }
.lock-screen {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 84px 24px 40px;
}
.lock-date { font-size: 12px; color: var(--text-dim); letter-spacing: 0.04em; }
.lock-clock {
  font-size: 104px;
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin-top: 6px;
}
.lock-card {
  margin-top: auto;
  width: 320px;
  padding: 22px 24px 26px;
  background: var(--panel-bg);
  backdrop-filter: var(--blur-chrome);
  -webkit-backdrop-filter: var(--blur-chrome);
  border: 1px solid var(--border);
  border-radius: var(--radius-composer);
}

/* ---------- login / invite ---------- */
.auth-body {
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 320px;
  padding: 28px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-composer);
}
.auth-wordmark { font-size: 18px; font-weight: 600; letter-spacing: 0.02em; margin-bottom: 18px; }
.auth-subtitle { font-size: 13px; color: var(--text-dim); margin: -10px 0 18px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-label { font-size: 11.5px; color: var(--text-dim); margin-top: 10px; }
.auth-input {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 11px;
  outline: none;
}
.auth-input:focus { border-color: var(--accent); }
.auth-submit {
  margin-top: 18px;
  background: var(--accent);
  color: #10121a;
  border: none;
  border-radius: var(--radius);
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.auth-error {
  background: rgba(226, 113, 107, 0.12);
  color: var(--danger);
  border: 1px solid rgba(226, 113, 107, 0.35);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 12.5px;
}

/* ---------- launcher / settings shared chrome ---------- */
.launcher-body, .settings-body { overflow: auto; }
.launcher-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.launcher-topbar-right { display: flex; align-items: center; gap: 18px; }
.launcher-link {
  color: var(--text-dim);
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
}
.launcher-link:hover { color: var(--text); }
.launcher-logout { text-decoration: none; }

.launcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 32px;
  max-width: 960px;
  margin: 0 auto;
}
.launcher-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-composer);
  text-decoration: none;
  color: var(--text);
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.launcher-tile:hover { background: var(--bg-hover); border-color: var(--accent-dim); color: var(--text); }
.launcher-tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken);
  color: var(--accent);
}
.launcher-tile-name { font-size: 13.5px; font-weight: 500; }
.launcher-tile-host { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.launcher-empty { grid-column: 1 / -1; color: var(--text-dim); font-size: 13px; text-align: center; padding: 40px 0; }

/* ---------- settings ---------- */
.settings-body-inner { max-width: 960px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 36px; }
.settings-section-header { display: flex; justify-content: space-between; align-items: center; }
.settings-section h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.settings-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.settings-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11.5px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.settings-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.settings-input {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 9px;
}
.settings-btn {
  background: var(--accent);
  color: #10121a;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.settings-btn:disabled { opacity: 0.5; cursor: default; }
.settings-btn-link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
}
.settings-btn-link:hover { color: var(--danger); }
.settings-inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.settings-checkbox { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-dim); }
.settings-access-grid { display: flex; flex-wrap: wrap; gap: 8px; max-width: 320px; }
.settings-status { font-size: 12.5px; color: var(--text-dim); margin: 8px 0; }
.settings-status.error { color: var(--danger); }

/* ---------- settings: OS-style pane window (Shao Design System) ---------- */
.settings-body { overflow: hidden; }
.settings-home {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 20px;
}
.settings-home .menubar { border-bottom: none; padding-bottom: 12px; }
.settings-home .menubar-left { gap: 14px; }
.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}
.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; }
.settings-label { font-size: var(--text-xs); color: var(--text-dim); }

.settings-window {
  flex: 1;
  min-height: 0;
  display: flex;
  background: var(--panel-bg);
  backdrop-filter: var(--blur-chrome);
  -webkit-backdrop-filter: var(--blur-chrome);
  border: 1px solid var(--border);
  border-radius: var(--radius-composer);
  overflow: hidden;
}

.settings-panelist {
  width: var(--settings-pane-width);
  flex: 0 0 auto;
  border-right: 1px solid var(--border);
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.settings-pane-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 8px 10px;
  background: transparent;
  font-family: var(--font);
  font-size: var(--text-list);
  color: var(--text-dim);
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.settings-pane-btn:hover { background: var(--bg-hover); }
.settings-pane-btn.active { background: var(--accent-dim); color: var(--text); }
.settings-pane-btn.active .settings-pane-icon { color: var(--accent); }
.settings-pane-icon { display: flex; color: inherit; }
.settings-pane-btn svg { width: 16px; height: 16px; }
.settings-pane-label { flex: 1; }
.settings-pane-soon { font-family: var(--mono); font-size: var(--text-2xs); color: var(--text-dim); }

.settings-pane-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.settings-pane-header {
  padding: var(--space-9) var(--space-10) var(--space-7);
  border-bottom: 1px solid var(--border);
}
.settings-pane-title-row { display: flex; align-items: baseline; gap: 12px; }
.settings-pane-title { font-size: var(--text-title); font-weight: var(--weight-medium); }
.settings-pane-tag { font-family: var(--mono); font-size: var(--text-2xs); color: var(--text-dim); }
.settings-pane-note { font-size: var(--text-xs); color: var(--text-dim); margin-top: 4px; }

.settings-pane-content { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: var(--space-10) var(--space-10) var(--space-4); }
.settings-pane-inner { max-width: 720px; }

.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-9);
  border-top: 1px solid var(--border);
}
.settings-footer-status { font-size: var(--text-xs); color: var(--text-dim); }
.settings-footer-status.saved { color: var(--accent); }
.settings-footer-actions { display: flex; gap: 8px; }
.settings-footer-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--font);
  font-size: var(--text-control);
  cursor: pointer;
  opacity: 0.4;
}
.settings-footer-btn:not(:disabled) { cursor: pointer; opacity: 1; }
.settings-footer-btn.primary {
  border: none;
  background: var(--accent-dim);
  color: var(--text);
}
.settings-footer-btn.primary:not(:disabled) { background: var(--accent); color: #10121a; }

/* field / group primitives */
.field {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.field:last-child { border-bottom: none; }
.field-main { flex: 1; min-width: 0; }
.field-label { font-size: var(--text-control); }
.field-hint { font-size: var(--text-xs); color: var(--text-dim); margin-top: 3px; }
.field-mono { font-family: var(--mono); font-size: var(--text-2xs); color: var(--text-dim); margin-top: 4px; }
.field-control { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }

.settings-group { margin-bottom: var(--space-10); }
.settings-group-title { font-size: var(--text-2xs); color: var(--text-dim); margin-bottom: 2px; }
.settings-group-note { font-size: var(--text-xs); color: var(--text-dim); margin-bottom: 8px; max-width: 520px; }
.settings-group-body { border-top: 1px solid var(--border); }

.segmented {
  display: flex;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 2px;
  gap: 2px;
}
.segmented-btn {
  border: none;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-sm);
  background: transparent;
  color: var(--text-dim);
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.segmented-btn.on { background: var(--accent-dim); color: var(--text); }
.segmented-btn:disabled { cursor: not-allowed; opacity: 0.45; }

.switch {
  width: 40px;
  height: 23px;
  border-radius: var(--radius-pill);
  position: relative;
  cursor: pointer;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 0;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch:disabled { opacity: 0.4; cursor: default; }
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: left 160ms var(--ease);
}
.switch.on .switch-thumb { left: 19px; background: #10121a; }

.settings-select, .settings-text {
  background: var(--bg-sunken);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-code);
  font-family: var(--font);
  font-size: var(--text-sm);
  padding: 6px 8px;
  outline: none;
}
.settings-select.mono, .settings-text.mono { font-family: var(--mono); }
.settings-select:focus, .settings-text:focus { border-color: var(--accent); }

.settings-stepper { display: flex; align-items: center; gap: 8px; }
.settings-stepper-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--mono);
  font-size: var(--text-code);
}
.settings-stepper-value { font-family: var(--mono); font-size: var(--text-sm); min-width: 54px; text-align: center; }

.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); flex: 0 0 auto; }
.status-dot.up { background: var(--accent); }
.status-dot.down { background: var(--danger); }
.key-state { font-family: var(--mono); font-size: var(--text-2xs); color: var(--text-dim); }

.planned-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-code);
  padding: 10px 12px;
  margin-bottom: 20px;
  font-size: var(--text-xs);
  color: var(--text-dim);
  line-height: var(--leading-body);
}
.planned-note svg { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 1px; }

.settings-real-pane .settings-section-header { margin-bottom: 4px; }
.settings-real-pane .settings-section:not(:last-child) { margin-bottom: var(--space-10); }

/* ---------- voice mode ---------- */
@keyframes voicePulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.app-surface {
  transition: opacity 420ms var(--ease), transform 760ms var(--ease), filter 520ms var(--ease);
}
.app-surface.hushed {
  opacity: 0;
  transform: scale(1.03);
  filter: blur(6px);
  pointer-events: none;
}

.footer-left { display: flex; align-items: center; gap: 16px; }
.wake-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease-standard);
}
.wake-chip:hover { color: var(--text-body); }
.wake-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--action-primary);
  animation: voicePulse 2.4s ease-in-out infinite;
}

.voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 82px 34px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 480ms var(--ease);
}
.voice-overlay.open { opacity: 1; pointer-events: auto; }

.voice-top-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 520ms var(--ease) 160ms, transform 520ms var(--ease) 160ms;
}
.voice-overlay.open .voice-top-row { opacity: 1; transform: none; }

.voice-spacer { flex: 1; }

.voice-ribbon-box {
  width: min(880px, 78vw);
  height: 260px;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 520ms var(--ease);
}
.voice-overlay.open .voice-ribbon-box { opacity: 1; }
.voice-ribbon-box canvas { width: 100%; height: 100%; display: block; }

.voice-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  flex: 0 0 auto;
}
.voice-state-row { display: flex; align-items: center; gap: 9px; }
.voice-state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 300ms var(--ease);
}
.voice-state-dot.listening { background: rgba(231, 232, 234, 0.9); }
.voice-state-dot.speaking { background: rgba(124, 158, 255, 1); }
.voice-state-dot.pulse { animation: voicePulse 1.8s ease-in-out infinite; }
.voice-state-dot.muted { background: var(--text-danger); animation: none; }
.voice-state-label { font-size: var(--text-xs); color: var(--text-body); letter-spacing: 0.02em; }
.voice-state-hint { font-size: var(--text-2xs); color: var(--text-muted); }

.voice-transcript {
  width: min(680px, 70vw);
  flex: 0 0 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  transition: max-height 520ms var(--ease), opacity 320ms var(--ease), margin-top 520ms var(--ease);
  mask-image: linear-gradient(to bottom, transparent 0, #000 24%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 24%);
}
.voice-transcript.open { max-height: 210px; opacity: 1; margin-top: 26px; }
.voice-transcript-inner { display: flex; flex-direction: column; gap: 12px; }
.voice-transcript-row { display: flex; gap: 12px; align-items: baseline; opacity: 0.4; transition: opacity 400ms var(--ease); }
.voice-transcript-row.last { opacity: 0.92; }
.voice-transcript-speaker { font-family: var(--font-mono); font-size: var(--text-2xs); flex: 0 0 40px; color: var(--text-muted); }
.voice-transcript-speaker.shao { color: var(--action-primary); }
.voice-transcript-text { font-size: var(--text-list); color: var(--text-body); text-wrap: pretty; }

.voice-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 520ms var(--ease) 220ms, transform 520ms var(--ease) 220ms;
}
.voice-overlay.open .voice-controls { opacity: 1; transform: none; }

.voice-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  background: rgba(30, 32, 37, 0.62);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: var(--text-muted);
  transition: background 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}
.voice-pill:hover { background: rgba(255, 255, 255, 0.10); color: var(--text-body); }
.voice-pill.danger:hover { color: var(--text-danger); border-color: rgba(226, 113, 107, 0.45); }
.voice-pill-key { font-family: var(--font-mono); font-size: var(--text-2xs); opacity: 0.9; }

/* ==================== Mobile shell (templates/mobile.html) ====================
   Ported from the Shao Design System's templates/mobile/MobileApp.dc.html. The
   design mocks its phone view inside a bezel graphic on a desktop artboard — that
   bezel is presentation chrome for the design canvas, not something a real phone
   browser needs, so it's dropped here in favor of filling the actual viewport,
   same as how flyover-home's artboard frame isn't reproduced in index.html. The
   design's fake iOS status bar (hardcoded clock/signal/wifi/battery glyphs) is
   dropped for the same reason, plus a real one can't be recreated honestly — the
   Battery Status and signal-strength are not available to web pages — so this
   just reserves safe-area space for the real one instead of drawing a fake one. */

.mobile-body { overflow: hidden; }

.mobile-dim {
  position: fixed; inset: 0; z-index: 0;
  background: var(--surface-app);
  opacity: 0; pointer-events: none;
  transition: opacity 320ms var(--ease);
}
.mobile-dim.on { opacity: 1; }

.mobile-screen {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  height: 100dvh; width: 100%;
}

.mobile-safe-top { flex: 0 0 auto; height: env(safe-area-inset-top); }

.mobile-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.mobile-view.scr { overflow-y: auto; }

/* ---- Home ---- */
.mobile-home { padding: 0 24px 8px; }
.mobile-clock { padding-top: 22px; font-size: 60px; font-weight: 200; letter-spacing: -0.03em; line-height: 1; }
.mobile-date { margin-top: 6px; font-size: var(--text-control); color: var(--text-muted); }
.mobile-home-heading { margin-top: 30px; font-size: var(--text-title); line-height: var(--leading-tight); color: var(--text-body); }

.mobile-recent { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.mobile-recent-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  text-align: left; width: 100%; min-height: 52px; padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.07); border-radius: var(--radius);
  background: rgba(30, 32, 37, 0.55); backdrop-filter: blur(18px) saturate(180%); -webkit-backdrop-filter: blur(18px) saturate(180%);
  color: var(--text-body); cursor: pointer;
}
.mobile-recent-slug { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--action-primary); }
.mobile-recent-title { font-size: var(--text-list); color: var(--text-body); }

.mobile-spacer { flex: 1; }

.mobile-subjects { display: flex; gap: 8px; padding-bottom: 12px; overflow-x: auto; }
.mobile-subject-chip {
  flex: 0 0 auto; min-height: 44px; padding: 0 15px; border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08); background: rgba(13, 14, 17, 0.5);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  color: var(--text-muted); font-family: var(--font-mono); font-size: var(--text-2xs); cursor: pointer;
}

.mobile-empty { padding: 40px 16px; text-align: center; font-size: var(--text-list); color: var(--text-muted); }

/* ---- Chats list ---- */
.mobile-list-header { flex: 0 0 auto; padding: 12px 22px 10px; }
.mobile-list-top { display: flex; align-items: center; justify-content: space-between; }
.mobile-list-title { margin: 0; font-size: var(--text-display); font-weight: var(--weight-semibold); letter-spacing: -0.02em; }
.mobile-list-new {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); border: none; background: var(--action-primary); color: var(--text-on-accent); cursor: pointer;
}
.mobile-search {
  margin-top: 12px; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  border-radius: var(--radius); background: var(--surface-sunken); border: 1px solid var(--border-default); color: var(--text-muted);
}
.mobile-search-input { flex: 1; min-width: 0; border: none; background: transparent; color: var(--text-body); font-family: var(--font-ui); font-size: var(--text-control); outline: none; }

.mobile-convo-list { flex: 1; overflow-y: auto; padding: 0 12px 12px; }
.mobile-convo-item {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left;
  width: 100%; min-height: 64px; padding: 13px 12px; border: none; border-radius: var(--radius);
  background: transparent; color: var(--text-body); cursor: pointer;
}
.mobile-convo-item:hover { background: var(--surface-hover); }
.mobile-convo-row { display: flex; width: 100%; gap: 8px; align-items: baseline; }
.mobile-convo-title { flex: 1; font-size: var(--text-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-convo-when { flex: 0 0 auto; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-muted); }
.mobile-convo-subject { flex: 0 0 auto; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--action-primary); }
.mobile-convo-preview { flex: 1; font-size: var(--text-list); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Chat thread ---- */
.mobile-chat-header {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 4px 12px 10px;
  border-bottom: 1px solid var(--border-default);
}
.mobile-chat-back, .mobile-chat-voice-btn {
  width: 44px; height: 44px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer;
}
.mobile-chat-back { color: var(--action-primary); }
.mobile-chat-voice-btn { color: var(--text-muted); }
.mobile-chat-meta { flex: 1; min-width: 0; }
.mobile-chat-title { font-size: var(--text-control); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-chat-subject { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--action-primary); }

.mobile-thread { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.mobile-msg-user { display: flex; justify-content: flex-end; }
.mobile-msg-user-bubble {
  max-width: 80%; padding: 10px 14px; border-radius: 18px 18px 4px 18px;
  background: var(--surface-selected); font-size: var(--text-control); line-height: var(--leading-body); white-space: pre-wrap;
}
.mobile-msg-assistant { font-size: var(--text-control); line-height: var(--leading-body); color: var(--text-body); }
.mobile-cursor { display: inline-block; width: 7px; height: 15px; vertical-align: -2px; background: var(--action-primary); animation: mobileCaret 1s steps(1) infinite; }
.mobile-msg-context {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px;
  border: 1px solid var(--border-default); border-radius: var(--radius-pill); background: var(--surface-sunken);
}
.mobile-msg-context-subject { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--action-primary); }
.mobile-msg-context-counts { font-size: var(--text-2xs); color: var(--text-muted); }

.mobile-composer {
  flex: 0 0 auto; padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-default); background: var(--surface-app);
  display: flex; align-items: flex-end; gap: 8px;
}
.mobile-composer-input-wrap {
  flex: 1; min-width: 0; display: flex; align-items: center; min-height: 44px; padding: 0 14px;
  border-radius: 22px; background: var(--surface-raised); border: 1px solid var(--border-default);
}
.mobile-composer-input { flex: 1; min-width: 0; border: none; background: transparent; color: var(--text-body); font-family: var(--font-ui); font-size: var(--text-composer); outline: none; }
.mobile-send {
  width: 44px; height: 44px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-pill); background: var(--action-primary); color: var(--text-on-accent); cursor: pointer;
}
.mobile-send:disabled { opacity: 0.5; cursor: default; }

/* ---- Voice mode ---- */
.mobile-voice { padding: 0 26px 8px; }
.mobile-voice-label { padding-top: 16px; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--action-primary); letter-spacing: 0.06em; }
.mobile-voice-mid { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; min-height: 0; }

.mobile-voice-orb-wrap { position: relative; width: 132px; height: 132px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.mobile-voice-orb {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 42% 34%, rgba(124, 158, 255, 0.55), rgba(124, 158, 255, 0.06) 68%);
  animation: mobileOrbPulse 2.6s ease-in-out infinite;
}
.mobile-voice-ring { position: absolute; inset: 26px; border-radius: 50%; border: 1px solid rgba(124, 158, 255, 0.45); }
.mobile-voice-bars { position: relative; display: flex; align-items: flex-end; gap: 4px; height: 36px; }
.mobile-voice-bars .bar { width: 4px; height: 36px; border-radius: 2px; background: var(--action-primary); transform-origin: center bottom; animation: mobileBarPulse 1.1s ease-in-out infinite; }
.mobile-voice-bars .bar:nth-child(1) { animation-delay: 0s; }
.mobile-voice-bars .bar:nth-child(2) { animation-delay: 0.13s; }
.mobile-voice-bars .bar:nth-child(3) { animation-delay: 0.26s; }
.mobile-voice-bars .bar:nth-child(4) { animation-delay: 0.39s; }
.mobile-voice-bars .bar:nth-child(5) { animation-delay: 0.52s; }

.mobile-voice-line { text-align: center; font-size: var(--text-title); line-height: var(--leading-tight); color: var(--text-body); }
.mobile-voice-transcript { max-height: 30vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.mobile-voice-row { display: flex; gap: 10px; align-items: baseline; }
.mobile-voice-who { flex: 0 0 auto; font-family: var(--font-mono); font-size: var(--text-2xs); width: 34px; color: var(--text-muted); }
.mobile-voice-body { flex: 1; font-size: var(--text-list); color: var(--text-muted); }

.mobile-voice-controls { display: flex; justify-content: center; gap: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.mobile-voice-btn {
  width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(30, 32, 37, 0.6); color: var(--text-muted); cursor: pointer;
}
.mobile-voice-btn.on { color: var(--action-primary); border-color: rgba(124, 158, 255, 0.4); }
.mobile-voice-btn-danger { border: none; background: var(--action-danger); color: #16171b; }

/* ---- Ambient ---- */
.mobile-ambient { padding: 14px 20px 8px; display: flex; flex-direction: column; gap: 12px; }
.mobile-ambient-label { font-size: var(--text-2xs); font-family: var(--font-mono); color: var(--text-muted); letter-spacing: 0.06em; }
.mobile-now-card, .mobile-recent-card { padding: 16px; border: 1px solid var(--border-default); border-radius: var(--radius-composer); background: var(--surface-raised); }
.mobile-now-card { padding: 18px; }
.mobile-now-tag { font-size: var(--text-2xs); font-family: var(--font-mono); color: var(--action-primary); }
.mobile-now-body { margin-top: 8px; font-size: var(--text-title); line-height: var(--leading-tight); }

.mobile-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mobile-stat-card { padding: 14px; border: 1px solid var(--border-default); border-radius: var(--radius-composer); background: var(--surface-raised); }
.mobile-stat-label { font-size: var(--text-2xs); font-family: var(--font-mono); color: var(--text-muted); letter-spacing: 0.05em; }
.mobile-stat-value { margin-top: 6px; font-size: 26px; font-weight: 300; letter-spacing: -0.02em; }
.mobile-stat-note { margin-top: 2px; font-size: var(--text-2xs); color: var(--text-muted); }

.mobile-recent-card-label { font-size: var(--text-2xs); font-family: var(--font-mono); color: var(--text-muted); letter-spacing: 0.05em; }
.mobile-recent-card-list { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.mobile-recent-card-row { display: flex; gap: 10px; align-items: baseline; border: none; background: transparent; padding: 0; text-align: left; cursor: pointer; color: inherit; font-family: inherit; }
.mobile-recent-card-when { flex: 0 0 auto; font-family: var(--font-mono); font-size: var(--text-2xs); width: 30px; color: var(--text-muted); }
.mobile-recent-card-slug { flex: 0 0 auto; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--action-primary); }
.mobile-recent-card-title { flex: 1; font-size: var(--text-list); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Dock ---- */
.mobile-dock {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 8px 16px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(13, 14, 17, 0.55); backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
}
.mobile-dock-tab {
  flex: 1; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: none; background: transparent; color: var(--text-muted); cursor: pointer;
}
.mobile-dock-tab:hover { color: var(--text-body); }
.mobile-dock-tab.active { color: var(--action-primary); }
.mobile-dock-tab span { font-size: 10px; }

@keyframes mobileOrbPulse { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.13); opacity: 0.95; } }
@keyframes mobileBarPulse { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
@keyframes mobileCaret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
