/* Solo Operator engine — dark indigo/purple/pink template, mobile-first. All sizes in rem. */

:root {
  --indigo: #6366f1;
  --purple: #a855f7;
  --indigo-soft: #818cf8;
  --purple-soft: #c084fc;
  --pink: #f472b6;
  --bg: #0e0b26;
  --ink: #efeaff;
  --ink-soft: #bdb6e6;
  --line: rgba(255, 255, 255, 0.13);
  --panel-solid: rgba(26, 22, 62, 0.94);
  --panel-glass: rgba(255, 255, 255, 0.065);
  --field: rgba(10, 8, 30, 0.55);
  --bubble-user: linear-gradient(135deg, #6366f1, #a855f7);
  --bubble-user-ink: #ffffff;
  --bubble-bot: rgba(255, 255, 255, 0.08);
  --bar-solid: rgba(14, 11, 38, 0.96);
  --bar-glass: rgba(14, 11, 38, 0.62);
  --glow-1: rgba(99, 102, 241, 0.62);
  --glow-2: rgba(168, 85, 247, 0.5);
  --glow-3: rgba(244, 114, 182, 0.42);
  --focus: #c084fc;
  --warn: #ff9a85;
  --heading: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --pad-x: clamp(0.75rem, 3vw, 2.5rem);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f2ff;
  --ink: #1d1a4a;
  --ink-soft: #4f4a82;
  --line: rgba(99, 102, 241, 0.22);
  --panel-solid: rgba(255, 255, 255, 0.96);
  --panel-glass: rgba(255, 255, 255, 0.66);
  --field: rgba(255, 255, 255, 0.9);
  --bubble-bot: rgba(99, 102, 241, 0.08);
  --bar-solid: rgba(244, 242, 255, 0.97);
  --bar-glass: rgba(244, 242, 255, 0.7);
  --glow-1: rgba(99, 102, 241, 0.38);
  --glow-2: rgba(168, 85, 247, 0.3);
  --glow-3: rgba(244, 114, 182, 0.3);
  --focus: #7c3aed;
  --warn: #c2410c;
  color-scheme: light;
}

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-font-size="sm"] { font-size: 87.5%; }
html[data-font-size="md"] { font-size: 100%; }
html[data-font-size="lg"] { font-size: 115%; }
html[data-font-size="xl"] { font-size: 130%; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  text-align: center;
  overflow-wrap: break-word;
}
ul, ol { text-align: left; }
h1, h2, h3 { font-family: var(--heading); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--purple-soft); text-underline-offset: 0.18em; }
html[data-theme="light"] a { color: #6d28d9; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.1875rem; border-radius: 0.375rem; }

.skip-link { position: absolute; left: 0.5rem; top: -3rem; z-index: 60; background: var(--indigo); color: #fff; padding: 0.5rem 1rem; border-radius: 0.5rem; }
.skip-link:focus { top: calc(0.5rem + env(safe-area-inset-top, 0px)); }

/* Vibrant background glow — fixed layer, no scrim over it */
.glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40rem 30rem at 8% 0%, var(--glow-1), transparent 62%),
    radial-gradient(36rem 28rem at 95% 12%, var(--glow-2), transparent 60%),
    radial-gradient(44rem 30rem at 55% 105%, var(--glow-3), transparent 62%);
}

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bar-solid);
  border-bottom: 0.0625rem solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .bar { background: var(--bar-glass); -webkit-backdrop-filter: blur(1rem) saturate(1.3); backdrop-filter: blur(1rem) saturate(1.3); }
}
.bar__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 1.25rem; padding: 0.625rem var(--pad-x); }
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); text-decoration: none; font-family: var(--heading); font-weight: 700; font-size: 1.125rem; }
.brand img { width: 1.75rem; height: 1.75rem; }
.brand__sub { background: linear-gradient(90deg, var(--indigo-soft), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="light"] .brand__sub { background: none; color: #7c3aed; }
.bar__nav { display: flex; gap: 1rem; }
.bar__nav a { color: var(--ink-soft); text-decoration: none; font-weight: 600; padding: 0.375rem 0.25rem; border-bottom: 0.125rem solid transparent; }
.bar__nav a[aria-current="page"], .bar__nav a:hover { color: var(--ink); border-bottom-color: var(--purple); }

.prefs { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem; }
.size-group { display: inline-flex; padding: 0.125rem; border-radius: 999rem; border: 0.0625rem solid var(--line); background: var(--field); }
.size-btn { font: inherit; font-family: var(--heading); font-weight: 600; color: var(--ink-soft); background: transparent; border: 0; border-radius: 999rem; min-width: 2.25rem; min-height: 2.25rem; padding: 0 0.5rem; cursor: pointer; line-height: 1; }
.size-btn--sm { font-size: 0.8125rem; }
.size-btn--md { font-size: 0.9375rem; }
.size-btn--lg { font-size: 1.0625rem; }
.size-btn--xl { font-size: 1.25rem; }
.size-btn[aria-pressed="true"] { background: linear-gradient(135deg, var(--indigo), var(--purple)); color: #fff; }
.theme-btn { font: inherit; font-weight: 600; font-size: 0.9375rem; color: var(--ink); display: inline-flex; align-items: center; gap: 0.375rem; min-height: 2.5rem; padding: 0 0.875rem; border-radius: 999rem; cursor: pointer; background: var(--field); border: 0.0625rem solid var(--line); }
.theme-btn svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn__moon { fill: currentColor; stroke: none; }
.theme-btn__sun { display: none; }
html[data-theme="dark"] .theme-btn__moon { display: none; }
html[data-theme="dark"] .theme-btn__sun { display: inline; }

/* Board: four panels */
.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 1rem var(--pad-x) 1.5rem; align-items: start; }

.panel {
  position: relative; min-width: 0; overflow: hidden;
  background: var(--panel-solid);
  border: 0.0625rem solid var(--line);
  border-radius: 1.125rem;
  padding: 1.25rem 1.125rem 1.25rem;
  box-shadow: 0 1.25rem 3rem rgba(8, 5, 30, 0.35);
}
html[data-theme="light"] .panel { box-shadow: 0 1rem 2.5rem rgba(76, 29, 149, 0.12); }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .panel { background: var(--panel-glass); -webkit-backdrop-filter: blur(1.125rem) saturate(1.35); backdrop-filter: blur(1.125rem) saturate(1.35); }
}
.panel::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.25rem; }
.panel--chat::before { background: linear-gradient(90deg, #6366f1, #a855f7); }
.panel--top::before { background: linear-gradient(90deg, #a855f7, #f472b6); }
.panel--short::before { background: linear-gradient(90deg, #f472b6, #818cf8); }
.panel--details::before { background: linear-gradient(90deg, #818cf8, #c084fc); }

.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem 1rem; margin-bottom: 0.875rem; }
.panel__head h1, .panel__head h2 { font-size: 1.25rem; }
.panel__body { display: grid; gap: 0.75rem; }
.empty { color: var(--ink-soft); font-size: 0.9375rem; }

.link-btn { font: inherit; font-size: 0.875rem; font-weight: 600; color: var(--ink-soft); background: transparent; border: 0.0625rem solid var(--line); border-radius: 999rem; padding: 0.375rem 0.875rem; min-height: 2.25rem; cursor: pointer; }
.link-btn:hover { color: var(--ink); border-color: var(--purple-soft); }

/* Chat log */
.log {
  display: flex; flex-direction: column; gap: 0.75rem;
  min-height: 14rem; max-height: 60vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 0.25rem 0.125rem 0.5rem; text-align: left;
}
.msg { max-width: 92%; padding: 0.75rem 0.9375rem; border-radius: 1rem; display: grid; gap: 0.5rem; min-width: 0; }
.msg p { white-space: pre-line; }
.msg ul, .msg ol { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.25rem; }
.msg--bot { align-self: flex-start; background: var(--bubble-bot); border: 0.0625rem solid var(--line); border-bottom-left-radius: 0.375rem; }
.msg--user { align-self: flex-end; background: var(--bubble-user); color: var(--bubble-user-ink); border-bottom-right-radius: 0.375rem; }
.msg--notice { align-self: stretch; max-width: 100%; background: transparent; border: 0.0625rem dashed var(--warn); color: var(--ink); font-size: 0.9375rem; }
.msg--notice strong { color: var(--warn); }
.typing { align-self: flex-start; display: inline-flex; gap: 0.3rem; padding: 0.875rem 1rem; border-radius: 1rem; background: var(--bubble-bot); border: 0.0625rem solid var(--line); }
.typing span { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--purple-soft); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-0.15rem); } }

/* Composer */
.composer { margin-top: 0.75rem; display: grid; gap: 0.5rem; text-align: left; }
.composer__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.composer__input {
  width: 100%; font: inherit; color: var(--ink); background: var(--field);
  border: 0.0625rem solid var(--line); border-radius: 0.875rem; padding: 0.75rem 0.875rem; min-height: 5.5rem; resize: vertical;
}
.composer__input::placeholder { color: var(--ink-soft); opacity: 0.85; }
.composer__input:focus { outline: none; border-color: var(--purple-soft); box-shadow: 0 0 0 0.1875rem rgba(168, 85, 247, 0.35); }
.composer__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.composer__status { color: var(--ink-soft); font-size: 0.875rem; flex: 1 1 10rem; min-width: 0; }
.send-btn { font: inherit; font-weight: 700; color: #fff; border: 0; border-radius: 999rem; min-height: 2.75rem; padding: 0 1.5rem; cursor: pointer; background: linear-gradient(135deg, #6366f1, #a855f7 60%, #f472b6); }
.send-btn:disabled { opacity: 0.55; cursor: progress; }

/* Top match */
.top__title { font-size: 1.375rem; }
.top__score { display: inline-flex; align-items: baseline; justify-content: center; gap: 0.25rem; font-family: var(--heading); font-weight: 700; }
.top__score b { font-size: 2.25rem; background: linear-gradient(90deg, var(--indigo-soft), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-theme="light"] .top__score b { background: none; color: #6d28d9; }
.top__why { color: var(--ink-soft); }
.pill-link { display: inline-flex; align-items: center; justify-content: center; min-height: 2.5rem; padding: 0 1rem; border-radius: 999rem; border: 0.0625rem solid var(--purple-soft); text-decoration: none; font-weight: 600; }

/* Gauge */
.gauge { position: relative; width: 9rem; height: 9rem; margin: 0 auto 1rem; }
.gauge__svg { width: 100%; height: 100%; display: block; }
.gauge__track { fill: none; stroke: var(--line); stroke-width: 12; }
.gauge__value { fill: none; stroke: url(#gauge-grad); stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray 0.5s ease; }
.gauge__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge__num { font-family: var(--heading); font-weight: 700; font-size: 2rem; line-height: 1; }
.gauge__cap { font-size: 0.75rem; color: var(--ink-soft); }

.short-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.short-item { width: 100%; font: inherit; color: var(--ink); text-align: left; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; align-items: center; padding: 0.625rem 0.75rem; border-radius: 0.75rem; background: var(--field); border: 0.0625rem solid var(--line); }
.short-item[aria-pressed="true"] { border-color: var(--purple-soft); box-shadow: 0 0 0 0.125rem rgba(192, 132, 252, 0.35); }
.short-item__title { font-weight: 600; min-width: 0; }
.short-item__score { font-family: var(--heading); font-weight: 700; color: var(--purple-soft); }
html[data-theme="light"] .short-item__score { color: #6d28d9; }

/* Details */
.details-title { font-size: 1.125rem; }
.dl { margin: 0; display: grid; gap: 0.625rem; text-align: center; }
.dl__row { display: grid; gap: 0.125rem; padding-bottom: 0.625rem; border-bottom: 0.0625rem solid var(--line); }
.dl__row:last-child { border-bottom: 0; padding-bottom: 0; }
.dl dt { font-size: 0.8125rem; font-weight: 700; color: var(--ink-soft); }
.dl dd { margin: 0; }

.foot { padding: 0.5rem var(--pad-x) calc(1.5rem + env(safe-area-inset-bottom, 0px)); color: var(--ink-soft); font-size: 0.875rem; }
.foot p { max-width: 60rem; margin: 0 auto; }

/* Tablet: chat full width, then two panels, details full width */
@media (min-width: 48em) {
  .bar__inner { justify-content: space-between; }
  .bar__nav { margin-right: auto; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel--chat, .panel--details { grid-column: 1 / -1; }
  .panel__head { justify-content: space-between; }
  .log { max-height: 55vh; }
  .dl { text-align: left; }
  .dl__row { grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: 1rem; }
  .foot p { margin: 0; }
  body { text-align: left; }
  .panel__body { justify-items: start; }
  .top__score { justify-content: flex-start; }
}

/* Desktop: the four-card row */
@media (min-width: 75em) {
  .board { grid-template-columns: minmax(0, 1.75fr) repeat(3, minmax(0, 1fr)); }
  .panel--chat, .panel--details { grid-column: auto; }
  .panel--chat { display: flex; flex-direction: column; height: calc(100vh - 7.5rem); min-height: 34rem; }
  .log { flex: 1 1 auto; max-height: none; min-height: 0; }
  .dl__row { grid-template-columns: minmax(0, 1fr); gap: 0.125rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
