:root {
  --bg: #f5f1e8;
  --card-border: #d4c9b8;
  --text: #1d1a16;
  --muted: #776e62;
  --green: #2d6a4f;

  /* Type scale */
  --fs-xs:      12px;
  --fs-sm:      14px;
  --fs-base:    16px;
  --fs-md:      18px;
  --fs-lg:      22px;
  --fs-xl:      28px;
  --fs-2xl:     36px;
  --fs-3xl:     48px;
  --fs-display: 56px;

  /* Font weights */
  --fw-normal:    400;
  --fw-semibold:  600;
  --fw-bold:      700;
  --fw-extrabold: 800;

  /* Line heights */
  --lh-tight:   1.15;
  --lh-heading: 1.2;
  --lh-snug:    1.3;
  --lh-base:    1.5;
  --lh-reading: 1.85;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(var(--bg) 60%, #ede8dd);
  color: var(--text);
  line-height: var(--lh-base);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 26px 0 0 100px;
  font-weight: 800;
  font-size: 40px;
}
.brand-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--green), #1a4a30);
}
.brand-icon svg {
  width: 26px;
  height: 26px;
  stroke: #fff;
  fill: none;
}

main {
  max-width: 1000px;
  margin: 65px auto 0;
}

.progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}
.step {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.step.active {
  width: 50px;
  height: 50px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--green);
}
.step.done { background: #8ab09a; color: #fff; }
.step.muted { background: #d4cfc6; color: #9a9088; }
.line.done { background: var(--green); }
.label.active { color: var(--green); font-weight: 800; font-size: 1.05em; }
.label.muted { color: var(--muted); }
.line { width: 60px; height: 2px; background: var(--card-border); }
.step-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.card {
  width: 760px;
  margin: 60px auto;
  background: #fefcf9;
  border: 2px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(29, 26, 22, 0.08);
  padding: 28px 24px 22px;
  text-align: center;
}
.card h1 {
  margin: 0;
  font-size: var(--fs-3xl);
  line-height: var(--lh-heading);
  font-weight: var(--fw-extrabold);
}
.card p {
  margin-top: 10px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 32px;
  line-height: var(--lh-snug);
}
.card.error {
  border-color: #ef4444;
  background: #fef2f2;
}
.card.error h1::before {
  content: "! ";
  color: #ef4444;
  font-weight: var(--fw-extrabold);
}
.char-count {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}
.char-count.warn { color: #b45309; }
.char-count.error-count { color: #ef4444; font-weight: 600; }
.storage-warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  color: #92400e;
  font-size: 14px;
  padding: 10px 14px;
  margin: 0 auto 16px;
  max-width: 500px;
  text-align: center;
}
.srs-review-notice {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #991b1b;
  font-size: 14px;
  padding: 10px 14px;
  margin: 0 auto 16px;
  max-width: 500px;
  text-align: center;
}
.audio-unavailable {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  color: #0369a1;
  font-size: 13px;
  padding: 8px 14px;
  margin: 6px auto 2px;
  max-width: 400px;
  text-align: center;
}
.storage-choice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.storage-choice-dialog {
  background: #fefcf9;
  border-radius: 12px;
  padding: 28px 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(29, 26, 22, 0.18);
}
.storage-choice-dialog h2 {
  margin: 0 0 10px;
  font-size: 20px;
}
.storage-choice-dialog > p {
  margin: 0 0 18px;
  font-size: 15px;
}
.storage-choice-dialog button {
  display: block;
  width: 100%;
  margin-bottom: 10px;
}
.storage-choice-note {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0 !important;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.lang {
  /* override global `button` rules (height/width/margin/font-size) that would otherwise clobber tile layout and force text to overflow below the tile */
  height: auto;
  width: auto;
  margin-top: 0;
  font-size: inherit;
  font-weight: inherit;
  color: var(--text);
  background: #fefcf9;
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 20px 12px;
  cursor: pointer;
  transition: .15s;
}
.lang .flag {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  background: var(--card-border);
  color: var(--muted);
  border-radius: 4px;
  padding: 3px 7px;
  display: inline-block;
  margin-bottom: 2px;
}
.lang .name { font-weight: var(--fw-bold); font-size: var(--fs-lg); margin-top: 6px; }
.lang:hover:not(.selected) { background: #ede8dd; transform: translateY(-2px); box-shadow: 0 4px 8px rgba(29, 26, 22, 0.08); }
.lang:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.lang.selected {
  border-color: var(--green);
  border-width: 2px;
  background: #e6efe9;
  position: relative;
}
.lang.selected::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 14px;
  font-weight: 900;
  color: var(--green);
  line-height: 1;
}
.lang-add-custom {
  border: 2px dashed var(--card-border);
  color: var(--muted);
  background: transparent;
}
.lang-add-custom:hover:not(.selected) {
  border-color: var(--green);
  color: var(--text);
  background: #ede8dd;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(29, 26, 22, 0.08);
}
.lang-add-custom .flag {
  font-size: var(--fs-md);
  font-weight: var(--fw-extrabold);
  background: transparent;
  color: var(--muted);
}

.custom-lang-form {
  margin-top: 16px;
  padding: 20px;
  background: #fefcf9;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.custom-lang-title {
  font-weight: 700;
  font-size: 18px;
  margin: 0 0 4px;
}
.custom-lang-count {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.custom-lang-form label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-top: 4px;
}
.custom-lang-form input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--card-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.custom-lang-form input[type="text"]:focus { border-color: var(--green); }
.custom-lang-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.custom-lang-add-btn, .custom-lang-cancel-btn {
  width: auto;
  flex: none;
  margin-top: 0;
  padding: 0 24px;
  height: 44px;
  font-size: 15px;
}

.lf-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--green);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: auto;
  cursor: pointer;
  z-index: 9999;
  white-space: nowrap;
}
.lf-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

button {
  width: 100%;
  margin-top: 18px;
  border: none;
  border-radius: 12px;
  height: 58px;
  font-size: 30px;
  font-weight: 700;
  font-family: 'Inter', system-ui, sans-serif;
  color: #fff;
  background: var(--green);
}
#continueBtn {
  position: sticky;
  bottom: 16px;
}
button:disabled {
  cursor: not-allowed;
  background: #d4cfc6;
  color: #9a9088;
  opacity: 0.65;
}
button:disabled:hover {
  background: #d4cfc6;
}
button:enabled {
  cursor: pointer;
  background: linear-gradient(90deg, var(--green), #3d8a64);
}
button:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.3); }
.hint-text {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
  min-height: 1.2em;
}
button:enabled + .hint-text {
  visibility: hidden;
}

.progress-bar-track {
  height: 4px;
  background: var(--card-border);
  border-radius: 999px;
  margin-bottom: 12px;
  overflow: hidden;
}
.progress-bar-fill {
  width: var(--progress, 0%);
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.learn-counter { font-size: var(--fs-md); color: var(--muted); margin-bottom: 4px; }
.quiz-counter { font-size: var(--fs-md); color: var(--muted); margin-bottom: 8px; }
.quiz-word { font-size: var(--fs-3xl); font-weight: var(--fw-bold); margin: 16px 0 24px; overflow-wrap: break-word; word-break: break-word; }
.quiz-input {
  width: 100%;
  border: 2px solid var(--card-border);
  border-radius: 12px;
  font-size: 24px;
  font-family: inherit;
  padding: 12px 16px;
  outline: none;
  color: var(--text);
  background: #fefcf9;
}
.quiz-input:focus { border-color: var(--green); }
.quiz-input:focus-visible { box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.2); }
.answer-feedback {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  padding: 16px;
  border-radius: 12px;
  margin: 12px 0;
}
.answer-feedback.correct { background: #e6efe9; color: var(--green); }
.answer-feedback.wrong { background: #fef2f2; color: #dc2626; }
.quiz-feedback { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.link-success { color: var(--green); }
.change-language-link { margin-top: 16px; font-size: 16px; }
.change-language-link a {
  display: inline-block;
  padding: 12px 8px;
  min-height: 44px;
  line-height: 20px;
  color: var(--muted);
  text-decoration: underline;
}
.change-language-link a:hover { color: var(--text); }

.btn-secondary {
  background: #d4cfc6;
  color: var(--text);
  margin-top: 10px;
}
.btn-secondary:enabled {
  background: #d4cfc6;
  cursor: pointer;
}
.btn-secondary:enabled:hover { background: #c4bfb5; }

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}
.results-actions .btn-secondary {
  margin-top: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  border: none;
}
.results-actions .btn-secondary:hover { background: #c4bfb5; }
.results-actions .btn-primary {
  margin-top: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  min-height: 44px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: linear-gradient(90deg, var(--green), #3d8a64);
  color: #fff;
}
.results-actions .btn-primary:hover { filter: brightness(0.93); }
.btn-tertiary { background: transparent; color: var(--muted); font-size: 13px; }
.btn-tertiary:hover { background: transparent !important; color: var(--text); text-decoration: underline; }

.review-header-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-bottom: 2px solid var(--card-border);
  margin-top: 16px;
}
.review-list {
  border: 1px solid var(--card-border);
  border-top: none;
  border-radius: 0 0 10px 10px;
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 4px;
}
.review-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #e8e3db;
  font-size: 15px;
  align-items: center;
}
.review-row:last-child { border-bottom: none; }
.review-word-cell { font-weight: 700; overflow-wrap: break-word; word-break: break-word; }
.review-yours-cell { color: #dc2626; overflow-wrap: break-word; word-break: break-word; }
.review-correct-cell { color: var(--green); font-weight: 600; overflow-wrap: break-word; word-break: break-word; }

/* Step 3 — Upload Materials */
.upload-area {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  justify-content: center;
}
.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 2px solid var(--card-border);
  border-radius: 10px;
  background: #fefcf9;
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  cursor: pointer;
  transition: .15s;
}
.file-label svg { width: 18px; height: 18px; stroke: currentColor; fill: none; flex-shrink: 0; }
.file-label:hover { border-color: var(--green); background: #e6efe9; }
.file-input { display: none; }
.file-error {
  font-size: 14px;
  color: #ef4444;
  font-weight: 600;
  margin: 4px 0 0;
  text-align: center;
}
.upload-help {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 10px;
}
.upload-example {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}
.upload-example summary {
  cursor: pointer;
  color: var(--green);
  font-weight: 500;
  user-select: none;
  display: inline;
}
.upload-example summary:hover { text-decoration: underline; }
.upload-example-body {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
}
.upload-example-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
}
.upload-file-heading {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.upload-sep {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}
.upload-sep::before,
.upload-sep::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--card-border);
}
.card label[for="textInput"] {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.text-area {
  width: 100%;
  border: 2px solid var(--card-border);
  border-radius: 12px;
  font-size: 18px;
  font-family: inherit;
  padding: 14px 16px;
  outline: none;
  color: var(--text);
  background: #fefcf9;
  resize: vertical;
  line-height: 1.5;
}
.text-area:focus { border-color: var(--green); }

/* Loading indicator */
.loading-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-top: 14px;
  font-size: var(--fs-md);
  color: var(--muted);
  font-weight: var(--fw-bold);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--card-border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Results */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 20px 0;
}
.stat-box {
  flex: 1;
  max-width: 160px;
  background: #ede8dd;
  border-radius: 12px;
  padding: 16px 8px;
}
.stat-num { font-size: 40px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 14px; color: var(--muted); margin-top: 4px; }
.word-group { text-align: left; margin-top: 16px; }
.group-label { font-size: 16px; margin: 0 0 10px; }
.unmastered-label { color: #dc2626; }
.mastered-label { color: var(--green); }
.word-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: default;
}
.chip.unmastered { background: #fef2f2; color: #dc2626; border: 2px solid #fca5a5; }
.chip.mastered { background: #e6efe9; color: var(--green); border: 2px solid #8ab09a; }
.no-matches { font-size: 18px; color: var(--muted); margin: 20px 0; }

/* Reading view (step 3 APPLY section) */
.reading-section {
  margin-top: 28px;
  text-align: left;
  border-top: 2px solid var(--card-border);
  padding-top: 20px;
}
.reading-section h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 10px;
}
.reading-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--muted);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.legend-dot.unmastered { background: #fca5a5; }
.legend-dot.mastered   { background: #8ab09a; }
.reading-tip { font-size: 13px; color: var(--muted); margin-left: auto; font-style: italic; }
.reading-text {
  background: #fefcf9;
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 18px 20px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 17px;
  line-height: var(--lh-reading);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
}
.reading-text .w-unmastered {
  background: #fef2f2;
  color: #dc2626;
  border-radius: 3px;
  padding: 1px 3px;
  cursor: pointer;
  border-bottom: 2px solid #fca5a5;
  font-weight: 700;
}
.reading-text .w-mastered {
  background: #e6efe9;
  color: var(--green);
  border-radius: 3px;
  padding: 1px 3px;
  cursor: pointer;
  border-bottom: 2px solid #8ab09a;
  font-weight: 700;
}
.reading-text .w-unmastered:hover,
.reading-text .w-mastered:hover { filter: brightness(0.93); }
.reading-text .w-unmastered:focus-visible,
.reading-text .w-mastered:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.reading-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--card-border);
}
.reading-page-info {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
  min-width: 90px;
  text-align: center;
}
.btn-page {
  background: #fefcf9;
  color: var(--text);
  border: 2px solid var(--card-border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-page:hover:not(:disabled) { background: #ede8dd; }
.btn-page:disabled { opacity: 0.4; cursor: not-allowed; }
.word-tooltip {
  position: fixed;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  pointer-events: auto;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(29, 26, 22, 0.25);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tooltip-add-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.tooltip-add-btn:hover:not(:disabled) { background: rgba(255,255,255,0.35); }
.tooltip-add-btn:disabled { opacity: 0.7; cursor: default; }

/* First-visit onboarding hint panel for read.html */
.reading-onboarding {
  background: #e6f0ea;
  border: 1px solid #8ab09a;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.reading-onboarding-body {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.reading-onboarding-body > strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}
.reading-onboarding-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.reading-onboarding-list li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.onboarding-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.onboarding-dot--unmastered { background: #fca5a5; }
.onboarding-dot--mastered   { background: #8ab09a; }
.reading-onboarding-close {
  flex-shrink: 0;
  width: auto;
  height: auto;
  margin-top: 0;
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
  align-self: center;
  white-space: nowrap;
  cursor: pointer;
}
.reading-onboarding-close:enabled { cursor: pointer; }
.reading-onboarding-close:hover { filter: brightness(0.9); }

/* Standalone reading section (read.html) — no dividing border at top */
.reading-section--solo {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.reading-section--solo .reading-text {
  max-height: none;
  overflow-y: visible;
}

/* 4-step progress bar — narrower connector lines to fit */
.progress-4 .line { width: 44px; }

/* 5-step progress bar — even narrower connector lines to fit */
.progress-5 .line { width: 28px; }

/* Learn step — flashcard */
.learn-counter { font-size: var(--fs-md); color: var(--muted); margin-bottom: 12px; }
.learn-word {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: var(--fs-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  margin: 8px 0 0;
  color: var(--text);
  overflow-wrap: break-word;
  word-break: break-word;
}
.learn-divider {
  font-size: var(--fs-xl);
  color: var(--card-border);
  margin: 10px 0 6px;
  line-height: 1;
}
.learn-translation {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 8px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.btn-audio {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--card-border);
  margin: 6px auto 2px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-audio:enabled {
  background: transparent;
  cursor: pointer;
}
.btn-audio:enabled:hover {
  background: #ede8dd;
  border-color: #9a9088;
}
.btn-audio:active {
  background: #d4cfc6;
}
.btn-flag,
.btn-flag:enabled {
  height: auto;
  width: auto;
  display: block;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--card-border);
  font-size: 15px;
  margin-top: 8px;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-flag:hover { background: #ede8dd; color: var(--text); border-color: #9a9088; }
.flagged-badge {
  display: inline-block;
  font-size: 13px;
  color: #d97706;
  background: #fef3c7;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.last-word-badge {
  display: inline-block;
  font-size: 13px;
  color: var(--green);
  background: #e6efe9;
  border: 1px solid #8ab09a;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
  font-weight: 700;
}
.word-badge-common {
  display: inline-block;
  font-size: 13px;
  color: #1d4ed8;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.word-badge-frequent {
  display: inline-block;
  font-size: 13px;
  color: #5b21b6;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.word-badge-advanced {
  display: inline-block;
  font-size: 13px;
  color: #c2410c;
  background: #ffedd5;
  border: 1px solid #fdba74;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.btn-skip,
.btn-skip:enabled {
  height: auto;
  width: auto;
  display: block;
  background: transparent;
  color: var(--muted);
  border: 1px solid #cdc7bb;
  font-size: 14px;
  margin-top: 8px;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-skip:hover { background: #ede8dd; color: var(--text); border-color: #9a9088; }
.word-badge-missed {
  display: inline-block;
  font-size: 13px;
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.word-badge-sr {
  display: inline-block;
  font-size: 13px;
  color: #0369a1;
  background: #e0f2fe;
  border: 1px solid #7dd3fc;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.word-badge-mastered {
  display: inline-block;
  font-size: 13px;
  color: var(--green);
  background: #e6efe9;
  border: 1px solid #8ab09a;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
  font-weight: 700;
}
.quiz-lesson-recap {
  background: #f0f4f2;
  border: 1px solid #8ab09a;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 16px;
  text-align: left;
}
.quiz-lesson-recap-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.quiz-lesson-recap-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
}
.quiz-lesson-chip {
  display: inline-block;
  background: #fff;
  border: 1px solid #8ab09a;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.word-badge-challenge {
  display: inline-block;
  font-size: 13px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 4px 10px;
  margin-bottom: 8px;
}
.feedback-lesson-note {
  font-size: 14px;
  font-weight: 400;
  margin-top: 8px;
  opacity: 0.85;
}
.sr-context {
  font-size: 13px;
  color: var(--muted);
  margin: -8px 0 12px;
}
.sr-schedule-section {
  text-align: left;
  margin: 16px 0 4px;
}
.sr-schedule-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.sr-schedule {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.sr-schedule-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-bottom: 2px solid var(--card-border);
  background: #fefcf9;
}
.sr-schedule-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid #e8e3db;
  font-size: 14px;
  align-items: center;
}
.sr-schedule-row:last-child { border-bottom: none; }
.sr-schedule-word { font-weight: 700; overflow-wrap: break-word; }
.sr-schedule-label { color: var(--muted); }
.sr-label-mastered { color: var(--green); font-weight: 700; }
.sr-label-due-today { color: #d97706; font-weight: 700; }
.btn-start-quiz,
.btn-start-quiz:enabled {
  background: linear-gradient(90deg, var(--green), #3d8a64);
}

.learn-complete-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 8px;
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .step-group {
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }
  .progress { gap: 4px; }
}

@media (max-width: 1000px) {
  .brand { padding-left: 60px; }
}

@media (max-width: 900px) {
  .brand { padding-left: 40px; font-size: 30px; }
  main { margin-top: 20px; }
  .card { width: calc(100% - 32px); }
  .card h1 { font-size: var(--fs-2xl); }
  .card p { font-size: 24px; }
  .lang .name { font-size: 18px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .learn-word { font-size: 44px; }
  .learn-divider { font-size: 22px; }
  .learn-translation { font-size: 26px; }
  .quiz-word { font-size: 38px; }
}

@media (max-width: 600px) {
  .brand { padding-left: 24px; padding-top: 14px; }
  main { margin-top: 12px; }
  .card { margin-top: 16px; margin-bottom: 16px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .lang { padding: 16px 8px; }
  .lang .flag { font-size: 28px; }
  .lang .name { font-size: 16px; }
  .progress { gap: 6px; }
  .progress .label { font-size: 12px; }
  .line { width: 32px; }
  .upload-area {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  .learn-word { font-size: 36px; }
  .learn-divider { font-size: 20px; }
  .learn-translation { font-size: 22px; }
  .quiz-word { font-size: 30px; }
  .answer-feedback { font-size: 18px; padding: 12px; }
  button { min-height: 44px; }
}

/* Intro / landing page */
.intro-main {
  max-width: 760px;
  margin: 60px auto 0;
  padding: 0 16px;
  text-align: center;
}
.intro-hero {
  margin-bottom: 48px;
}
.intro-headline {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-extrabold);
  line-height: var(--lh-heading);
  margin: 0 0 20px;
  color: var(--text);
}
.intro-subheadline {
  font-size: 22px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}
.intro-loop {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  margin-bottom: 48px;
  flex-wrap: wrap;
}
.loop-step {
  background: #fefcf9;
  border: 2px solid var(--card-border);
  border-radius: 18px;
  padding: 28px 20px 22px;
  width: 200px;
  box-shadow: 0 4px 14px rgba(29, 26, 22, 0.06);
}
.loop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  line-height: 1;
}
.loop-icon svg {
  width: 36px;
  height: 36px;
  stroke: var(--green);
  fill: none;
}
.loop-label {
  font-size: var(--fs-lg);
  font-weight: var(--fw-extrabold);
  color: var(--text);
  margin-bottom: 8px;
}
.loop-desc {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.4;
}
.loop-arrow {
  font-size: 32px;
  font-weight: 800;
  color: var(--green);
  align-self: center;
  padding: 0 4px;
}
.intro-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, var(--green), #3d8a64);
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 26px;
  font-weight: 700;
  border-radius: 12px;
  padding: 0 48px;
  height: 64px;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s;
}
.intro-cta:hover { filter: brightness(0.93); }
.intro-cta:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.3); }

@media (max-width: 900px) {
  .intro-headline { font-size: var(--fs-2xl); }
  .intro-subheadline { font-size: var(--fs-md); }
}
@media (max-width: 600px) {
  .intro-main { margin-top: 24px; }
  .intro-headline { font-size: 28px; }
  .intro-subheadline { font-size: 16px; }
  .intro-loop { flex-direction: column; align-items: center; }
  .loop-arrow { transform: rotate(90deg); padding: 0; }
  .loop-step { width: min(280px, 100%); }
  .intro-cta { font-size: 20px; padding: 0 32px; height: 56px; }
}

@media (max-width: 375px) {
  .brand { font-size: 24px; }
  .card { margin-top: 8px; }
  .card h1 { font-size: 28px; }
  .card p { font-size: 18px; margin-bottom: 16px; }
  button { font-size: 18px; }
  .learn-word { font-size: 28px; }
  .learn-divider { font-size: 16px; }
  .learn-translation { font-size: 18px; }
  .quiz-word { font-size: 24px; }
  .progress { gap: 3px; align-items: center; }
  .progress-4 .line { width: 16px; }
  .progress-5 .line { width: 8px; }
  .step-group .label { font-size: 10px; }
}
