:root {
  color-scheme: light;
  --ink: #202821;
  --muted: #69736b;
  --line: #e2e5df;
  --paper: #fff;
  --canvas: #f5f6f2;
  --green: #185b43;
  --green-dark: #124733;
  --green-soft: #e6f0e9;
  --gold: #d08a24;
  --danger: #a63b31;
  --shadow: 0 16px 48px rgb(24 42 30 / 7%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #77ae91; outline-offset: 3px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 12px max(24px, calc((100vw - 1160px) / 2)); border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 94%); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 12px; background: var(--green); color: white; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.main-nav { display: flex; align-items: center; gap: 4px; }
.nav-link { min-height: 38px; padding: 8px 12px; border: 0; border-radius: 9px; background: transparent; color: #657068; font-size: 12px; font-weight: 750; }
.nav-link:hover, .nav-link.is-active { background: #edf3ee; color: var(--green); }
.nav-link.is-active { box-shadow: inset 0 0 0 1px #dbe7de; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.active-bank-control { display: grid; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 750; }
.active-bank-control select { max-width: 220px; min-height: 36px; padding: 6px 28px 6px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 750; }
.active-bank-control select:disabled { opacity: .6; }
.storage-indicator { color: var(--muted); font-size: 12px; }
.app-shell { width: min(1160px, calc(100% - 40px)); min-height: calc(100vh - 73px); margin: 0 auto; padding: 42px 0 72px; }
.loading-view { display: grid; min-height: 60vh; place-content: center; justify-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 32px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 9px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 700px; margin-bottom: 12px; font-size: clamp(34px, 5vw, 54px); line-height: 1.04; letter-spacing: -.055em; }
.hero-copy { max-width: 580px; margin: 0; color: var(--muted); line-height: 1.6; }
.countdown { min-width: 170px; padding: 18px 20px; border: 1px solid #dce8df; border-radius: 18px; background: var(--green-soft); text-align: center; }
.countdown strong { display: block; color: var(--green); font-size: 37px; line-height: 1; letter-spacing: -.05em; }
.countdown span { display: block; margin-top: 7px; color: #557362; font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.bank-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.bank-choice-card { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.bank-choice-card.is-active { border-color: #8bb59a; box-shadow: 0 0 0 2px rgb(39 104 63 / 8%); }
.bank-choice-heading { display: flex; align-items: center; gap: 9px; color: var(--ink); font-size: 16px; font-weight: 800; }
.bank-choice-heading strong { margin-left: auto; color: var(--muted); font-size: 11px; }
.active-badge { padding: 4px 7px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 800; }
.bank-choice-metrics { display: flex; flex-wrap: wrap; gap: 9px; color: var(--muted); font-size: 11px; }
.bank-choice-error { color: var(--danger); }
.stat-card { padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.stat-card span { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin-top: 9px; font-size: 27px; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 16px; align-items: start; }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: 19px; background: var(--paper); box-shadow: 0 3px 14px rgb(24 42 30 / 2%); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.panel-heading h2, .panel h2 { margin-bottom: 5px; font-size: 20px; letter-spacing: -.03em; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 19px; padding: 5px; border-radius: 12px; background: #f0f2ed; }
.mode-option { position: relative; }
.mode-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mode-option span { display: block; padding: 10px; border: 1px solid transparent; border-radius: 9px; color: var(--muted); text-align: center; font-size: 13px; font-weight: 700; cursor: pointer; }
.mode-option input:checked + span { border-color: var(--line); background: white; color: var(--green); box-shadow: 0 2px 5px rgb(30 49 36 / 7%); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 7px; color: #455149; font-size: 12px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.field input, .field select, .answer-input, .answer-select { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid #d9ded8; border-radius: 10px; background: #fff; color: var(--ink); }
.field input::placeholder { color: #9ca59d; }
.filter-toggle { display: inline-flex; align-items: center; gap: 7px; margin: 17px 0 0; padding: 0; border: 0; background: none; color: var(--green); font-size: 12px; font-weight: 750; }
.filter-grid { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 750; transition: background .15s ease, transform .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); }
.button-quiet { border-color: var(--line); background: #fff; color: #465249; }
.button-quiet:hover { background: #f6f8f5; }
.button-danger { background: var(--danger); color: white; }
.button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.button-large { min-height: 48px; padding-inline: 22px; font-size: 14px; }
.round-note { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.progress-card { display: grid; gap: 13px; }
.progress-row { display: flex; justify-content: space-between; gap: 15px; color: #526057; font-size: 13px; }
.progress-row strong { color: var(--ink); }
.progress-bar { height: 8px; overflow: hidden; border-radius: 99px; background: #edf0eb; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.notice { margin: 0 0 18px; padding: 12px 15px; border: 1px solid #ead6ad; border-radius: 12px; background: #fff9ec; color: #765416; font-size: 13px; line-height: 1.5; }
.notice-error { border-color: #efc9c4; background: #fff3f1; color: #8d322a; }
.notice-info { border-color: #d5e3da; background: #f1f7f2; color: #315f44; }
.notice strong { font-weight: 800; }
.cloud-alert { width: min(1160px, calc(100% - 28px)); margin: 14px auto 0; overflow-wrap: anywhere; }
.cloud-alert[hidden] { display: none; }
.practice-top { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.practice-top .eyebrow { margin-bottom: 5px; }
.practice-progress { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.practice-progress strong { color: var(--ink); }
.practice-card { max-width: 850px; margin: 0 auto; padding: clamp(22px, 5vw, 44px); border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.question-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tag { padding: 5px 9px; border-radius: 99px; background: #eef3ef; color: #41624e; font-size: 11px; font-weight: 750; }
.tag-neutral { background: #f0f1ee; color: #6b746d; }
.question-title { margin-bottom: 12px; font-size: clamp(22px, 3vw, 30px); line-height: 1.24; letter-spacing: -.035em; }
.question-prompt { margin: 0 0 25px; color: #465149; font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.question-prompt p:last-child { margin-bottom: 0; }
.question-prompt table, .review-table { width: 100%; margin: 14px 0; border-collapse: collapse; font-size: 13px; }
.question-prompt th, .question-prompt td, .review-table th, .review-table td { padding: 9px 11px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.question-prompt th, .review-table th { background: #f3f5f1; }
.question-prompt img, .answer-content img { display: block; max-width: 100%; max-height: 520px; object-fit: contain; margin: 16px auto; border-radius: 10px; }
.question-asset { width: fit-content; max-width: 100%; margin: 18px auto 22px; padding: 10px; border: 1px solid var(--line); border-radius: 13px; background: #fafbf9; }
.question-asset img { display: block; max-width: 100%; max-height: 560px; object-fit: contain; border-radius: 8px; }
.question-asset figcaption { margin: 8px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.required-asset-status { max-width: 760px; margin: 14px 0; }
.choice-list { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.choice-option { display: flex; align-items: flex-start; gap: 12px; padding: 14px 15px; border: 1px solid #e0e4df; border-radius: 12px; background: #fff; cursor: pointer; line-height: 1.5; transition: border-color .15s, background .15s; }
.choice-option:hover { border-color: #a8c5b2; background: #fbfdfb; }
.choice-option:has(input:checked) { border-color: #75a489; background: #f1f8f3; }
.choice-option input { flex: none; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--green); }
.choice-letter { display: grid; flex: none; width: 24px; height: 24px; place-items: center; border-radius: 7px; background: #f0f2ed; color: #59635b; font-size: 11px; font-weight: 800; }
.choice-content { min-width: 0; }
.answer-section { display: grid; gap: 15px; margin-top: 20px; }
.answer-hint { margin: 0; color: var(--muted); font-size: 12px; }
.order-list { display: grid; gap: 9px; padding: 0; list-style: none; counter-reset: order; }
.order-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 9px 10px 9px 14px; border: 1px solid var(--line); border-radius: 11px; counter-increment: order; }
.order-item::before { content: counter(order); display: grid; width: 25px; height: 25px; place-items: center; border-radius: 8px; background: #eef3ef; color: var(--green); font-size: 11px; font-weight: 800; }
.order-item > span { flex: 1; line-height: 1.45; }
.order-controls { display: flex; gap: 5px; }
.icon-button { display: grid; width: 33px; height: 33px; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: white; color: #405247; font-size: 15px; }
.icon-button:disabled { opacity: .35; cursor: default; }
.match-row, .group-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, .9fr); align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; }
.match-label, .group-label { line-height: 1.45; }
.group-choices { display: grid; gap: 9px; }
.confidence { display: grid; gap: 9px; margin-top: 23px; padding: 16px; border: 1px solid #e8e8dd; border-radius: 13px; background: #fbfbf5; }
.confidence legend { padding: 0 4px; color: #514c35; font-size: 12px; font-weight: 800; }
.confidence-options { display: flex; flex-wrap: wrap; gap: 8px; }
.confidence-option { position: relative; }
.confidence-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.confidence-option span { display: block; padding: 9px 12px; border: 1px solid #e2e2d6; border-radius: 9px; background: white; color: #615e4d; font-size: 12px; font-weight: 700; cursor: pointer; }
.confidence-option input:checked + span { border-color: #d3ae60; background: #fff5da; color: #705315; }
.confidence-option input:focus-visible + span { outline: 3px solid #77ae91; outline-offset: 2px; }
.answer-error { min-height: 17px; margin: 0; color: var(--danger); font-size: 12px; }
.question-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.question-actions .right-actions { display: flex; gap: 9px; }
.submitted-note { margin: 12px 0 0; color: var(--green); font-size: 12px; font-weight: 700; }
.review-header { margin-bottom: 22px; }
.review-header h1 { font-size: clamp(32px, 4vw, 43px); }
.review-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 15px 0 0; }
.summary-chip { padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: white; color: #536057; font-size: 12px; }
.review-list { display: grid; gap: 14px; }
.review-item { padding: 21px 23px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.review-item h2 { margin-bottom: 10px; font-size: 18px; }
.result-label { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 13px; padding: 6px 9px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.result-correct { background: #e7f4ea; color: #21603b; }
.result-wrong { background: #fff0ed; color: #9b3b30; }
.result-ungraded { background: #eef1f2; color: #45545b; }
.answer-content { display: grid; gap: 7px; color: #48544b; font-size: 13px; line-height: 1.55; }
.answer-content strong { color: #303b33; }
.explanation { margin: 14px 0 0; padding: 13px 15px; border-left: 3px solid #86ae92; border-radius: 0 10px 10px 0; background: #f4f8f4; color: #495b4d; font-size: 13px; line-height: 1.6; }
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 21px; }
.empty-state { padding: 34px 24px; border: 1px dashed #cbd4cc; border-radius: 17px; background: white; text-align: center; }
.empty-state h2 { margin-bottom: 8px; font-size: 21px; }
.empty-state p { max-width: 470px; margin: 0 auto 18px; color: var(--muted); line-height: 1.6; }
.footer-note { margin: 22px 0 0; color: #7b847d; font-size: 11px; line-height: 1.6; }
.dialog { width: min(480px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 24px 100px rgb(15 28 19 / 30%); }
.dialog::backdrop { background: rgb(17 31 21 / 48%); backdrop-filter: blur(3px); }
.dialog-card { position: relative; padding: 28px; }
.dialog-card h2 { margin-bottom: 9px; font-size: 24px; letter-spacing: -.035em; }
.dialog-card p:not(.eyebrow):not(.form-note) { color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border: 0; border-radius: 9px; background: #f1f3ef; color: #59635b; font-size: 22px; }
.file-picker { display: inline-flex; margin-top: 8px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--green); font-size: 13px; font-weight: 750; cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.form-note { min-height: 19px; margin: 11px 0 0; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.import-preview { display: grid; gap: 8px; margin-top: 16px; padding: 16px; border: 1px solid #dce8df; border-radius: 12px; background: #f6f8f5; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.backup-actions .button { font-size: 11px; }
.import-preview p { margin: 0; color: #566158; font-size: 13px; line-height: 1.5; }
.error-screen { max-width: 700px; margin: 8vh auto; padding: 28px; border: 1px solid #efc9c4; border-radius: 18px; background: #fff; }
.error-screen h1 { font-size: 31px; }
.error-screen p { color: var(--muted); line-height: 1.6; }
.storage-locked { display: grid; gap: 10px; margin-bottom: 18px; }
.bank-tools { margin-top: 18px; }
.confidence-practice { display: grid; gap: 10px; margin-top: 14px; padding: 16px; border: 1px solid #d9e6dc; border-radius: 13px; background: #f7faf6; }
.confidence-practice h3 { margin: 0; font-size: 16px; }
.confidence-practice .round-note { margin: 0; }
.bank-list { display: grid; gap: 9px; margin-top: 18px; }
.bank-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.bank-row-copy { min-width: 0; }
.bank-row-copy strong { display: block; margin-bottom: 5px; }
.bank-row-copy p { margin: 0 0 6px; color: #4f5b52; font-size: 13px; line-height: 1.45; }
.bank-row-copy small { color: var(--muted); font-size: 11px; }
.bank-row-copy .retired-question-note { display: block; margin: 3px 0 6px; color: #8a4f20; font-weight: 750; }
.bank-row-actions { display: flex; gap: 7px; }
.bank-row-actions .button { min-height: 36px; padding: 7px 10px; font-size: 11px; }
.note-input { width: 100%; min-height: 100px; padding: 12px; border: 1px solid #d9ded8; border-radius: 10px; resize: vertical; }
.question-detail { margin-top: 15px; }
.detail-answer { margin: 22px 0; padding: 16px; border-radius: 12px; background: #f6f7f4; }
.detail-answer h2 { margin-bottom: 10px; }
.detail-answer p { margin-bottom: 8px; }
.daily-list { display: grid; gap: 8px; }
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 11px 0; border-bottom: 1px solid var(--line); color: #4c584f; font-size: 13px; }
.progress-row:last-child { border-bottom: 0; }
.progress-row strong { color: var(--ink); text-align: right; }
@media (max-width: 760px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand right" "nav nav"; min-height: 64px; padding: 10px 16px; gap: 8px 12px; }
  .brand { grid-area: brand; min-width: 0; }
  .main-nav { grid-area: nav; gap: 1px; }
  .topbar-right { grid-area: right; min-width: 0; justify-content: flex-end; gap: 8px; }
  .active-bank-control { min-width: 0; }
  .active-bank-control select { width: 100%; min-width: 0; max-width: 190px; }
  .nav-link { min-height: 35px; padding: 7px 8px; font-size: 11px; }
  .storage-indicator { display: none; }
  .app-shell { width: min(100% - 28px, 620px); padding-top: 28px; }
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .countdown { justify-self: start; min-width: 150px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stat-card { padding: 15px; }
  .stat-card strong { font-size: 24px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .practice-card { padding: 22px 17px; }
  .match-row, .group-row { grid-template-columns: 1fr; gap: 9px; }
  .question-actions { align-items: stretch; flex-direction: column-reverse; }
  .question-actions .right-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .question-actions > .button { width: 100%; }
  .bank-row { grid-template-columns: auto minmax(0, 1fr); }
  .bank-row-actions { grid-column: 2; }
  .progress-row { align-items: flex-start; flex-direction: column; gap: 5px; }
  .progress-row strong { text-align: left; }
}
@media (max-width: 540px) {
  .topbar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "right" "nav"; justify-content: stretch; }
  .topbar-right { justify-content: space-between; gap: 8px; }
  .active-bank-control { flex: 1; }
  .active-bank-control select { max-width: 190px; min-height: 34px; font-size: 10px; }
  .main-nav { width: 100%; justify-content: center; border-top: 1px solid var(--line); padding-top: 6px; }
}
@media (max-width: 430px) {
  .brand-mark { width: 34px; height: 34px; }
  .brand strong { font-size: 13px; }
  .topbar-right .button { min-height: 37px; padding: 8px 10px; font-size: 11px; }
  .field-grid { grid-template-columns: 1fr; }
  .bank-choice-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .practice-top { align-items: flex-start; flex-direction: column; }
  .confidence-options { display: grid; grid-template-columns: 1fr; }
}
/* Mobile and touch refinements for phone practice. */
@media (pointer: coarse) {
  button,
  .nav-link,
  .button,
  .icon-button,
  .filter-toggle,
  .confidence-option span,
  .mode-option span,
  .file-picker,
  .dialog-close {
    min-height: 44px;
  }

  .icon-button { width: 44px; }
  .choice-option { min-height: 52px; }
  .match-row select,
  .group-row select,
  .field select,
  .field input,
  .answer-input,
  .answer-select { min-height: 44px; }
}

/* Keep dense question tables readable without allowing page-level overflow. */
.question-prompt table,
.review-table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.question-prompt th,
.question-prompt td,
.review-table th,
.review-table td {
  min-width: 5rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .storage-indicator { display: block; font-size: 11px; line-height: 1.25; }
  .topbar { position: relative; }
  .nav-link { min-height: 44px; }
  .filter-toggle { min-height: 44px; padding-inline: 4px; }
}

@media (max-width: 540px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "brand brand" "right right" "nav nav";
    gap: 5px 8px;
    padding: 8px 12px;
  }
  .brand { min-height: 40px; }
  .topbar-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "bank backup" "status status";
    align-items: center;
    gap: 4px 8px;
  }
  .active-bank-control { grid-area: bank; min-width: 0; }
  .active-bank-control select { width: 100%; max-width: none; min-height: 44px; font-size: 11px; }
  .topbar-right .button { grid-area: backup; min-height: 44px; white-space: nowrap; }
  .storage-indicator { grid-area: status; min-height: 16px; }
  .main-nav { min-height: 48px; padding-top: 3px; }
  .nav-link { flex: 1; min-width: 0; padding: 6px 4px; font-size: 11px; }
  .app-shell { width: calc(100% - 24px); padding-top: 18px; }
  .panel { padding: 16px; }
  .practice-card { padding: 18px 14px; border-radius: 16px; }
  .choice-option { gap: 9px; padding: 12px; }
  .question-actions .right-actions { grid-template-columns: 1fr; }
  .question-actions .right-actions .button { width: 100%; }
}

@media (max-width: 360px) {
  .brand { gap: 8px; }
  .brand small { font-size: 10px; }
  .topbar-right { gap: 4px; }
  .topbar-right .button { padding-inline: 8px; font-size: 10px; }
  .question-meta { gap: 5px; }
  .tag { padding: 5px 7px; }
  .order-item { gap: 7px; padding-inline: 8px; }
  .order-item > span { overflow-wrap: anywhere; }
}

/* Keep cloud controls and both status messages separate on narrow screens. */
@media (max-width: 760px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "brand" "right" "nav";
    gap: 5px 8px;
  }

  .topbar-right {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "bank backup"
      "storage storage"
      "cloud cloud"
      "cloud-action cloud-action";
    align-items: center;
    justify-content: stretch;
    gap: 4px 8px;
    min-width: 0;
    max-width: 100%;
  }

  .active-bank-control { grid-area: bank; min-width: 0; }
  .active-bank-control select { width: 100%; max-width: none; min-height: 44px; font-size: 11px; }
  #backup-button { grid-area: backup; min-height: 44px; white-space: nowrap; }
  #storage-indicator { grid-area: storage; }
  #cloud-status { grid-area: cloud; }
  #cloud-login-button,
  #cloud-logout-button,
  #cloud-retry-button { grid-area: cloud-action; justify-self: start; }

  #storage-indicator,
  #cloud-status {
    display: block;
    min-width: 0;
    min-height: 16px;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 11px;
    line-height: 1.25;
  }
}
