/* ------------------------------------------------------------------
   JLPT 单词翻转卡 — styles
   Baseline: Chrome 61 / Android 8.1 WebView (no flex gap, no clamp(),
   no logical properties, no inset). Enhancements are opt-in via a
   behaviour-detected class on <html>.
   Colour schemes are theme classes on <html> (theme-sakura / -mint /
   -ocean / -ink) that only swap custom properties.
   ------------------------------------------------------------------ */

:root {
  --radius: 20px;
  --radius-sm: 13px;
}

html.theme-sakura {
  --bg: #fff6f5;
  --bg-2: #ffe8ee;
  --ink: #241a1d;
  --ink-2: #4b4044;
  --muted: #a38e93;
  --line: rgba(36, 26, 29, 0.09);
  --accent: #ff2e4d;
  --accent-ink: #b3122e;
  --accent-soft: rgba(255, 46, 77, 0.1);
  --accent-glow: rgba(255, 46, 77, 0.26);
  --on-accent: #ffffff;
  --card: #ffffff;
  --card-2: #fff8f9;
  --chip: rgba(255, 255, 255, 0.78);
  --chip-ink: #6b5b60;
  --shadow: 0 12px 34px rgba(180, 60, 80, 0.12);
  --ok-bg: #ecfdf3;
  --ok-ink: #15803d;
  --ok-line: rgba(22, 163, 74, 0.26);
}

html.theme-mint {
  --bg: #f4fbf7;
  --bg-2: #dff5ea;
  --ink: #16241e;
  --ink-2: #3b4f46;
  --muted: #88a698;
  --line: rgba(22, 36, 30, 0.09);
  --accent: #10a06b;
  --accent-ink: #0a7049;
  --accent-soft: rgba(16, 160, 107, 0.1);
  --accent-glow: rgba(16, 160, 107, 0.26);
  --on-accent: #ffffff;
  --card: #ffffff;
  --card-2: #f5fdf9;
  --chip: rgba(255, 255, 255, 0.8);
  --chip-ink: #4c6359;
  --shadow: 0 12px 34px rgba(26, 116, 88, 0.13);
  --ok-bg: #ecfdf3;
  --ok-ink: #15803d;
  --ok-line: rgba(22, 163, 74, 0.26);
}

html.theme-ocean {
  --bg: #f4f8ff;
  --bg-2: #e2edff;
  --ink: #141c26;
  --ink-2: #3a4657;
  --muted: #8595aa;
  --line: rgba(20, 28, 38, 0.09);
  --accent: #2f6fed;
  --accent-ink: #1c4fc0;
  --accent-soft: rgba(47, 111, 237, 0.1);
  --accent-glow: rgba(47, 111, 237, 0.26);
  --on-accent: #ffffff;
  --card: #ffffff;
  --card-2: #f7faff;
  --chip: rgba(255, 255, 255, 0.8);
  --chip-ink: #4a5a70;
  --shadow: 0 12px 34px rgba(38, 88, 178, 0.14);
  --ok-bg: #ecfdf3;
  --ok-ink: #15803d;
  --ok-line: rgba(22, 163, 74, 0.26);
}

html.theme-ink {
  --bg: #151920;
  --bg-2: #1d232d;
  --ink: #e9edf3;
  --ink-2: #b7c1ce;
  --muted: #7e8796;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #f0a24b;
  --accent-ink: #f6bd78;
  --accent-soft: rgba(240, 162, 75, 0.15);
  --accent-glow: rgba(240, 162, 75, 0.28);
  --on-accent: #241a08;
  --card: #1e232c;
  --card-2: #252b37;
  --chip: rgba(255, 255, 255, 0.07);
  --chip-ink: #a9b3c1;
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.5);
  --ok-bg: rgba(34, 197, 94, 0.16);
  --ok-ink: #7fe3a9;
  --ok-line: rgba(34, 197, 94, 0.32);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* The hidden attribute must win over the layout rules below it, otherwise a
   hidden flex row would still be drawn. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  min-height: var(--app-height, 100vh);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--bg-2) 0px, var(--bg) 420px);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Source Han Sans SC",
               "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.app {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  min-height: var(--app-height, 100vh);
  margin: 0 auto;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-top: 0;
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  margin-bottom: 14px;
}

.brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 700;
  line-height: 26px;
  text-align: center;
  margin-right: 8px;
  flex: 0 0 auto;
  box-shadow: 0 4px 10px var(--accent-glow);
}

.brand-text {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  font-size: 12px;
  color: var(--muted);
  margin-left: 10px;
  flex: 0 0 auto;
}

/* ---------- level switch ---------- */

.levels {
  display: flex;
  flex-direction: row;
  margin-bottom: 16px;
}

.level-btn {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  min-height: 38px;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--chip);
  color: var(--chip-ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* baseline spacing: single-sided margins (Chrome 61 has no flex gap) */
.level-btn + .level-btn {
  margin-left: 6px;
}

.level-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 5px 14px var(--accent-glow);
}

.level-btn:active {
  opacity: 0.75;
}

/* ---------- feature buttons (test / recite) ---------- */

.features {
  display: flex;
  flex-direction: row;
  margin-bottom: 16px;
}

.feature-btn {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  min-height: 64px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--chip);
  color: var(--chip-ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background-color 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, box-shadow 0.2s ease;
}

.feature-btn + .feature-btn {
  margin-left: 10px;
}

.feature-btn:active {
  opacity: 0.8;
}

.feature-btn.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.feature-icon {
  flex: 0 0 auto;
  margin-right: 9px;
  font-size: 25px;
  line-height: 1.1;
}

.feature-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.feature-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
}

.feature-sub {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.35;
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feature-state {
  flex: 0 0 auto;
  margin-left: 7px;
  padding: 3px 8px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
}

.feature-btn.is-on .feature-state {
  background: rgba(255, 255, 255, 0.24);
  color: var(--on-accent);
}

.supports-flex-gap .features {
  column-gap: 10px;
}

.supports-flex-gap .feature-btn + .feature-btn {
  margin-left: 0;
}

/* enhancement: real flex gap, only when the layout engine proves it works */
.supports-flex-gap .levels {
  column-gap: 6px;
}

.supports-flex-gap .level-btn + .level-btn {
  margin-left: 0;
}

/* ---------- card ---------- */

.stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

/* soft halo behind the card */
.stage::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 320px;
  height: 320px;
  margin: -160px 0 0 -160px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  pointer-events: none;
}

.card {
  position: relative;
  perspective: 1200px;
  width: 100%;
  cursor: pointer;
  outline: none;
}

/* 焦点样式：Chrome 61 只认 :focus，先给基线；新内核再用 :focus-visible
   把鼠标点击时的边框收掉，键盘操作仍然看得见焦点。 */
.card:focus {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.card:focus:not(:focus-visible) {
  outline: none;
}

.card-inner {
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0.2, 0.2, 1);
  will-change: transform;
}

.card.is-flipped .card-inner {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.face {
  width: 100%;
  min-height: 310px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background-color: var(--card);
  background-image: linear-gradient(158deg, var(--card-2) 0%, var(--card) 58%);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 26px 20px;
  text-align: center;
}

.face-front {
  position: relative;
  padding-top: 66px;
}

.face-back {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

@media (min-height: 700px) {
  .face {
    min-height: 350px;
  }
}

.word {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: 0.04em;
  word-break: break-word;
}

/* 例句：与主词之间用一条细线分开，字号比正文略大一点 */
.example {
  align-self: stretch;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-2);
  word-break: break-word;
}

.example.is-empty {
  display: none;
}

.hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}

.kana {
  font-size: 29px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--accent);
  word-break: break-word;
}

.zh {
  margin-top: 10px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}

/* ---------- example block on the back face ---------- */

.ex-block {
  width: 100%;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.exkana {
  font-size: 14px;
  line-height: 1.8;
  color: var(--muted);
  word-break: break-word;
}

.exzh {
  display: inline-block;
  max-width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 15px;
  line-height: 1.65;
  text-align: left;
  word-break: break-word;
}

.exzh-tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

/* ---------- card tools: separate word / sentence playback ---------- */

.card-tools {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: row;
}

.mini-speak {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 44px;
  margin-left: 8px;
  border: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 44px;
  text-align: center;
  cursor: pointer;
}

.mini-speak:first-child {
  margin-left: 0;
}

.mini-speak:active {
  opacity: 0.6;
}

/* ---------- back-face action ---------- */

.known-btn {
  -webkit-appearance: none;
  appearance: none;
  margin-top: 20px;
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--chip);
  color: var(--chip-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.known-btn.is-known {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-ink);
}

.known-btn:active {
  opacity: 0.75;
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  flex-direction: column;
  margin-top: 18px;
}

.control-row {
  display: flex;
  flex-direction: row;
}

.control-row + .control-row {
  margin-top: 10px;
}

.btn {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  min-height: 46px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--chip);
  color: var(--chip-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  opacity: 0.75;
  transform: scale(0.985);
}

.btn-ghost {
  flex: 0 1 auto;
}

.btn-primary {
  flex: 1 1 auto;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.btn + .btn {
  margin-left: 10px;
}

.supports-flex-gap .control-row {
  column-gap: 10px;
}

.supports-flex-gap .control-row .btn + .btn {
  margin-left: 0;
}

/* 上一个 / 下一个 同处一行：下一个是主操作，占比更大但不至于铺满整行 */
.control-nav .btn-ghost {
  flex: 1 1 0;
  min-width: 92px;
}

.control-nav .btn-primary {
  flex: 1.7 1 0;
}

/* ---------- auto-read switches + huge card ---------- */

.settings {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.settings-label {
  font-size: 11px;
  color: var(--muted);
  margin-right: 8px;
}

.toggle {
  -webkit-appearance: none;
  appearance: none;
  min-height: 30px;
  margin-left: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip);
  color: var(--chip-ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.toggle:first-of-type {
  margin-left: 0;
}

.toggle.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.toggle:active {
  opacity: 0.75;
}

.settings-sep {
  width: 1px;
  height: 16px;
  margin: 0 8px;
  background: var(--line);
}

/* ---------- 语音选择 ----------
   设备上装了多个日语 / 中文语音时，可以自己挑一个；Natural 排在最前。
   下面那一行是诊断信息：浏览器到底报了多少个语音。 */

.voice-settings {
  margin-top: 10px;
}

.voice-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.voice-row + .voice-row {
  margin-top: 6px;
}

.voice-select {
  flex: 1 1 150px;
  min-width: 0;
  max-width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chip);
  color: var(--chip-ink);
  font-family: inherit;
  font-size: 12px;
  line-height: 18px;
}

.voice-preview,
.voice-rescan {
  flex: 0 0 auto;
  min-height: 32px;
  margin-left: 8px;
  padding: 6px 14px;
  font-size: 12px;
}

/* 语音检测：诊断信息 + 「重新检测」按钮 */
.voice-scan {
  align-items: flex-start;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.voice-scan-text {
  flex: 1 1 150px;
  min-width: 0;
  font-size: 11px;
  line-height: 18px;
  color: var(--muted);
  word-break: break-all;
}

/* 语音清单里没有日语时的说明：告诉用户浏览器到底报了什么、该怎么试 */
.voice-hint {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 18px;
  color: var(--muted);
  word-break: break-all;
}

/* 一个语音都没检测到时的提示 */
.voice-empty {
  font-size: 11px;
  color: var(--muted);
}

/* ---------- 巨大卡片模式 ----------
   整屏只剩一张居中的大卡片：卡片按内容收缩、四周留白，像手机变成 iPad；
   翻面用淡入淡出，不再整页 3D 翻转；按钮收在画面正下方。 */

.is-big .topbar,
.is-big .levels,
.is-big .features,
.is-big .qmodes,
.is-big .controls,
.is-big .settings,
.is-big .voice-settings,
.is-big .themes,
.is-big .foot,
.is-big .credit,
.is-big .usage-hint {
  display: none !important;
}

/* 手机变成 iPad：页面收成一块居中的画布 */
.is-big .app {
  max-width: 720px;
  padding: 0;
}

.is-big .stage {
  justify-content: center;
  align-items: center;
  padding: 16px 16px 104px;
}

/* 卡片按内容收缩，圆角与阴影交给卡片本身 */
.is-big .card {
  flex: 0 1 auto;
  width: auto;
  min-width: 240px;
  max-width: 560px;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 26px;
  background-color: var(--card);
  background-image: linear-gradient(158deg, var(--card-2) 0%, var(--card) 58%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 两个面叠在同一个格子里：翻面时卡片高度不跳动 */
.is-big .card-inner {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  transform: none;
  -webkit-transform: none;
  transition: none;
}

.is-big .face {
  grid-area: 1 / 1;
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  min-height: 0;
  padding: 28px 30px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
  /* 背面原本是转 180° 放着的，这里不再翻转，只做淡入淡出 */
  transform: none;
  -webkit-transform: none;
  transition: opacity 0.24s ease;
}

/* 大卡片不整页翻转，只做一次柔和的淡入淡出 */
.is-big .card.is-flipped .card-inner {
  transform: none;
  -webkit-transform: none;
}

/* 进入大卡片的那一帧：背面直接消失，不做淡出。
   普通模式里背面是转 180° 放着的（靠 backface-visibility 藏起来），
   大卡片里它改成正面朝向 —— 要是让它慢慢淡出，两面的字会叠在一起。 */
.is-big.no-fade .face {
  transition: none !important;
}

.is-big .card:not(.is-flipped) .face-back {
  opacity: 0;
  pointer-events: none;
}

.is-big .card.is-flipped .face-front {
  opacity: 0;
  pointer-events: none;
}

/* 正面右上角给朗读按钮留位 */
.is-big .face-front {
  padding-top: 76px;
}

/* 主要内容放大：单词、例句、翻转后的假名与译文 */
.is-big {
  --word-size: 16.5vw;
  --example-size: 5.8vw;
  --kana-size: 11vw;
  --zh-size: 7.2vw;
  --exkana-size: 5vw;
  --exzh-size: 5vw;
}

.is-big .word {
  font-size: var(--word-size);
  line-height: 1.22;
}

.is-big .example {
  margin-top: 22px;
  padding-top: 18px;
  font-size: var(--example-size);
  line-height: 1.7;
}

/* 注释文字保持原样，不跟着放大 */
.is-big .hint {
  margin-top: 22px;
  font-size: 12px;
}

.is-big .kana {
  font-size: var(--kana-size);
}

.is-big .zh {
  margin-top: 12px;
  font-size: var(--zh-size);
}

.is-big .ex-block {
  margin-top: 22px;
  padding-top: 18px;
}

.is-big .exkana {
  font-size: var(--exkana-size);
  line-height: 1.8;
}

.is-big .exzh {
  margin-top: 12px;
  padding: 2.6vw 3.2vw;
  font-size: var(--exzh-size);
}

/* 字越长，字号收一档：长词不拆行、长句不撑破一屏 */
.is-big .card[data-wlen="2"] {
  --word-size: 12.6vw;
  --kana-size: 8.6vw;
}

.is-big .card[data-wlen="3"] {
  --word-size: 10vw;
  --kana-size: 7vw;
}

.is-big .card[data-exlen="2"] {
  --example-size: 5.2vw;
  --exkana-size: 4.6vw;
  --exzh-size: 4.6vw;
}

.is-big .card[data-exlen="3"] {
  --example-size: 4.8vw;
  --exkana-size: 4.2vw;
  --exzh-size: 4.2vw;
}

.is-big .exzh-tag {
  font-size: 12px;
}

.is-big .known-btn {
  min-height: 48px;
  padding: 12px 24px;
  font-size: 16px;
}

.is-big .mini-speak {
  width: 52px;
  height: 52px;
  font-size: 18px;
  line-height: 52px;
}

/* 提示条浮在按钮上方，不压住卡片 */
.is-big .tts-note {
  position: fixed;
  left: 50%;
  bottom: 76px;
  z-index: 31;
  width: calc(100% - 32px);
  max-width: 520px;
  margin: 0;
  transform: translateX(-50%);
}

/* 两条提示同时出现时不能叠在一起 —— 中文那条放到日语那条上面 */
.is-big .tts-note-zh {
  bottom: 132px;
}

/* 屏幕不高时整体收一档，保证一屏放得下 */
@media (max-height: 700px) {
  .is-big .stage {
    padding: 12px 14px 92px;
  }
  .is-big .face {
    padding: 22px 26px;
  }
  .is-big .face-front {
    padding-top: 68px;
  }
  .is-big {
    --word-size: 14vw;
    --example-size: 5.1vw;
    --kana-size: 9.4vw;
    --zh-size: 6.2vw;
    --exkana-size: 4.4vw;
    --exzh-size: 4.4vw;
  }
  .is-big .card[data-wlen="2"] {
    --word-size: 11.4vw;
    --kana-size: 7.9vw;
  }
  .is-big .card[data-wlen="3"] {
    --word-size: 9.2vw;
    --kana-size: 6.4vw;
  }
  .is-big .card[data-exlen="2"] {
    --example-size: 4.8vw;
    --exkana-size: 4.2vw;
    --exzh-size: 4.2vw;
  }
  .is-big .card[data-exlen="3"] {
    --example-size: 4.4vw;
    --exkana-size: 4vw;
    --exzh-size: 4vw;
  }
}

/* 宽屏上文字不再继续变大 */
@media (min-width: 560px) {
  .is-big {
    --word-size: 96px;
    --example-size: 30px;
    --kana-size: 64px;
    --zh-size: 40px;
    --exkana-size: 24px;
    --exzh-size: 24px;
  }
  .is-big .card[data-wlen="2"] {
    --word-size: 72px;
    --kana-size: 52px;
  }
  .is-big .card[data-wlen="3"] {
    --word-size: 58px;
    --kana-size: 42px;
  }
  .is-big .card[data-exlen="2"] {
    --example-size: 26px;
    --exkana-size: 22px;
    --exzh-size: 22px;
  }
  .is-big .card[data-exlen="3"] {
    --example-size: 24px;
    --exkana-size: 21px;
    --exzh-size: 21px;
  }
}

/* 大卡片模式下的悬浮操作条：按钮收在画面正下方 */
.big-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--bg) 45%);
}

/* 真机才有真实的 env() 安全区；Chrome 61 不认识 env()，整块跳过，
   保留上面那条基线写法。 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .big-bar {
    padding-bottom: calc(12px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  }
}

.is-big .big-bar {
  display: flex;
}

/* 两个按钮并排居中，大小保持正常，不铺满整行 */
.big-bar .btn {
  flex: 0 0 auto;
  min-width: 118px;
  min-height: 48px;
  padding: 12px 22px;
  font-size: 16px;
}

/* ---------- note ---------- */

.tts-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

/* 中文语音缺失时的安装提示 —— 语气比日语语音那条弱一档 */
.tts-note-zh {
  background: var(--chip);
  color: var(--muted);
  word-break: break-all;
}

/* 使用提示：默认收起，需要时点开 */
.usage-hint {
  margin: 10px auto 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.usage-hint > summary {
  cursor: pointer;
  list-style: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--chip);
  display: inline-block;
}

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

.usage-hint > summary::before {
  content: '💡 ';
}

.usage-hint[open] > summary {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.usage-hint p {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--chip);
  text-align: left;
}

.usage-hint code {
  font-family: Consolas, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--ink-2);
}

/* ---------- colour schemes ---------- */

.themes {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.themes-label {
  font-size: 11px;
  color: var(--muted);
  margin-right: 10px;
}

.theme-btn {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  margin-left: 8px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-btn:first-of-type {
  margin-left: 0;
}

.theme-btn.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.sw {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.sw-sakura {
  background: linear-gradient(135deg, #ffd9e0 0%, #ff2e4d 100%);
}

.sw-mint {
  background: linear-gradient(135deg, #d7f3e5 0%, #10a06b 100%);
}

.sw-ocean {
  background: linear-gradient(135deg, #d7e6ff 0%, #2f6fed 100%);
}

.sw-ink {
  background: linear-gradient(135deg, #39414f 0%, #f0a24b 100%);
}

/* ---------- 题型 (test modes) ---------- */

.qmodes {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: -6px 0 14px;
}

.qmodes-label {
  font-size: 11px;
  color: var(--muted);
  margin-right: 8px;
}

.qm-btn {
  -webkit-appearance: none;
  appearance: none;
  min-height: 30px;
  margin: 3px 4px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--chip);
  color: var(--chip-ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  cursor: pointer;
}

.qm-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.qm-btn:active {
  opacity: 0.75;
}

/* ---------- quiz ---------- */

.quiz {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background-color: var(--card);
  background-image: linear-gradient(158deg, var(--card-2) 0%, var(--card) 58%);
  box-shadow: var(--shadow);
  padding: 20px 18px;
}

.quiz-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.quiz-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

.quiz-score {
  font-size: 12px;
  color: var(--muted);
}

.quiz-prompt {
  margin-top: 18px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  word-break: break-word;
}

.quiz-prompt.is-small {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.6;
}

.quiz-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}

.quiz-listen {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  margin: 14px auto 0;
  min-width: 132px;
  min-height: 52px;
  padding: 12px 20px;
  border: none;
  border-radius: 26px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 20px var(--accent-glow);
  cursor: pointer;
}

.quiz-listen:active {
  opacity: 0.8;
}

.quiz-options {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 18px;
}

.quiz-option {
  -webkit-appearance: none;
  appearance: none;
  width: 48%;
  min-height: 54px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--chip);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  word-break: break-word;
  cursor: pointer;
}

.quiz-option:nth-child(odd) {
  margin-right: 4%;
}

.quiz-option:active {
  opacity: 0.75;
}

/* an answered question keeps its colours */
.quiz-option[disabled] {
  opacity: 1;
}

.btn[disabled] {
  opacity: 0.45;
}

.quiz-option.is-correct {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-ink);
}

.quiz-option.is-wrong {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.quiz-feedback {
  margin-top: 4px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  text-align: center;
}

.qf-word {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
}

.qf-kana {
  margin-top: 2px;
  font-size: 15px;
  color: var(--accent-ink);
}

.qf-zh {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
}

.qf-ex {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
}

.qf-exzh {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}

.qf-summary {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.7;
}

.quiz-actions {
  display: flex;
  flex-direction: row;
  margin-top: 16px;
}

.quiz-actions .btn + .btn {
  margin-left: 10px;
}

.supports-flex-gap .quiz-actions {
  column-gap: 10px;
}

.supports-flex-gap .quiz-actions .btn + .btn {
  margin-left: 0;
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-bottom: 0;
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  font-size: 11px;
  color: var(--muted);
}

.link-btn {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: none;
  padding: 8px 4px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}

.link-btn:active {
  opacity: 0.6;
}

/* 背诵模式开启时高亮 */
.link-btn.is-on {
  color: var(--accent);
  font-weight: 600;
}

.dot {
  margin: 0 6px;
}

.credit {
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* ---------- empty-field guards ----------
   A card whose example sentence or example translation is missing must not
   leave a coloured hole behind: the element is collapsed instead. */

.example:empty,
.exkana:empty,
.qf-ex:empty,
.qf-exzh:empty {
  display: none;
}

/* without the kana line the translation box moves up */
.exkana:empty + .exzh {
  margin-top: 0;
}

/* the whole example block disappears when neither part has content */
.ex-block.is-empty {
  display: none;
}

