/* Tokens follow the Portrai design system (Beginner persona, Section 3.2/3.3/3.4). */
:root {
  --color-background: oklch(1 0 0);
  --color-foreground: oklch(0.145 0 0);
  --color-card: oklch(1 0 0);
  --color-popover: oklch(1 0 0);
  --color-popover-foreground: oklch(0.145 0 0);
  --color-primary: oklch(0.635 0.158 245.333);
  --color-primary-foreground: oklch(0.985 0 0);
  --color-secondary: oklch(0.97 0 0);
  --color-muted: oklch(0.97 0 0);
  --color-muted-foreground: oklch(0.556 0 0);
  --color-accent: oklch(0.97 0 0);
  --color-border: oklch(0.922 0 0);
  --color-input: oklch(0.922 0 0);
  --color-ring: oklch(0.708 0 0);
  --color-primary-subtle: color-mix(in oklch, var(--color-primary) 12%, transparent);
  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --shadow-sm: 0 1px 3px 0 hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1);
  --shadow-md: 0 4px 6px -1px hsl(0 0% 0% / 0.1), 0 2px 4px -2px hsl(0 0% 0% / 0.1);
  --font-sans: "Pretendard Variable", Pretendard, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --color-background: oklch(0.145 0 0);
  --color-foreground: oklch(0.985 0 0);
  --color-card: oklch(0.205 0 0);
  --color-popover: oklch(0.269 0 0);
  --color-popover-foreground: oklch(0.985 0 0);
  --color-primary-foreground: oklch(0.141 0.005 285.823);
  --color-secondary: oklch(0.269 0 0);
  --color-muted: oklch(0.269 0 0);
  --color-muted-foreground: oklch(0.708 0 0);
  --color-accent: oklch(0.371 0 0);
  --color-border: oklch(0.275 0 0);
  --color-input: oklch(0.325 0 0);
  --color-ring: oklch(0.556 0 0);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--color-background); color: var(--color-foreground);
  font-family: var(--font-sans); font-size: 1rem; line-height: 1.625;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--color-primary); }
.muted { color: var(--color-muted-foreground); }
:focus-visible { outline: 3px solid color-mix(in oklch, var(--color-primary) 50%, transparent); outline-offset: 2px; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 clamp(16px, 4vw, 40px);
  background: color-mix(in oklch, var(--color-background) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--color-foreground); text-decoration: none; white-space: nowrap; }
.brand .logo { height: 18px; width: auto; display: block; }
.brand span { padding-left: 10px; border-left: 1px solid var(--color-border); }
:root[data-theme="dark"] .logo-light, :root:not([data-theme="dark"]) .logo-dark { display: none; }
.toc { display: flex; gap: 4px; margin-left: auto; }
.toc a { color: var(--color-muted-foreground); text-decoration: none; font-size: 0.875rem; padding: 6px 10px; border-radius: var(--radius-md); white-space: nowrap; transition: background-color .15s, color .15s; }
.toc a:hover, .toc a.active { background: var(--color-accent); color: var(--color-foreground); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: transparent; color: var(--color-foreground); cursor: pointer; flex: none; transition: background-color .15s; }
.icon-btn:hover { background: var(--color-accent); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
:root[data-theme="dark"] .i-moon, :root:not([data-theme="dark"]) .i-sun { display: none; }

/* ---------------------------------------------------------------- layout */
main { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
/* hero: full-bleed, always on the dark palette so the moving backdrop reads the same in both themes */
.hero {
  --color-foreground: oklch(0.985 0 0);
  --color-muted-foreground: oklch(0.708 0 0);
  --color-primary-foreground: oklch(0.141 0.005 285.823);
  --color-accent: oklch(0.371 0 0);
  --color-border: oklch(0.275 0 0);
  position: relative; isolation: isolate; overflow: hidden;
  min-height: calc(100dvh - 56px); display: flex; align-items: center;
  background: oklch(0.145 0 0); color: var(--color-foreground);
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.hero-scrim { position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(90deg, hsl(0 0% 0% / 0.82) 0%, hsl(0 0% 0% / 0.55) 45%, hsl(0 0% 0% / 0.25) 100%),
    linear-gradient(0deg, oklch(0.145 0 0) 0%, transparent 22%); }
.hero-inner { width: 100%; max-width: 1200px; margin: 0 auto; padding: 64px clamp(16px, 4vw, 40px) 96px; }
.hero-logo { display: block; height: 28px; width: auto; margin-bottom: 24px; }
.hero h1 { font-size: clamp(3rem, 8vw, 4.5rem); line-height: 1.05; font-weight: 700; letter-spacing: -0.03em; margin: 0 0 12px; }
.hero-tag { font-size: clamp(1.25rem, 2.4vw, 1.875rem); line-height: 1.3; font-weight: 500; margin: 0 0 20px; max-width: 22em; }
.hero .lede { color: var(--color-muted-foreground); font-size: 1.0625rem; margin: 0 0 32px; max-width: 32em; }
.hero-caption { position: absolute; left: 0; right: 0; bottom: 20px; max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); font-size: 0.8125rem; color: var(--color-muted-foreground); transition: opacity .3s; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; height: 40px; padding: 0 24px; border-radius: var(--radius-md); font: 500 0.875rem var(--font-sans); text-decoration: none; cursor: pointer; transition: background-color .15s; }
.btn.primary { background: var(--color-primary); color: var(--color-primary-foreground); border: 1px solid transparent; }
.btn.primary:hover { background: color-mix(in oklch, var(--color-primary) 90%, transparent); }
.btn.ghost { color: var(--color-foreground); border: 1px solid var(--color-border); background: hsl(0 0% 0% / 0.3); backdrop-filter: blur(4px); }
.btn.ghost:hover { background: var(--color-accent); }

.chapter { padding: 64px 0 16px; }
.chapter h2 { font-size: 1.5rem; line-height: 1.25; font-weight: 600; margin: 0 0 8px; }
.intro { color: var(--color-muted-foreground); max-width: 46em; margin: 0 0 24px; }

/* ---------------------------------------------------------------- start cards */
.start-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.start-card { display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--color-border); border-radius: var(--radius-xl); background: var(--color-card); color: var(--color-foreground); text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color .15s; }
.start-card:hover { border-color: var(--color-primary); }
.start-card h3 { margin: 0 0 4px; font-size: 1.125rem; font-weight: 600; }
.start-card p { margin: 0 0 12px; font-size: 0.875rem; }
.start-card ul { margin: 0 0 16px; padding-left: 18px; font-size: 0.9375rem; flex: 1; }
.start-card li { margin: 4px 0; }
.start-card .go { font-size: 0.875rem; font-weight: 500; color: var(--color-primary); }

/* ---------------------------------------------------------------- panels & controls */
.panel { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: 16px; box-shadow: var(--shadow-sm); }
.controls { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-bottom: 16px; }
.ctl-label { display: block; font-size: 0.75rem; color: var(--color-muted-foreground); margin-bottom: 6px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--color-muted); border-radius: var(--radius-lg); }
.seg.wrap { display: flex; }
.seg button { min-height: 36px; border: 0; background: transparent; color: var(--color-muted-foreground); font: 500 0.875rem var(--font-sans); padding: 0 12px; border-radius: var(--radius-md); cursor: pointer; transition: background-color .15s, color .15s; }
.seg button:hover { color: var(--color-foreground); }
.seg button.on { background: var(--color-background); color: var(--color-foreground); box-shadow: var(--shadow-sm); }
.viewer-row { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; align-items: start; }
.sub { margin: 12px 0 0; font-size: 0.875rem; }
.side { font-size: 0.875rem; }
.side p { margin: 0 0 12px; color: var(--color-muted-foreground); }

.legend { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.legend button { display: flex; align-items: center; gap: 8px; min-height: 32px; border: 0; background: transparent; color: var(--color-foreground); font: 0.875rem var(--font-sans); padding: 0 8px; border-radius: var(--radius-md); cursor: pointer; text-align: left; transition: background-color .15s, opacity .15s; }
.legend button:hover { background: var(--color-accent); }
.legend button.dim { opacity: 0.4; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px hsl(0 0% 0% / 0.3); }
.legend .n { margin-left: auto; color: var(--color-muted-foreground); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.ramp { height: 10px; border-radius: 5px; margin: 4px 0; }
.ramp-l { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--color-muted-foreground); margin-bottom: 12px; }

.range-row { display: flex; align-items: center; gap: 12px; margin: 4px 0; font-size: 0.875rem; flex-wrap: wrap; }
.range-row > span { min-width: 110px; color: var(--color-muted-foreground); }
.range-row input[type=range] { flex: 1; min-width: 140px; accent-color: var(--color-primary); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { min-height: 32px; font: 0.8125rem var(--font-mono); border: 1px solid var(--color-border); background: transparent; color: var(--color-foreground); border-radius: var(--radius-sm); padding: 0 10px; cursor: pointer; transition: background-color .15s, border-color .15s; }
.chips button:hover { background: var(--color-accent); }
.chips button.on { background: var(--color-primary-subtle); border-color: var(--color-primary); }

/* ---------------------------------------------------------------- compare slider */
.compare { position: relative; width: 100%; max-height: 76vh; border-radius: var(--radius-lg); overflow: hidden; background: var(--color-muted); user-select: none; touch-action: pan-y; cursor: ew-resize; aspect-ratio: 4 / 3; }
.compare .layer { position: absolute; inset: 0; overflow: hidden; }
.compare .stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.compare .stage > img, .compare .stage > canvas { display: block; width: 100%; height: 100%; }
.compare .after { clip-path: inset(0 0 0 var(--split, 50%)); }
.compare .handle { position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 0; z-index: 5; pointer-events: none; }
.compare .handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: oklch(1 0 0); box-shadow: 0 0 8px hsl(0 0% 0% / 0.4); }
.compare .knob { position: absolute; top: 50%; left: 0; width: 44px; height: 44px; transform: translate(-50%, -50%); border-radius: 50%; background: oklch(1 0 0); box-shadow: var(--shadow-md); display: grid; place-items: center; pointer-events: auto; cursor: ew-resize; }
.compare .knob svg { width: 20px; height: 20px; fill: none; stroke: oklch(0.205 0 0); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.compare .lab { position: absolute; top: 8px; z-index: 4; font-size: 0.75rem; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-sm); background: hsl(0 0% 0% / 0.6); color: oklch(0.985 0 0); pointer-events: none; transition: opacity .15s; }
.compare .lab.l { left: 8px; }
.compare .lab.r { right: 8px; }
.compare .zoom-ctl { position: absolute; right: 8px; bottom: 8px; z-index: 6; display: flex; flex-direction: column; gap: 4px; }
.compare .zoom-ctl button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius-md); border: 0; background: hsl(0 0% 0% / 0.6); color: oklch(0.985 0 0); cursor: pointer; transition: background-color .15s; }
.compare .zoom-ctl button:hover { background: hsl(0 0% 0% / 0.8); }
.compare .zoom-ctl svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; pointer-events: none; }

/* ---------------------------------------------------------------- tooltip */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--color-popover); color: var(--color-popover-foreground); border: 1px solid var(--color-border); font-size: 0.8125rem; line-height: 1.5; padding: 8px 10px; border-radius: var(--radius-md); max-width: 280px; opacity: 0; transition: opacity .1s; box-shadow: var(--shadow-md); }
.tip.show { opacity: 1; }
.tip .g { font-family: var(--font-mono); font-size: 0.75rem; color: var(--color-muted-foreground); }
.tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

/* ---------------------------------------------------------------- chat */
.chat { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.questions { display: flex; flex-direction: column; gap: 6px; }
.qgroup { font-size: 0.75rem; color: var(--color-muted-foreground); margin: 12px 0 2px; }
.qgroup:first-child { margin-top: 0; }
.q { display: flex; gap: 10px; align-items: center; text-align: left; min-height: 44px; padding: 8px 12px; border: 1px solid var(--color-border); background: var(--color-card); color: var(--color-foreground); border-radius: var(--radius-lg); font: 0.875rem/1.4 var(--font-sans); cursor: pointer; transition: background-color .15s, border-color .15s; }
.q:hover { background: var(--color-accent); }
.q.on { border-color: var(--color-primary); }
.q img { width: 36px; height: 36px; border-radius: var(--radius-sm); flex: none; object-fit: cover; }
.convo { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: 20px; min-height: 440px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-sm); }
.msg { max-width: 88%; padding: 12px 14px; border-radius: var(--radius-xl); font-size: 0.9375rem; }
.msg.user { align-self: flex-end; background: var(--color-primary-subtle); }
.msg.bot { align-self: flex-start; background: var(--color-muted); }
.msg .who { display: block; font-size: 0.75rem; color: var(--color-muted-foreground); margin-bottom: 4px; }
.msg img { display: block; width: 180px; height: 180px; object-fit: cover; border-radius: var(--radius-md); margin-top: 8px; }
.msg p { margin: 0; }
.msg .note { margin-top: 8px; font-size: 0.8125rem; color: var(--color-muted-foreground); }
.genes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.genes span { font: 0.8125rem var(--font-mono); padding: 2px 8px; border-radius: var(--radius-sm); background: var(--color-background); border: 1px solid var(--color-border); }
.genes span.hit { border-color: var(--color-primary); }
.typing::after { content: ""; display: inline-block; width: 6px; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--color-muted-foreground); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.empty { margin: auto; text-align: center; color: var(--color-muted-foreground); font-size: 0.9375rem; }
.fade-in { animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- compare bars */
.bench { display: grid; gap: 6px; margin-top: 16px; }
.brow { display: grid; grid-template-columns: 180px 1fr 56px; gap: 12px; align-items: center; font-size: 0.875rem; }
.brow .bn { color: var(--color-muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow .bt { height: 16px; background: var(--color-muted); border-radius: var(--radius-sm); position: relative; overflow: hidden; }
.brow .bt i { position: absolute; inset: 0; transform-origin: 0 0; background: var(--color-ring); border-radius: var(--radius-sm); transition: transform .3s ease-out; }
.brow .bv { font-size: 0.8125rem; text-align: right; color: var(--color-muted-foreground); font-variant-numeric: tabular-nums; }
.brow.me .bn { color: var(--color-foreground); font-weight: 600; }
.brow.me .bt i { background: var(--color-primary); }
.brow.me .bv { color: var(--color-foreground); }

/* ---------------------------------------------------------------- end */
.limits { margin: 0 0 24px; padding-left: 20px; color: var(--color-muted-foreground); max-width: 50em; }
.limits li { margin: 6px 0; }
.cite { font-size: 0.875rem; color: var(--color-muted-foreground); max-width: 50em; }
.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 48px; padding: 24px clamp(16px, 4vw, 40px); border-top: 1px solid var(--color-border); color: var(--color-muted-foreground); font-size: 0.875rem; }

@media (max-width: 960px) {
  .hero-scrim { background: linear-gradient(0deg, oklch(0.145 0 0) 0%, hsl(0 0% 0% / 0.55) 30%, hsl(0 0% 0% / 0.6) 100%); }
  .start-grid { grid-template-columns: 1fr; }
  .viewer-row, .chat { grid-template-columns: 1fr; }
  .toc { display: none; }
  .icon-btn { margin-left: auto; }
}
@media (max-width: 560px) {
  .brow { grid-template-columns: 112px 1fr 48px; font-size: 0.8125rem; }
  .msg { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
