:root {
  color-scheme: light;
  --background: #f1f7f8;
  --surface: #fff;
  --text: #10252e;
  --muted: #526872;
  --line: #d5e0e4;
  --line-light: #e6edf0;
  --teal: #0b656b;
  --teal-dark: #084c53;
  --teal-light: #def4ef;
  --danger: #8b3932;
  --radius: 15px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.55;
  font-size: 16px;
  background: var(--background);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .56; }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #2e9296;
  outline-offset: 3px;
}
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.28; letter-spacing: -.02em; font-weight: 750; }
h1:focus, h2:focus, main:focus { outline: none; }
svg { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }
.muted, .quiet { color: var(--muted); }
.error { color: var(--danger); }
.feedback { margin: .75rem 0; min-width: 0; overflow-wrap: anywhere; }
.feedback:empty { display: none; }
.feedback:not(.error) { color: var(--teal-dark); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner {
  display: flex; align-items: center; gap: 3rem;
  width: min(100% - 3rem, 1430px); margin-inline: auto; min-height: 65px;
}
.brand {
  display: inline-flex; align-items: center; gap: .45rem; flex: none;
  font-size: 1.22rem; font-weight: 760; line-height: 1.2; color: var(--text);
}
.brand svg { color: var(--teal); }
.header-links { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; white-space: nowrap; }
.header-links a:not(.button), .header-links .text-button { color: var(--text); font-weight: 580; }
.nav-tabs { display: flex; align-self: stretch; gap: .9rem; }
.nav-tabs button, .nav-tabs a, .bank-tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem .95rem;
  color: var(--muted); font-weight: 650;
}
.nav-tabs a { display: inline-flex; align-items: center; }
.nav-tabs [aria-current], .bank-tabs button[aria-pressed="true"] { color: var(--teal); border-bottom-color: var(--teal); }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .64rem 1.08rem; border: 1px solid transparent; border-radius: 9px;
  background: var(--surface); color: var(--text); font-weight: 680; line-height: 1.35; text-align: center;
  transition: background-color .16s, border-color .16s;
}
.button.primary { background: var(--teal); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--teal-dark); }
.button.light { background: #fff; color: #10252e; }
.button.light:hover:not(:disabled) { background: #dfefef; }
.button.outline { color: var(--teal-dark); border-color: #8caaae; }
.button.outline:hover:not(:disabled) { background: #eaf5f5; }
.button.small { min-height: 38px; padding: .43rem .82rem; }
.button.full { width: 100%; }
.text-button {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  background: transparent; border: none; color: var(--teal-dark); padding: .36rem .12rem; font-weight: 620;
}
.text-button:hover { text-decoration: underline; text-underline-offset: .2em; }
.icon-button { background: transparent; color: var(--muted); border: 0; border-radius: 6px; padding: .45rem; }
.icon-button:hover { color: var(--text); background: var(--background); }

.main-shell { width: min(100% - 3rem, 1136px); margin: 2.05rem auto 3rem; }
.practice-hero {
  display: flex; align-items: center; min-height: 294px; border-radius: 22px;
  background: #0b303c url("/water.webp") right 46% / cover no-repeat;
  color: #fff; overflow: hidden;
}
.hero-content {
  width: 100%; align-self: stretch; display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; padding: 2rem 4.15rem;
  background: linear-gradient(90deg, #0b303c 0%, #0b303cf2 25%, #0b303c35 57%, transparent 72%);
}
.hero-content h1 { font-size: clamp(2.15rem, 4.6vw, 3.5rem); }
.hero-content p { margin-top: .42rem; font-size: clamp(1rem, 1.8vw, 1.22rem); color: #f0f9fa; }
.hero-content .button { margin-top: 1.35rem; min-width: 9rem; min-height: 46px; }
.category-section { margin-top: 1.7rem; }
.category-section h2 { font-size: clamp(1.45rem, 2.8vw, 2rem); margin-bottom: 1rem; }
.topic-subheading { margin: 1.2rem 0 .65rem; font-size: 1.12rem; }
.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
.category-card {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .88rem; text-align: left;
  min-height: 92px; padding: 1rem 1.14rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); transition: border-color .16s, background-color .16s;
}
.category-card:hover:not(:disabled) { border-color: #63a2a6; background: #fbffff; }
.category-icon { color: var(--teal); }
.category-label { min-width: 0; }
.category-label strong { display: block; line-height: 1.35; font-size: 1.12rem; }
.category-label small { display: block; color: var(--muted); font-size: .92rem; margin-top: .2rem; }
.category-chevron { color: #36555e; }
.continue-strip {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: 1rem;
  padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.continue-strip span { margin-left: .75rem; color: var(--muted); font-size: .9rem; }

.login-shell { display: grid; place-items: start center; margin-top: clamp(2.5rem, 12vh, 7rem); }
.login-card {
  width: min(100%, 420px); padding: 2.25rem; border-radius: 17px; border: 1px solid var(--line);
  background: var(--surface);
}
.login-card h1 { text-align: center; font-size: clamp(1.45rem, 5vw, 1.7rem); margin: .2rem 0 1.75rem; }
.login-card form { display: grid; gap: .4rem; }
.login-card form > input + label { margin-top: .5rem; }
.login-card .button { margin-top: .7rem; }
.login-link { display: block; text-align: center; margin-top: 1rem; font-weight: 650; }
input:not([type="checkbox"], [type="radio"]), select, textarea {
  width: 100%; min-width: 0; min-height: 42px; border: 1px solid #aec2ca;
  border-radius: 8px; background: #fff; color: var(--text); padding: .5rem .66rem;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { resize: vertical; }

.narrow-shell { width: min(100% - 3rem, 680px); }
.quiz-panel, .result-panel, .review-panel {
  padding: 1.7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.quiz-progress { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .65rem; }
.quiz-progress h1 { font-size: clamp(1.35rem, 5vw, 1.75rem); }
.quiz-progress span { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
progress {
  appearance: none; display: block; width: 100%; height: 8px; border: none;
  border-radius: 10px; background: #e5eef0; color: var(--teal); overflow: hidden;
}
progress::-webkit-progress-bar { background: #e5eef0; }
progress::-webkit-progress-value { background: var(--teal); border-radius: 10px; }
progress::-moz-progress-bar { background: var(--teal); border-radius: 10px; }
.question-content { margin-top: 1.16rem; }
.question-type { display: inline-block; font-size: .875rem; font-weight: 650; color: var(--muted); }
.question-prompt {
  font-size: clamp(1.22rem, 4.3vw, 1.47rem); line-height: 1.45; margin: .28rem 0 .9rem; overflow-wrap: anywhere; white-space: pre-wrap;
}
.answer-options { min-width: 0; display: grid; gap: .5rem; border: 0; padding: 0; margin: 0; }
.option {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .68rem;
  min-height: 50px; padding: .57rem .68rem; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--text); cursor: pointer;
}
.option input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; left: .5rem;
}
.option:has(input:focus-visible) { outline: 3px solid #2e9296; outline-offset: 2px; }
.option:has(input:checked:not(:disabled)) { background: #ebf7f6; border-color: #368a8e; }
.option:hover:has(input:not(:disabled)) { border-color: #63a2a6; }
.option:has(input:disabled) { cursor: default; }
.option.is-correct { background: var(--teal-light); border-color: #b7e0d5; }
.option.is-incorrect { background: #fcf0ed; border-color: #edccc4; }
.option.is-selected { background: #ebf7f6; border-color: #a9d4d1; }
.option-letter {
  display: inline-grid; place-items: center; width: 1.65rem; height: 1.65rem; border-radius: 5px;
  background: #edf3f5; color: var(--text); font-size: .92rem; font-weight: 700;
}
.is-correct .option-letter, .option:has(input:checked:not(:disabled)) .option-letter { background: #ccebe5; color: var(--teal-dark); }
.is-incorrect .option-letter { background: #f8ded7; color: var(--danger); }
.option-text { min-width: 0; overflow-wrap: anywhere; }
.option-status { color: var(--teal-dark); font-size: .85rem; white-space: nowrap; }
.is-incorrect .option-status { color: var(--danger); }
.answer-panel { margin-top: .9rem; padding: .85rem 1rem; border-radius: 9px; color: #233626; background: #f0f6ef; overflow-wrap: anywhere; }
.answer-panel.correct { background: #eaf6e7; }
.answer-panel.incorrect { background: #faf3e6; color: #523e24; }
.answer-panel h2 { font-size: 1.08rem; margin-bottom: .28rem; }
.answer-panel p + p { margin-top: .25rem; white-space: pre-wrap; }
.answer-key { font-size: .9rem; }
.answer-key span { display: inline-block; margin-left: .85rem; }
.source { display: inline-flex; align-items: center; gap: .3rem; margin-top: .43rem; color: var(--teal-dark); font-size: .875rem; font-weight: 600; }
.quiz-actions { display: grid; gap: .44rem; margin-top: 1rem; }
.quiz-actions .quiet { justify-self: center; color: var(--muted); font-size: .9rem; }
.question-type, .source { line-height: 1.35; }
.storage-note { color: var(--muted); margin: .75rem 0 0; font-size: .9rem; }

.review-panel { max-width: 820px; margin-inline: auto; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: .65rem; margin-bottom: 1rem; }
.section-heading h1, .result-panel h1 { font-size: 1.8rem; }
.section-heading .muted { margin-top: .25rem; }
.empty { border: 1px dashed var(--line); padding: 1.5rem 1rem; border-radius: 9px; color: var(--muted); text-align: center; }
.wrong-item { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; margin-bottom: .65rem; }
.wrong-item summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: .5rem; cursor: pointer; padding: .7rem .8rem;
}
.wrong-item summary:focus-visible { outline-offset: -3px; }
.wrong-item summary::-webkit-details-marker { display: none; }
.wrong-item summary strong { display: block; overflow-wrap: anywhere; }
.wrong-item[open] summary svg { transform: rotate(90deg); }
.wrong-content { padding: 0 .8rem .8rem; }
.result-panel { text-align: center; }
.result-panel h1 { margin-top: .65rem; }
.result-icon { display: inline-grid; place-items: center; border-radius: 50%; width: 60px; height: 60px; color: var(--teal); background: var(--teal-light); }
.score { margin-top: .8rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--muted); }
.score strong { font-size: 3.4rem; color: var(--teal-dark); }
.score span { font-size: 1.3rem; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; margin-top: 1.2rem; }

.admin-shell { width: min(100% - 2rem, 1430px); margin-top: 1.2rem; }
.admin-layout { display: grid; gap: .65rem; }
.admin-layout.form-open { grid-template-columns: minmax(0, 1fr) minmax(350px, min(43%, 510px)); align-items: start; }
.bank-panel, .editor { background: var(--surface); border: 1px solid var(--line-light); border-radius: var(--radius); padding: 1.4rem; min-width: 0; }
.admin-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.2rem; }
.admin-heading > div { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .75rem; }
.admin-heading h1 { font-size: clamp(1.55rem, 4vw, 2rem); }
.admin-heading .button { flex: none; }
.admin-filters { display: grid; grid-template-columns: minmax(130px, 1.6fr) minmax(100px, 1fr) minmax(100px, 1fr); gap: .55rem; }
.search-field { position: relative; color: var(--muted); }
.search-field svg { position: absolute; top: 11px; left: 10px; pointer-events: none; }
.search-field input { padding-left: 2.25rem; }
.select-wrap { position: relative; display: block; }
.select-wrap::after {
  content: ""; position: absolute; right: .9rem; top: calc(50% - .28rem); width: .48rem; height: .48rem;
  border: solid #3f5f68; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none;
}
.select-wrap select { appearance: none; padding-right: 1.65rem; }
.bank-tabs { display: flex; border-bottom: 1px solid var(--line-light); margin: .45rem 0 .75rem; }
.bank-tabs button { padding-inline: .75rem; }
.question-table { overflow-x: auto; }
.question-table table { border-collapse: collapse; width: 100%; min-width: 550px; font-size: .94rem; text-align: left; }
.question-table thead { background: #edf4f6; }
.question-table thead th { font-weight: 680; }
.question-table th, .question-table td { padding: .52rem .56rem; vertical-align: middle; }
.question-table tbody th { font-weight: 560; width: 50%; overflow-wrap: anywhere; }
.question-table tbody tr { border-bottom: 1px solid var(--line-light); }
.question-table tbody tr:hover { background: #f8fbfc; }
.question-table td:nth-child(3), .question-table td:last-child { white-space: nowrap; }
.question-table thead th:nth-child(4) { white-space: nowrap; }
.table-source { min-width: 6rem; overflow-wrap: anywhere; }
.paper-list { margin: 0; padding: 0; list-style: none; }
.paper-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .8rem 0; border-top: 1px solid var(--line-light);
}
.paper-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.paper-row .muted { display: block; font-size: .9rem; }
.paper-row .button { flex: none; white-space: nowrap; }
.paper-actions, .exam-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.paper-actions { flex: none; }
.exam-actions { margin-top: 1rem; }
#submit-exam { margin-left: auto; }
.exam-back { display: inline-block; margin-top: .65rem; }
.exam-save { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .55rem; font-size: .88rem; }
.exam-save .error { color: var(--danger); }
.account-enabled { display: flex; align-items: center; gap: .5rem; }
.account-enabled > input { accent-color: var(--teal); }
#user-list, .roster-table { margin-top: .8rem; }
.question-table .account-table tbody th { width: auto; }
.roster-table table { min-width: 680px; }
.account-table tbody th small { display: block; font-weight: 400; }
.roster-summary { margin-bottom: .7rem; }
.exam-record-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.exam-record-facts dt { color: var(--muted); font-size: .88rem; }
.exam-record-facts dd { margin: .1rem 0 0; }
.question-numbers { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .65rem; max-height: 10rem; overflow-y: auto; }
.question-number {
  min-width: 36px; min-height: 36px; padding-inline: .35rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); color: var(--text);
}
.question-number.answered { background: var(--teal-light); }
.question-number[aria-current] { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); color: var(--teal-dark); font-weight: 700; }
.builder-modes { margin: 0; padding: 0; border: 0; min-width: 0; }
.builder-modes legend { margin-bottom: .35rem; padding: 0; font-weight: 650; }
.builder-modes > label { display: inline-flex; align-items: center; gap: .35rem; margin-right: .9rem; }
.builder-modes input, .question-pick input { accent-color: var(--teal); }
.builder-modes label > input { display: inline-block; margin: 0; }
.topic-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .2rem .55rem; }
.question-pick {
  display: flex; gap: .55rem; align-items: flex-start; padding: .35rem .1rem;
  cursor: pointer; overflow-wrap: anywhere;
}
.question-pick > span { min-width: 0; }
.question-pick > input { flex: none; margin-top: .32rem; }
.question-pick small { display: block; font-weight: 400; color: var(--muted); }
.topic-picks .question-pick { min-height: 36px; }
.topic-picks .question-pick span { display: flex; flex-wrap: wrap; column-gap: .35rem; align-items: baseline; }
.builder-quantity, .paper-filter { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: .55rem; align-items: end; }
.builder-quantity { margin-top: .6rem; }
.builder-quantity p { padding-bottom: .42rem; }
.builder-selection { margin-top: .45rem; }
.manual-choices { max-height: 20rem; min-height: 5rem; overflow: auto; margin-top: .5rem; border-top: 1px solid var(--line-light); }
.manual-choices .question-pick { padding-block: .5rem; border-bottom: 1px solid var(--line-light); }
.table-actions { display: flex; gap: .48rem; }
.table-actions button { min-height: 35px; }
.editor { scroll-margin-top: 1rem; }
.editor-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .8rem; }
.editor-heading h2 { font-size: 1.5rem; }
.editor form { display: grid; gap: .65rem; }
.editor label, .option-field-title { font-weight: 600; }
.editor label > input, .editor label > textarea, .editor label > .select-wrap { display: block; margin-top: .2rem; font-weight: 400; }
.editor-selects { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.editor-options { min-width: 0; padding: 0; border: 0; margin: 0; }
.option-field-title { display: flex; justify-content: space-between; margin-bottom: .3rem; }
.option-field-title span + span { color: var(--muted); font-size: .875rem; }
.editor-option { display: flex; align-items: center; gap: .36rem; margin-bottom: .38rem; }
.editor-option > input { flex: 1; min-height: 36px; padding-block: .3rem; }
.check-holder { min-width: 2rem; display: grid; place-items: center; }
.check-holder input { margin: 0 !important; width: 1.13rem; height: 1.13rem; accent-color: var(--teal); }
.add-option { font-size: .9rem; }
.editor-actions { display: flex; justify-content: flex-end; gap: .55rem; border-top: 1px solid var(--line-light); padding-top: .75rem; }
.editor-actions .button { min-width: 5.15rem; }
.confirmation {
  width: min(100% - 2rem, 420px); padding: 1.25rem; border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); background: var(--surface);
}
.confirmation::backdrop { background: #10252e66; }
.confirmation h2 { font-size: 1.3rem; }
.confirmation p { margin: .55rem 0 1rem; color: var(--muted); }

@media (max-width: 900px) {
  .header-inner { gap: 1.1rem; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout.form-open { grid-template-columns: 1fr; }
  .form-open .editor { grid-row: 1; }
}

@media (max-width: 770px) {
  .header-inner:has(.nav-tabs a[href="/admin/users"]) { flex-wrap: wrap; gap: 0 .6rem; }
  .header-inner:has(.nav-tabs a[href="/admin/users"]) .nav-tabs { order: 3; width: 100%; }
}

@media (max-width: 580px) {
  .header-inner { flex-wrap: wrap; gap: 0 .6rem; width: calc(100% - 1.6rem); padding-top: .32rem; min-height: 56px; }
  .brand { font-size: clamp(.98rem, 4.05vw, 1.13rem); min-height: 43px; gap: .22rem; }
  .brand svg { width: 24px; height: 24px; }
  .header-links { font-size: .88rem; gap: .6rem; }
  .nav-tabs { order: 3; width: 100%; gap: .55rem; }
  .nav-tabs button, .nav-tabs a { min-height: 40px; padding: .35rem .74rem .42rem; }
  .paper-row:has(.paper-actions) { align-items: flex-start; flex-direction: column; gap: .25rem; }
  .exam-actions { gap: .35rem; }
  .exam-actions .button { padding-inline: .65rem; }
  .exam-record-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-shell, .narrow-shell { width: calc(100% - 1.5rem); margin-top: 1rem; }
  .practice-hero { min-height: 206px; border-radius: 16px; background-position: 63% center; }
  .hero-content { padding: 1.3rem 1.12rem; background: linear-gradient(90deg, #0b303c 0%, #0b303cdb 36%, #0b303c20 75%, transparent 92%); }
  .hero-content p { max-width: 70%; }
  .hero-content .button { margin-top: .9rem; min-width: 7rem; min-height: 43px; }
  .category-grid { grid-template-columns: 1fr; gap: .55rem; }
  .category-section { margin-top: 1.2rem; }
  .category-section h2 { margin-bottom: .6rem; }
  .category-card { min-height: 68px; padding: .64rem .72rem; gap: .65rem; }
  .category-icon svg { width: 26px; height: 26px; }
  .continue-strip { padding: .55rem .64rem; }
  .continue-strip span { display: block; margin-left: 0; }
  .login-shell { margin-top: clamp(2.5rem, 10vh, 5rem); }
  .login-card { padding: 1.7rem 1.35rem; }
  .quiz-panel, .review-panel, .result-panel { padding: .9rem; }
  .option { gap: .52rem; padding-inline: .55rem; }
  .option-status { font-size: .78rem; }
  .option:not(:has(.option-status)) { grid-template-columns: auto 1fr; }
  .bank-panel, .editor { padding: .75rem; }
  .admin-filters { grid-template-columns: 1fr 1fr; gap: .4rem; }
  .search-field { grid-column: 1 / -1; }
  .admin-heading { margin-bottom: .7rem; }
}

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