/* U.G.L.Y. Studio: the Director (engine). Dark by default. */
:root {
  --bg: #0a0a19;
  --panel: #161433;
  --panel-glass: rgba(22, 20, 51, 0.74);
  --panel-solid: #161433;
  --border: rgba(129, 140, 248, 0.24);
  --text: #eef0ff;
  --muted: #b9bce6;
  --faint: #9ea2d6;
  --accent: #818cf8;
  --accent-2: #c084fc;
  --pink: #f472b6;
  --indigo: #6366f1;
  --purple: #a855f7;
  --coral: #ff9a8a;
  --btn-text: #0b0b1d;
  --bubble-user: #2b2770;
  --bubble-bot: #1d1a42;
  --input-bg: #0f0e26;
  --glow-a: rgba(99, 102, 241, 0.55);
  --glow-b: rgba(168, 85, 247, 0.45);
  --glow-c: rgba(244, 114, 182, 0.32);
  --grad-text: linear-gradient(90deg, #a5b4fc, #d8b4fe 50%, #f9a8d4);
  --tile-grad: linear-gradient(135deg, #4f46e5, #7e22ce 55%, #be185d);
  --shadow: 0 1.25rem 3rem rgba(0, 0, 0, 0.45);
  --font-head: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --nav-h: 4rem;
  --chat-h: 30rem;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f3ff;
  --panel: #ffffff;
  --panel-glass: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --border: rgba(79, 70, 229, 0.2);
  --text: #18153a;
  --muted: #47437a;
  --faint: #55518a;
  --accent: #4f46e5;
  --accent-2: #7e22ce;
  --pink: #be185d;
  --coral: #b42318;
  --btn-text: #ffffff;
  --bubble-user: #e3e1ff;
  --bubble-bot: #f6f5ff;
  --input-bg: #ffffff;
  --glow-a: rgba(99, 102, 241, 0.32);
  --glow-b: rgba(168, 85, 247, 0.26);
  --glow-c: rgba(244, 114, 182, 0.22);
  --grad-text: linear-gradient(90deg, #4338ca, #7e22ce 50%, #be185d);
  --shadow: 0 1.25rem 3rem rgba(49, 46, 129, 0.14);
  color-scheme: light;
}

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: 143.75%; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: #0a0a19;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}
.glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40rem 26rem at 12% -6%, var(--glow-a), transparent 70%),
    radial-gradient(38rem 26rem at 92% 4%, var(--glow-b), transparent 70%),
    radial-gradient(44rem 30rem at 55% 105%, var(--glow-c), transparent 70%);
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 0.1875rem solid var(--accent-2); outline-offset: 0.125rem;
}
.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: 100; background: var(--panel-solid); color: var(--text); padding: 0.5rem 0.875rem; border-radius: 0.5rem; }
.skip:focus { top: 1rem; }

/* ---------- 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: #121031;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="light"] .topnav { background: #f4f3ff; background: color-mix(in srgb, var(--bg) 82%, transparent); }
.nav-row {
  width: min(100% - 2rem, 120rem); margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 0.5rem 1.25rem; padding: 0.625rem 0;
}
.brand { display: flex; align-items: center; gap: 0.625rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: none;
  border-radius: 0.75rem; font-family: var(--font-head); font-weight: 700; color: #ffffff;
  background: linear-gradient(135deg, #6366f1, #a855f7 55%, #ec4899);
  box-shadow: 0 0.375rem 1.25rem rgba(168, 85, 247, 0.4);
}
.brand-name { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name strong { font-family: var(--font-head); font-size: 1rem; }
.brand-name span { font-size: 0.75rem; color: var(--muted); }
.nav-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; }
.nav-links a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.875rem;
  padding: 0.375rem 0.75rem; border-radius: 62rem;
}
.nav-links a:hover { color: var(--text); background: rgba(129, 140, 248, 0.14); }
.nav-links a[aria-current="page"] { color: var(--text); background: rgba(129, 140, 248, 0.2); }
.prefs { display: flex; align-items: center; gap: 0.5rem; }
.size-group { display: flex; align-items: flex-end; gap: 0.125rem; padding: 0.1875rem; border: 1px solid var(--border); border-radius: 62rem; }
.size-btn {
  min-width: 2rem; height: 2rem; border: 0; border-radius: 62rem; background: transparent;
  color: var(--muted); font-family: var(--font-head); font-weight: 700; 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.1875rem; }
.size-btn[aria-pressed="true"] { background: var(--accent); color: var(--btn-text); }
.theme-btn {
  width: 2.5rem; height: 2.5rem; border-radius: 62rem; border: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer; display: grid; place-items: center;
}
.theme-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-btn .i-moon { fill: currentColor; stroke: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
:root[data-theme="light"] .theme-btn .i-sun { display: none; }

/* ---------- HERO ---------- */
.hero { width: min(100% - 2rem, 75rem); margin: 0 auto; padding: 1.25rem 0 1rem; text-align: center; }
.chip {
  display: inline-block; margin: 0 0 0.5rem; padding: 0.25rem 0.75rem; border-radius: 62rem;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; color: var(--text);
  background: rgba(129, 140, 248, 0.16); border: 1px solid var(--border);
}
.hero h1 {
  font-family: var(--font-head); font-weight: 700; letter-spacing: -0.02em;
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem); line-height: 1.1; margin: 0 0 0.5rem;
}
.grad {
  color: #c4b5fd;
  background: var(--grad-text); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subline { margin: 0 auto 0.75rem; max-width: 60rem; font-size: 0.9375rem; color: var(--text); }
.subline br { display: none; }
.hero-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.chip-link {
  display: inline-flex; align-items: center; min-height: 2.25rem; padding: 0.375rem 0.875rem;
  border-radius: 62rem; border: 1px solid var(--border); background: var(--panel-glass);
  color: var(--text); font-weight: 600; font-size: 0.875rem; text-decoration: none;
}
.chip-link:hover { border-color: var(--accent); }

/* ---------- BOARD ---------- */
.board {
  width: min(100% - 2rem, 83.75rem); margin: 0 auto 1.5rem;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; align-items: start;
}
.slot { min-width: 0; }
.card {
  position: relative; min-width: 0;
  background: #161433;
  background: var(--panel-glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 1.125rem; box-shadow: var(--shadow);
  padding: 1rem; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.1875rem;
  background: linear-gradient(90deg, #6366f1, #a855f7);
}
.top-card::before { background: linear-gradient(90deg, #a855f7, #f472b6); }
.short-card::before { background: linear-gradient(90deg, #818cf8, #c084fc); }
.detail-card::before { background: linear-gradient(90deg, #f472b6, #6366f1); }
.card h2 { font-family: var(--font-head); font-size: 1.0625rem; margin: 0; letter-spacing: -0.01em; }

/* chat */
.chat-card { display: flex; flex-direction: column; height: var(--chat-h); container-type: inline-size; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; flex: none; }
.chat-titles { flex: 1 0 auto; min-width: 0; }
.chat-sub { flex: none; margin: 0.125rem 0 0; font-size: 0.8125rem; color: var(--muted); }
.chat-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; flex: 0 0 auto; margin-left: auto; }
.icon-btn {
  width: 2.25rem; height: 2.25rem; border-radius: 62rem; border: 1px solid var(--border);
  background: transparent; color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#full-btn .i-shrink { display: none; }
#full-btn[aria-pressed="true"] .i-expand { display: none; }
#full-btn[aria-pressed="true"] .i-shrink { display: block; }
#full-btn[aria-pressed="true"] { background: var(--accent); color: var(--btn-text); border-color: transparent; }
.pill-btn {
  height: 2.25rem; padding: 0 0.875rem; border-radius: 62rem; border: 1px solid var(--border);
  background: transparent; color: var(--text); font-weight: 600; font-size: 0.8125rem; cursor: pointer; white-space: nowrap;
}
.pill-btn[aria-pressed="true"] { background: var(--accent); color: var(--btn-text); border-color: transparent; }
.count-chip {
  align-self: flex-start; flex: none; margin: 0.375rem 0; padding: 0.0625rem 0.625rem; border-radius: 62rem;
  font-size: 0.75rem; color: var(--muted); border: 1px solid var(--border);
}
.log {
  position: relative;
  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.25rem 0.5rem 0;
  scrollbar-width: thin; scrollbar-color: var(--accent) transparent;
}
.scroll-box { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
.log::-webkit-scrollbar, .scroll-box::-webkit-scrollbar { width: 0.375rem; }
.log::-webkit-scrollbar-thumb, .scroll-box::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 62rem; }
.msg { flex: none; max-width: 92%; padding: 0.625rem 0.875rem; border-radius: 1rem; font-size: 0.9375rem; min-width: 0; }
.msg p { margin: 0 0 0.5rem; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 0 0 0.5rem; padding-left: 1.125rem; }
.msg a { overflow-wrap: anywhere; }
.msg .h { font-family: var(--font-head); font-weight: 700; }
.msg.user { align-self: flex-end; background: var(--bubble-user); border-bottom-right-radius: 0.25rem; }
.msg.bot { align-self: flex-start; background: var(--bubble-bot); border: 1px solid var(--border); border-bottom-left-radius: 0.25rem; }
.msg.error { align-self: flex-start; border: 1px solid var(--coral); color: var(--coral); background: transparent; }
.msg .speaker { display: block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.25rem; }
.thinking .dots { display: inline-flex; gap: 0.3125rem; padding: 0.25rem 0; }
.thinking .dots span { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--accent-2); animation: pulse 1.2s infinite ease-in-out; }
.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.25rem 0 0; font-size: 0.8125rem; color: var(--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: 1; transform: none; }
  html { scroll-behavior: auto; }
}

.composer { flex: none; margin-top: 0.5rem; }
.composer-row { display: flex; flex-direction: column; gap: 0.5rem; }
.composer textarea {
  width: 100%; min-width: 0; resize: none; overflow-y: hidden; display: block;
  min-height: 2.75rem; max-height: 8rem; padding: 0.6875rem 0.875rem;
  border-radius: 1.375rem; border: 1px solid var(--border); background: var(--input-bg);
  color: var(--text); font: inherit; font-size: 1rem; line-height: 1.35;
}
.composer textarea::placeholder { color: var(--faint); opacity: 1; }
.composer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; flex: none; }
.mic-btn {
  width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 1px solid var(--border); flex: none;
  background: transparent; color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.mic-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mic-btn[aria-pressed="true"] { background: var(--pink); color: #ffffff; border-color: transparent; box-shadow: 0 0 0 0.25rem rgba(244, 114, 182, 0.28); }
:root[data-theme="dark"] .mic-btn[aria-pressed="true"] { color: #1a0b16; }
.send-btn {
  height: 2.75rem; padding: 0 1.25rem; border-radius: 62rem; border: 0; flex: none;
  background: linear-gradient(135deg, #818cf8, #c084fc); color: #0b0b1d; font-weight: 700; font-size: 0.9375rem; cursor: pointer;
}
:root[data-theme="light"] .send-btn { background: linear-gradient(135deg, #4f46e5, #7e22ce); color: #ffffff; }
.send-btn:disabled { opacity: 0.55; cursor: progress; }
.mic-status { margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--muted); }
.mic-error { margin: 0.375rem 0 0; font-size: 0.8125rem; color: var(--coral); }
.chat-note { flex: none; margin: 0.5rem 0 0; font-size: 0.75rem; color: var(--muted); }
@container (min-width: 18.5rem) {
  .composer-row { flex-direction: row; align-items: flex-end; }
  .composer textarea { flex: 1 1 auto; }
}

/* full page */
.chat-card.is-full {
  position: fixed; z-index: 60; height: auto; margin: 0;
  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);
  background: var(--panel-solid);
}
body.chat-full { overflow: hidden; }
.full-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(5, 5, 20, 0.6); }

/* side cards */
.side-card { display: flex; flex-direction: column; gap: 0.625rem; }
.pill-label {
  align-self: flex-start; margin: 0; padding: 0.1875rem 0.6875rem; border-radius: 62rem;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text);
  background: rgba(244, 114, 182, 0.18); border: 1px solid rgba(244, 114, 182, 0.4);
}
.match-tile {
  flex: none; display: flex; flex-direction: column; gap: 0.25rem; padding: 0.875rem; border-radius: 0.875rem;
  background: var(--tile-grad); color: #ffffff;
}
.tile-kind { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: #ffffff; }
.tile-title { font-family: var(--font-head); font-weight: 700; font-size: 1.125rem; line-height: 1.2; }
.fit-line { flex: none; margin: 0; color: var(--muted); font-size: 0.875rem; }
.fit-line strong { color: var(--text); font-family: var(--font-head); font-size: 1.125rem; }
.why { margin: 0; font-size: 0.875rem; color: var(--text); flex: 0 1 auto; min-height: 0; }
.short-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex: none; }
.gauge { position: relative; width: 2.75rem; height: 2.75rem; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.g-track { fill: none; stroke: rgba(129, 140, 248, 0.22); stroke-width: 5; }
.g-fill { fill: none; stroke: var(--accent-2); stroke-width: 5; stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.gauge span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: 0.8125rem; }
.rank-note { flex: none; margin: 0; font-size: 0.8125rem; color: var(--muted); }
.short-list { list-style: none; margin: 0; padding: 0 0.25rem 0 0; display: flex; flex-direction: column; gap: 0.375rem; flex: 0 1 auto; min-height: 0; }
.short-list li { flex: none; }
.short-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; text-align: left;
  padding: 0.5rem 0.625rem; border-radius: 0.625rem; border: 1px solid var(--border); background: transparent;
  color: var(--text); font: inherit; font-size: 0.875rem; cursor: pointer;
}
.short-item[aria-pressed="true"] { border-color: var(--accent-2); background: rgba(168, 85, 247, 0.14); }
.short-item .t { min-width: 0; overflow-wrap: anywhere; }
.short-item .s { flex: none; font-family: var(--font-head); font-weight: 700; }
.short-empty { font-size: 0.875rem; color: var(--muted); }
.detail-scroll { flex: 0 1 auto; min-height: 0; padding-right: 0.25rem; }
.detail-name { margin: 0 0 0.5rem; font-family: var(--font-head); font-weight: 700; }
.fields { margin: 0; display: grid; gap: 0.375rem; }
.fields div { flex: none; padding: 0.375rem 0.5rem; border-radius: 0.5rem; background: rgba(129, 140, 248, 0.1); }
.fields dt { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.fields dd { margin: 0; font-size: 0.875rem; overflow-wrap: anywhere; }
.guide-link { display: inline-block; margin-top: 0.625rem; font-weight: 600; font-size: 0.875rem; }
.next-step { flex: none; padding-top: 0.625rem; border-top: 1px solid var(--border); }
.next-step h3 { margin: 0 0 0.25rem; font-family: var(--font-head); font-size: 0.875rem; }
.next-step p { margin: 0; font-size: 0.875rem; }

.foot { width: min(100% - 2rem, 75rem); margin: 0 auto; padding: 0 0 calc(1.5rem + env(safe-area-inset-bottom)); text-align: center; font-size: 0.8125rem; color: var(--muted); }
.foot p { margin: 0 0 0.375rem; }

/* ---------- LAYOUTS ---------- */
@media (min-width: 700px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slot-chat { grid-column: 1 / -1; grid-row: 1; }
  .top-card { grid-column: 1; grid-row: 2; }
  .short-card { grid-column: 2; grid-row: 2; }
  .detail-card { grid-column: 3; grid-row: 2; }
  .subline br { display: inline; }
  .hero { text-align: center; }
}
@media (min-width: 1100px) {
  .board {
    width: min(100% - 3rem, clamp(56.25rem, 66vw, 83.75rem));
    grid-template-columns: 1.36fr 1.06fr 0.98fr 0.98fr;
  }
  .slot-chat { grid-column: 1; grid-row: 1; }
  .top-card { grid-column: 2; grid-row: 1; }
  .short-card { grid-column: 3; grid-row: 1; }
  .detail-card { grid-column: 4; grid-row: 1; }
  .side-card { max-height: var(--chat-h); }
}
