:root {
  --ink: #0b1f3b;
  --paper: #f4efe2;
  --accent: #ff6b35;
  --accent-2: #0f9d8b;
  --soft: #fff9f0;
  --muted: #516079;
  --shadow: 0 12px 30px rgba(11, 31, 59, 0.15);
  --radius: 22px;
  --bg-a: #ffe2c6;
  --bg-b: #f8e7cc;
  --bg-c: #e8f2ff;
  --shape-a: #78c1f3;
  --shape-b: #ffc36e;
}

body[data-theme="harbour"] {
  --ink: #10354d;
  --paper: #f0f8fa;
  --accent: #e64d3d;
  --accent-2: #1a8a84;
  --soft: #f9fffe;
  --muted: #466476;
  --bg-a: #d6f2ff;
  --bg-b: #eaf7f3;
  --bg-c: #fff0e4;
  --shape-a: #74b8ff;
  --shape-b: #ffd48a;
}

body[data-theme="neon"] {
  --ink: #17213e;
  --paper: #f7f1e9;
  --accent: #ff5f45;
  --accent-2: #0f9d8b;
  --soft: #fffdf8;
  --muted: #5a6486;
  --bg-a: #ffe8d6;
  --bg-b: #f7e7ff;
  --bg-c: #dff5ff;
  --shape-a: #93b7ff;
  --shape-b: #ffb171;
}

body[data-theme="neon-strong"] {
  --ink: #101733;
  --paper: #fff4ec;
  --accent: #ff3b30;
  --accent-2: #00a39b;
  --soft: #fffdf7;
  --muted: #4d5579;
  --bg-a: #ffd8bf;
  --bg-b: #ffe5f8;
  --bg-c: #cfefff;
  --shape-a: #4f8dff;
  --shape-b: #ff8a42;
}

body[data-theme="neon-extreme"] {
  --ink: #fff8ff;
  --paper: #18071f;
  --accent: #ff2f6d;
  --accent-2: #00f5d4;
  --soft: #221031;
  --muted: #f4c8f2;
  --bg-a: #16030f;
  --bg-b: #2b031e;
  --bg-c: #051429;
  --shape-a: #00ecff;
  --shape-b: #ff5a00;
}

body[data-theme="ink"] {
  --ink: #1d1d1d;
  --paper: #f2f2ee;
  --accent: #5a5a5a;
  --accent-2: #2e2e2e;
  --soft: #fbfbf8;
  --muted: #636363;
  --bg-a: #e8e8e3;
  --bg-b: #f1f1ec;
  --bg-c: #dfe2e5;
  --shape-a: #bfc6cc;
  --shape-b: #cfc8be;
}

body[data-theme="ink"]::after {
  content:
    "香港日報 一九三七 九月 港聞 特刊\\A維港 大風 雨勢 航運 通知\\A中環 上環 灣仔 銅鑼灣 報導\\A九龍 油麻地 旺角 深水埗 消息\\A新界 沙田 荃灣 元朗 北區 札記\\A廣東話 聲調 練習 專欄\\A買 賣 食 識 早 做 手 受 詩 史 富 苦\\A早報 晚報 社論 港聞 經濟\\A航運 鐵路 電報 商務 碼頭\\A市集 茶樓 店舖 車站 街市\\A學校 課本 字典 讀寫 聽講\\A粵語 口音 聲調 句式 語法\\A本報 記者 採訪 現場 照會\\A公告 天氣 風向 潮汐 警報\\A港島 九龍 新界 三地 新聞\\A茶餐廳 的士 電車 小巴 記\\A街頭 霓虹 廣告 招牌 夜景\\A家庭 朋友 旅行 日常 對話\\A如果 就會 咗 過 緊 住 返\\A香港日報 香港日報 香港日報";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  white-space: pre-wrap;
  font-family: "Courier New", "American Typewriter", monospace;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 3px;
  color: rgba(10, 10, 10, 0.33);
  padding: 12px 8px;
  writing-mode: vertical-rl;
  text-orientation: upright;
}

body[data-theme="ink"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.85;
  background:
    repeating-linear-gradient(0deg, rgba(30, 30, 30, 0.06) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(90deg, rgba(30, 30, 30, 0.05) 0 1px, transparent 1px 28px),
    radial-gradient(circle at 20% 10%, rgba(110, 110, 110, 0.15), transparent 40%);
}

body[data-theme="poster"] {
  --ink: #fff7e8;
  --paper: #2a1515;
  --accent: #ef3e2f;
  --accent-2: #ffcc00;
  --soft: #381a19;
  --muted: #ffd6bd;
  --bg-a: #5b1a1a;
  --bg-b: #163a2f;
  --bg-c: #331a52;
  --shape-a: #f23d2f;
  --shape-b: #ffd500;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 20%, var(--bg-a) 0%, var(--bg-b) 34%, var(--bg-c) 78%);
  min-height: 100vh;
  touch-action: manipulation;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  z-index: 0;
  filter: blur(30px);
  opacity: 0.5;
}

body[data-theme="neon-extreme"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.84;
  background:
    radial-gradient(circle at 84% 20%, rgba(255, 44, 120, 0.34), transparent 35%),
    radial-gradient(circle at 20% 80%, rgba(0, 245, 210, 0.3), transparent 40%),
    linear-gradient(145deg, rgba(255, 55, 0, 0.14), transparent 45%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 26px);
}

body[data-theme="neon-extreme"] .bg-shape {
  filter: blur(8px);
  opacity: 0.95;
}

body[data-theme="neon-extreme"]::after {
  content: "香港\\A霓虹\\A茶餐廳\\A的士\\A夜街";
  position: fixed;
  right: 10px;
  top: 12px;
  z-index: 0;
  pointer-events: none;
  font-family: "PingFang TC", "Heiti TC", sans-serif;
  font-size: 42px;
  line-height: 1.05;
  letter-spacing: 4px;
  writing-mode: vertical-rl;
  color: #ff4f8a;
  text-shadow: 0 0 8px #ff4f8a, 0 0 16px #ff4f8a, 0 0 22px #00f5d4;
  opacity: 0.92;
}

body[data-theme="poster"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
  background:
    linear-gradient(25deg, rgba(255, 212, 0, 0.1), transparent 35%),
    linear-gradient(160deg, rgba(239, 62, 47, 0.14), transparent 45%),
    repeating-linear-gradient(-35deg, rgba(255, 255, 255, 0.05) 0 4px, transparent 4px 38px);
}

body[data-theme="poster"] .bg-shape {
  display: none;
}

.shape-a {
  width: 220px;
  height: 220px;
  background: var(--shape-a);
  top: -70px;
  right: -60px;
}

.shape-b {
  width: 180px;
  height: 180px;
  background: var(--shape-b);
  bottom: -40px;
  left: -50px;
}

.app-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 16px 24px;
  position: relative;
  z-index: 1;
}

body.platform-ios .app-shell {
  padding-top: calc(18px + (env(safe-area-inset-top) * 0.75));
}

.main-transition-overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  border-radius: 14px;
  background:
    radial-gradient(circle at 22% 18%, color-mix(in srgb, var(--paper) 76%, #fff), transparent 58%),
    linear-gradient(170deg, color-mix(in srgb, var(--soft) 90%, #fff), color-mix(in srgb, var(--paper) 86%, #fff));
}

.main-transition-overlay.is-running {
  animation: main-tab-overlay-fade 260ms ease-in-out;
}

body.bottom-nav-enabled .app-shell {
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.version-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #8fb3d9;
  color: #365173;
  font-weight: 700;
  font-size: 0.75rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-transform: none;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(1.68rem, 3.3vw, 2.18rem);
  line-height: 1.12;
}

h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2.35vw, 1.4rem);
  line-height: 1.2;
  font-weight: 800;
}

#appTitle {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title-version {
  margin-left: 0;
  transform: translateY(1px);
}

.topbar-right #streakBadge {
  display: none;
}

.streak {
  background: color-mix(in srgb, var(--soft) 62%, transparent);
  border: 1px solid rgba(53, 95, 125, 0.14);
  border-radius: 999px;
  padding: 6px 11px;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.1;
  white-space: nowrap;
}

.tabs {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tab {
  border: 1px solid rgba(116, 141, 171, 0.2);
  background: rgba(255, 255, 255, 0.64);
  border-radius: 12px;
  padding: 10px 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.03rem;
  line-height: 1.15;
  color: var(--ink);
  box-shadow: 0 3px 8px rgba(37, 62, 93, 0.12);
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.tab.is-active {
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border-color: rgba(233, 108, 111, 0.62);
  color: #fff;
}

.tabs .tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  text-align: left;
}

.tabs .learn-tab-icon {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tabs .learn-tab-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.tabs .learn-tab-label {
  font-size: 0.86rem;
  line-height: 1.05;
  font-weight: 700;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: 100%;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-radius: 14px 14px 0 0;
  border: 1px solid rgba(86, 120, 156, 0.22);
  border-bottom: 0;
  background: color-mix(in srgb, var(--soft) 76%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: 0 -6px 20px rgba(16, 37, 63, 0.2);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.bottom-nav-btn {
  border: 1px solid rgba(116, 141, 171, 0.2);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 11px;
  padding: 7px 6px 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--ink);
  box-shadow: 0 3px 8px rgba(37, 62, 93, 0.12);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 49px;
}

.bottom-nav-btn.is-active {
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border-color: rgba(233, 108, 111, 0.62);
  color: #fff;
  box-shadow: 0 7px 14px rgba(184, 71, 92, 0.28);
}

.bottom-nav-btn.utility-btn:not(.is-active) {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(103, 126, 152, 0.2);
}

.bottom-nav-btn.utility-btn.is-active {
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border-color: rgba(233, 108, 111, 0.62);
  color: #fff;
}

.bottom-nav-icon {
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.9;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav-icon svg.legacy-icon {
  display: none;
}

.bottom-nav-label {
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

body.stories-mode .tabs {
  display: none;
}

body.book-mode .tabs {
  display: none;
}

body.search-mode .tabs {
  display: none;
}

body.settings-mode .tabs {
  display: none;
}

body.user-mode .tabs {
  display: none;
}

#panel-search .card {
  display: grid;
  gap: 10px;
}

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

.search-nav-btn {
  font-size: 0.95rem;
}

.search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

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

.slang-filters label {
  display: block;
  margin: 0 0 5px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #35506a;
}

.slang-filters select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(118, 147, 179, 0.35);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 9px 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

@media (max-width: 640px) {
  .slang-filters {
    grid-template-columns: 1fr;
  }
}

#searchInput {
  width: 100%;
  border-radius: 11px;
  border: 1px solid rgba(118, 147, 179, 0.35);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 600;
}

#runSearch,
#clearSearch {
  min-width: auto;
  min-height: 36px;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 0.88rem;
  font-weight: 700;
}

#runSearch {
  border: 2px solid #ef8d66;
  color: #fff;
  background: linear-gradient(160deg, #ff9968 0%, #ff7474 52%, #ff5c86 100%);
  box-shadow: 0 5px 12px rgba(228, 94, 98, 0.28);
}

#clearSearch {
  border: 2px solid #d3dce9;
  color: #35506a;
  background: linear-gradient(180deg, #f8f9fb 0%, #e9edf3 100%);
}

.search-results {
  display: grid;
  gap: 8px;
}

.search-item {
  border: 1px solid rgba(117, 145, 180, 0.2);
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.68);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.search-main .hanzi,
.search-main .jyutping,
.search-main .english {
  margin: 0;
}

.search-main .hanzi {
  font-size: 1.3rem;
}

.search-main .jyutping {
  margin-top: 3px;
}

.search-main .english {
  margin-top: 4px;
}

.search-slang-meta {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.search-slang-tone {
  margin-top: 6px;
}

.search-slang-note {
  margin: 6px 0 0;
  font-size: 0.84rem;
  line-height: 1.35;
}

.search-slang-risk {
  margin: 6px 0 0;
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.3;
}

.search-slang-risk.is-rude {
  color: #8c2f1b;
  background: rgba(255, 109, 77, 0.14);
  border: 1px solid rgba(236, 91, 54, 0.42);
}

.search-slang-risk.is-offensive {
  color: #fff;
  background: linear-gradient(180deg, #d92525 0%, #a91515 100%);
  border: 1px solid #8f0d0d;
}

.search-chip {
  margin: 0 0 6px;
}

.search-actions {
  margin: 0;
  justify-content: flex-end;
}

.stories-card {
  display: grid;
  gap: 10px;
}

.stories-card > h2 {
  margin: 0;
}

.stories-intro {
  margin: -2px 0 0;
}

.stories-card.is-facts-compact {
  gap: 6px;
}

.stories-card.is-facts-compact > .stories-intro {
  display: none;
}

body.stories-mode.fun-games-focus .stories-top-tabs {
  margin-top: 12px;
  gap: 8px;
}

body.stories-mode.fun-games-focus .stories-nav-btn {
  padding-top: 10px;
  padding-bottom: 10px;
  font-size: 0.95rem;
}

body.stories-mode.fun-games-focus #stories-facts {
  padding: 12px;
}

body.stories-mode.fun-games-focus #stories-facts > .formula {
  margin: 0;
  padding: 8px 10px;
  font-size: 0.95rem;
}

.stories-top-tabs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  display: none;
}

.book-top-tabs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  display: none;
}

.stories-nav-btn {
  font-size: 0.95rem;
  min-height: 44px;
  white-space: nowrap;
}

.book-nav-btn {
  font-size: 0.95rem;
  min-height: 44px;
  white-space: nowrap;
}

.book-part-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 8px;
}

.book-part-btn {
  border: 1px solid rgba(114, 144, 178, 0.26);
  background: rgba(255, 255, 255, 0.76);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  box-shadow: 0 3px 7px rgba(24, 49, 82, 0.12);
}

.book-part-btn.is-active {
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border-color: rgba(233, 108, 111, 0.62);
  color: #fff;
}

.book-tone-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 8px;
}

.book-tone-btn {
  border: 1px solid rgba(114, 144, 178, 0.26);
  background: rgba(255, 255, 255, 0.76);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  box-shadow: 0 3px 7px rgba(24, 49, 82, 0.12);
}

.book-tone-btn.is-active {
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border-color: rgba(233, 108, 111, 0.62);
  color: #fff;
}

.book-lesson.book-tone-panel {
  display: none;
}

.book-lesson.book-tone-panel.is-active {
  display: grid;
}

.book-writing-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 8px;
}

.book-writing-btn {
  border: 1px solid rgba(114, 144, 178, 0.26);
  background: rgba(255, 255, 255, 0.76);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  box-shadow: 0 3px 7px rgba(24, 49, 82, 0.12);
}

.book-writing-btn.is-active {
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border-color: rgba(233, 108, 111, 0.62);
  color: #fff;
}

.book-lesson.book-writing-panel {
  display: none;
}

.book-lesson.book-writing-panel.is-active {
  display: grid;
}

.stories-subpanel {
  display: none;
  background: color-mix(in srgb, #fff 82%, var(--soft));
  border: 1px solid rgba(114, 144, 178, 0.16);
  border-radius: 12px;
  padding: 12px;
  animation: fade 200ms ease-out;
}

.book-subpanel {
  display: none;
  background: color-mix(in srgb, #fff 82%, var(--soft));
  border: 1px solid rgba(114, 144, 178, 0.16);
  border-radius: 12px;
  padding: 12px;
  animation: fade 200ms ease-out;
}

.book-lesson {
  display: grid;
  gap: 8px;
}

.book-lesson p {
  margin: 0;
  line-height: 1.5;
}

.book-lead {
  color: #8f2f20;
  font-size: 1.05rem;
}

.book-subtitle {
  margin-top: 4px;
  color: #325b8c;
  font-weight: 800;
}

.book-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #edf5ff;
  border: 1px solid #c7d8ee;
  color: #2a4d78;
  font-weight: 700;
}

.book-example {
  background: #fff7ea;
  border: 1px solid #f0d6a8;
  border-radius: 10px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.book-sheet-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.book-sheet-item {
  border: 1px solid rgba(114, 144, 178, 0.24);
  border-radius: 10px;
  background: #fffdf8;
  padding: 8px 9px;
  display: grid;
  gap: 2px;
}

.book-sheet-hanzi {
  font-family: "PingFang TC", "Hiragino Sans GB", serif;
  font-size: 1.5rem;
  line-height: 1.1;
  color: #26456a;
}

.book-sheet-jp {
  font-family: "Menlo", "Courier New", monospace;
  font-size: 0.78rem;
  color: #516a87;
}

.book-sheet-en {
  font-size: 0.82rem;
  color: #4f6075;
}

.book-sheet-groups {
  margin-top: 6px;
  display: grid;
  gap: 10px;
}

.book-sheet-group {
  border: 1px solid rgba(114, 144, 178, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
  padding: 9px 10px;
  display: grid;
  gap: 6px;
}

.book-sheet-group-title {
  margin: 0;
  font-size: 0.86rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #31547d;
}

.book-sheet-line {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.book-sheet-token {
  min-width: 0;
  max-width: none;
  border: 1px solid rgba(140, 163, 190, 0.28);
  border-radius: 9px;
  padding: 7px 7px;
  background: #fffefb;
  display: grid;
  gap: 1px;
  overflow: hidden;
}

.book-sheet-token strong {
  font-family: "PingFang TC", "Hiragino Sans GB", serif;
  font-size: clamp(1.44rem, 5.8vw, 1.86rem);
  line-height: 1.02;
  color: #26456a;
}

.book-sheet-token em {
  font-style: normal;
  font-family: "Menlo", "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.16;
  color: #4f6886;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-sheet-token small {
  font-size: 0.76rem;
  line-height: 1.16;
  color: #5a6779;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 560px) {
  .book-sheet-line {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.book-tone-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.book-tone-audio-btn {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0;
  border: 1px solid #fff4ec;
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 7px rgba(225, 80, 95, 0.24);
}

.book-quote {
  background: #f5f9ff;
  border-left: 3px solid #80a7df;
  border-radius: 8px;
  padding: 7px 10px;
  color: #304761;
}

.stories-subpanel.is-active {
  display: block;
}

.book-subpanel.is-active {
  display: block;
}

.story-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.story-day-head .formula {
  margin: 0;
}

.mini-story-select-wrap {
  margin-top: 6px;
  margin-bottom: 8px;
}

.mini-story-select {
  max-width: 100%;
  width: 100%;
  margin: 0;
}

#playStoryAudio {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
}

.story-lines {
  display: grid;
  gap: 10px;
}

.story-line-block {
  border: 1px solid rgba(110, 143, 181, 0.16);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.6);
}

.mini-story-line-block.is-speaking {
  border-bottom-color: rgba(110, 143, 181, 0.16);
  box-shadow: none;
}

#stories-dialogs .mini-story-line-block {
  overflow: hidden;
}

.mini-story-hanzi-chunk {
  display: inline;
  border-bottom: 3px solid transparent;
  border-radius: 6px;
  padding-bottom: 1px;
  transition: border-color 140ms ease, background 140ms ease;
}

.mini-story-hanzi-chunk.is-speaking {
  border-bottom-color: transparent;
  background: rgba(47, 126, 194, 0.06);
}

.mini-story-token {
  display: inline-block;
  border-bottom: 3px solid transparent;
  border-radius: 5px;
  transition: border-color 120ms ease, background 120ms ease;
}

.mini-story-token.is-speaking {
  border-bottom-color: #2f7ec2;
  background: rgba(47, 126, 194, 0.16);
}

#stories-dialogs .story-hanzi-line {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: clamp(1.6rem, 6.6vw, 2.36rem);
  line-height: 1.78;
}

#stories-dialogs .story-hanzi-line ruby {
  ruby-position: over;
  ruby-align: center;
  white-space: nowrap;
}

#stories-dialogs .story-hanzi-line rt {
  font-family: "Menlo", "Courier New", monospace;
  font-size: 0.39em;
  line-height: 1;
  color: #365173;
}

.story-hanzi-line {
  margin: 0 0 4px;
  line-height: 1.6;
}

.story-jyutping-line {
  margin: 0 0 4px;
}

.story-english-line {
  margin: 0 0 4px;
}

.story-literal-line {
  margin: 0;
}

.mini-game-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.mini-game-tab {
  border: 1px solid rgba(114, 144, 178, 0.3);
  background: rgba(255, 255, 255, 0.76);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 3px 7px rgba(24, 49, 82, 0.12);
}

.mini-game-tab.is-active {
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border-color: rgba(233, 108, 111, 0.62);
  color: #fff;
}

.mini-game-panel {
  display: none;
  margin-top: 10px;
  border: 1px solid rgba(114, 144, 178, 0.2);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.68);
}

.mini-game-panel.is-active {
  display: grid;
  gap: 9px;
}

#mini-game-match3 {
  gap: 6px;
}

.mini-game-head {
  display: grid;
  gap: 2px;
}

.mini-game-title {
  margin: 0;
  font-weight: 800;
  color: #2e4f75;
  font-size: clamp(1.08rem, 2.1vw, 1.24rem);
}

.mini-game-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: #5d728b;
}

.match3-compact-lead {
  margin: 0 0 2px;
  font-size: 0.8rem;
  color: #5d728b;
}

.match3-action-btn {
  border: 2px solid #f28e63;
  background: radial-gradient(circle at 50% 45%, #f7f9fc 0%, #eef2f7 68%, #ffe4d7 100%);
  color: #8f5440;
  box-shadow: inset 0 0 0 2px #f5f7fb, 0 4px 10px rgba(242, 142, 99, 0.24);
  font-weight: 700;
}

.match3-start-gate {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 240px;
  margin: 6px 0 8px;
}

.match3-start-hero {
  min-width: 210px;
  min-height: 64px;
  border: 2px solid #f28e63;
  border-radius: 16px;
  background: linear-gradient(155deg, #ff9b6f 0%, #ff7164 50%, #ff5b7f 100%);
  color: #fff;
  font-size: 1.14rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 18px rgba(225, 92, 86, 0.28);
}

.match3-rules-btn {
  border: 1px solid rgba(138, 165, 196, 0.42);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
  color: #476180;
  min-width: 110px;
  padding: 7px 10px;
  font-weight: 700;
}

.match3-end-summary {
  margin: 0;
  width: min(360px, 92%);
  border: 1px solid rgba(235, 117, 102, 0.42);
  border-radius: 14px;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.72) 0%, transparent 42%),
    linear-gradient(160deg, #fff8f4 0%, #ffe8de 54%, #ffd9d3 100%);
  color: #7f2d28;
  box-shadow: 0 10px 18px rgba(188, 86, 76, 0.2);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.match3-end-title {
  margin: 0;
  text-align: center;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  font-weight: 800;
}

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

.match3-end-stat {
  border: 1px solid rgba(236, 131, 123, 0.34);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
  padding: 7px 8px;
  display: grid;
  gap: 3px;
}

.match3-end-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b6058;
  font-weight: 800;
}

.match3-end-value {
  font-size: 1.18rem;
  line-height: 1.1;
  color: #8d2d26;
}

.match3-end-note {
  margin: 0;
  text-align: center;
  color: #944840;
  font-size: 0.84rem;
}

.match3-start-gate.is-summary .match3-start-hero,
.match3-start-gate.is-summary .match3-rules-btn {
  display: none;
}

.match3-start-gate.is-summary .match3-end-summary {
  display: block;
}

.match3-mini-stats {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.match3-stat-card {
  border: 1px solid rgba(126, 153, 187, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  padding: 5px 7px;
  display: grid;
  gap: 2px;
}

.match3-stat-card p {
  margin: 0;
  line-height: 1.2;
}

.match3-stat-score {
  grid-column: 1 / 3;
}

.match3-stat-penalty {
  grid-column: 3 / 5;
}

.match3-stat-idle {
  grid-column: 3 / 5;
}

.match3-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c7f96;
  font-weight: 800;
}

.match3-stat-value-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.match3-stat-value {
  font-size: 1.02rem;
  font-weight: 800;
  color: #274a70;
}

#match3Score {
  color: #1d8a4f;
  font-weight: 800;
}

.match3-costs {
  margin: 0;
  min-height: 0;
  font-size: 0.75rem;
}

.match3-actions {
  margin-top: 2px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.match3-actions .match3-action-btn {
  white-space: nowrap;
  flex: 0 0 auto;
  min-width: auto;
  padding: 7px 10px;
}

.match3-delta {
  margin: 0;
  min-height: 0;
  font-size: 0.78rem;
  font-weight: 800;
  color: #1d8a4f;
  opacity: 0;
  transform: translateY(0);
  pointer-events: none;
}

.match3-delta.is-penalty {
  color: #b62a2a;
}

.match3-delta.is-show {
  animation: match3DeltaPop 2s ease forwards;
}

.match3-live-word {
  margin: 0;
  opacity: 0;
  transform: translateY(-5px);
  pointer-events: none;
}

.match3-live-word.is-visible {
  opacity: 1;
  transform: translateY(0);
  animation: match3Flash 3.6s ease;
}

.match3-board-wrap {
  display: grid;
  margin-top: 6px;
  gap: 6px;
}

#mini-game-match3.is-standby .match3-mini-stats,
#mini-game-match3.is-standby #match3Actions,
#mini-game-match3.is-standby .match3-costs,
#mini-game-match3.is-standby .match3-live-word,
#mini-game-match3.is-standby .match3-board-wrap,
#mini-game-match3.is-standby #match3Status {
  display: none;
}

#mini-game-match3:not(.is-standby) .match3-start-gate {
  display: none;
}

.match3-quiz {
  border: 1px solid rgba(255, 127, 84, 0.45);
  background: linear-gradient(160deg, #fff9f2 0%, #ffe8d9 100%);
  border-radius: 10px;
  padding: 5px 7px 6px;
  display: grid;
  gap: 4px;
}

.match3-quiz-hanzi {
  margin: 0;
  text-align: center;
  font-family: "PingFang TC", "Hiragino Sans GB", serif;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
  color: #2f4a6f;
}

#match3QuizChoices {
  margin-top: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  grid-template-columns: none;
  flex-wrap: wrap;
}

#match3QuizChoices .choice {
  min-width: auto;
  padding: 5px 8px;
  font-size: 0.76rem;
  line-height: 1.2;
  border-radius: 8px;
  white-space: nowrap;
}

.match3-quiz-feedback {
  margin: 0;
  font-size: 0.72rem;
  color: #b33b2c;
  text-align: center;
  min-height: 0;
}

.match3-penalty {
  color: #b62a2a;
  font-weight: 800;
}

.match3-status.is-end {
  color: #c62828;
  font-weight: 800;
}

.match3-penalty.is-flash {
  animation: match3PenaltyFlash 420ms ease;
}

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

.match3-tile {
  min-width: auto;
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid rgba(118, 149, 184, 0.32);
  background: linear-gradient(180deg, #ffffff 0%, #edf4ff 100%);
  color: #23466d;
  font-family: "PingFang TC", "Hiragino Sans GB", serif;
  font-size: 1.32rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
  box-shadow: 0 3px 6px rgba(24, 49, 82, 0.14);
  padding: 0;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

body.platform-ios .match3-board {
  gap: 5px;
}

body.platform-ios .match3-tile {
  min-height: 44px;
  font-size: 1.18rem;
}

.match3-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 10px rgba(24, 49, 82, 0.2);
}

.match3-tile.is-selected {
  border-color: #ff7e4c;
  box-shadow: 0 0 0 2px rgba(255, 126, 76, 0.28);
  transform: translateY(-1px);
}

.match3-tile.is-clearing {
  border-color: #ff4d7f;
  background: linear-gradient(180deg, #fff1f6 0%, #ffd9e9 100%);
  color: #8f274b;
  animation: match3Clear 190ms ease-in forwards;
}

.match3-tile.is-hint {
  border-color: #1f9b8f;
  box-shadow: 0 0 0 2px rgba(31, 155, 143, 0.28), 0 6px 12px rgba(20, 117, 108, 0.26);
  animation: match3HintPulse 900ms ease-in-out infinite;
}

.match3-tile.is-swapping {
  transition: transform 190ms cubic-bezier(0.22, 0.61, 0.36, 1);
  transform: translate(var(--swap-x, 0px), var(--swap-y, 0px));
  z-index: 2;
}

.match3-tile.is-falling {
  animation: match3Fall 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

.mini-game-panel#mini-game-speed .actions {
  justify-content: center;
}

#speedStart {
  min-width: 210px;
  min-height: 54px;
  border: 2px solid #2e8f88;
  border-radius: 14px;
  background: linear-gradient(155deg, #2cb8a5 0%, #1f9fbe 56%, #2b77c7 100%);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 16px rgba(36, 121, 160, 0.28);
}

#speedStart:hover {
  opacity: 1;
  filter: brightness(1.04);
}

.mini-speed-choices .choice {
  text-align: center;
  font-size: 1.42rem;
  font-family: "PingFang TC", "Hiragino Sans GB", serif;
}

@keyframes match3Clear {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.6);
    opacity: 0.2;
  }
}

@keyframes match3Flash {
  0% {
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
  }
  16% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  82% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
  }
}

@keyframes match3HintPulse {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-1px) scale(1.03);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes match3PenaltyFlash {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.75;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes match3Fall {
  0% {
    transform: translateY(-10px);
    opacity: 0.82;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes match3DeltaPop {
  0% {
    opacity: 0;
    transform: translateY(2px);
  }
  15% {
    opacity: 1;
    transform: translateY(0);
  }
  78% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-4px);
  }
}

body.stories-mode .stories-top-tabs {
  display: grid;
}

body.book-mode .book-top-tabs {
  display: grid;
}

/* Legacy User drawer styles (kept intentionally for possible rollback). */
.side-panel {
  position: fixed;
  inset: 0;
  z-index: 45;
}

.side-panel-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(13, 25, 44, 0.38);
  opacity: 0;
  transition: opacity 200ms ease;
}

.side-panel-drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: min(360px, 92vw);
  height: 100%;
  background: linear-gradient(170deg, #ffe7d4 0%, #ffdccc 48%, #ffe8c9 100%);
  border-right: 1px solid rgba(201, 133, 103, 0.25);
  box-shadow: 10px 0 28px rgba(93, 51, 33, 0.22);
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  transform: translateX(-106%);
  transition: transform 220ms ease;
  overflow: auto;
}

.side-panel.is-open .side-panel-backdrop {
  opacity: 1;
}

.side-panel.is-open .side-panel-drawer {
  transform: translateX(0);
}

.side-panel.is-closing .side-panel-backdrop {
  opacity: 0;
}

.side-panel.is-closing .side-panel-drawer {
  transform: translateX(-106%);
}

.user-page-card {
  display: grid;
  gap: 10px;
}

.side-simple-list {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.side-profile-head {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.side-name-block {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(198, 121, 86, 0.24);
  border-radius: 11px;
  padding: 5px 8px;
  display: grid;
  gap: 2px;
}

.side-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.side-name-edit {
  margin-top: 2px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
}

.side-name-edit-btn {
  min-width: 46px;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d96f55;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 140ms ease, color 140ms ease, opacity 140ms ease;
}

.edit-pencil-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-name-edit-btn:hover {
  transform: scale(1.07);
  color: #c9573c;
}

.side-name-edit-btn:active {
  transform: scale(1);
  opacity: 0.85;
}

.side-name-inline-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(191, 105, 82, 0.34);
  background: rgba(255, 255, 255, 0.86);
  color: #b85c42;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 7px rgba(111, 56, 41, 0.12);
}

.side-name-inline-btn:hover {
  transform: translateY(-1px);
}

.side-name-inline-btn:active {
  transform: translateY(0);
}

.side-name-inline-cancel {
  color: #7b5567;
}

.side-avatar-circle {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid rgba(190, 114, 84, 0.45);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 230, 209, 0.88) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(138, 74, 58, 0.2);
}

.side-avatar-btn {
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.side-avatar-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(138, 74, 58, 0.24);
}

.side-avatar-btn:active {
  transform: translateY(0);
}

.side-avatar-glyph {
  font-size: 2.55rem;
  line-height: 1;
}

.side-avatar-image {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: block;
}

.side-avatar-help {
  display: none;
}

.side-kv {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(198, 121, 86, 0.24);
  border-radius: 11px;
  padding: 8px 9px;
  display: grid;
  gap: 4px;
}

.side-kv-spaced {
  margin-top: 8px;
}

.side-k {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8d563f;
  font-weight: 700;
}

.side-v {
  font-size: 1.02rem;
  color: #3b2b28;
  line-height: 1.25;
}

.side-select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(179, 111, 84, 0.34);
  background: rgba(255, 255, 255, 0.82);
  color: #3b2b28;
  padding: 8px 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

.side-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.side-inline .side-v {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.side-inline-single {
  grid-template-columns: 1fr;
}

.side-inline-single .side-inline-btn {
  justify-self: end;
}

.password-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.password-row .side-inline {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.password-row #changePasswordBtn.side-inline-btn {
  min-width: 88px;
  padding: 6px 10px;
}

#changeEmailBtn.side-inline-btn {
  min-width: 88px;
  padding: 6px 10px;
}

.password-row #userPasswordHint {
  display: none;
}

.side-auth-status {
  margin: 0;
  color: #6a3f2f;
  font-size: 0.86rem;
}

.side-auth-message {
  margin: 2px 0 0;
  min-height: 1.2em;
  color: #9a2f2f;
  font-size: 0.88rem;
  font-weight: 600;
}

.side-auth-form {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 360px;
}

.assistive-field {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.auth-mode-view {
  display: grid;
  gap: 6px;
}

.auth-mode-title {
  margin: 0;
  color: #5b3428;
  font-size: 1.06rem;
  font-weight: 800;
}

.auth-method-label {
  margin: 0;
  color: #8d563f;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.auth-login-help {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.auth-flow-cta {
  margin: 2px 0 0;
  text-align: center;
  color: #7a4c39;
  font-size: 0.84rem;
  font-weight: 600;
}

.auth-flow-cta-strong {
  margin-top: 16px;
  color: #a93f2f;
  font-size: 0.98rem;
  font-weight: 800;
}

.auth-or-sep {
  margin: 14px 0;
  width: 100%;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #89554a;
  position: relative;
}

.auth-or-sep::before,
.auth-or-sep::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 34%;
  height: 1px;
  background: rgba(142, 95, 76, 0.28);
}

.auth-or-sep::before {
  left: 0;
}

.auth-or-sep::after {
  right: 0;
}

.side-auth-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(179, 111, 84, 0.34);
  background: rgba(255, 255, 255, 0.86);
  color: #3b2b28;
  padding: 8px 10px;
  font-size: 0.94rem;
}

.side-auth-input.is-invalid {
  border-color: rgba(193, 41, 41, 0.7);
  background: #fff3f3;
  box-shadow: 0 0 0 2px rgba(193, 41, 41, 0.12);
}

.auth-input-error {
  margin: -1px 0 2px;
  min-height: 1.15em;
  color: #b42424;
  font-size: 0.82rem;
  font-weight: 700;
}

.side-auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.side-auth-hint {
  margin: 2px 0 0;
}

.auth-login-help .side-auth-hint {
  margin: 0;
}

.auth-login-help .auth-alt-btn.side-inline-btn {
  width: auto;
  justify-self: end;
}

.side-actions-stack {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.side-action-btn {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(199, 106, 82, 0.42);
  background: linear-gradient(160deg, #ff9b6e 0%, #ff7a76 50%, #ff6993 100%);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 700;
  padding: 10px 9px;
  box-shadow: 0 4px 10px rgba(167, 79, 77, 0.22);
}

.side-action-btn.side-action-soft {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(179, 111, 84, 0.3);
  color: #6a3f2f;
}

.side-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.side-inline-btn {
  width: auto;
  min-width: 116px;
  padding: 7px 10px;
  font-size: 0.85rem;
  border-radius: 10px;
  justify-self: end;
}

.auth-alt-btn.side-inline-btn {
  width: 100%;
}

.auth-switch-btn.side-inline-btn {
  border-style: dashed;
}

.auth-create-cta.side-inline-btn {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 10px;
  border-style: solid;
  border-width: 1px;
  border-color: #f28e63;
  background: rgba(255, 255, 255, 0.72);
  color: #6a3f2f;
  box-shadow: none;
}

.auth-google-btn {
  border-style: solid;
  border-width: 1px;
  border-color: #f28e63 !important;
  background: rgba(255, 255, 255, 0.72) !important;
  color: #6a3f2f !important;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.auth-confirm-note {
  margin: 0;
  text-align: center;
  color: #6a3f2f;
  font-size: 0.88rem;
  line-height: 1.42;
}

.auth-resend-timer {
  margin: 0;
  text-align: center;
  color: #8b5a49;
  font-size: 0.8rem;
  font-weight: 600;
}

.auth-confirm-email {
  margin: 0;
  text-align: center;
  color: #4f78a8;
  font-size: 0.9rem;
  font-weight: 800;
}

#authGateConfirmView {
  justify-items: center;
  gap: 4px;
}

#authGateConfirmView .side-auth-hint {
  text-align: center;
  margin-top: 0;
}

#authGateConfirmView .auth-confirm-email {
  margin-bottom: 2px;
}

#authGateConfirmView .auth-confirm-next-step {
  margin-top: -2px;
  margin-bottom: 1px;
}

.auth-captcha-wrap {
  display: grid;
  justify-content: center;
  margin: 2px 0 4px;
}

.google-g {
  display: inline-block;
  color: #4285f4;
  background: linear-gradient(90deg, #4285f4 0%, #34a853 35%, #fbbc05 67%, #ea4335 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  margin-right: 6px;
}

#authGateConfirmView .auth-confirm-back-btn {
  background: linear-gradient(160deg, #ef615f 0%, #df4c59 56%, #c73450 100%);
  border-color: rgba(176, 45, 66, 0.72);
  color: #fff;
  box-shadow: 0 8px 16px rgba(167, 44, 70, 0.26);
}

#upgradeAccountBtn.side-inline-btn {
  min-width: 92px;
}

.example.side-msg {
  margin-top: 8px;
  min-height: 18px;
  color: #7a4c39;
}

.avatar-picker-card {
  max-width: min(480px, 95vw);
}

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

.avatar-choice-btn {
  border: 1px solid rgba(179, 111, 84, 0.3);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
  color: #4a322d;
  padding: 8px 6px;
  display: grid;
  gap: 4px;
  justify-items: center;
  box-shadow: 0 2px 6px rgba(145, 84, 68, 0.14);
}

.avatar-choice-btn.is-selected {
  border-color: rgba(235, 101, 109, 0.64);
  background: linear-gradient(160deg, #ff9b6e 0%, #ff7a76 50%, #ff6993 100%);
  color: #fff;
}

.avatar-choice-image {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: block;
}

.avatar-choice-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

/* Additive top-tab depth skin (keeps original tab styles above intact). */
body.tabs-depth-v1 .tab {
  position: relative;
  border: 1px solid rgba(79, 105, 139, 0.28);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(233, 241, 253, 0.9) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(133, 159, 194, 0.25),
    0 4px 10px rgba(24, 49, 82, 0.16);
  transform: translateY(0);
  transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease;
}

body.tabs-depth-v1 .tab::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 6px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0));
  pointer-events: none;
}

body.tabs-depth-v1 .tab:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    inset 0 -1px 0 rgba(133, 159, 194, 0.3),
    0 6px 14px rgba(24, 49, 82, 0.2);
}

body.tabs-depth-v1 .tab:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(24, 49, 82, 0.2),
    0 2px 6px rgba(24, 49, 82, 0.14);
}

body.tabs-depth-v1 .tab.is-active {
  border-color: rgba(43, 73, 111, 0.42);
  background: linear-gradient(180deg, #35506a 0%, #2b4058 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 6px 14px rgba(18, 32, 52, 0.35);
}

body.tabs-depth-v1 .tab.is-active::before {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
}

body.tabs-depth-v1 .fun-tab {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 6px 14px rgba(189, 67, 108, 0.3);
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.card {
  margin-top: 14px;
  background: var(--soft);
  border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 24px);
  box-shadow: var(--shadow);
}

.controls-card {
  margin-top: 12px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.card-head h2 {
  margin: 0;
}

.ghost-btn {
  background: #365173;
}

.gear-btn {
  width: 30px;
  min-width: 30px;
  height: 26px;
  min-height: 26px;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: #355f7d;
  padding: 0;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.86;
}

.gear-lines,
.gear-lines::before,
.gear-lines::after {
  display: block;
  width: 20px;
  height: 2.1px;
  border-radius: 999px;
  background: #5d6d7e;
  content: "";
}

.gear-lines {
  position: relative;
}

.gear-lines::before {
  position: absolute;
  left: 0;
  top: -6.5px;
}

.gear-lines::after {
  position: absolute;
  left: 0;
  top: 6.5px;
}

.inactive-control {
  opacity: 0.5;
}

.inactive-control select,
.inactive-control input {
  pointer-events: none;
}

.controls-card.is-collapsed .actions,
.controls-card.is-collapsed #controlsMessage {
  display: none;
}

#toggleControlsCard {
  min-width: auto;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #365173;
  line-height: 1;
  padding: 3px 4px;
}

#toggleControlsCard .controls-chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
  display: inline-block;
  transition: transform 150ms ease;
}

#toggleControlsCard.is-collapsed .controls-chevron {
  transform: rotate(-45deg);
}

.inline-pair {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.controls-grid {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 720px;
  opacity: 1;
  transform: translateY(0);
  transform-origin: top;
  overflow: hidden;
  transition: max-height 250ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 250ms cubic-bezier(0.22, 0.61, 0.36, 1), transform 250ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.controls-card.is-collapsed .controls-grid {
  max-height: 0;
  opacity: 0;
  transform: translateY(-9px);
  pointer-events: none;
}

.controls-card > .actions {
  display: none;
}

.controls-grid label {
  font-size: 1.03rem;
}

.controls-grid select,
.controls-grid input {
  font-size: 1.02rem;
}

.controls-divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.controls-divider::before,
.controls-divider::after {
  content: "";
  height: 1px;
  background: rgba(54, 81, 115, 0.35);
  flex: 1;
}

.chip {
  margin: 0;
  background: #dff8f4;
  color: #096457;
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: capitalize;
}

.hanzi {
  font-family: "PingFang TC", "Hiragino Sans GB", serif;
  font-size: clamp(2rem, 7vw, 3rem);
  margin: 10px 0 2px;
}

#panel-words #wordHanzi {
  text-align: center;
}

#panel-words #wordJyutping,
#panel-words #wordEnglish {
  text-align: center;
}

.hanzi.pattern-ruby {
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hanzi.pattern-ruby ruby {
  ruby-position: over;
  ruby-align: center;
}

.hanzi.pattern-ruby rt {
  font-family: "Menlo", "Courier New", monospace;
  font-size: 0.43em;
  line-height: 1;
  color: #365173;
  letter-spacing: 0.01em;
}

.jyutping {
  font-family: "Menlo", "Courier New", monospace;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.english {
  margin: 6px 0 0;
  font-size: 1.1rem;
}

.compare-lines {
  white-space: pre-line;
}

.compare-prefix {
  display: inline-block;
  min-width: 1.8em;
  font-weight: 800;
  color: #4f5f78;
}

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

button,
.file-btn {
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Prevent Android WebView tap-highlight and default focus flash on touch controls. */
button,
.file-btn,
.tab,
.bottom-nav-btn {
  -webkit-tap-highlight-color: transparent;
}

button:focus,
.file-btn:focus,
.tab:focus,
.bottom-nav-btn:focus {
  outline: none;
}

/* iOS WKWebView can drop some Unicode glyphs in the default UI font stack.
   Keep CJK/symbol/emoji fallbacks separated by glyph type. */
#toggleWordJyutping,
#togglePatternJyutping,
#toggleQuizJyutping,
#toggleToneJyutping,
#toggleQuestionJyutping,
#toggleMiniStoryJyutping,
#toggleGrammarLens,
#toggleQuizGrammarLens,
#toggleQuestionGrammarLens,
#toggleMiniStoryLens {
  font-family:
    "PingFang TC",
    "Hiragino Sans",
    "Heiti TC",
    "Apple Symbols",
    "Arial Unicode MS",
    sans-serif;
}

#closeSettings,
#closeAuthGate,
#closeResetPassword,
#closeGrammarModal,
#closeInfoModal,
#closeAvatarPicker,
#editUserNameBtn,
#cancelUserNameBtn,
#cancelUserEmailBtn {
  font-family:
    -apple-system,
    "SF Pro Text",
    "Apple Symbols",
    "Arial Unicode MS",
    sans-serif;
}

.side-avatar-glyph,
.avatar-choice-glyph {
  font-family:
    "Apple Color Emoji",
    "Segoe UI Emoji",
    "Noto Color Emoji",
    sans-serif;
}

body[data-theme="neon-extreme"] .tab.is-active,
body[data-theme="neon-extreme"] button,
body[data-theme="neon-extreme"] .file-btn {
  box-shadow: 0 0 14px rgba(255, 60, 140, 0.45), 0 0 20px rgba(0, 220, 200, 0.22);
}

body[data-theme="neon-extreme"] .card {
  border: 1px solid rgba(255, 96, 163, 0.45);
  box-shadow: 0 0 22px rgba(255, 61, 156, 0.25), 0 0 28px rgba(0, 224, 210, 0.18);
}

button:hover,
.file-btn:hover {
  opacity: 0.92;
}

#markKnown {
  background: var(--accent-2);
}

#nextWord,
#nextQuiz,
#newPattern,
#nextTone,
#nextQuestion {
  background: var(--accent);
}

#toggleWordJyutping,
#toggleWordEnglish {
  background: #365173;
}

#panel-words .panel-actions,
#panel-patterns .pattern-actions,
#panel-listening .panel-actions,
#panel-questions .panel-actions,
#panel-tones .panel-actions,
#panel-exercises .panel-actions,
#panel-stories #stories-dialogs .panel-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  overflow-x: auto;
  /* Horizontal scroll containers clip visual overflow; keep vertical headroom for play halos/rings. */
  padding: 12px 0 8px;
}

#panel-words .pattern-control-col,
#panel-patterns .pattern-control-col,
#panel-listening .pattern-control-col,
#panel-questions .pattern-control-col,
#panel-tones .pattern-control-col,
#panel-exercises .pattern-control-col,
#panel-stories #stories-dialogs .pattern-control-col {
  display: grid;
  grid-template-rows: 78px 16px;
  align-items: center;
  justify-items: center;
  row-gap: 5px;
  min-width: 56px;
}

#panel-words .pattern-control-text,
#panel-patterns .pattern-control-text,
#panel-listening .pattern-control-text,
#panel-questions .pattern-control-text,
#panel-tones .pattern-control-text,
#panel-exercises .pattern-control-text,
#panel-stories #stories-dialogs .pattern-control-text {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 600;
  color: #3f5167;
  text-align: center;
  white-space: nowrap;
}

#panel-words .pattern-mini-btn,
#panel-patterns .pattern-mini-btn,
#panel-listening .pattern-mini-btn,
#panel-questions .pattern-mini-btn,
#panel-tones .pattern-mini-btn,
#panel-exercises .pattern-mini-btn,
#panel-stories #stories-dialogs .pattern-mini-btn {
  width: 46px;
  min-width: 46px;
  height: 46px;
  min-height: 46px;
  border-radius: 999px;
  border: 2px solid #d8dfe9;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58), 0 4px 10px rgba(42, 53, 73, 0.22);
  color: #35506a;
  background: linear-gradient(180deg, #f8f9fb 0%, #e9edf3 100%);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
}

#panel-patterns #toggleGrammarLens.pattern-mini-btn,
#panel-listening #toggleQuizGrammarLens.pattern-mini-btn,
#panel-questions #toggleQuestionGrammarLens.pattern-mini-btn,
#stories-dialogs #toggleMiniStoryLens.pattern-mini-btn {
  font-size: 1.22rem;
}

#panel-patterns #toggleGrammarLens.pattern-mini-btn.is-on,
#panel-listening #toggleQuizGrammarLens.pattern-mini-btn.is-on,
#panel-questions #toggleQuestionGrammarLens.pattern-mini-btn.is-on,
#stories-dialogs #toggleMiniStoryLens.pattern-mini-btn.is-on {
  color: #fff;
  background: linear-gradient(160deg, #ffba34 0%, #ff8e36 50%, #ff6d58 100%);
  border-color: #f0823f;
}

#panel-patterns #togglePatternJyutping.pattern-mini-btn.is-on {
  color: #fff;
  background: linear-gradient(160deg, #16d5b8 0%, #19b8db 48%, #3289ff 100%);
  border-color: #2f9bd1;
}

#panel-words #toggleWordJyutping.pattern-mini-btn.is-on,
#panel-listening #toggleQuizJyutping.pattern-mini-btn.is-on,
#panel-questions #toggleQuestionJyutping.pattern-mini-btn.is-on,
#panel-tones #toggleToneJyutping.pattern-mini-btn.is-on,
#stories-dialogs #toggleMiniStoryJyutping.pattern-mini-btn.is-on {
  color: #fff;
  background: linear-gradient(160deg, #16d5b8 0%, #19b8db 48%, #3289ff 100%);
  border-color: #2f9bd1;
}

#panel-patterns #togglePatternEnglish.pattern-mini-btn.is-on {
  color: #fff;
  background: linear-gradient(160deg, #6ea7ff 0%, #5d90ff 55%, #6d6be8 100%);
  border-color: #6b7ed8;
}

#panel-words #toggleWordEnglish.pattern-mini-btn.is-on,
#panel-listening #toggleQuizEnglish.pattern-mini-btn.is-on,
#panel-questions #toggleQuestionEnglish.pattern-mini-btn.is-on,
#panel-tones #toggleToneEnglish.pattern-mini-btn.is-on,
#stories-dialogs #toggleMiniStoryEnglish.pattern-mini-btn.is-on {
  color: #fff;
  background: linear-gradient(160deg, #6ea7ff 0%, #5d90ff 55%, #6d6be8 100%);
  border-color: #6b7ed8;
}

#panel-listening #showQuizText.pattern-mini-btn.is-on {
  color: #fff;
  background: linear-gradient(160deg, #7ac66f 0%, #42b889 52%, #1ba4a4 100%);
  border-color: #3aa291;
}

#panel-words .pattern-mini-btn.is-off,
#panel-patterns .pattern-mini-btn.is-off,
#panel-listening .pattern-mini-btn.is-off,
#panel-questions .pattern-mini-btn.is-off,
#panel-tones .pattern-mini-btn.is-off,
#panel-exercises .pattern-mini-btn.is-off,
#panel-stories #stories-dialogs .pattern-mini-btn.is-off {
  color: #4f6075;
  background: linear-gradient(180deg, #f8f9fb 0%, #e9edf3 100%);
  border-color: #d2dbe7;
}

#panel-words .pattern-next-btn,
#panel-patterns .pattern-next-btn,
#panel-listening .pattern-next-btn,
#panel-questions .pattern-next-btn,
#panel-tones .pattern-next-btn,
#panel-exercises .pattern-next-btn {
  width: 46px;
  min-width: 46px;
  height: 46px;
  min-height: 46px;
  border-radius: 999px;
  border: 2px solid #f28e63;
  background: radial-gradient(circle at 50% 45%, #f7f9fc 0%, #eef2f7 68%, #ffe4d7 100%);
  color: #8f5440;
  box-shadow: inset 0 0 0 2px #f5f7fb, 0 4px 10px rgba(242, 142, 99, 0.24);
  font-size: 1.28rem;
  line-height: 1;
  font-weight: 700;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#panel-words #playWordAudio.pattern-play-main,
#panel-patterns #playPatternAudio.pattern-play-main,
#panel-listening #playQuizAudio.pattern-play-main,
#panel-questions #playQuestionAudio.pattern-play-main,
#panel-exercises #playExerciseAudio.pattern-play-main,
#stories-dialogs #playMiniStoryAudio.pattern-play-main {
  width: 78px;
  min-width: 78px;
  height: 78px;
  min-height: 78px;
  border-radius: 999px;
  font-size: 1.75rem;
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border: 3px solid #fff8f4;
  box-shadow: 0 8px 22px rgba(225, 80, 95, 0.35);
}

.play-icon-btn,
.book-tone-audio-btn,
#funStreetPlayAll {
  position: relative;
  overflow: visible;
  isolation: isolate;
  transition: transform 180ms cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 180ms ease, filter 180ms ease;
}

.play-icon-btn::before,
.play-icon-btn::after,
.book-tone-audio-btn::before,
.book-tone-audio-btn::after,
#funStreetPlayAll::before,
#funStreetPlayAll::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
}

.play-icon-btn::before,
.book-tone-audio-btn::before,
#funStreetPlayAll::before {
  z-index: -1;
  background:
    conic-gradient(
      from 120deg,
      rgba(22, 215, 177, 0),
      rgba(22, 215, 177, 0.42),
      rgba(91, 211, 255, 0.5),
      rgba(22, 215, 177, 0)
    );
  filter: blur(0.5px);
}

.play-icon-btn::after,
.book-tone-audio-btn::after,
#funStreetPlayAll::after {
  border: 2px solid rgba(110, 231, 212, 0.65);
}

.play-icon-btn.is-audio-burst,
.book-tone-audio-btn.is-audio-burst,
#funStreetPlayAll.is-audio-burst {
  animation: listening-play-burst 620ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.play-icon-btn.is-audio-burst::after,
.book-tone-audio-btn.is-audio-burst::after,
#funStreetPlayAll.is-audio-burst::after {
  animation: listening-play-ring 760ms ease-out;
}

.play-icon-btn.is-audio-playing,
.book-tone-audio-btn.is-audio-playing,
#funStreetPlayAll.is-audio-playing {
  animation: listening-play-float 1150ms ease-in-out infinite;
  box-shadow: 0 10px 24px rgba(22, 180, 167, 0.34), 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.play-icon-btn.is-audio-playing::before,
.book-tone-audio-btn.is-audio-playing::before,
#funStreetPlayAll.is-audio-playing::before {
  opacity: 0.95;
  animation: listening-play-orbit 1200ms linear infinite;
}

.mini-story-quick-toggle {
  position: fixed;
  right: 14px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 38;
  width: 58px;
  min-width: 58px;
  height: 58px;
  min-height: 58px;
  border-radius: 999px;
  font-size: 1.3rem;
  border: 3px solid #fff8f4;
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(225, 80, 95, 0.34);
}

.mini-story-audio-btn {
  color: #fff;
}

.mini-story-audio-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  position: relative;
}

.mini-story-audio-btn[data-audio-state="play"] .mini-story-audio-icon {
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 15px solid currentColor;
  margin-left: 3px;
}

.mini-story-audio-btn[data-audio-state="pause"] .mini-story-audio-icon::before,
.mini-story-audio-btn[data-audio-state="pause"] .mini-story-audio-icon::after {
  content: "";
  position: absolute;
  top: 0;
  width: 5px;
  height: 18px;
  border-radius: 2px;
  background: currentColor;
}

.mini-story-audio-btn[data-audio-state="pause"] .mini-story-audio-icon::before {
  left: 2px;
}

.mini-story-audio-btn[data-audio-state="pause"] .mini-story-audio-icon::after {
  right: 2px;
}

body.bottom-nav-enabled .mini-story-quick-toggle {
  bottom: calc(86px + env(safe-area-inset-bottom));
}

#stories-dialogs #miniStoryLines.is-tap-start-enabled .story-hanzi-line {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#stories-dialogs #miniStoryLines.is-tap-start-enabled .mini-story-token {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#stories-dialogs #miniStoryLines.is-tap-start-enabled .mini-story-token:active {
  border-bottom-color: #2f7ec2;
  background: rgba(47, 126, 194, 0.16);
}

#panel-tones .tone-play-btn {
  width: 56px;
  min-width: 56px;
  height: 56px;
  min-height: 56px;
  border-radius: 999px;
  font-size: 1.4rem;
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  border: 3px solid #fff8f4;
  box-shadow: 0 6px 16px rgba(225, 80, 95, 0.31);
}

#panel-exercises #checkExercise.pattern-mini-btn.is-on {
  color: #fff;
  background: linear-gradient(160deg, #19b67b 0%, #0fa97b 50%, #168cb2 100%);
  border-color: #1f9e88;
}

#panel-exercises #clearExercise.pattern-mini-btn {
  font-size: 1.08rem;
}

.exercise-bank,
.exercise-selected {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#exerciseBuilt {
  text-align: center;
}

.exercise-chip {
  border: 1px solid #c8d6ea;
  border-radius: 10px;
  background: #ffffff;
  color: #2a3f58;
  padding: 8px 11px;
  font-size: 1.06rem;
  font-weight: 650;
  line-height: 1.15;
  font-family: "PingFang TC", "Hiragino Sans", "Heiti TC", sans-serif;
  box-shadow: 0 2px 6px rgba(34, 54, 80, 0.09);
}

.exercise-chip:hover {
  transform: translateY(-1px);
}

.exercise-chip.selected {
  background: #eaf6ff;
  border-color: #8fb7dd;
}

#panel-words #markKnown.pattern-mini-btn {
  color: #fff;
  background: linear-gradient(160deg, #19b67b 0%, #0fa97b 50%, #168cb2 100%);
  border: 2px solid #1f9e88;
  box-shadow: 0 6px 14px rgba(15, 153, 123, 0.27);
  font-size: 1.15rem;
}

#panel-words #markKnown.pattern-mini-btn.is-known {
  background: linear-gradient(160deg, #59d194 0%, #35bf7e 56%, #269d68 100%);
  border-color: #2da775;
  box-shadow: 0 6px 14px rgba(41, 159, 108, 0.29);
}

#panel-words #markKnown.pattern-mini-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#panel-words .word-example-actions {
  justify-content: flex-start;
  margin-top: 14px;
}

#revealExample {
  min-width: auto;
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid #ef8d66;
  color: #fff;
  background: linear-gradient(160deg, #ff9968 0%, #ff7474 52%, #ff5c86 100%);
  box-shadow: 0 5px 12px rgba(228, 94, 98, 0.28);
  font-size: 0.88rem;
  font-weight: 700;
}

#revealExample:hover {
  opacity: 1;
  filter: brightness(1.04);
}

#playWordAudio,
#playPatternAudio,
#playQuizAudio,
#playQuestionAudio,
#playToneA,
#playToneB,
#playToneRandom,
#testVoice,
#bossPlayAudio {
  background: linear-gradient(135deg, #0fa97b, #1493b8);
}

.play-icon-btn {
  width: 46px;
  min-width: 46px;
  height: 46px;
  min-height: 46px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 800;
  border: 2px solid #fff8f4;
  background: linear-gradient(160deg, #ff8f63 0%, #ff646f 48%, #ff4f85 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(225, 80, 95, 0.29);
}

.play-tone-btn {
  position: relative;
}

.play-tone-btn::after {
  content: attr(data-tone-label);
  position: absolute;
  right: -4px;
  bottom: -6px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  color: #365173;
  border: 1px solid #b7cadf;
  font-size: 0.67rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

#applyControls {
  background: #0f9d8b;
}

#applyControls,
#controlsMessage {
  display: none !important;
}

.literal {
  margin: 8px 0 0;
  color: #2f5b7a;
  font-style: italic;
  font-size: 0.95rem;
}

.grammar-notes {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.grammar-note {
  background: #edf8ff;
  border-left: 4px solid #4f8fc5;
  border-radius: 8px;
  padding: 7px 9px;
  color: #26435b;
  font-size: 0.88rem;
}

.tok {
  display: inline-block;
  margin-right: 4px;
  margin-bottom: 4px;
  padding: 0 4px;
  border-radius: 6px;
}

.tok-gloss {
  font-size: 0.93rem;
  font-style: normal;
  border: 0;
  text-decoration: none !important;
}

.tok-map-0 { background: #fff2f2; }
.tok-map-1 { background: #fff6e8; }
.tok-map-2 { background: #f4ffe8; }
.tok-map-3 { background: #e8fff8; }
.tok-map-4 { background: #e9f4ff; }
.tok-map-5 { background: #eff0ff; }
.tok-map-6 { background: #f8ecff; }
.tok-map-7 { background: #ffeefa; }

.tok-verb {
  border: 2px solid #0f9d8b;
  background: #e9fbf8;
}

.tok-past {
  border: 2px solid #ff6b35;
  background: #fff1ea;
}

.tok-prog {
  border: 2px solid #2f7ec2;
  background: #ebf4fd;
}

.tok-future {
  border: 2px solid #d09821;
  background: #fff6e2;
}

.tok-jp.tok-verb {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
  text-decoration-color: #0f9d8b;
}

.tok-jp.tok-past {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
  text-decoration-color: #ff6b35;
}

.tok-jp.tok-prog {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
  text-decoration-color: #2f7ec2;
}

.tok-jp.tok-future {
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
  text-decoration-color: #d09821;
}

.tok-clickable {
  cursor: pointer;
}

.tok-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(11, 31, 59, 0.14);
}

.example {
  min-height: 26px;
  margin-bottom: 0;
  color: var(--muted);
}

#controlsMessage.pending {
  color: #c62828;
  font-weight: 800;
}

#controlsMessage.applied {
  color: #1b7f4c;
  font-weight: 700;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 600;
}

.mission-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.mission-grid p {
  margin: 0;
  background: #edf3ff;
  border-radius: 10px;
  padding: 7px 9px;
}

.goal-line {
  margin: 10px 0 0;
  color: #b45a1a;
  font-weight: 700;
  font-size: 0.95rem;
}

.boss-wrap {
  margin-top: 10px;
  border: 2px solid #d6e4ff;
  border-radius: 12px;
  padding: 10px;
  background: #f6f9ff;
}

.fun-tab {
  background: linear-gradient(135deg, #ff8a00, #ff3d7f);
  color: #fff;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 11, 28, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.modal-card {
  width: min(720px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 18px;
  background: linear-gradient(165deg, #ffd9c8 0%, #ffcfe1 46%, #ffe3b8 100%);
  border: 2px solid #ffbf9a;
  box-shadow: var(--shadow);
  padding: 16px;
  opacity: 0;
  transform: translateY(18px) scale(0.972);
  transition: transform 280ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 280ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal.is-open .modal-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.modal.is-closing {
  opacity: 0;
  pointer-events: none;
}

.modal.is-closing .modal-card {
  opacity: 0;
  transform: translateY(14px) scale(0.972);
}

#settingsModal .modal-card {
  background: linear-gradient(170deg, #ffe7d4 0%, #ffdccc 48%, #ffe8c9 100%);
  border: 1px solid rgba(200, 133, 102, 0.36);
}

#settingsModal .card-head h2 {
  color: #7c3b1f;
}

#closeSettings {
  min-width: auto;
  padding: 0 2px;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #5b6778;
  font-size: 2.9rem;
  line-height: 1;
}

#closeSettings:hover {
  color: #3f4a58;
  transform: scale(1.04);
}

#settingsModal .slot-grid {
  gap: 10px;
}

#settingsModal .settings-noise-test-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

#settingsModal .settings-noise-level {
  min-width: 0;
}

#settingsModal .slot-grid label {
  color: #8d563f;
}

#settingsModal .slot-grid select,
#settingsModal .slot-grid input[type="range"] {
  border: 1px solid rgba(179, 111, 84, 0.34);
  background: rgba(255, 255, 255, 0.8);
}

#settingsModal .actions {
  margin-top: 10px;
}

#settingsModal .settings-note {
  margin-top: 6px;
}

#settingsModal .play-icon-btn {
  width: 50px;
  min-width: 50px;
  height: 50px;
  min-height: 50px;
}

#analyticsConsentModal .modal-card {
  width: min(760px, 92vw);
  background:
    radial-gradient(circle at 8% 16%, rgba(168, 245, 224, 0.44) 0, rgba(168, 245, 224, 0) 34%),
    radial-gradient(circle at 92% 8%, rgba(146, 209, 255, 0.42) 0, rgba(146, 209, 255, 0) 36%),
    linear-gradient(165deg, #f8fefd 0%, #eef9ff 56%, #f8fefc 100%);
  border: 1px solid rgba(94, 156, 172, 0.28);
  box-shadow: 0 24px 56px rgba(11, 31, 59, 0.18);
  color: #123241;
}

#analyticsConsentModal {
  z-index: 90;
  background: rgba(5, 16, 31, 0.82);
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

#analyticsConsentModal .analytics-consent-card {
  width: 100vw;
  max-width: none;
  min-height: 100dvh;
  border-radius: 0;
  border: 0;
  padding: clamp(30px, 6vh, 64px) clamp(18px, 5vw, 64px) clamp(24px, 4vh, 40px);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

#analyticsConsentModal .analytics-consent-eyebrow {
  margin: 0;
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #2e7f8f;
  font-weight: 700;
}

#analyticsConsentModal .analytics-consent-head {
  margin-bottom: 0;
}

#analyticsConsentModal .analytics-consent-head h2 {
  margin: 0;
  color: #103042;
  font-size: clamp(1.65rem, 4.6vw, 2.4rem);
}

#analyticsConsentModal .analytics-consent-lead {
  margin: 0;
  max-width: 820px;
  color: #35586b;
  font-size: clamp(1.02rem, 2.1vw, 1.15rem);
  line-height: 1.48;
}

#analyticsConsentModal .analytics-consent-grid {
  width: min(980px, 100%);
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

#analyticsConsentModal .analytics-consent-item {
  border: 1px solid rgba(96, 156, 172, 0.24);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  padding: 12px;
  text-align: left;
}

#analyticsConsentModal .analytics-consent-item h3 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  color: #17576e;
}

#analyticsConsentModal .analytics-consent-item p {
  margin: 0;
  font-size: 0.88rem;
  color: #35586b;
  line-height: 1.42;
}

#analyticsConsentModal .actions {
  margin-top: 8px;
}

#analyticsConsentModal .analytics-consent-actions {
  width: min(540px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

#analyticsConsentModal .analytics-consent-accept {
  border: 1px solid rgba(13, 135, 156, 0.82);
  background: linear-gradient(160deg, #32d2be 0%, #16b6d4 52%, #0d88b9 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 14px 24px rgba(18, 130, 154, 0.3);
}

#analyticsConsentModal .analytics-consent-accept:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 28px rgba(18, 130, 154, 0.36);
}

#analyticsConsentModal #declineAnalyticsBtn {
  border-color: rgba(104, 146, 160, 0.42);
  color: #35586b;
  background: rgba(255, 255, 255, 0.86);
}

#analyticsConsentModal .analytics-consent-footnote {
  margin: 2px 0 0;
  color: #537083;
  font-size: 0.8rem;
}

@media (max-width: 840px) {
  #analyticsConsentModal .analytics-consent-grid {
    grid-template-columns: 1fr;
  }
  #analyticsConsentModal .analytics-consent-card {
    align-content: start;
    padding-top: 34px;
    gap: 12px;
  }
  #analyticsConsentModal .analytics-consent-item {
    padding: 11px;
  }
}

#authGateModal {
  z-index: 88;
  background: #fff3ea;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

body.auth-gate-open .bottom-nav {
  display: none !important;
}

body.auth-gate-open .app-shell > *:not(#authGateModal) {
  opacity: 0;
  pointer-events: none;
}

body.reset-password-open .bottom-nav {
  display: none !important;
}

#authGateModal .modal-card {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  background: linear-gradient(180deg, #fff4ec 0%, #fff8f2 100%);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 74px 16px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

#resetPasswordModal {
  z-index: 92;
  background: #fff3ea;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

#resetPasswordModal .modal-card {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: 100dvh;
  background: linear-gradient(180deg, #fff4ec 0%, #fff8f2 100%);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 74px 16px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

#resetPasswordModal .auth-gate-brand,
#resetPasswordModal .card-head,
#resetPasswordModal .auth-gate-lead,
#resetPasswordModal .auth-gate-form {
  width: min(350px, 88vw);
  margin-left: auto;
  margin-right: auto;
}

.reset-rule-list {
  margin: 2px 0 2px;
  padding-left: 18px;
  display: grid;
  gap: 3px;
}

.reset-rule-item {
  font-size: 0.82rem;
  font-weight: 700;
}

.reset-rule-item.is-missing {
  color: #d5122d;
}

.reset-rule-item.is-ok {
  color: #2f8f50;
}

#resetPasswordMessage {
  color: #d5122d;
  font-size: 0.9rem;
  font-weight: 800;
  min-height: 1.3em;
}

.auth-gate-brand {
  display: grid;
  place-items: center;
  margin-bottom: 0;
}

#authGateLogo {
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 10px 20px rgba(90, 79, 70, 0.18));
}

#resetPasswordModal .auth-gate-brand img {
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 10px 20px rgba(90, 79, 70, 0.18));
}

.auth-gate-card .card-head {
  margin-bottom: 0;
  justify-content: center;
}

.auth-gate-card .card-head h2 {
  font-size: 1.42rem;
  color: #4b2f2a;
}

#closeAuthGate,
#closeResetPassword {
  min-width: auto;
  border: 0;
  background: transparent;
  color: #7d5a4e;
  box-shadow: none;
  font-size: 2rem;
  line-height: 1;
  padding: 0 4px;
}

#closeAuthGate:hover,
#closeResetPassword:hover {
  color: #5e433b;
  transform: scale(1.04);
}

#closeAuthGate:focus,
#closeAuthGate:focus-visible,
#closeResetPassword:focus,
#closeResetPassword:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Temporarily hide the login close "x" while keeping the tap target active. */
#closeAuthGate,
#closeAuthGate:hover,
#closeAuthGate:focus,
#closeAuthGate:focus-visible {
  color: transparent;
}

.auth-gate-lead {
  margin: 0 0 10px;
  text-align: center;
  color: #684740;
}

.auth-gate-form {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(188, 121, 92, 0.2);
  border-radius: 14px;
  padding: 10px;
}

#authGateModal .auth-gate-brand,
#authGateModal .card-head,
#authGateModal .auth-gate-lead,
#authGateModal .auth-mode-title,
#authGateModal .auth-method-label,
#authGateModal #authGateStatus,
#authGateModal #authGateMessage,
#authGateModal .auth-gate-form,
#authGateModal #authGateSignedIn {
  width: min(350px, 88vw);
  margin-left: auto;
  margin-right: auto;
}

#authGateModal .side-auth-actions {
  grid-template-columns: 1fr 1fr;
}

#authGateModal .side-auth-input {
  border-color: rgba(160, 111, 83, 0.3);
  background: #fff;
}

#authGateModal .side-auth-hint {
  font-size: 0.78rem;
  line-height: 1.35;
}

.auth-gate-version {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: #8a5c50;
  font-weight: 700;
}

#authForgotBtn,
#authGateForgotBtn {
  width: auto;
  justify-self: end;
  min-width: 0;
  padding: 6px 10px;
  font-size: 0.8rem;
}

#authGateStatus,
#authGateMessage {
  text-align: center;
}

#authGateStatus {
  order: 70;
  margin-top: 8px;
}

#authGateMessage {
  order: 71;
}

#authGateVersion {
  order: 72;
}

#authGateSignedIn {
  margin-top: 8px;
}

@media (max-width: 680px) {
  #settingsModal .settings-noise-test-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  #settingsModal .settings-noise-test-row .play-icon-btn {
    justify-self: end;
  }
}

.grammar-modal-card {
  width: min(640px, 96vw);
  background: #fffaf4;
  border: 2px solid #f0d6bf;
}

.grammar-modal-card .card-head h2 {
  color: #7c3b1f;
}

.grammar-modal-body {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  color: #263750;
}

.grammar-modal-body p {
  margin: 0;
  line-height: 1.45;
}

.info-modal-card {
  width: min(620px, 94vw);
  background: linear-gradient(170deg, #ffe7d4 0%, #ffdccc 48%, #ffe8c9 100%);
  border: 1px solid rgba(200, 133, 102, 0.36);
}

.grammar-hero {
  display: flex;
  align-items: baseline;
  gap: 12px;
  background: #fff;
  border: 1px solid #f0d9c4;
  border-radius: 12px;
  padding: 8px 10px;
}

.grammar-hero-hanzi {
  font-family: "PingFang TC", "Hiragino Sans GB", serif;
  font-size: clamp(2.7rem, 8.8vw, 4.1rem);
  line-height: 1;
  color: #d4471d;
}

.grammar-hero-jyutping {
  font-family: "Menlo", "Courier New", monospace;
  color: #1f5eaa;
  font-size: 1.02rem;
}

.grammar-row {
  background: #fff;
  border: 1px solid #f0dcc9;
  border-radius: 10px;
  padding: 7px 9px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.grammar-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a25a2d;
  font-weight: 800;
  min-width: 74px;
  line-height: 1.25;
}

.grammar-row p {
  display: inline;
  margin: 0;
  line-height: 1.35;
  flex: 1;
}

.grammar-inline-jp {
  font-family: "Menlo", "Courier New", monospace;
  color: #5e6e88;
  margin-left: 6px;
}

#closeGrammarModal {
  min-width: auto;
  padding: 0 2px;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #cf5a2c;
  font-size: 2.8rem;
  line-height: 1;
}

#closeGrammarModal:hover {
  color: #b3471b;
  transform: scale(1.04);
}

#closeSettings,
#closeGrammarModal,
#closeUserPanel,
#closeInfoModal,
#closeAvatarPicker {
  min-width: auto;
  padding: 0 2px;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #c85f33;
  font-size: 2.85rem;
  line-height: 1;
}

#closeSettings:hover,
#closeGrammarModal:hover,
#closeUserPanel:hover,
#closeInfoModal:hover,
#closeAvatarPicker:hover {
  color: #ad4920;
  transform: scale(1.04);
}

#funStreetPlayAll {
  border: 1px solid rgba(226, 126, 90, 0.48);
  color: #8a4320;
  font-weight: 700;
  background: linear-gradient(180deg, #fff4ec 0%, #ffe9d9 100%);
  box-shadow: 0 4px 10px rgba(218, 126, 88, 0.16);
}

#funStreetPlayAll:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.1);
}

.fun-street-list {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.fun-street-group {
  border: 1px solid rgba(169, 129, 96, 0.26);
  border-radius: 13px;
  background: rgba(255, 248, 239, 0.74);
  padding: 10px;
  display: grid;
  gap: 10px;
}

.fun-street-group-title {
  margin: 0;
  color: #8d3f1f;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.fun-street-group-grid {
  display: grid;
  gap: 9px;
}

.fun-street-item {
  border: 1px solid rgba(176, 138, 102, 0.28);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.84);
  display: grid;
  gap: 4px;
}

.fun-street-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fun-street-context {
  margin: 0;
  color: #8d3f1f;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.fun-street-play-btn {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  font-size: 0.92rem;
}

.fun-street-line {
  margin: 0;
}

.fun-street-item .hanzi.fun-street-line {
  font-size: 1.52rem;
  line-height: 1.16;
  color: #28486a;
}

.fun-street-item .jyutping.fun-street-line {
  margin-top: 2px;
  font-size: 0.83rem;
  font-family: "Menlo", "Courier New", monospace;
  color: #4d6685;
}

.fun-street-item .english.fun-street-line {
  margin-top: 4px;
  color: #546274;
  font-size: 0.92rem;
}

.formula {
  font-family: "Menlo", "Courier New", monospace;
  background: #e7f0ff;
  padding: 8px 10px;
  border-radius: 10px;
}

.slot-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.slot-grid label {
  font-size: 1.04rem;
  color: var(--muted);
  font-weight: 600;
}

.slot-grid select {
  margin-top: 5px;
  width: 100%;
  border-radius: 10px;
  border: 2px solid #d6e1f5;
  padding: 9px;
  background: #fff;
  font-size: 1.03rem;
  font-weight: 600;
}

.slot-grid input[type="range"] {
  margin-top: 8px;
  width: 100%;
}

.result-box {
  margin-top: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  border: 2px solid #e8edf8;
}

.question-answer-box {
  margin-top: 8px;
  border: 1px solid rgba(122, 151, 188, 0.34);
  border-radius: 10px;
  background: rgba(243, 249, 255, 0.72);
  overflow: hidden;
}

.question-answer-box summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.88rem;
  font-weight: 800;
  color: #2f4f76;
  padding: 8px 10px;
  border-bottom: 1px solid transparent;
}

.question-answer-box summary::-webkit-details-marker {
  display: none;
}

.question-answer-box[open] summary {
  border-bottom-color: rgba(122, 151, 188, 0.28);
}

.question-answer-body {
  padding: 8px 10px 10px;
  display: grid;
  gap: 3px;
}

#questionAnswerHanzi,
#questionAnswerJyutping,
#questionAnswerEnglish {
  margin: 0;
}

.choices {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.choice {
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 2px solid #d7dfef;
}

#quizEnglishControl,
#toneJyutpingControl {
  display: none !important;
}

#panel-listening .choice {
  font-size: 1.15rem;
  line-height: 1.4;
  padding: 12px 14px;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

#panel-tones .choice {
  font-size: 1.2rem;
  line-height: 1.45;
  padding: 13px 15px;
}

.choice.is-correct {
  border-color: #0a7d6f;
  background: #e9fbf5;
}

.choice.is-wrong {
  border-color: #b62a2a;
  background: #ffecee;
}

.choice.is-correct.is-pop {
  animation: quiz-choice-pop 260ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.choice.is-wrong.is-jitter {
  animation: quiz-choice-jitter 180ms ease-in-out 1;
}

.feedback {
  font-weight: 700;
  min-height: 20px;
}

#quizFeedback.is-pop {
  animation: quiz-feedback-pop 260ms ease-out;
}

.feedback.ok {
  color: #0a7d6f;
}

.feedback.bad {
  color: #b62a2a;
}

.hidden {
  display: none;
}

.app-boot-overlay.hidden {
  display: none !important;
}

.app-boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 18px;
  background: radial-gradient(circle at 15% 20%, var(--bg-a) 0%, var(--bg-b) 34%, var(--bg-c) 78%);
  opacity: 0;
  transition: opacity 220ms ease;
}

.app-boot-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.app-boot-card {
  width: auto;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.app-boot-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(15, 51, 83, 0.24);
  border-top-color: #0f3353;
  animation: app-boot-spin 0.9s linear infinite;
}

.app-boot-message {
  margin: 0;
  color: #23334a;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.35;
  white-space: pre-line;
}

@keyframes app-boot-spin {
  to {
    transform: rotate(360deg);
  }
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

.known-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.known-item {
  display: grid;
  grid-template-columns: minmax(70px, auto) minmax(90px, auto) 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 6px 8px;
  border: 1px solid #e8edf8;
  border-radius: 10px;
  background: #fff;
}

.known-item .hanzi {
  font-size: 1.2rem;
  margin: 0;
}

.known-item .jyutping,
.known-item .english {
  margin: 0;
}

.known-list-actions {
  margin-top: 8px;
  justify-content: flex-start;
}

#toggleKnownList,
#clearKnownList {
  min-width: auto;
  padding: 7px 11px;
  min-height: 32px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 3px 8px rgba(42, 53, 73, 0.14);
}

#toggleKnownList {
  color: #35506a;
  border: 2px solid #d3dce9;
  background: linear-gradient(180deg, #f8f9fb 0%, #e9edf3 100%);
}

#toggleKnownList:hover {
  background: linear-gradient(180deg, #fcfdff 0%, #edf2f8 100%);
}

#clearKnownList {
  color: #fff;
  border: 2px solid #cf6a74;
  background: linear-gradient(160deg, #e8787f 0%, #d75a68 100%);
}

#clearKnownList:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.known-remove-btn {
  border: 1px solid #d7deec;
  background: #f6f8fc;
  color: #6f3e45;
  border-radius: 999px;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
}

.known-remove-btn:hover {
  background: #feeff1;
  border-color: #e8bbc2;
}

#knownListWrap {
  overflow: hidden;
  transform-origin: top;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 250ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 250ms cubic-bezier(0.22, 0.61, 0.36, 1), transform 250ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

#knownListWrap.is-open {
  max-height: 680px;
  opacity: 1;
  transform: translateY(0);
}

#knownListWrap.is-closing {
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  opacity: 0.95;
  border-radius: 2px;
  animation: confetti-fall 1600ms linear forwards;
}

.lightning-flash {
  position: absolute;
  inset: 0;
  background: rgba(235, 247, 255, 0.8);
  animation: lightning-pop 440ms ease-out forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-8vh) rotate(0deg); opacity: 0.95; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes lightning-pop {
  0% { opacity: 0; }
  15% { opacity: 1; }
  35% { opacity: 0.2; }
  55% { opacity: 0.85; }
  100% { opacity: 0; }
}

pre {
  background: #f0f4fc;
  border-radius: 12px;
  padding: 12px;
  overflow-x: auto;
  font-size: 0.8rem;
}

input[type="file"] {
  display: none;
}

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

@keyframes quiz-choice-jitter {
  0% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

@keyframes quiz-choice-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes quiz-feedback-pop {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes listening-play-burst {
  0% {
    transform: translateY(0) scale(1) rotate(0deg);
    filter: brightness(1);
  }
  25% {
    transform: translateY(-1px) scale(1.05) rotate(-4deg);
    filter: brightness(1.12);
  }
  62% {
    transform: translateY(-1px) scale(1.03) rotate(3deg);
    filter: brightness(1.08);
  }
  100% {
    transform: translateY(0) scale(1) rotate(0deg);
    filter: brightness(1);
  }
}

@keyframes listening-play-ring {
  0% {
    opacity: 0.9;
    transform: scale(0.92);
  }
  100% {
    opacity: 0;
    transform: scale(1.24);
  }
}

@keyframes listening-play-float {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes listening-play-orbit {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes main-tab-overlay-fade {
  0% { opacity: 0; }
  45% { opacity: 0.35; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .main-transition-overlay.is-running {
    animation: none;
  }

  .choice.is-correct.is-pop,
  .choice.is-wrong.is-jitter,
  #quizFeedback.is-pop {
    animation: none;
  }

  .play-icon-btn.is-audio-burst,
  .play-icon-btn.is-audio-playing,
  .play-icon-btn.is-audio-burst::after,
  .play-icon-btn.is-audio-playing::before,
  .book-tone-audio-btn.is-audio-burst,
  .book-tone-audio-btn.is-audio-playing,
  .book-tone-audio-btn.is-audio-burst::after,
  .book-tone-audio-btn.is-audio-playing::before,
  #funStreetPlayAll.is-audio-burst,
  #funStreetPlayAll.is-audio-playing,
  #funStreetPlayAll.is-audio-burst::after,
  #funStreetPlayAll.is-audio-playing::before {
    animation: none;
  }
}

@media (max-width: 720px) {
  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  #panel-patterns .pattern-actions {
    gap: 9px;
  }

  #panel-patterns .pattern-mini-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  #panel-patterns .pattern-next-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .streak {
    font-size: 0.78rem;
    padding: 3px 7px;
  }

  .bottom-nav {
    width: 100%;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    gap: 6px;
    border-radius: 12px 12px 0 0;
  }

  .bottom-nav-btn {
    padding: 6px 4px;
    font-size: 0.8rem;
  }

  .bottom-nav-label {
    font-size: 0.68rem;
  }

  .stories-top-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .book-top-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .book-sheet-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) and (min-width: 721px) {
  .controls-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
