:root {
  color-scheme: dark;
  /* Page backdrop, kept well below the panel tones so the panel stands out. */
  --bg: #08090b;
  --panel: #1a1d22;
  --panel-rgb: 26, 29, 34;
  --ink: #f2f4f7;
  --muted: #b3b9c2;
  /* Secondary reading text (example translations): a step below --ink. */
  --soft-ink: #d6dae0;
  --line: #313640;
  --accent: #434954;
  --accent-strong: #5a616d;
  --success: #24745c;
  --warm: #a84f3a;
  --gold: #e0b75a;
  --gold-ink: #1f1708;
  --blue: #82aee1;
  --blue-strong: #a5c6ec;
  --blue-ink: #101820;
  --card-border: #3a404b;
  --error-bg: rgba(216, 122, 94, 0.16);
  --error-ink: #ffd5c8;
  --page-glow-start: transparent;
  --page-glow-end: transparent;
  --control-bg: rgba(44, 49, 57, 0.92);
  --control-soft: rgba(36, 40, 47, 0.8);
  --answer-bg: rgba(36, 40, 47, 0.52);
  /* The word band and bottom bar share a lighter tone; the answer area
     between them is darker, as in a dictionary app. */
  --band-bg: #23262c;
  --answer-area: #17191d;
  /* Opaque match for the answer area, behind pinned buttons. */
  --answer-backing: var(--answer-area);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
  --chevron-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E");
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b3b9c2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --speaker-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z' fill='black'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7'/%3E%3Cpath d='M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E");
  /* System fonts: 苹方 for Chinese and UI text, Hiragino Sans for anything
     marked Japanese; other platforms fall back to their own CJK gothic. */
  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

:lang(ja) {
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  width: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  min-height: 0;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  /* A study card, not a document: taps and drags never select text or open
     the iOS long-press menu. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  color: var(--ink);
  background:
    linear-gradient(135deg, var(--page-glow-start), transparent 34%),
    linear-gradient(315deg, var(--page-glow-end), transparent 38%),
    var(--bg);
}

button {
  -webkit-tap-highlight-color: transparent;
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

.app-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 10px 0;
  overflow: hidden;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:where(button, [tabindex]):focus-visible {
  outline: 3px solid var(--blue-strong);
  outline-offset: 3px;
}

html[data-input-mode="pointer"] :where(button, [tabindex]):focus-visible {
  outline: none;
}

.noscript-banner {
  align-self: start;
  padding: 12px 14px;
  border: 1px solid var(--warm);
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-ink);
  font-weight: 800;
  line-height: 1.4;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 5.2vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-bg);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.icon-button:hover {
  border-color: var(--accent);
  background: var(--panel);
  transform: translateY(-1px);
}

/* The module page takes the card's place above the bottom bar. */
.deck-page {
  z-index: 2;
  container-type: size;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border: 1px solid var(--card-border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--answer-area);
  overflow: hidden;
}

.deck-page:not(.is-open) {
  display: none;
}

.deck-page-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px clamp(12px, 3vw, 24px);
  border-bottom: 1px solid var(--line);
  background: var(--band-bg);
}

.deck-page-header h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

/* Short or zoomed screens can still reach every module and block. */
.deck-scroll {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.deck-scroll > * {
  flex: none;
}

/* Levels stack vertically. Every vocabulary and grammar row shares the same
   four button columns, with a compact level badge beside both rows. */
.deck-tabs {
  --module-row-height: clamp(40px, 7.3cqh, 56px);
  --module-column-gap: clamp(8px, 2.2cqw, 12px);
  --module-group-gap: clamp(20px, 3.4cqh, 28px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  align-content: start;
  gap: var(--module-group-gap) var(--module-column-gap);
  width: 100%;
  max-width: 908px;
  margin-inline: auto;
  padding: 12px clamp(12px, 3vw, 24px);
  padding-block: clamp(10px, 1.8cqh, 20px);
}

.deck-row[data-row="base"] {
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.deck-row {
  display: grid;
  min-width: 0;
  gap: 4px;
}

/* Progress backup sits in the header's otherwise empty right side. */
.text-button {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
}

.deck-row-title {
  margin: 0;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
}

/* The tinted frame sits outside the grid, preserving equal button widths. */
.deck-level-group {
  --level-rgb: 130, 174, 225;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  min-width: 0;
  align-items: center;
  gap: 8px 6px;
}

.deck-level-group > .deck-row {
  grid-column: 2;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.deck-level-group::before {
  position: absolute;
  z-index: -1;
  inset: -6px;
  border: 1px solid rgba(var(--level-rgb), 0.25);
  border-radius: 12px;
  background: rgba(var(--level-rgb), 0.035);
  pointer-events: none;
  content: "";
}

.deck-level-group[data-level="n4"] {
  --level-rgb: 224, 183, 90;
}

.deck-level-group[data-level="n3"] {
  --level-rgb: 132, 196, 150;
}

.deck-level-group[data-level="n2"] {
  --level-rgb: 190, 156, 228;
}

.deck-level-title,
.deck-row[data-row="base"] > .deck-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--soft-ink);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
}

.deck-level-title {
  grid-column: 1;
  grid-row: 1 / span 2;
  justify-content: center;
}

.deck-level-group:has(> .deck-row[hidden]) > .deck-level-title {
  grid-row: 1;
}

.deck-level-group .tab-button {
  --cell-border: rgba(var(--level-rgb), 0.25);
  --cell-bg: rgba(var(--level-rgb), 0.065);
}

.deck-level {
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 0.81rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.deck-level[data-level="n5"] {
  background: rgba(130, 174, 225, 0.18);
  color: var(--blue-strong);
}

.deck-level[data-level="n4"] {
  background: rgba(224, 183, 90, 0.18);
  color: #f0d08a;
}

.deck-level[data-level="n3"] {
  background: rgba(132, 196, 150, 0.18);
  color: #9fdcb0;
}

.deck-level[data-level="n2"] {
  background: rgba(190, 156, 228, 0.18);
  color: #d6bff2;
}

/* Vocabulary and grammar share the exact same columns. */
.deck-row-items {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px var(--module-column-gap);
}

.tab-button {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 48px;
  place-items: center;
  padding: 0 2px;
  border: 1px solid var(--cell-border, var(--line));
  border-radius: 8px;
  background: var(--cell-bg, var(--control-bg));
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

@media (hover: hover) {
  .tab-button:hover {
    border-color: var(--blue-strong);
    color: var(--ink);
  }
}

/* Lighter type and brighter labels separate the text from the tinted cells. */
.deck-tabs .tab-button {
  padding-inline: 0;
  min-height: var(--module-row-height);
  color: var(--soft-ink);
  font-size: clamp(0.86rem, 4.1cqw, 1.05rem);
  font-weight: 500;
}

/* Basics remain easy to scan without taking the space of a full study row. */
.deck-row[data-row="base"] > .deck-row-items {
  width: min(100%, 440px);
  gap: 6px;
}

.deck-row[data-row="base"] .tab-button {
  min-height: clamp(34px, 6cqh, 42px);
  border-radius: 6px;
  font-size: clamp(0.8rem, 3.7cqw, 0.95rem);
}

.deck-tabs .tab-button:has(> .deck-round-count:not([hidden])) {
  padding-top: 8px;
}

@media (max-width: 359px) {
  .deck-tabs {
    --module-row-height: 40px;
  }

  .tab-button {
    font-size: 0.86rem;
  }
}

.deck-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-round-count {
  position: absolute;
  top: 2px;
  right: 4px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1;
}

/* A larger corner count once the cells are tall enough to clear the label. */
@container (min-height: 680px) {
  .deck-round-count {
    top: 5px;
    right: 7px;
    font-size: 0.74rem;
  }
}

.deck-round-count[hidden] {
  display: none;
}

/* A vocab or grammar cell opens its 小块 in the module grid's place: 全部 across
   the top, then the blocks, each with what is left of its 当前 round and its
   模糊 / 不认识 counts in the bottom bar's colours and icons. */
.deck-tabs[hidden],
.block-grid[hidden] {
  display: none;
}

.block-grid {
  --level-rgb: 130, 174, 225;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  align-content: start;
  gap: 8px;
  width: 100%;
  max-width: calc(860px + 2 * clamp(12px, 3vw, 24px));
  margin-inline: auto;
  padding: 12px clamp(12px, 3vw, 24px);
}

.block-grid[data-level="n4"] {
  --level-rgb: 224, 183, 90;
}

.block-grid[data-level="n3"] {
  --level-rgb: 132, 196, 150;
}

.block-grid[data-level="n2"] {
  --level-rgb: 190, 156, 228;
}

.block-grid.is-grammar {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.block-tile {
  --fill-known: 0%;
  --fill-fuzzy: 0%;
  --fill-unknown: 0%;
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 64px;
  align-content: center;
  justify-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 2px solid rgba(var(--level-rgb), 0.28);
  border-radius: 8px;
  background:
    linear-gradient(
      90deg,
      rgba(46, 150, 116, 0.62) 0 var(--fill-known),
      rgba(196, 150, 46, 0.62) var(--fill-known) var(--fill-fuzzy),
      rgba(196, 88, 62, 0.66) var(--fill-fuzzy) var(--fill-unknown),
      transparent var(--fill-unknown)
    ),
    var(--control-bg);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.block-tile.is-all {
  grid-column: 1 / -1;
  min-height: 56px;
}

.block-tile[data-state="done"] {
  border-color: #4fc39b;
}

.block-tile[data-state="fuzzy"] {
  border-color: #e3b84f;
}

.block-tile[data-state="unknown"] {
  border-color: #ee7a5c;
}

/* The block being studied gets a ring outside its border, which keeps the
   border's progress colour. */
.block-tile.active {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--blue-strong);
}

@media (hover: hover) {
  .block-tile:hover {
    filter: brightness(1.15);
  }
}

.block-tile:focus-visible {
  outline: 3px solid var(--blue-strong);
  outline-offset: 3px;
}

.block-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-status {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.2;
}

.block-tile .deck-round-count {
  color: var(--ink);
}

.tab-button.active {
  border-color: var(--blue-strong);
  background: var(--accent);
  color: #fff;
}

.tab-button.active .deck-round-count {
  color: rgba(255, 255, 255, 0.78);
}

.tab-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

/* The undo "<" hangs in the band's top-left corner over the card instead of
   taking a row of its own, so the prompt starts at the top of the band. */
.stats-grid {
  position: relative;
  z-index: 1;
  display: flex;
  height: 0;
  align-items: flex-start;
}

/* A bare "<" like a native back button: undo in the word band, return on the
   module page. */
.chevron-button {
  display: inline-flex;
  min-width: 44px;
  height: 44px;
  align-items: center;
  gap: 2px;
  margin-left: -10px;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
}

.chevron-button::before {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  background: currentColor;
  content: "";
  -webkit-mask: var(--chevron-icon) center / contain no-repeat;
  mask: var(--chevron-icon) center / contain no-repeat;
}

.chevron-button:disabled {
  cursor: default;
  opacity: 0.3;
}

@media (hover: hover) {
  .chevron-button:not(:disabled):hover {
    color: var(--ink);
  }
}

/* The label only shows on the finished-round screen, where a bare "<" would
   not read as undo. */
.undo-text {
  display: none;
}

.empty-state .undo-button {
  margin-left: 0;
  color: var(--blue-strong);
}

.empty-state .undo-text {
  display: inline;
}

/* The card (or finished-round screen) and the bottom bar form one panel. The
   card, the finished-round screen and the module page share the first row. */
.study-card,
.empty-state,
.deck-page {
  grid-row: 1;
  grid-column: 1;
}

.bottom-bar {
  grid-row: 2;
}

.study-area {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* 当前 / 模糊 / 不认识 select the deck's pools; 模块 opens the module page. */
.bottom-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--card-border);
  border-top-color: var(--line);
  border-radius: 0 0 8px 8px;
  background: var(--band-bg);
}

.bottom-tab {
  position: relative;
  display: grid;
  min-height: 54px;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 800;
}

.bottom-tab.is-active,
.bottom-tab[aria-expanded="true"] {
  color: var(--blue-strong);
}

/* While the module page is open only 模块 reads as selected. */
.study-area.is-picking .bottom-tab.is-active {
  color: var(--muted);
}

@media (hover: hover) {
  .bottom-tab:not(.is-active):not([aria-expanded="true"]):hover {
    color: var(--ink);
  }
}

.bottom-tab-icon {
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: var(--tab-icon) center / contain no-repeat;
  mask: var(--tab-icon) center / contain no-repeat;
}

.icon-current {
  --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='5' y='3' width='14' height='18' rx='2'/%3E%3Cpath d='M9 8h6M9 12h6M9 16h3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.icon-fuzzy {
  --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M7.5 12.5c1.5-1.6 3-1.6 4.5 0s3 1.6 4.5 0'/%3E%3C/svg%3E");
}

.icon-unknown {
  --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .8-1 1.5v.4'/%3E%3Ccircle cx='12' cy='17' r='.6' fill='black'/%3E%3C/svg%3E");
}

.icon-modules {
  --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Crect x='4' y='4' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='13.5' y='4' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='4' y='13.5' width='6.5' height='6.5' rx='1.5'/%3E%3Crect x='13.5' y='13.5' width='6.5' height='6.5' rx='1.5'/%3E%3C/svg%3E");
}

/* The badge hangs off the icon's top-right corner in both tab layouts. */
.bottom-tab-figure {
  position: relative;
  display: grid;
}

.bottom-tab-badge {
  position: absolute;
  top: -6px;
  left: 16px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warm);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
}

.study-header {
  display: grid;
  align-self: start;
  gap: clamp(8px, 2vw, 16px);
}

/* Word band on top, answer area below it taking the remaining space (and
   scrolling there). */
.study-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  max-height: 100%;
  padding: 0;
  border: 1px solid var(--card-border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--answer-area);
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.study-card.is-answering {
  cursor: default;
}

.word-band {
  display: grid;
  gap: 4px;
  padding: 10px clamp(12px, 3vw, 24px);
  border-bottom: 1px solid var(--line);
  background: var(--band-bg);
}

/* Shares the answer row so it sits centered in the empty answer area. */
.reveal-hint {
  grid-row: 2;
  grid-column: 1;
  align-self: center;
  justify-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
  pointer-events: none;
}

.study-card.is-choosing {
  cursor: default;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 0 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: inherit;
  text-align: center;
}

.card-reveal {
  position: relative;
  z-index: 0;
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  justify-items: center;
  gap: 10px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: center;
}

.card-reveal:disabled {
  cursor: default;
}

.card-type:empty {
  display: none;
}

.card-type {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.3;
}

.card-prompt {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(2.6rem, 12vw, 4.5rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0;
}

.card-phonetic {
  display: flex;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
}

.card.speaker-corner .card-phonetic {
  position: absolute;
  top: 2px;
  right: -4px;
  min-height: 0;
}

.card.reading-centered .prompt-speak {
  position: absolute;
  top: 2px;
  right: -4px;
}

/* Room for the corner speaker (2px + 32px) when the band holds one short
   line, such as a revealed 文型 card. */
.card.speaker-corner {
  min-height: 34px;
}

/* Speaker glyph drawn with a mask so the buttons carry no text content. */
.speaker-button {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--blue);
}

.speaker-button::before {
  width: 20px;
  height: 20px;
  background: currentColor;
  content: "";
  -webkit-mask: var(--speaker-icon) center / contain no-repeat;
  mask: var(--speaker-icon) center / contain no-repeat;
}

.icon-button.speaker-button:hover {
  border-color: rgba(130, 174, 225, 0.3);
  background: rgba(49, 93, 143, 0.16);
  transform: none;
}

.speech-status {
  position: absolute;
  right: clamp(12px, 4vw, 28px);
  bottom: 8px;
  z-index: 2;
  max-width: min(75%, 360px);
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(18, 20, 23, 0.94);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
}

.speech-status[data-state="error"] {
  border-color: var(--warm);
  color: var(--error-ink);
}

.speech-status[data-state="retry"] {
  border-color: var(--gold);
  color: var(--gold);
}

/* The kana sit right under a vocab word, as in a dictionary: with the
   speaker moved to the corner the row needs no speaker-high minimum. */
.card.is-vocab {
  gap: 2px;
}

.card.reading-centered .card-phonetic {
  min-height: 0;
}

.card.is-vocab .card-prompt {
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 1.04;
}

.card.is-zh-prompt .card-prompt {
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  line-height: 1.08;
}

.card.is-grammar .card-prompt {
  font-size: clamp(1.3rem, 5vw, 2.2rem);
  line-height: 1.12;
}

.card.is-choice .card-prompt {
  font-size: clamp(1.2rem, 4.8vw, 2.2rem);
  line-height: 1.16;
}

/* Grammar sentence cards teach the pattern: it takes the large prompt size and
   the example sentence shrinks to a secondary line under it. */
.card-pattern {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(1.5rem, 7vw, 2.2rem);
  font-weight: 900;
  line-height: 1.1;
}

.card.is-pattern-first .card-prompt {
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
}

.card-subtle {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

/* A vocab word's kana, set like a dictionary's phonetics under the word. */
.card-subtle.is-reading {
  font-size: 1.05rem;
}

.reading-note {
  font-size: 0.86em;
}

.answer-panel,
.empty-state {
  padding: clamp(8px, 2.2vw, 14px);
  border: 0;
  border-radius: 8px;
  box-shadow: none;
}

.answer-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Square on top, where the answer's band meets the word band. */
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  padding: 10px clamp(12px, 3vw, 24px);
  /* The answer row is content-sized and only shrinks when the card is full, so
     stretching keeps a long answer inside its row (scrolling there) instead of
     growing upward over the prompt; flex-start keeps its top reachable. */
  justify-content: flex-start;
  align-self: stretch;
  block-size: auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

/* The panel only takes programmatic focus after a reveal so screen readers
   land on the answer; it is not a control, so it shows no focus ring. */
.answer-panel:focus-visible {
  outline: none;
}

.answer-panel.is-revealed {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.app-status,
.load-error-banner,
.fatal-error-banner {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
}

.app-status {
  border: 1px solid var(--line);
  background: var(--control-soft);
  color: var(--muted);
}

/* Until app.js has run the page is aria-busy and its controls do nothing yet:
   they are dimmed and ignore taps instead of looking ready. */
.study-area[aria-busy="true"] button {
  opacity: 0.45;
  pointer-events: none;
}

/* A deck whose data is still downloading waits in the empty state; its note
   fades in only if the wait lasts, so a fast load never flashes it. */
.empty-state.is-loading {
  animation: loading-note-appear 0.2s ease-out 0.6s both;
}

@keyframes loading-note-appear {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.load-error-banner,
.fatal-error-banner {
  border: 1px solid rgba(199, 87, 50, 0.36);
  background: var(--error-bg);
  color: var(--error-ink);
}

/* The answer shares the word band's background: the spread shadows paint it
   out to the panel's edges (which clip it) and up over the panel's top
   padding, with a full-width rule under it. */
.answer-main {
  padding: 2px 2px 12px;
  background: var(--band-bg);
  box-shadow:
    0 0 0 100vmax var(--band-bg),
    0 1px 0 100vmax var(--line);
  clip-path: inset(-10px -100vmax -1px);
  font-size: clamp(1.2rem, 5.2vw, 1.6rem);
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.answer-main:empty {
  display: none;
}

/* Vocab meanings and word lists are set like a word-list app's definitions:
   normal-size text in tight lines under the large word, not a second
   headline. */
.answer-main.is-meaning,
.answer-main.is-word-list {
  padding-bottom: 8px;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.45;
}

/* The part of speech takes the first column; the meaning, its numbered
   senses and any note on the whole word share the second. */
.answer-main.is-meaning:not(.is-word-list) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
}

/* 名 / 动 / 形动 before a 日→中 meaning: small grey type on the same line, the
   way word-list apps set "n." before a gloss. */
.part-of-speech {
  margin-right: 0.5em;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.meaning-senses {
  grid-column: 2;
  margin: 0;
  padding-left: 1.4em;
}

.meaning-senses li::marker {
  color: var(--muted);
  font-size: 0.85em;
}

.meaning-note {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* A choice's result is already shown by the option colours and their 你的选择 /
   正确项 labels; the 回答正确／回答错误 line stays for screen readers only. */
.study-card.is-choice .answer-main {
  position: absolute;
  background: none;
  box-shadow: none;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 说明 and 例句 sit side by side once the card is wide enough for two
   380px columns (iPad landscape, desktop); a lone section fills the row.
   A phone narrower than 380px shrinks the column instead of overflowing. */
.answer-details {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  align-items: start;
  gap: 8px 12px;
}

.answer-details:not(:has(> :not([hidden]))) {
  display: none;
}

.answer-section {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-soft);
}

.answer-section-title {
  margin: 0;
  padding: 6px 12px 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

/* 说明 and, on grammar cards, the 出口仁 episode at the right of its line. */
.answer-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.meta-lecture {
  padding: 6px 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: right;
}

.meta-lecture[hidden] {
  display: none;
}

.answer-meta {
  display: grid;
  gap: 4px;
  padding: 4px 12px 8px;
  font-size: 0.92rem;
  line-height: 1.35;
}

.meta-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
}

.meta-key {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.meta-value {
  grid-column: 2;
  min-width: 0;
  overflow-wrap: anywhere;
}

.meta-row > .meta-value:only-child {
  grid-column: 1 / -1;
}

/* Pitch accent: the nucleus position as a superscript on the word or reading. */
.pitch-accent {
  margin-left: 1px;
  color: var(--blue-strong);
  font-size: 0.62em;
  font-weight: 800;
  line-height: 0;
}

/* 同音 takes the answer line: one row per word, ①②③ by frequency, then the
   word and its meaning in aligned columns; words written alike (空 そら /
   から) list their readings the same way, unnumbered. The card's own word is
   set off in gold, the colour examples use for the point taught. */
.answer-main.is-word-list {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: baseline;
  gap: 2px 10px;
}

.answer-main.is-word-list:has(.is-homograph) {
  grid-template-columns: auto minmax(0, 1fr);
}

/* Five or more words (つく) would push a short landscape card past one
   screen, so those lists sit in tighter lines. */
.answer-main.is-word-list:has(> .homophone:nth-child(5)) {
  line-height: 1.2;
}

.homophone {
  display: contents;
}

.homophone-index {
  color: var(--muted);
  font-weight: 700;
}

.homophone-word {
  font-weight: 800;
  white-space: nowrap;
}

.homophone-gloss {
  min-width: 0;
}

.homophone.is-current .homophone-word,
.homophone.is-current .homophone-index {
  color: var(--gold);
}

.choice-block {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.choice-list {
  display: grid;
  gap: 8px;
}

.choice-option {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 52px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-soft);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

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

.choice-marker {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 8px;
  background: var(--control-bg);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.choice-text {
  min-width: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: clamp(0.9rem, 2.8vw, 1.02rem);
  font-weight: 850;
  line-height: 1.34;
}

.choice-option:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--panel);
}

.choice-option.is-selected {
  border-color: var(--gold);
}

.choice-option.is-correct {
  border-color: var(--success);
  background: rgba(32, 106, 93, 0.12);
}

.choice-option.is-correct .choice-marker {
  background: var(--success);
  color: #fff;
}

.choice-option.is-wrong {
  border-color: var(--warm);
  background: rgba(199, 87, 50, 0.12);
}

.choice-option.is-wrong .choice-marker {
  background: var(--warm);
  color: #fff;
}

.choice-feedback {
  display: grid;
  gap: 6px;
  max-height: none;
  overflow: hidden;
  padding-right: 2px;
}

/* Once answered, only the picked and the correct option stay, each with its
   explanation, followed by the pattern's 说明 and the completed sentence, so
   the answer fits on one screen. */
.choice-list.is-answered .choice-option:not(.is-selected):not(.is-correct),
.study-card.is-choice.is-answering .choice-reason:not(.is-selected):not(.is-correct) {
  display: none;
}

.choice-reason {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border-left: 3px solid var(--line);
  background: var(--control-soft);
  font-size: 0.84rem;
  line-height: 1.34;
}

.choice-reason strong {
  font-size: 0.8rem;
}

.choice-reason.is-correct {
  border-left-color: var(--success);
}

.choice-reason.is-selected:not(.is-correct) {
  border-left-color: var(--warm);
}

.examples-list {
  display: grid;
}

.example-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 6px 12px;
}

/* Examples are set apart by space, not rules: the sentence, then its
   translation, as in a dictionary's example list. */
.example-item + .example-item {
  margin-top: 4px;
}

.example-text {
  min-width: 0;
}

.example-ja {
  margin: 0 0 1px;
  color: var(--ink);
  font-size: clamp(1rem, 3.2vw, 1.14rem);
  font-weight: 400;
  line-height: 1.36;
}

/* WebKit spreads a short base across a long reading (台 所 under だいどころ);
   centering keeps the word's kanji together, as Chromium already does. The
   reading does not overhang its neighbours: browsers lay that out differently
   and adjacent readings would collide. */
.example-ja ruby {
  ruby-position: over;
  ruby-align: center;
}

.example-ja rt {
  color: var(--muted);
  font-size: 0.5em;
  font-weight: 700;
  line-height: 1;
}

.example-romaji {
  margin: 0 0 1px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.example-zh {
  margin: 0;
  color: var(--soft-ink);
  font-size: 0.92rem;
  line-height: 1.36;
}

.feedback-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
}

/* When a long answer scrolls, the rating and next buttons stay in view, with
   an opaque backing over the content scrolling underneath them. */
.feedback-row,
.choice-next {
  position: sticky;
  bottom: 0;
  z-index: 1;
}

.feedback-row,
.choice-next {
  /* Extend the backing over the 8px gap above and the panel padding below. */
  box-shadow:
    0 -8px 0 var(--answer-backing),
    0 16px 0 var(--answer-backing);
}

.feedback-row {
  background: var(--answer-backing);
}

.feedback,
.primary-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 900;
}

.feedback {
  display: grid;
  min-height: 50px;
  place-content: center;
  gap: 2px;
  border: 1.5px solid;
  border-radius: 10px;
  font-size: 1rem;
}

.feedback.clear {
  border-color: #3f9f80;
  background: rgba(36, 116, 92, 0.16);
  color: #8fdcbf;
}

.feedback.unsure {
  border-color: #c19a3c;
  background: rgba(176, 134, 40, 0.16);
  color: #f0cf7e;
}

.feedback.forgot {
  border-color: #c96a52;
  background: rgba(168, 79, 58, 0.16);
  color: #f3a993;
}

.primary-button {
  background: var(--accent);
}

.choice-next {
  width: 100%;
  margin-top: auto;
}

.feedback:hover,
.primary-button:hover {
  filter: brightness(0.95);
}

.empty-state {
  display: grid;
  height: 100%;
  min-height: 0;
  place-items: center;
  align-content: center;
  gap: 18px;
  border: 1px solid var(--card-border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--answer-area);
  text-align: center;
}

.empty-state h2 {
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  font-weight: 900;
}

.empty-state p {
  color: var(--muted);
  font-weight: 800;
}

.primary-button {
  padding: 0 18px;
}

.restart-button {
  min-width: min(360px, calc(100vw - 72px));
  min-height: 84px;
  font-size: clamp(1.25rem, 5vw, 2rem);
}

.restart-button[hidden] + * {
  margin-top: 0;
}

@media (min-width: 840px) {
  .answer-panel {
    min-height: 0;
  }

  /* iPad landscape and desktop have room for larger answer text. */
  .answer-section-title {
    font-size: 0.82rem;
  }

  .meta-lecture {
    font-size: 0.86rem;
  }

  .answer-meta {
    font-size: 1.05rem;
  }

  .meta-key {
    font-size: 0.9rem;
  }

  .example-ja {
    font-size: 1.24rem;
  }

  .example-romaji {
    font-size: 0.88rem;
  }

  .example-zh {
    font-size: 1.06rem;
  }
}

/* Short, wide windows (iPad landscape, a laptop with toolbars) widen the card
   so 说明 and 例句 sit in two columns and everything fits one screen. */
@media (min-width: 1000px) and (max-height: 780px) {
  .app-shell {
    width: min(1100px, calc(100% - 32px));
  }
}

/* With a mouse (desktops and laptops) the card otherwise keeps a phone-like column:
   760px wide at most, at most 860px tall, centred in the window instead of
   stretching an empty answer area over a tall screen. */
@media (hover: hover) and (pointer: fine) and (min-width: 561px) {
  body {
    display: grid;
    grid-template-rows: min(100%, 860px);
    align-content: center;
  }

  /* Read at arm's length on a laptop: one size up. Spacing stays as on a
     phone here so every card still fits a laptop screen; taller windows add
     air below. */
  .answer-main {
    font-size: 1.7rem;
  }

  .answer-main.is-meaning,
  .answer-main.is-word-list {
    font-size: 1.2rem;
  }

  .card-subtle.is-reading {
    font-size: 1.15rem;
  }

  .answer-section-title {
    font-size: 0.82rem;
  }

  .meta-lecture {
    font-size: 0.86rem;
  }

  .answer-meta {
    font-size: 1.08rem;
  }

  .example-ja {
    font-size: 1.3rem;
  }

  .example-romaji {
    font-size: 0.9rem;
  }

  .example-zh {
    font-size: 1.1rem;
  }

  .feedback {
    font-size: 1.1rem;
  }

  .bottom-tab {
    font-size: 0.84rem;
  }

  .bottom-tab-icon {
    width: 26px;
    height: 26px;
  }

  /* 模块 and its blocks: bigger cells with room between them. */
  .deck-page-header {
    padding-block: 14px;
  }

  .deck-page-header h2 {
    font-size: 1.25rem;
  }

  .deck-tabs .tab-button {
    font-size: 1.15rem;
  }

  .block-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 14px;
    padding: 20px clamp(16px, 3vw, 28px);
  }

  .block-grid.is-grammar {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .block-tile {
    min-height: 84px;
    gap: 4px;
    border-radius: 10px;
  }

  .block-tile.is-all {
    min-height: 72px;
  }

  .block-name {
    font-size: 1.45rem;
  }

  .block-status {
    font-size: 1rem;
  }
}

/* Laptop windows under 820px tall keep the examples at the tablet size so
   the longest grammar cards still fit. */
@media (hover: hover) and (pointer: fine) and (min-width: 561px) and (max-height: 820px) {
  .example-ja {
    font-size: 1.2rem;
  }

  .example-romaji {
    font-size: 0.86rem;
  }

  .example-zh {
    font-size: 0.98rem;
  }

  .example-item + .example-item {
    margin-top: 0;
  }
}

/* Tall desktop windows give the card more height and the answer more air. */
@media (hover: hover) and (pointer: fine) and (min-width: 561px) and (min-height: 960px) {
  body {
    grid-template-rows: min(100%, 940px);
  }

  .answer-panel {
    gap: 12px;
    padding-block: 14px;
  }

  .answer-details {
    gap: 12px 14px;
  }

  .answer-section-title {
    padding: 10px 16px 2px;
  }

  .meta-lecture {
    padding: 10px 16px 2px 0;
  }

  .answer-meta {
    gap: 6px;
    padding: 6px 16px 12px;
  }

  .example-item {
    gap: 12px;
    padding: 9px 10px 10px 16px;
  }

  .example-item + .example-item {
    margin-top: 10px;
  }

  .example-ja {
    margin-bottom: 4px;
  }

  .feedback {
    min-height: 56px;
  }

  .feedback-row {
    gap: 14px;
  }

  .bottom-tab {
    min-height: 62px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .study-card,
  .empty-state {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .word-band {
    padding:
      max(10px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      12px
      max(12px, env(safe-area-inset-left));
  }

  .answer-panel {
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  }

  .empty-state {
    padding:
      max(14px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      14px
      max(14px, env(safe-area-inset-left));
  }

  .deck-page {
    border: 0;
    border-radius: 0;
  }

  .deck-page-header {
    padding:
      max(10px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      10px
      max(12px, env(safe-area-inset-left));
  }

  .deck-tabs,
  .block-grid {
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  }

  /* Edge-to-edge bar like a native tab bar, clear of the home indicator. */
  .study-area {
    border-radius: 0;
    box-shadow: none;
  }

  .bottom-bar {
    padding-bottom: env(safe-area-inset-bottom);
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    border-width: 1px 0 0;
    border-radius: 0;
  }

  .feedback-row {
    gap: 6px;
  }



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

  .choice-list.is-answered .choice-option.is-selected.is-correct {
    grid-column: 1 / -1;
  }

  .choice-option {
    grid-template-columns: 1.65rem minmax(0, 1fr);
    gap: 6px;
    min-height: 60px;
    padding-block: 6px;
    padding-inline: 7px;
  }

  .choice-marker {
    width: 1.65rem;
    height: 1.65rem;
  }

  .choice-text {
    font-size: 0.84rem;
    line-height: 1.27;
  }

  .choice-reason {
    font-size: 0.8rem;
    line-height: 1.28;
  }

}

@media (max-height: 640px) {
  .choice-feedback {
    max-height: none;
  }

}

@media (min-height: 521px) and (max-height: 640px) {
  .study-card.is-answering .answer-panel {
    align-self: stretch;
    block-size: 100%;
    justify-content: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-height: 520px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .study-card {
    grid-template-rows: auto auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .empty-state,
  .deck-page {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .answer-panel {
    align-self: start;
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  }

  .word-band {
    padding:
      max(10px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      12px
      max(12px, env(safe-area-inset-left));
  }

  .study-area {
    border-radius: 0;
    box-shadow: none;
  }

  .bottom-bar {
    padding-bottom: env(safe-area-inset-bottom);
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    border-width: 1px 0 0;
    border-radius: 0;
  }

  .bottom-tab {
    min-height: 44px;
    grid-auto-flow: column;
    justify-content: center;
    gap: 6px;
  }

  /* Icon, count, label in one row: the count sits inline instead of
     overlapping the label. */
  .bottom-tab-figure {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .bottom-tab-badge {
    position: static;
  }
}

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

/* The grammar pattern or vocab word inside each example sentence, its
   furigana included. */
.example-ja mark.example-focus,
.example-ja mark.example-focus rt {
  background: none;
  color: var(--gold);
}

/* Its romaji is marked the same way. */
.example-romaji mark.example-romaji-focus {
  background: none;
  color: var(--gold);
}

/* Its counterpart in the translation keeps the text colour and gets a
   dotted underline. */
.example-zh mark.example-zh-focus {
  background: none;
  color: inherit;
  text-decoration: underline dotted var(--muted);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.28em;
}

/* 提示 sits above the options until opened, then lists the pattern and its
   formation in the 说明 style. */
.choice-hint {
  display: grid;
  justify-items: start;
}

.choice-hint-body {
  width: 100%;
  padding: 6px 10px;
  border-left: 3px solid var(--gold);
  background: var(--control-soft);
}
