/* FlowMind · 念流 — design system and component styles.
   Mood: a quiet night sky, breath, ink, starlight. Every color is a token so the
   dawn theme and the canvas renderers (graph palette is read from these vars) stay in sync. */

/* ------------------------------------------------------------------ tokens: night */
:root {
  color-scheme: dark;

  --bg-0: #07060f;
  --bg-1: #0e0b22;
  --bg-grad: radial-gradient(130% 90% at 50% -10%, #1b1442 0%, #0e0b22 45%, #07060f 100%);
  --header-fade: rgba(7, 6, 15, 0.8);
  --tabbar-bg: rgba(10, 8, 24, 0.84);

  --text: #ece8f6;
  --text-muted: #a59fc0;
  --text-faint: rgba(236, 232, 246, 0.36);

  --aurora-violet: #6b5bd6;
  --aurora-teal: #3fb6a8;
  --aurora-rose: #e8a5b8;
  --gold: #f2d49b;
  --gold-text: #f2d49b;
  --gold-border: rgba(242, 212, 155, 0.45);
  --gold-glow: rgba(242, 212, 155, 0.35);
  --gold-soft: rgba(242, 212, 155, 0.12);

  --accent: #b9a6ff;
  --accent-soft: rgba(185, 166, 255, 0.22);
  --focus: #f2d49b;
  --danger: #ff9fb0;
  --success: #9be3a5;

  --glass: rgba(255, 255, 255, 0.04);
  --glass-strong: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-strong: rgba(255, 255, 255, 0.14);
  --glass-blur: 18px;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-bg-open: rgba(19, 15, 42, 0.74);
  --input-bg: rgba(255, 255, 255, 0.035);
  --popover-bg: rgba(16, 13, 36, 0.97);
  --dialog-bg: rgba(14, 11, 32, 0.94);
  --toast-bg: rgba(20, 16, 44, 0.92);
  --selected-bg: rgba(242, 212, 155, 0.1);
  --switch-off: rgba(255, 255, 255, 0.12);
  --switch-on: rgba(242, 212, 155, 0.55);
  --knob: #ece8f6;
  --stream-line: rgba(185, 166, 255, 0.3);
  --scroll-thumb: rgba(255, 255, 255, 0.14);
  --shadow-soft: 0 18px 50px -24px rgba(0, 0, 0, 0.85);
  --shadow-lift: 0 30px 80px -28px rgba(0, 0, 0, 0.9);
  --grain-opacity: 0.05;

  --orb-size: 220px;
  --orb-inner: #fff7e8;
  --orb-mid: #d9cbff;
  --orb-outer: #7b68e0;
  --orb-edge: #2a1f6e;
  --orb-accent: rgba(63, 182, 168, 0.55);
  --orb-glow: rgba(123, 104, 224, 0.55);
  --orb-ring: rgba(214, 203, 255, 0.55);
  --orb-shade: rgba(20, 10, 60, 0.45);
  --swirl-opacity: 0.9;

  --enso-a: #f2d49b;
  --enso-b: #ece8f6;
  --enso-c: #b9a6ff;
  --enso-star: #fff8ea;

  /* Thought types (also read by main.js for the graph palette). */
  --type-idea: #f2d49b;
  --type-task: #7fd1c7;
  --type-reflection: #b9a6ff;
  --type-question: #8fb8ff;
  --type-feeling: #f4a6b8;
  --type-plan: #9be3a5;
  --type-memory: #d7c4a3;
  --type-insight: #e9e4ff;

  /* Constellation canvas palette. The background is translucent so the aurora of the sky
     canvas glows faintly through the constellation. */
  --graph-bg: rgba(7, 6, 15, 0.62);
  --graph-text: #ece8f6;
  --graph-text-dim: rgba(236, 232, 246, 0.55);
  --graph-link: rgba(185, 166, 255, 0.2);
  --graph-relation: #f2d49b;
  --graph-insight: #e8a5b8;
  --graph-glow: #b9a6ff;

  /* Type & rhythm. */
  --font-display: "Cormorant Garamond", "Noto Serif SC", "Songti SC", "STSong", "Source Han Serif SC", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.2rem;
  --fs-xl: clamp(1.4rem, 1.15rem + 1vw, 1.75rem);
  --fs-2xl: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem);
  --fs-3xl: clamp(2rem, 1.3rem + 3vw, 3.1rem);

  --radius-sm: 10px;
  --radius: 18px;
  --radius-lg: 26px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-breath: cubic-bezier(0.45, 0, 0.55, 1);
  --dur-1: 400ms;
  --dur-2: 600ms;
  --dur-3: 800ms;

  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 760px;
  --topbar-h: 68px;
  --tabbar-h: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ------------------------------------------------------------------ tokens: dawn */
[data-theme="dawn"] {
  color-scheme: light;

  --bg-0: #f6f0e6;
  --bg-1: #efe4f3;
  --bg-grad: radial-gradient(130% 90% at 50% -10%, #fff8ec 0%, #f6f0e6 45%, #efe4f3 100%);
  --header-fade: rgba(246, 240, 230, 0.84);
  --tabbar-bg: rgba(249, 244, 237, 0.9);

  --text: #2b2540;
  --text-muted: #5f577a;
  --text-faint: rgba(43, 37, 64, 0.38);

  --aurora-violet: #8b7fd6;
  --aurora-teal: #5fae9f;
  --aurora-rose: #e8a87c;
  --gold: #b88a2c;
  --gold-text: #8a6418;
  --gold-border: rgba(184, 138, 44, 0.5);
  --gold-glow: rgba(232, 168, 124, 0.38);
  --gold-soft: rgba(184, 138, 44, 0.12);

  --accent: #6b5fc0;
  --accent-soft: rgba(107, 95, 192, 0.2);
  --focus: #6b5fc0;
  --danger: #b4405a;
  --success: #2f7d4a;

  --glass: rgba(255, 255, 255, 0.5);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(43, 37, 64, 0.09);
  --glass-border-strong: rgba(43, 37, 64, 0.17);
  --card-bg: rgba(255, 255, 255, 0.55);
  --card-bg-open: rgba(255, 255, 255, 0.84);
  --input-bg: rgba(255, 255, 255, 0.72);
  --popover-bg: rgba(255, 252, 247, 0.98);
  --dialog-bg: rgba(250, 246, 240, 0.96);
  --toast-bg: rgba(255, 252, 247, 0.95);
  --selected-bg: rgba(184, 138, 44, 0.12);
  --switch-off: rgba(43, 37, 64, 0.14);
  --switch-on: rgba(139, 127, 214, 0.78);
  --knob: #ffffff;
  --stream-line: rgba(107, 95, 192, 0.3);
  --scroll-thumb: rgba(43, 37, 64, 0.18);
  --shadow-soft: 0 18px 50px -26px rgba(60, 40, 90, 0.35);
  --shadow-lift: 0 30px 80px -30px rgba(60, 40, 90, 0.45);
  --grain-opacity: 0.06;

  --orb-inner: #fffaf0;
  --orb-mid: #f6d2b4;
  --orb-outer: #a597e6;
  --orb-edge: #6d5fc4;
  --orb-accent: rgba(232, 168, 124, 0.6);
  --orb-glow: rgba(232, 168, 124, 0.5);
  --orb-ring: rgba(139, 127, 214, 0.6);
  --orb-shade: rgba(80, 60, 140, 0.25);
  --swirl-opacity: 0.7;

  --enso-a: #b88a2c;
  --enso-b: #4a3f6b;
  --enso-c: #8b7fd6;
  --enso-star: #b88a2c;

  --type-idea: #b8862a;
  --type-task: #2f8f84;
  --type-reflection: #7a68d6;
  --type-question: #4a78c8;
  --type-feeling: #c9607e;
  --type-plan: #4c9a5a;
  --type-memory: #9a7b4f;
  --type-insight: #6f5fc9;

  --graph-bg: rgba(246, 240, 230, 0.66);
  --graph-text: #2b2540;
  --graph-text-dim: rgba(43, 37, 64, 0.55);
  --graph-link: rgba(43, 37, 64, 0.16);
  --graph-relation: #b88a2c;
  --graph-insight: #c9607e;
  --graph-glow: #8b7fd6;
}

/* ------------------------------------------------------------------ base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg-0);
  scrollbar-color: var(--scroll-thumb) transparent;
  scrollbar-width: thin;
  /* scrollIntoView targets (a new insight, a flashed thought) stay clear of the sticky header and tab bar. */
  scroll-padding-top: calc(var(--topbar-h) + var(--safe-top) + 12px);
  scroll-padding-bottom: calc(var(--tabbar-h) + 12px);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-0) var(--bg-grad) fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-x: clip;
  transition: background-color var(--dur-3) var(--ease), color var(--dur-3) var(--ease);
}

body[data-view="constellation"] {
  overflow: hidden;
  overscroll-behavior: none;
}

/* Film grain: inline SVG turbulence, barely there. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

::selection {
  background: rgba(242, 212, 155, 0.32);
}

[data-theme="dawn"] ::selection {
  background: rgba(139, 127, 214, 0.28);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  overflow-wrap: anywhere;
}

kbd {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.75em;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-gh {
  fill: currentColor;
  stroke: none;
}

.skip-link {
  position: fixed;
  top: -80px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--popover-bg);
  color: var(--text);
  text-decoration: none;
  transition: top var(--dur-1) var(--ease);
}

.skip-link:focus {
  top: calc(12px + var(--safe-top));
}

.noscript {
  position: relative;
  z-index: 5;
  max-width: 520px;
  margin: 20vh auto 0;
  padding: 24px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.7;
}

#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* ------------------------------------------------------------------ type helpers */
.eyebrow {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.display {
  font-family: var(--font-display);
}

/* ------------------------------------------------------------------ glass & buttons */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(120%);
  backdrop-filter: blur(var(--glass-blur)) saturate(120%);
  box-shadow: var(--shadow-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 42px;
  padding: 0.55em 1.15em;
  border: 1px solid var(--glass-border-strong);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}

.btn:hover {
  background: var(--glass-strong);
  border-color: var(--glass-border-strong);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  border-color: var(--gold-border);
  background: linear-gradient(135deg, var(--gold-soft), rgba(185, 166, 255, 0.14));
  box-shadow: 0 0 28px -12px var(--gold-glow);
}

.btn.primary:hover {
  box-shadow: 0 0 34px -8px var(--gold-glow);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn.ghost:hover {
  color: var(--text);
  background: var(--glass);
}

.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

.btn.danger:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.btn.sm {
  min-height: 34px;
  padding: 0.35em 0.85em;
  font-size: 0.82rem;
  gap: 0.4em;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-glyph {
  color: var(--gold);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--glass-strong);
  border-color: var(--glass-border);
}

.icon-btn[aria-pressed="true"] {
  color: var(--gold-text);
}

.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  text-decoration: underline dotted;
  text-decoration-color: var(--text-faint);
  text-underline-offset: 0.3em;
  cursor: pointer;
  transition: color var(--dur-1) var(--ease);
}

.link-btn:hover {
  color: var(--text);
}

/* ------------------------------------------------------------------ chips */
.chip {
  --tc: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 30px;
  max-width: 100%;
  padding: 0.22em 0.8em;
  border: 1px solid var(--glass-border-strong);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease),
    border-color var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}

.chip > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip:hover {
  color: var(--text);
  border-color: var(--glass-border-strong);
  background: var(--glass-strong);
}

.chip[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--gold-border);
  background: var(--selected-bg);
}

.chip-count {
  font-size: 0.72rem;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.chip-glyph {
  color: var(--tc);
  font-size: 0.95em;
}

.chip.concept {
  --hue: 260;
  color: hsl(var(--hue) 72% 86%);
  border-color: hsl(var(--hue) 60% 72% / 0.3);
  background: hsl(var(--hue) 60% 65% / 0.1);
}

.chip.concept::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex: none;
  background: hsl(var(--hue) 80% 78%);
  box-shadow: 0 0 8px hsl(var(--hue) 80% 70% / 0.8);
}

.chip.concept:hover,
.chip.concept[aria-pressed="true"] {
  color: hsl(var(--hue) 80% 92%);
  border-color: hsl(var(--hue) 70% 76% / 0.6);
  background: hsl(var(--hue) 60% 65% / 0.2);
}

[data-theme="dawn"] .chip.concept {
  color: hsl(var(--hue) 45% 30%);
  border-color: hsl(var(--hue) 40% 45% / 0.3);
  background: hsl(var(--hue) 55% 55% / 0.1);
}

[data-theme="dawn"] .chip.concept::before {
  background: hsl(var(--hue) 55% 50%);
  box-shadow: none;
}

[data-theme="dawn"] .chip.concept:hover,
[data-theme="dawn"] .chip.concept[aria-pressed="true"] {
  color: hsl(var(--hue) 50% 24%);
  border-color: hsl(var(--hue) 45% 40% / 0.55);
  background: hsl(var(--hue) 55% 55% / 0.2);
}

.chip.type-chip[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--tc) 60%, transparent);
  background: color-mix(in srgb, var(--tc) 14%, transparent);
}

.chip.is-off {
  opacity: 0.42;
}

.chip.is-off .chip-glyph {
  color: var(--text-muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.chip-row:empty {
  display: none;
}

:where(.result-card, .thought-card, .resonance-btn, .link-candidate) { --tc: var(--type-reflection); }

.type-idea { --tc: var(--type-idea); }
.type-task { --tc: var(--type-task); }
.type-reflection { --tc: var(--type-reflection); }
.type-question { --tc: var(--type-question); }
.type-feeling { --tc: var(--type-feeling); }
.type-plan { --tc: var(--type-plan); }
.type-memory { --tc: var(--type-memory); }
.type-insight { --tc: var(--type-insight); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge.processing::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: pulse 1.6s var(--ease-breath) infinite;
}

.badge.warn {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.badge.pinned {
  color: var(--gold-text);
  border-color: var(--gold-border);
}

/* ------------------------------------------------------------------ header & navigation */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) max(var(--gutter), env(safe-area-inset-right, 0px)) 0
    max(var(--gutter), env(safe-area-inset-left, 0px));
}

.app-header::before {
  content: "";
  position: absolute;
  inset: 0 0 -28px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--header-fade) 0%, var(--header-fade) 52%, transparent 100%);
}

body[data-view="constellation"] .app-header::before {
  background: linear-gradient(to bottom, var(--header-fade) 0%, transparent 100%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  border-radius: 14px;
}

.enso {
  width: 38px;
  height: 38px;
  flex: none;
  overflow: visible;
}

.enso-stop-a { stop-color: var(--enso-a); }
.enso-stop-b { stop-color: var(--enso-b); }
.enso-stop-c { stop-color: var(--enso-c); }

.enso-glow {
  fill: var(--gold);
  opacity: 0.12;
  animation: twinkle 6s var(--ease-breath) infinite;
}

.enso-stroke {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 1.6s var(--ease);
}

.enso-star {
  fill: var(--enso-star);
  transform-box: fill-box;
  transform-origin: center;
  animation: star-breathe 6s var(--ease-breath) infinite;
}

.brand:hover .enso-stroke {
  transform: rotate(-14deg);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.wordmark-en {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.wordmark-zh {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.32em;
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-inline: auto;
  padding: 4px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 16px;
  border-radius: 999px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1.08rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--dur-2) var(--ease), background-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.tab:hover {
  color: var(--text);
}

.tab[aria-current="page"] {
  color: var(--text);
  background: var(--glass-strong);
  box-shadow: inset 0 0 0 1px var(--glass-border-strong), 0 0 26px -10px var(--gold-glow);
}

.tab-glyph {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color var(--dur-2) var(--ease);
}

.tab-glyph .fill {
  fill: currentColor;
  stroke: none;
}

.tab[aria-current="page"] .tab-glyph {
  color: var(--gold);
}

.tab-alt {
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.icon-to-night {
  display: none;
}

[data-theme="dawn"] .icon-to-dawn {
  display: none;
}

[data-theme="dawn"] .icon-to-night {
  display: block;
}

/* ------------------------------------------------------------------ main & views */
main {
  position: relative;
  z-index: 1;
  display: block;
  padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + 56px)
    max(var(--gutter), env(safe-area-inset-left, 0px));
}

main:focus {
  outline: none;
}

.view {
  animation: view-in var(--dur-3) var(--ease);
}

.view-head {
  max-width: var(--maxw);
  margin: clamp(12px, 5vh, 48px) auto 24px;
  text-align: center;
}

.view-title {
  margin: 6px 0 4px;
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.08em;
}

.view-sub {
  margin: 0;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  text-wrap: balance;
}

.empty {
  max-width: 460px;
  margin: 8vh auto 0;
  text-align: center;
  animation: rise var(--dur-3) var(--ease);
}

.empty-glyph {
  margin: 0;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 2.6rem;
  line-height: 1;
  opacity: 0.85;
  animation: twinkle 6s var(--ease-breath) infinite;
}

.empty-title {
  margin: 14px 0 6px;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 400;
  line-height: 1.35;
}

.empty-text {
  margin: 0 0 18px;
  color: var(--text-muted);
  line-height: 1.7;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ------------------------------------------------------------------ Now view */
.now {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 680px;
  min-height: calc(100dvh - var(--topbar-h) - var(--safe-top) - var(--tabbar-h) - 56px);
  margin: 0 auto;
  padding-top: clamp(8px, 4vh, 44px);
  text-align: center;
}

.greeting {
  min-height: 1.6em;
  margin: 0 0 6px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-style: italic;
  letter-spacing: 0.05em;
}

.now-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 300;
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-wrap: balance;
}

.orb-stage {
  position: relative;
  flex: none;
  width: var(--orb-size);
  height: var(--orb-size);
  margin: clamp(30px, 7vh, 64px) auto clamp(22px, 4vh, 36px);
}

.orb {
  --level: 0;
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.orb:focus-visible {
  outline-offset: 14px;
}

.orb > span {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.orb-halo {
  inset: -42%;
  background: radial-gradient(closest-side, var(--orb-glow), transparent 72%);
  opacity: 0.7;
  animation: halo 6s var(--ease-breath) infinite;
  transition: opacity var(--dur-3) var(--ease), transform 160ms linear;
}

.orb-core {
  inset: 0;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.32) 9%, transparent 27%),
    radial-gradient(circle at 66% 72%, var(--orb-accent) 0%, transparent 48%),
    radial-gradient(circle at 50% 50%, var(--orb-inner) 0%, var(--orb-mid) 32%, var(--orb-outer) 68%, var(--orb-edge) 100%);
  box-shadow:
    0 0 60px -6px var(--orb-glow),
    0 0 140px -20px var(--orb-glow),
    inset -14px -20px 44px var(--orb-shade),
    inset 10px 12px 30px rgba(255, 255, 255, 0.2);
  animation: breathe 6s var(--ease-breath) infinite;
  transition: transform 160ms linear, filter var(--dur-3) var(--ease);
}

.orb-sheen {
  inset: 7%;
  background: radial-gradient(circle at 50% 4%, rgba(255, 255, 255, 0.4), transparent 52%);
  opacity: 0.8;
  animation: breathe 6s var(--ease-breath) infinite;
}

.orb-ripples {
  inset: 0;
  transform: scale(calc(1 + var(--level) * 0.22));
  transition: transform 160ms linear;
}

.orb-ripples i {
  position: absolute;
  inset: 0;
  border: 1px solid var(--orb-ring);
  border-radius: 50%;
  opacity: 0;
  box-shadow: 0 0 22px -6px var(--orb-glow), inset 0 0 22px -10px var(--orb-glow);
}

.orb-swirl {
  inset: -9%;
  background: conic-gradient(from 0deg, transparent 0deg, var(--aurora-violet) 60deg, transparent 120deg,
    var(--aurora-teal) 180deg, transparent 240deg, var(--aurora-rose) 300deg, transparent 360deg);
  filter: blur(16px);
  opacity: 0;
  transition: opacity 1.2s var(--ease);
}

.orb:hover .orb-core {
  filter: brightness(1.06);
}

.orb[data-state="listening"] .orb-core,
.orb[data-state="listening"] .orb-sheen {
  animation: none;
  transform: scale(calc(1.02 + var(--level) * 0.1));
  filter: brightness(calc(1.04 + var(--level) * 0.22)) saturate(1.1);
}

.orb[data-state="listening"] .orb-halo {
  animation: none;
  opacity: calc(0.8 + var(--level) * 0.2);
  transform: scale(calc(1.05 + var(--level) * 0.25));
}

.orb[data-state="listening"] .orb-ripples i {
  animation: ripple 3.3s var(--ease) infinite;
}

.orb[data-state="listening"] .orb-ripples i:nth-child(2) {
  animation-delay: 1.1s;
}

.orb[data-state="listening"] .orb-ripples i:nth-child(3) {
  animation-delay: 2.2s;
}

.orb[data-state="thinking"] .orb-swirl {
  opacity: var(--swirl-opacity);
  animation: swirl 9s linear infinite;
}

.orb[data-state="thinking"] .orb-core {
  animation-duration: 4s;
  filter: saturate(1.15);
}

.orb[data-state="thinking"] .orb-sheen {
  background: conic-gradient(from 90deg, transparent, rgba(255, 255, 255, 0.35), transparent 40%,
    rgba(255, 255, 255, 0.2), transparent 75%);
  animation: swirl 5s linear infinite reverse;
}

.breath {
  position: relative;
  width: 100%;
  height: 1.7em;
  margin: -10px 0 4px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  letter-spacing: 0.22em;
}

.breath span {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  opacity: 0;
}

.breath-in {
  animation: breath-in 6s var(--ease-breath) infinite;
}

.breath-out {
  animation: breath-out 6s var(--ease-breath) infinite;
}

.orb-hint {
  min-height: 1.6em;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-wrap: balance;
  transition: opacity var(--dur-2) var(--ease);
}

.transcript {
  width: 100%;
  max-width: 34em;
  max-height: 40vh;
  margin-top: 18px;
  overflow-y: auto;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1rem + 1.1vw, 1.6rem);
  line-height: 1.6;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  animation: rise var(--dur-2) var(--ease);
}

.transcript-interim {
  opacity: 0.45;
  transition: opacity var(--dur-1) var(--ease);
}

.listen-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  animation: rise var(--dur-2) var(--ease);
}

.type-toggle {
  margin-top: 22px;
}

.audio-rescue {
  width: 100%;
  margin-top: 20px;
  padding: 16px 18px;
  border-color: var(--gold-border);
  border-radius: var(--radius);
  text-align: left;
  animation: rise var(--dur-2) var(--ease);
}

.audio-rescue-title {
  margin: 0;
  color: var(--gold-text);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 500;
  line-height: 1.3;
}

.audio-rescue-text {
  margin: 4px 0 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.audio-rescue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.composer {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-lg);
  text-align: left;
  animation: rise var(--dur-2) var(--ease);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.composer:focus-within {
  border-color: var(--glass-border-strong);
  box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow-soft);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  max-height: 50vh;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.composer textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
  font-style: italic;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--glass-border);
}

.composer-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.result {
  width: 100%;
  margin-top: 26px;
  text-align: left;
}

.result:empty {
  display: none;
}

.welcome {
  width: 100%;
  margin-top: 26px;
  padding: clamp(20px, 5vw, 30px);
  border-radius: var(--radius-lg);
  text-align: left;
  animation: rise 1s var(--ease) 0.2s backwards;
}

.welcome-title {
  margin: 8px 0 10px;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 400;
  line-height: 1.35;
}

.welcome-text {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.75;
}

.welcome-steps {
  display: grid;
  gap: 10px;
  margin: 18px 0 22px;
  padding: 0;
  list-style: none;
}

.welcome-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-glyph {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 50%;
  color: var(--gold);
  font-family: var(--font-display);
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.organizer-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: auto 0 0;
  padding-top: 40px;
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.organizer-dot {
  --dot: var(--text-muted);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 10px var(--dot);
}

.organizer-line[data-provider="claude"] .organizer-dot { --dot: var(--gold); }
.organizer-line[data-provider="openai"] .organizer-dot { --dot: var(--type-task); }
.organizer-line[data-provider="local"] .organizer-dot { --dot: var(--type-reflection); }

/* ------------------------------------------------------------------ the distilled thought (result card) */
.result-card {
  position: relative;
  overflow: hidden;
  padding: clamp(18px, 4.5vw, 30px);
  border-radius: var(--radius-lg);
  animation: rise var(--dur-3) var(--ease);
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0 10% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--tc), transparent);
  opacity: 0.8;
}

.result-card::after {
  content: "";
  position: absolute;
  top: -40%;
  left: 50%;
  width: 70%;
  height: 80%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tc) 18%, transparent), transparent);
  pointer-events: none;
}

.result-card > * {
  position: relative;
  z-index: 1;
}

.rc-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

.rc-meta,
.tc-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0;
  padding-right: 40px;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

.type-mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--tc);
  letter-spacing: 0.12em;
}

.type-mark .glyph {
  color: var(--tc);
  font-size: 1rem;
  text-shadow: 0 0 10px color-mix(in srgb, var(--tc) 70%, transparent);
}

/* Dawn type colours are tuned for star glows; mixed with ink they read as text (≥ 4.5:1). */
[data-theme="dawn"] .type-mark {
  color: color-mix(in srgb, var(--tc) 60%, var(--text));
}

.dot-sep {
  opacity: 0.5;
}

.rc-title {
  margin: 12px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 1.2rem + 1.5vw, 2.1rem);
  font-weight: 500;
  line-height: 1.25;
  text-wrap: balance;
}

.rc-content,
.tc-content {
  margin: 0;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rc-summary {
  margin: 14px 0 0;
  padding-left: 14px;
  border-left: 2px solid color-mix(in srgb, var(--tc) 50%, transparent);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.6;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.section-label {
  margin: 22px 0 8px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.distilling .rc-title {
  opacity: 0.85;
}

.distilling-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 0;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
}

.shimmer {
  background: linear-gradient(90deg, var(--text-muted) 0%, var(--text) 38%, var(--gold) 50%, var(--text) 62%, var(--text-muted) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 3.6s linear infinite;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.4s var(--ease-breath) infinite;
}

.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }

.rc-raw {
  margin-top: 12px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.rc-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

/* actions as soft checkboxes */
.actions-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.action-item label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease);
}

.action-item label:hover {
  background: var(--glass);
}

.check {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 19px;
  height: 19px;
  margin: 3px 0 0;
  border: 1px solid var(--glass-border-strong);
  border-radius: 7px;
  background: var(--input-bg) no-repeat center / 12px 12px;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}

.check:checked {
  border-color: transparent;
  background-color: var(--type-task);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%2307060f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.check:checked + span {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
}

.action-item span {
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* resonance: connections to other thoughts */
.resonance-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.resonance-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.resonance-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease);
}

.resonance-btn:hover {
  background: var(--glass-strong);
}

.res-glyph {
  grid-row: span 2;
  align-self: center;
  color: var(--tc);
  font-size: 0.95rem;
}

.res-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 500;
}

.res-relation {
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-style: italic;
  overflow-wrap: anywhere;
}

.res-relation::before {
  content: "↔ ";
  color: var(--gold);
  font-style: normal;
}

.res-by {
  margin-left: 6px;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-style: normal;
  letter-spacing: 0.06em;
}

.unlink {
  width: 34px;
  height: 34px;
}

.unlink .icon {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------------ Stream view */
.stream-tools {
  display: grid;
  gap: 12px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search .icon {
  position: absolute;
  /* Above the input: its backdrop-filter makes it a later-painted layer that would blur the icon away. */
  z-index: 1;
  left: 17px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 50px;
  padding: 0 48px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 999px;
  background: var(--glass);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.search input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.search input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-kbd {
  position: absolute;
  right: 18px;
  padding: 1px 7px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 6px;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity var(--dur-1) var(--ease);
}

.search input:focus + .search-kbd,
.search input:not(:placeholder-shown) + .search-kbd {
  opacity: 0;
}

.stream-count {
  max-width: var(--maxw);
  min-height: 1.4em;
  margin: 14px auto 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-align: center;
}

.stream-list {
  max-width: var(--maxw);
  margin: 0 auto;
}

.day-group {
  margin-top: 30px;
}

.day-label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.18em;
}

.day-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--glass-border-strong), transparent);
}

.day-cards {
  position: relative;
  display: grid;
  gap: 12px;
}

.day-cards::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 14px;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--stream-line) 12%, var(--stream-line) 88%, transparent);
}

.thought-card {
  position: relative;
  margin-left: 42px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.thought-card:hover {
  border-color: var(--glass-border-strong);
}

.thought-card.is-open {
  background: var(--card-bg-open);
  border-color: var(--glass-border-strong);
  box-shadow: var(--shadow-soft);
}

.thought-card.is-flash {
  animation: flash 2.4s var(--ease);
}

.tc-node {
  position: absolute;
  top: 15px;
  left: -42px;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 1px solid color-mix(in srgb, var(--tc) 45%, transparent);
  border-radius: 50%;
  background: var(--bg-0);
  color: var(--tc);
  font-size: 0.85rem;
  line-height: 1;
  box-shadow: 0 0 16px -4px color-mix(in srgb, var(--tc) 70%, transparent);
}

.tc-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  width: 100%;
  padding: 14px 16px 10px;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.tc-title {
  font-family: var(--font-display);
  font-size: 1.24rem;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.tc-time {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-top: 4px;
}

.tc-summary {
  grid-column: 1 / -1;
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.6;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.tc-badges {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tc-badges:empty {
  display: none;
}

.tc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 14px;
}

.tc-chips:empty {
  display: none;
}

.tc-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--glass-border);
  animation: fade-in var(--dur-2) var(--ease);
}

.tc-content {
  margin: 14px 0 4px;
}

.tc-raw {
  margin-top: 12px;
}

.tc-raw summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  list-style: none;
  border-radius: 8px;
}

.tc-raw summary::-webkit-details-marker {
  display: none;
}

.tc-raw summary::before {
  content: "›";
  display: inline-block;
  transition: transform var(--dur-1) var(--ease);
}

.tc-raw[open] summary::before {
  transform: rotate(90deg);
}

.tc-raw p {
  margin: 8px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--glass-border-strong);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.tc-toolbar .btn[aria-pressed="true"] {
  color: var(--gold-text);
  border-color: var(--gold-border);
}

.tc-toolbar .spacer {
  flex: 1;
}

.edit-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.edit-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.link-picker {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 16px;
  background: var(--popover-bg);
  box-shadow: var(--shadow-lift);
  animation: rise var(--dur-1) var(--ease);
}

.link-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.link-candidates {
  display: grid;
  gap: 2px;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.link-candidate {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.link-candidate:hover {
  background: var(--glass-strong);
}

.link-candidate .res-glyph {
  grid-row: auto;
}

.link-candidate-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.link-candidate-date {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.muted-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

/* ------------------------------------------------------------------ forms */
.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.edit-form .field {
  margin-top: 0;
}

.field > label {
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}

.field input,
.field select,
.field textarea,
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 0.98rem;
  outline: none;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.field textarea {
  min-height: 120px;
  line-height: 1.7;
  resize: vertical;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder,
.input::placeholder {
  color: var(--text-faint);
}

.field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 15px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

select option {
  background: var(--bg-1);
  color: var(--text);
}

.field-hint {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.field-hint.warn {
  color: var(--danger);
}

.title-input {
  font-family: var(--font-display);
  font-size: 1.2rem !important;
}

/* ------------------------------------------------------------------ Constellation view */
.view-constellation {
  position: fixed;
  inset: 0;
  z-index: 1;
  animation: fade-in 1.2s var(--ease);
}

#graph {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#graph:active {
  cursor: grabbing;
}

#graph[data-hover="1"] {
  cursor: pointer;
}

#graph:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--focus);
}

/* The canvas repaints its own background every frame, so the ring is drawn above it, inside the
   area left free by the header and the tab bar. */
.view-constellation:has(> #graph:focus-visible)::after {
  content: "";
  position: absolute;
  inset: calc(var(--topbar-h) + var(--safe-top) + 4px) 6px calc(var(--tabbar-h) + 6px);
  z-index: 1;
  border: 2px solid var(--focus);
  border-radius: var(--radius);
  pointer-events: none;
}

@supports selector(:has(*)) {
  #graph:focus-visible {
    box-shadow: none;
  }
}

.graph-head {
  position: absolute;
  top: calc(var(--topbar-h) + var(--safe-top) + 6px);
  left: max(var(--gutter), env(safe-area-inset-left, 0px));
  max-width: calc(100% - 2 * var(--gutter) - 70px);
  pointer-events: none;
}

.graph-title {
  margin: 0;
  font-size: var(--fs-2xl);
  text-shadow: 0 2px 20px var(--bg-0);
}

.graph-stats {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 12px var(--bg-0);
}

.graph-toolbar {
  position: absolute;
  top: calc(var(--topbar-h) + var(--safe-top) + 8px);
  right: max(var(--gutter), env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px;
  border-radius: 999px;
}

.graph-bottom {
  position: absolute;
  right: max(var(--gutter), env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabbar-h) + 22px);
  left: max(var(--gutter), env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  transition: opacity var(--dur-2) var(--ease), right var(--dur-2) var(--ease);
}

.graph-bottom > * {
  pointer-events: auto;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
}

.graph-legend .chip {
  background: var(--popover-bg);
  background: color-mix(in srgb, var(--bg-0) 70%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.graph-highlight {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  color: var(--gold-text);
  font-family: var(--font-display);
  font-size: 1.02rem;
  letter-spacing: 0.06em;
  animation: rise var(--dur-2) var(--ease);
}

.reveal {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  max-width: 100%;
  padding: 12px 28px;
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  background:
    radial-gradient(120% 180% at 50% 0%, rgba(242, 212, 155, 0.26), transparent 60%),
    color-mix(in srgb, var(--bg-0) 62%, rgba(107, 91, 214, 0.4));
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 0 44px -10px var(--gold-glow), inset 0 0 20px -8px var(--gold-glow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: reveal-glow 6s var(--ease-breath) infinite;
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.reveal:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 60px -8px var(--gold-glow), inset 0 0 24px -8px var(--gold-glow);
}

.reveal-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reveal-glyph {
  display: inline-block;
  color: var(--gold);
  font-size: 1.3rem;
  animation: swirl 30s linear infinite;
}

.reveal[aria-busy="true"] .reveal-glyph,
.btn-insight[aria-busy="true"] .btn-glyph {
  display: inline-block;
  animation: swirl 2.4s linear infinite;
}

.detail {
  position: absolute;
  top: calc(var(--topbar-h) + var(--safe-top) + 8px);
  right: calc(max(var(--gutter), env(safe-area-inset-right, 0px)) + 62px);
  width: min(380px, calc(100vw - 2 * var(--gutter) - 62px));
  max-height: calc(100% - var(--topbar-h) - var(--safe-top) - var(--tabbar-h) - 40px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--card-bg-open);
  animation: slide-in var(--dur-2) var(--ease);
  overscroll-behavior: contain;
}

.view-constellation.has-detail .graph-bottom {
  right: calc(max(var(--gutter), env(safe-area-inset-right, 0px)) + 460px);
}

.detail-close {
  position: sticky;
  top: 10px;
  float: right;
  margin: 10px 10px 0 0;
  z-index: 2;
  background: var(--popover-bg);
}

.detail-body {
  padding: 22px 22px 22px;
}

.detail-title {
  margin: 10px 0 8px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1.25;
}

.detail-summary {
  margin: 0;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.detail-concept-mark {
  --hue: 260;
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: hsl(var(--hue) 70% 72%);
  box-shadow: 0 0 16px hsl(var(--hue) 80% 70%);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.graph-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: calc(var(--topbar-h) + 20px) var(--gutter) calc(var(--tabbar-h) + 20px);
  text-align: center;
  pointer-events: none;
}

.graph-empty > * {
  max-width: 440px;
  margin-inline: auto;
}

.graph-empty .empty-actions {
  pointer-events: auto;
}

.view-constellation.is-empty .graph-bottom,
.view-constellation.is-empty .graph-toolbar {
  display: none;
}

/* ------------------------------------------------------------------ Insights view */
.btn-insight {
  margin-top: 22px;
  min-height: 48px;
  padding-inline: 1.5em;
  font-size: 1rem;
}

.insights-list {
  display: grid;
  gap: 26px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.insight {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 5vw, 42px);
  border-radius: var(--radius-lg);
  animation: rise var(--dur-3) var(--ease);
}

.insight::before {
  content: "";
  position: absolute;
  top: -45%;
  left: -25%;
  width: 90%;
  height: 90%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--aurora-violet) 28%, transparent), transparent);
  pointer-events: none;
}

.insight::after {
  content: "";
  position: absolute;
  right: -20%;
  bottom: -40%;
  width: 70%;
  height: 70%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--aurora-teal) 16%, transparent), transparent);
  pointer-events: none;
}

.insight > * {
  position: relative;
  z-index: 1;
}

.insight.is-new {
  animation: rise var(--dur-3) var(--ease), flash 2.6s var(--ease);
}

.insight-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

.insight-kicker {
  margin: 18px 0 0;
  color: var(--gold-text);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.insight-title {
  margin: 8px 0 16px;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 1.25rem + 2.2vw, 2.7rem);
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}

.insight-narrative {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.12rem, 1rem + 0.5vw, 1.32rem);
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.insight-section {
  margin-top: 28px;
}

.insight-section > h3 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.next-steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.next-steps li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: start;
  line-height: 1.7;
  counter-increment: step;
  overflow-wrap: anywhere;
}

.next-steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--gold-border);
  border-radius: 50%;
  color: var(--gold-text);
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.themes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.theme {
  padding: 14px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: var(--glass);
}

.theme-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.theme-desc {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.theme-count {
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.questions {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.questions li {
  padding-left: 18px;
  border-left: 1px solid var(--gold-border);
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-style: italic;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.hidden-links {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hidden-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 10px 14px;
  border: 1px dashed var(--glass-border-strong);
  border-radius: 14px;
}

.hidden-link-text {
  flex: 1 1 240px;
  min-width: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.hidden-link-text b {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
}

.hidden-link-text em {
  display: block;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.star-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.insight-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--glass-border);
}

.insight-pending {
  padding: clamp(22px, 5vw, 42px);
  border-radius: var(--radius-lg);
  text-align: center;
}

.insight-pending .insight-title {
  margin-bottom: 6px;
}

/* ------------------------------------------------------------------ dialogs */
.dialog {
  width: min(640px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(88vh, 920px);
  max-height: min(88dvh, 920px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg);
  background: var(--dialog-bg);
  color: var(--text);
  box-shadow: var(--shadow-lift);
  -webkit-backdrop-filter: blur(24px) saturate(120%);
  backdrop-filter: blur(24px) saturate(120%);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in var(--dur-2) var(--ease);
}

.dialog::backdrop {
  background: rgba(4, 3, 10, 0.58);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

[data-theme="dawn"] .dialog::backdrop {
  background: rgba(60, 48, 90, 0.22);
}

.dialog-inner {
  flex: 1;
  min-height: 0;
  padding: 24px clamp(18px, 4vw, 32px) 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dialog-title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 500;
  line-height: 1.3;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px clamp(18px, 4vw, 32px) calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--glass-border);
}

.set-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--glass-border);
}

.dialog-head + .set-section {
  margin-top: 18px;
  border-top: 0;
  padding-top: 0;
}

.set-title {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
}

.provider-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 10px;
}

.provider-card {
  position: relative;
  display: block;
  padding: 14px 14px 16px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 16px;
  background: var(--glass);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.provider-card:hover {
  background: var(--glass-strong);
}

.provider-card input,
.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.provider-card:has(input:checked) {
  border-color: var(--gold-border);
  background: var(--selected-bg);
  box-shadow: 0 0 30px -14px var(--gold-glow);
}

.provider-card:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.pc-body {
  display: grid;
  gap: 6px;
}

.pc-name {
  position: relative;
  display: block;
  padding-left: 22px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  hyphens: manual;
}

.pc-name::before {
  content: "";
  position: absolute;
  top: calc((1.4em - 14px) / 2);
  left: 0;
  width: 14px;
  height: 14px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}

input:checked + .pc-body .pc-name::before {
  border-color: var(--gold);
  background: radial-gradient(circle, var(--gold) 0 38%, transparent 44%);
}

.pc-badge {
  display: inline-block;
  vertical-align: 0.12em;
  padding: 0 8px;
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  color: var(--gold-text);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.pc-desc {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.provider-fields,
.voice-fields {
  animation: fade-in var(--dur-2) var(--ease);
}

.test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.test-result {
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.test-result.is-ok {
  color: var(--success);
}

.test-result.is-error {
  color: var(--danger);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 22px;
  background: var(--glass);
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: 8px 16px;
  border-radius: 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease);
}

.segmented label:hover span {
  color: var(--text);
}

.segmented input:checked + span {
  color: var(--text);
  background: var(--selected-bg);
  box-shadow: inset 0 0 0 1px var(--gold-border);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.set-section .segmented + .field,
.set-section .field + .segmented {
  margin-top: 16px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  cursor: pointer;
}

.switch-text {
  display: grid;
  gap: 2px;
}

.switch-title {
  font-weight: 500;
}

.switch-desc {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 48px;
  height: 28px;
  margin: 0;
  border: 1px solid var(--glass-border-strong);
  border-radius: 999px;
  background-color: var(--switch-off);
  background-image: radial-gradient(circle, var(--knob) 0 8.5px, transparent 9.5px);
  background-position: 0 50%;
  background-size: 26px 26px;
  background-repeat: no-repeat;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease), background-position var(--dur-1) var(--ease);
}

.switch:checked {
  background-color: var(--switch-on);
  background-position: 100% 50%;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.privacy-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.privacy-list li {
  position: relative;
  padding-left: 22px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.65;
}

.privacy-list li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--gold);
  font-size: 0.75rem;
  line-height: 2.1;
}

.about {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 18px 0 0;
}

.about-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--glass-border-strong);
  padding-bottom: 2px;
}

.about-link:hover {
  border-color: var(--gold-border);
}

.about-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.confirm {
  width: min(440px, calc(100vw - 32px));
}

.confirm .dialog-inner {
  padding: 26px 26px 22px;
}

.confirm-text {
  margin: 10px 0 0;
  color: var(--text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed;
  inset: auto auto calc(var(--tabbar-h) + 20px + var(--toast-lift, 0px)) 50%;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100vw - 32px));
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--text);
  transform: translateX(-50%);
  pointer-events: none;
}

.toasts::backdrop {
  display: none;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  padding: 12px 14px 12px 16px;
  border: 1px solid var(--glass-border-strong);
  border-radius: 16px;
  background: var(--toast-bg);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
  box-shadow: var(--shadow-lift);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  pointer-events: auto;
  animation: toast-in var(--dur-2) var(--ease);
}

.toast.is-leaving {
  animation: toast-out 0.5s var(--ease) forwards;
}

.toast-mark {
  flex: none;
  color: var(--gold);
}

.toast-error .toast-mark {
  color: var(--danger);
}

.toast-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast .btn {
  flex: none;
}

.toast .toast-close {
  flex: none;
  width: 32px;
  height: 32px;
  margin: -4px -6px -4px -4px;
}

/* ------------------------------------------------------------------ keyframes */
@keyframes breathe {
  0%, 100% { transform: scale(0.94); }
  50% { transform: scale(1.03); }
}

@keyframes halo {
  0%, 100% { opacity: 0.5; transform: scale(0.9); }
  50% { opacity: 0.95; transform: scale(1.06); }
}

@keyframes ripple {
  0% { opacity: 0.75; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.95); }
}

@keyframes swirl {
  to { transform: rotate(1turn); }
}

@keyframes breath-in {
  0% { opacity: 0; }
  12%, 38% { opacity: 0.85; }
  50%, 100% { opacity: 0; }
}

@keyframes breath-out {
  0%, 50% { opacity: 0; }
  62%, 88% { opacity: 0.85; }
  100% { opacity: 0; }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes star-breathe {
  0%, 100% { transform: scale(0.9); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -150% 0; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(18px); }
}

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(40px); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

@keyframes flash {
  0% { box-shadow: 0 0 0 0 var(--gold-glow), var(--shadow-soft); border-color: var(--gold-border); }
  100% { box-shadow: 0 0 0 18px transparent, var(--shadow-soft); }
}

@keyframes reveal-glow {
  0%, 100% { box-shadow: 0 0 36px -12px var(--gold-glow), inset 0 0 18px -10px var(--gold-glow); }
  50% { box-shadow: 0 0 60px -8px var(--gold-glow), inset 0 0 24px -8px var(--gold-glow); }
}

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1023.98px) {
  .tab-alt {
    display: none;
  }

  .tab {
    padding-inline: 14px;
  }

  /* With a star's detail open there is no room left for the legend and the Confluence button:
     fade the bar out (visibility also takes it out of the tab order and hit-testing). */
  .view-constellation.has-detail .graph-bottom {
    right: max(var(--gutter), env(safe-area-inset-right, 0px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-2) var(--ease), visibility 0s linear var(--dur-2);
  }

  .view-constellation.has-detail .graph-bottom > * {
    pointer-events: none;
  }
}

@media (max-width: 719.98px) {
  :root {
    --orb-size: 180px;
    --topbar-h: 56px;
    --tabbar-h: calc(64px + var(--safe-bottom));
  }

  .app-header {
    gap: 8px;
  }

  .header-actions {
    margin-left: auto;
  }

  .enso {
    width: 32px;
    height: 32px;
  }

  .wordmark-en {
    font-size: 1.25rem;
  }

  .tabs {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    height: var(--tabbar-h);
    margin: 0;
    padding: 6px max(6px, env(safe-area-inset-right, 0px)) var(--safe-bottom) max(6px, env(safe-area-inset-left, 0px));
    border: 0;
    border-top: 1px solid var(--glass-border);
    border-radius: 0;
    background: var(--tabbar-bg);
  }

  .tab {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 50px;
    padding: 4px 2px;
    border-radius: 14px;
    font-family: var(--font-body);
    font-size: 0.74rem;
    letter-spacing: 0.06em;
  }

  .tab[aria-current="page"] {
    background: transparent;
    box-shadow: none;
  }

  .tab[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--gold);
    box-shadow: 0 0 12px var(--gold);
    transform: translateX(-50%);
  }

  .tab-glyph {
    width: 22px;
    height: 22px;
  }

  .view-head {
    margin-top: 8px;
  }

  .chip-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
    margin-inline: calc(-1 * var(--gutter));
    padding: 2px var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
  }

  .chip-row::-webkit-scrollbar {
    display: none;
  }

  .thought-card {
    margin-left: 34px;
  }

  .tc-node {
    left: -34px;
    width: 25px;
    height: 25px;
    font-size: 0.78rem;
  }

  .day-cards::before {
    left: 12px;
  }

  .tc-head {
    padding: 12px 14px 8px;
  }

  .tc-chips {
    padding: 0 14px 12px;
  }

  .tc-body {
    padding: 4px 14px 14px;
  }

  .graph-toolbar .icon-btn {
    width: 38px;
    height: 38px;
  }

  .graph-legend {
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: calc(100% + 2 * var(--gutter));
    margin-inline: calc(-1 * var(--gutter));
    padding: 2px var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .graph-legend::-webkit-scrollbar {
    display: none;
  }

  .reveal {
    min-height: 46px;
    padding: 10px 20px;
    font-size: 1.02rem;
  }

  /* The call to action wraps instead of losing its verb to an ellipsis. */
  .reveal-label {
    line-height: 1.3;
    text-align: center;
    text-wrap: balance;
    white-space: normal;
  }

  .detail {
    top: auto;
    right: 8px;
    bottom: calc(var(--tabbar-h) + 8px);
    left: 8px;
    width: auto;
    max-height: 58%;
    border-radius: 24px 24px 20px 20px;
    animation: sheet-up var(--dur-2) var(--ease);
  }

  .dialog.settings {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 26px 26px 0 0;
  }

  .dialog.settings[open] {
    animation: sheet-up var(--dur-2) var(--ease);
  }

  .welcome-actions .btn,
  .empty-actions .btn {
    flex: 1 1 auto;
  }

  /* First visit on a phone: tighten the space around the orb and put the welcome card's two
     actions right under its title, so "Light up a sample" and "Connect an AI" are within reach. */
  .now:has(> .welcome:not([hidden])) {
    padding-top: 8px;
  }

  .now:has(> .welcome:not([hidden])) .orb-stage {
    margin: 20px auto 14px;
  }

  .now:has(> .welcome:not([hidden])) .type-toggle {
    margin-top: 12px;
  }

  .welcome {
    display: flex;
    flex-direction: column;
    margin-top: 14px;
  }

  .welcome-title {
    font-size: var(--fs-lg);
  }

  .welcome-actions {
    margin-bottom: 16px;
  }

  .welcome-text,
  .welcome-steps {
    order: 1;
  }

  .welcome-steps {
    margin-bottom: 0;
  }
}

@media (max-width: 719.98px) and (max-height: 760px) {
  .now:has(> .welcome:not([hidden])) {
    --orb-size: 160px;
  }
}

@media (max-width: 380px) {
  .wordmark-zh {
    display: none;
  }

  .tc-time {
    display: none;
  }
}

@media (max-height: 640px) and (min-width: 720px) {
  :root {
    --orb-size: 170px;
  }
}

@media (hover: none) {
  .search-kbd,
  .composer-hint {
    display: none;
  }

  .composer-foot {
    justify-content: flex-end;
  }
}

/* ------------------------------------------------------------------ motion & contrast preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .breath-in {
    opacity: 0.85;
  }
}

@media (forced-colors: active) {
  .orb-core {
    border: 2px solid ButtonText;
  }

  .chip[aria-pressed="true"],
  .tab[aria-current="page"] {
    outline: 2px solid Highlight;
  }
}
