:root {
  --navy: #102a43;
  --navy-2: #173f5f;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --teal-soft: #dff4f0;
  --mint: #edf9f6;
  --blue-soft: #e8f1ff;
  --amber-soft: #fff4dc;
  --rose-soft: #ffeaec;
  --surface: #fff;
  --canvas: #f5f8fa;
  --text: #172b3a;
  --muted: #607283;
  --line: #dce5eb;
  --danger: #b42335;
  --success: #15704c;
  --shadow: 0 16px 42px rgba(16, 42, 67, .09);
  --radius: 18px;
  --radius-small: 11px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: var(--canvas); color: var(--text); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
input, select, textarea {
  width: 100%; border: 1px solid #bdccd6; border-radius: var(--radius-small); background: #fff; color: var(--text);
  min-height: 48px; padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #e2a827; outline-offset: 3px; }
label { display: block; margin: 17px 0 7px; color: var(--navy); font-size: .9rem; font-weight: 700; }
label span { color: var(--muted); font-weight: 500; }
h1, h2, h3, p { margin-top: 0; }
h1 { color: var(--navy); font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.04; letter-spacing: -.045em; }
h2 { color: var(--navy); letter-spacing: -.025em; }
p { color: var(--muted); line-height: 1.65; }

.skip-link { position: fixed; left: 16px; top: -100px; z-index: 1000; padding: 10px 14px; background: var(--navy); color: white; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.site-header { height: 76px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 24px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px 11px 11px 3px; background: var(--teal); color: white; font-size: 1.25rem; font-weight: 850; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand strong { letter-spacing: .12em; font-size: .96rem; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .7rem; }
.site-nav { display: flex; align-items: center; gap: 18px; font-size: .9rem; font-weight: 650; }
.site-nav a { text-decoration: none; }
.site-nav form { margin: 0; }
.page-shell { width: min(1180px, calc(100% - 40px)); min-height: calc(100vh - 150px); margin: 0 auto; padding: 52px 0 70px; }
.site-footer { min-height: 74px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px max(24px, calc((100vw - 1180px) / 2)); color: var(--muted); border-top: 1px solid var(--line); font-size: .78rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(16,42,67,.05); }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border: 1px solid transparent; border-radius: 11px; text-decoration: none; font-weight: 750; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; pointer-events: none; }
.button-primary { background: var(--teal); color: #fff; box-shadow: 0 7px 16px rgba(15,118,110,.18); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { background: #fff; border-color: #b9cbd4; color: var(--navy); }
.button-quiet { background: transparent; color: var(--navy); }
.button-small { min-height: 38px; padding: 7px 12px; font-size: .82rem; }
.button-wide { width: 100%; margin-top: 24px; }
.icon-button { width: 42px; height: 42px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; background: #fff; text-decoration: none; cursor: pointer; font-size: 1.35rem; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--teal-dark); text-decoration: none; font-size: .88rem; font-weight: 700; }
.eyebrow { display: block; margin-bottom: 10px; color: var(--teal); font-size: .74rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.notice { max-width: 780px; padding: 12px 16px; border-radius: 10px; font-weight: 650; }
.notice-error { color: #8e1b2d; background: var(--rose-soft); border: 1px solid #ffcbd2; }
.notice-success { color: #126143; background: #e6f7ef; border: 1px solid #bfe9d4; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

/* Public home */
.home-page { background: radial-gradient(circle at 85% 8%, #dff3ee 0, transparent 30%), var(--canvas); }
.hero { min-height: 490px; display: grid; grid-template-columns: 1.04fr .96fr; align-items: center; gap: clamp(48px, 9vw, 115px); }
.hero-copy h1 { margin-bottom: 24px; font-size: clamp(2.8rem, 6.5vw, 5.2rem); }
.hero-copy h1 span { color: var(--teal); }
.hero-copy p { max-width: 630px; font-size: 1.14rem; }
.code-card { padding: clamp(25px, 4vw, 42px); background: rgba(255,255,255,.96); border: 1px solid #d4e1e7; border-radius: 24px; box-shadow: var(--shadow); }
.code-card > label { margin-top: 0; font-size: 1.02rem; }
.code-entry { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.code-entry input { height: 60px; padding: 8px 18px; font-size: 1.65rem; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.code-entry .button { min-height: 60px; padding-inline: 24px; }
.code-card small { display: block; margin-top: 12px; color: var(--muted); }
.code-card .notice { margin: 17px 0 0; }
.feature-strip { display: grid; grid-template-columns: repeat(3, 1fr); padding: 26px 0 5px; border-top: 1px solid var(--line); }
.feature-strip > div { display: grid; grid-template-columns: 46px 1fr; gap: 1px 14px; align-items: center; padding: 6px 30px; border-right: 1px solid var(--line); }
.feature-strip > div:first-child { padding-left: 0; }
.feature-strip > div:last-child { border-right: 0; }
.feature-icon { grid-row: span 2; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--teal-soft); color: var(--teal); font-size: 1.35rem; }
.feature-strip strong { color: var(--navy); }
.feature-strip small { color: var(--muted); line-height: 1.35; }

/* Login */
.auth-layout { min-height: 630px; display: grid; grid-template-columns: 1fr minmax(360px, 480px); gap: clamp(50px, 10vw, 130px); align-items: center; }
.auth-intro { max-width: 530px; }
.auth-intro p { font-size: 1.08rem; }
.auth-card { padding: clamp(28px, 4vw, 42px); }
.auth-card h2 { font-size: 1.7rem; }
.form-hint { margin: 18px 0 0; font-size: .78rem; text-align: center; }

/* Dashboard and editor */
.page-heading { max-width: 820px; margin-bottom: 40px; }
.page-heading h1 { margin-bottom: 12px; }
.page-heading p { margin-bottom: 0; }
.heading-actions { max-width: none; display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.compact-heading { margin-bottom: 26px; }
.compact-heading .back-link { margin-bottom: 22px; }
.compact-heading h1 { font-size: clamp(2rem, 4vw, 2.8rem); }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.set-card { position: relative; padding: 25px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 7px 22px rgba(16,42,67,.04); }
.set-card.is-muted { opacity: .72; }
.set-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.status-badge { display: inline-flex; align-items: center; width: fit-content; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-size: .7rem; font-weight: 800; }
.status-badge::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }
.status-badge.published { color: #116249; background: #dcf5e9; }
.status-badge.draft { color: #687683; background: #edf1f3; }
.language-pair { color: var(--muted); font-size: .73rem; }
.set-card h2 { margin: 20px 0 7px; font-size: 1.32rem; }
.set-card p { min-height: 2.9em; margin-bottom: 17px; font-size: .88rem; }
.line-clamp { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.set-meta { display: flex; gap: 20px; align-items: center; color: var(--muted); font-size: .78rem; }
.set-meta > strong { color: var(--navy); font-size: 1.05rem; }
.set-meta span { margin-left: auto; }
.code-text { color: var(--navy); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.share-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 20px; }
.share-row input { min-height: 40px; padding: 8px 10px; color: var(--muted); font-size: .75rem; background: #f7f9fa; }
.card-actions { min-height: 50px; display: flex; gap: 4px; align-items: center; margin: 20px -6px -8px; padding-top: 15px; border-top: 1px solid var(--line); }
.action-menu { position: relative; margin-left: auto; }
.action-menu summary { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; list-style: none; font-weight: 900; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu > div { position: absolute; z-index: 5; right: 0; top: 44px; min-width: 180px; overflow: hidden; padding: 7px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.action-menu a, .action-menu button { width: 100%; display: block; min-height: 36px; padding: 8px 10px; color: var(--text); background: none; border: 0; border-radius: 7px; text-align: left; text-decoration: none; cursor: pointer; font-size: .8rem; }
.action-menu a:hover, .action-menu button:hover { background: var(--canvas); }
.danger-text { color: var(--danger) !important; }
.empty-state { max-width: 620px; margin: 45px auto; padding: 60px 35px; text-align: center; }
.empty-state p { max-width: 430px; margin: 0 auto 24px; }
.empty-icon { width: 70px; height: 70px; display: grid; place-items: center; margin: 0 auto 20px; color: var(--teal); background: var(--teal-soft); border-radius: 20px; font-size: 1.45rem; font-weight: 800; }
.editor-layout { display: grid; grid-template-columns: minmax(275px, 340px) minmax(0, 1fr); align-items: start; gap: 22px; }
.settings-panel, .terms-panel { padding: 27px; }
.settings-panel h2, .terms-panel h2 { margin-bottom: 10px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-list { margin: 25px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.detail-list div { display: flex; justify-content: space-between; gap: 15px; margin: 8px 0; }
.detail-list dt { color: var(--muted); font-size: .78rem; }
.detail-list dd { margin: 0; font-size: .82rem; font-weight: 700; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 22px; }
.panel-heading h2 { margin-bottom: 4px; }
.panel-heading p { margin: 0; font-size: .8rem; }
.term-table { display: grid; gap: 8px; }
.term-header { display: grid; grid-template-columns: 24px 1fr 1fr 38px; gap: 8px; padding: 0 3px; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.term-header span:first-child { grid-column: 2; }
.term-row { display: grid; grid-template-columns: 24px 1fr 1fr 38px; gap: 8px; align-items: center; }
.term-row input { min-width: 0; }
.drag-handle { color: #a0afba; cursor: grab; font-size: 1.15rem; }
.remove-term { width: 36px; height: 36px; color: var(--muted); border: 0; background: transparent; }
.add-term { margin: 15px 0; }
.sticky-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 20px -27px -27px; padding: 18px 27px; background: #f9fbfc; border-top: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); }

/* Import and admin */
.import-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 22px; align-items: start; }
.import-form, .import-help, .preview-panel { padding: 27px; }
.import-form > label:first-of-type { margin-top: 0; }
.import-help h2 { font-size: 1.1rem; }
.import-help ol { padding-left: 20px; color: var(--muted); line-height: 1.7; font-size: .88rem; }
.import-help p { margin-bottom: 0; font-size: .8rem; }
.preview-panel { margin-top: 22px; }
.preview-table { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.preview-row { display: grid; grid-template-columns: 65px 1fr 1fr minmax(100px, .7fr); }
.preview-row span { min-width: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; font-size: .82rem; }
.preview-row:last-child span { border-bottom: 0; }
.preview-head { background: #f4f7f9; color: var(--muted); font-weight: 800; }
.preview-row.row-error { background: var(--rose-soft); color: #8e1b2d; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 22px; align-items: start; }
.admin-layout > .panel, .overview-panel { padding: 27px; }
.create-account h2 { margin-bottom: 20px; }
.create-account .button { margin-top: 22px; width: 100%; }
.account-list { display: grid; gap: 9px; }
.account-item { border: 1px solid var(--line); border-radius: 12px; }
.account-item summary { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; padding: 12px; cursor: pointer; list-style: none; }
.account-item summary::-webkit-details-marker { display: none; }
.account-item summary strong, .account-item summary small { display: block; }
.account-item summary small { margin-top: 3px; color: var(--muted); }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--teal); background: var(--teal-soft); font-weight: 850; }
.account-editor { padding: 4px 14px 15px 68px; border-top: 1px solid var(--line); }
.account-editor form { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: end; }
.account-editor form + form { margin-top: 8px; }
.account-editor label { margin-top: 8px; }
.overview-panel { margin-top: 22px; }
.overview-table { overflow-x: auto; }
.overview-row { min-width: 720px; display: grid; grid-template-columns: minmax(200px, 1.5fr) 1fr .7fr .8fr .6fr; gap: 15px; padding: 12px 8px; border-bottom: 1px solid var(--line); align-items: center; font-size: .82rem; }
.overview-row > span:first-child strong, .overview-row > span:first-child small { display: block; }
.overview-row small { margin-top: 3px; color: var(--muted); }
.overview-head { color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.empty-copy { margin: 20px 0 5px; text-align: center; }

/* Student mode picker */
.student-page { background: linear-gradient(180deg, #eff8f6 0, var(--canvas) 380px); }
.student-intro { max-width: 780px; margin: 0 auto 46px; text-align: center; }
.student-intro .back-link { display: block; width: fit-content; margin: 0 auto 32px; }
.student-intro h1 { margin: 18px 0 14px; }
.student-intro > p { max-width: 640px; margin: 0 auto 14px; }
.language-route { display: inline-flex; align-items: center; gap: 12px; padding: 7px 14px; color: var(--navy); background: white; border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; font-weight: 700; }
.language-route span:nth-child(2) { color: var(--teal); }
.term-count { color: var(--muted); font-size: .82rem; font-weight: 700; }
.mode-grid { max-width: 900px; display: grid; grid-template-columns: 1fr 1fr; gap: 17px; margin: 0 auto; }
.mode-card { min-height: 142px; display: grid; grid-template-columns: 76px 1fr auto; gap: 20px; align-items: center; padding: 24px; background: #fff; border: 1px solid var(--line); border-radius: 19px; box-shadow: 0 8px 24px rgba(16,42,67,.055); text-decoration: none; transition: transform .18s, box-shadow .18s; }
.mode-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.mode-icon { width: 76px; height: 76px; display: flex; align-items: center; justify-content: center; gap: 4px; border-radius: 19px; }
.mode-icon i { font-style: normal; font-weight: 850; }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { margin-bottom: 7px; color: var(--navy); font-size: 1.16rem; }
.mode-card small { color: var(--muted); }
.mode-card > b { color: var(--teal); font-size: 1.3rem; }
.mode-flash .mode-icon { color: #1d5a92; background: var(--blue-soft); }
.mode-memory .mode-icon { color: #7c4b0d; background: var(--amber-soft); }
.mode-choice .mode-icon { color: #126249; background: var(--teal-soft); }
.mode-write .mode-icon { color: #94354a; background: var(--rose-soft); font-size: 1.8rem; }

/* Learning modes */
.learning-page { height: 100vh; overflow: hidden; background: #eef3f5; }
.learning-page .site-header, .learning-page .site-footer { display: none; }
.learning-shell { width: 100%; height: 100vh; padding: 0; }
.learning-app { height: 100%; display: flex; flex-direction: column; }
.learning-header { min-height: 70px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 15px; align-items: center; padding: 11px clamp(16px, 4vw, 50px); background: #fff; border-bottom: 1px solid var(--line); }
.learning-header .close-button { justify-self: start; }
.learning-title { text-align: center; }
.learning-title strong, .learning-title small { display: block; }
.learning-title strong { color: var(--navy); }
.learning-title small { margin-top: 2px; color: var(--muted); font-size: .7rem; }
.direction-button { justify-self: end; }
.progress-track { width: 100%; height: 5px; flex: 0 0 auto; appearance: none; border: 0; border-radius: 0; background: #d8e2e6; }
.progress-track::-webkit-progress-bar { background: #d8e2e6; }
.progress-track::-webkit-progress-value { background: var(--teal); transition: width .25s; }
.progress-track::-moz-progress-bar { background: var(--teal); transition: width .25s; }
.learning-content { width: min(1050px, calc(100% - 32px)); min-height: 0; flex: 1; display: flex; flex-direction: column; margin: 0 auto; padding: clamp(14px, 2.6vh, 28px) 0; }
.mode-toolbar { min-height: 36px; display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: clamp(12px, 2vh, 22px); color: var(--muted); font-size: .82rem; font-weight: 700; }
.mode-toolbar label { display: flex; align-items: center; gap: 8px; margin: 0; }
.mode-toolbar select { width: auto; min-height: 38px; padding-block: 5px; }
.flashcard { position: relative; min-height: 0; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; color: var(--navy); background: #fff; border: 1px solid #d4e0e5; border-radius: 26px; box-shadow: 0 18px 45px rgba(16,42,67,.08); cursor: pointer; }
.flashcard strong { max-width: 90%; font-size: clamp(2.4rem, 8vw, 5.5rem); line-height: 1.1; overflow-wrap: anywhere; }
.flashcard .card-language { position: absolute; top: 25px; color: var(--teal); font-size: .72rem; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.flashcard .speaker-button { position: absolute; top: 18px; right: 20px; width: 46px; height: 46px; display: grid; place-items: center; border: 0; border-radius: 50%; color: var(--teal); background: var(--mint); cursor: pointer; font-size: .85rem; }
.flashcard small { position: absolute; bottom: 24px; color: var(--muted); }
.flashcard.is-back { background: linear-gradient(135deg, #f1faf8, #fff); border-color: #9ed4cb; }
.flash-actions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; padding-top: clamp(12px, 2.3vh, 24px); }
.flash-actions > .button:first-child { justify-self: start; }
.flash-actions > .button:last-child { justify-self: end; }
.self-rating { display: flex; gap: 8px; }
.rating-no { color: #983247; background: var(--rose-soft); border-color: #ffc8d1; }
.rating-yes { color: #116249; background: var(--teal-soft); border-color: #b8e1d9; }
.memory-toolbar { justify-content: flex-start; }
.memory-toolbar > span { margin-left: auto; }
.memory-grid { min-height: 0; flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(7px, 1.2vw, 13px); }
.memory-tile { min-height: 64px; padding: 9px; color: var(--navy); background: var(--navy); border: 2px solid transparent; border-radius: 13px; cursor: pointer; font-size: clamp(.76rem, 1.7vw, 1rem); font-weight: 750; overflow-wrap: anywhere; }
.memory-tile::before { content: "A"; display: grid; place-items: center; width: 32px; height: 32px; margin: auto; color: white; border: 1px solid rgba(255,255,255,.4); border-radius: 9px 9px 9px 3px; }
.memory-tile span { display: none; }
.memory-tile.is-open, .memory-tile.is-matched { background: #fff; border-color: #9ecfc7; }
.memory-tile.is-open::before, .memory-tile.is-matched::before { display: none; }
.memory-tile.is-open span, .memory-tile.is-matched span { display: inline; }
.memory-tile.is-matched { color: #116249; background: #e0f5ec; opacity: .75; }
.question-card, .writing-card { padding: clamp(22px, 5vh, 48px); background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 10px 30px rgba(16,42,67,.055); text-align: center; }
.question-label { color: var(--muted); font-size: .82rem; font-weight: 700; }
.spoken-term { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 12px; }
.spoken-term h2 { margin: 0; font-size: clamp(2rem, 6vw, 4rem); overflow-wrap: anywhere; }
.speaker { color: var(--teal); background: var(--mint); border: 0; font-size: .78rem; }
.choice-grid { min-height: 0; flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; padding-top: 18px; }
.choice-button { min-height: 74px; padding: 15px 22px; color: var(--navy); background: #fff; border: 2px solid #d9e3e7; border-radius: 15px; cursor: pointer; font-weight: 750; font-size: clamp(.9rem, 2vw, 1.08rem); }
.choice-button:hover { border-color: #8ebfb8; }
.choice-button.correct { color: #105f45; background: #def4e9; border-color: #45a77f; }
.choice-button.wrong { color: #922c40; background: #ffe6ea; border-color: #d96d80; }
.feedback-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 14px; padding: 12px 17px; background: #fff; border-radius: 13px; font-weight: 750; }
.writing-card { width: min(780px, 100%); margin: auto; }
.writing-card form { margin-top: clamp(30px, 6vh, 65px); text-align: left; }
.writing-card label { font-size: .78rem; }
.answer-entry { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.answer-entry input { min-height: 58px; font-size: 1.16rem; }
.writing-feedback { display: grid; grid-template-columns: 1fr auto; gap: 4px 15px; align-items: center; margin-top: 18px; padding: 14px 16px; border-radius: 12px; text-align: left; }
.writing-feedback strong, .writing-feedback span { display: block; }
.writing-feedback span { color: var(--muted); font-size: .84rem; }
.writing-feedback .button { grid-column: 2; grid-row: 1 / span 2; }
.writing-feedback.correct { background: #def4e9; }
.writing-feedback.wrong { background: #ffe6ea; }
.completion-card { max-width: 520px; margin: auto; padding: 40px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); text-align: center; }
.completion-card[hidden], .feedback-bar[hidden], .writing-feedback[hidden] { display: none; }
.success-ring { width: 68px; height: 68px; display: grid; place-items: center; margin: 0 auto 18px; color: #fff; background: var(--teal); border-radius: 50%; font-size: 1.8rem; }
.completion-card p strong { color: var(--navy); font-size: 1.25rem; }
.error-page h1 { font-size: 2.4rem; }

@media (max-width: 850px) {
  .hero { grid-template-columns: 1fr; min-height: 0; gap: 35px; padding: 25px 0; }
  .hero-copy { text-align: center; }
  .hero-copy p { margin-inline: auto; }
  .feature-strip { grid-template-columns: 1fr; }
  .feature-strip > div { padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .feature-strip > div:last-child { border-bottom: 0; }
  .auth-layout { grid-template-columns: 1fr; min-height: 0; gap: 30px; }
  .auth-intro { max-width: none; text-align: center; }
  .auth-intro .back-link { display: block; }
  .set-grid { grid-template-columns: 1fr; }
  .editor-layout, .admin-layout, .import-layout { grid-template-columns: 1fr; }
  .settings-panel { order: 0; }
  .terms-panel { order: 1; }
  .create-account { order: -1; }
}

@media (max-width: 620px) {
  .site-header { height: 66px; padding: 0 16px; }
  .brand small { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .site-nav > a { display: none; }
  .page-shell { width: min(100% - 28px, 1180px); padding: 33px 0 55px; }
  .site-footer { flex-direction: column; padding: 18px; text-align: center; }
  .hero-copy h1 { font-size: 2.75rem; }
  .code-card { padding: 21px; }
  .code-entry { grid-template-columns: 1fr; }
  .code-entry input { text-align: center; }
  .heading-actions { align-items: stretch; flex-direction: column; }
  .set-card { padding: 20px; }
  .set-card-top { align-items: start; flex-direction: column; }
  .share-row { grid-template-columns: 1fr; }
  .card-actions { flex-wrap: wrap; }
  .settings-panel, .terms-panel, .import-form, .import-help, .preview-panel, .admin-layout > .panel, .overview-panel { padding: 19px; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
  .term-header { display: none; }
  .term-row { grid-template-columns: 19px 1fr 35px; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .term-row input:first-of-type { grid-column: 2; }
  .term-row input:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .term-row .drag-handle { grid-column: 1; grid-row: 1 / 3; }
  .term-row .remove-term { grid-column: 3; grid-row: 1 / 3; }
  .sticky-actions { margin: 18px -19px -19px; padding: 15px 19px; }
  .preview-table { overflow-x: auto; }
  .preview-row { min-width: 610px; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 112px; grid-template-columns: 62px 1fr auto; padding: 18px; }
  .mode-icon { width: 62px; height: 62px; }
  .learning-header { min-height: 62px; grid-template-columns: 44px 1fr auto; padding: 8px 12px; }
  .learning-header .direction-button span { display: none; }
  .learning-header .direction-button { width: 42px; padding: 0; }
  .learning-title strong { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .learning-content { width: calc(100% - 20px); }
  .flashcard { padding: 25px 15px; border-radius: 20px; }
  .flash-actions { grid-template-columns: 1fr 1fr; }
  .self-rating { grid-row: 1; grid-column: 1 / 3; justify-content: center; }
  .flash-actions > .button:first-child { grid-row: 2; }
  .flash-actions > .button:last-child { grid-row: 2; }
  .memory-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .question-card, .writing-card { padding: 22px 16px; }
  .choice-grid { grid-template-columns: 1fr; }
  .choice-button { min-height: 55px; }
  .answer-entry { grid-template-columns: 1fr; }
  .writing-feedback { grid-template-columns: 1fr; }
  .writing-feedback .button { grid-column: 1; grid-row: auto; margin-top: 8px; }
}

@media (max-height: 650px) and (min-width: 621px) {
  .learning-header { min-height: 58px; }
  .flashcard strong { font-size: 3rem; }
  .question-card { padding-block: 16px; }
  .spoken-term h2 { font-size: 2.2rem; }
  .choice-button { min-height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
