/* Navigator (engine) page. Dark by default, indigo / purple / pink accents. */

:root {
  --bg: #0a0a18;
  --bg-glow-1: rgba(99, 102, 241, 0.42);
  --bg-glow-2: rgba(168, 85, 247, 0.34);
  --bg-glow-3: rgba(244, 114, 182, 0.24);
  --text: #eef0ff;
  --text-muted: #b9bde0;
  --panel: rgb(22, 22, 48);
  --panel-glass: rgba(22, 22, 48, 0.74);
  --panel-solid: #16163a;
  --panel-border: rgba(165, 180, 252, 0.22);
  --inset: rgba(255, 255, 255, 0.05);
  --inset-border: rgba(165, 180, 252, 0.18);
  --link: #c4b5fd;
  --accent-1: #6366f1;
  --accent-2: #a855f7;
  --accent-3: #818cf8;
  --accent-4: #c084fc;
  --accent-5: #f472b6;
  --btn-grad: linear-gradient(135deg, #4f46e5, #7e22ce);
  --btn-text: #ffffff;
  --chip-bg: rgba(129, 140, 248, 0.16);
  --chip-text: #dfe3ff;
  --user-bubble: linear-gradient(135deg, #4338ca, #6b21a8);
  --user-text: #ffffff;
  --bot-bubble: rgba(255, 255, 255, 0.06);
  --coral: #ff8a8a;
  --coral-bg: rgba(255, 99, 99, 0.12);
  --focus: #f0abfc;
  --nav-glass: rgba(12, 12, 30, 0.72);
  --track: rgba(255, 255, 255, 0.12);
  --shadow: 0 1.25rem 3rem rgba(0, 0, 0, 0.45);
  --scrollbar: rgba(196, 181, 253, 0.55);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f4ff;
  --bg-glow-1: rgba(99, 102, 241, 0.26);
  --bg-glow-2: rgba(168, 85, 247, 0.20);
  --bg-glow-3: rgba(244, 114, 182, 0.18);
  --text: #15152e;
  --text-muted: #45486a;
  --panel: rgb(255, 255, 255);
  --panel-glass: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --panel-border: rgba(79, 70, 229, 0.18);
  --inset: rgba(79, 70, 229, 0.05);
  --inset-border: rgba(79, 70, 229, 0.16);
  --link: #4338ca;
  --chip-bg: rgba(99, 102, 241, 0.12);
  --chip-text: #2e2a8a;
  --bot-bubble: rgba(79, 70, 229, 0.06);
  --coral: #b4232f;
  --coral-bg: rgba(220, 38, 38, 0.08);
  --focus: #7e22ce;
  --nav-glass: rgba(255, 255, 255, 0.78);
  --track: rgba(79, 70, 229, 0.14);
  --shadow: 0 1.25rem 3rem rgba(49, 46, 129, 0.14);
  --scrollbar: rgba(79, 70, 229, 0.45);
  color-scheme: light;
}

/* Text size: everything is in rem, so the root size scales the whole page. */
html { font-size: 100%; }
html[data-font-size="md"] { font-size: 112.5%; }
html[data-font-size="lg"] { font-size: 125%; }
html[data-font-size="xl"] { font-size: 137.5%; }

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background-color: var(--bg);
  background-image:
    radial-gradient(60rem 40rem at 8% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(50rem 36rem at 96% 4%, var(--bg-glow-2), transparent 62%),
    radial-gradient(46rem 34rem at 50% 108%, var(--bg-glow-3), transparent 64%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.15;
  margin: 0;
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

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

:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.125rem; border-radius: 0.375rem; }

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

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--panel-solid); color: var(--text); padding: 0.5rem 0.875rem; border-radius: 0.5rem;
}
.skip-link:focus { top: 1rem; }

.wrap { width: min(100% - 2rem, clamp(56.25rem, 66vw, 83.75rem)); margin-inline: auto; }

/* ---------- Nav ---------- */
.topnav {
  position: sticky; top: 0; z-index: 40;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: var(--panel-solid);
  border-bottom: 1px solid var(--panel-border);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topnav {
    background: var(--nav-glass);
    -webkit-backdrop-filter: blur(1rem) saturate(1.3);
    backdrop-filter: blur(1rem) saturate(1.3);
  }
}
.nav-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0.5rem 1rem; padding-block: 0.625rem;
}
.brand { display: flex; align-items: center; gap: 0.625rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; border-radius: 0.75rem; flex: none;
  background: linear-gradient(135deg, #4338ca, #6d28d9 55%, #be185d);
  display: grid; place-items: center; color: #fff; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 0.8125rem;
  box-shadow: 0 0.5rem 1.25rem rgba(99, 102, 241, 0.4);
}
.brand-name { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.brand-name strong { font-family: "Space Grotesk", sans-serif; font-size: 1rem; }
.brand-name span { font-size: 0.75rem; color: var(--text-muted); }
.nav-links { display: flex; flex-wrap: wrap; gap: 0.25rem; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: inline-block; padding: 0.375rem 0.75rem; border-radius: 999px;
  color: var(--text); text-decoration: none; font-size: 0.875rem; font-weight: 500;
}
.nav-links a[aria-current="page"] { background: var(--chip-bg); color: var(--chip-text); }
.nav-links a:hover { background: var(--inset); }
.nav-tools { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.size-group { display: inline-flex; align-items: flex-end; gap: 0.125rem; padding: 0.1875rem; border-radius: 999px; background: var(--inset); border: 1px solid var(--inset-border); }
.size-group button {
  border: 0; background: transparent; cursor: pointer; border-radius: 999px;
  min-width: 2rem; height: 2rem; padding: 0 0.375rem; font-weight: 700; line-height: 1; color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}
.size-group button[data-size="sm"] { font-size: 0.75rem; }
.size-group button[data-size="md"] { font-size: 0.875rem; }
.size-group button[data-size="lg"] { font-size: 1rem; }
.size-group button[data-size="xl"] { font-size: 1.1875rem; }
.size-group button[aria-pressed="true"] { background: var(--btn-grad); color: var(--btn-text); }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.375rem; cursor: pointer;
  border: 1px solid var(--inset-border); background: var(--inset); color: var(--text);
  height: 2.375rem; padding: 0 0.875rem; border-radius: 999px; font-size: 0.875rem; font-weight: 600;
}
.theme-toggle svg { width: 1rem; height: 1rem; }
@media (max-width: 30em) {
  .nav-row { gap: 0.375rem 0.5rem; }
  .nav-links a { padding: 0.375rem 0.625rem; }
  .size-group button { min-width: 1.75rem; }
  .theme-toggle { padding: 0 0.625rem; }
  .theme-toggle [data-theme-label] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Hero ---------- */
.hero { padding-block: 1.25rem 1rem; text-align: center; }
.chip {
  display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.75rem; border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-text); font-size: 0.8125rem; font-weight: 600;
}
.chip-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: linear-gradient(135deg, var(--accent-3), var(--accent-5)); }
.hero h1 { font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem); margin-top: 0.625rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.grad {
  color: var(--accent-4);
  background: linear-gradient(90deg, var(--accent-3), var(--accent-4) 50%, var(--accent-5));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
:root[data-theme="light"] .grad { color: #6d28d9; background: linear-gradient(90deg, #4338ca, #7e22ce 55%, #be185d); -webkit-background-clip: text; background-clip: text; }
.hero-sub { margin: 0.5rem auto 0; font-weight: 700; font-size: 1rem; color: var(--text); }
.hero-sub span { display: block; }
.hero-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.chip-link {
  display: inline-flex; align-items: center; gap: 0.375rem; text-decoration: none;
  padding: 0.4375rem 0.875rem; border-radius: 999px; font-size: 0.875rem; font-weight: 600;
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--panel-border);
}
.chip-link:hover { border-color: var(--accent-3); }

/* ---------- Board ---------- */
.board {
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 0 auto 1.5rem;
  display: grid; gap: 0.75rem; align-items: start;
  grid-template-columns: minmax(0, 1fr);
}
@media (max-width: 30em) { .board { width: calc(100% - 1.5rem); } }

.card {
  position: relative; min-width: 0;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-radius: 1.125rem;
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow: hidden;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: var(--panel-glass); -webkit-backdrop-filter: blur(1.125rem) saturate(1.2); backdrop-filter: blur(1.125rem) saturate(1.2); }
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 0.1875rem;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2), var(--accent-5));
}
.card.c-match::before { background: linear-gradient(90deg, var(--accent-5), var(--accent-4)); }
.card.c-short::before { background: linear-gradient(90deg, var(--accent-3), var(--accent-1)); }
.card.c-detail::before { background: linear-gradient(90deg, var(--accent-2), var(--accent-3)); }

.card-title { font-size: 1.125rem; }
.card-sub { margin: 0.125rem 0 0; color: var(--text-muted); font-size: 0.875rem; }

.pill {
  display: inline-block; align-self: flex-start; padding: 0.1875rem 0.625rem; border-radius: 999px;
  background: var(--chip-bg); color: var(--chip-text); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}

/* Grid placement: explicit cells, staggered heights. */
.c-chat { grid-column: 1; grid-row: 1; }
.c-match { grid-column: 1; grid-row: 2; }
.c-short { grid-column: 1; grid-row: 3; }
.c-detail { grid-column: 1; grid-row: 4; }

@media (min-width: 43.75em) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .c-chat { grid-column: 1 / -1; grid-row: 1; }
  .c-match { grid-column: 1; grid-row: 2; }
  .c-short { grid-column: 2; grid-row: 2; }
  .c-detail { grid-column: 3; grid-row: 2; }
}
@media (min-width: 68.75em) {
  .board { grid-template-columns: 1.36fr 1.06fr 0.98fr 0.98fr; }
  .c-chat { grid-column: 1; grid-row: 1; }
  .c-match { grid-column: 2; grid-row: 1; }
  .c-short { grid-column: 3; grid-row: 1; }
  .c-detail { grid-column: 4; grid-row: 1; }
}

/* Thin scrollbars that work with wheel, trackpad, touch and keys. */
.scroll {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent;
}
.scroll::-webkit-scrollbar { width: 0.5rem; }
.scroll::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 999px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll > * { flex: none; }

/* ---------- Chat card ---------- */
.c-chat { display: flex; flex-direction: column; container-type: inline-size; container-name: chat; }
.chat-head { min-width: 0; }
.chat-head-tools { display: flex; gap: 0.375rem; align-items: center; flex: none; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none; cursor: pointer;
  width: 2.375rem; height: 2.375rem; border-radius: 50%;
  border: 1px solid var(--inset-border); background: var(--inset); color: var(--text);
}
.icon-btn svg { width: 1.125rem; height: 1.125rem; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.text-btn {
  cursor: pointer; height: 2.375rem; padding: 0 0.75rem; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--inset-border); background: var(--inset); color: var(--text); font-size: 0.8125rem; font-weight: 600;
}
.chat-meta { margin-top: 0.5rem; display: flex; align-items: center; justify-content: space-between; gap: 0.375rem 0.5rem; flex-wrap: wrap; }
.count-chip { font-size: 0.75rem; font-weight: 600; padding: 0.1875rem 0.625rem; border-radius: 999px; background: var(--chip-bg); color: var(--chip-text); }

.log {
  position: relative; margin-top: 0.625rem; flex: 1 1 auto; min-height: 8rem;
  display: flex; flex-direction: column; gap: 0.625rem;
  padding: 0.25rem 0.375rem 0.25rem 0.125rem;
}
.empty-state { margin: auto 0; text-align: center; color: var(--text-muted); padding: 1rem 0.5rem; }
.empty-state strong { display: block; color: var(--text); font-family: "Space Grotesk", sans-serif; font-size: 1.0625rem; margin-bottom: 0.25rem; }
.empty-examples { list-style: none; padding: 0; margin: 0.75rem 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.375rem; }
.empty-examples button {
  cursor: pointer; border: 1px solid var(--inset-border); background: var(--inset); color: var(--text);
  border-radius: 999px; padding: 0.375rem 0.75rem; font-size: 0.8125rem; text-align: left;
}

.msg { max-width: 92%; padding: 0.625rem 0.875rem; border-radius: 1rem; overflow-wrap: anywhere; }
.msg p { margin: 0 0 0.5rem; }
.msg p:last-child { margin-bottom: 0; }
.msg ol, .msg ul { margin: 0 0 0.5rem; padding-left: 1.25rem; text-align: left; }
.msg-user { align-self: flex-end; background: var(--user-bubble); color: var(--user-text); border-bottom-right-radius: 0.375rem; }
.msg-bot { align-self: flex-start; background: var(--bot-bubble); border: 1px solid var(--inset-border); border-bottom-left-radius: 0.375rem; }
.msg-bot a { color: var(--link); }
.msg-label { display: block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.25rem; opacity: 0.85; }
.msg-error { align-self: flex-start; background: var(--coral-bg); color: var(--coral); border: 1px solid currentColor; }

.thinking .dots { display: inline-flex; gap: 0.3125rem; align-items: center; height: 1rem; }
.thinking .dots span {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-3), var(--accent-5));
  animation: pulse 1.2s ease-in-out infinite;
}
.thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking .dots span:nth-child(3) { animation-delay: 0.4s; }
.thinking .wait-note { margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--text-muted); }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.35; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) {
  .thinking .dots span { animation: none; opacity: 0.85; transform: none; }
  html { scroll-behavior: auto; }
}

.composer { margin-top: 0.625rem; display: grid; grid-template-columns: 1fr auto auto; gap: 0.5rem; align-items: end; }
.composer textarea {
  grid-column: 1 / -1;
  width: 100%; min-width: 0; resize: none; overflow-y: hidden;
  min-height: 2.75rem; max-height: 9rem; padding: 0.6875rem 0.875rem; line-height: 1.4;
  border-radius: 1.375rem; border: 1px solid var(--inset-border); background: var(--inset); color: var(--text);
}
.composer textarea::placeholder { color: var(--text-muted); opacity: 1; }
.composer .spacer { grid-column: 1; }
.mic-btn { width: 2.75rem; height: 2.75rem; }
.mic-btn[aria-pressed="true"] { background: var(--btn-grad); color: var(--btn-text); border-color: transparent; box-shadow: 0 0 0 0.25rem rgba(168, 85, 247, 0.3); }
.send-btn {
  cursor: pointer; height: 2.75rem; min-width: 4.75rem; padding: 0 1.125rem; border-radius: 999px; border: 0;
  background: var(--btn-grad); color: var(--btn-text); font-weight: 700;
}
.send-btn:disabled { cursor: progress; filter: saturate(0.6) brightness(0.85); }
@container chat (min-width: 18.5rem) {
  .composer textarea { grid-column: 1; }
  .composer .spacer { display: none; }
}
.voice-status { margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.voice-error { margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--coral); font-weight: 600; }
.chat-note { margin: 0.5rem 0 0; font-size: 0.75rem; color: var(--text-muted); }

/* Full page mode: fixed overlay; a placeholder keeps the grid from moving. */
.c-chat.is-full {
  position: fixed; z-index: 60;
  top: calc(env(safe-area-inset-top) + 0.75rem);
  bottom: calc(env(safe-area-inset-bottom) + 0.75rem);
  left: calc(env(safe-area-inset-left) + 0.75rem);
  right: calc(env(safe-area-inset-right) + 0.75rem);
  height: auto !important; max-height: none !important;
  margin: 0;
  background: var(--panel-solid);
}
.chat-placeholder { min-width: 0; }
body.full-open { overflow: hidden; }
.full-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(5, 5, 15, 0.6); }

/* ---------- Side cards ---------- */
.c-match, .c-short, .c-detail { display: flex; flex-direction: column; }
.side { display: flex; flex-direction: column; gap: 0.625rem; flex: 1 1 auto; min-height: 0; }
.side > * { flex: none; }
.side > .scroll { flex: 0 1 auto; min-height: 2.75rem; }
@media (min-width: 68.75em) {
  .side > .why, .side > .shortlist { max-height: none; }
}
.match-tile {
  border-radius: 0.875rem; padding: 0.875rem; color: #ffffff;
  background: linear-gradient(135deg, #4338ca, #7e22ce 60%, #be185d);
}
.match-kind { display: block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #f1e9ff; }
.match-title { display: block; margin-top: 0.25rem; font-family: "Space Grotesk", sans-serif; font-size: 1.125rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.match-tile.is-empty .match-title { font-size: 1rem; font-weight: 600; }
.score-row { display: flex; align-items: baseline; gap: 0.375rem; }
.score-num { font-family: "Space Grotesk", sans-serif; font-size: 1.75rem; font-weight: 700; }
.score-label { color: var(--text-muted); font-size: 0.8125rem; }
.why { margin: 0; color: var(--text); font-size: 0.875rem; max-height: 8rem; }

.gauge-row { display: flex; align-items: center; gap: 0.75rem; }
.gauge { width: 4rem; height: 4rem; flex: none; }
.gauge .g-track { stroke: var(--track); }
.gauge .g-fill { stroke: url(#gaugeGrad); transition: stroke-dasharray 0.4s ease; }
.gauge .g-fill.is-empty { opacity: 0; }
.gauge text { fill: var(--text); font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 0.875rem; }
.rank-note { margin: 0; font-size: 0.8125rem; color: var(--text-muted); }
.shortlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; max-height: 14rem; }
.shortlist button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; text-align: left; cursor: pointer;
  padding: 0.5rem 0.625rem; border-radius: 0.625rem; border: 1px solid var(--inset-border); background: var(--inset); color: var(--text);
}
.shortlist button[aria-pressed="true"] { border-color: var(--accent-4); background: var(--chip-bg); }
.shortlist .sl-title { min-width: 0; overflow-wrap: anywhere; font-size: 0.875rem; font-weight: 600; }
.shortlist .sl-score { flex: none; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 0.875rem; }
.muted { color: var(--text-muted); font-size: 0.875rem; margin: 0; }

.c-detail { display: flex; flex-direction: column; }
.c-detail .side { min-height: 0; flex: 1 1 auto; }
.fields { margin: 0; display: grid; gap: 0.375rem; min-height: 0; flex: 1 1 auto; }
.field { padding: 0.4375rem 0.625rem; border-radius: 0.625rem; background: var(--inset); border: 1px solid var(--inset-border); }
.field dt { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.field dd { margin: 0.125rem 0 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.guide-link { font-size: 0.875rem; font-weight: 600; }
.next-step { flex: none; border-top: 1px solid var(--panel-border); padding-top: 0.625rem; }
.next-step h3 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }
.next-step p { margin: 0.25rem 0 0; font-size: 0.875rem; overflow-wrap: anywhere; }

/* ---------- Footer ---------- */
.foot { padding: 0 0 calc(1.5rem + env(safe-area-inset-bottom)); text-align: center; color: var(--text-muted); font-size: 0.8125rem; }
.foot p { margin: 0.25rem 0; }

@media (min-width: 43.75em) {
  .hero-sub span { display: block; }
}
@media (min-width: 68.75em) {
  .hero h1 { white-space: nowrap; }
}
