/* Engine: dark glass layout, indigo/purple/pink accents. Mobile first. All sizes in rem. */
:root {
  --bg: #f4f4fb;
  --ink: #1b1838;
  --ink-soft: #33305a;
  --muted: #4d4a72;
  --line: rgba(79, 70, 229, 0.18);
  --glass: rgba(255, 255, 255, 0.78);
  --glass-strong: rgba(255, 255, 255, 0.94);
  --glass-solid: #ffffff;
  --nav-glass: rgba(255, 255, 255, 0.72);
  --nav-solid: #ffffff;
  --accent-text: #4338ca;
  --pink-text: #be185d;
  --chip-bg: rgba(99, 102, 241, 0.1);
  --chip-ink: #3730a3;
  --bubble-user: #4f46e5;
  --bubble-user-ink: #ffffff;
  --bubble-bot: #ffffff;
  --bubble-bot-ink: #1b1838;
  --input-bg: #ffffff;
  --pressed-bg: #4f46e5;
  --pressed-ink: #ffffff;
  --coral: #b4321e;
  --coral-bg: #fff0ec;
  --dots: #6366f1;
  --track: rgba(99, 102, 241, 0.15);
  --shadow: 0 0.0625rem 0.125rem rgba(27, 24, 56, 0.06), 0 0.75rem 2rem rgba(27, 24, 56, 0.1);
  --glow-1: rgba(99, 102, 241, 0.28);
  --glow-2: rgba(168, 85, 247, 0.22);
  --glow-3: rgba(244, 114, 182, 0.2);
  --send-bg: #4f46e5;
  --send-bg-2: #7e22ce;
  --send-ink: #ffffff;
  --focus: #4338ca;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a0a18;
  --ink: #eef0ff;
  --ink-soft: #d6d8f5;
  --muted: #b4b6db;
  --line: rgba(129, 140, 248, 0.22);
  --glass: rgba(20, 20, 44, 0.62);
  --glass-strong: rgba(24, 24, 52, 0.9);
  --glass-solid: #15152e;
  --nav-glass: rgba(10, 10, 24, 0.66);
  --nav-solid: #0e0e22;
  --accent-text: #a5b4fc;
  --pink-text: #f9a8d4;
  --chip-bg: rgba(129, 140, 248, 0.16);
  --chip-ink: #c7d2fe;
  --bubble-user: #4f46e5;
  --bubble-user-ink: #ffffff;
  --bubble-bot: rgba(255, 255, 255, 0.07);
  --bubble-bot-ink: #eef0ff;
  --input-bg: rgba(10, 10, 24, 0.7);
  --pressed-bg: #818cf8;
  --pressed-ink: #0a0a18;
  --coral: #ff9e8a;
  --coral-bg: rgba(255, 120, 100, 0.12);
  --dots: #c084fc;
  --track: rgba(129, 140, 248, 0.18);
  --shadow: 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.4), 0 1rem 2.5rem rgba(0, 0, 0, 0.35);
  --glow-1: rgba(99, 102, 241, 0.42);
  --glow-2: rgba(168, 85, 247, 0.34);
  --glow-3: rgba(244, 114, 182, 0.26);
  --send-bg: #4f46e5;
  --send-bg-2: #9333ea;
  --send-ink: #ffffff;
  --focus: #c084fc;
  color-scheme: dark;
}

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 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; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  text-align: center;
  position: relative;
}
h1, h2, h3 { font-family: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; margin: 0; line-height: 1.15; overflow-wrap: anywhere; }
p { margin: 0; }
a { color: var(--accent-text); text-underline-offset: 0.15em; }
button { font: inherit; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.125rem; border-radius: 0.375rem; }
ul, ol, dl { text-align: left; }
[hidden] { display: none !important; }
.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 { position: absolute; left: 1rem; top: -4rem; z-index: 60; background: var(--ink); color: var(--bg); padding: 0.5rem 1rem; border-radius: 0.5rem; }
.skip:focus { top: 1rem; }

/* Background glow: vivid, never dimmed by a scrim */
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40rem 28rem at 12% 8%, var(--glow-1), transparent 70%),
    radial-gradient(36rem 26rem at 88% 18%, var(--glow-2), transparent 70%),
    radial-gradient(44rem 30rem at 55% 105%, var(--glow-3), transparent 70%);
}
main, .nav, .foot { position: relative; z-index: 1; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: var(--nav-solid);
  background: var(--nav-glass);
  -webkit-backdrop-filter: blur(1rem) saturate(1.5);
  backdrop-filter: blur(1rem) saturate(1.5);
  border-bottom: 0.0625rem solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.nav-row {
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 0 auto; padding: 0.5rem 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 1.25rem;
}
@media (min-width: 64rem) { .nav-row { justify-content: space-between; } }
.brand { display: inline-flex; align-items: center; gap: 0.625rem; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-mark {
  width: 2.25rem; height: 2.25rem; border-radius: 0.75rem; display: grid; place-items: center; flex: none;
  background: #6366f1;
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #f472b6);
  color: #ffffff; font-family: "Space Grotesk", system-ui, sans-serif; font-weight: 700; font-size: 0.875rem;
  box-shadow: 0 0.375rem 1rem rgba(168, 85, 247, 0.35);
}
.brand-text { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.brand-text strong { font-family: "Space Grotesk", system-ui, sans-serif; font-size: 1rem; }
.brand-text span { font-size: 0.75rem; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1rem; }
.nav-links a { color: var(--ink-soft); text-decoration: none; font-size: 0.875rem; font-weight: 600; padding: 0.25rem 0; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--accent-text); }
.prefs { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.sizes { display: inline-flex; padding: 0.125rem; border-radius: 999px; border: 0.0625rem solid var(--line); background: var(--glass-strong); }
.size-btn { border: 0; background: transparent; color: var(--ink); font-weight: 700; min-width: 2rem; height: 2rem; padding: 0 0.375rem; border-radius: 999px; cursor: pointer; line-height: 1; }
.size-btn.s1 { font-size: 0.75rem; }
.size-btn.s2 { font-size: 0.875rem; }
.size-btn.s3 { font-size: 1rem; }
.size-btn.s4 { font-size: 1.125rem; }
.size-btn[aria-pressed="true"] { background: var(--pressed-bg); color: var(--pressed-ink); }
.theme-btn { display: inline-flex; align-items: center; gap: 0.375rem; height: 2.25rem; padding: 0 0.875rem; border-radius: 999px; border: 0.0625rem solid var(--line); background: var(--glass-strong); color: var(--ink); font-size: 0.875rem; font-weight: 600; cursor: pointer; }

/* Hero (compact) */
.hero { width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem)); margin: 0 auto; padding: 1.25rem 0 1rem; }
.chip { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink); font-size: 0.75rem; font-weight: 600; border: 0.0625rem solid var(--line); }
.hero h1 { margin-top: 0.625rem; font-size: clamp(1.75rem, 1rem + 2.4vw, 2.75rem); letter-spacing: -0.02em; }
.grad { color: #a855f7; background: linear-gradient(90deg, #818cf8, #c084fc 50%, #f472b6); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
:root:not([data-theme="dark"]) .grad { color: #7e22ce; background: linear-gradient(90deg, #4f46e5, #9333ea 55%, #be185d); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.subline { margin-top: 0.5rem; font-weight: 600; color: var(--ink-soft); font-size: 1rem; }
.br-wide { display: none; }
.hero-links { margin-top: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.chip-link { display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0.375rem 0.875rem; border-radius: 999px; border: 0.0625rem solid var(--line); background: var(--glass-strong); color: var(--accent-text); font-size: 0.875rem; font-weight: 600; text-decoration: none; }
.chip-link:hover { border-color: #818cf8; }

/* Board */
.board {
  width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
  margin: 0 auto; padding-bottom: 1.5rem;
  display: grid; gap: 0.75rem; grid-template-columns: minmax(0, 1fr); align-items: start;
}
.card {
  position: relative; min-width: 0;
  background: var(--glass-solid);
  background: var(--glass);
  -webkit-backdrop-filter: blur(1.25rem) saturate(1.4);
  backdrop-filter: blur(1.25rem) saturate(1.4);
  border: 0.0625rem solid var(--line); border-radius: 1.25rem; box-shadow: var(--shadow);
  padding: 1.125rem 1rem 1rem; overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 0.1875rem; background: #6366f1; }
.chat-card::before { background: linear-gradient(90deg, #6366f1, #a855f7, #f472b6); }
.match-card::before { background: linear-gradient(90deg, #a855f7, #c084fc); }
.short-card::before { background: linear-gradient(90deg, #818cf8, #6366f1); }
.detail-card::before { background: linear-gradient(90deg, #f472b6, #c084fc); }
.card-title { font-size: 1.0625rem; }

@media (min-width: 43.75rem) {
  body { text-align: left; }
  .hero { text-align: center; }
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chat-card { grid-column: 1 / -1; grid-row: 1; }
  .match-card { grid-column: 1; grid-row: 2; }
  .short-card { grid-column: 2; grid-row: 2; }
  .detail-card { grid-column: 3; grid-row: 2; }
}
@media (min-width: 68.75rem) {
  .board { grid-template-columns: 1.36fr 1.06fr 0.98fr 0.98fr; }
  .chat-card { grid-column: 1; grid-row: 1; }
  .match-card { grid-column: 2; grid-row: 1; }
  .short-card { grid-column: 3; grid-row: 1; }
  .detail-card { grid-column: 4; grid-row: 1; }
  .br-wide { display: inline; }
}

/* Chat card */
.chat-card {
  display: flex; flex-direction: column; gap: 0.625rem;
  height: 34rem; height: clamp(26rem, 78svh, 36rem);
}
@media (min-width: 43.75rem) { .chat-card { height: 32rem; height: clamp(24rem, 62svh, 34rem); } }
@media (min-width: 68.75rem) { .chat-card { height: 30rem; height: clamp(22rem, 100svh - 21rem, 38rem); } }
.chat-head { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: flex-start; justify-content: center; }
.chat-title-wrap { flex: 1 1 10rem; min-width: 0; }
.chat-title-wrap .count-chip { display: inline-block; margin-top: 0.375rem; }
.chat-title-wrap h2 { font-size: 1.125rem; }
.card-sub { font-size: 0.8125rem; color: var(--muted); }
.chat-tools { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; justify-content: center; }
@media (min-width: 43.75rem) { .chat-head { justify-content: space-between; } }
.count-chip { font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.625rem; border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink); white-space: nowrap; }
.icon-btn, .pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
  height: 2.25rem; border-radius: 999px; border: 0.0625rem solid var(--line);
  background: var(--glass-strong); color: var(--ink); cursor: pointer;
}
.icon-btn { width: 2.25rem; padding: 0; }
.pill-btn { padding: 0 0.75rem; font-size: 0.8125rem; font-weight: 600; }
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pill-btn[aria-pressed="true"] { background: var(--pressed-bg); color: var(--pressed-ink); border-color: transparent; }

.log {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 0.625rem; padding: 0.25rem 0.125rem;
  text-align: left;
}
.empty { margin: auto 0; text-align: center; color: var(--muted); font-size: 0.9375rem; padding: 0.5rem; }
.empty-title { color: var(--ink); font-weight: 600; margin-bottom: 0.25rem; }
.msg { max-width: 92%; padding: 0.625rem 0.875rem; border-radius: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9375rem; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-ink); border-bottom-right-radius: 0.25rem; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); color: var(--bubble-bot-ink); border: 0.0625rem solid var(--line); border-bottom-left-radius: 0.25rem; }
.msg.error { align-self: flex-start; background: var(--coral-bg); color: var(--coral); border: 0.0625rem solid var(--coral); font-weight: 600; }

.thinking { align-self: flex-start; padding: 0.75rem 0.875rem; border-radius: 1rem; border-bottom-left-radius: 0.25rem; background: var(--bubble-bot); border: 0.0625rem solid var(--line); }
.dots { display: inline-flex; gap: 0.3rem; align-items: center; height: 0.75rem; }
.dots span { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--dots); animation: pulse 1.2s ease-in-out infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .dots span { animation: none; opacity: 1; transform: none; } }
.wait-note { margin-top: 0.375rem; font-size: 0.8125rem; color: var(--muted); }

.composer { container-type: inline-size; display: grid; gap: 0.375rem; }
.composer-row { display: grid; gap: 0.5rem; grid-template-columns: minmax(0, 1fr); }
.composer textarea {
  width: 100%; min-height: 2.75rem; max-height: 8rem; resize: none; overflow-y: hidden;
  padding: 0.625rem 0.875rem; border-radius: 1.375rem; border: 0.0625rem solid var(--line);
  background: var(--input-bg); color: var(--ink); font: inherit; font-size: 1rem; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer-actions { display: flex; gap: 0.5rem; justify-content: center; align-items: center; }
@container (min-width: 18.5rem) {
  .composer-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .composer-actions { justify-content: flex-end; }
}
.mic-btn {
  width: 2.75rem; height: 2.75rem; border-radius: 50%; flex: none; cursor: pointer;
  border: 0.0625rem solid var(--line); background: var(--glass-strong); color: var(--ink);
  display: inline-grid; place-items: center;
}
.mic-btn[hidden] { display: none; }
.mic-btn[aria-pressed="true"] { background: #db2777; color: #ffffff; border-color: transparent; box-shadow: 0 0 0 0.25rem rgba(244, 114, 182, 0.3); }
.send-btn {
  height: 2.75rem; min-width: 4.75rem; padding: 0 1.125rem; border-radius: 999px; border: 0; cursor: pointer; flex: none;
  background: var(--send-bg);
  background: linear-gradient(135deg, var(--send-bg), var(--send-bg-2));
  color: var(--send-ink); font-weight: 700; font-size: 0.9375rem;
}
.send-btn:disabled { opacity: 0.6; cursor: progress; }
.mic-status { font-size: 0.8125rem; color: var(--muted); }
.mic-error { font-size: 0.8125rem; color: var(--coral); font-weight: 600; }
.chat-note { font-size: 0.75rem; color: var(--muted); }

/* Full page chat */
.chat-card.is-full {
  position: fixed; inset: 0; z-index: 50; height: auto; border-radius: 0; margin: 0;
  background: var(--glass-solid);
  padding: calc(1rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
@media (min-width: 64rem) {
  .chat-card.is-full { padding-left: max(12vw, env(safe-area-inset-left)); padding-right: max(12vw, env(safe-area-inset-right)); }
}
.chat-placeholder { visibility: hidden; }

/* Side cards */
.pill { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.25rem 0.625rem; border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink); }
.match-tile {
  margin-top: 0.75rem; border-radius: 1rem; padding: 1rem;
  background: #4f46e5;
  background: linear-gradient(135deg, #4f46e5, #7e22ce 60%, #be185d);
  color: #ffffff; text-align: left;
}
.tile-kind { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #ffffff; opacity: 0.92; }
.tile-title { margin-top: 0.25rem; font-family: "Space Grotesk", system-ui, sans-serif; font-size: 1.125rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.fit { margin-top: 0.75rem; font-size: 0.9375rem; }
.fit-label { color: var(--muted); }
.fit strong { color: var(--accent-text); font-family: "Space Grotesk", system-ui, sans-serif; font-size: 1.25rem; }
.why { margin-top: 0.25rem; color: var(--ink-soft); font-size: 0.875rem; overflow-wrap: anywhere; }

.gauge-row { margin-top: 0.75rem; display: flex; gap: 0.75rem; align-items: center; text-align: left; }
.gauge { flex: none; transform: rotate(-90deg); }
.gauge-track { stroke: var(--track); }
.gauge-fill.is-empty { stroke-opacity: 0; }
.gauge-fill { stroke: #a855f7; stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.gauge-num { font-family: "Space Grotesk", system-ui, sans-serif; font-size: 1.375rem; font-weight: 700; color: var(--ink); }
.rank-note { font-size: 0.8125rem; color: var(--muted); }
.short-list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.375rem; }
.short-list button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; text-align: left;
  padding: 0.5rem 0.625rem; border-radius: 0.75rem; border: 0.0625rem solid var(--line); background: var(--glass-strong);
  color: var(--ink); cursor: pointer; font-size: 0.875rem; font-weight: 600;
}
.short-list button[aria-pressed="true"] { border-color: #a855f7; box-shadow: inset 0 0 0 0.0625rem #a855f7; }
.short-list .t { min-width: 0; overflow-wrap: anywhere; }
.short-list .s { flex: none; color: var(--accent-text); font-family: "Space Grotesk", system-ui, sans-serif; }
.short-empty { margin-top: 0.75rem; font-size: 0.875rem; color: var(--muted); }

.detail-name { margin-top: 0.5rem; font-weight: 600; overflow-wrap: anywhere; }
.detail-list { margin: 0.5rem 0 0; display: grid; gap: 0.375rem; }
.detail-list div { padding: 0.375rem 0.5rem; border-radius: 0.625rem; background: var(--chip-bg); min-width: 0; }
.detail-list dt { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.detail-list dd { margin: 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.guide-link { display: inline-block; margin-top: 0.625rem; font-size: 0.875rem; font-weight: 600; }
.next { margin-top: 0.875rem; padding-top: 0.75rem; border-top: 0.0625rem solid var(--line); }
.next h3 { font-size: 0.9375rem; color: var(--pink-text); }
.next p { margin-top: 0.25rem; font-size: 0.875rem; color: var(--ink-soft); overflow-wrap: anywhere; }

.foot { width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem)); margin: 0 auto; padding: 0.5rem 0 calc(1.5rem + env(safe-area-inset-bottom)); text-align: center; font-size: 0.75rem; color: var(--muted); }
