:root {
  color-scheme: light;
  --ink: #15171c;
  --muted: #686b75;
  --paper: #f6f5f2;
  --card: #ffffff;
  --line: #deddd9;
  --red: #e8341c;
  --red-dark: #b92412;
  --green: #137a4a;
  --green-bg: #e9f7ef;
  --red-bg: #fff0ed;
  --shadow: 0 22px 60px rgba(19, 21, 26, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 76px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 245, 242, .92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 10px; background: var(--red); color: white; font-weight: 800;
  transform: rotate(-4deg);
}
.brand > span:last-child { display: flex; align-items: baseline; gap: 8px; }
.brand strong { font-size: 1.15rem; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.source-link { font-size: .86rem; color: var(--muted); text-decoration: none; }
.source-link:hover { color: var(--ink); }

.layout {
  width: min(1420px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}
.rail {
  padding: 54px 36px 48px clamp(24px, 4vw, 64px);
  border-right: 1px solid var(--line);
  background: linear-gradient(155deg, #eceae4 0%, #f6f5f2 58%);
}
.rail-head { margin-bottom: 34px; }
.eyebrow { margin: 0 0 8px; color: var(--red-dark); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.rail h1 { margin: 0 0 18px; font-size: clamp(2rem, 3vw, 3.35rem); line-height: 1.07; letter-spacing: -.055em; }
.rail-head > p:last-child { margin: 0; color: var(--muted); font-size: .92rem; }
.domain-nav { display: grid; gap: 8px; }
.domain-button {
  width: 100%; padding: 13px 14px; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--muted); text-align: left; cursor: pointer;
}
.domain-button:hover { background: rgba(255,255,255,.6); color: var(--ink); }
.domain-button.active { background: var(--ink); color: white; box-shadow: 0 10px 24px rgba(20,22,27,.12); }
.domain-index { font-variant-numeric: tabular-nums; font-size: .78rem; font-weight: 800; opacity: .62; }
.domain-name { font-size: .88rem; font-weight: 750; line-height: 1.35; }
.domain-count { font-size: .75rem; opacity: .62; }
.rail-note { margin-top: 32px; padding: 18px; border-left: 3px solid var(--red); background: rgba(255,255,255,.65); }
.rail-note strong { font-size: .86rem; }
.rail-note p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.55; }

.workspace { padding: 54px clamp(24px, 6vw, 88px) 36px; min-width: 0; }
.workspace-head { display: flex; justify-content: space-between; gap: 24px; align-items: end; max-width: 850px; }
.workspace-head h2 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.25rem); letter-spacing: -.04em; line-height: 1.2; }
.score-chip { min-width: 112px; display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 99px; background: #fff; }
.score-chip span { color: var(--muted); font-size: .76rem; font-weight: 700; }
.score-chip strong { font-size: 1.35rem; }
.progress-track { height: 4px; max-width: 850px; margin: 24px 0 28px; border-radius: 99px; background: #e3e1dc; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--red); transition: width .35s ease; }

.quiz-card { max-width: 850px; padding: clamp(24px, 4.5vw, 52px); border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.question-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.number-badge { min-width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--ink); color: white; font-size: .88rem; font-weight: 850; }
.subdomain { color: var(--muted); font-size: .82rem; font-weight: 700; }
.quiz-card h3 { margin: 0 0 28px; font-size: clamp(1.18rem, 2vw, 1.55rem); line-height: 1.6; letter-spacing: -.018em; }
.quiz-card code, .feedback code { padding: .12em .38em; border-radius: 5px; background: #f0efeb; color: #ad2616; font-family: "SFMono-Regular", Consolas, monospace; font-size: .88em; overflow-wrap: anywhere; }
.options { display: grid; gap: 11px; }
.option {
  position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: #fcfcfb; cursor: pointer; transition: border-color .18s, transform .18s, background .18s;
}
.option:hover { border-color: #aaa8a1; transform: translateY(-1px); }
.option:has(input:focus-visible) { outline: 3px solid rgba(232,52,28,.22); outline-offset: 2px; }
.option:has(input:checked) { border-color: var(--ink); background: #f1f0ed; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option-letter { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #e9e7e2; font-size: .8rem; font-weight: 850; }
.option-text { line-height: 1.58; }
.option.correct { border-color: var(--green); background: var(--green-bg); }
.option.correct .option-letter { background: var(--green); color: white; }
.option.wrong { border-color: var(--red); background: var(--red-bg); }
.option.wrong .option-letter { background: var(--red); color: white; }
.option.locked { cursor: default; transform: none; }
.feedback { margin-top: 22px; padding: 18px 20px; border-radius: 14px; background: #f1f0ed; }
.feedback.success { background: var(--green-bg); }
.feedback.error { background: var(--red-bg); }
.feedback-title { display: flex; align-items: center; gap: 8px; }
.feedback-title span { font-size: 1.2rem; }
.feedback p { margin: 8px 0 0; color: #45474f; }
.card-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.button { min-height: 44px; padding: 0 18px; border: 0; border-radius: 11px; font-weight: 800; cursor: pointer; }
.button:focus-visible, .source-link:focus-visible, .domain-button:focus-visible { outline: 3px solid rgba(232,52,28,.25); outline-offset: 3px; }
.button:disabled { opacity: .35; cursor: not-allowed; }
.button-primary { background: var(--red); color: white; }
.button-primary:hover:not(:disabled) { background: var(--red-dark); }
.button-dark { background: var(--ink); color: white; }
.button-dark:hover { background: #30333a; }
.button-ghost { background: transparent; color: var(--muted); }
.button-ghost:hover { background: #e8e6e1; color: var(--ink); }

.result-card { max-width: 850px; padding: clamp(28px, 5vw, 58px); border-radius: 22px; background: var(--ink); color: white; box-shadow: var(--shadow); }
.result-card .eyebrow { color: #ff7f6d; }
.result-score { display: flex; align-items: baseline; gap: 6px; }
.result-score strong { font-size: clamp(4rem, 10vw, 7.5rem); line-height: 1; letter-spacing: -.07em; }
.result-score span { color: #aeb1ba; font-size: 1.2rem; }
.result-card h2 { margin: 18px 0 8px; font-size: 1.65rem; }
.result-card > p:not(.eyebrow) { color: #c7c9d0; }
.breakdown { display: grid; gap: 9px; margin: 30px 0; }
.breakdown-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; padding: 10px 0; border-bottom: 1px solid #33363e; font-size: .88rem; }
.breakdown-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 800; }
footer { max-width: 850px; margin-top: 30px; color: var(--muted); font-size: .76rem; }
footer a { text-underline-offset: 3px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .rail { padding: 28px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-head h1 { font-size: 2.15rem; }
  .rail-head h1 br { display: none; }
  .rail-head { margin-bottom: 18px; }
  .domain-nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .rail-note { display: none; }
  .workspace { padding: 30px 20px; }
}

@media (max-width: 560px) {
  .topbar { height: 66px; padding: 0 16px; }
  .brand small, .source-link { display: none; }
  .domain-nav { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 4px; scrollbar-width: thin; }
  .domain-button { min-width: 205px; }
  .workspace-head { align-items: center; }
  .score-chip { min-width: 90px; padding: 9px 11px; }
  .quiz-card { padding: 22px 17px; border-radius: 16px; }
  .quiz-card h3 { font-size: 1.08rem; }
  .option { padding: 14px 13px; }
  .card-actions { flex-direction: column; }
  .card-actions .button { width: 100%; }
}

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