/* 月儿背单词 — app-specific stylesheet.
   Loaded after site/fonts.css and site/atlas.css (the Word Atlas design system,
   ported verbatim from word-atlas @9eff300 — MIT, see site/vendor/word-atlas).
   Only rules the original has no equivalent for live here: the unit grid,
   daily-goal chips, 错词本 panel, spell tiles, the supplement 释义 block,
   fix-notes, mute/theme buttons, focus rings, iPad hit-area minimums and the
   reduced-motion overrides. All colours and metrics come from the ported
   tokens (--paper, --card, --ink, --line, --terra, --ochre, --sage, --serif,
   --r, ...). */

/* ---------- iPad finger rule ---------- */
/* The e2e suite requires every tap target to be >= 64x64 css px (an iPad
   finger, not a mouse). These rules grow the real hit box; the painted
   affordances (pill backgrounds, icon circles) are re-drawn at their original
   size centred inside it so the look stays close to the original. */
button {
  min-height: 64px;
}
a {
  min-height: 64px;
}
.icon-btn {
  position: relative;
  isolation: isolate;
  width: auto;
  height: auto;
  min-width: 64px;
  min-height: 64px;
}
.icon-btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 999px;
  background: transparent;
  transition: background-color 0.2s;
  z-index: -1;
}
.icon-btn:hover:not(:disabled) {
  background: none;
  color: var(--ink);
}
.icon-btn:hover:not(:disabled)::before {
  background: var(--paper-2);
}
.icon-btn:active:not(:disabled)::before {
  background: var(--paper-3);
}
.icon-btn:active:not(:disabled) {
  transform: none;
}
.btn {
  min-height: 64px;
}
.btn-xl {
  min-height: 64px;
}
.chip-btn,
.segmented button {
  min-height: 64px;
}
.speak {
  min-height: 64px;
  min-width: 64px;
}
.topbar-logo {
  display: inline-flex;
  align-items: center;
  min-height: 64px;
}
.topnav a {
  position: relative;
  isolation: isolate;
  height: auto;
  min-height: 64px;
}
.topnav a.is-on {
  background: none;
}
.topnav a.is-on::before {
  content: "";
  position: absolute;
  inset: 13px 0;
  border-radius: 999px;
  background: var(--paper-2);
  z-index: -1;
}
.sheet-nav .icon-btn,
.sheet-close {
  min-width: 64px;
  min-height: 64px;
}
.icon-btn.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
}
.link {
  min-height: 64px;
  padding: 0 2px;
}

/* ---------- app shell ---------- */
#app {
  position: relative;
  z-index: 1;
}
.page.is-focus {
  padding: 0;
  max-width: none;
}
.screen {
  width: 100%;
}

/* Mute / theme buttons (chrome + learn top bar). */
.mute-toggle,
.theme-toggle {
  display: inline-grid;
  place-items: center;
  color: var(--ink-2);
  border-radius: 999px;
  transition: background-color 0.2s, color 0.2s;
}
.mute-toggle:hover,
.theme-toggle:hover {
  background: var(--paper-2);
  color: var(--ink);
}
.mute-toggle-icon,
.theme-toggle-icon {
  display: grid;
  place-items: center;
  line-height: 1;
}
.mute-toggle-icon svg,
.theme-toggle-icon svg {
  width: 21px;
  height: 21px;
}

/* Footer attribution, ported .footer look with our copy. */
.footer-note {
  max-width: 82ch;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-3);
}
.footer-note a {
  color: var(--terra-ink);
  border-bottom: 1px solid transparent;
}
.footer-note a:hover {
  border-color: currentColor;
}
.footer .logo .mark {
  width: 22px;
  height: 22px;
}

/* ---------- home: daily goal, 错词本, 21 天单元 ---------- */
.goal-panel .segmented {
  margin-top: 18px;
}
.goal-main {
  display: grid;
  gap: 10px;
}
.goal-status {
  font-size: 15px;
  color: var(--ink-2);
}
.goal-status b {
  font: 600 22px/1 var(--serif);
  font-variation-settings: "opsz" 48;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--paper-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ochre), var(--terra));
  transition: width 0.5s var(--ease);
}
.mistakes-panel {
  cursor: pointer;
  transition: transform 0.35s var(--spring), box-shadow 0.3s;
}
.mistakes-panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.mistakes-panel.is-empty {
  cursor: default;
}
.mistakes-panel.is-empty:hover {
  transform: none;
  box-shadow: var(--shadow);
}
.mistakes-tile-count {
  font: 600 30px/1 var(--serif);
  font-variation-settings: "opsz" 72;
  font-variant-numeric: tabular-nums;
  color: var(--terra-ink);
}
.mistakes-panel .chip {
  margin-top: 18px;
}
.unit-panel {
  grid-column: 1 / -1;
}
.unit-tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
}
.unit-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 148px;
  padding: 16px 16px 14px;
  border-radius: 20px;
  background:
    radial-gradient(120% 80% at 50% 0%, var(--ochre-soft), transparent 70%),
    var(--card-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  isolation: isolate;
  transition: transform 0.4s var(--spring), box-shadow 0.3s;
}
.unit-tile:hover {
  transform: translateY(-4px) rotate(-0.6deg);
  box-shadow: var(--shadow-lg);
}
.unit-tile-day {
  font: 600 26px/1 var(--serif);
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.01em;
}
.unit-tile-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.unit-tile-meta {
  margin-top: auto;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.unit-tile-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--paper-3);
  overflow: hidden;
}
.unit-tile-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sage);
}

/* ---------- entry extras (supplement definition, fixes) ---------- */
.page .entry-head {
  padding-right: 64px;
}
.entry-zh {
  margin-top: 20px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
}
.entry-zh .pos {
  margin-right: 8px;
}
.fix-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.block.fix-notes {
  margin-top: 20px;
  padding-top: 16px;
}
.fix-note {
  display: inline-block;
  margin: 0;
  padding: 3px 10px;
  font-size: 12.5px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--ink);
  background: var(--ochre-soft);
  border: 1px solid color-mix(in oklab, var(--ochre) 55%, transparent);
  border-radius: 999px;
}
.book-ipa-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-3);
}
.book-ipa-line .ipa {
  font-size: 14px;
  color: var(--ink-2);
}
.block.def-block p {
  margin-top: 8px;
}
.def-zh {
  font-size: 17px;
  font-weight: 600;
}
.def-en {
  font: italic 400 15px/1.5 var(--serif);
  color: var(--ink-2);
}
.sub-phrases {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}
.sub-item {
  font-size: 14px;
  color: var(--ink-2);
}
.sub-phrase {
  font: 500 16px var(--serif);
  color: var(--ink);
}
.relations .link,
.relations span {
  font: inherit;
}
.relations .eyebrow {
  margin-bottom: 8px;
}
/* Ported from the Word Atlas entry/About area (not part of the copied sections):
   the ex-tag chips, specimen rule and usage note that the word card uses. */
.ex-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.ex-tag.is-ielts {
  color: var(--terra-ink);
}
.specimen {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font: 600 11px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.specimen i {
  flex: 0 0 28px;
  height: 1px;
  background: var(--line-strong);
}
.usage-note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-3);
  padding-left: 12px;
  border-left: 2px solid var(--terra-soft);
}

/* ---------- word card as a sheet ---------- */
.page.card-page {
  padding: 16px var(--gutter) 20px;
}
.card-sheet-stage {
  display: grid;
  place-items: center;
}
.sheet.card-sheet {
  margin: 0 auto;
  max-height: calc(100dvh - var(--top) - 36px);
}
@media (min-width: 760px) {
  .sheet.card-sheet {
    max-width: 1040px;
  }
}
.sheet.card-sheet .entry-art .illo {
  max-width: none;
}
.card-pager {
  padding-top: 6px;
  border-top: 1px solid var(--line);
  margin-top: 28px;
  gap: 8px;
}
.card-pager [data-testid="card-counter"] {
  min-width: 80px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- unit page ---------- */
.unit-page .display small {
  margin-left: 14px;
}
.unit-page .page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}
.unit-words {
  margin-top: 20px;
  display: grid;
  gap: 8px;
  padding: 0;
  list-style: none;
}
.word-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 8px 12px 8px 8px;
  border-radius: var(--r);
  background: var(--card-2);
  border: 1px solid var(--line);
  transition: border-color 0.2s, background-color 0.2s;
}
.word-row:hover {
  border-color: var(--ink-4);
  background: var(--card);
}
.word-row .illo {
  flex: none;
  width: 56px;
  border-radius: 12px;
}
.word-row-word {
  font: 600 20px/1.15 var(--serif);
  font-variation-settings: "opsz" 24;
  min-width: 0;
  overflow-wrap: anywhere;
}
.word-row-zh {
  margin-left: auto;
  text-align: right;
  font-size: 14px;
  color: var(--ink-3);
  max-width: 46%;
}
.unit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- learning flow (kept from the pre-port app; part 2 reworks it) ---------- */
.top-bar {
  flex: 0 0 auto;
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 8px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 124px;
  min-height: 72px;
  padding: 0 20px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  font-size: 22px;
  font-weight: 700;
}

.top-bar-spacer {
  display: inline-block;
  min-width: 124px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar-center {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.top-bar-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.top-bar-counter {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.screen-card {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(94px + env(safe-area-inset-bottom, 0px));
}

.card-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 6px var(--gutter) 12px;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.card {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.card-media {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.pic {
  display: block;
  width: min(78vw, 640px);
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--r-lg);
  background: var(--paper-2);
  box-shadow: var(--shadow-lg);
}

.card-text-col {
  flex: 1 0 auto;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-front {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.word-title-group {
  flex: 1 1 auto;
  min-width: 0;
}

.word-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}

.word {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(56px, 8vh, 84px);
  font-weight: 640;
  font-variation-settings: "SOFT" 0, "WONK" 0;
  letter-spacing: -0.018em;
  line-height: 1.02;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pron-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.btn-pron {
  min-height: 68px;
  padding: 8px 18px;
  background: var(--card-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 21px;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}

.btn-pron:hover {
  border-color: var(--ochre);
  background: var(--ochre-soft);
}

.pron-icon {
  font-size: 22px;
  line-height: 1;
}

.pron-tag {
  font-size: 20px;
  font-weight: 750;
  color: var(--terra-ink);
}

.book-ipa {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-3);
  font-size: 20px;
  font-family: var(--mono);
}

.card-back {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--line-strong);
  animation: card-reveal 180ms var(--ease) both;
}

@keyframes card-reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.meaning-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meaning-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
}

.meaning-pos {
  font-family: var(--serif);
  font-style: italic;
  color: var(--terra-ink);
  background: var(--terra-soft);
  border-color: transparent;
}

.zh {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
}

.sub-phrases {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.sub-item {
  margin: 0;
  font-size: 20px;
}

.sub-phrase {
  font-weight: 700;
}

.card-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

/* Supplement definition */
.def-zh {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.def-en {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.4;
  color: var(--ink-3);
}

/* Senses */
.senses-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sense-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  column-gap: 10px;
  align-items: baseline;
}

.sense-pos {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 20px;
  color: var(--terra);
}

.sense-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sense-zh {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.sense-en {
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.4;
  color: var(--ink-3);
}

/* Examples */
.examples-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.example-block {
  padding: 12px 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.example-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.example-text {
  flex: 1 1 auto;
  min-width: 0;
}

.example-en {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
}

.example-en mark {
  background: linear-gradient(transparent 54%, var(--mark) 54%);
  color: inherit;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 3px;
}

.example-zh {
  margin: 6px 0 0;
  font-size: 20px;
  color: var(--ink-3);
}

.ex-ielts {
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--card-2);
  overflow: hidden;
}

.ex-ielts-summary {
  min-height: 68px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 21px;
  font-weight: 700;
  color: var(--terra-ink);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  list-style: none;
}

.ex-ielts-summary::-webkit-details-marker {
  display: none;
}

.ex-ielts-summary::after {
  content: "展开 ▾";
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-3);
}

.ex-ielts[open] > .ex-ielts-summary {
  border-bottom: 1px solid var(--line);
}

.ex-ielts[open] > .ex-ielts-summary::after {
  content: "收起 ▴";
}

.ex-ielts-body {
  border: 0;
  border-radius: 0;
  background: transparent;
}

/* Collocations */
.col-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.col-chip {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--card-2);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.col-en {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.col-zh {
  font-size: 20px;
  color: var(--ink-3);
}

/* Tip box */
.tip-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: var(--ochre-soft);
  border: 1px solid var(--ochre);
  color: var(--ink);
}

.tip-icon {
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1.3;
}

.tip-text {
  margin: 0;
  font-size: 20px;
  line-height: 1.5;
  color: var(--ink);
}

/* Relations */
.relations-section {
  gap: 12px;
}

.rel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.rel-label {
  margin: 0;
  min-width: 52px;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-3);
}

.rel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rel-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
}

/* Usage note */
.btn-icon {
  flex: 0 0 auto;
  min-width: 72px;
  min-height: 72px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r);
  font-size: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

/* Fixed Bottom Bar */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--paper);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -18px 40px -32px var(--ink);
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  gap: 14px;
}

.btn-bottom {
  min-height: 72px;
  border-radius: var(--r);
  font-size: 24px;
  font-weight: 800;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.btn-bottom.btn-nav {
  flex: 1 1 180px;
  max-width: 260px;
  font-size: 32px;
}

/* Done & Empty Screens */
.screen-center {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.done-panel {
  width: 100%;
  max-width: 720px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: 36px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.done-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 46px;
  font-weight: 620;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.done-subtitle {
  margin: 0;
  font-size: 24px;
  color: var(--ink-3);
}

.done-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
}

.stat-box {
  flex: 1 1 180px;
  max-width: 220px;
  padding: 18px;
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid transparent;
}

.stat-know {
  background: var(--sage-soft);
  color: var(--sage-ink);
  border-color: var(--sage);
}

.stat-dont {
  background: var(--terra-soft);
  color: var(--terra-ink);
  border-color: var(--terra);
}

.stat-num {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 640;
}

.stat-label {
  font-size: 20px;
  font-weight: 700;
}

.done-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
}

/* Big touch buttons for the learning flow only; the ported .btn styles are
   used everywhere else (home, unit page, card sheet). */
.screen .btn-primary,
.screen .btn-secondary {
  min-height: 76px;
  padding: 0 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  border-radius: var(--r);
}

.screen .btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow-sm);
}

.screen .btn-secondary {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

@media (min-aspect-ratio: 1 / 1) {
  .card.has-img {
    flex-direction: row;
    align-items: flex-start;
    gap: 28px;
    padding: 22px 28px;
  }

  .card.has-img .card-media {
    flex: 0 0 44%;
    max-width: 520px;
    width: 44%;
    position: sticky;
    top: 0;
    align-self: flex-start;
  }

  .card.has-img .pic {
    width: 100%;
    max-width: 520px;
    height: auto;
  }

  .card.has-img .card-text-col {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
  }

}

/* ---------- learn flow (ported Learn.tsx DOM, iPad finger sizes) ---------- */

/* Quiz screens never scroll: the prompt takes the free space, the answer
   area sits on the bottom edge and the answered feedback flows underneath. */
.learn-quiz {
  height: 100dvh;
  overflow: hidden;
}
.learn-quiz .learn-stage {
  min-height: 0;
}
.learn-quiz .quiz {
  min-height: 0;
  overflow: hidden;
}
.learn .prompt {
  min-height: 0;
}
.learn .learn-close {
  color: var(--ink-2);
}
.learn .learn-count {
  font-size: 17px;
}

/* Prompt: word */
.learn .prompt-word .headword {
  font-size: clamp(52px, 9vw, 88px);
}
.quiz-speak {
  margin-top: 4px;
}

/* Prompt: picture */
.learn .prompt-picture {
  max-width: 620px;
  gap: 16px;
}
.learn .prompt-picture .illo {
  width: min(100%, 320px);
  max-height: 42dvh;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.learn .prompt-picture .cloze {
  font-size: clamp(20px, 2.4vw, 26px);
}

/* Prompt: listen */
.learn .listen-orb {
  width: 168px;
  height: 168px;
}
.learn .prompt-listen {
  gap: 12px;
}
.learn .prompt-listen .link {
  color: var(--terra-ink);
  font-size: 14px;
  font-weight: 600;
  min-height: 64px;
  padding: 0 16px;
}
.cloze .nowrap {
  white-space: nowrap;
}

/* Prompt: spell */
.learn .prompt-spell {
  max-width: 680px;
}
.learn .prompt-spell .illo.spell-art {
  width: 100%;
}
.learn .prompt-spell .spell-zh {
  font-size: 21px;
  line-height: 1.4;
}
.learn .prompt-spell .cloze-sm {
  color: var(--ink-2);
}

/* Options (meaning / picture / listen) */
.learn .options {
  margin: 0;
}
.learn .option {
  min-height: 76px;
  font-size: 20px;
  gap: 12px;
}
.learn .option kbd {
  flex: none;
}
.learn .options-en .option span {
  font-size: 24px;
}
.options-zh .option span {
  font-weight: 600;
}
.option-mark {
  display: inline-flex;
}

/* Spell: slots stay on one row, tiles are finger sized (>= 96px). */
.learn .spell {
  margin-bottom: 0;
  gap: 14px;
}
.learn .slots {
  flex-wrap: nowrap;
  gap: 8px;
}
.learn .slot {
  flex: 0 1 auto;
  min-width: 0;
  border-radius: 12px;
}
.learn .slot.is-filled,
.learn .slot.is-ok,
.learn .slot.is-bad {
  cursor: pointer;
}
.spell-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.tile {
  width: 96px;
  min-width: 96px;
  height: 96px;
  min-height: 96px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1.5px solid var(--line-strong);
  border-bottom-width: 3px;
  background: var(--card);
  color: var(--ink);
  font: 600 40px/1 var(--serif);
  font-variation-settings: "opsz" 72;
  text-transform: lowercase;
  transition: transform 0.2s var(--spring), border-color 0.15s, background-color 0.2s, opacity 0.2s;
}
.tile:hover:not(.is-used) {
  border-color: var(--ink-3);
  transform: translateY(-1px);
}
.tile:active:not(.is-used) {
  transform: scale(0.94);
}
.tile.is-used {
  opacity: 0.22;
  background: var(--paper-2);
}
.spell-correction {
  text-align: center;
  font-size: 15px;
  color: var(--terra-ink);
}
.spell-correction b {
  font: 600 20px var(--serif);
  letter-spacing: 0.02em;
}

/* Feedback sits in the flow under the answers so it can never cover them. */
.learn .feedback {
  position: static;
  margin: 12px 0 0;
  padding: 0;
}
.learn .feedback-inner {
  margin-bottom: 0;
  border-radius: 22px;
  border-bottom: 1px solid var(--line);
}
.learn .feedback .btn {
  min-width: 190px;
}

/* ---------- summary (ported Summary DOM, static sky) ---------- */

.learn.summary {
  padding: 24px var(--gutter) 48px;
}
/* .summary-sky lives in atlas-pages.css (galaxy mini mode, as in the original). */
.summary-sky p {
  text-align: center;
}
.summary-card .display {
  margin-top: 6px;
}
.summary-word-link {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  align-content: start;
}
.summary-word-link .illo {
  border-radius: 14px;
  margin-bottom: 6px;
}
.summary-word-link span {
  font: 600 15px var(--serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-word-link small {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-words li.is-wrong .summary-word-link .illo {
  box-shadow: 0 0 0 2.5px var(--terra);
}
.summary-words li.is-wrong .summary-word-link span {
  color: var(--terra-ink);
}
.summary-actions .btn {
  min-height: 64px;
}

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

/* ---------- round 1c: 图鉴 (layout overrides on the ported atlas rules) ---------- */
/* The original virtualises tiles with absolute transforms; 905 words render
   fine as a plain CSS grid with the same column maths:
   cols = floor((width + 16) / (188 + 16)). */
.atlas .vgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 16px;
}
.atlas .atile {
  position: relative;
  top: auto;
  left: auto;
  min-height: 64px;
  will-change: auto;
  cursor: pointer;
  color: inherit;
  font: inherit;
}
.atlas .atile .illo {
  aspect-ratio: 1;
  width: 100%;
}
/* Not learned yet: a dark silhouette card with a "?" — collect it by learning it. */
.atile.is-locked {
  background: color-mix(in oklab, var(--card) 70%, var(--paper));
  box-shadow: none;
}
.atile.is-locked .illo {
  background: #0b0e1a;
}
.atile.is-locked .illo img,
.atile.is-locked .illo .plate {
  filter: grayscale(1) brightness(0.42) contrast(2.2);
  opacity: 0.32;
}
.atile.is-locked .illo::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: radial-gradient(120% 90% at 50% 40%, rgba(70, 92, 160, 0.18), rgba(5, 7, 16, 0.55));
  pointer-events: none;
}
.atile.is-locked .atile-word {
  color: var(--ink-3);
}
.atile.is-locked .atile-zh {
  opacity: 0.55;
}
.atile-lock {
  position: absolute;
  z-index: 2;
  left: 7px;
  right: 7px;
  top: 7px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font: 600 64px/1 var(--serif);
  color: rgba(243, 236, 223, 0.22);
  pointer-events: none;
}
.atile-saved {
  position: absolute;
  z-index: 3;
  top: 15px;
  left: 15px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--terra);
  color: #fff;
  box-shadow: 0 0 0 2.5px #fbf8f2;
}
.atile.is-saved .atile-no {
  display: none;
}
.atlas-unit {
  margin-bottom: 40px;
}
.atlas-unit-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 16px;
}
.atlas-unit-head h2 {
  font: 600 26px/1.1 var(--serif);
  font-variation-settings: "opsz" 48;
  letter-spacing: -0.01em;
}
.atlas-unit-count {
  color: var(--ink-3);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.atlas-unit-count b {
  color: var(--ink);
  font-weight: 700;
}
.atlas-unit-bar {
  flex: 1 1 160px;
  max-width: 320px;
  height: 6px;
  border-radius: 99px;
  background: var(--paper-3);
  overflow: hidden;
}
.atlas-unit-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ochre), var(--terra));
}
.atlas-unit.is-complete .atlas-unit-bar i {
  background: var(--sage);
}
.atlas-unit-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage-ink);
  font-size: 13px;
  font-weight: 600;
}
.atlas .vlist {
  display: grid;
  gap: 4px;
}
.atlas .vlist {
  gap: 0;
}
.atlas .row {
  position: relative;
  height: auto;
  min-height: 64px;
  padding-top: 0;
  padding-bottom: 0;
}
.atlas .row.is-locked .row-art {
  filter: grayscale(1) brightness(0.25);
}
.atlas .row.is-locked .row-word {
  color: var(--ink-3);
}
.atlas .row .speak {
  margin: 0 -14px;
}

/* Filter chips + segmented controls: 64px hit boxes, original pills painted inside. */
.filters .chips-scroll {
  margin-top: -14px;
  margin-bottom: -14px;
}
.filters .chip-btn {
  position: relative;
  isolation: isolate;
  height: auto;
  min-height: 64px;
  border: 0;
  background: none;
}
.filters .chip-btn::before {
  content: "";
  position: absolute;
  inset: 15px 0;
  z-index: -1;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  transition: all 0.2s var(--ease);
}
.filters .chip-btn:hover::before {
  border-color: var(--ink-4);
}
.filters .chip-btn.is-on {
  background: none;
  color: var(--paper);
}
.filters .chip-btn.is-on::before {
  background: var(--ink);
  border-color: var(--ink);
}
.filters .chip-btn.lv.is-on::before {
  background: var(--lv);
  border-color: var(--lv);
}
.filters .chip-btn.lv.is-on {
  color: #fff;
}
.filters-row {
  margin-top: -8px;
  margin-bottom: -8px;
}
.filters .segmented {
  position: relative;
  isolation: isolate;
  padding: 0 3px;
  border: 0;
  background: none;
  overflow: visible;
}
.filters .segmented::before {
  content: "";
  position: absolute;
  inset: 13px 0;
  z-index: -2;
  border-radius: 999px;
  background: var(--paper-2);
  border: 1px solid var(--line);
}
.filters .segmented button {
  position: relative;
  height: auto;
  min-height: 64px;
  background: none;
  box-shadow: none;
}
.filters .segmented button.is-on {
  background: none;
  box-shadow: none;
}
.filters .segmented button.is-on::before {
  content: "";
  position: absolute;
  inset: 16px 0;
  z-index: -1;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.filters .segmented-icons button {
  width: 48px;
}

/* Top-bar search pill (ported look, 64px hit box). */
.search-pill {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 0 16px;
  color: var(--ink-3);
  font-size: 14px;
}
.search-pill::before {
  content: "";
  position: absolute;
  inset: 12px 0;
  z-index: -1;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line-strong);
}
.search-pill:hover {
  color: var(--ink);
}
.search-pill {
  min-width: 220px;
  margin-right: 6px;
  height: auto;
  border: 0;
  background: none;
  box-shadow: none;
}
.search-pill:hover {
  box-shadow: none;
}
.search-pill:hover::before {
  border-color: var(--ink-4);
  box-shadow: var(--shadow-sm);
}
.search-pill span {
  flex: 1;
  text-align: left;
}

/* ---------- word card actions (ported .entry-actions; 64px targets, 40px look) ---------- */
.page .entry-head {
  padding-right: 0;
}
.entry-actions {
  margin: -12px 28px -12px 0;
  gap: 0;
}
.entry-actions .icon-btn {
  min-width: 64px;
  min-height: 64px;
  color: var(--ink-2);
}
.entry-actions .icon-btn.is-on {
  color: var(--terra);
}

/* round1c: 练习 / 我的 — iPad tap targets (≥64px) on the ported controls. */
.practice .segmented-wide button,
.me .segmented button {
  height: 64px;
  min-width: 64px;
  font-size: 16px;
}
.practice .segmented-wide {
  border-radius: 999px;
}
.practice .mode-card {
  min-height: 64px;
}
.unit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.unit-chips button {
  min-width: 64px;
  min-height: 64px;
  padding: 0 12px;
  border-radius: 18px;
  border: 1.5px solid var(--line-strong);
  background: var(--card-2);
  color: var(--ink-2);
  font: 600 15px var(--sans);
}
.unit-chips button.is-on {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--card);
}
.me .field.toggle {
  min-height: 64px;
}
.me .data-actions .btn {
  min-height: 64px;
}

/* round1c: summary grid labels wrap instead of truncating ("fasten your safety belt"). */
.summary-words span {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
.summary-words span.is-long {
  font-size: 12.5px;
  letter-spacing: -0.01em;
}
.summary-words span.is-longer {
  font-size: 11px;
  letter-spacing: -0.015em;
}
.summary-words small {
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}
