:root {
  color-scheme: light;
  --paper: #f5efe5;
  --surface: #fffcf6;
  --surface-strong: #eadfce;
  --ink: #392f27;
  --muted: #6d5c4d;
  --rule: #c8b7a3;
  --rule-soft: #e2d5c5;
  --accent: #b4754d;
  --accent-strong: #79452c;
  --accent-soft: #efe2d1;
  --amber: #925117;
  --amber-soft: #f3e3ca;
  --red: #a73c36;
  --red-soft: #f7e2dc;
  --green: #486b46;
  --green-soft: #e4ecdd;
  --shadow: 0 16px 34px rgb(65 43 27 / 12%);
  --body-font: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --keyboard-inset: 0px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body-font);
  font-size: 15px;
  line-height: 1.5;
}

.loading-progress {
  width: 100%;
  height: 4px;
  display: block;
  border: 0;
  accent-color: var(--accent);
  color: var(--accent);
}

.loading-progress[hidden] {
  display: none;
}

.loading-progress::-webkit-progress-bar {
  background: var(--rule-soft);
}

.loading-progress::-webkit-progress-value {
  background: var(--accent);
}

.loading-progress::-moz-progress-bar {
  background: var(--accent);
}

.app-loading-progress {
  margin-bottom: 8px;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select,
summary,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

a {
  color: var(--accent-strong);
}

:focus-visible {
  outline: 3px solid #a34a10;
  outline-offset: 3px;
}

.app-shell {
  width: min(100% - 64px, 1440px);
  margin-inline: auto;
}

.topbar {
  min-height: 82px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--rule);
}

.brand {
  grid-column: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: block;
  object-fit: contain;
  border-radius: 6px;
}

.brand-name {
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.topbar-menu-panel {
  display: contents;
}

.topbar-nav {
  min-width: 0;
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
}

.topbar-link {
  position: relative;
  min-width: 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.topbar-link > svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.topbar-link:first-child > svg {
  fill: none;
}

.topbar-link:hover {
  color: var(--accent-strong);
  background: var(--surface);
}

.topbar-link[aria-current="location"] {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.topbar-menu-button {
  display: none;
}

.topbar-menu-icon {
  width: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topbar-menu-icon span {
  width: 20px;
  height: 2px;
  display: block;
  border-radius: 999px;
  background: currentColor;
  transition: transform 160ms ease, opacity 120ms ease;
}

.topbar-link-short {
  display: none;
}

.topbar-tools {
  min-width: 0;
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
  padding: 8px;
  color: var(--ink);
}

.offline-status {
  color: var(--ink);
  cursor: pointer;
}

.offline-progress {
  height: 3px;
  margin-top: 8px;
}

.offline-status svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #b27811;
}

.offline-status.is-ready .status-dot {
  background: var(--green);
}

.offline-status.is-error .status-dot {
  background: var(--red);
}

.app-version {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.settings-version {
  margin: 0;
}

.topbar-panel {
  position: relative;
  flex: 0 0 auto;
}

.topbar-panel::after {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  height: 10px;
  content: "";
}

.topbar-panel-trigger svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.topbar-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(310px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-5px);
  visibility: hidden;
  transition: opacity 160ms ease, transform 180ms ease, visibility 180ms;
}

.topbar-popover-content {
  display: grid;
  gap: 8px;
}

.topbar-panel.is-open .topbar-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  visibility: visible;
}

.topbar-panel-copy {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.topbar-panel-action {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: start;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.topbar-panel-action:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.topbar-panel-action:disabled {
  cursor: wait;
  opacity: 0.65;
}

.update-progress {
  width: 100%;
  margin-top: 8px;
}

.update-short {
  display: none;
}

.update-feedback {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.topbar-panel-action .update-short {
  display: none;
}

.update-feedback[hidden] {
  display: none;
}

.install-dialog {
  width: min(420px, calc(100vw - 32px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 50px rgb(23 47 50 / 24%);
}

.install-dialog::backdrop {
  background: rgb(23 47 50 / 42%);
}

.install-dialog-content {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.install-dialog h2 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 29px);
  line-height: 1.2;
}

.install-dialog p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.install-dialog .next-button {
  width: 100%;
  margin-top: 4px;
}

.theme-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.language-button {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.learning-tabs-shell {
  position: relative;
  min-width: 0;
  flex: 0 1 340px;
  z-index: 20;
}

.learning-area-selector {
  position: relative;
  display: block;
  width: min(340px, 100%);
  max-width: 100%;
  margin-left: auto;
}

.learning-area-summary {
  min-height: 48px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  text-align: left;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.learning-area-summary::-webkit-details-marker {
  display: none;
}

.learning-area-summary:hover,
.learning-area-selector[open] .learning-area-summary {
  border-color: var(--accent-strong);
}

.learning-area-summary-label {
  min-width: 0;
  flex: 1 1 auto;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learning-area-chevron {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 160ms ease;
}

.learning-area-selector[open] .learning-area-chevron {
  transform: rotate(180deg);
}

.learning-tabs {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 4;
  width: min(480px, calc(100vw - 32px));
  box-sizing: border-box;
  max-height: min(45vh, 360px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.learning-tab {
  min-height: 44px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  text-align: left;
}

.learning-tab,
.tool-button,
.mode-button,
.match-option,
.soft-button,
.next-button,
.primary-button,
.bookmark-button,
.collection-favorite,
.preserve-streak-button {
  transition:
    transform 120ms cubic-bezier(0.16, 1, 0.3, 1),
    color 120ms ease,
    background-color 120ms ease,
    border-color 120ms ease,
    opacity 120ms ease;
}

.learning-tab:active,
.tool-button:active,
.mode-button:active,
.match-option:active,
.soft-button:active,
.next-button:active,
.primary-button:active,
.collection-favorite:active,
.preserve-streak-button:active {
  transform: translateY(1px) scale(0.985);
  border-bottom: 1px solid var(--rule);
}

.round-active .topbar,
.round-active .learning-tabs-shell,
.round-active .learning-tabs,
.round-active .study-heading,
.round-active .progress-section,
.round-active .collector-section,
.round-active .collection-section,
.round-active .data-tools,
.round-active .app-footer,
.round-active .more-details,
.round-active .mode-picker,
.round-active .matching-variants,
.round-active .round-config,
.round-active .round-start {
  display: none !important;
}

.round-active .color-reading {
  display: none !important;
}

.round-active .app-shell {
  width: min(100% - 32px, 1040px);
}

.round-active .workbench {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 22px;
  background: var(--surface);
}

.round-active .workbench.is-entering {
  animation: round-enter 340ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.round-active .specimen-side.is-entering {
  animation: specimen-side-enter 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.round-active .exercise-side.is-entering {
  animation: exercise-side-enter 360ms 60ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes round-enter {
  from { opacity: 0.7; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes specimen-side-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes exercise-side-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.round-active .specimen-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 24px 12px;
  border-right: 0;
  border-bottom: 1px solid var(--rule-soft);
}

.round-active .specimen-label {
  width: 100%;
}

.round-active.round-flashcard .specimen-side {
  display: none;
}

.round-active.round-matching .specimen-side {
  display: none;
}

.round-active.round-flashcard .exercise-side {
  width: min(100%, 840px);
  align-self: center;
}

.round-active .specimen-figure {
  width: 100%;
  max-width: 760px;
  height: clamp(280px, 40svh, 460px);
  min-height: 0;
  margin: 6px 0 0;
}

.round-active .exercise-side {
  width: min(100%, 840px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-self: center;
  border: 0;
  padding: 16px 24px 16px;
}

.round-active .exercise-topline {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: 8px;
}

.round-active .exercise-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.round-active .exercise-actions .source-link {
  min-height: 44px;
  justify-content: center;
  padding: 0 6px;
}

.round-active .question-block {
  min-height: 0;
  padding: 10px 0 6px;
}

.round-active .question-hint {
  display: block;
  min-height: 0;
  margin: 5px 0 0;
}

.round-active.round-flashcard .question-hint {
  display: none !important;
}

.round-active .answer-area {
  min-height: 0;
  flex: 0 0 auto;
  justify-content: flex-start;
  padding-top: 8px;
}

.round-active .feedback-slot {
  min-height: 0;
  display: flex;
  align-items: center;
}

.round-active .feedback-slot .feedback {
  width: 100%;
}

.round-active .next-row {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  border-top: 0;
  padding: 0;
  z-index: 3;
}

.round-active .next-row .next-button:not([hidden]) {
  margin-top: 12px;
}

.learning-tab {
  min-height: 64px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 17px;
  border: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.learning-tab:hover {
  color: var(--ink);
}

.learning-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.tab-glyph {
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--accent-strong);
  position: relative;
}

.tab-glyph::before {
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 50%;
  background: currentColor;
}

.tab-number {
  font-size: 14px;
}

main {
  padding-bottom: 40px;
}

body.round-active main,
body.round-result-active main {
  padding-bottom: 0;
}

.round-result-active .topbar,
.round-result-active .learning-tabs-shell,
.round-result-active .learning-tabs,
.round-result-active .study-heading,
.round-result-active .progress-section,
.round-result-active .collector-section,
.round-result-active .collection-section,
.round-result-active .data-tools,
.round-result-active .app-footer,
.round-result-active .more-details {
  display: none !important;
}

.round-result-active .app-shell {
  width: min(100% - 32px, 980px);
}

.round-result-active .workbench {
  min-height: min(820px, calc(100dvh - 32px));
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 22px;
  background: var(--surface);
}

.round-result-active .specimen-side {
  display: none;
}

.round-result-active .exercise-side {
  width: min(100%, 760px);
  min-height: min(740px, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: center;
  border: 0;
  padding: 28px;
}

.round-result-active .round-result {
  min-height: 100%;
  justify-content: center;
}

.round-result-active .round-result .next-button {
  width: 100%;
  min-height: 54px;
  margin-top: auto;
}

.tabler-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-block;
  background-color: currentColor;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.tabler-icon-route {
  -webkit-mask-image: url("./assets/mit/tabler/route.svg");
  mask-image: url("./assets/mit/tabler/route.svg");
}

.tabler-icon-bookmark {
  -webkit-mask-image: url("./assets/mit/tabler/bookmark.svg");
  mask-image: url("./assets/mit/tabler/bookmark.svg");
}

.exercise-sequence::before {
  content: "";
  width: 14px;
  height: 14px;
  display: inline-block;
  margin-right: 7px;
  vertical-align: -2px;
  background-color: currentColor;
  -webkit-mask: url("./assets/mit/tabler/diamond.svg") center / contain no-repeat;
  mask: url("./assets/mit/tabler/diamond.svg") center / contain no-repeat;
}

.study-heading {
  min-height: 142px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 24px 0 20px;
}

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

h1 {
  max-width: 12ch;
  margin-bottom: 7px;
  font-size: clamp(29px, 3.2vw, 42px);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-wrap: balance;
}

.study-heading p {
  max-width: 60ch;
  margin-bottom: 0;
  color: var(--muted);
}

.study-stats {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 16px;
  padding: 6px 0;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 9px;
}

.review-stat-button {
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.review-stat-button:hover:not(:disabled) {
  border-color: var(--accent-strong);
}

.review-stat-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.stat-symbol {
  color: var(--accent);
  font-size: 23px;
}

.stat-item strong,
.stat-item small {
  display: block;
}

.stat-item strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-item small {
  color: var(--muted);
  font-size: 11px;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--rule);
}

.workbench {
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(390px, 0.95fr);
  border: 1px solid var(--rule);
  background: var(--surface);
}

.specimen-side {
  min-width: 0;
  padding: 23px 26px 20px;
  border-right: 1px solid var(--rule);
  background: var(--surface-strong);
}

.specimen-label,
.exercise-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.specimen-index,
.specimen-kind,
.exercise-sequence,
.reading-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.timed-quiz-status {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.timed-quiz-status[hidden] {
  display: none;
}

.quiz-timer,
.quiz-score {
  color: var(--ink);
  font-size: 15px;
  font-weight: 780;
}

.quiz-tier {
  color: var(--muted);
}

.specimen-figure {
  position: relative;
  min-height: 350px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 15px 0 12px;
  border: 1px solid var(--rule-soft);
  background: var(--paper);
}

.gem-fallback {
  position: relative;
  z-index: 1;
  width: min(68%, 340px);
  max-height: 82%;
  overflow: visible;
  filter: drop-shadow(8px 14px 10px rgb(29 57 56 / 18%));
}

.gem-shadow {
  fill: #437e75;
}

.gem-face {
  stroke: rgb(255 255 255 / 55%);
  stroke-width: 1.3;
}

.gem-face-dark {
  fill: #226b66;
}

.gem-face-mid {
  fill: #73aaa0;
}

.gem-face-light {
  fill: #9dc9bd;
}

.gem-face-base {
  fill: #8b684f;
}

.gem-outline {
  fill: none;
  stroke: #fff9ed;
  stroke-linejoin: round;
  stroke-width: 1;
  opacity: 0.78;
}

.gem-image {
  position: relative;
  z-index: 1;
  width: min(84%, 480px);
  max-height: 84%;
  object-fit: contain;
  mix-blend-mode: multiply;
  filter: drop-shadow(0 10px 20px rgb(23 47 50 / 16%));
}

.gem-image.is-entering {
  animation: specimen-arrival 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.specimen-figure.is-correct::after,
.specimen-figure.is-incorrect::after {
  content: "";
  width: 8px;
  height: 8px;
  position: absolute;
  z-index: 3;
  top: 18%;
  right: 24%;
  border-radius: 50%;
  pointer-events: none;
}

.specimen-figure.is-correct::after {
  background: #d8a62a;
  box-shadow:
    -34px 18px 0 -2px #75bea7,
    26px 44px 0 -2px #f3c96b,
    -18px 76px 0 -3px #75bea7;
  animation: correct-spark 1100ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes correct-feedback {
  0% { transform: scale(0.95); }
  35% { transform: scale(1.055); }
  68% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.specimen-figure.is-incorrect {
  animation: specimen-incorrect 680ms ease-out;
}

@keyframes incorrect-feedback {
  0%, 100% { transform: translateX(0); }
  16% { transform: translateX(-6px); }
  32% { transform: translateX(5px); }
  48% { transform: translateX(-4px); }
  64% { transform: translateX(3px); }
  80% { transform: translateX(-1px); }
}

@keyframes specimen-arrival {
  from { transform: translateY(8px) scale(0.985); opacity: 0.45; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes correct-spark {
  0% { transform: scale(0.2) rotate(-10deg); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: scale(1.35) rotate(12deg); opacity: 0; }
}

@keyframes specimen-incorrect {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-7px); }
  38% { transform: translateX(6px); }
  58% { transform: translateX(-4px); }
  78% { transform: translateX(2px); }
}

.round-active .gem-image {
  width: 100%;
  height: 100%;
  max-width: calc(100% - 20px);
  max-height: min(460px, calc(40svh - 20px));
  object-fit: contain;
  object-position: center;
  padding: 0;
}

.specimen-figure.has-image .gem-fallback {
  display: none;
}

.specimen-caption {
  min-height: 25px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.specimen-name {
  font-weight: 760;
  letter-spacing: -0.02em;
}

.specimen-family {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.color-reading {
  min-height: 35px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  margin-top: 8px;
}

.color-reading .reading-label {
  flex: 0 0 auto;
}

.color-swatches {
  display: flex;
  gap: 5px;
}

.color-swatch {
  width: 15px;
  height: 15px;
  border: 1px solid rgb(23 47 50 / 32%);
  border-radius: 50%;
}

.color-reading-text {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-note {
  flex: 0 0 100%;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.source-note[hidden] {
  display: none;
}

.property-scale {
  min-width: 90px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.property-scale-track {
  height: 7px;
  position: relative;
  flex: 1;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.property-scale-range {
  position: absolute;
  top: -1px;
  bottom: -1px;
  min-width: 5px;
  background: var(--accent);
}

.exercise-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 23px 28px 20px;
}

.bookmark-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.bookmark-button > span:first-child {
  font-size: 18px;
}

.bookmark-button[aria-pressed="true"] {
  color: var(--amber);
}

.question-block {
  min-height: 94px;
  padding: 28px 0 17px;
}

.question-block h2 {
  max-width: 26ch;
  margin-bottom: 7px;
  font-size: clamp(22px, 2.2vw, 29px);
  font-weight: 710;
  letter-spacing: -0.04em;
  line-height: 1.2;
  text-wrap: balance;
}

.question-hint {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.mode-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--rule);
  background: var(--paper);
}

.mode-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.mode-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.65;
}

.mode-button:hover {
  color: var(--ink);
}

.mode-button.is-active {
  border-color: var(--rule);
  background: var(--surface);
  color: var(--accent-strong);
}

.round-config {
  padding: 0;
  border: 0;
}

.round-config-heading {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  align-items: start;
  gap: 8px 13px;
  margin-bottom: 14px;
}

.round-config h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.round-config-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.round-config-heading .learning-tabs-shell {
  width: 100%;
  flex: none;
}

.round-config-heading .learning-area-selector {
  width: 100%;
  max-width: none;
}

.round-config-heading .learning-area-summary {
  min-height: 48px;
}

.goal-controls {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  align-items: center;
  gap: 8px 13px;
}

.goal-controls label {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}

.goal-controls select {
  width: 100%;
  min-height: 48px;
  padding: 8px 11px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
}

.goal-summary {
  min-height: 20px;
  margin: 10px 0 0 !important;
  color: var(--accent-strong) !important;
  font-weight: 620;
}

.home-config {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  gap: clamp(24px, 4vw, 58px);
  align-items: center;
  margin-bottom: 34px;
  padding: 10px 0 0;
}

.home-map-panel {
  min-width: 0;
  min-height: 430px;
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  border: 0;
  border-radius: 22px;
  background: transparent;
}

.home-ambient {
  display: none;
}

@keyframes mineral-atmosphere {
  from { background-position: 0% 40%; transform: scale(1); }
  to { background-position: 100% 60%; transform: scale(1.045); }
}

.home-config-controls {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 19px;
}

.home-mode-config {
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
  background: var(--surface);
}

.home-mode-heading {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule-soft);
}

.home-daily-brief .reading-label > span:first-child {
  color: var(--accent-strong);
  font-size: 16px;
}

.home-mode-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.mode-config-content {
  padding: 10px 10px 12px;
}

.home-mode-config .mode-picker {
  background: var(--surface);
}

.home-mode-config .mode-button,
.home-mode-config .mode-button.is-active {
  border-radius: 999px;
}

.mode-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mode-button.is-active {
  border: 2px solid var(--accent-strong);
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 800;
  box-shadow: inset 0 -3px 0 var(--accent);
}

.home-daily-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 12px 15px;
  border: 1px solid var(--rule-soft);
  border-radius: 12px;
  background: var(--accent-soft);
}

.home-daily-copy-wrap {
  min-width: 0;
}

.home-daily-brief .reading-label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.home-daily-brief p {
  margin: 5px 0 3px;
  font-size: 14px;
  font-weight: 650;
}

.learning-path-steps {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.home-daily-brief .expedition-track {
  max-width: 420px;
  height: 14px;
}

.home-map-panel .home-specimen {
  width: min(84%, 430px);
  min-height: 0;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  align-items: stretch;
  justify-items: stretch;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(65 43 27 / 14%);
}

.home-specimen.is-changing {
  animation: specimen-change 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes specimen-change {
  from { opacity: 0.72; transform: translateY(5px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.home-specimen {
  position: relative;
  touch-action: pan-y;
}

.home-specimen img {
  display: block;
  width: 100%;
  height: clamp(210px, 28vw, 320px);
  position: relative;
  object-fit: contain;
  object-position: center;
  padding: 14px;
  background: var(--surface);
  touch-action: pan-y;
}

.home-specimen-image-status {
  position: absolute;
  top: 38%;
  left: 50%;
  z-index: 2;
  width: min(250px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  transform: translate(-50%, -50%);
  padding: 7px 10px;
  background: var(--surface);
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 13px;
  text-align: center;
}

.home-specimen-image-status[hidden] {
  display: none;
}

.home-specimen figcaption {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 11px 15px 13px;
  border-top: 1px solid var(--rule-soft);
  background: var(--surface);
}

.home-specimen figcaption > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.home-specimen figcaption strong {
  font-size: 19px;
  line-height: 1.25;
}

.home-specimen figcaption small {
  color: var(--muted);
}

.home-carousel-pagination {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-block: -4px;
  background: var(--surface);
}

.home-carousel-pagination[hidden] {
  display: none;
}

.home-carousel-dot {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
}

.home-carousel-dot::before {
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 50%;
  background: var(--rule);
}

.home-carousel-dot[aria-current="true"]::before {
  width: 18px;
  border-radius: 999px;
  background: var(--accent);
}

.answer-area {
  min-height: 142px;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 18px 0;
}

.round-start,
.round-result {
  min-height: 310px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
}

.round-result:not([hidden]) {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  align-content: center;
  gap: 18px;
}

.round-result-art {
  display: grid;
  place-items: center;
}

.round-result-art img {
  width: 132px;
  height: 132px;
  object-fit: contain;
}

.round-result.is-entering .round-result-art {
  animation: treasure-arrival 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.round-result.is-entering h2,
.round-result.is-entering p,
.round-result.is-entering .round-kicker {
  animation: reward-copy-enter 280ms 120ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes treasure-arrival {
  0% { transform: translateY(16px) scale(0.82) rotate(-4deg); opacity: 0; }
  55% { transform: translateY(-4px) scale(1.06) rotate(2deg); opacity: 1; }
  100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}

@keyframes reward-copy-enter {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.round-result .next-button {
  grid-column: 1 / -1;
}

.timed-quiz-review-panel {
  width: 100%;
  min-width: 0;
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}

.timed-quiz-review-panel[hidden] {
  display: none;
}

.timed-quiz-review-panel h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.timed-quiz-review {
  display: grid;
  gap: 8px;
  max-height: min(42vh, 480px);
  overflow: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timed-quiz-review-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
}

.timed-quiz-review-image {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  background: var(--surface-strong);
  object-fit: cover;
}

.timed-quiz-review-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.timed-quiz-review-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.timed-quiz-review-name {
  overflow-wrap: anywhere;
  font-size: 17px;
}

.timed-quiz-review-answer {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 14px;
}

.round-start {
  min-height: 0;
  width: 100%;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0 0 18px;
}

.home-config .round-start .next-button {
  width: 100%;
  min-height: 56px;
  border-radius: 999px;
}

.round-start[hidden],
.round-result[hidden] {
  display: none;
}

.round-start h2,
.round-result h2 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.round-start p,
.round-result p {
  max-width: 38ch;
  margin: 0 0 8px;
  color: var(--muted);
}

.round-kicker {
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

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

.answer-input,
.collection-tools input {
  min-width: 0;
  min-height: 49px;
  padding: 10px 13px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--surface);
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.answer-input:focus,
.collection-tools input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(121 69 44 / 10%);
}

.answer-input::placeholder,
.collection-tools input::placeholder {
  color: #536767;
  opacity: 1;
}

.primary-button,
.next-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 10px 17px;
  border: 1px solid var(--accent-strong);
  border-radius: 12px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 13px;
  font-weight: 720;
}

.primary-button:hover,
.next-button:hover {
  background: #0c544f;
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.choice-option,
.match-option {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
  transition:
    transform 120ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 120ms ease,
    background-color 120ms ease;
}

.choice-option:active,
.match-option:active {
  transform: scale(0.985);
}

.choice-option:hover,
.match-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-option {
  position: relative;
  padding-right: 40px;
}

.choice-option.is-correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.choice-option.is-incorrect {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.choice-option.is-correct::after,
.choice-option.is-incorrect::after {
  content: "";
  width: 18px;
  height: 18px;
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background-color: currentColor;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.choice-option.is-correct::after {
  -webkit-mask-image: url("./assets/mit/tabler/check.svg");
  mask-image: url("./assets/mit/tabler/check.svg");
}

.choice-option.is-incorrect::after {
  -webkit-mask-image: url("./assets/mit/tabler/circle-x.svg");
  mask-image: url("./assets/mit/tabler/circle-x.svg");
}

.choice-option .option-letter {
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.flashcard {
  width: 100%;
  min-height: 150px;
  display: grid;
  grid-template-columns: minmax(94px, 0.7fr) minmax(0, 1.3fr);
  align-items: center;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  transition:
    transform 180ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 180ms ease,
    background-color 180ms ease;
}

.flashcard-specimen {
  width: 100%;
  height: 126px;
  object-fit: contain;
  padding: 7px;
  background: var(--surface-strong);
}

.flashcard-label {
  display: block;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 680;
}

.flashcard:active {
  transform: scale(0.988);
}

.flashcard-value {
  display: block;
  margin-top: 6px;
  font-size: 21px;
  font-weight: 710;
  letter-spacing: -0.025em;
}

.flashcard-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-top: 12px;
}

.flashcard-wrap.is-flip-card {
  perspective: 1200px;
}

.flashcard-flip {
  position: relative;
  width: 100%;
  height: clamp(300px, 44svh, 480px);
  display: block;
  overflow: visible;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--ink);
  text-align: center;
  touch-action: manipulation;
  transform-style: preserve-3d;
  transition: transform 620ms cubic-bezier(0.2, 0.78, 0.2, 1);
}

.flashcard-flip.is-revealed {
  transform: rotateY(180deg);
  animation: flashcard-flip 640ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes flashcard-flip {
  0% {
    transform: rotateY(0deg) translateZ(0) scale(1);
  }
  42% {
    transform: rotateY(76deg) translateZ(18px) scale(1.035);
  }
  55% {
    transform: rotateY(104deg) translateZ(18px) scale(1.035);
  }
  100% {
    transform: rotateY(180deg) translateZ(0) scale(1);
  }
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--surface);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-front {
  gap: 12px;
}

.flashcard-back {
  gap: 14px;
  transform: rotateY(180deg);
  background: var(--surface-strong);
}

.flashcard-front[aria-hidden="true"],
.flashcard-back[aria-hidden="true"] {
  visibility: hidden;
}

.flashcard-flip .flashcard-specimen {
  width: 100%;
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  padding: 0;
  background: transparent;
  object-fit: contain;
}

.flashcard-flip .flashcard-label {
  flex: 0 0 auto;
  font-size: 15px;
}

.flashcard-flip .flashcard-value {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(25px, 4vw, 38px);
}

.is-flip-card .flashcard-actions {
  gap: 12px;
  padding-top: 16px;
}

.is-flip-card .flashcard-actions button {
  min-width: min(190px, 50%);
  min-height: 48px;
  font-size: 14px;
}

.soft-button {
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.soft-button.is-success {
  border-color: var(--green);
  background: var(--green-soft);
  color: #164a37;
}

.soft-button.is-retry {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: #743600;
}

.matching-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.matching-column {
  display: grid;
  align-content: start;
  gap: 7px;
}

.matching-heading {
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.match-option {
  min-height: 42px;
  font-size: 11px;
}

.match-option.is-selected {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.match-option.is-matched {
  border-color: var(--green);
  background: var(--green-soft);
  color: #164a37;
  animation: match-success 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes match-success {
  0% { transform: scale(0.96); }
  55% { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.match-option:disabled {
  opacity: 1;
}

.matching-variants {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.matching-variants[hidden] {
  display: none;
}

.matching-variant {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.matching-variant.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.match-image {
  width: 74px;
  height: 74px;
  object-fit: contain;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.has-image-loading-progress {
  position: relative;
}

.match-option {
  position: relative;
}

.image-loading-progress {
  position: absolute;
  right: 6px;
  bottom: 3px;
  left: 6px;
  z-index: 4;
  width: calc(100% - 12px);
  height: 3px;
}

.collection-gallery-item {
  min-width: 0;
  min-height: 104px;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--rule-soft);
  background: var(--surface-strong);
}

.match-thumb {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  object-fit: contain;
}

.feedback {
  padding: 10px 12px;
  margin: 0 0 10px;
  border: 1px solid var(--rule);
  font-size: 12px;
}

.feedback.is-entering {
  animation: feedback-enter 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes feedback-enter {
  from { transform: translateY(5px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.feedback.is-correct {
  animation: correct-feedback 1250ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
  border-color: #7da992;
  background: var(--green-soft);
  color: #174b37;
}

.feedback.is-incorrect {
  animation: incorrect-feedback 820ms ease-out both;
  border-color: #ca8884;
  background: var(--red-soft);
  color: #6f1b22;
}

.feedback-answer-label {
  display: block;
}

.feedback-answer {
  display: block;
  max-width: 100%;
  margin-top: 4px;
  font-size: clamp(1.25rem, 2.8vw, 1.5rem);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.feedback.is-note {
  border-color: #c79759;
  background: var(--amber-soft);
  color: #69360b;
}

.next-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-top: 1px solid var(--rule-soft);
  padding-top: 12px;
}

.next-button {
  min-height: 44px;
  padding: 7px 12px;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.source-link svg {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.source-link:hover {
  color: var(--accent-strong);
}

.progress-section {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(200px, 1.2fr) minmax(220px, 1fr);
  align-items: center;
  gap: 25px;
  padding: 23px 0 20px;
  border-bottom: 1px solid var(--rule);
}

.progress-copy h2 {
  margin-bottom: 4px;
  font-size: 16px;
  letter-spacing: -0.015em;
}

.progress-copy p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.progress-track-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  height: 16px;
  flex: 1;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.progress-track span {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-count {
  min-width: 43px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.collector-section {
  padding: 22px 0 20px;
  border-bottom: 1px solid var(--rule);
}

.collector-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(230px, 0.9fr);
  align-items: center;
  gap: 16px 30px;
}

.collector-heading h2 {
  margin: 0 0 3px;
  font-size: 19px;
}

.collector-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.rank-block {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 10px;
}

.rank-name {
  color: var(--accent-strong);
  font-size: 16px;
  font-weight: 760;
}

.rank-name.is-new-rank {
  animation: rank-facets 780ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rank-facets {
  0% { transform: translateY(3px); text-shadow: 0 0 0 transparent; }
  45% { transform: translateY(-2px); text-shadow: 0 0 12px rgb(229 189 69 / 76%); }
  100% { transform: translateY(0); text-shadow: 0 0 0 transparent; }
}

.owned-count {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.more-details {
  margin-top: 20px;
  border-block: 1px solid var(--rule);
}

.more-details > summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 690;
  list-style: none;
}

.more-details > summary::-webkit-details-marker {
  display: none;
}

.more-details > summary > span:first-child {
  color: var(--accent-strong);
  font-size: 17px;
}

.more-details > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--accent-strong);
  font-size: 20px;
  font-weight: 450;
}

.more-details[open] > summary::after {
  content: "−";
}

.more-details-content {
  padding-bottom: 12px;
}

.facet-track {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  min-height: 9px;
}

.facet {
  height: 12px;
  border: 1px solid var(--rule);
  background: var(--surface);
  clip-path: polygon(20% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%);
}

.facet.is-filled {
  border-color: var(--accent);
  background: var(--accent);
}

.preserve-streak-button {
  margin-top: 10px;
  padding: 6px 9px;
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.streak-feedback {
  margin: 7px 0 0;
  color: var(--accent-strong);
  font-size: 11px;
}

.owned-stone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 14px 0 3px;
}

.owned-stone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 11px;
}

.owned-mark {
  color: var(--accent-strong);
  font-weight: 800;
}

.expedition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 18px;
}

.expedition h3,
.seal-section h3 {
  margin: 0 0 5px;
  font-size: 13px;
}

.expedition p {
  min-height: 40px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.expedition-track {
  height: 13px;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.expedition-track span {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

.rank-ladder {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 1.8vw, 18px);
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--rule-soft);
  list-style: none;
}

.rank-block-label,
.rank-ladder-label,
.owned-stones-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rank-block-label {
  grid-column: 1 / -1;
  display: block;
  margin-bottom: 4px;
}

.rank-ladder-label,
.owned-stones-label {
  margin: 16px 0 0;
}

.rank-ladder-label + .rank-ladder {
  margin-top: 6px;
}

.owned-stones-label + .owned-stone-list {
  margin-top: 6px;
}

.rank-step {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 7px 0 0;
  border-bottom: 2px solid transparent;
}

.rank-step.is-current {
  border-bottom-color: var(--accent);
}

.rank-step-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.rank-step-marker {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.rank-step.is-current .rank-step-marker,
.rank-step.is-reached .rank-step-marker {
  color: var(--accent-strong);
}

.rank-step-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 720;
}

.rank-step-status,
.rank-step-requirement {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.rank-step.is-current .rank-step-status {
  color: var(--accent-strong);
  font-weight: 760;
}

.rank-step-track {
  height: 11px;
  display: block;
  overflow: hidden;
  border: 1px solid var(--rule);
  background: var(--surface-strong);
}

.rank-step-fill {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 480ms cubic-bezier(0.16, 1, 0.3, 1);
}

.rank-step.is-reached .rank-step-fill {
  background: var(--accent-strong);
}

.seal-section {
  margin-top: 18px;
}

.seal-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.seal {
  padding: 6px 9px;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-size: 11px;
}

.seal.is-open {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
}

.collection-section {
  padding-top: 16px;
  border-bottom: 1px solid var(--rule);
}

.collection-heading {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--rule-soft);
}

.collection-heading h2,
.data-tools h2 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 29px);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.collection-heading h2 {
  font-size: 15px;
  font-weight: 720;
}


@keyframes detail-reveal {
  from { transform: translateY(-4px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.collection-count,
.collection-status {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.sensitivity-section {
  margin-top: 24px;
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--rule);
}

.sensitivity-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.sensitivity-heading h2 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 29px);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.sensitivity-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.source-page {
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
  padding: 6px 8px;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.topbar-link-full {
  display: none;
}

.topbar-link-short {
  display: inline;
}

.sensitivity-search-label {
  display: grid;
  gap: 6px;
  max-width: 520px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.sensitivity-search-label input {
  min-height: 42px;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--rule);
  background: var(--surface);
}

.sensitivity-table-wrap {
  margin-top: 12px;
  max-height: min(70dvh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--rule-soft);
}

.sensitivity-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}

.sensitivity-table th,
.sensitivity-table td {
  min-width: 96px;
  padding: 10px;
  border-right: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  text-align: left;
  vertical-align: middle;
}

.sensitivity-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.sensitivity-cell-note {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.sensitivity-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.workshop-pdf-section {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.workshop-sensitivity-table {
  min-width: 1360px;
}

.workshop-sensitivity-table th,
.workshop-sensitivity-table td {
  min-width: 138px;
  white-space: pre-line;
  vertical-align: top;
}

.workshop-sensitivity-table th:first-child,
.workshop-sensitivity-table td:first-child {
  min-width: 190px;
  position: sticky;
  left: 0;
  z-index: 1;
}

.workshop-sensitivity-table th:first-child {
  z-index: 4;
  background: var(--surface-strong);
}

.workshop-sensitivity-table td:first-child {
  background: var(--surface);
}

.workshop-pdf-table-wrap:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .sensitivity-table tbody tr:hover > td {
    background-color: var(--accent-soft);
  }
}

.sensitivity-details,
.workshop-pdf-section {
  margin-top: 18px;
  border: 1px solid var(--rule-soft);
  background: var(--surface);
}

.sensitivity-details summary,
.workshop-pdf-section summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-weight: 760;
}

.sensitivity-details summary::-webkit-details-marker,
.workshop-pdf-section summary::-webkit-details-marker {
  display: none;
}

.sensitivity-details[open] summary span:last-child,
.workshop-pdf-section[open] summary span:last-child {
  transform: rotate(45deg);
}

.sensitivity-details-content,
.workshop-pdf-content {
  padding: 0 12px 12px;
  border-top: 1px solid var(--rule-soft);
  animation: panel-enter 180ms ease-out both;
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.sensitivity-level-bar {
  width: 100%;
  min-width: 44px;
  height: 9px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--rule);
}

.sensitivity-level-part {
  min-width: 0;
  background: var(--surface-strong);
}

.sensitivity-level-part:not(:last-child) {
  border-right: 1px solid var(--surface);
}

.sensitivity-level-part.is-filled {
  background: var(--ink);
}

.collection-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 13px;
}

.collection-tools input {
  min-height: 42px;
  flex: 1;
}

.collection-list {
  max-height: 430px;
  overflow: auto;
  border-top: 1px solid var(--rule-soft);
}

.collection-row {
  min-height: 52px;
  display: grid;
  grid-template-columns: 48px minmax(100px, 0.9fr) minmax(200px, 1.6fr) minmax(74px, auto) 38px 28px;
  align-items: center;
  gap: 11px;
  padding: 7px 6px;
  border-bottom: 1px solid var(--rule-soft);
  background: transparent;
}

.collection-row.is-expanded {
  background: var(--surface);
}

.collection-expanded {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.8fr);
  gap: 14px;
  padding: 12px 6px 14px;
  border-top: 1px solid var(--rule-soft);
}

.collection-expanded[hidden] {
  display: none;
}

.collection-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0;
}

.collection-detail-grid div {
  min-width: 0;
}

.collection-detail-grid dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.collection-detail-grid dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.collection-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 7px;
  min-width: 0;
}

.collection-gallery-image {
  width: 100%;
  height: clamp(96px, 12vw, 150px);
  display: block;
  object-fit: contain;
}

.collection-row:hover {
  background: var(--surface);
}

.collection-row button {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 690;
  text-align: left;
}

.collection-thumb {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: var(--surface-strong);
}

.collection-info {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(55px, 0.5fr) minmax(80px, 0.8fr) minmax(0, 1.5fr);
  align-items: center;
  gap: 10px;
}

.collection-details {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-ownership {
  color: transparent;
  font-size: 10px;
  white-space: nowrap;
}

.collection-ownership.is-owned {
  color: var(--accent-strong);
  font-weight: 720;
}

.collection-favorite {
  min-width: 44px;
  min-height: 44px;
  padding: 3px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--amber);
  font-size: 26px;
  line-height: 1;
}

.collection-favorite[aria-pressed="true"] {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.collection-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-family {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 28px;
  color: var(--muted);
  font-size: 11px;
}

.app-footer p {
  margin: 0;
}

.data-tools {
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--rule);
}

.data-tools h2 {
  margin-bottom: 12px;
}

.data-tools-content {
  padding: 0 0 16px;
}

.image-pack-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.8fr);
  gap: 18px;
  align-items: center;
  margin-block: 18px;
  padding: 14px 0;
  border-block: 1px solid var(--rule-soft);
}

.image-pack-copy h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.image-pack-copy p {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.photo-pack-status {
  margin-top: 8px !important;
}

.image-pack-actions {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.image-pack-actions .soft-button,
.photo-variety-toggle {
  min-height: 44px;
}

.photo-pack-progress {
  width: min(100%, 360px);
  height: 5px;
  margin-top: 8px;
}

.table-loading-progress {
  margin-bottom: 8px;
}

.data-loading-progress {
  width: min(100%, 360px);
  margin-top: 12px;
}

.photo-variety-toggle {
  font-size: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.toggle-row input {
  accent-color: var(--accent);
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.update-actions {
  margin-top: 12px;
}

.import-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.reset-button {
  color: var(--red);
}

.data-feedback {
  margin: 10px 0 0;
  color: var(--accent-strong);
  font-size: 12px;
}

.data-feedback.is-error {
  color: var(--red);
}

.crystal-system-visual {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-block: 1px solid var(--rule-soft);
  background: var(--surface);
}

.crystal-diagram-label {
  max-width: 14ch;
  color: var(--muted);
  font-size: 11px;
}

.crystal-diagrams {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crystal-diagram {
  min-width: 0;
  flex: 1 1 180px;
  max-width: 230px;
  margin: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 3px 8px;
}

.crystal-system-image {
  width: 58px;
  height: 68px;
  grid-row: 1 / span 3;
  object-fit: contain;
  border: 1px solid var(--rule-soft);
  background: #fff;
}

.crystal-diagram-caption {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.crystal-system-name {
  color: var(--ink);
  font-size: 11px;
  font-weight: 680;
}

.crystal-example,
.crystal-image-source,
.crystal-system-note {
  color: var(--muted);
  font-size: 11px;
}

.crystal-image-source {
  width: fit-content;
  text-underline-offset: 2px;
}

.app-footer a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-underline-offset: 2px;
}

.empty-state {
  padding: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

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

[hidden] {
  display: none !important;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #241b16;
  --surface: #30251d;
  --surface-strong: #403127;
  --ink: #f5ebde;
  --muted: #cdb9a4;
  --rule: #755e4a;
  --rule-soft: #534233;
  --accent: #d29a6e;
  --accent-strong: #e4b487;
  --accent-soft: #483426;
  --amber: #e5b16b;
  --amber-soft: #4a3524;
  --red: #ef9b8d;
  --red-soft: #4c2b27;
  --green: #9dc18d;
  --green-soft: #2f3e2b;
  --shadow: 0 16px 34px rgb(0 0 0 / 32%);
}

html[data-theme="dark"] .gem-image {
  mix-blend-mode: normal;
  filter: drop-shadow(0 10px 20px rgb(0 0 0 / 28%));
}

html[data-theme="dark"] .gem-fallback {
  filter: drop-shadow(8px 14px 11px rgb(0 0 0 / 38%));
}

html[data-theme="dark"] .primary-button,
html[data-theme="dark"] .next-button {
  background: #79452c;
  color: #fff;
}

html[data-theme="dark"] .primary-button:hover,
html[data-theme="dark"] .next-button:hover {
  background: #633b27;
}

html[data-theme="dark"] .feedback.is-correct,
html[data-theme="dark"] .soft-button.is-success {
  color: #d1f6df;
}

html[data-theme="dark"] .feedback.is-incorrect {
  color: #ffd9dc;
}

html[data-theme="dark"] .feedback.is-note,
html[data-theme="dark"] .soft-button.is-retry {
  color: #ffdfb4;
}

@media (max-width: 1400px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px 12px;
    padding-block: 8px;
  }

  .topbar-nav {
    justify-content: center;
    gap: 2px;
  }

  .topbar-tools {
    flex-wrap: nowrap;
    gap: 5px;
  }

  .topbar-link {
    gap: 6px;
    padding-inline: 8px;
  }
}

@media (max-width: 1016px) {
  .topbar {
    position: relative;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    padding-block: 8px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    min-height: 44px;
    padding-right: 4px;
  }

  .topbar-menu-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    grid-column: 2;
    grid-row: 1;
    display: grid;
    place-items: center;
    border: 1px solid var(--rule);
    border-radius: 2px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease;
  }

  .topbar-menu-button:hover {
    border-color: var(--accent);
    background: var(--surface-strong);
  }

  .topbar.is-menu-open .topbar-menu-button {
    border-color: var(--accent);
    color: var(--accent-strong);
  }

  .topbar.is-menu-open .topbar-menu-icon span:first-child {
    transform: translateY(6px) rotate(45deg);
  }

  .topbar.is-menu-open .topbar-menu-icon span:nth-child(2) {
    opacity: 0;
  }

  .topbar.is-menu-open .topbar-menu-icon span:last-child {
    transform: translateY(-6px) rotate(-45deg);
  }

  .topbar-menu-panel {
    width: 100%;
    min-width: 0;
    grid-column: 1 / -1;
    grid-row: 2;
    display: none;
  }

  .topbar-panel::after {
    display: none;
  }

  .topbar.is-menu-open .topbar-menu-panel {
    display: grid;
    gap: 8px;
  }

  .topbar-nav {
    width: 100%;
    display: grid;
    grid-column: auto;
    justify-self: stretch;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--rule);
    background: var(--surface);
  }

  .topbar-tools {
    width: 100%;
    grid-column: auto;
    justify-self: stretch;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
    align-items: start;
    gap: 6px;
  }

  .topbar-panel {
    width: 100%;
  }

  .topbar-panel.is-open {
    grid-column: 1 / -1;
  }

  .topbar-popover {
    position: static;
    width: 100%;
    display: grid;
    grid-template-rows: 0fr;
    overflow: hidden;
    border-color: transparent;
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
    transform: none;
    visibility: hidden;
    transition: grid-template-rows 220ms cubic-bezier(0.2, 0.8, 1), opacity 150ms ease,
      border-color 180ms ease, visibility 180ms;
  }

  .topbar-popover-content {
    min-height: 0;
    overflow: hidden;
    padding: 10px;
  }

  .topbar-panel.is-open .topbar-popover {
    grid-template-rows: 1fr;
    border-color: var(--rule);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }

  .topbar-link {
    width: 100%;
    min-height: 48px;
    justify-content: flex-start;
    padding: 8px 10px;
    border-bottom: 1px solid var(--rule-soft);
    font-size: 14px;
    line-height: 1.35;
    text-align: start;
  }

  .topbar-link:last-child {
    border-bottom: 0;
  }

  .topbar-link[aria-current="location"] {
    background: var(--surface-strong);
  }

  .offline-status,
  .tool-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 1050px) {
  .app-shell {
    width: min(100% - 40px, 1440px);
  }

  .workbench {
    grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  }

  .specimen-side {
    padding-inline: 19px;
  }

  .exercise-side {
    padding-inline: 20px;
  }

  .mode-button {
    padding-inline: 7px;
  }

  .progress-section {
    grid-template-columns: minmax(170px, 0.8fr) minmax(180px, 1fr);
  }

  .difficult-list-wrap {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 28px, 620px);
  }

  body {
    font-size: 16px;
  }

  .home-config {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 20px;
    padding: 4px 0 0;
  }

  .home-map-panel {
    min-height: clamp(300px, 50vw, 380px);
  }

  .home-config-controls {
    gap: 16px;
  }

  .round-config-heading {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-bottom: 10px;
  }

  .round-config-heading .learning-tabs-shell {
    width: 100%;
  }

  .round-config-heading .learning-area-selector {
    margin-left: 0;
  }

  .goal-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .goal-controls label:not([hidden]) {
    margin-top: 5px;
  }

  .home-map-panel .home-specimen {
    width: min(88%, 390px);
  }

  .home-specimen img {
    height: clamp(180px, 50vw, 240px);
    padding: 12px;
  }

  .round-start {
    display: flex;
    gap: 10px;
  }

  #start-round-button {
    width: 100%;
    margin-top: 8px;
    min-height: 56px;
  }

  .topbar-link-full {
    display: inline;
  }

  .topbar-link-short {
    display: none;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-name {
    font-size: 18px;
  }

  .app-version {
    margin-inline: 2px;
  }

  .learning-tab {
    min-height: 44px;
    justify-content: flex-start;
    gap: 9px;
    padding-inline: 10px;
    font-size: 15px;
  }

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

  .tab-glyph {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .study-heading {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding-block: 14px 12px;
  }

  h1 {
    max-width: 20ch;
    font-size: clamp(27px, 7vw, 36px);
  }

  .study-stats {
    gap: 12px;
    padding: 0;
  }

  .stat-divider {
    height: 26px;
  }

  .workbench {
    display: flex;
    flex-direction: column;
  }

  .round-active .workbench {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
  }

  .round-active .specimen-side {
    position: sticky;
    top: env(safe-area-inset-top);
    z-index: 5;
    align-items: center;
    padding: 8px 14px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--rule-soft);
  }

  .round-active .specimen-figure {
    width: 100%;
    height: clamp(150px, 26svh, 220px);
    min-height: 150px;
    margin: 2px 0 0;
  }

  .round-active .gem-image {
    max-height: calc(26svh - 16px);
  }

  .round-active .exercise-side {
    width: 100%;
    min-height: 0;
    padding: 10px 14px max(16px, env(safe-area-inset-bottom));
  }

  .round-active .question-block {
    padding-top: 11px;
  }

  .round-active .answer-area {
    flex: 0 0 auto;
    padding-top: 8px;
  }

  .round-active .next-row {
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .round-active .next-row .next-button {
    width: 100%;
    min-height: 48px;
  }

  .round-active .feedback-slot {
    min-height: 0;
  }

  .round-result-active .workbench {
    display: flex;
    min-height: 0;
    padding: 0;
  }

  .round-result-active .exercise-side {
    min-height: calc(100dvh - 40px);
    padding: 20px 14px calc(78px + env(safe-area-inset-bottom));
  }

  .round-result-active .round-result {
    min-height: calc(100dvh - 80px);
    justify-content: flex-start;
  }

  .round-result-active .round-result .next-button {
    position: sticky;
    bottom: env(safe-area-inset-bottom);
    margin-top: auto;
  }

  .specimen-side {
    padding: 16px 15px 13px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .specimen-figure {
    min-height: 270px;
    margin-top: 11px;
  }

  .gem-fallback {
    width: min(68%, 270px);
  }

  .gem-image {
    width: min(84%, 330px);
    max-height: 80%;
  }

  .exercise-side {
    padding: 17px 15px 16px;
  }

  .question-block {
    min-height: 76px;
    padding-top: 18px;
  }

  .question-block h2 {
    font-size: 24px;
  }

  .mode-picker {
    gap: 2px;
    padding: 4px;
  }

  .mode-button {
    flex: 1 1 28%;
    min-height: 38px;
    gap: 5px;
    padding: 6px 4px;
    font-size: 11px;
  }

  .mode-button svg {
    width: 15px;
    height: 15px;
    flex-basis: 15px;
  }

  .round-start .next-button {
    width: 100%;
    min-height: 52px;
  }

  .answer-area {
    min-height: 128px;
  }

  .progress-section {
    grid-template-columns: 1fr;
    gap: 14px;
    padding-block: 17px;
  }

  .collector-heading {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .expedition-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .expedition p {
    min-height: 0;
  }

  .crystal-system-visual {
    align-items: start;
  }

  .difficult-list-wrap {
    grid-column: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .collection-heading {
    min-height: 56px;
  }

  .image-pack-settings {
    grid-template-columns: minmax(0, 1fr);
  }

  .collection-row {
    grid-template-columns: 38px minmax(78px, 1fr) minmax(0, 1.4fr) 36px 26px;
    gap: 7px;
    padding-inline: 5px;
  }

  .collection-ownership {
    display: none;
  }

  .collection-thumb {
    width: 34px;
    height: 34px;
  }

  .collection-info {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .collection-info .collection-family {
    display: none;
  }

  .app-footer {
    flex-direction: column;
    gap: 5px;
    padding-bottom: 21px;
  }
}

@media (max-width: 760px) {
  .sensitivity-heading {
    flex-direction: column;
  }

  .source-page {
    align-self: flex-start;
  }
}

@media (max-width: 430px) {
  .app-shell {
    width: min(100% - 22px, 620px);
  }

  .topbar-tools {
    gap: 6px;
  }

  .brand {
    gap: 8px;
  }

  .brand-name {
    font-size: 16px;
  }

  .offline-status,
  .tool-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .study-heading {
    min-height: 0;
    padding-block: 12px 8px;
  }

  .study-stats {
    gap: 10px;
  }

  .stat-item {
    gap: 6px;
  }

  .stat-symbol {
    font-size: 20px;
  }

  .study-heading p {
    font-size: 14px;
  }

  .home-map-panel {
    min-height: clamp(280px, 70vw, 320px);
  }

  .home-map-panel .home-specimen {
    width: min(90%, 350px);
  }

  .home-specimen img {
    height: clamp(170px, 52vw, 220px);
    padding: 10px;
  }

  .home-specimen figcaption {
    padding: 8px 11px 10px;
  }

  .home-specimen figcaption strong {
    font-size: 16px;
  }

  .home-config-controls {
    gap: 12px;
  }

  .rank-ladder {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .specimen-figure {
    min-height: 245px;
  }

  .specimen-side {
    padding-inline: 11px;
  }

  .exercise-side {
    padding-inline: 11px;
  }

  .bookmark-button {
    font-size: 10px;
  }

  .choice-list {
    grid-template-columns: 1fr;
  }

  .matching-board {
    gap: 8px;
  }

  .match-option {
    padding: 7px 6px;
    font-size: 10px;
  }

  .match-thumb {
    width: 27px;
    height: 27px;
    flex-basis: 27px;
  }

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

  .flashcard {
    min-height: 124px;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    padding: 9px;
  }

  .flashcard-specimen {
    height: 104px;
  }

  .flashcard-flip {
    min-height: 0;
    display: block;
    grid-template-columns: none;
    gap: 0;
    height: clamp(260px, 48svh, 420px);
    padding: 0;
  }

  .flashcard-face {
    padding: 14px;
  }

  .primary-button {
    width: 100%;
  }

  .collection-row {
    grid-template-columns: 44px minmax(68px, 0.9fr) minmax(0, 1.3fr) 44px 44px;
    font-size: 12px;
  }

  .collection-expanded {
    grid-template-columns: 1fr;
  }

  .collection-detail-grid {
    grid-template-columns: 1fr;
  }

  .collection-gallery {
    grid-template-columns: repeat(2, minmax(72px, 1fr));
  }

  .collection-details {
    font-size: 12px;
  }

  .collection-favorite {
    min-width: 32px;
  }

  .backup-actions > * {
    flex: 1 1 100%;
    justify-content: center;
  }

  .image-pack-actions,
  .image-pack-actions .soft-button {
    width: 100%;
  }

}

@media (max-width: 1050px) {
  button:not([hidden]) {
    min-width: 44px;
    min-height: 44px;
  }

  input:not([type="checkbox"]),
  select {
    min-height: 44px;
  }

  .brand,
  .topbar-link {
    min-height: 44px;
  }

  .collection-row a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .toggle-row,
  .import-button,
  .source-link {
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  .collection-row {
    grid-template-columns: 44px minmax(72px, 0.9fr) minmax(0, 1.3fr) 44px 44px;
  }

  .collection-favorite {
    min-width: 44px;
    min-height: 44px;
  }

  .sensitivity-table {
    font-size: 14px;
  }

  .sensitivity-table th {
    font-size: 12px;
  }

  .source-page {
    width: fit-content;
    max-width: 100%;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .round-active .specimen-figure {
    height: clamp(130px, 32svh, 190px);
    min-height: 130px;
  }

  .round-active .gem-image {
    max-height: calc(32svh - 16px);
  }

  .round-active .specimen-side {
    padding-block: 6px;
  }
}

@media (max-width: 760px) and (max-height: 760px) {
  .round-active .question-block {
    min-height: 0;
    padding: 8px 0 4px;
  }

  .round-active .answer-area {
    min-height: 100px;
    padding-top: 6px;
  }

  .round-active .feedback-slot {
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  .round-active .bookmark-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
  }

  .round-active .bookmark-button > span[data-copy="difficult"],
  .round-active #source-link > span[data-copy="source"] {
    display: none;
  }

  .round-active .source-link {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
  }

  html.keyboard-open .round-active.round-typed-answer .answer-form {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(var(--keyboard-inset) + max(8px, env(safe-area-inset-bottom)));
    left: max(14px, env(safe-area-inset-left));
    z-index: 6;
    padding: 8px;
    border: 1px solid var(--rule-soft);
    background: var(--surface);
    box-shadow: 0 -4px 14px rgb(65 43 27 / 12%);
  }

  html.keyboard-open .round-active.round-typed-answer .exercise-side {
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 700px) and (max-width: 1000px) and (orientation: landscape) and (max-height: 600px) {
  .round-active .workbench {
    display: grid;
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
    min-height: calc(100dvh - 16px);
  }

  .round-active .specimen-side {
    min-height: 0;
    padding: 8px 12px;
    border-right: 1px solid var(--rule-soft);
    border-bottom: 0;
  }

  .round-active .exercise-side {
    width: 100%;
    min-height: 0;
    align-self: stretch;
    padding: 8px 12px 12px;
  }

  .round-active .exercise-topline {
    min-height: 36px;
    gap: 8px;
    padding-bottom: 4px;
    flex-wrap: wrap;
  }

  .round-active .timed-quiz-status {
    order: 1;
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .round-active .bookmark-button {
    order: 2;
    margin-left: auto;
  }

  .round-active .question-block {
    min-height: 60px;
    padding: 7px 0 5px;
  }

  .round-active .question-block h2 {
    margin-bottom: 3px;
    font-size: clamp(20px, 2.4vw, 25px);
  }

  .round-active .question-hint {
    font-size: 12px;
    line-height: 1.3;
  }

  .round-active .answer-area {
    min-height: 96px;
    flex: 0 0 auto;
    padding-top: 6px;
  }

  .round-active .feedback-slot {
    min-height: 44px;
  }

  .round-active .next-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) and (orientation: landscape) and (max-height: 500px) {
  .round-active .exercise-side {
    padding-top: 6px;
  }

  .round-active .question-block {
    min-height: 0;
    padding: 5px 0 3px;
  }

  .round-active .answer-area {
    min-height: 0;
    padding-top: 4px;
  }

  .round-active .feedback-slot {
    min-height: 36px;
  }
}

.round-active.round-typed-answer .answer-area {
  min-height: 0;
  flex: 0 0 auto;
}

.round-active.round-typed-answer .feedback-slot {
  min-height: 0;
  margin-top: 8px;
}

@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;
  }

  .flashcard-flip,
  .flashcard-flip.is-revealed {
    transform: none;
    animation: none;
  }

  .flashcard-back {
    transform: none;
  }

  .flashcard-front[aria-hidden="true"],
  .flashcard-back[aria-hidden="true"] {
    display: none;
  }
}
