:root {
  color-scheme: light;
  --bg: #f7f3ec;
  --paper: #fdfbf7;
  --ink: #3b3029;
  --muted: #80766b;
  --line: #e3dbcf;
  --accent: #8a6d54;
  --card: #423831;
  --card-text: #fcf7ef;
  --green: #52684e;
  --red: #a05847;
  --feedback-known: #00df68;
  --feedback-repeat: #ff3030;
  --feedback-ink: #21140f;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --brand: #65462c;
  --secondary-text: #66594b;
  --hint: #75695d;
  --primary-hover: #57463a;
  --strong-border: #bda78e;
  --secondary-hover: #f1eade;
  --hover-bg: #ede5da;
  --symbol: #c9b69d;
  --hero-note: #938574;
  --search-line: #d4c9ba;
  --search-icon: #958875;
  --topic-hover-line: #bca58a;
  --topic-index: #b9a48a;
  --empty-bg: #eee7dc80;
  --empty-line: #d2c6b5;
  --answer: #f0e6d7;
  --answer-ink: #3b3029;
  --answer-meta: #66594b;
  --grade-muted-bg: #e4e2df;
  --grade-muted-ink: #62615e;
  --grade-muted-line: #b8b5b0;
  --card-focus: #ae9371;
  --card-meta: #cbbfad;
  --card-hint: #d2c4b1;
  --menu-hover: #eee5d8;
  --round-line: #b39b7b;
  --round-ink: #806446;
  --disabled-ink: #bcb2a6;
  --disabled-line: #dcd2c4;
  --repeat-line: #dec7bd;
  --known-line: #c8d0be;
  --disabled-bg: #f9f6f0;
  --known-hover: #edf1e7;
  --repeat-hover: #f5e8e0;
  --progress-bg: #e5dbcd;
  --progress-fill: #9c8567;
  --keyboard-hint: #928777;
  --kbd-line: #ded3c4;
  --result-bg: #e7ebde;
  --login-bg: #ede4d6;
  --field-line: #d5c9b8;
  --error-ink: #864534;
  --error-bg: #f6e6dc;
  --error-line: #e7c7b6;
  --upload-line: #baa487;
  --upload-bg: #f2ecdf;
  --upload-focus: #eee2cf;
  --editor-field: #fffefb;
  --preview-answer: #eee9dd;
  --warning-bg: #f0e6d1;
  --warning-ink: #7b603a;
  --backdrop: #2b241b65;
  --toast-bg: #3b3029;
  --toast-ink: #fff9f0;
  --toast-line: #5d4e41;
  --loading-dot: #aa9070;
  --current-bg: #f0e9dd;
  --past-ink: #74716d;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #211c18;
  --paper: #2b241f;
  --ink: #f4ede3;
  --muted: #c2b3a3;
  --line: #51443a;
  --accent: #d6b18d;
  --card: #352c25;
  --card-text: #faf2e7;
  --green: #b6c5a7;
  --red: #e7b09e;
  --brand: #f0d9bb;
  --secondary-text: #d6c3ad;
  --hint: #c2b3a3;
  --primary-hover: #e6d9c6;
  --strong-border: #9a816c;
  --secondary-hover: #3b3029;
  --hover-bg: #3b3029;
  --symbol: #a18b72;
  --hero-note: #b7a58f;
  --search-line: #766552;
  --search-icon: #bfab92;
  --topic-hover-line: #9a816c;
  --topic-index: #bca78f;
  --empty-bg: #2c241e;
  --empty-line: #776552;
  --answer: #d8c4ac;
  --answer-ink: #3b3029;
  --answer-meta: #5d4c3d;
  --grade-muted-bg: #343331;
  --grade-muted-ink: #afada9;
  --grade-muted-line: #5a5855;
  --card-focus: #dec29f;
  --card-meta: #cbbfad;
  --card-hint: #d2c4b1;
  --menu-hover: #44382f;
  --round-line: #bba389;
  --round-ink: #dec5a9;
  --disabled-ink: #8d7e70;
  --disabled-line: #53473d;
  --repeat-line: #b08065;
  --known-line: #78866b;
  --disabled-bg: #28221d;
  --known-hover: #35412f;
  --repeat-hover: #4a3028;
  --progress-bg: #514337;
  --progress-fill: #d6b18d;
  --keyboard-hint: #b4a48f;
  --kbd-line: #776351;
  --result-bg: #34402e;
  --login-bg: #3a3027;
  --field-line: #8b7663;
  --error-ink: #f1b39f;
  --error-bg: #442b25;
  --error-line: #936652;
  --upload-line: #9b836b;
  --upload-bg: #30281f;
  --upload-focus: #44382b;
  --editor-field: #28211d;
  --preview-answer: #383026;
  --warning-bg: #443525;
  --warning-ink: #eed0a2;
  --backdrop: #0d0b09ba;
  --toast-bg: #e9dfd0;
  --toast-ink: #2b241f;
  --toast-line: #d8c6ae;
  --loading-dot: #cfac84;
  --current-bg: #3b3028;
  --past-ink: #aaa197;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
main:focus { outline: none; }
button { border: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 400; }
h1, h2, h3 { font-family: var(--serif); }
h1 { font-size: clamp(32px, 4.7vw, 60px); line-height: 1.16; letter-spacing: -.04em; }
h2 { font-size: 28px; line-height: 1.3; letter-spacing: -.025em; }
h3 { font-size: 26px; line-height: 1.25; }
.icon { width: 22px; height: 22px; flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font: 14px/1.5 var(--sans); }
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1240px; margin: auto; height: 100px; padding: 0 56px; display: flex; justify-content: space-between; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 22px; font: italic 36px/1 var(--serif); letter-spacing: -.045em; }
.nav-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
.nav-link[aria-current=page] { color: var(--accent); }
#main { max-width: 1240px; min-height: calc(100svh - 195px); margin: auto; padding: 0 56px 64px; }
.site-footer { max-width: 1128px; margin: 0 auto; min-height: 95px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 24px; font-size: 12px; color: var(--muted); }
.footer-right { display: flex; align-items: center; gap: 26px; }
.footer-right a { min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); }
.skip-link { position: fixed; top: -100px; left: 20px; z-index: 10; background: var(--paper); padding: 12px; }
.skip-link:focus { top: 12px; }
.button, .icon-button, .round-button, .grade-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: background .18s, border-color .18s, transform .18s; }
.button { min-height: 48px; padding: 11px 21px; border-radius: 12px; font-size: 14px; line-height: 1.4; font-weight: 500; white-space: nowrap; }
.button.primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.button.secondary { background: var(--paper); border: 1px solid var(--line); }
.button.secondary:hover:not(:disabled) { border-color: var(--strong-border); background: var(--secondary-hover); }
.button.quiet { background: transparent; border: 1px solid transparent; color: var(--muted); }
.button.quiet:hover:not(:disabled) { background: var(--hover-bg); color: var(--ink); }
.button:disabled { opacity: .55; }
.icon-button { width: 44px; min-height: 44px; border-radius: 50%; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--hover-bg); color: var(--ink); }
.text-link { color: var(--accent); text-underline-offset: 5px; display: inline-block; padding: 12px 0; font-size: 14px; }
.text-link:hover { text-decoration: underline; }
.back-link { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; background: none; padding: 0; color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--ink); }
.actions { display: flex; gap: 12px; align-items: center; }
.full-width { width: 100%; }
.library-hero { padding: 74px 0 66px; display: flex; justify-content: space-between; align-items: center; gap: 40px; }
.library-hero h1 { font-size: clamp(40px, 5.1vw, 64px); }
.lead { margin-top: 24px; font-size: 18px; line-height: 1.8; color: var(--muted); }
.hero-note { text-align: center; padding: 0 42px; flex: none; }
.serif-symbol { display: block; font: 88px/.9 var(--serif); font-weight: 400; color: var(--symbol); margin-bottom: 24px; }
.hero-note p { color: var(--hero-note); font: italic 17px/1.6 var(--serif); }
.collection-toolbar { padding: 0 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.collection-toolbar h2 { display: flex; gap: 12px; align-items: baseline; }
.search-field { display: flex; align-items: center; gap: 10px; width: 240px; border-bottom: 1px solid var(--search-line); color: var(--search-icon); }
label.search-field > input[type=search] { background: transparent; border: 0; border-radius: 0; margin-top: 0; min-height: 46px; padding: 10px 0; width: 100%; min-width: 0; font-size: 14px; color: var(--ink); outline-offset: 3px; }
.search-field input::placeholder { color: var(--hint); }
.topic-row { display: flex; gap: 34px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 40px; margin-bottom: 16px; transition: border-color .2s, box-shadow .2s; }
.topic-row:hover { border-color: var(--topic-hover-line); box-shadow: 0 12px 32px #6b533309; }
.topic-index { align-self: flex-start; color: var(--topic-index); font: italic 28px/1.2 var(--serif); }
.topic-body { flex: 1; min-width: 0; }
.topic-body h3 { font-size: 31px; }
.topic-body p { color: var(--muted); margin-top: 12px; font-size: 15px; overflow-wrap: anywhere; }
.topic-meta { color: var(--accent); font-size: 13px; margin-top: 24px; display: flex; align-items: center; gap: 8px; }
.topic-meta .icon { width: 17px; height: 17px; }
.topic-action { display: flex; align-items: center; gap: 25px; background: var(--ink); color: var(--paper); border-radius: 12px; padding: 12px 22px; min-height: 50px; font-size: 14px; }
.library-footnote { margin-top: 24px; font-size: 13px; color: var(--muted); }
.collection-empty { text-align: center; background: var(--empty-bg); border: 1px dashed var(--empty-line); border-radius: 16px; padding: 50px 25px; }
.collection-empty p { margin-top: 12px; color: var(--muted); }
.study-shell { max-width: 920px; margin: auto; padding-top: 24px; }
.study-topline { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.study-tools { display: flex; align-items: center; gap: 10px; }
.study-heading { margin: 25px 0 28px; text-align: center; }
.study-heading h1 { font-size: 38px; line-height: 1.25; }
.study-heading p { margin-top: 9px; color: var(--muted); font-size: 14px; }
.card-frame { position: relative; }
.flashcard { position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; width: 100%; min-height: 440px; padding: 30px 42px 25px; color: var(--card-text); background: var(--card); border-radius: 32px; text-align: left; box-shadow: 0 20px 38px -28px #3c2b2270; touch-action: pan-y; }
.flashcard.is-answer { background: var(--answer); }
.flashcard:focus-visible { outline-color: var(--card-focus); outline-offset: 6px; }
.card-top { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 0; align-items: center; color: var(--card-meta); font-size: 14px; }
.card-top > span:first-child { white-space: nowrap; min-width: 0; }
.card-side { grid-column: 2; text-align: center; font-size: 18px; font-weight: 500; line-height: 1.2; letter-spacing: .08em; text-transform: uppercase; }
.card-copy { display: block; padding: 50px 0; font-size: clamp(23px, 2.8vw, 36px); line-height: 1.5; letter-spacing: -.02em; font-weight: 400; white-space: pre-wrap; overflow-wrap: anywhere; animation: reveal .2s ease-out; }
.card-copy.long-copy { font-size: clamp(19px, 2.1vw, 26px); }
.card-bottom { color: var(--card-hint); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.card-bottom .icon { width: 16px; height: 16px; }
.study-controls { display: flex; align-items: center; justify-content: center; gap: 22px; margin-top: 24px; }
.round-button { width: 58px; height: 58px; border: 1px solid var(--round-line); border-radius: 50%; background: transparent; color: var(--round-ink); }
.round-button:disabled { color: var(--disabled-ink); border-color: var(--disabled-line); }
.round-button:hover:not(:disabled) { background: var(--menu-hover); }
.grade-button { border: 1px solid var(--line); border-radius: 32px; min-height: 58px; min-width: 177px; padding: 12px 22px; background: var(--paper); font-size: 14px; }
.grade-button output { font-variant-numeric: tabular-nums; margin-left: 8px; min-width: 15px; }
.grade-button.repeat { color: var(--red); border-color: var(--repeat-line); }
.grade-button.known { color: var(--green); border-color: var(--known-line); }
.grade-button[data-requires-answer=true] { background: var(--grade-muted-bg); color: var(--grade-muted-ink); border-color: var(--grade-muted-line); }
.grade-button.known:hover:not([aria-disabled=true]) { background: var(--known-hover); }
.grade-button.repeat:hover:not([aria-disabled=true]) { background: var(--repeat-hover); }
.study-progress { max-width: 370px; margin: 27px auto 0; }
.study-progress > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
progress { appearance: none; -webkit-appearance: none; height: 3px; width: 100%; display: block; border: none; border-radius: 4px; background: var(--progress-bg); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--progress-bg); }
progress::-webkit-progress-value { background: var(--progress-fill); border-radius: 4px; transition: width .25s; }
progress::-moz-progress-bar { background: var(--progress-fill); }
.study-restart { display: flex; justify-content: center; margin-top: 18px; }
.session-note { margin-top: 20px; text-align: center; color: var(--muted); font-size: 11px; }
.result-panel { border: 1px solid var(--line); background: var(--paper); border-radius: 28px; padding: 44px; text-align: center; }
.result-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--result-bg); color: var(--green); display: grid; place-items: center; margin: 0 auto 22px; }
.result-mark .icon { width: 30px; height: 30px; }
.result-panel h2 { font-size: 42px; }
.result-panel > p { color: var(--muted); margin-top: 10px; font-size: 15px; }
.result-stats { display: flex; justify-content: center; gap: 60px; padding: 36px 0; margin: 25px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-stats div { display: flex; flex-direction: column; gap: 8px; min-width: 80px; }
.result-stats strong { font: 46px/1 var(--serif); }
.result-stats span { color: var(--muted); font-size: 12px; }
.result-actions { display: flex; align-items: center; flex-direction: column; gap: 12px; }
.result-actions p { color: var(--muted); }
.login-panel { max-width: 405px; padding: 62px 0; margin: auto; text-align: center; }
.login-lock { width: 58px; height: 58px; background: var(--login-bg); border-radius: 50%; display: grid; place-items: center; color: var(--accent); margin: 0 auto 25px; }
.login-panel h1 { font-size: 46px; }
.login-panel > p { color: var(--muted); margin: 17px 0 30px; font-size: 15px; }
.login-panel form { text-align: left; }
.login-panel .full-width { margin-top: 20px; }
.login-panel .text-link { margin-top: 20px; }
label { display: block; font-size: 13px; color: var(--secondary-text); }
input:not([type=checkbox]):not([type=file]), textarea { color: var(--ink); font-size: 15px; }
label > input:not([type=file]):not([type=checkbox]), label > textarea, .password-field { display: block; width: 100%; margin-top: 8px; border-radius: 10px; border: 1px solid var(--field-line); background: var(--paper); }
label > input:not([type=file]):not([type=checkbox]), label > textarea { padding: 13px 15px; }
textarea { resize: vertical; min-height: 74px; }
.password-field { position: relative; }
.password-field input { padding: 13px 92px 13px 15px; border: 0; border-radius: 10px; width: 100%; background: none; }
.password-toggle { position: absolute; right: 6px; top: 4px; min-height: 44px; font-size: 12px; color: var(--muted); background: none; padding: 8px; }
.form-error { padding: 13px 16px; margin: 16px 0; color: var(--error-ink); background: var(--error-bg); border: 1px solid var(--error-line); border-radius: 10px; font-size: 14px; }
.admin-shell { padding-top: 50px; }
.admin-heading { display: flex; justify-content: space-between; align-items: center; gap: 28px; margin-bottom: 52px; }
.admin-heading h1 { font-size: 46px; }
.admin-heading p { margin-top: 13px; font-size: 15px; color: var(--muted); }
.admin-list-heading { display: flex; align-items: baseline; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.admin-list-heading > span { font-size: 13px; color: var(--muted); }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 28px 0; border-bottom: 1px solid var(--line); }
.admin-row-info { min-width: 0; }
.admin-row-info h3 { font-size: 26px; overflow-wrap: anywhere; }
.admin-row-info p { margin-top: 9px; font-size: 13px; color: var(--muted); }
.dot-divider { padding: 0 6px; }
.status.published { color: var(--green); }
.row-actions { display: flex; gap: 8px; align-items: center; }
.editor-shell { max-width: 950px; margin: auto; padding-top: 25px; }
.editor-title { margin: 25px 0 34px; }
.editor-title h1 { font-size: 44px; }
.editor-title p { color: var(--muted); font-size: 14px; margin-top: 14px; }
.editor-meta { display: grid; gap: 20px; }
.drop-zone { position: relative; cursor: pointer; border: 1px dashed var(--upload-line); background: var(--upload-bg); border-radius: 16px; padding: 28px; margin: 30px 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 7px; }
.drop-zone .icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: 9px; }
.drop-zone strong { font-size: 16px; font-weight: 500; }
.drop-zone span { color: var(--muted); font-size: 13px; }
.drop-zone small { color: var(--muted); font-size: 11px; }
.drop-zone input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.drop-zone:focus-within, .drop-zone.dragging { outline: 2px solid var(--accent); outline-offset: 4px; background: var(--upload-focus); }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.preview-heading h2 { display: flex; gap: 12px; align-items: baseline; }
#card-editor { margin-top: 22px; scroll-margin-top: 25px; }
.edit-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 18px; }
.edit-card-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.edit-card-heading h3 { font: 14px/1.5 var(--sans); color: var(--accent); }
.edit-card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.edit-card-fields textarea { background: var(--editor-field); font-size: 14px; }
.card-preview { margin-top: 14px; font-size: 13px; }
.card-preview summary { color: var(--accent); cursor: pointer; min-height: 32px; padding: 5px 0; }
.preview-question, .preview-answer { padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.preview-question { background: var(--card); color: var(--card-text); border-radius: 10px 10px 0 0; }
.preview-answer { background: var(--answer); color: var(--answer-ink); border-radius: 0 0 10px 10px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.pagination span { color: var(--muted); font-size: 13px; }
.editor-save { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 24px 0; border-top: 1px solid var(--line); margin-top: 25px; }
.publish-option { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.publish-option input { accent-color: var(--ink); width: 19px; height: 19px; flex: none; }
.publish-option small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.import-warning { background: var(--warning-bg); border-radius: 12px; padding: 18px; margin: 20px 0; color: var(--warning-ink); font-size: 13px; }
.dialog { max-width: 450px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); color: var(--ink); padding: 32px; box-shadow: 0 20px 90px #0002; }
.dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
.dialog h2 { font-size: 30px; }
.dialog p { color: var(--muted); font-size: 14px; margin: 18px 0 25px; }
.dialog form { margin-top: 24px; }
.dialog .actions { justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: min(540px, calc(100% - 32px)); width: max-content; background: var(--toast-bg); color: var(--toast-ink); border: 1px solid var(--toast-line); border-radius: 12px; padding: 14px 20px; font-size: 13px; z-index: 20; box-shadow: 0 8px 28px #0002; }
.loading, .empty-state { min-height: 420px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; color: var(--muted); }
.empty-state h1 { color: var(--ink); font-size: 38px; }
.loading-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--loading-dot); animation: pulse 1s infinite alternate; }
.no-script { padding: 30px; }
math { font-family: 'Cambria Math', 'STIX Two Math', math, serif; font-size: 1.1em; }
.math-fallback { font-family: var(--sans); font-size: .9em; }
@keyframes reveal { from { opacity: .3; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { to { opacity: .25; } }
@media (min-width: 1440px) { .flashcard { min-height: 470px; } }
@media (max-width: 1000px) {
  .header-inner { padding: 0 32px; }
  #main { padding: 0 32px 50px; }
  .site-footer { margin: 0 32px; }
  .hero-note { padding: 0 10px; }
  .topic-row { padding: 30px; gap: 24px; }
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .admin-row { align-items: flex-start; flex-direction: column; gap: 15px; }
}
@media (max-width: 650px) {
  .header-inner { height: 80px; padding: 0 21px; gap: 16px; }
  .brand { font-size: 31px; }
  .nav-link { font-size: 12px; }
  #main { padding: 0 20px 38px; min-height: calc(100svh - 194px); }
  .site-footer { margin: 0 20px; min-height: 114px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; font-size: 11px; }
  .footer-right { width: 100%; justify-content: space-between; gap: 8px; }
  .library-hero { padding: 48px 0 40px; }
  .library-hero h1 { font-size: 42px; max-width: 330px; }
  .lead { font-size: 15px; margin-top: 20px; }
  .hero-note { display: none; }
  .collection-toolbar { flex-direction: column; align-items: stretch; gap: 16px; }
  .collection-toolbar h2 { font-size: 25px; }
  .search-field { width: 100%; }
  .topic-row { position: relative; padding: 26px 22px; flex-wrap: wrap; gap: 16px; }
  .topic-index { font-size: 21px; }
  .topic-body { flex-basis: calc(100% - 44px); }
  .topic-body h3 { font-size: 27px; }
  .topic-body p { font-size: 13px; }
  .topic-meta { margin-top: 19px; font-size: 12px; }
  .topic-action { margin-top: 5px; margin-left: 37px; min-height: 45px; font-size: 13px; }
  .library-footnote { font-size: 12px; line-height: 1.8; }
  .study-shell { padding-top: 16px; }
  .study-topline { gap: 8px; }
  .back-link { font-size: 12px; gap: 7px; }
  .back-link .icon { width: 18px; height: 18px; }
  .study-tools { gap: 0; }
  .study-tools .button { padding: 8px; font-size: 12px; gap: 7px; }
  .study-tools .button .icon { width: 18px; height: 18px; }
  .study-tools .icon-button { width: 38px; }
  .study-heading { margin: 17px 0 24px; }
  .study-heading h1 { font-size: 30px; }
  .study-heading p { font-size: 12px; max-width: 280px; margin: 8px auto 0; }
  .flashcard { min-height: 355px; padding: 25px 25px 23px; border-radius: 25px; }
  .card-top { font-size: 12px; }
  .card-side { font-size: 16px; }
  .card-copy { font-size: 23px; line-height: 1.55; padding: 37px 0; }
  .card-copy.long-copy { font-size: 18px; }
  .card-bottom { font-size: 11px; }
  .study-controls { gap: 8px; margin-top: 20px; }
  .round-button { width: 44px; height: 48px; flex: none; }
  .grade-button { min-width: 0; flex: 1; padding: 10px 11px; min-height: 48px; gap: 6px; font-size: 12px; }
  .grade-button .icon { width: 18px; height: 18px; }
  .grade-button output { margin-left: 0; min-width: 8px; }
  .study-progress { margin-top: 22px; max-width: 280px; }
  .session-note { font-size: 10px; margin-top: 18px; }
  .result-panel { padding: 28px 19px; border-radius: 24px; }
  .result-panel h2 { font-size: 34px; }
  .result-panel > p { font-size: 13px; }
  .result-stats { gap: 10px; padding: 28px 0; }
  .result-stats div { flex: 1; min-width: 0; }
  .result-stats strong { font-size: 36px; }
  .result-stats span { font-size: 10px; }
  .result-actions .button { width: 100%; font-size: 12px; padding: 12px; }
  .login-panel { padding-top: 45px; }
  .login-panel h1 { font-size: 40px; }
  .admin-shell { padding-top: 30px; }
  .admin-heading { margin-bottom: 34px; gap: 20px; }
  .admin-heading h1, .editor-title h1 { font-size: 36px; }
  .admin-heading p { font-size: 13px; }
  .admin-heading .actions { flex-direction: row-reverse; }
  .admin-list-heading h2 { font-size: 25px; }
  .admin-row-info h3 { font-size: 25px; }
  .row-actions { gap: 3px; flex-wrap: wrap; }
  .row-actions .button { font-size: 12px; padding: 9px 13px; }
  .editor-title p { font-size: 13px; }
  .drop-zone { padding: 24px 18px; }
  .drop-zone strong { font-size: 14px; }
  .drop-zone span { font-size: 12px; }
  .preview-heading h2 { font-size: 24px; }
  .preview-heading .button { font-size: 12px; padding: 8px 0; }
  .edit-card { padding: 17px; }
  .edit-card-fields { grid-template-columns: 1fr; gap: 16px; }
  .editor-save { flex-direction: column; align-items: stretch; gap: 22px; }
  .pagination .button { font-size: 12px; padding: 8px 13px; }
  .pagination span { font-size: 11px; }
  .dialog { padding: 26px; }
}
@media (max-width: 370px) {
  #main { padding-left: 14px; padding-right: 14px; }
  .grade-button { padding: 10px 7px; gap: 4px; }
  .grade-button .icon { width: 16px; height: 16px; }
  .study-controls { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

/* Motion layers: slide/feedback never overwrite the rotor's 3D transform. */
.card-stage { position: relative; overflow: clip; overflow-clip-margin: 40px; }
.card-slide { width: 100%; }
.card-outgoing { position: absolute; inset: 0 0 auto; pointer-events: none; }
.flashcard { display: block; padding: 0; background: transparent; perspective: 1200px; }
.flashcard.is-answer { background: transparent; }
.card-rotor { display: grid; min-height: inherit; transform-style: preserve-3d; }
.card-face { grid-area: 1 / 1; display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; min-width: 0; min-height: 440px; padding: 30px 42px 25px; border-radius: inherit; background: var(--card); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.card-rotor, .card-face { border-radius: inherit; }
.card-answer { transform: rotateY(180deg); background: var(--answer); color: var(--answer-ink); }
.card-answer .card-top, .card-answer .card-bottom { color: var(--answer-meta); }
.card-face .card-copy { animation: none; }
.card-feedback { pointer-events: none; position: absolute; inset: 0; border-radius: inherit; opacity: 0; }
.card-slide[data-feedback=known] { --feedback-fill: var(--feedback-known); }
.card-slide[data-feedback=repeat] { --feedback-fill: var(--feedback-repeat); }
.card-slide[data-feedback] .card-face { background: var(--feedback-fill); color: var(--feedback-ink); }
.card-slide[data-feedback] .card-top, .card-slide[data-feedback] .card-bottom { color: var(--feedback-ink); }
.feedback-known { box-shadow: inset 0 0 0 2px var(--feedback-known), 0 5px 18px #00df6835; }
.feedback-repeat { box-shadow: inset 0 0 0 2px var(--feedback-repeat); }
.card-frame[aria-busy=true] [data-action=flip], .study-controls [aria-disabled=true] { cursor: default; }
.study-shell { overflow-anchor: none; }
.card-hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); z-index: 2; display: flex; align-items: center; flex-direction: column; gap: 10px; width: max-content; max-width: calc(100% - 24px); pointer-events: none; }
.card-hint-label { padding: 9px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.4; text-align: center; box-shadow: 0 8px 22px #0002; }
.card-hint-gesture { position: relative; width: 64px; height: 70px; color: var(--card-text); }
.card-hint-gesture .icon { position: absolute; top: 12px; left: 8px; width: 48px; height: 48px; }
.card-hint-pulse { position: absolute; left: 30px; top: 18px; width: 20px; height: 20px; border: 2px solid currentColor; border-radius: 50%; transform: translate(-50%,-50%); opacity: 0; }
.admin-heading .actions { flex-wrap: wrap; }
.motion-settings { max-width: 920px; margin: auto; }
.motion-fields { max-width: 640px; display: grid; gap: 28px; margin: 30px 0 20px; }
.motion-inputs { display: flex; align-items: flex-start; gap: 24px; margin-top: 8px; }
.motion-range { flex: 1; min-width: 0; }
.motion-range input[type=range] { display: block; width: 100%; height: 44px; margin: 0; padding: 0; border: 0; background: transparent; accent-color: var(--accent); cursor: pointer; }
.motion-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.motion-number { display: flex; align-items: center; gap: 8px; flex: none; }
.motion-number input[type=number] { margin: 0; width: 88px; min-height: 44px; padding: 8px 10px; font-variant-numeric: tabular-nums; }
.motion-number [aria-invalid=true] { border-color: var(--red); }
.motion-save { margin-top: 24px; flex-wrap: wrap; min-height: 48px; }
.motion-save #motion-status { flex-basis: 100%; }
.motion-preview { margin-top: 46px; padding-top: 32px; border-top: 1px solid var(--line); }
.motion-preview > p { margin-top: 12px; }
.motion-preview .card-frame { margin-top: 24px; }
.preview-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 650px) {
  .card-face { min-height: 355px; padding: 25px 25px 23px; }
  .motion-inputs { gap: 14px; }
  .motion-save { align-items: stretch; flex-direction: column; }
  .motion-save #motion-status { flex-basis: auto; }
}

/* Home and schedule use the established paper, serif and native dialog system. */
body.content-dialog-open { overflow: hidden; }
.brand-logo { --logo-height: 68px; display: flex; flex-direction: row; align-items: center; gap: 12px; flex: none; }
.brand-word { display: block; height: var(--logo-height); flex: none; background-color: var(--brand); mask-repeat: no-repeat; mask-position: center; mask-size: contain; mask-mode: alpha; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: contain; }
.brand-elena { width: calc(var(--logo-height) * 508 / 281); mask-image: url('/assets/media/logo-elena.svg'); -webkit-mask-image: url('/assets/media/logo-elena.svg'); }
.brand-baskakova { width: calc(var(--logo-height) * 790 / 281); mask-image: url('/assets/media/logo-baskakova.svg'); -webkit-mask-image: url('/assets/media/logo-baskakova.svg'); }
.theme-toggle { width: 44px; height: 44px; min-width: 44px; min-height: 44px; aspect-ratio: 1; flex: 0 0 auto; padding: 0; color: var(--accent); }
::selection { color: var(--paper); background: var(--ink); }
input, textarea { caret-color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--hint); opacity: 1; }
:root[data-theme=dark] .section-art { filter: brightness(.82) saturate(.85); }
.home-shell { max-width: 920px; margin: auto; padding-top: 54px; }
.home-heading { text-align: center; margin-bottom: 32px; }
.home-heading h1 { font-size: 42px; line-height: 1.25; }
.home-heading p { margin-top: 14px; color: var(--secondary-text); font-size: 15px; }
.upcoming-list, .schedule-group ol { list-style: none; margin: 0; padding: 0; }
.upcoming-list { border-top: 1px solid var(--line); }
.event-button { display: flex; align-items: center; gap: 24px; width: 100%; padding: 22px 16px; border-bottom: 1px solid var(--line); background: transparent; text-align: left; border-radius: 0; transition: background .18s; }
.event-button:hover { background: var(--paper); }
.event-button time, .schedule-event time { flex: 0 0 112px; font: 20px/1.35 var(--serif); color: var(--secondary-text); font-variant-numeric: tabular-nums; }
.event-copy { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 0; }
.event-discipline { font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.event-kind { font-size: 12px; line-height: 1.6; color: var(--secondary-text); }
.event-button > .icon { color: var(--accent); width: 18px; height: 18px; }
.schedule-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 12px; }
.schedule-footer .text-link { display: inline-flex; gap: 8px; align-items: center; background: transparent; color: var(--secondary-text); }
.schedule-footer .webinar-link { margin-left: auto; }
.schedule-footer .icon { width: 17px; height: 17px; }
.schedule-note { max-width: 360px; font-size: 12px; line-height: 1.6; color: var(--hint); }
.schedule-message { padding: 36px 20px; text-align: center; color: var(--hint); font-size: 15px; }
.schedule-message .button { margin-top: 18px; }
.home-sections { margin-top: 58px; }
.home-sections h2 { margin-bottom: 24px; }
.section-card { display: grid; grid-template-columns: 44% 1fr; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--paper); transition: border-color .2s; }
.section-card:hover { border-color: var(--topic-hover-line); }
.section-art { display: block; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 3/2; }
.section-card-copy { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 24px; padding: 38px; min-width: 0; }
.section-card-title { font: 32px/1.25 var(--serif); overflow-wrap: anywhere; }
.section-card-action { display: inline-flex; align-items: center; gap: 12px; color: var(--accent); font-size: 14px; }
.section-card-action .icon { width: 18px; height: 18px; }
.schedule-dialog { max-width: 760px; max-height: calc(100dvh - 40px); padding: 0; overflow: hidden; }
.content-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 24px 28px; border-bottom: 1px solid var(--line); }
.content-dialog-heading h2 { min-width: 0; }
.dialog-close { display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px; aspect-ratio: 1; flex: 0 0 auto; padding: 0; border-radius: 50%; color: var(--ink); background: transparent; }
.dialog-close:hover { background: var(--hover-bg); }
.schedule-scroll { position: relative; max-height: calc(100dvh - 150px); overflow-y: auto; overscroll-behavior: contain; padding: 24px 28px 32px; scrollbar-color: var(--strong-border) var(--paper); }
.schedule-group + .schedule-group { margin-top: 32px; }
.schedule-group h3 { font-size: 23px; margin-bottom: 12px; }
.schedule-event { display: flex; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.schedule-event time { font-size: 18px; flex-basis: 100px; }
.event-details { white-space: pre-wrap; font-size: 12px; line-height: 1.65; margin-top: 6px; color: var(--secondary-text); }
.schedule-group.past { color: var(--past-ink); }
.schedule-group.past time, .schedule-group.past .event-kind, .schedule-group.past .event-details { color: var(--past-ink); }
.schedule-group.current { padding: 22px; background: var(--current-bg); border-radius: 16px; }
.schedule-group.current .schedule-event:last-child { border-bottom: 0; padding-bottom: 0; }
.schedule-undated { margin-top: 32px; }
.schedule-undated h3 { font-size: 23px; margin-bottom: 14px; }
.schedule-undated p { font-size: 13px; margin: 0 0 14px; }
.schedule-undated strong { font-weight: 500; color: var(--ink); }
.schedule-undated span { display: block; white-space: pre-wrap; margin-top: 6px; }
@media (max-width: 650px) {
  .brand-logo { --logo-height: 42px; gap: 8px; }
  .home-shell { padding-top: 36px; }
  .home-heading h1 { font-size: 32px; }
  .home-heading p { font-size: 13px; }
  .event-button { padding: 18px 0; gap: 12px; }
  .event-button time { flex-basis: 72px; font-size: 18px; }
  .event-discipline { font-size: 14px; }
  .event-kind { font-size: 11px; }
  .schedule-footer { align-items: flex-start; flex-direction: column; gap: 4px; }
  .home-sections { margin-top: 40px; }
  .section-card { grid-template-columns: 1fr; }
  .section-art { height: auto; }
  .section-card-copy { padding: 26px 24px; gap: 18px; }
  .section-card-title { font-size: 28px; }
  .schedule-dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); }
  .content-dialog-heading { padding: 16px; }
  .content-dialog-heading h2 { font-size: 27px; }
  .schedule-scroll { padding: 18px 16px 24px; max-height: calc(100dvh - 110px); }
  .schedule-event { flex-direction: column; gap: 8px; }
  .schedule-event time { flex-basis: auto; }
  .schedule-group.current { padding: 16px; }
}
