:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: #111721;
  --surface-raised: #151e2a;
  --line: rgba(220, 233, 248, 0.15);
  --text: #f5f8fc;
  --muted: #a8b6c6;
  --blue: #1eb7ff;
  --orange: #ff8c1a;
  --green: #68d9a5;
  --red: #ff8a7a;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    radial-gradient(circle at 78% 9%, rgba(30, 183, 255, 0.16), transparent 27rem),
    radial-gradient(circle at 8% 60%, rgba(255, 140, 26, 0.1), transparent 26rem),
    var(--bg);
  background-size: 42px 42px, 42px 42px, auto, auto, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.shell {
  width: min(1080px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.topbar,
.footer-links,
.panel-heading,
.progress-overview,
.mode-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  min-height: 32px;
}

.back-link,
.footer a {
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover,
.footer a:hover {
  color: var(--blue);
}

.data-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.data-source::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--orange);
  content: "";
}

.data-source[data-source="supabase"]::before {
  background: var(--green);
}

.intro {
  max-width: 760px;
  padding: 58px 0 28px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.35rem, 6vw, 4.6rem);
  line-height: 0.99;
  letter-spacing: -0.055em;
}

h1 span {
  color: var(--orange);
}

.lede {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(0.98rem, 2vw, 1.12rem);
  line-height: 1.6;
}

.language-bar {
  min-width: 0;
  margin: 0;
  padding: 12px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 23, 33, 0.86);
}

.language-bar legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.language-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.language-choice {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b111a;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 750;
}

.language-choice:has(input:checked) {
  border-color: var(--blue);
  background: #203044;
  color: var(--text);
}

.language-choice input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.language-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.word-list-language {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
}


.progress-overview {
  gap: 26px;
  margin: 20px 0;
  padding: 14px 2px 16px;
  border-bottom: 1px solid var(--line);
}

.progress-copy {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 24px;
}

.progress-copy .eyebrow {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.6rem;
}

.progress-copy strong {
  display: block;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.progress-copy strong span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.progress-track {
  width: min(360px, 100%);
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #202a37;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #66d5ff);
  transition: width 240ms ease;
}

.deck-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.word-list-section {
  margin: -4px 0 20px;
}

.word-list-toggle {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(30, 183, 255, 0.4);
  border-radius: 9px;
  background: #122536;
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
}

.word-list-toggle:hover {
  border-color: var(--blue);
  background: #193247;
}

.word-list-toggle::after {
  margin-left: 12px;
  color: var(--blue);
  content: "+";
  font-size: 1.1rem;
}

.word-list-toggle[aria-expanded="true"]::after {
  content: "−";
}

.word-list-panel {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 23, 33, 0.91);
}

.word-list-panel[hidden] {
  display: none;
}

.word-list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.word-list-header h2,
.word-list-header p {
  margin-bottom: 0;
}

.word-list-header h2 {
  font-size: 1.1rem;
}

.word-list-header p {
  color: var(--muted);
  font-size: 0.8rem;
}

.word-list-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.word-list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d131c;
}

.word-list-terms {
  display: grid;
  gap: 3px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.word-list-danish {
  color: var(--muted);
  font-size: 0.78rem;
}

.word-list-reading,
.word-list-target.is-primary {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 750;
}

.word-list-target {
  color: var(--orange);
  font-size: 0.85rem;
  line-height: 1.3;
}

.word-list-status {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  white-space: nowrap;
}

.word-list-item.is-learned .word-list-status {
  border-color: rgba(104, 217, 165, 0.4);
  background: rgba(104, 217, 165, 0.1);
  color: var(--green);
}

.learning-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.8fr);
  align-items: start;
  gap: 18px;
}

.practice-panel,
.deck-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 23, 33, 0.91);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
}

.practice-panel {
  min-height: 430px;
  padding: 22px;
}

.deck-panel {
  padding: 20px;
}

.panel-heading {
  gap: 16px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.025em;
}

.panel-heading .eyebrow {
  margin-bottom: 5px;
}

.mode-step {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.practice-controls {
  margin: 20px 0 18px;
}

.control-group {
  max-width: 580px;
  min-width: 0;
}

.control-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: stretch;
  gap: 5px;
  min-height: 52px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1119;
}

.mode-tab {
  min-width: 0;
  min-height: 40px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.25;
  transition: background 150ms ease, color 150ms ease;
}

.mode-tab[aria-pressed="true"] {
  background: #203044;
  color: white;
  box-shadow: inset 0 0 0 1px rgba(30, 183, 255, 0.35);
}

.mode-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.question-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.question-word {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 780;
  line-height: 1.12;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.question-roman,
.question-danish {
  display: block;
  color: var(--text);
  font-size: clamp(2.25rem, 5.5vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.question-target {
  display: block;
  margin-top: 0;
  color: var(--orange);
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.question-target.is-primary {
  color: var(--text);
  font-size: clamp(1.5rem, 5.5vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.08;
  white-space: nowrap;
}

.question-card {
  min-height: 156px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 0 16px;
  padding: 20px;
  border: 1px solid rgba(255, 140, 26, 0.23);
  border-radius: 11px;
  background:
    radial-gradient(circle at 88% 12%, rgba(255, 140, 26, 0.1), transparent 45%),
    #0c121b;
}

.word-pair {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.word-language {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.answer-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  min-height: 68px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 720;
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.answer-target {
  color: var(--orange);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
}

.answer-target.is-primary {
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 720;
  letter-spacing: -0.015em;
}

.answer-reading {
  color: var(--text);
  font-size: 1.12rem;
  font-weight: 720;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.answer-choice:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--blue);
  background: #1a2938;
}

.answer-choice:disabled {
  cursor: default;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.answer-form input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0a1018;
  color: var(--text);
  font-size: 1rem;
}

.answer-form input::placeholder {
  color: #7f8da0;
}

.hint-panel {
  margin: 15px 0 11px;
  padding: 13px;
  border: 1px solid rgba(30, 183, 255, 0.2);
  border-radius: 10px;
  background: rgba(10, 16, 24, 0.72);
}

.hint-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hint-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.hint-button,
.hint-method {
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 750;
}

.hint-button {
  min-height: 34px;
  padding: 0 13px;
  border-color: rgba(30, 183, 255, 0.45);
  background: #152738;
  color: white;
  font-size: 0.8rem;
}

.hint-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.hint-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.hint-method {
  min-height: 32px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
}

.hint-method[aria-pressed="true"] {
  border-color: rgba(255, 140, 26, 0.6);
  background: rgba(255, 140, 26, 0.12);
  color: white;
}

.hint-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.hint-pattern {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px;
  min-height: 34px;
  margin-top: 11px;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.7;
}

.hint-letter {
  display: inline-flex;
  min-width: 0.82em;
  justify-content: center;
  border-bottom: 1px solid rgba(168, 182, 198, 0.5);
  color: #6f8093;
}

.hint-letter.is-revealed {
  border-color: var(--orange);
  color: var(--orange);
}

.hint-space {
  flex: 0 0 0.5em;
}

.hint-symbol {
  color: var(--muted);
}

.submit-button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  background: var(--blue);
  color: #061018;
  cursor: pointer;
  font-weight: 800;
}

.submit-button:hover {
  filter: brightness(1.08);
}

.feedback {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.5;
}

.feedback[data-kind="success"],
.feedback[data-kind="error"],
.feedback[data-kind="learned"] {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.feedback[data-kind="success"],
.feedback[data-kind="learned"] {
  color: var(--green);
}

.feedback[data-kind="error"] {
  color: var(--red);
  font-size: 1rem;
  font-weight: 400;
}

.feedback-title {
  display: block;
  margin-bottom: 12px;
  color: var(--red);
  font-size: 1.15rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.correction-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  border: 1px solid rgba(255, 138, 122, 0.5);
  border-radius: 10px;
  overflow: hidden;
  color: var(--text);
}

.correction-matrix th,
.correction-matrix td {
  width: 50%;
  padding: 10px 13px;
  overflow-wrap: anywhere;
  text-align: left;
}

.correction-matrix th {
  background: rgba(255, 138, 122, 0.12);
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.correction-matrix th + th,
.correction-matrix td + td {
  border-left: 1px solid rgba(255, 138, 122, 0.3);
}

.correction-matrix tbody tr + tr td {
  border-top: 1px solid rgba(255, 138, 122, 0.3);
}

.correction-matrix td {
  background: rgba(255, 138, 122, 0.04);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  font-weight: 750;
  line-height: 1.25;
}

.correction-matrix .is-correct td {
  background: rgba(104, 217, 165, 0.09);
}

.feedback-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.deck-mark {
  color: rgba(30, 183, 255, 0.85);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.active-words {
  display: grid;
  gap: 10px;
  margin: 18px 0 14px;
  padding: 0;
  list-style: none;
  counter-reset: words;
}

.word-row {
  position: relative;
  min-height: 72px;
  padding: 12px 12px 11px 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d131c;
  counter-increment: words;
}

.word-row::before {
  position: absolute;
  top: 13px;
  left: 13px;
  color: var(--orange);
  content: "0" counter(words);
  font-size: 0.75rem;
  font-weight: 850;
}

.word-row-name {
  display: block;
  margin-bottom: 7px;
  font-size: 0.97rem;
  font-weight: 760;
}

.word-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metric {
  padding: 3px 7px;
  border: 1px solid rgba(168, 182, 198, 0.15);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.63rem;
  line-height: 1.2;
}

.metric.is-done {
  border-color: rgba(104, 217, 165, 0.34);
  color: var(--green);
}

.deck-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.loading,
.complete-message {
  color: var(--muted);
  line-height: 1.6;
}

.complete-message {
  min-height: 250px;
  display: grid;
  align-content: center;
  text-align: center;
}

.complete-message strong {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 1.45rem;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.footer p {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.5;
}

.footer-links {
  flex: 0 0 auto;
  gap: 16px;
}

.footer-links a,
.footer-links button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  text-decoration: none;
  white-space: nowrap;
}

.footer-links a:hover,
.footer-links button:hover {
  color: var(--orange);
}

@media (max-width: 780px) {
  .word-list-items {
    grid-template-columns: 1fr;
  }

  .learning-layout {
    grid-template-columns: 1fr;
  }

  .deck-panel {
    order: -1;
  }

  .active-words {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .word-row {
    padding-left: 12px;
    padding-top: 34px;
  }

  .word-row::before {
    top: 11px;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 24px, 1080px);
    padding-top: 16px;
  }

  .intro {
    padding: 42px 0 22px;
  }

  .language-choices {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .language-choice {
    padding: 9px 10px;
  }

  .progress-overview {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .progress-copy {
    width: 100%;
    gap: 15px;
  }

  .progress-track {
    flex: 1;
  }

  .practice-panel,
  .deck-panel {
    padding: 16px;
  }

  .active-words {
    grid-template-columns: 1fr;
  }

  .word-row {
    min-height: 66px;
    padding: 12px 12px 10px 44px;
  }

  .word-row::before {
    top: 13px;
  }

  .word-pair {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 8px;
  }

  .word-language {
    font-size: 0.72rem;
  }

  .answer-grid {
    grid-template-columns: 1fr;
  }

  .answer-choice {
    min-height: 54px;
  }

  .footer-links {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


.miraris-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 7px;
  border: 1px solid rgba(30, 183, 255, 0.35);
  border-radius: 6px;
  background: #122536;
  color: var(--blue);
  font-size: 0.65rem;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.miraris-link:hover {
  border-color: var(--blue);
  background: #193247;
  color: var(--text);
}

.question-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.question-word {
  min-width: 0;
}

.answer-option {
  position: relative;
  display: grid;
  min-width: 0;
}

.answer-option .answer-choice {
  width: 100%;
  min-width: 0;
  padding-bottom: 40px;
}

.answer-option > .miraris-link {
  position: absolute;
  right: 8px;
  bottom: 7px;
}

.word-row-heading,
.word-list-danish-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.word-row-heading {
  margin-bottom: 7px;
}

.word-row-heading .word-row-name {
  margin-bottom: 0;
}

.word-list-actions {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

.feedback-word-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.correction-matrix td .miraris-link {
  display: table;
  margin-top: 7px;
}

@media (max-width: 560px) {
  .question-content {
    flex-wrap: wrap;
    gap: 8px;
  }
}

.japanese-scripts { display: grid; gap: 0.3em; width: 100%; }
.japanese-script { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3em 0.65em; }
.script-label { color: var(--muted); font-size: 0.6em; font-weight: 500; min-width: 5.6em; }
.question-target .japanese-scripts, .answer-target .japanese-scripts,
.word-list-target .japanese-scripts { font-size: inherit; }
.matrix-reading { display: block; margin-bottom: 0.3em; }

/* Enlarge only words in Japanese, Greek, Arabic and Cyrillic scripts. */
.question-target:is([lang="ja"], [lang="el"], [lang="ar"], [lang="sr"], [lang="ru"]) { font-size: 1.44rem; }
.question-target.is-primary:is([lang="ja"], [lang="el"], [lang="ar"], [lang="sr"], [lang="ru"]) { font-size: clamp(2.25rem, 8.25vw, 5.7rem); }
.answer-target:is([lang="ja"], [lang="el"], [lang="ar"], [lang="sr"], [lang="ru"]) { font-size: 1.17rem; }
.answer-target.is-primary:is([lang="ja"], [lang="el"], [lang="ar"], [lang="sr"], [lang="ru"]) { font-size: 1.68rem; }
.word-list-target:is([lang="ja"], [lang="el"], [lang="ar"], [lang="sr"], [lang="ru"]) { font-size: 1.275rem; }
.word-list-target.is-primary:is([lang="ja"], [lang="el"], [lang="ar"], [lang="sr"], [lang="ru"]) { font-size: 1.575rem; }
.correction-matrix .japanese-scripts { font-size: 1.5em; }
.japanese-scripts .script-label { font-size: 0.4em; }

.word-tools {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.question-tools {
  flex: 0 0 auto;
  flex-direction: column;
}

.history-button {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 140, 26, 0.5);
  border-radius: 6px;
  background: #2a2118;
  color: var(--orange);
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

.history-button:hover {
  background: #3a2c1b;
  border-color: var(--orange);
  color: var(--text);
}

.answer-option > .word-tools {
  position: absolute;
  right: 8px;
  left: 8px;
  bottom: 7px;
  justify-content: space-between;
}

.correction-matrix td .word-tools {
  display: flex;
  margin-top: 7px;
}

.correction-matrix td .word-tools .miraris-link {
  display: inline-flex;
  margin-top: 0;
}

body:has(.history-dialog[open]) {
  overflow: hidden;
}

.history-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 26px;
  overflow-y: auto;
  border: 1px solid rgba(255, 140, 26, 0.4);
  border-radius: 16px;
  background: #111721;
  color: var(--text);
  box-shadow: 0 24px 100px rgba(0, 0, 0, 0.6);
}

.history-dialog::backdrop {
  background: rgba(4, 7, 12, 0.82);
  backdrop-filter: blur(5px);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.history-header h2 {
  margin-bottom: 8px;
  font-size: 1.8rem;
  overflow-wrap: anywhere;
}

#history-subtitle {
  margin: 0;
  color: var(--orange);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.history-close {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #203044;
  color: var(--text);
  cursor: pointer;
}

.history-scope {
  margin: 20px 0;
  font-weight: 750;
}

.history-hint-note {
  margin: 16px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 140, 26, 0.1);
  color: var(--orange);
  font-size: 0.8rem;
  line-height: 1.5;
}

#history-content section {
  margin: 24px 0;
}

#history-content h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

#history-content section > p,
.history-draft {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.history-explication {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 23px;
  line-height: 1.65;
}

.history-molecule {
  color: var(--orange);
  font-weight: 700;
}

.history-primes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.history-primes li {
  padding: 10px;
  border: 1px solid rgba(30, 183, 255, 0.2);
  border-radius: 8px;
  background: #0c1823;
}

.history-primes strong {
  display: block;
  color: var(--blue);
  font-size: 0.9rem;
}

.history-primes span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.6rem;
}

.history-molecules {
  display: grid;
  gap: 8px;
}

.history-molecules details {
  padding: 11px 13px;
  border: 1px solid rgba(255, 140, 26, 0.2);
  border-radius: 8px;
  background: #191a1e;
}

.history-molecules summary {
  cursor: pointer;
  font-weight: 700;
}

.history-molecules summary span {
  color: var(--orange);
}

.history-molecules p {
  margin: 10px 0 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.history-draft {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.history-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.history-sources a {
  color: var(--blue);
  font-size: 0.76rem;
}

@media (max-width: 560px) {
  .history-dialog { padding: 18px; }
  .history-header h2 { font-size: 1.4rem; }
}

.kana-memo-button {
  display: inline;
  margin: 0;
  padding: 0 0.04em;
  border: 0;
  border-bottom: 1px dotted currentColor;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
}
.kana-memo-button:hover { background: rgba(255, 140, 26, 0.18); }
.kana-memo-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.answer-option.has-kana {
  align-content: start;
  padding-bottom: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #161e29;
}
.answer-option.has-kana .answer-choice {
  min-height: 44px;
  padding-bottom: 8px;
  border: 0;
  background: transparent;
}
.answer-option.has-kana > .answer-target { padding: 0 13px 10px; cursor: pointer; }
.kana-dialog { width: min(1000px, calc(100% - 24px)); }
.kana-note { color: var(--muted); font-size: 0.85rem; line-height: 1.6; }
.kana-images { display: grid; gap: 16px; }
.kana-images img { display: block; width: 100%; height: auto; border-radius: 8px; background: white; }

/* Large translation heading above the displayed word. */
.translation-cue {
  margin: 22px 0 16px;
  color: var(--text);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 500;
  line-height: 1.25;
}

.language-flag { display: inline-block; width: 28px; height: 20px; object-fit: cover; border-radius: 4px; margin-inline-end: 8px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(255,255,255,.2); flex-shrink: 0; }
.word-illustration { display: block; object-fit: contain; border-radius: 10px; width: 160px; height: 160px; background: #101722; flex-shrink: 0; }
.word-illustration.is-choice { width: 100%; height: 96px; margin-top: 8px; }
.word-illustration[hidden] { display: none; }
.word-illustration.is-prompt { width: clamp(90px, 14vw, 160px); height: auto; aspect-ratio: 1; }
.question-content.has-illustration { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; }
.word-row-name { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.answer-choice > .language-flag { margin-bottom: 3px; }
.answer-reading { display: flex; align-items: center; gap: 4px; }
.feedback-word-links { align-items: center; }
@media (max-width: 560px) {
  .question-content.has-illustration { grid-template-columns: minmax(0, 1fr) 80px; gap: 10px; }
  .question-content.has-illustration .question-tools { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .word-illustration.is-prompt { width: 80px; }
  .question-word .language-flag { width: 24px; height: 17px; margin-right: 5px; }
}


.history-scope {
  margin: 20px 0;
  font-weight: 750;
}

.history-path {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0b1019;
  font-size: 1rem;
  line-height: 1.8;
}

.history-path bdi { overflow-wrap: anywhere; }
.history-path .reconstructed { color: #86d7cc; }
.history-path .hypothesis { color: #efbd77; text-decoration: underline dotted; }
.history-path-arrow { color: var(--muted); }

#history-content .history-boundary {
  margin: 20px 0;
  padding: 16px 18px;
  border: 1px dashed #806642;
  border-radius: 10px;
  background: #211d18;
}

.history-boundary .eyebrow { font-size: 0.65rem; margin: 0 0 6px; }
.history-boundary p:last-child { margin-bottom: 0; }
.history-date-note { color: var(--muted); font-size: 0.76rem; line-height: 1.6; }

.history-timeline { list-style: none; padding: 0; margin: 18px 0 0; }
.history-step { position: relative; padding: 18px 18px 20px 24px; border-left: 2px solid #426272; }
.history-step.reconstructed { border-left-color: #61b7a9; background: rgba(97,183,169,0.04); }
.history-step.hypothesis { border-left: 2px dashed #cf9c55; background: rgba(207,156,85,0.05); }
.history-step::before { content: ''; position: absolute; top: 24px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: #85c2db; }
.history-step.reconstructed::before { background: #86d7cc; }
.history-step.hypothesis::before { background: #efbd77; }
.history-stage { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; font-size: 0.8rem; font-weight: 750; }
.history-status { padding: 3px 7px; border-radius: 4px; background: #1d2935; color: #b0d1df; font-size: 0.63rem; }
.reconstructed .history-status { background: #17312e; color: #86d7cc; }
.hypothesis .history-status { background: #36291b; color: #efbd77; }
.history-period { margin: 6px 0 12px; color: var(--muted); font-size: 0.72rem; }
.history-step h4 { font-size: clamp(1.3rem, 4vw, 1.7rem); margin: 0 0 7px; line-height: 1.45; overflow-wrap: anywhere; }
.history-reading { color: #b7cadd; margin: 0 0 10px; font-size: 0.88rem; overflow-wrap: anywhere; }
.history-change { margin: 0; color: var(--muted); font-size: 0.87rem; line-height: 1.65; }
.history-transition { color: #80b7c9; font-size: 0.65rem; margin: -4px 0 15px; letter-spacing: 0.03em; }
.history-transition.uncertain { color: #efbd77; }
.history-transition span { margin-right: 5px; }
.history-notation { padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.history-notation summary { cursor: pointer; font-size: 0.85rem; font-weight: 750; }
.history-notation p { font-size: 0.8rem; color: var(--muted); line-height: 1.7; }
.history-notation p:last-child { margin-bottom: 0; }
.history-notation strong { color: var(--text); }
.history-relatives { padding: 16px; border-radius: 10px; background: #18212c; }
.history-button:focus-visible, .history-close:focus-visible, .history-notation summary:focus-visible { outline: 2px solid #86d7cc; outline-offset: 4px; }

.history-hint-note {
  margin: 16px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 140, 26, 0.1);
  color: var(--orange);
  font-size: 0.8rem;
  line-height: 1.5;
}

#history-content section {
  margin: 24px 0;
}

#history-content h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

#history-content section > p,
.history-draft {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.history-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.history-sources a {
  color: var(--blue);
  font-size: 0.76rem;
}

@media (max-width: 560px) {
  .history-dialog { padding: 18px; }
  .history-header h2 { font-size: 1.4rem; }
}
