.topbar { min-height: 58px; }
#screen > .button, .choices { margin-top: 12px; }
#screen > .subtitle { margin-bottom: 10px; }
.quick,.format { display:grid; align-content:start; gap:6px; min-height:88px; padding:12px; }
.quick img { width:42px; height:42px; object-fit:contain; }
.format-icon { display:grid; width:42px; height:42px; place-items:center; border-radius:12px; color:var(--accent); background:var(--soft); }
.format { min-height:126px; }
.format h2 { font-size:20px; }
.format.highlight { background:var(--accent); color:var(--on,#fff); }
.format.highlight small { color:inherit; }
.format.highlight .format-icon { color:inherit; background:color-mix(in srgb,currentColor 14%,transparent); }
.panel fieldset { border:0; padding:0; }
.panel legend { font-weight:700; }
.panel label,.answer { display:flex; gap:10px; align-items:center; min-height:44px; }
.setup-hint { display:flex; align-items:flex-start; gap:9px; margin:10px 4px 0; color:var(--muted); font-size:14px; line-height:1.4; }
.setup-hint .icon { width:18px; height:18px; color:var(--accent); }
.answer { padding:8px 14px; margin:8px 0; }
.answer:has(:checked) { background:var(--soft); border-color:var(--accent); }
input:is([type="checkbox"],[type="radio"]) { width:20px; height:20px; flex:none; accent-color:var(--accent); }
button:disabled { opacity:.55; cursor:default; }
.badge { color:var(--accent); margin-bottom:10px; font-weight:700; font-size:14px; }
.feedback { padding:9px 12px; border-radius:12px; margin:8px 0; background:var(--soft); font-weight:700; }
.feedback.right { border-left:3px solid #23805b; }
.feedback.incorrect { border-left:3px solid #a53449; }
:root[data-theme="dark"] .format.highlight { color:#102438; }

:root[data-theme='burgundy'] {
  --bg: #f8f7f5;
  --text: #24282d;
  --muted: #62666a;
  --accent: #752b40;
  --soft: #f2eeeb;
  --border: #ddd6d3;
}

[data-section='study'] .shell { max-width: 480px; }
[data-section='study'] .topbar > span { font-size: 16px; }
[data-section='study'] .topbar .circle { min-width: 40px; min-height: 40px; }
[data-section='study'] .topbar.study-home-header { display: grid; grid-template-columns: 1fr 44px 44px; gap: 10px; }
[data-section='study'] .topbar.study-home-header > span { color: var(--accent); font-size: 26px; text-align: start; }
[data-section='study'] .card { border-color: var(--border); }
.home-content h1 { margin: 4px 4px 14px; font-size: clamp(25px,7.7vw,30px); }
.home-content > .subtitle { margin: 0 4px 12px; }
.home-hero { position: relative; min-height: 212px; padding: 17px 18px 12px; overflow: hidden; }
.home-first .home-hero { min-height: 230px; }
.home-return .home-hero { min-height: 177px; }
:root[data-theme='burgundy'] .home-hero { background: linear-gradient(160deg,#8c3c55,#642139); }
.home-hero > div { position: relative; z-index: 1; max-width: 76%; }
.home-hero small { display: inline-block; padding: 7px 8px; border-radius: 22px; background: var(--surface); color: var(--text); font-size: 14px; }
.home-hero h2 { margin-block: 8px 4px; color: inherit; font-size: clamp(24px,8vw,32px); }
.home-hero p { margin: 2px 0 13px; color: inherit; line-height: 18px; }
.home-hero img { position: absolute; inset: 34px 14px auto auto; width: 98px; height: 90px; object-fit: contain; }
.home-hero > .button { position: relative; grid-column: 1 / -1; margin-top: 10px; }
.home-stat { min-height: 112px; display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; margin-top: 14px; }
.home-stat strong { font: 700 36px/42px 'PT Serif',Georgia,serif; margin-right: 8px; }
.home-stat small { display: block; margin-top: 5px; }
.home-ring { display: grid; width: 66px; height: 66px; place-items: center; border: 8px solid var(--accent); border-radius: 50%; }
.home-no-score { display: flex; align-items: center; gap: 18px; margin-top: 12px; padding: 15px 22px; border-radius: 22px; background: var(--soft); }
.home-no-score .icon, .home-topics .icon, .home-topic-heading a { color: var(--accent); }
.home-topic-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 19px 4px 9px; }
.home-topic-heading h2 { margin: 0; font: 700 22px/28px 'PT Serif',Georgia,serif; }
.home-topic-heading a { font-size: 12px; font-weight: 700; }
.home-topics .card { display: grid; gap: 5px; min-height: 94px; padding: 12px 15px; }
.home-topics .card b { font: 700 17px/22px 'PT Serif',Georgia,serif; }
.home-topics .card small { color: var(--muted); font-size: 12px; }
.home-shortcuts { display: grid; gap: 8px; margin-top: 12px; }

.practice-content { padding: 0 3px; }
.practice-content h1 { margin: 10px 0 7px; font-size: clamp(20px,5.75vw,23px); }
.practice-content > h2 { font: 700 24px/30px 'PT Serif',Georgia,serif; }
.practice-content > .subtitle { margin-bottom: 16px; font-size: 16px; }
.practice-content .search { border-radius: 40px; min-height: 46px; }
.formats { gap: 12px 10px; margin: 18px 0 20px; }
.format { position: relative; min-height: 162px; padding: 16px; border-radius: 24px; }
.format-icon { width: 52px; height: 52px; border-radius: 17px; }
.format-icon .icon { width: 28px; height: 28px; }
.format h2 { margin: 10px 0 0; font: 700 clamp(18px,5.8vw,23px)/27px 'PT Serif',Georgia,serif; }
.format small { font-size: 12px; text-wrap: balance; }
.format-chevron { position: absolute; inset: auto 16px 11px auto; font-size: 23px; }
.practice-content:not(.choose-topic) #topic-results { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.practice-content:not(.choose-topic) #topic-results small { display: none; }
.practice-content .stat-row { min-height: 55px; margin: 0; font-size: 14px; }
.practice-content .stat-row > img { width: 30px; height: 30px; }
.choose-topic .stat-row { min-height: 66px; margin-bottom: 10px; }
.choose-topic .stat-row b { font: 700 18px/23px 'PT Serif',Georgia,serif; }
.topic-filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 9px; scrollbar-width: none; }
.topic-filters button { min-height: 38px; padding: 5px 12px; border: 0; border-radius: 24px; background: var(--surface); color: var(--text); font-size: 12px; white-space: nowrap; }
.topic-filters button[aria-pressed='true'] { background: var(--accent); color: var(--on,#fff); }

#screen[data-view='setup'], #screen[data-view='modes'] { min-height: calc(100dvh - 76px); }
.training-setup { display: flex; min-height: inherit; flex-direction: column; gap: 15px; padding: 0 4px; }
.training-setup h2 { margin: 4px 0 0; font: 700 18px/24px 'PT Serif',Georgia,serif; }
.setup-topic { display: flex; align-items: center; gap: 22px; padding: 8px; }
.setup-topic.card { min-height: 78px; background: var(--soft); padding-inline: 18px; }
.setup-topic h1 { margin: 0 0 4px; font-size: 27px; }
.setup-topic p { margin: 0; }
.setup-topic .icon { color: var(--accent); }
.study-counts { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 0; }
.study-counts button { min-width: 0; padding: 6px; font-size: 16px; font-weight: 700; }
.study-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.study-modes .button .icon { width: 20px; height: 20px; color: inherit; }
.mode-cards { grid-template-columns: 1fr; }
.mode-cards .button { justify-content: start; min-height: 54px; padding-inline: 18px; }
.study-switches { padding: 10px 16px; }
.study-switches label { justify-content: space-between; font-size: 14px; font-weight: 700; }
.study-switch input { appearance: none; position: relative; width: 44px; height: 26px; margin: 0; border-radius: 20px; background: var(--border); cursor: pointer; }
.study-switch input::after { position: absolute; inset: 3px auto 3px 3px; width: 20px; border-radius: 50%; background: #fff; content: ''; }
.study-switch input:checked { background: var(--accent); }
.study-switch input:checked::after { transform: translateX(18px); }
.training-setup .setup-hint { margin-top: auto; padding-block: 12px; }
.custom-topics { border: 0; margin: 0; padding: 0; }
.custom-topics legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.custom-topics label { display: flex; align-items: center; gap: 18px; min-height: 64px; border-bottom: 4px solid var(--soft); padding: 8px; }
.custom-summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 12px; font-size: 14px; }
.study-bottom { display: grid; gap: 12px; margin-top: auto; padding: 13px 0 max(6px,env(safe-area-inset-bottom)); background: var(--bg); }
.study-bottom .button { min-height: 48px; }
#screen:is([data-view='question'],[data-view='feedback']) { display: flex; min-height: calc(100dvh - 76px); flex-direction: column; }
.study-progress { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; margin: 4px 4px 13px; font-size: 14px; }
.study-progress > b:first-child { grid-column: 1 / 2; }
.study-progress > b:only-of-type { grid-column: 1 / -1; }
[data-section='study'] progress { width: 100%; height: 9px; border: 0; border-radius: 8px; overflow: hidden; background: var(--soft); accent-color: var(--accent); }
[data-section='study'] progress::-webkit-progress-bar { background: var(--soft); }
[data-section='study'] progress::-webkit-progress-value { background: var(--accent); border-radius: 8px; }
.study-question { padding: 14px 12px 8px; }
.question-chip { display: inline-block; padding: 7px 15px; border-radius: 18px; box-shadow: var(--shadow); color: var(--muted); font-size: 12px; }
.study-question-title { display: grid; grid-template-columns: minmax(0,1fr) min(28%,96px); align-items: center; gap: 8px; }
.study-question-title h1 { margin: 10px 0; font-size: 22px; }
.study-question-title > img { width: 100%; height: 82px; object-fit: contain; }
.study-question-title > .subtitle { grid-row: 2; }
.study-question .answer { margin: 6px 0; box-shadow: none; font-size: 16px; }
.study-hint { display: flex; align-items: center; gap: 16px; margin-block: 10px; padding: 12px 16px; border-radius: 18px; background: var(--soft); text-align: start; }
.study-hint .icon { color: var(--accent); }
.study-hint small { display: block; margin-top: 3px; }
.feedback-hero { margin-bottom: 14px; padding: 20px; border-radius: 24px; background: #e4f3e9; text-align: center; color: #22674e; }
.feedback-hero.incorrect { background: #f9e9ed; color: #9f2e44; }
.feedback-hero h1 { color: inherit; margin-block: 9px; font-size: 28px; }
.feedback-hero p { color: inherit; font-weight: 700; }
.feedback-mark { display: inline-grid; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: #22674e; color: #fff; font-size: 26px; }
.feedback-hero.incorrect .feedback-mark { background: #9f2e44; }
.feedback-hero.compact .feedback-mark { width: 70px; height: 70px; font-size: 31px; }
.explanation, .feedback-choices { margin-bottom: 12px; padding: 15px 17px; }
.explanation h2, .feedback-choices h2 { margin: 0 0 8px; font: 700 18px/22px 'PT Serif',Georgia,serif; }
.explanation h2 { display: flex; align-items: center; gap: 12px; }
.explanation .icon { color: var(--accent); }
.feedback-option { display: flex; justify-content: space-between; margin: 5px 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 15px; }
.feedback-option.right { background: #e4f3e9; color: #22674e; }
.feedback-option.selected { background: var(--soft); }
.feedback-option small { font-size: 11px; }
.practice-state { text-align: center; }
.practice-state > img { display: block; width: min(220px,94%); height: 170px; object-fit: contain; margin: 0 auto 12px; }
.practice-state h1 { font-size: 25px; }
.practice-state > .button { margin-block: 11px; }
.practice-state .explanation { text-align: start; }
.mistake-setup .study-question-title, .paused-study .study-question-title { margin: 10px 0 15px; }
.mistake-setup .study-question-title h1, .paused-study .study-question-title h1 { font-size: 28px; }
.paused-study > .button { margin-top: 10px; }
#pause, #exit-training { position: fixed; inset: auto 0 0; width: min(calc(100% - 40px),430px); margin: 0 auto max(20px,env(safe-area-inset-bottom)); border: 1px solid var(--border); border-radius: 26px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#pause::backdrop, #exit-training::backdrop { background: rgb(20 14 19 / 28%); backdrop-filter: blur(3px); }
#pause form, #exit-training form { text-align: center; }
#pause form > img { display: block; object-fit: contain; margin: 6px auto 12px; }
#pause h2, #exit-training h2 { font: 700 27px/32px 'PT Serif',Georgia,serif; }
#pause p, #exit-training p { color: var(--muted); }
#pause .column { display: grid; gap: 8px; }
.study-dialog-close { position: absolute; inset: 8px 8px auto auto; font-size: 22px; }
.exit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
