:root {
  --ink: #102a43; --ink-2: #334e68; --muted: #627d98; --paper: #f5f8fb; --card: #fff;
  --line: #d9e2ec; --gold: #f7c948; --gold-dark: #8d6510; --blue: #2463a3;
  --complete: #13795b; --incomplete: #a25a08; --incorrect: #bd2c32;
  --shadow: 0 16px 40px rgba(16,42,67,.09); --radius: 18px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.topbar { min-height: 68px; padding: 10px clamp(16px,4vw,48px); display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: white; }
.brand { display: flex; gap: 11px; align-items: center; color: white; text-decoration: none; font-weight: 800; font-size: 1.08rem; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--ink); background: var(--gold); border-radius: 11px; font-family: Georgia, serif; font-size: 1.45rem; }
nav { display: flex; gap: 4px; }
.account-controls { display: flex; align-items: center; gap: 7px; color: #b7c9da; font-size: .78rem; }
.account-controls #sync-status[data-state="saving"] { color: var(--gold); }
.account-controls #sync-status[data-state="error"] { color: #ffaaa9; }
.nav-button { border: 0; background: transparent; color: #b7c9da; padding: 10px 14px; border-radius: 10px; font-weight: 700; }
.nav-button:hover, .nav-button.active { color: white; background: rgba(255,255,255,.1); }
main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 64px; }
.loading-panel { min-height: 50vh; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); }
.auth-card { width: min(440px,100%); margin: 4vh auto 0; padding: clamp(26px,6vw,46px); border-radius: 24px; background: white; box-shadow: var(--shadow); }
.auth-mark { margin-bottom: 20px; }
.auth-card h1 { margin: 4px 0 8px; font-family: Georgia, serif; font-size: 2.5rem; }
.auth-card > p:not(.eyebrow) { color: var(--muted); }
.auth-card form { display: grid; gap: 8px; margin-top: 25px; }
.auth-card label { margin-top: 7px; font-weight: 800; }
.auth-card input { min-height: 48px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 11px; color: var(--ink); background: white; }
.auth-card input:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36,99,163,.12); }
.auth-card button { margin-top: 10px; }
.auth-error { margin: 4px 0 0; color: var(--incorrect) !important; font-weight: 700; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem,4vw,3.15rem); line-height: 1.05; margin: 3px 0 0; letter-spacing: -.025em; }
.eyebrow { margin: 0; color: var(--blue); text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 800; }
.bank-count { color: var(--muted); text-align: right; }
.setup-grid, .progress-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card { min-width: 0; margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: 0 4px 16px rgba(16,42,67,.03); }
fieldset.card { padding-top: 15px; }
.wide-card { grid-column: 1 / -1; }
legend, .card h2 { padding: 0 7px; margin: 0 0 13px -7px; color: var(--ink); font-size: 1rem; font-weight: 800; }
.choice-grid { display: grid; gap: 9px; }
.preset-grid { grid-template-columns: repeat(5, 1fr); }
.choice-grid label, .segmented label { position: relative; }
.choice-grid input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.choice-grid label span, .segmented label span { min-height: 48px; display: grid; place-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: #f9fbfd; color: var(--ink-2); font-weight: 750; text-align: center; transition: .15s ease; }
.choice-grid input:checked + span, .segmented input:checked + span { color: var(--ink); border-color: var(--gold-dark); background: #fff6cf; box-shadow: inset 0 0 0 1px var(--gold); }
.choice-grid input:focus-visible + span, .segmented input:focus-visible + span { outline: 3px solid rgba(36,99,163,.25); outline-offset: 2px; }
.field-note, .storage-note { color: var(--muted); font-size: .88rem; margin: 13px 0 0; }
.segmented { display: flex; gap: 8px; }
.segmented label { flex: 1; }
.segmented.wrap { flex-wrap: wrap; }
.segmented.wrap label { min-width: 58px; }
.stacked-options { display: grid; gap: 8px; }
.stacked-options label { display: flex; align-items: flex-start; gap: 11px; padding: 10px 11px; border-radius: 12px; cursor: pointer; }
.stacked-options label:hover { background: #f5f8fb; }
.stacked-options input { accent-color: var(--blue); margin-top: 5px; }
.stacked-options span, .switch-row span { display: grid; }
.stacked-options small, .switch-row small { color: var(--muted); font-size: .82rem; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; }
.switch-row input { appearance: none; width: 51px; height: 29px; flex: 0 0 auto; padding: 3px; border: 0; border-radius: 20px; background: #bcccdc; transition: .2s; }
.switch-row input::before { content: ""; display: block; width: 23px; height: 23px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(0,0,0,.18); transition: .2s; }
.switch-row input:checked { background: var(--blue); }
.switch-row input:checked::before { transform: translateX(22px); }
.start-card { padding: 20px 22px; border-radius: var(--radius); color: white; background: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.start-card div { display: grid; }
.start-card span { color: #b7c9da; font-size: .9rem; }
.primary-button, .secondary-button, .danger-button { min-height: 46px; padding: 11px 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 800; }
.primary-button { color: var(--ink); background: var(--gold); }
.primary-button:hover { background: #ffd65c; transform: translateY(-1px); }
.secondary-button { color: var(--ink); background: white; border-color: var(--line); }
.danger-button { color: white; background: var(--incorrect); }
.text-button { border: 0; padding: 8px 0; background: transparent; color: var(--muted); font-weight: 750; }
.quiz-shell { width: min(800px, 100%); margin: 0 auto; }
.quiz-topline { display: flex; justify-content: space-between; align-items: center; }
.quiz-progress-text { display: grid; text-align: right; font-weight: 800; }
.quiz-progress-text small { color: var(--muted); font-weight: 600; }
.progress-track { height: 7px; margin: 12px 0 24px; overflow: hidden; border-radius: 8px; background: var(--line); }
#progress-bar { width: 0; height: 100%; background: var(--gold); transition: width .25s; }
.question-card { min-height: 500px; padding: clamp(24px,5vw,54px); border-radius: 24px; background: var(--card); box-shadow: var(--shadow); border-top: 6px solid var(--gold); }
.question-meta { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: .82rem; font-weight: 750; }
.question-meta > span { padding: 5px 9px; border-radius: 8px; background: #eef3f7; }
.practice-pill { color: #744210; background: #fff3c4 !important; }
.question-instruction { margin: 40px 0 8px; color: var(--muted); }
.question-prompt { min-height: 74px; margin: 0 0 38px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem,7vw,4rem); line-height: 1.15; overflow-wrap: anywhere; }
.answer-label { display: block; margin-bottom: 7px; font-weight: 800; }
.answer-wrap { border: 2px solid var(--line); border-radius: 14px; overflow: hidden; background: white; transition: .15s; }
.answer-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36,99,163,.12); }
#answer-input { width: 100%; min-height: 82px; resize: vertical; padding: 15px 16px; border: 0; outline: 0; color: var(--ink); font-size: 1.2rem; line-height: 1.4; }
.greek-keyboard { margin-top: 12px; padding: 10px; border: 1px solid #b8c9d9; border-radius: 14px; background: #eaf1f7; user-select: none; }
.greek-key-row { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
.greek-key-row button { min-width: 0; min-height: 46px; padding: 5px 2px; border: 1px solid #b8c9d9; border-radius: 9px; color: var(--ink); background: white; box-shadow: 0 2px 0 #b8c9d9; font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; font-weight: 700; touch-action: manipulation; }
.greek-key-row button:hover { background: #fff8d8; border-color: var(--gold-dark); }
.greek-key-row button:active { transform: translateY(2px); box-shadow: none; }
.keyboard-tools { grid-template-columns: .7fr .7fr 1.5fr 1.5fr 1.1fr .8fr 1fr; margin-bottom: 3px; }
.keyboard-tools button { font-family: inherit; font-size: .78rem; }
.keyboard-tools button > span { font-family: Georgia, serif; font-size: 1.05rem; }
.greek-keyboard > p { margin: 7px 2px 0; color: var(--muted); font-size: .78rem; text-align: center; }
.answer-button { margin-top: 14px; width: 100%; }
.feedback { margin-top: 25px; border-top: 1px solid var(--line); padding-top: 23px; }
.feedback-heading { display: flex; gap: 12px; align-items: center; }
.feedback-heading > span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: white; font-weight: 900; }
.feedback-heading div { display: grid; }
.feedback-heading small { color: var(--muted); }
.feedback.complete .feedback-heading > span { background: var(--complete); }
.feedback.incomplete .feedback-heading > span { background: var(--incomplete); }
.feedback.incorrect .feedback-heading > span { background: var(--incorrect); }
.answer-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.answer-comparison div { min-width: 0; padding: 12px; border-radius: 11px; background: #f5f8fb; }
.answer-comparison dt { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.answer-comparison dd { margin: 3px 0 0; overflow-wrap: anywhere; }
#next-question { width: 100%; }
.key-hint { margin-left: 8px; font-weight: 600; opacity: .65; }
.keyboard-tip { text-align: center; color: var(--muted); font-size: .84rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.stat strong { display: block; font-family: Georgia, serif; font-size: 2rem; line-height: 1; }
.stat span { color: var(--muted); font-size: .83rem; }
.stat.complete strong { color: var(--complete); }.stat.incomplete strong { color: var(--incomplete); }.stat.incorrect strong { color: var(--incorrect); }
.results-card { margin-top: 18px; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.card-heading h2 { padding: 0; margin: 0; }
.muted { color: var(--muted); font-size: .82rem; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { color: var(--muted); font-size: .72rem; text-align: left; text-transform: uppercase; letter-spacing: .055em; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
td { overflow-wrap: anywhere; }
.result-badge { display: inline-block; padding: 4px 8px; border-radius: 7px; font-size: .76rem; font-weight: 800; }
.result-badge.complete { color: #075f46; background: #d8f3e9; }.result-badge.incomplete { color: #7a4100; background: #fff0d0; }.result-badge.incorrect { color: #982027; background: #fde0e1; }
.progress-layout { margin-top: 18px; }
.direction-block + .direction-block { margin-top: 18px; }
.direction-block header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.mini-bar { display: flex; height: 12px; border-radius: 7px; overflow: hidden; background: var(--line); }
.mini-bar span.complete { background: var(--complete); }.mini-bar span.incomplete { background: var(--incomplete); }.mini-bar span.incorrect { background: var(--incorrect); }
.rank-list { display: grid; gap: 9px; }
.rank-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 11px; border-radius: 11px; background: #f5f8fb; }
.rank-item b { font-family: Georgia, serif; font-size: 1.07rem; }.rank-item small { color: var(--muted); }.rank-item em { grid-row: 1 / 3; grid-column: 2; align-self: center; color: var(--incorrect); font-style: normal; font-weight: 800; }
dialog { max-width: min(440px,calc(100% - 32px)); border: 0; padding: 0; border-radius: 18px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16,42,67,.6); }
.dialog-card { padding: 26px; }.dialog-card h2 { margin-top: 0; }.dialog-card > div { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
@media (max-width: 800px) {
  main { width: min(100% - 24px, 700px); padding-top: 28px; }
  .setup-grid, .progress-layout { grid-template-columns: 1fr; }
  .wide-card { grid-column: auto; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .question-card { min-height: 0; }
}
@media (max-width: 520px) {
  .topbar { padding-inline: 12px; }.brand span:last-child { display: none; }
  .nav-button { padding-inline: 10px; }
  .account-controls #sync-status { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }.bank-count { text-align: left; }
  .vertical-mobile { flex-direction: column; }.vertical-mobile label { flex: auto; }
  .start-card { align-items: stretch; flex-direction: column; }.start-card .primary-button { width: 100%; }
  .question-card { padding: 24px 18px; border-radius: 18px; }
  .question-instruction { margin-top: 28px; }.question-prompt { min-height: 60px; margin-bottom: 28px; }
  .answer-comparison { grid-template-columns: 1fr; }
  .greek-keyboard { margin-inline: -8px; padding: 7px; }
  .greek-key-row { gap: 4px; margin-bottom: 4px; }
  .greek-key-row button { min-height: 43px; border-radius: 7px; }
  .keyboard-tools { grid-template-columns: repeat(4, 1fr); }
  .keyboard-tools button:nth-child(5), .keyboard-tools button:nth-child(6), .keyboard-tools button:nth-child(7) { grid-column: span 1; }
  .stat-grid { gap: 9px; }.stat { padding: 15px; }.stat strong { font-size: 1.6rem; }
  .summary-heading .primary-button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
