/* Editorial layout. Spacing follows an 8 px rhythm inspired by Carbon. */
:root {
  color-scheme: light;
  --ink: #273943;
  --muted: #626861;
  --line: #d7d8ce;
  --link: #294a60;
  --paper: #fcfbf7;
  --sidebar: #f1f0e9;
  --error: #943e34;
  --success: #3b6850;
  --success-surface: #e6f1e8;
  --success-border: #578064;
  --error-surface: #f9e9e4;
  --error-border: #ad6557;
  --serif: "Bitstream Charter", Charter, Georgia, serif;
  --radius: 3px;
  --canvas: #e9e9e2;
  --control: #fff;
  --control-line: #b7bdb4;
  --hover: #f1f2ee;
  --action: #294a60;
  --action-hover: #1e394b;
  --on-action: #fff;
  --header-line: var(--ink);
  font-family: Cantarell, "Segoe UI", sans-serif;
  font-synthesis: none;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5e7e1;
  --muted: #b4bcb8;
  --line: #3b464b;
  --link: #b7cede;
  --paper: #1f2427;
  --sidebar: #242b2e;
  --error: #f1a79a;
  --success: #a0c8aa;
  --success-surface: #263c30;
  --success-border: #78a587;
  --error-surface: #422d2b;
  --error-border: #cc8b7d;
  --canvas: #171c1f;
  --control: #252d31;
  --control-line: #5c696f;
  --hover: #303c41;
  --action: #bdd2df;
  --action-hover: #d5e3eb;
  --on-action: #17252e;
  --header-line: #62727b;
}
* { box-sizing: border-box; }
@media (prefers-reduced-motion: no-preference) {
  .theme-changing body,
  .theme-changing body *,
  .theme-changing body *::before,
  .theme-changing body *::after,
  .theme-changing input::placeholder,
  .theme-changing textarea::placeholder,
  .theme-changing input::file-selector-button {
    transition-property: color, background-color, border-color, outline-color, accent-color;
    transition-duration: 240ms;
    transition-timing-function: ease-in-out;
  }
}
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 15px; line-height: 1.6; }
button, input, textarea, select { font: inherit; }
button, a, input, label { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3, p { margin-top: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; max-width: 1328px; margin: auto; background: var(--paper); }
.site-header { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 24px 40px; background: var(--paper); border-bottom: 1px solid var(--header-line); }
.site-header p { margin: 0; color: var(--muted); font-size: 14px; }
.sidebar { padding: 32px 24px; background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: stretch; gap: 24px; min-width: 0; }
.site-title { margin: 0; }
.brand { display: block; margin: 0; font-family: var(--serif); font-size: 34px; line-height: 1.2; font-weight: normal; color: var(--ink); text-decoration: none; }
.section-label { display: flex; align-items: baseline; gap: 8px; }
.section-label h2 { margin: 0; font-size: 16px; font-weight: 600; }
.plain-count { color: var(--muted); font-size: 12px; }
.plain-count::before { content: "("; }
.plain-count::after { content: ")"; }
.bank-search { width: 100%; min-width: 0; min-height: 40px; margin-top: 16px; border: 1px solid var(--control-line); border-radius: var(--radius); padding: 8px 12px; background: var(--paper); color: var(--ink); font-size: 13px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
.library-groups { display: flex; flex-direction: column; gap: 24px; margin-top: 24px; }
.bank-group { min-width: 0; }
.bank-group-heading { display: flex; align-items: baseline; gap: 8px; }
.bank-group-heading h3 { margin: 0; font-size: 14px; font-weight: 600; }
.bank-group-description { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.bank-list { display: flex; flex-direction: column; list-style: none; margin: 12px 0 0; padding: 0; max-height: 330px; overflow-y: auto; border: 1px solid var(--control-line); border-radius: var(--radius); background: var(--paper); }
#library-login { margin-top: 12px; }
.bank-item + .bank-item { border-top: 1px solid var(--line); }
.bank-button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border: 0; background: transparent; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
.bank-button strong { font-size: 15px; line-height: 1.4; font-weight: 600; }
.bank-button:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.bank-button:focus-visible { outline-offset: -3px; }
.bank-details { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.bank-action { font-size: 12px; font-weight: 600; color: var(--link); }
.bank-button .selection-note { color: var(--ink); }
.bank-empty { margin: 12px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 12px; color: var(--muted); }
.sidebar-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.upload-zone { display: flex; flex-direction: column; gap: 8px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 13px; }
.upload-zone strong { font-size: 15px; font-weight: 600; }
.upload-zone span, .upload-zone small { color: var(--muted); }
.upload-zone input { width: 100%; min-width: 0; margin-top: 4px; font-size: 12px; }
input[type=file]::file-selector-button { padding: 8px 10px; margin-right: 8px; border: 1px solid var(--control-line); border-radius: var(--radius); background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; }
.upload-zone.dragging { outline: 2px dashed var(--link); outline-offset: 5px; }
.format-link { margin-top: -10px; font-size: 12px; }
.create-bank-button { min-height: 40px; border: 1px solid var(--control-line); border-radius: var(--radius); padding: 8px 12px; background: var(--paper); color: var(--link); font-size: 14px; text-align: left; }
.create-bank-button:hover { border-color: var(--link); }
.create-bank-button + .create-bank-button { margin-top: -10px; }
.privacy-note { margin: auto 0 0; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
main { width: 100%; max-width: 1048px; min-width: 0; padding: 32px 48px 40px; }
.topbar { text-align: right; }
.session-status { color: var(--muted); font-size: 12px; }
.view { padding-bottom: 25px; }
.intro h2, .results-heading { margin: 0 0 12px; font-family: var(--serif); font-size: clamp(28px, 3vw, 34px); line-height: 1.2; font-weight: normal; }
.intro { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.intro p { color: var(--muted); font-size: 14px; margin: 0; }
.selected-bank { display: block; padding: 0; }
.selected-bank h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 24px; line-height: 1.3; font-weight: normal; overflow-wrap: anywhere; }
.selected-bank p { margin: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.selected-bank p:empty { display: none; }
.origin-tag, .subject-tag { display: block; padding: 0; margin-top: 6px; border: 0; background: none; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
#draft-question-count { display: inline; color: var(--ink); }
#draft-question-count::before { content: "("; }
#draft-question-count::after { content: ")"; }
.bank-tools { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.bank-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 16px 0 24px; font-size: 14px; border-bottom: 1px solid var(--line); }
.bank-stats > div { display: flex; align-items: baseline; gap: 5px; }
.bank-stats strong { font-size: inherit; font-weight: 600; }
.bank-stats span { color: var(--muted); }
.config-card { min-width: 0; border: 0; background: none; padding: 0; margin-top: 24px; }
.step-heading { display: flex; align-items: baseline; gap: 12px; }
.step-heading h3 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.step-heading p { margin: 0; font-size: 13px; color: var(--muted); }
.text-button { border: 0; padding: 4px 0; background: none; color: var(--link); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.text-button:hover { color: var(--ink); }
.step-heading > button { margin-left: auto; flex-shrink: 0; }
fieldset { border: 0; padding: 0; margin: 14px 0 0; min-width: 0; }
#subjects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }
.subject-option { display: flex; align-items: center; min-height: 32px; gap: 12px; font-size: 14px; cursor: pointer; }
.subject-option input { width: 16px; height: 16px; margin: 0; flex-shrink: 0; accent-color: var(--link); }
.subject-option span { overflow-wrap: anywhere; }
.subject-option small { margin-left: 6px; color: var(--muted); font-size: 12px; }
.subject-option small::before { content: "("; }
.subject-option small::after { content: ")"; }
.divider { margin: 24px 0; height: 1px; background: var(--line); }
.quantity-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 16px 0; font-size: 13px; }
.quantity-row input { width: 72px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--control-line); border-radius: var(--radius); background: var(--control); color: var(--ink); }
.presets { display: flex; gap: 8px; margin-left: 8px; }
.presets button { min-width: 32px; min-height: 32px; padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--control); color: var(--link); font-size: 13px; }
.presets button:hover { border-color: var(--link); }
.switch-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; cursor: pointer; }
.switch-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--link); }
.start-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 26px; }
.start-row p { color: var(--muted); font-size: 12px; margin: 0; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 20px; border: 1px solid var(--control-line); border-radius: var(--radius); background: var(--control); color: var(--ink); font-size: 14px; font-weight: 600; white-space: normal; text-align: center; }
.primary-button { background: var(--action); border-color: var(--action); color: var(--on-action); }
.compact-button { min-height: 40px; padding: 8px 12px; font-size: 13px; }
.header-tools { display: flex; align-items: center; gap: 12px; }
.header-tools > button { flex-shrink: 0; }
.primary-button:hover:enabled { background: var(--action-hover); }
.secondary-button:hover:enabled { border-color: var(--link); background: var(--hover); }
.footnote { color: var(--muted); font-size: 12px; margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.empty-state { padding: 18px 0; }
.empty-state h3 { font-size: 15px; margin: 0 0 8px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.notice { margin-top: 18px; padding: 12px; border: 1px solid var(--error); color: var(--error); font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; }
.quiz-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.quiz-top > span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12px; }
progress { width: 100%; height: 5px; accent-color: var(--link); }
.question-card { padding: 0; margin-top: 28px; }
.question-card h2 { margin: 8px 0 16px; font-family: var(--serif); font-size: 28px; font-weight: normal; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-instruction { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.answers { display: flex; flex-direction: column; }
.answer-button { display: flex; align-items: baseline; gap: 16px; width: 100%; min-width: 0; padding: 16px 8px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); text-align: left; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-letter { width: 18px; flex-shrink: 0; color: var(--muted); font-size: 13px; }
.answer-letter::after { content: "."; }
.answer-text { flex: 1; min-width: 0; }
.answer-state { flex-shrink: 0; font-size: 12px; }
.answer-button:hover:enabled { background: var(--sidebar); }
.answer-button:disabled { opacity: 1; cursor: default; }
.answer-button.correct .answer-state { color: var(--success); }
.answer-button.incorrect .answer-state { color: var(--error); }
.answer-button.correct .answer-text, .answer-button.incorrect .answer-text { font-weight: bold; }
.feedback { margin-top: 24px; padding: 16px 0 0; border-top: 1px solid var(--line); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback strong { color: var(--success); }
.feedback.incorrect strong { color: var(--error); }
.feedback p { margin: 8px 0 0; }
/* Answer results use full borders and explicit labels in both themes. */
#answers .answer-button.correct, #answers .answer-button.incorrect {
  margin: 4px 0;
  padding: 14px 12px;
  border: 2px solid var(--success-border);
  border-radius: var(--radius);
  background: var(--success-surface);
}
#answers .answer-button.incorrect { border-color: var(--error-border); background: var(--error-surface); }
#answers .answer-button.correct .answer-letter { color: var(--success); }
#answers .answer-button.incorrect .answer-letter { color: var(--error); }
#answers .answer-state { font-size: 13px; font-weight: bold; }
#feedback {
  padding: 20px 24px;
  scroll-margin-block: 24px;
  border: 2px solid var(--success-border);
  border-radius: var(--radius);
  background: var(--success-surface);
  font-size: 15px;
  line-height: 1.6;
}
#feedback.incorrect { border-color: var(--error-border); background: var(--error-surface); }
#feedback-title { display: block; font-size: 22px; line-height: 1.3; }
#correct-answer { margin-top: 12px; font-weight: 600; }
.next-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 24px; }
.next-row > span { color: var(--muted); font-size: 12px; }
.result-stats { display: flex; flex-direction: column; gap: 8px; margin: 24px 0; padding: 16px 24px; background: var(--sidebar); font-size: 15px; }
.result-stats > div { display: flex; align-items: baseline; gap: 6px; }
.result-stats strong { font-size: inherit; }
.result-stats span { color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.review-heading { margin: 32px 0 8px; font-family: var(--serif); font-size: 24px; font-weight: normal; }
.muted, #results-bank { color: var(--muted); font-size: 13px; }
.review-item { padding: 14px 0; margin: 0; border-bottom: 1px solid var(--line); }
.review-item summary { cursor: pointer; font-size: 13px; overflow-wrap: anywhere; }
.review-item p { margin: 10px 0 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-status { display: inline-block; margin-right: 12px; color: var(--success); font-size: 12px; }
.review-item.incorrect .review-status { color: var(--error); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Forms share the same typography, surfaces and control sizes. */
.editor-meta { padding: 24px; border-bottom: 1px solid var(--line); background: var(--sidebar); }
.editor-meta label, .editor-question > label { display: block; font-size: 13px; font-weight: bold; margin: 16px 0 6px; }
.editor-meta label:first-child { margin-top: 0; }
.editor-meta input, .editor-meta textarea, .editor-meta select, .editor-question select, .editor-question input[type=text], .editor-question input[type=number], .editor-question textarea,
.login-form input, .admin-upload input[type=text], .admin-upload select, .admin-metadata input, .admin-metadata select, .admin-list-heading input, .admin-editor-controls select {
  display: block; width: 100%; min-width: 0; border: 1px solid var(--control-line); border-radius: var(--radius); padding: 10px 12px; background: var(--control); color: var(--ink); font-size: 13px; line-height: 1.6;
}
.editor-meta textarea, .editor-question textarea { resize: vertical; min-height: 65px; }
.editor-question input[type=number] { max-width: 140px; }
.math-help { margin: 18px 0; padding: 0; font-size: 13px; }
.math-help summary { cursor: pointer; color: var(--link); text-decoration: underline; }
.math-help p { margin: 12px 0 0; }
.math-help code { font-size: 12px; overflow-wrap: anywhere; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.editor-grid h3 { font-family: var(--serif); font-size: 24px; font-weight: normal; margin-bottom: 16px; }
.editor-alternatives { display: block; margin-top: 18px; }
.editor-alternatives legend { font-size: 13px; font-weight: bold; }
.editor-alternatives > p { font-size: 12px; margin: 4px 0 12px; }
.editor-alt-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 24px; gap: 8px; align-items: start; margin-bottom: 12px; }
.editor-correct-selector { display: flex; flex-direction: column; align-items: center; font-size: 10px; gap: 5px; padding-top: 28px; cursor: pointer; }
.editor-correct-selector input { width: 17px; height: 17px; margin: 0; }
.editor-alt-text > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.remove-alternative { border: 0; background: none; color: var(--error); font-size: 24px; margin-top: 24px; padding: 0; }
.editor-alternatives .secondary-button { padding: 6px 12px; font-size: 12px; }
.editor-form-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 20px; }
.editor-preview { position: sticky; top: 20px; min-width: 0; }
.preview-question { margin: 16px 0; font-family: var(--serif); font-size: 24px; white-space: pre-wrap; overflow-wrap: anywhere; }
.editor-preview .answer-button { font-size: 13px; cursor: default; }
#editor-preview-explanation { margin-top: 8px; overflow-x: auto; }
#editor-math-status { color: var(--error); margin: 12px 0 0; }
.editor-list-heading { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin: 28px 0 12px; }
.editor-list-heading h3 { font-size: 16px; margin: 0; }
.draft-actions { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 14px; }
.danger-button { color: var(--error); }
.editor-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 18px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.editor-footer p { margin: 0; font-size: 12px; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 8px 2px; margin: 12px 0 !important; }
.question-card h2, .preview-question, .answer-text, #explanation, #correct-answer, .review-item summary > span { overflow-x: auto; }
.katex { font-size: 1.08em !important; }
.typst-math { font-family: math; font-size: 1.08em; white-space: normal; }
.typst-math[display=block] { overflow-x: auto; overflow-y: hidden; padding: 8px 2px; margin: 12px 0; }
.review-item summary > span:not(.review-status) { display: inline-block; max-width: 100%; vertical-align: top; }

/* Administration */
.login-form { max-width: 480px; padding: 24px; background: var(--sidebar); }
.login-note { margin: 20px 0 0; }
.account-session { max-width: 600px; padding: 24px; background: var(--sidebar); margin-top: 24px; }
.login-form label, .admin-upload > label, .admin-metadata label, .admin-editor-controls > label { display: block; font-size: 13px; font-weight: bold; margin: 14px 0 6px; }
.login-form button, .admin-upload > button { margin-top: 20px; }
.admin-intro { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 22px 0; }
.admin-intro p { margin: 0; }
.admin-upload h3 { font-size: 16px; }
.admin-upload input[type=file] { max-width: 100%; font-size: 12px; }
.admin-list-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: 30px 0 10px; }
.admin-list-heading h3 { font-size: 16px; margin: 0; }
.admin-list-heading input { max-width: 280px; }
.admin-bank-card { padding: 20px 0; border-top: 1px solid var(--line); }
.admin-bank-card h4 { font-size: 16px; margin: 0 0 5px; overflow-wrap: anywhere; }
.admin-bank-card p { margin: 0; overflow-wrap: anywhere; }
.admin-metadata { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.admin-metadata label { margin: 12px 0 0; }
.admin-metadata label input, .admin-metadata label select { margin-top: 5px; }
.admin-metadata button { grid-column: 1 / -1; justify-self: start; }
.admin-editor-controls { padding-top: 20px; border-top: 1px solid var(--line); }
.admin-editor-controls p { margin: 5px 0 0; }
.admin-editor-controls select { max-width: 300px; margin-bottom: 15px; }

/* Documentation */
.json-guide { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.json-guide h3 { margin: 0 0 12px; font-family: var(--serif); font-size: 24px; font-weight: normal; }
.json-guide > p { font-size: 14px; color: var(--muted); }
.json-guide summary { cursor: pointer; padding: 8px 0; min-height: 40px; color: var(--link); font-size: 14px; }
.json-example-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; margin-top: 16px; align-items: start; }
.json-guide pre { margin: 0; min-width: 0; padding: 24px; background: var(--sidebar); font-size: 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.json-fields { min-width: 0; font-size: 13px; }
.json-fields h4 { margin: 0 0 16px; font-size: 15px; font-weight: 600; }
.json-fields dl { margin: 0; }
.json-fields dt { margin: 0 0 4px; font-weight: 600; overflow-wrap: anywhere; }
.json-fields dd { margin: 0 0 16px; color: var(--muted); }
.json-fields > p { color: var(--muted); }
.json-guide-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin-top: 16px; font-size: 13px; }
#json-copy-status { margin: 12px 0 0; }
#json-copy-status:empty { display: none; }
.format-page { display: block; max-width: 900px; padding: 40px; margin: auto; background: var(--paper); }
.format-page h1 { font-family: var(--serif); font-size: 34px; font-weight: normal; line-height: 1.3; }
.format-page h2 { font-family: var(--serif); font-size: 24px; font-weight: normal; margin-top: 32px; }
.format-page pre { padding: 24px; background: var(--sidebar); overflow: auto; font-size: 12px; }
.format-page code { font-size: .9em; overflow-wrap: anywhere; }
.format-page table { width: 100%; border-collapse: collapse; font-size: 13px; }
.format-page th, .format-page td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.format-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 32px; }
.format-page .brand { margin: 0; }
.format-page .primary-button { text-decoration: none; }
@media (max-width: 1100px) {
  .json-example-layout { grid-template-columns: minmax(0, 1fr); }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-preview { position: static; padding-top: 20px; border-top: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 235px minmax(0, 1fr); }
  .sidebar { padding: 26px 18px; }
  main { padding: 32px 24px; }
  .site-header { padding: 24px; }
  .site-header p { display: none; }
  #subjects { grid-template-columns: minmax(0, 1fr); }
  .presets { margin-left: 0; }
  .answer-state { max-width: 80px; text-align: right; }
  .start-row { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 700px) {
  .app-shell { display: block; }
  .site-header { align-items: center; flex-wrap: wrap; gap: 16px; padding: 24px; }
  .header-tools { width: 100%; justify-content: space-between; gap: 12px; }
  .site-header .brand { font-size: 30px; }
  .sidebar { padding: 24px; gap: 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin-bottom: 0; }
  .bank-list { max-height: 190px; }
  main { padding: 32px 24px; }
  .intro h2, .results-heading { font-size: 30px; }
  .step-heading { align-items: flex-start; flex-wrap: wrap; }
  .step-heading > button { margin-left: 0; }
  .next-row { align-items: flex-start; flex-direction: column; }
  .question-card h2 { font-size: 24px; }
  .answer-button { flex-wrap: wrap; gap: 8px; padding: 12px 4px; }
  .answer-state { max-width: none; flex-basis: 100%; margin-left: 26px; text-align: left; }
  .editor-footer { align-items: stretch; }
  .editor-footer .result-actions { flex-direction: column; width: 100%; }
  .editor-footer .primary-button, .admin-editor-controls .primary-button { width: 100%; }
  .editor-alt-row { grid-template-columns: 42px minmax(0, 1fr) 20px; gap: 7px; }
  .admin-intro, .admin-list-heading { align-items: stretch; flex-direction: column; }
  .admin-list-heading input { max-width: none; }
  .admin-metadata { grid-template-columns: minmax(0, 1fr); }
  .format-page { padding: 24px 16px; }
  .format-page th, .format-page td { padding: 8px; }
  .editor-meta, .login-form, .account-session, .json-guide pre { padding: 16px; }
}
