:root {
  --ink: #172b3a;
  --muted: #657583;
  --paper: #fffdf8;
  --canvas: #f2f5f3;
  --navy: #173f5f;
  --navy-light: #e8f0f5;
  --amber: #e9a23b;
  --amber-light: #fff3dc;
  --green: #2f7d68;
  --green-light: #e4f3ee;
  --red: #b34b45;
  --red-light: #fbeae8;
  --line: #dce3e2;
  --shadow: 0 18px 50px rgb(23 63 95 / 9%);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgb(233 162 59 / 12%), transparent 30rem),
    radial-gradient(circle at 95% 20%, rgb(47 125 104 / 10%), transparent 30rem),
    var(--canvas);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.6;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid rgb(233 162 59 / 55%); outline-offset: 3px; }

.skip-link { position: fixed; top: -4rem; left: 1rem; z-index: 20; padding: .7rem 1rem; color: white; background: var(--navy); border-radius: 12px; }
.skip-link:focus { top: 1rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: .8rem max(1.25rem, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgb(220 227 226 / 80%);
  background: rgb(255 253 248 / 88%);
  backdrop-filter: blur(16px);
}

.brand { display: flex; gap: .7rem; align-items: center; padding: 0; text-align: left; border: 0; background: transparent; cursor: pointer; }
.brand-mark { display: grid; width: 43px; height: 43px; place-items: center; color: white; background: var(--navy); border-radius: 14px; font-family: serif; font-size: 1.4rem; }
.brand strong, .brand small { display: block; line-height: 1.2; }
.brand small { margin-top: .25rem; color: var(--muted); font-size: .72rem; letter-spacing: .08em; }
.header-action, .text-button { padding: .55rem .75rem; color: var(--navy); border: 0; background: transparent; cursor: pointer; font-weight: 700; }
.header-nav { display: flex; align-items: center; gap: .2rem; }

#app { width: min(1180px, calc(100% - 2rem)); min-height: calc(100vh - 76px); margin: 0 auto; padding: 3rem 0 5rem; outline: none; }

.hero { display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: center; padding: 3rem; color: white; overflow: hidden; background: linear-gradient(125deg, #173f5f, #205f72); border-radius: 34px; box-shadow: var(--shadow); }
.hero h1 { max-width: 760px; margin: .2rem 0 1rem; font-family: Georgia, "Songti SC", serif; font-size: clamp(2rem, 5vw, 4.3rem); line-height: 1.12; letter-spacing: -.04em; }
.hero-copy { max-width: 650px; margin: 0; color: rgb(255 255 255 / 76%); font-size: 1.05rem; }
.eyebrow { margin: 0 0 .3rem; color: var(--amber); font-size: .76rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero-total { display: grid; min-width: 180px; min-height: 180px; place-content: center; text-align: center; border: 1px solid rgb(255 255 255 / 22%); background: rgb(255 255 255 / 8%); border-radius: 50%; }
.hero-total strong { font-family: Georgia, serif; font-size: 3.4rem; line-height: 1; }
.hero-total span { color: rgb(255 255 255 / 70%); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 1rem 0 2rem; }
.stats-grid article { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border: 1px solid var(--line); background: rgb(255 253 248 / 82%); border-radius: 18px; }
.stats-grid span { color: var(--muted); }
.stats-grid strong { color: var(--navy); font-family: Georgia, serif; font-size: 1.7rem; }

.config-card, .question-card, .review-list, .history-shell, .result-shell, .guide-overview, .guide-card { padding: 2rem; border: 1px solid var(--line); background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-heading, .page-heading, .dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.section-heading h2, .page-heading h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 2rem; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.type-filter { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin: 1.5rem 0; }
.type-filter legend { margin-bottom: .7rem; color: var(--muted); font-size: .88rem; font-weight: 700; }
.type-filter label { position: relative; cursor: pointer; }
.type-filter input { position: absolute; opacity: 0; }
.type-filter span { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; transition: .2s ease; }
.type-filter small { color: var(--muted); }
.type-filter input:checked + span { color: var(--navy); border-color: var(--navy); background: var(--navy-light); box-shadow: inset 4px 0 var(--navy); }
.type-filter input:focus-visible + span { outline: 3px solid rgb(233 162 59 / 55%); }

.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.mode-card { position: relative; min-height: 230px; padding: 1.5rem; border: 1px solid var(--line); background: white; border-radius: 20px; }
.primary-mode { background: linear-gradient(145deg, #fff8e9, #fff); border-color: #eed7ac; }
.mode-icon { display: grid; width: 44px; height: 44px; place-items: center; color: var(--navy); background: var(--navy-light); border-radius: 14px; font-family: serif; font-size: 1.2rem; font-weight: 800; }
.mode-card h3 { margin: 1rem 0 .25rem; font-size: 1.3rem; }
.mode-card p { margin: 0 0 1rem; color: var(--muted); }
.mode-card button { width: 100%; }
.count-field { display: flex; align-items: center; justify-content: space-between; margin: .9rem 0; color: var(--muted); }
.count-field input { width: 90px; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: white; }

.primary-button, .secondary-button, .danger-button { min-height: 46px; padding: .7rem 1.15rem; border-radius: 13px; cursor: pointer; font-weight: 800; transition: transform .15s ease, box-shadow .15s ease; }
.primary-button { color: white; border: 1px solid var(--navy); background: var(--navy); box-shadow: 0 8px 18px rgb(23 63 95 / 17%); }
.secondary-button { color: var(--navy); border: 1px solid var(--line); background: white; }
.danger-button { color: var(--red); border: 1px solid #efc6c2; background: var(--red-light); }
.primary-button:hover:not(:disabled), .secondary-button:hover:not(:disabled), .danger-button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .45; }
.privacy-note { margin: 1.3rem 0 0; color: var(--muted); font-size: .85rem; text-align: center; }

.guide-shell { display: grid; gap: 1.2rem; }
.guide-hero { display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: center; padding: 2.5rem 3rem; color: white; background: linear-gradient(125deg, #173f5f, #28765f); border-radius: 30px; box-shadow: var(--shadow); }
.guide-hero h1 { margin: .15rem 0 .7rem; font-family: Georgia, "Songti SC", serif; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1.2; }
.guide-hero p:last-child { max-width: 760px; margin: 0; color: rgb(255 255 255 / 75%); }
.guide-count { display: grid; min-width: 140px; min-height: 140px; place-content: center; text-align: center; border: 1px solid rgb(255 255 255 / 22%); border-radius: 50%; }
.guide-count strong { font-family: Georgia, serif; font-size: 3rem; line-height: 1; }
.guide-overview h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 2rem; }
.guide-overview > ul { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem 2rem; padding-left: 1.3rem; }
.skill-tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; }
.skill-tags span { padding: .38rem .7rem; color: var(--navy); background: var(--navy-light); border-radius: 999px; font-size: .8rem; font-weight: 700; }
.guide-list { display: grid; gap: 1rem; }
.guide-card-heading { display: grid; grid-template-columns: 58px 1fr; gap: 1rem; align-items: start; }
.guide-card-heading > span { display: grid; width: 52px; height: 52px; place-items: center; color: white; background: var(--navy); border-radius: 16px; font-family: Georgia, serif; font-size: 1.25rem; }
.guide-card-heading h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 1.65rem; }
.guide-card-heading p { margin: .25rem 0 0; color: var(--muted); }
.guide-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.4rem; }
.guide-columns section { padding: 1rem; background: var(--canvas); border-radius: 14px; }
.guide-columns h3 { margin: 0 0 .45rem; color: var(--navy); font-size: .95rem; }
.guide-columns ul, .guide-columns ol, .risk-note ul { margin: 0; padding-left: 1.2rem; }
.guide-columns li, .risk-note li { margin: .3rem 0; }
.deliverables { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-top: 1rem; padding: .9rem 1rem; background: var(--amber-light); border-radius: 14px; }
.deliverables code { padding: .25rem .5rem; color: #6d4710; background: rgb(255 255 255 / 65%); border-radius: 7px; }
.risk-note { margin-top: .8rem; color: var(--red); }
.risk-note summary { cursor: pointer; font-weight: 800; }
.risk-note ul { margin-top: .45rem; }

.quiz-shell { width: min(860px, 100%); margin: 0 auto; }
.quiz-topline, .question-meta, .quiz-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.quiz-topline > span { font-weight: 800; }
.progress-track { height: 7px; margin: .8rem 0 1.2rem; overflow: hidden; background: #dfe7e7; border-radius: 99px; }
.progress-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), #f2c066); border-radius: inherit; transition: width .25s ease; }
.question-meta { margin-bottom: .8rem; color: var(--muted); font-size: .84rem; }
.type-badge { display: inline-flex; padding: .25rem .6rem; color: var(--navy); background: var(--navy-light); border-radius: 999px; font-size: .76rem; font-style: normal; font-weight: 800; }
.question-card { min-height: 470px; }
.question-card h1 { margin: 0 0 1.8rem; font-family: Georgia, "Songti SC", serif; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.55; }
.options { display: grid; gap: .8rem; }
.option { display: grid; grid-template-columns: 42px 1fr; gap: .9rem; align-items: center; width: 100%; padding: .9rem 1rem; text-align: left; border: 1px solid var(--line); background: white; border-radius: 15px; cursor: pointer; }
.option:not(:disabled):hover { border-color: #9bb0bd; background: #f8fbfc; }
.option-key { display: grid; width: 38px; height: 38px; place-items: center; color: var(--navy); background: var(--navy-light); border-radius: 11px; font-weight: 800; }
.option.is-selected { border-color: var(--navy); background: var(--navy-light); box-shadow: inset 4px 0 var(--navy); }
.option.is-correct { border-color: var(--green); background: var(--green-light); box-shadow: inset 4px 0 var(--green); }
.option.is-correct .option-key { color: white; background: var(--green); }
.option.is-wrong { border-color: var(--red); background: var(--red-light); box-shadow: inset 4px 0 var(--red); }
.option.is-wrong .option-key { color: white; background: var(--red); }
.answer-panel { margin-top: 1.2rem; padding: 1rem 1.2rem; border-radius: 14px; }
.answer-panel p { margin: .25rem 0 0; }
.correct-panel { color: #215d4d; background: var(--green-light); }
.wrong-panel { color: #873b36; background: var(--red-light); }
.quiz-actions { position: sticky; bottom: 0; padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--canvas) 25%); }
.quiz-actions button { min-width: 135px; }

.answer-sheet { width: min(620px, calc(100% - 2rem)); max-height: 80vh; padding: 1.5rem; border: 0; border-radius: 22px; box-shadow: 0 25px 80px rgb(0 0 0 / 25%); }
.answer-sheet::backdrop { background: rgb(10 28 39 / 55%); backdrop-filter: blur(4px); }
.dialog-heading h2 { margin: 0; }
.dialog-heading button { width: 38px; height: 38px; border: 0; background: var(--canvas); border-radius: 50%; cursor: pointer; font-size: 1.4rem; }
.sheet-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: .55rem; margin-top: 1.2rem; }
.sheet-grid button { aspect-ratio: 1; border: 1px solid var(--line); background: white; border-radius: 10px; cursor: pointer; }
.sheet-grid .answered { color: white; background: var(--navy); }
.sheet-grid .current { outline: 3px solid var(--amber); }

.result-shell { width: min(900px, 100%); margin: 0 auto; }
.result-hero { display: grid; justify-items: center; text-align: center; }
.result-hero h1 { margin: 0; font-family: Georgia, serif; font-size: 2.5rem; }
.score-ring { display: grid; width: 170px; height: 170px; margin: 1.5rem 0; place-content: center; color: white; background: var(--navy); border: 10px solid #dce8ed; border-radius: 50%; }
.score-ring strong { font-family: Georgia, serif; font-size: 3.4rem; line-height: 1; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.result-stats article { display: grid; padding: 1rem; text-align: center; background: var(--canvas); border-radius: 14px; }
.result-stats strong { font-size: 1.35rem; }
.result-stats span { color: var(--muted); font-size: .8rem; }
.result-actions { display: flex; justify-content: center; gap: .8rem; margin: 1.3rem 0 2rem; }
.review-list { padding: 1.25rem; box-shadow: none; }
.review-item { margin-top: .7rem; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.review-item summary { display: grid; grid-template-columns: 32px 1fr auto; gap: .7rem; align-items: center; padding: .9rem; cursor: pointer; }
.review-item summary > span { display: grid; width: 28px; height: 28px; place-items: center; background: var(--canvas); border-radius: 8px; }
.review-item summary strong { font-weight: 600; }
.review-item summary em { font-size: .8rem; font-style: normal; font-weight: 800; }
.review-correct summary em { color: var(--green); }
.review-wrong summary em { color: var(--red); }
.review-item > div { padding: .3rem 1rem 1rem 3.9rem; color: var(--muted); background: #fafbf9; }
.review-item p { margin: .3rem 0; }

.page-heading { margin-bottom: 1.5rem; }
.page-heading p { margin: .2rem 0 0; color: var(--muted); }
.page-heading > div:last-child { display: flex; gap: .6rem; }
.history-list { display: grid; gap: .8rem; }
.history-list article { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: 16px; }
.history-list h2 { display: inline-block; margin: .4rem .7rem 0 0; font-family: Georgia, serif; font-size: 2rem; }
.history-list p { display: inline; color: var(--muted); font-size: .85rem; }
.history-score { display: flex; gap: .8rem; align-items: center; color: var(--muted); font-size: .85rem; }
.empty-state, .error-state, .loading-card { display: grid; min-height: 420px; place-content: center; justify-items: center; text-align: center; }
.empty-state > span, .error-state > span { display: grid; width: 70px; height: 70px; place-items: center; color: var(--navy); background: var(--navy-light); border-radius: 22px; font-family: serif; font-size: 2rem; }
.empty-state h2, .error-state h1 { margin: 1rem 0 .2rem; }
.empty-state p, .error-state p { margin: 0 0 1rem; color: var(--muted); }
.loader { width: 44px; height: 44px; border: 4px solid var(--line); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; }
.toast { position: fixed; bottom: 1.5rem; left: 50%; z-index: 30; padding: .7rem 1.1rem; color: white; background: #172b3a; border-radius: 12px; opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 1rem; color: white; background: var(--red); text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  #app { width: min(100% - 1rem, 1180px); padding-top: 1rem; }
  .site-header { min-height: 66px; padding: .7rem 1rem; }
  .brand-mark { width: 38px; height: 38px; }
  .brand small { display: none; }
  .header-action { padding: .5rem; font-size: .84rem; }
  .hero { grid-template-columns: 1fr; padding: 1.5rem; border-radius: 24px; }
  .hero-total { grid-auto-flow: column; gap: .6rem; align-items: baseline; min-width: 0; min-height: auto; padding: .9rem; border-radius: 16px; }
  .hero-total strong { font-size: 2rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid article { padding: .75rem; }
  .config-card, .question-card, .history-shell, .result-shell, .guide-overview, .guide-card { padding: 1rem; border-radius: 18px; }
  .type-filter { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 0; }
  .guide-hero { grid-template-columns: 1fr; padding: 1.5rem; border-radius: 24px; }
  .guide-count { grid-auto-flow: column; gap: .5rem; align-items: baseline; min-width: 0; min-height: auto; padding: .8rem; border-radius: 15px; }
  .guide-count strong { font-size: 2rem; }
  .guide-overview > ul, .guide-columns { grid-template-columns: 1fr; }
  .question-card { min-height: 0; }
  .question-meta span:last-child { display: none; }
  .option { grid-template-columns: 36px 1fr; padding: .75rem; }
  .option-key { width: 34px; height: 34px; }
  .sheet-grid { grid-template-columns: repeat(6, 1fr); }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .result-actions, .page-heading, .history-list article, .history-score { align-items: stretch; flex-direction: column; }
  .page-heading > div:last-child { width: 100%; }
  .page-heading > div:last-child button { flex: 1; }
  .history-list article { align-items: flex-start; }
  .history-score { gap: .2rem; }
  .review-item summary { grid-template-columns: 30px 1fr; }
  .review-item summary em { grid-column: 2; }
  .review-item > div { padding-left: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
