:root {
  color-scheme: light;
  --bg: #f4f1e9;
  --surface: #fffdf8;
  --surface-2: #ebe7dc;
  --ink: #17211c;
  --muted: #66706a;
  --line: #d8d4c9;
  --accent: #e85d37;
  --accent-dark: #ba3e20;
  --green: #315c4b;
  --shadow: 0 18px 55px rgba(31, 43, 36, 0.08);
  --page-fold-light: rgba(255,255,255,.38);
  --page-fold-shadow: rgba(31,43,36,.22);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151a17;
  --surface: #1d2420;
  --surface-2: #272e2a;
  --ink: #f4f0e7;
  --muted: #a8b0aa;
  --line: #38413c;
  --green: #91c5ad;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.22);
  --page-fold-light: rgba(255,255,255,.1);
  --page-fold-shadow: rgba(0,0,0,.48);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  min-height: 70px;
  padding: 0 clamp(20px, 5vw, 72px);
}
.brand { align-items: center; color: var(--ink); display: flex; font-weight: 700; gap: 10px; text-decoration: none; }
.brand-mark { align-items: center; background: var(--ink); border-radius: 50%; color: var(--bg); display: flex; height: 32px; justify-content: center; width: 32px; }
nav { display: flex; gap: 28px; }
.nav-link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 24px 0 20px; }
.nav-link.active { border-bottom: 2px solid var(--accent); color: var(--ink); font-weight: 600; }
.theme-button { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; color: var(--ink); cursor: pointer; display: flex; font-size: .78rem; font-weight: 600; gap: 7px; justify-self: end; min-height: 38px; padding: 7px 12px; }
.theme-button:hover { border-color: var(--green); }
.theme-button #theme-icon { font-size: 1rem; line-height: 1; }
main { margin: auto; max-width: 1500px; padding: 0 clamp(20px, 5vw, 72px) 80px; }

.hero { align-items: end; display: grid; gap: 40px; grid-template-columns: 1fr auto; padding: 72px 0 48px; }
.eyebrow { color: var(--accent); font-family: "IBM Plex Mono", monospace; font-size: .72rem; font-weight: 500; letter-spacing: .13em; margin: 0 0 14px; }
h1 { font-size: clamp(2.5rem, 5vw, 5.5rem); letter-spacing: -.055em; line-height: .98; margin: 0; max-width: 920px; }
h1 em { color: var(--green); font-family: Georgia, serif; font-weight: 400; }
.hero-copy { color: var(--muted); font-size: 1.05rem; margin: 25px 0 0; max-width: 620px; }
.hero-stat { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 180px; padding: 10px 0 10px 30px; }
.hero-stat strong { font-family: Georgia, serif; font-size: 3.2rem; font-weight: 400; line-height: 1; }
.hero-stat span { color: var(--muted); font-size: .85rem; margin-top: 8px; }

.filters { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: grid; gap: 10px; grid-template-columns: minmax(220px, 1fr) repeat(3, auto) auto; padding: 10px; }
.filters select, .search-field { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; min-height: 44px; }
.filters select { color: var(--ink); cursor: pointer; min-width: 145px; padding: 0 34px 0 12px; }
.filters option { background: var(--surface); color: var(--ink); }
.search-field { align-items: center; display: flex; gap: 8px; padding: 0 12px; }
.search-field input { background: transparent; border: 0; color: var(--ink); min-width: 0; outline: none; width: 100%; }
.secondary-button, .primary-button { border: 0; border-radius: 9px; cursor: pointer; font-weight: 600; padding: 11px 16px; }
.secondary-button { background: var(--ink); color: var(--bg); white-space: nowrap; }
.primary-button { background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-dark); }
.results-line { color: var(--muted); font-size: .85rem; margin: 22px 0 10px; }

.practice-layout { align-items: start; display: grid; gap: 22px; grid-template-columns: 330px minmax(0, 1fr); }
.question-list { display: flex; flex-direction: column; gap: 7px; max-height: 760px; overflow: auto; padding-right: 5px; }
.question-item { background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer; padding: 15px; text-align: left; width: 100%; }
.question-item:hover { background: var(--surface); }
.question-item.active { background: var(--surface); border-color: var(--line); box-shadow: 0 6px 20px rgba(31,43,36,.05); }
.item-meta { color: var(--muted); display: flex; font-family: "IBM Plex Mono", monospace; font-size: .65rem; justify-content: space-between; letter-spacing: .06em; margin-bottom: 7px; text-transform: uppercase; }
.question-item strong { display: -webkit-box; font-size: .9rem; font-weight: 600; line-height: 1.35; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.status-dot { color: var(--accent); }

.question-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); min-height: 590px; padding: clamp(25px, 5vw, 60px); perspective: 1800px; position: relative; }
.question-card.page-turning { pointer-events: none; }
.page-flip-sheet { backface-visibility: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; inset: -1px; overflow: hidden; padding: clamp(25px, 5vw, 60px); position: absolute; transform-style: preserve-3d; will-change: transform; z-index: 20; }
.page-flip-sheet::after { content: ""; inset: 0; pointer-events: none; position: absolute; }
.page-flip-sheet.page-flip-next { animation: page-flip-next 760ms cubic-bezier(.32,.02,.18,1) both; border-right: 3px solid color-mix(in srgb, var(--line) 72%, var(--ink)); transform-origin: left center; }
.page-flip-sheet.page-flip-next::after { background: linear-gradient(90deg, var(--page-fold-shadow), transparent 16%, transparent 72%, var(--page-fold-light)); }
.page-flip-sheet.page-flip-previous { animation: page-flip-previous 760ms cubic-bezier(.32,.02,.18,1) both; border-left: 3px solid color-mix(in srgb, var(--line) 72%, var(--ink)); transform-origin: right center; }
.page-flip-sheet.page-flip-previous::after { background: linear-gradient(270deg, var(--page-fold-shadow), transparent 16%, transparent 72%, var(--page-fold-light)); }
@keyframes page-flip-next {
  0% { box-shadow: 2px 0 3px rgba(31,43,36,.08); transform: rotateY(0); }
  38% { box-shadow: 26px 8px 32px rgba(31,43,36,.22); }
  72% { box-shadow: 10px 5px 18px rgba(31,43,36,.15); }
  100% { box-shadow: 0 0 0 rgba(31,43,36,0); transform: rotateY(-180deg); }
}
@keyframes page-flip-previous {
  0% { box-shadow: -2px 0 3px rgba(31,43,36,.08); transform: rotateY(0); }
  38% { box-shadow: -26px 8px 32px rgba(31,43,36,.22); }
  72% { box-shadow: -10px 5px 18px rgba(31,43,36,.15); }
  100% { box-shadow: 0 0 0 rgba(31,43,36,0); transform: rotateY(180deg); }
}
.empty-state { color: var(--muted); padding: 120px 20px; text-align: center; }
.empty-state h2 { color: var(--ink); margin-bottom: 6px; }
.empty-icon { color: var(--accent); font-size: 3rem; }
.question-toolbar { align-items: start; display: flex; justify-content: space-between; }
.badges { display: flex; flex-wrap: wrap; gap: 7px; }
.badge { background: var(--surface-2); border-radius: 99px; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .05em; padding: 5px 9px; text-transform: uppercase; }
.badge.accent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.bookmark-button { background: transparent; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; font-size: 1.5rem; height: 42px; width: 42px; }
.bookmark-button.saved { background: var(--ink); color: var(--bg); }
.question-number { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: .72rem; letter-spacing: .08em; margin: 36px 0 8px; }
.question-card h2 { font-family: Georgia, serif; font-size: clamp(1.6rem, 3vw, 2.7rem); font-weight: 400; letter-spacing: -.025em; line-height: 1.1; margin: 0 0 20px; }
.question-card h2.question-text { font-size: clamp(1.65rem, 3vw, 2.75rem); line-height: 1.18; margin: 0; max-width: 950px; white-space: pre-line; }
.answer-block { border-top: 1px solid var(--line); margin-top: 40px; padding-top: 28px; }
.answer-heading { align-items: center; display: flex; justify-content: space-between; margin-bottom: 10px; }
.answer-heading label { font-weight: 700; }
.answer-heading span { color: var(--muted); font-size: .75rem; }
textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); line-height: 1.6; padding: 16px; resize: vertical; width: 100%; }
textarea:focus { border-color: var(--green); outline: 2px solid color-mix(in srgb, var(--green) 20%, transparent); }
.answer-actions { align-items: center; display: flex; gap: 18px; margin-top: 12px; }
.text-button { background: transparent; border: 0; color: var(--muted); cursor: pointer; }
.answer-reveal-actions { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 16px; margin-top: 38px; padding-top: 26px; }
.answer-reveal-actions span { color: var(--muted); font-size: .82rem; }
.answer-guide { border-top: 1px solid var(--line); margin-top: 35px; padding-top: 30px; scroll-margin-top: 20px; }
.answer-content { display: grid; gap: 12px; }
.learner-answer { color: var(--ink); max-width: 920px; }
.learner-answer p { line-height: 1.72; margin: 0 0 15px; }
.learner-answer h3 { font-family: Georgia, serif; font-size: 1.35rem; font-weight: 400; margin: 30px 0 12px; }
.learner-answer ol, .learner-answer ul { margin: 8px 0 20px; padding-left: 25px; }
.focused-answer ul.nested-list { padding-left: 48px; }
.learner-answer li { line-height: 1.7; margin-bottom: 10px; padding-left: 4px; }
.learner-answer code { background: var(--surface-2); border-radius: 4px; font-family: "IBM Plex Mono", monospace; font-size: .83em; padding: 2px 5px; }
.learner-answer pre { background: #17211c; border-radius: 10px; color: #f4f1e9; overflow-x: auto; padding: 16px; }
.learner-answer pre code { background: transparent; color: inherit; padding: 0; }
.learner-answer .code-block { margin: 14px 0 24px; }
.learner-answer .mermaid { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 14px 0 26px; overflow-x: auto; padding: 20px; text-align: center; }
.learner-answer .mermaid svg { height: auto; max-width: 100%; }
.learner-answer blockquote { border-left: 3px solid var(--accent); color: var(--muted); margin: 20px 0; padding: 4px 0 4px 18px; }
.answer-summary-card { background: color-mix(in srgb, var(--green) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--green) 25%, var(--line)); border-radius: 14px; padding: 24px; }
.answer-summary-card .answer-section-label { color: var(--green); font-family: "IBM Plex Mono", monospace; font-size: .7rem; font-weight: 700; letter-spacing: .08em; margin-bottom: 5px; text-transform: uppercase; }
.answer-summary-card h3 { font-family: Georgia, serif; font-size: 1.55rem; margin: 0 0 12px; }
.answer-summary-card blockquote { border: 0; color: var(--ink); margin: 0; padding: 0; }
.answer-summary-card blockquote:last-child, .answer-summary-card p:last-child { margin-bottom: 0; }
.answer-details { border: 1px solid var(--line); border-radius: 14px; margin-top: 18px; overflow: hidden; }
.answer-details > summary { align-items: center; cursor: pointer; display: flex; gap: 16px; justify-content: space-between; list-style: none; padding: 20px 22px; }
.answer-details > summary::-webkit-details-marker { display: none; }
.details-summary-copy { display: grid; gap: 5px; }
.details-summary-copy strong { font-size: .95rem; }
.details-summary-copy small { color: var(--muted); font-size: .75rem; font-weight: 400; }
.details-summary-icon { font-size: 1.5rem; line-height: 1; }
.answer-details[open] .details-summary-icon { transform: rotate(45deg); }
.answer-details-content { border-top: 1px solid var(--line); padding: 4px 22px 24px; }
.code-shell { background: #17211c; border-radius: 10px; margin: 14px 0 24px; overflow: hidden; }
.code-toolbar { align-items: center; border-bottom: 1px solid rgba(244, 241, 233, .14); color: rgba(244, 241, 233, .7); display: flex; font-family: "IBM Plex Mono", monospace; font-size: .68rem; justify-content: space-between; padding: 8px 10px 8px 16px; text-transform: uppercase; }
.learner-answer .code-shell .code-block { border-radius: 0; margin: 0; padding-top: 14px; }
.copy-code-button { background: rgba(244, 241, 233, .08); border: 1px solid rgba(244, 241, 233, .25); border-radius: 6px; color: #f4f1e9; cursor: pointer; font-size: .72rem; padding: 5px 9px; text-transform: none; }
.copy-code-button:hover { background: rgba(244, 241, 233, .16); }
.answer-pending { background: var(--surface-2); border-radius: 10px; color: var(--muted); padding: 20px; }
.guide-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.guide-section { background: var(--bg); border-radius: 10px; padding: 18px; }
.guide-section h3 { font-size: .82rem; margin: 0 0 8px; text-transform: uppercase; }
.guide-section p { color: var(--muted); margin: 0; white-space: pre-line; }
.guide-list ul { color: var(--muted); margin: 0; padding-left: 20px; }
.guide-list li { line-height: 1.55; margin-bottom: 8px; }
.guide-list li:last-child { margin-bottom: 0; }
.self-check { align-items: center; display: flex; justify-content: space-between; margin-top: 25px; }
.interviewer-actions { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 16px; margin-top: 34px; padding-top: 26px; }
.interviewer-actions span { color: var(--muted); font-size: .82rem; }
.interviewer-view { background: var(--surface-2); border-radius: 12px; margin-top: 18px; padding: 24px; scroll-margin-top: 20px; }
.interviewer-view .guide-section { background: var(--surface); }
.question-navigation { align-items: center; border-top: 1px solid var(--line); display: grid; gap: 10px; grid-template-columns: 1fr auto 1fr; margin-top: 34px; padding-top: 24px; }
.navigation-button { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; color: var(--ink); cursor: pointer; font-weight: 600; padding: 10px 14px; }
.navigation-button:first-child { justify-self: start; }
.navigation-button:last-child { justify-self: end; }
.navigation-button-priority { background: var(--ink); color: var(--bg); }
.navigation-button:hover:not(:disabled) { border-color: var(--green); }
.navigation-button:disabled { cursor: not-allowed; opacity: .38; }
.rating { display: flex; gap: 7px; }
.rating button { background: transparent; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; padding: 8px 12px; }
.rating button.active { background: var(--green); color: var(--bg); }

.progress-header { padding: 72px 0 45px; }
.progress-header h1 { font-size: clamp(2.5rem, 5vw, 4.8rem); }
.progress-header > p:last-child { color: var(--muted); }
.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.stat-card strong { display: block; font-family: Georgia, serif; font-size: 2.5rem; font-weight: 400; }
.stat-card span { color: var(--muted); font-size: .85rem; }
.progress-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: grid; gap: 45px; grid-template-columns: 1fr 2fr; margin-top: 16px; padding: 32px; }
.progress-panel h2 { margin: 0; }
.domain-row { display: grid; gap: 12px; grid-template-columns: 130px 1fr 50px; margin-bottom: 15px; }
.progress-track { align-self: center; background: var(--surface-2); border-radius: 10px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--accent); height: 100%; }
.domain-count { color: var(--muted); font-size: .8rem; text-align: right; }
.toast { background: var(--ink); border-radius: 8px; bottom: 22px; color: var(--bg); left: 50%; opacity: 0; padding: 10px 16px; pointer-events: none; position: fixed; transform: translate(-50%, 15px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { height: 1px; margin: -1px; overflow: hidden; position: absolute; width: 1px; clip: rect(0,0,0,0); }

@media (prefers-reduced-motion: reduce) {
  .question-card { animation: none !important; scroll-behavior: auto; }
}

@media (max-width: 1000px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .practice-layout { grid-template-columns: 260px minmax(0, 1fr); }
  .question-card { padding: 35px; }
}
@media (max-width: 740px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 18px; }
  .topbar nav { bottom: 0; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; left: 0; position: fixed; width: 100%; z-index: 10; }
  .nav-link { padding: 14px 0 11px; }
  .theme-button { grid-column: 2; grid-row: 1; }
  main { padding: 0 16px 90px; }
  .hero { display: block; padding: 45px 0 32px; }
  .hero-stat { border-left: 0; border-top: 1px solid var(--line); margin-top: 30px; padding: 20px 0 0; }
  .filters { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .practice-layout { display: block; }
  .question-list { flex-direction: row; margin-bottom: 14px; max-height: none; overflow-x: auto; }
  .question-item { flex: 0 0 240px; }
  .question-card { min-height: 450px; padding: 24px 20px; }
  .guide-grid, .stats-grid, .progress-panel { grid-template-columns: 1fr; }
  .self-check { align-items: start; flex-direction: column; gap: 12px; }
  .answer-reveal-actions { align-items: flex-start; flex-direction: column; }
  .question-navigation { grid-template-columns: 1fr 1fr; }
  .navigation-button-priority { grid-column: 1 / -1; grid-row: 1; width: 100%; }
  .navigation-button:first-child, .navigation-button:last-child { justify-self: stretch; }
  .rating { flex-wrap: wrap; }
  .domain-row { grid-template-columns: 100px 1fr 45px; }
}
