:root {
  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --good: #1d8f4e;
  --bad: #d70015;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.06);
  --nav-bg: rgba(255, 255, 255, 0.72);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-2: #161617;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #86868b;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #2997ff;
    --accent-soft: rgba(41, 151, 255, 0.14);
    --good: #30d158;
    --bad: #ff453a;
    --shadow: none;
    --nav-bg: rgba(22, 22, 23, 0.72);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-2: #161617;
  --card: #1c1c1e;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #86868b;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.14);
  --good: #30d158;
  --bad: #ff453a;
  --shadow: none;
  --nav-bg: rgba(22, 22, 23, 0.72);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1024px; margin: 0 auto; height: 48px;
  display: flex; align-items: center; gap: 24px; padding: 0 22px;
}
.brand { font-weight: 600; font-size: 17px; color: var(--text); white-space: nowrap; }
.nav-links { display: flex; gap: 22px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { font-size: 12px; color: var(--text-2); white-space: nowrap; transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.icon-btn {
  background: none; border: 0; cursor: pointer; color: var(--text-2);
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
}
.icon-btn:hover { color: var(--text); background: var(--bg-2); }

main { max-width: 1024px; margin: 0 auto; padding: 0 22px 120px; }
.view { animation: fade .45s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Type */
.eyebrow { font-size: 14px; font-weight: 600; color: var(--text-3); margin-bottom: 6px; }
.hero { padding: 96px 0 56px; text-align: center; }
.hero h1 { font-size: clamp(44px, 8vw, 80px); line-height: 1.05; letter-spacing: -0.04em; font-weight: 700; }
.hero p { font-size: clamp(19px, 2.4vw, 24px); color: var(--text-2); max-width: 640px; margin: 18px auto 0; line-height: 1.35; }
.page-head { padding: 64px 0 32px; }
.page-head h1 { font-size: clamp(36px, 6vw, 56px); letter-spacing: -0.035em; line-height: 1.08; font-weight: 700; }
.page-head p { color: var(--text-2); font-size: 21px; margin-top: 10px; max-width: 640px; line-height: 1.38; }
h2 { font-size: 28px; letter-spacing: -0.03em; line-height: 1.15; font-weight: 600; }
h3 { font-size: 19px; letter-spacing: -0.02em; font-weight: 600; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.section { margin-top: 56px; }
.section > h2 { margin-bottom: 18px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--accent); color: #fff; border: 0;
  padding: 11px 22px; border-radius: 980px; font-size: 15px; font-weight: 500;
  transition: opacity .2s, transform .1s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: var(--bg-2); color: var(--text); }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 15px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Cards / grid */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card {
  background: var(--bg-2); border-radius: var(--radius); padding: 28px;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s;
}
a.card, button.card { display: block; color: inherit; text-align: left; border: 0; cursor: pointer; width: 100%; }
a.card:hover, button.card:hover { transform: scale(1.012); box-shadow: var(--shadow); }
.card h3 { margin-bottom: 6px; }
.card p { color: var(--text-2); font-size: 15px; line-height: 1.45; }
.card .meta { font-size: 12px; color: var(--text-3); margin-bottom: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; }
.card .more { margin-top: 16px; font-size: 15px; color: var(--accent); }
.tile-icon { font-size: 28px; margin-bottom: 18px; display: block; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }

/* Segmented control */
.segmented {
  display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 2px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented button {
  border: 0; background: none; padding: 7px 16px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text-2); white-space: nowrap; transition: all .2s;
}
.segmented button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); font-weight: 500; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: none; border-radius: 980px;
  padding: 6px 14px; font-size: 14px; cursor: pointer; color: var(--text-2);
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 980px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.tag.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.tag.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }

/* Inputs */
.field { display: block; margin-bottom: 18px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.input, textarea.input, select.input {
  width: 100%; background: var(--bg-2); border: 1px solid transparent; border-radius: 12px;
  padding: 12px 14px; font-size: 16px; outline: none; transition: border .2s, background .2s;
}
.input:focus { border-color: var(--accent); background: var(--card); }
textarea.input { min-height: 180px; resize: vertical; line-height: 1.5; }
.search { padding-left: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5.5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 14px center; }

/* Sliders */
.slider { margin-bottom: 20px; }
.slider-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.slider-top span:first-child { color: var(--text-2); }
.slider-top output { font-variant-numeric: tabular-nums; font-weight: 600; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 2px; background: var(--line); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; }

/* Lab layout */
.lab { display: grid; grid-template-columns: 320px 1fr; gap: 24px; margin-top: 28px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--bg-2); border-radius: 14px; padding: 18px; }
.stat .k { font-size: 13px; color: var(--text-2); }
.stat .v { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.hl { background: var(--accent); color: #fff; }
.stat.hl .k { color: rgba(255,255,255,.8); }

table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-2); font-weight: 500; font-size: 13px; }
tr.total td { font-weight: 600; border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.note-line { font-size: 15px; color: var(--text-2); margin-top: 18px; line-height: 1.5; }

/* Lessons */
.lesson { padding: 40px 0; border-top: 1px solid var(--line); }
.lesson:first-of-type { border-top: 0; }
.lesson h2 { margin-bottom: 10px; }
.lesson .lead { font-size: 19px; color: var(--text-2); line-height: 1.45; max-width: 720px; }
.lesson ul { margin: 22px 0 0 0; list-style: none; display: grid; gap: 10px; max-width: 720px; }
.lesson li { padding-left: 22px; position: relative; }
.lesson li::before { content: ""; position: absolute; left: 4px; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.formula { font-family: var(--mono); font-size: 14px; background: var(--bg-2); border-radius: 12px; padding: 16px 18px; margin-top: 22px; line-height: 1.6; overflow-x: auto; }
.tip { margin-top: 18px; padding: 16px 18px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; max-width: 720px; }
.tip b { color: var(--accent); }

.back { display: inline-block; margin-top: 32px; font-size: 15px; }

/* Question detail */
.q-list { display: grid; gap: 10px; }
.q-item { display: block; background: var(--bg-2); border-radius: 14px; padding: 18px 22px; color: inherit; transition: background .2s; }
.q-item:hover { background: color-mix(in srgb, var(--bg-2) 80%, var(--text) 4%); }
.q-item .q { font-size: 17px; font-weight: 500; margin-top: 6px; line-height: 1.35; }
.q-item .sub { font-size: 13px; color: var(--text-3); }
.prose { font-size: 17px; line-height: 1.6; max-width: 720px; white-space: pre-wrap; }
.prose.md { white-space: normal; }
.md h1, .md h2, .md h3 { margin: 28px 0 10px; font-size: 21px; }
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0 10px 22px; }
.md li { margin: 4px 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--bg-2); padding: 2px 6px; border-radius: 6px; }
.md pre { background: var(--bg-2); padding: 14px; border-radius: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { margin: 14px 0; }
.script { font-size: 19px; line-height: 1.65; white-space: pre-wrap; max-width: 720px; }
.cue { color: var(--accent); font-style: italic; }
.timer { font-size: 56px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }

/* Flashcards */
.flash { perspective: 1000px; height: 220px; cursor: pointer; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.2,.8,.2,1); transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; justify-content: center; background: var(--bg-2); overflow: auto; }
.flash-face.back { transform: rotateY(180deg); background: var(--accent); color: #fff; }
.flash-face small { font-size: 12px; opacity: .6; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }

/* Score ring */
.ring { width: 160px; height: 160px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; font-weight: 600; letter-spacing: -0.04em; }
.split { display: grid; grid-template-columns: auto 1fr; gap: 40px; align-items: center; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 14px; min-height: 40vh; padding-bottom: 20px; }
.msg { max-width: 80%; padding: 12px 16px; border-radius: 20px; line-height: 1.5; font-size: 16px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: var(--bg-2); border-bottom-left-radius: 6px; }
.msg.ai > :first-child { margin-top: 0; }
.composer {
  position: sticky; bottom: 20px; display: flex; gap: 8px; align-items: flex-end;
  background: var(--nav-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: 26px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow);
}
.composer textarea { flex: 1; border: 0; background: none; resize: none; outline: none; padding: 9px 0; max-height: 160px; font-size: 16px; }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.send:disabled { opacity: .35; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); margin-right: 3px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Drop zone */
.drop { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 36px; text-align: center; color: var(--text-2); cursor: pointer; transition: all .2s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* Modal */
dialog { border: 0; border-radius: 22px; padding: 32px; max-width: 440px; width: calc(100% - 32px); background: var(--card); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.3); margin: auto; }
dialog::backdrop { background: rgba(0,0,0,.35); backdrop-filter: blur(4px); }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 980px; font-size: 14px; z-index: 100; animation: fade .3s; }

footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 40px 22px; border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .lab, .split { grid-template-columns: 1fr; }
  .nav-inner { gap: 14px; padding: 0 16px; }
  main { padding: 0 16px 100px; }
  .hero { padding: 64px 0 40px; }
  .page-head { padding: 40px 0 24px; }
  .card, .panel { padding: 22px; }
  .msg { max-width: 92%; }
  .ring { margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.adv { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 14px; }
.adv summary { cursor: pointer; font-size: 14px; color: var(--accent); list-style: none; }
.adv summary::-webkit-details-marker { display: none; }
.adv summary::after { content: " ›"; display: inline-block; transition: transform .2s; }
.adv[open] summary::after { transform: rotate(90deg); }
