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

:root {
  --bg: #f5f2ee;
  --surface: #fffefd;
  --surface-2: #f0ece8;
  --surface-3: #f4effa;
  --text: #141414;
  --text-muted: #77736f;
  --accent: #a990f6;
  --accent-hover: #9276ec;
  --accent-soft: #eee8ff;
  --peach: #ffbd94;
  --peach-soft: #fff0e7;
  --mint: #4bd37d;
  --mint-soft: #e8f5ea;
  --correct: #34c969;
  --correct-bg: #e5f5e8;
  --wrong: #ff6b6b;
  --wrong-bg: #ffe7e7;
  --current: #ffb16d;
  --current-bg: #fff0e7;
  --line: #1d1d1b;
  --line-soft: rgba(29, 29, 27, 0.18);
  --radius: 16px;
  --shadow: 6px 8px 0 #151515;
  --shadow-soft: 0 14px 40px rgba(122, 107, 170, 0.16);
  --sidebar-width: 280px;
}

body.theme-dark {
  --bg: #111014;
  --surface: #242229;
  --surface-2: #302d36;
  --surface-3: #292535;
  --text: #f5f1ea;
  --text-muted: #b9afa6;
  --accent: #b79dff;
  --accent-hover: #c5b1ff;
  --accent-soft: #352f49;
  --peach: #ffb783;
  --peach-soft: #3e2f2a;
  --mint: #62dc8c;
  --mint-soft: #253a2d;
  --correct-bg: #1f3b28;
  --wrong-bg: #47282b;
  --current-bg: #473428;
  --line: #101010;
  --line-soft: rgba(245, 241, 234, 0.18);
  --shadow: 6px 8px 0 #050505;
  --shadow-soft: 0 14px 40px rgba(0, 0, 0, 0.28);
}

body {
  font-family: "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(20, 20, 20, 0.26);
  backdrop-filter: blur(2px);
}
.welcome-modal.hidden { display: none; }
.welcome-card {
  position: relative;
  width: min(920px, 92vw);
  max-height: min(760px, 88vh);
  overflow: auto;
  padding: 2.25rem;
  border: 4px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(120deg, rgba(169, 144, 246, 0.16), rgba(255, 189, 148, 0.14)),
    var(--surface);
  color: var(--text);
  box-shadow: 10px 12px 0 var(--line);
}
.welcome-close {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  width: 3rem;
  height: 3rem;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--line);
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 4px 5px 0 var(--line);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.welcome-close:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 6px 0 var(--line);
  background: var(--peach);
}
.welcome-kicker {
  margin-bottom: 0.25rem;
  color: var(--accent-hover);
  font-size: 0.95rem;
  font-weight: 900;
}
.welcome-card h1,
.welcome-title {
  max-width: 760px;
  margin: 0 3.4rem 1.5rem 0;
  color: var(--text);
  font-size: clamp(2.1rem, 4vw, 4rem);
  line-height: 1.12;
  letter-spacing: 0;
}
.welcome-title span,
.welcome-title strong {
  display: block;
}
.welcome-title strong {
  font-size: 0.72em;
}
.welcome-install {
  padding: 1.1rem;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 6px 7px 0 var(--line);
}
html.device-desktop .welcome-install {
  display: none;
}
.welcome-install-icon {
  display: block;
  width: 4.3rem;
  height: 4.3rem;
  margin-bottom: 0.9rem;
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  object-fit: cover;
}
.welcome-install-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--line-soft);
}
.welcome-install-copy h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.2;
}
.welcome-install-copy h2 span {
  display: block;
}
.welcome-install-copy p {
  max-width: 24rem;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: right;
}
.welcome-install-steps {
  list-style: decimal;
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0 0 0 1.35rem;
}
.welcome-install-steps li {
  padding: 0.55rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
}

.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  background:
    linear-gradient(90deg, rgba(169, 144, 246, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 189, 148, 0.08) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
}

body.theme-dark .layout {
  background:
    linear-gradient(90deg, rgba(183, 157, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 183, 131, 0.06) 1px, transparent 1px),
    var(--bg);
}

body.theme-dark .welcome-modal { background: rgba(5, 5, 5, 0.48); }
body.theme-dark .welcome-card,
body.theme-dark .welcome-install,
body.theme-dark .welcome-close {
  border-color: var(--line);
}
body.theme-dark .welcome-close {
  color: var(--text);
}

@media (max-width: 720px) {
  .welcome-modal { padding: 1rem; align-items: flex-start; }
  .welcome-card { width: 100%; max-height: calc(100vh - 2rem); padding: 1.4rem; border-radius: 18px; }
  .welcome-card h1 { margin-right: 3rem; font-size: 2.2rem; }
  .welcome-close { width: 2.65rem; height: 2.65rem; }
  .welcome-install { padding: 1rem; }
  .welcome-install-copy {
    display: block;
    padding-bottom: 0.85rem;
  }
  .welcome-install-copy p {
    margin-top: 0.35rem;
    text-align: left;
  }
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 0;
  background: var(--surface);
  border-right: 3px solid var(--line);
  overflow: hidden;
  transition: width 0.22s ease, border-color 0.22s ease;
}
.sidebar-inner {
  width: var(--sidebar-width);
  height: 100%;
  min-height: 100vh;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}
.layout.sidebar-collapsed .sidebar {
  width: 0;
  border-right-color: transparent;
}
.sidebar-toggle {
  flex-shrink: 0;
  align-self: center;
  width: 22px;
  min-height: 72px;
  margin: 0 -1px;
  padding: 0;
  border: 3px solid var(--line);
  border-left: none;
  border-radius: 0 12px 12px 0;
  background: var(--accent-soft);
  color: var(--line);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 6;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-toggle:hover {
  background: var(--accent);
  color: var(--line);
  border-color: var(--line);
}
.sidebar-start-guide { display: none; }

.sidebar-header h2 {
  font-size: 1.45rem;
  margin-bottom: 0.25rem;
  letter-spacing: 0;
  font-weight: 900;
}
.sidebar-header-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 1rem;
}
.sidebar-header-row .sidebar-note { margin-bottom: 0; }
.user-avatar-btn {
  flex-shrink: 0; min-width: 4.8rem; height: 2.35rem; padding: 0 0.55rem; border-radius: 10px;
  border: 3px solid var(--line); background: var(--peach);
  color: var(--line); font-weight: 900; font-size: 0.78rem; white-space: nowrap; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 3px 4px 0 var(--line);
}
.user-avatar-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 5px 0 var(--line); }

.sidebar-note { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1rem; }

.corpus-list { display: flex; flex-direction: column; gap: 0.5rem; }

.corpus-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem;
  width: 100%; padding: 0.65rem 0.75rem;
  border: 2px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text); cursor: pointer; text-align: left;
  box-shadow: 3px 4px 0 var(--line);
}

.corpus-item:hover { transform: translate(-1px, -1px); background: var(--accent-soft); }
.corpus-item.active { border-color: var(--line); background: var(--accent); color: var(--line); }
.corpus-item-title { font-size: 0.92rem; font-weight: 600; }
.corpus-item-meta { font-size: 0.72rem; color: var(--text-muted); }

.test-level-panel {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.35rem 2rem;
}
.test-level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}
.test-level-choice {
  min-height: 5rem;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--line);
  box-shadow: 4px 5px 0 var(--line);
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 900;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.test-level-choice:hover {
  transform: translate(-1px, -1px);
  background: var(--accent-soft);
  box-shadow: 5px 6px 0 var(--line);
}
.test-level-choice:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 3px 0 var(--line);
}

.layout > .app { flex: 1; min-width: 0; max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.5rem 2.75rem; width: 100%; }

.mode-nav {
  display: flex; gap: 0.35rem; margin-bottom: 1rem;
  padding: 0.35rem; background: var(--surface-2); border: 3px solid var(--line); border-radius: 14px;
  box-shadow: 4px 5px 0 var(--line);
}
.mode-nav-btn {
  flex: 1; padding: 0.6rem 0.4rem; border: 2px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text-muted); font-weight: 600;
  font-size: 0.88rem; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.mode-nav-btn:hover { color: var(--text); background: rgba(169, 144, 246, 0.16); }
.mode-nav-btn.active { background: var(--accent); color: var(--line); border-color: var(--line); font-weight: 900; }

.sidebar-panel.hidden { display: none; }
.sidebar-panel-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); }
.favorite-entry { margin-bottom: 0.9rem; }
.favorite-entry-btn,
.ear-sidebar-btn {
  width: 100%;
  min-height: 4.4rem;
  padding: 0.85rem 0.95rem;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  color: var(--line);
  font-weight: 900;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  box-shadow: 4px 5px 0 var(--line);
  transition: transform 0.1s, background 0.15s;
}
.favorite-entry-btn {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  background: var(--peach-soft);
}
.favorite-entry-btn:hover,
.ear-sidebar-btn:hover {
  background: #ffe5ee;
  transform: translate(-1px, -2px);
}
.favorite-entry-heart {
  color: #ff3f66;
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 0 7px rgba(255, 63, 102, 0.45));
}
.favorite-entry-count {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.82rem;
}
.favorite-entry.is-empty .favorite-entry-btn {
  background: var(--surface);
}
.favorite-entry.is-empty .favorite-entry-heart {
  color: #cfcbd2;
  filter: none;
}
.ear-sidebar-actions {
  display: grid;
  gap: 0.9rem;
}
.ear-sidebar-btn {
  display: flex;
  align-items: center;
}
.ear-sidebar-btn-custom {
  background: var(--mint-soft);
}
.ear-sidebar-btn-custom:hover {
  background: var(--mint-soft);
}
.ear-sidebar-btn-level {
  background: #fff8c6;
}
.ear-sidebar-btn-level:hover {
  background: #fff8c6;
}
.ear-sidebar-btn-all {
  background: #ffe8fd;
}
.ear-sidebar-btn-all:hover {
  background: #ffe8fd;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.level-list.hidden { display: none; }
.level-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s, background 0.15s;
  box-shadow: 3px 4px 0 var(--line);
}
.level-item:nth-child(3n + 1) { background: var(--accent-soft); }
.level-item:nth-child(3n + 2) { background: var(--peach-soft); }
.level-item:nth-child(3n + 3) { background: var(--mint-soft); }
.level-item:hover { transform: translate(-1px, -1px); }
.level-item-name { font-weight: 700; font-size: 0.95rem; }
.level-item-count { font-size: 0.78rem; color: var(--text-muted); }
.episode-picker.hidden { display: none; }
.level-back-btn {
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.45rem 0.65rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--line);
  cursor: pointer;
  font-size: 0.82rem;
  text-align: left;
}
.level-back-btn:hover { background: var(--peach-soft); }
body.theme-dark .level-back-btn,
body.theme-dark .level-back-btn:hover {
  color: var(--text);
}

.episode-list {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.35rem;
  max-height: calc(100vh - 220px); overflow-y: auto; padding-right: 0.25rem;
}
.episode-item {
  padding: 0.4rem 0; border: 2px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 0.82rem; font-weight: 600;
  cursor: pointer; text-align: center;
}
.episode-item:hover { background: var(--peach-soft); }
.episode-item.active { border-color: var(--line); background: var(--accent); color: var(--line); }
.episode-item.episode-missing { opacity: 0.35; cursor: not-allowed; }
.episode-item.episode-locked { opacity: 0.4; cursor: not-allowed; }
.episode-item:disabled { pointer-events: none; }

.view.hidden { display: none; }
.hidden { display: none !important; }
.podcast-player.hidden { display: none !important; }
.view-placeholder {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
  background: var(--surface); border-radius: var(--radius); border: 3px dashed var(--line-soft);
}

.podcast-player {
  background: var(--surface); border: 3px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
.podcast-visual {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 1rem;
  background: transparent;
  border: none;
  aspect-ratio: 16 / 9;
  max-height: 360px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.podcast-bg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
  transform: translateX(-4%) scale(1.08);
  transform-origin: center center;
}
.podcast-srt-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  z-index: 2;
  display: flex;
  align-items: stretch;
  pointer-events: none;
  border-radius: 0;
  overflow: hidden;
  background: linear-gradient(
    to bottom,
    rgba(20, 16, 12, 0) 0%,
    rgba(20, 16, 12, 0.14) 34%,
    rgba(20, 16, 12, 0.38) 68%,
    rgba(20, 16, 12, 0.78) 100%
  );
}
.podcast-srt-panel.hidden { display: none; }
.podcast-srt-track {
  --srt-line-gap: 0.4rem;
  width: 100%;
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--srt-line-gap);
  padding: 1rem 1.5rem;
}
.podcast-srt-track::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.podcast-srt-line {
  margin: 0;
  padding: 0 0.35rem;
  min-height: 0;
  font-size: 1.96rem;
  line-height: 1.22;
  color: rgba(255, 255, 255, 0.38);
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  transition: color 0.2s ease, opacity 0.2s ease;
}
.podcast-srt-line.is-prev,
.podcast-srt-line.is-next {
  opacity: 0.38;
  font-weight: 400;
}
.podcast-srt-line.is-active {
  opacity: 1;
  color: #fff;
  font-weight: 600;
}
.podcast-srt-line.is-empty {
  visibility: hidden;
}
.podcast-meta { text-align: center; margin-bottom: 0.75rem; }
.podcast-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.25rem; }
.podcast-time { font-size: 0.85rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.podcast-progress-wrap {
  position: relative;
  height: 1.5rem;
  margin-bottom: 1rem;
  --progress-ratio: 0%;
  --progress-thumb-radius: 0.7rem;
}
.podcast-progress-wrap::before {
  content: "";
  position: absolute;
  left: var(--progress-thumb-radius);
  right: var(--progress-thumb-radius);
  top: 50%;
  height: 0.52rem;
  border: 2px solid rgba(29, 29, 27, 0.56);
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--progress-ratio),
    #4a4a4a var(--progress-ratio),
    #4a4a4a 100%
  );
  transform: translateY(-50%);
}
.podcast-progress-wrap::after {
  content: "";
  position: absolute;
  left: clamp(var(--progress-thumb-radius), var(--progress-ratio), calc(100% - var(--progress-thumb-radius)));
  top: 50%;
  width: 1.35rem;
  height: 1.35rem;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.podcast-progress-wrap:focus-within::after {
  outline: 3px solid rgba(169, 144, 246, 0.35);
  outline-offset: 3px;
}
.podcast-progress {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  opacity: 0;
}
.podcast-progress::-webkit-slider-runnable-track {
  height: 1.5rem;
  background: transparent;
}
.podcast-progress::-moz-range-track {
  height: 1.5rem;
  background: transparent;
}
.podcast-progress::-moz-range-progress {
  background: transparent;
}
.podcast-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.podcast-progress::-moz-range-thumb {
  width: 1.35rem;
  height: 1.35rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.podcast-progress:focus-visible {
  outline: none;
}
.podcast-controls-row {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "left"
    "controls"
    "extra";
  align-items: center;
  min-height: 2.75rem;
  row-gap: 0.75rem;
}
.podcast-controls-row .podcast-controls {
  grid-area: controls;
  justify-self: center;
}
.podcast-controls-spacer { grid-column: 3; }
.podcast-controls-extra {
  grid-area: extra;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.podcast-left-tools {
  grid-area: left;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}
.btn-key-phrases {
  padding: 0.45rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--mint-soft);
  color: var(--line);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 3px 4px 0 var(--line);
  transition: transform 0.12s, background 0.15s;
}
.btn-key-phrases:hover {
  background: var(--mint);
  border-color: var(--line);
  color: var(--line);
  transform: translate(-1px, -1px);
}
.btn-key-phrases:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-vocab-quiz {
  padding: 0.45rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--accent-soft);
  color: var(--line);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 3px 4px 0 var(--line);
  transition: transform 0.12s, background 0.15s;
}
.btn-vocab-quiz:hover {
  background: var(--accent);
  border-color: var(--line);
  color: var(--line);
  transform: translate(-1px, -1px);
}
.btn-vocab-quiz:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
body.theme-dark .btn-key-phrases,
body.theme-dark .btn-key-phrases:hover,
body.theme-dark .btn-vocab-quiz,
body.theme-dark .btn-vocab-quiz:hover {
  color: var(--text);
}
.podcast-srt-toggle {
  grid-column: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.podcast-srt-toggle-text { white-space: nowrap; }
.podcast-srt-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.podcast-srt-toggle-slider {
  position: relative;
  flex-shrink: 0;
  width: 2.5rem;
  height: 1.375rem;
  box-sizing: border-box;
  overflow: hidden;
  isolation: isolate;
  border-radius: 999px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.podcast-srt-toggle-slider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  background: var(--line);
  transform: translateY(-50%);
  transition: transform 0.2s ease;
  box-shadow: none;
  z-index: 1;
}
.podcast-srt-toggle-input:checked + .podcast-srt-toggle-slider {
  background: var(--accent);
  border-color: var(--line);
}
.podcast-srt-toggle-input:checked + .podcast-srt-toggle-slider::before {
  transform: translate(1rem, -50%);
}
.podcast-srt-toggle-input:focus-visible + .podcast-srt-toggle-slider {
  outline: 3px solid rgba(169, 144, 246, 0.45);
  outline-offset: 2px;
}
.podcast-srt-toggle:hover .podcast-srt-toggle-slider {
  background: var(--accent-soft);
}
.podcast-srt-lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.9rem;
  min-width: 4.9rem;
  max-width: 4.9rem;
  height: 2.55rem;
  padding: 0 0.8rem;
  box-sizing: border-box;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 3px 4px 0 var(--line);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.podcast-srt-lang-btn:hover {
  transform: translate(-1px, -1px);
  background: var(--accent-soft);
  box-shadow: 4px 5px 0 var(--line);
}
.podcast-srt-lang-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 2px 0 var(--line);
}
.podcast-srt-lang-btn.is-bilingual {
  background: var(--accent);
}
.podcast-favorite-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 3.5rem;
  min-width: 3.5rem;
  max-width: 3.5rem;
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 2.75rem;
  padding: 0;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 3px 4px 0 var(--line);
  cursor: pointer;
  line-height: 1;
  align-self: center;
  opacity: 1;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.podcast-favorite-btn:hover {
  transform: translate(-1px, -1px);
  background: var(--accent-soft);
  box-shadow: 4px 5px 0 var(--line);
}
.podcast-favorite-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 2px 0 var(--line);
}
.podcast-favorite-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: 3px 4px 0 var(--line);
}
.podcast-favorite-heart {
  display: block;
  width: 1.65rem;
  height: 1.5rem;
  overflow: visible;
}
.heart-shadow {
  display: none;
}
.heart-fill {
  fill: #c9c5ce;
  stroke: none;
  stroke-width: 0;
  stroke-linejoin: round;
  transition: fill 0.15s ease, transform 0.15s ease;
}
.heart-rim {
  display: none;
}
.heart-gloss {
  display: none;
}
.podcast-favorite-btn.is-liked {
  background: var(--peach);
  filter: none;
}
.podcast-favorite-btn.is-liked .heart-shadow {
  display: none;
}
.podcast-favorite-btn.is-liked .heart-fill {
  fill: #ff4b69;
  stroke: none;
  opacity: 1;
}
.podcast-favorite-btn.is-liked .heart-rim {
  display: none;
}
.podcast-favorite-btn.is-liked .heart-gloss {
  display: none;
}
.podcast-favorite-btn::before,
.podcast-favorite-btn::after {
  content: "";
  position: absolute;
  inset: 0.1rem;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
}
.podcast-favorite-btn::before {
  background:
    radial-gradient(circle at 50% 0%, #ff4b69 0 2px, transparent 3px),
    radial-gradient(circle at 92% 32%, #ffb98f 0 2px, transparent 3px),
    radial-gradient(circle at 14% 74%, #a990f6 0 2px, transparent 3px);
}
.podcast-favorite-btn.is-bursting {
  animation: heart-pop 0.36s ease-out;
}
.podcast-favorite-btn.is-bursting::before {
  animation: heart-spark 0.36s ease-out;
}
.podcast-controls { display: flex; justify-content: center; align-items: center; gap: 0.75rem; min-height: 2.75rem; }
.header-theme-btn {
  width: 3rem;
  min-width: 3rem;
  height: 2.55rem;
  min-height: 2.55rem;
  padding: 0;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.header-theme-btn .theme-icon {
  display: none;
}
.header-theme-btn::before {
  content: none;
}
.header-theme-glyph {
  display: grid;
  place-items: center;
  width: 1.12rem;
  height: 1.12rem;
  color: #000;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", system-ui, sans-serif;
  font-size: 1.12rem;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-0.01rem);
}
body.theme-dark .header-theme-glyph {
  color: #f3b83f;
}
body.theme-dark .header-theme-glyph::before {
  content: "";
  display: block;
  width: 0.68rem;
  height: 0.68rem;
  border: 0.16rem solid #f3b83f;
  border-radius: 50%;
  background: transparent;
  box-shadow:
    0 -0.6rem 0 -0.25rem #f3b83f,
    0 0.6rem 0 -0.25rem #f3b83f,
    -0.6rem 0 0 -0.25rem #f3b83f,
    0.6rem 0 0 -0.25rem #f3b83f,
    -0.43rem -0.43rem 0 -0.27rem #f3b83f,
    0.43rem -0.43rem 0 -0.27rem #f3b83f,
    -0.43rem 0.43rem 0 -0.27rem #f3b83f,
    0.43rem 0.43rem 0 -0.27rem #f3b83f;
}
.header-theme-btn .theme-icon {
  width: 1.45rem;
  height: 1.45rem;
}
.header-theme-btn .theme-icon-moon {
  width: 1.3rem;
  height: 1.3rem;
}
.theme-icon {
  display: block;
  width: 1.82rem;
  height: 1.82rem;
}
.theme-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.theme-icon-moon {
  width: 1.638rem;
  height: 1.638rem;
}
.theme-icon-moon svg {
  fill: #000;
}
.theme-icon-moon .moon-crescent {
  fill: #000;
}
.theme-icon-sun {
  display: none;
}
.theme-icon-sun svg {
  fill: none;
  stroke: #f3b83f;
  stroke-width: 6.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon-sun circle {
  fill: none;
}
body.theme-dark .theme-icon-moon {
  display: none;
}
body.theme-dark .theme-icon-sun {
  display: block;
}
.btn-ghost { margin-top: 1rem; background: var(--surface); border: 2px solid var(--line); color: var(--line); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--line); color: var(--line); }
body.theme-dark .btn-ghost,
body.theme-dark .btn-ghost:hover { color: var(--text); }
.podcast-error { margin-top: 0.75rem; text-align: center; color: var(--wrong); font-size: 0.85rem; }
.podcast-error.hidden { display: none; }

.unspaced-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem;
}
.unspaced-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem;
  padding: 1rem 1.1rem; border: 3px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left;
  min-height: 5rem; transition: transform 0.1s, background 0.15s;
  box-shadow: 4px 5px 0 var(--line);
}
.unspaced-item:nth-child(3n + 1) { background: var(--accent-soft); }
.unspaced-item:nth-child(3n + 2) { background: var(--peach-soft); }
.unspaced-item:nth-child(3n + 3) { background: var(--mint-soft); }
.unspaced-item:hover { transform: translate(-1px, -2px); }
.unspaced-item-title { font-weight: 700; font-size: 1rem; }
.unspaced-item-meta { font-size: 0.78rem; color: var(--text-muted); line-height: 1.35; }
.ear-group-grid,
.ear-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}
.ear-group-card,
.ear-group-add,
.ear-level-card {
  min-height: 8.4rem;
  padding: 1rem;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 5px 6px 0 var(--line);
}
.ear-group-card {
  display: grid;
  gap: 0.65rem;
  cursor: pointer;
}
.ear-group-card:nth-child(3n + 1),
.ear-level-card:nth-child(3n + 1) { background: var(--accent-soft); }
.ear-group-card:nth-child(3n + 2),
.ear-level-card:nth-child(3n + 2) { background: var(--peach-soft); }
.ear-group-card:nth-child(3n + 3),
.ear-level-card:nth-child(3n + 3) { background: var(--mint-soft); }
.ear-group-name {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 900;
}
.ear-group-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2rem;
  align-items: center;
  gap: 0.35rem;
}
.ear-group-name-row .ear-group-name[readonly] { cursor: default; }
.ear-group-rename {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--line);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}
.ear-group-meta {
  color: var(--text-muted);
  font-size: 0.86rem;
}
.ear-play-rule-switch {
  display: grid;
  grid-template-columns: auto 3.9rem auto;
  align-items: center;
  gap: 0.5rem;
  width: max-content;
  max-width: 100%;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
}
.ear-level-rule-switch { margin-bottom: 1rem; }
.ear-play-rule-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ear-play-rule-track {
  position: relative;
  box-sizing: border-box;
  width: 3.9rem;
  height: 1.9rem;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 2px 3px 0 var(--line);
  overflow: hidden;
  isolation: isolate;
}
.ear-play-rule-thumb {
  position: absolute;
  top: 50%;
  left: 0.32rem;
  box-sizing: border-box;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
  transition: left 0.16s ease, background 0.16s ease;
}
.ear-play-rule-input:checked + .ear-play-rule-track .ear-play-rule-thumb {
  left: 2.12rem;
  background: var(--peach);
}
.ear-play-rule-input:focus-visible + .ear-play-rule-track {
  outline: 3px solid rgba(169, 144, 246, 0.35);
  outline-offset: 3px;
}
.ear-group-actions {
  display: flex;
  gap: 0.5rem;
}
.ear-group-actions button {
  flex: 1;
  padding: 0.45rem 0.55rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--line);
  font-weight: 900;
  cursor: pointer;
}
.ear-group-add {
  display: grid;
  place-items: center;
  gap: 0.35rem;
  border-style: dashed;
  cursor: pointer;
  font-size: 1rem;
}
.ear-group-add span {
  display: grid;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  border: 3px solid var(--line);
  border-radius: 50%;
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}
.ear-editor-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.ear-editor-levels {
  display: grid;
  gap: 1rem;
}
.ear-editor-level {
  padding: 1rem;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 4px 5px 0 var(--line);
}
.ear-editor-level h3 {
  margin-bottom: 0.65rem;
  font-size: 1rem;
}
.ear-editor-episodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.1rem, 1fr));
  gap: 0.45rem;
}
.ear-editor-episode {
  min-height: 2.4rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}
.ear-editor-episode.selected {
  background: var(--accent);
  color: var(--line);
  box-shadow: 2px 3px 0 var(--line);
}
.ear-level-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
}
.ear-level-card strong {
  font-size: 1.35rem;
}
.ear-level-card span {
  color: var(--text-muted);
  font-weight: 800;
}

.header {
  text-align: left;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(100deg, var(--accent-soft), #fbf8ff 54%, var(--peach-soft));
  box-shadow: 6px 8px 0 var(--accent);
}
body.theme-dark .header {
  background: linear-gradient(100deg, var(--accent-soft), #211f27 54%, var(--peach-soft));
}
.header h1 { font-size: clamp(1.8rem, 4vw, 3.1rem); font-weight: 900; line-height: 1; }
.header-learn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header-learn .learn-title-row { flex: 1; min-width: 0; }
.view-ear .header.header-learn { position: relative; }
.ear-player-count {
  position: absolute;
  left: 50%;
  max-width: 44%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}
.ear-player-count:empty { display: none; }
#earBackBtn {
  flex-shrink: 0;
  margin-top: 0;
}
.header-learn {
  margin-bottom: 0.75rem;
  padding: 0.7rem 1rem;
  border-width: 2px;
  border-radius: 14px;
  box-shadow: 4px 5px 0 var(--accent);
}
.header-learn h1,
.view-ear .header.header-learn h1,
.view-test .header.header-learn h1 {
  font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  line-height: 1.1;
}
.learn-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
}
.learn-title-row h1 { margin: 0; }
.learn-title-row .subtitle {
  margin: 0;
  font-size: 0.85rem;
  text-align: right;
}
.mobile-player-title { display: none; }
.learn-vocab-quiz.hidden { display: none; }
.header-learn-quiz { margin-bottom: 1rem; }
.learn-quiz-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
}
.learn-quiz-title-row h1 { margin: 0; font-size: 1.75rem; }
.learn-quiz-title-row .subtitle { margin: 0.35rem 0 0; }
.learn-quiz-back { flex-shrink: 0; margin-top: 0.15rem; }
.learn-vocab-quiz .main { max-width: 1080px; margin: 0 auto; padding: 0 1.35rem 2rem; }
.view-test #typingPracticeRoot .main { max-width: 1080px; margin: 0 auto; padding: 0 1.35rem 2rem; }
.view-learn .podcast-player,
.view-ear .podcast-player { padding: 1rem 1.1rem; }
.view-learn .podcast-visual,
.view-ear .podcast-visual {
  max-height: min(52vh, 460px);
}
.subtitle { color: var(--text-muted); margin-top: 0.35rem; font-size: 0.95rem; }

.progress-bar { height: 12px; background: var(--surface); border: 3px solid var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 0.65rem; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--peach)); transition: width 0.4s; }
.progress-text { text-align: center; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.25rem; }

.sentence-card {
  background: var(--surface); border: 3px solid var(--line);
  border-radius: var(--radius); padding: 1.75rem 1.5rem; box-shadow: var(--shadow);
}
.vocab-definition {
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text);
  text-align: center;
  margin-bottom: 0.85rem;
  padding: 0 0.5rem;
}
.vocab-definition.hidden { display: none; }
.vocab-pos {
  font-size: 0.88rem;
  font-style: italic;
  color: var(--accent-hover);
  text-align: center;
  margin-bottom: 0.65rem;
}
.vocab-pos.hidden { display: none; }

.sentence-display {
  font-size: 1.35rem; line-height: 2.4; min-height: 5rem; padding: 1rem;
  background: var(--surface-3); border: 3px solid var(--line); border-radius: 14px; word-wrap: break-word;
}

.sentence-display.hidden { display: none; }
.token.punct { color: var(--text-muted); }

.word-input-wrap { display: inline-flex; flex-direction: column; align-items: center; position: relative; vertical-align: baseline; margin: 0 0.08em; }

.word-input {
  display: inline-block; min-width: 2.5em; min-height: 1.4em; padding: 0 0.15em 0.05em;
  border: none; border-bottom: 3px solid var(--line-soft);
  background: transparent; color: var(--text); font: inherit; font-size: inherit;
  outline: none; text-align: center; cursor: text;
}

.word-input:focus { border-bottom-color: var(--current); background: var(--current-bg); }
.word-input.correct { color: var(--correct); border-bottom-color: var(--correct); background: var(--correct-bg); }
.word-input.wrong { color: var(--wrong); border-bottom-color: var(--wrong); background: var(--wrong-bg); }

.spelling-hint {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  padding: 0.35rem 0.55rem; border-radius: 8px; background: var(--accent-soft);
  border: 2px solid var(--line); color: var(--line);
  font-size: 0.82rem; font-weight: 800; white-space: nowrap; z-index: 5; pointer-events: none;
}

.spelling-hint.hidden { display: none; }

.hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 1rem; text-align: center; }
.hint.highlight { color: var(--accent); }
.hint.success { color: var(--correct); font-weight: 800; }
.quiz-action-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}
.quiz-action-row.hidden { display: none; }
.quiz-tool-pair {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}
.quiz-tool-btn {
  min-width: 5.5rem;
  padding: 0.45rem 0.95rem;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--line);
  box-shadow: 3px 4px 0 var(--line);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.quiz-tool-btn:hover {
  background: var(--accent-soft);
  transform: translate(-1px, -1px);
  box-shadow: 4px 5px 0 var(--line);
}
.quiz-tool-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 2px 0 var(--line);
}
.quiz-tool-btn:focus-visible {
  outline: 3px solid rgba(169, 144, 246, 0.45);
  outline-offset: 2px;
}
.quiz-submit-btn {
  width: calc(11rem + 0.75rem);
  min-height: 3.05rem;
  background: var(--accent);
  font-size: 1rem;
}
.quiz-submit-btn:hover {
  background: var(--accent-hover);
}

.completion-section {
  margin-top: 1.25rem; padding: 1.25rem 1rem; border-radius: 14px;
  border: 3px solid var(--line); background: var(--mint-soft); text-align: center;
}

.completion-section.hidden { display: none; }
.completion-badge { display: inline-block; padding: 0.25rem 0.75rem; margin-bottom: 1rem; border-radius: 999px; border: 2px solid var(--line); background: var(--correct-bg); color: var(--line); font-size: 0.85rem; font-weight: 900; }
.completion-english {
  margin: 0.35rem 0 0.45rem;
}
.completion-english .word-gloss.empty {
  display: none;
}
.completion-chinese { font-size: 1.1rem; margin: 0 0 1.15rem; }
.completion-prompt { color: var(--accent); font-weight: 600; animation: pulse 1.6s ease-in-out infinite; }
.completion-space-btn {
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  background: var(--peach-soft);
  border: 2px solid var(--line);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9em;
  font-weight: 900;
  line-height: 1;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.completion-space-btn:hover {
  background: var(--peach);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--line);
}
.completion-space-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}
.completion-space-btn:focus-visible {
  outline: 3px solid rgba(169, 144, 246, 0.45);
  outline-offset: 2px;
}

.word-slot { display: inline-flex; flex-direction: column; align-items: center; vertical-align: bottom; margin: 0 0.06em; }
.word-gloss { font-size: 0.62em; color: var(--accent-hover); min-height: 1.3em; margin-bottom: 0.15em; }
.word-gloss.empty { visibility: hidden; }
.word-readonly { color: var(--correct); border-bottom: 2px solid var(--correct); padding: 0 0.1em; }

.feedback { margin-top: 1rem; text-align: center; min-height: 1.5rem; }
.feedback.success { color: var(--correct); }
.feedback.error { color: var(--wrong); }

.btn {
  padding: 0.65rem 1.15rem;
  border: 3px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 900;
  color: var(--line);
  box-shadow: 4px 5px 0 var(--line);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 6px 0 var(--line); }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 3px 0 var(--line); }
.btn-primary { background: var(--accent); color: var(--line); }

@keyframes mobile-button-tap {
  0% { transform: translate(0, 0); }
  42% { transform: translate(2px, 2px); }
  100% { transform: translate(0, 0); }
}

@media (pointer: coarse) {
  .btn:hover,
  .btn:active,
  .podcast-controls .btn.btn-control:hover,
  .podcast-controls .btn.btn-control:active,
  .podcast-favorite-btn:hover,
  .podcast-favorite-btn:active,
  .podcast-srt-lang-btn:hover,
  .podcast-srt-lang-btn:active,
  .btn-key-phrases:hover,
  .btn-key-phrases:active,
  .btn-vocab-quiz:hover,
  .btn-vocab-quiz:active,
  .quiz-tool-btn:hover,
  .quiz-tool-btn:active,
  .completion-space-btn:hover,
  .completion-space-btn:active {
    transform: translate(0, 0);
  }

  .btn.mobile-tap-feedback,
  .podcast-favorite-btn.mobile-tap-feedback,
  .podcast-srt-lang-btn.mobile-tap-feedback,
  .btn-key-phrases.mobile-tap-feedback,
  .btn-vocab-quiz.mobile-tap-feedback,
  .quiz-tool-btn.mobile-tap-feedback,
  .completion-space-btn.mobile-tap-feedback {
    animation: mobile-button-tap 0.18s ease-out;
  }
}

/* Podcast controls — after .btn so padding/height are not overridden */
.podcast-controls .btn.btn-control {
  min-width: 3.5rem;
  width: auto;
  height: 2.75rem;
  min-height: 2.75rem;
  max-height: 2.75rem;
  padding: 0 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text);
  border: 3px solid var(--line);
  box-shadow: 3px 4px 0 var(--line);
}
.podcast-controls .btn.btn-control:hover { border-color: var(--line); background: var(--accent-soft); color: var(--line); }
.podcast-controls .btn.btn-control.btn-play {
  min-width: 4rem;
  width: 4rem;
  max-width: 4rem;
  padding: 0;
  background: var(--accent);
  color: var(--line);
  border-color: var(--line);
}
.podcast-controls .btn.btn-control.btn-play.is-playing { background: var(--peach); }
.podcast-controls .btn-play-icon {
  position: relative;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  display: inline-block;
  line-height: 1;
  color: var(--line);
}
.podcast-controls .btn-play-icon::before {
  content: "";
  position: absolute;
  left: 0.28rem;
  top: 0.12rem;
  width: 0;
  height: 0;
  border-top: 0.45rem solid transparent;
  border-bottom: 0.45rem solid transparent;
  border-left: 0.68rem solid var(--line);
}
.podcast-controls .btn-play-icon.is-pause::before,
.podcast-controls .btn-play-icon.is-pause::after {
  content: "";
  position: absolute;
  top: 0.12rem;
  width: 0.28rem;
  height: 0.9rem;
  border: 0;
  border-radius: 2px;
  background: var(--line);
}
.podcast-controls .btn-play-icon.is-pause::before { left: 0.22rem; }
.podcast-controls .btn-play-icon.is-pause::after { right: 0.22rem; }

.modal { position: fixed; inset: 0; background: rgba(20,18,16,0.42); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(4px); }
.modal.hidden { display: none; }
.modal-content { background: var(--surface); border: 3px solid var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; max-width: 360px; box-shadow: var(--shadow); }

.auth-modal { z-index: 200; }
.auth-modal-content { width: min(92vw, 380px); text-align: left; padding: 1.75rem; }
.auth-title { text-align: center; margin-bottom: 1.25rem; font-size: 1.25rem; }
.auth-field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.85rem; }
.auth-field span { font-size: 0.82rem; color: var(--text-muted); }
.auth-field input {
  padding: 0.7rem 0.8rem; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 0.95rem;
}
.auth-field input:focus { outline: 3px solid rgba(169, 144, 246, 0.34); border-color: var(--line); background: var(--surface); }
@media (max-width: 720px) {
  /* iPhone Safari zooms the page when a focused form field is smaller than 16px. */
  html.device-mobile .auth-field input,
  html.device-mobile .auth-field textarea,
  html.device-mobile .profile-share-url {
    font-size: 16px;
  }
}
.auth-submit { width: 100%; margin-top: 0.25rem; }
.auth-toggle { width: 100%; margin-top: 0.65rem; }
.auth-message { min-height: 1.25rem; font-size: 0.85rem; margin-bottom: 0.5rem; }
.auth-message.is-error { color: var(--wrong); }
.auth-message.is-ok { color: var(--correct); }
.auth-helper { margin: -0.2rem 0 1rem; color: var(--text-muted); font-size: 0.85rem; line-height: 1.55; }
.auth-checkbox-row { display: flex; align-items: flex-start; gap: 0.55rem; margin: 0.15rem 0 0.9rem; color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }
.auth-checkbox-row input { width: 1rem; height: 1rem; margin: 0.1rem 0 0; accent-color: var(--accent); flex: 0 0 auto; }

body.auth-locked .layout { pointer-events: none; user-select: none; filter: blur(2px); }

.profile-panel {
  position: fixed; inset: 0; z-index: 150; background: rgba(20,18,16,0.38);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  backdrop-filter: blur(4px);
}
.profile-panel.hidden { display: none; }
.profile-panel-inner {
  width: min(92vw, 420px); max-height: min(90vh, 640px); overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); padding: 1.5rem;
  border: 3px solid var(--line); box-shadow: var(--shadow);
}
.profile-panel-inner.is-ledger {
  width: min(96vw, 1080px);
  height: min(92dvh, 760px);
  max-height: min(92dvh, 760px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}
.profile-panel-inner.is-ledger .profile-header { flex: 0 0 auto; margin-bottom: 0.65rem; }
.profile-panel-inner.is-ledger #profileLedgerView:not(.hidden) {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.profile-panel-inner.is-ledger #profileDashboardView:not(.hidden) {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.profile-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.profile-header h2 { flex: 1; font-size: 1.15rem; text-align: center; margin: 0; }
.profile-back {
  width: 2rem; height: 2rem; border: 2px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--line); font-size: 1.1rem; cursor: pointer;
}
.profile-back.hidden { visibility: hidden; pointer-events: none; }
.profile-back:hover { color: var(--text); }
.profile-close {
  width: 2rem; height: 2rem; border: 2px solid var(--line); border-radius: 8px;
  background: var(--peach-soft); color: var(--line); font-size: 1.25rem; cursor: pointer;
}
.profile-close:hover { color: var(--text); }
.profile-view.hidden { display: none; }
.profile-section { margin-bottom: 1.25rem; padding-top: 0.25rem; border-top: 2px solid var(--line-soft); }
.profile-section:first-child { border-top: none; padding-top: 0; }
.profile-section h3 { font-size: 0.95rem; margin-bottom: 0.65rem; color: var(--accent-hover); }
.profile-menu-list { display: flex; flex-direction: column; gap: 0.45rem; }
.profile-menu-list .profile-menu-btn { margin-bottom: 0; }
.profile-menu-btn {
  display: block; width: 100%; text-align: left; padding: 0.65rem 0.85rem; margin-bottom: 0.45rem;
  border: 2px solid var(--line); border-radius: 10px; background: var(--surface-2);
  color: var(--text); font-size: 0.92rem; cursor: pointer;
  box-shadow: 3px 4px 0 var(--line);
}
.profile-menu-btn:hover { border-color: var(--line); background: var(--accent-soft); }
.profile-menu-btn-danger { color: var(--line); border-color: var(--line); background: var(--wrong-bg); }
.profile-menu-btn-danger:hover { border-color: var(--line); background: #ffd6d6; }
.profile-account-name {
  font-size: 1.15rem; font-weight: 600; margin: 0 0 1rem; color: var(--text); text-align: center;
}
.profile-subsection { margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 2px solid var(--line-soft); }
.profile-subsection:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.profile-subsection-title { font-size: 0.9rem; color: var(--accent-hover); margin: 0 0 0.65rem; font-weight: 900; }
.profile-stat { font-size: 0.92rem; margin-bottom: 0.75rem; color: var(--text-muted); }
.profile-stat strong { color: var(--text); font-size: 1.15rem; }
.profile-hint, .profile-pref-hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.5rem; line-height: 1.45; }
.profile-empty { font-size: 0.9rem; color: var(--text-muted); text-align: center; padding: 1.5rem 0; }
.profile-history-list { list-style: none; padding: 0; margin: 0; }
.profile-history-item {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0; border-bottom: 2px solid var(--line-soft); font-size: 0.9rem;
}
.profile-history-ep { font-weight: 500; }
.profile-history-time { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }
.profile-captcha-row { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.85rem; }
.profile-captcha-img {
  width: 180px; height: 52px; object-fit: contain;
  border-radius: 10px; border: 2px solid var(--line); background: var(--surface-2);
}
.profile-success { text-align: center; color: var(--correct); font-size: 1.05rem; margin: 2rem 0 1.5rem; }
.profile-status-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }
.profile-status-value { font-size: 1.35rem; font-weight: 600; text-align: center; margin: 1.5rem 0; color: var(--text-muted); }
.profile-status-value.is-active { color: var(--correct); }
.profile-status-divider { height: 1px; background: var(--line); margin: 1.4rem 0; }
.profile-status-email { margin: 0.35rem 0 1rem; overflow-wrap: anywhere; text-align: center; font-weight: 600; }
.profile-email-state { margin: 0.25rem 0 1rem; font-size: 1.05rem; }
.profile-email-state.is-active { margin-top: 0; }
.profile-email-verify-btn { width: 100%; }
.profile-pref-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.profile-pref-row-spaced { margin-top: 1.25rem; }
.profile-switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.profile-switch input { opacity: 0; width: 0; height: 0; }
.profile-switch-slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 26px;
  background: var(--surface-2); border: 2px solid var(--line); transition: background 0.2s;
}
.profile-switch-slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 2px;
  background: var(--line); border-radius: 50%; transition: transform 0.2s;
}
.profile-switch input:checked + .profile-switch-slider { background: var(--accent); }
.profile-switch input:checked + .profile-switch-slider::before { transform: translateX(22px); }
.profile-share-row { display: flex; gap: 0.5rem; align-items: stretch; }
.profile-share-url {
  flex: 1; padding: 0.55rem 0.65rem; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: 0.85rem;
}
.auth-field textarea {
  padding: 0.55rem 0.65rem; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 0.92rem; resize: vertical;
}
.auth-field textarea:focus { outline: 3px solid rgba(169, 144, 246, 0.34); border-color: var(--line); background: var(--surface); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

.ledger-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}
.ledger-summary-item {
  min-height: 3.45rem;
  padding: 0.5rem 0.65rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.ledger-summary-item span { display: block; color: var(--text-muted); font-size: 0.74rem; }
.ledger-summary-item strong { display: block; margin-top: 0.05rem; color: var(--text); font-size: 1.2rem; }
.ledger-section,
.ledger-edit {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 2px solid var(--line-soft);
}
.ledger-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.ledger-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem; }
.ledger-section h3,
.ledger-edit h3 { margin: 0; color: var(--accent-hover); font-size: 0.95rem; }
.ledger-filters {
  display: grid;
  grid-template-columns: minmax(11rem, 1.6fr) repeat(3, minmax(7rem, 1fr)) auto;
  gap: 0.55rem;
  align-items: end;
}
.ledger-filters input,
.ledger-filters select {
  min-width: 0;
  min-height: 2.4rem;
  padding: 0.45rem 0.6rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
}
.ledger-create-grid,
.ledger-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.ledger-create-grid > form {
  min-width: 0;
}
.ledger-create-grid h3 { margin: 0 0 0.75rem; color: var(--accent-hover); font-size: 0.95rem; }
.ledger-create-grid .auth-field,
.ledger-edit .auth-field { margin-bottom: 0.7rem; }
.ledger-table-wrap {
  overflow: hidden;
  margin-top: 0.4rem;
  border: 2px solid var(--line);
  border-radius: 10px;
}
.ledger-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: collapse; background: var(--surface); }
.ledger-table th,
.ledger-table td { padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; }
.ledger-table th { background: var(--surface-2); color: var(--text-muted); font-size: 0.72rem; font-weight: 900; white-space: nowrap; }
.ledger-table tr:last-child td { border-bottom: none; }
.ledger-code { font-family: Consolas, "Courier New", monospace; font-weight: 900; white-space: nowrap; }
.ledger-cell-muted { color: var(--text-muted); font-size: 0.74rem; }
.ledger-status {
  display: inline-block;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
  white-space: nowrap;
}
.ledger-status.available { background: var(--accent-soft); color: var(--line); }
.ledger-status.sold { background: var(--peach-soft); color: var(--line); }
.ledger-status.redeemed { background: #d9f4df; color: #166534; }
.ledger-row-edit { padding: 0.28rem 0.5rem; font-size: 0.75rem; }
.ledger-pagination { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-top: 0.45rem; font-size: 0.82rem; color: var(--text-muted); }
.ledger-pagination .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: 3px 4px 0 var(--line); }
.ledger-edit-code { margin: 0 0 0.75rem; color: var(--text); font-family: Consolas, "Courier New", monospace; font-weight: 900; }
.ledger-sold-toggle { display: flex; align-items: center; gap: 0.45rem; margin: 0.15rem 0 0.85rem; color: var(--text); font-size: 0.88rem; font-weight: 700; }
.ledger-generated {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.55rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--accent-soft);
}
.ledger-generated-label { display: block; color: var(--text-muted); font-size: 0.72rem; }
.ledger-generated-codes { display: block; margin-top: 0.08rem; color: var(--line); font-family: Consolas, "Courier New", monospace; font-size: 1rem; letter-spacing: 0; }
.ledger-generated-note { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.72rem; }
.profile-panel-inner.is-ledger #ledgerDataSection { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; }
.profile-panel-inner.is-ledger #ledgerDataSection .ledger-table-wrap { flex: 1 1 auto; }
.profile-panel-inner.is-ledger .ledger-compose-open {}
.profile-panel-inner.is-ledger #profileLedgerView.ledger-compose-open .ledger-summary,
.profile-panel-inner.is-ledger #profileLedgerView.ledger-compose-open #ledgerFilterSection,
.profile-panel-inner.is-ledger #profileLedgerView.ledger-compose-open #ledgerDataSection,
.profile-panel-inner.is-ledger #profileLedgerView.ledger-compose-open .ledger-generated { display: none; }
.profile-panel-inner.is-ledger #profileLedgerView.ledger-compose-open #ledgerCreateArea { display: block; flex: 1 1 auto; }
.profile-panel-inner.is-ledger #profileLedgerView.ledger-compose-open .ledger-edit:not(.hidden) {
  display: block;
  flex: 1 1 auto;
}
.dashboard-tabs { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.35rem; }
.dashboard-tab { min-height: 2.1rem; padding: 0.35rem 0.65rem; border: 2px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.8rem; font-weight: 800; cursor: pointer; }
.dashboard-tab.active { background: var(--accent); }
.dashboard-refresh { margin-left: auto; }
.dashboard-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.55rem; margin-bottom: 0.7rem; }
.dashboard-summary-item { min-height: 3.45rem; padding: 0.5rem 0.65rem; border: 2px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.dashboard-summary-item span { display: block; color: var(--text-muted); font-size: 0.74rem; }
.dashboard-summary-item strong { display: block; margin-top: 0.05rem; font-size: 1.2rem; }
.dashboard-section { margin-top: 0.65rem; padding-top: 0.65rem; border-top: 2px solid var(--line-soft); }
.dashboard-section h3 { margin: 0 0 0.55rem; color: var(--accent-hover); font-size: 0.95rem; }
.dashboard-feature-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; }
.dashboard-feature-item { padding: 0.45rem 0.55rem; border: 2px solid var(--line-soft); border-radius: 8px; background: var(--surface-2); }
.dashboard-feature-item span { display: block; color: var(--text-muted); font-size: 0.72rem; }
.dashboard-feature-item strong { display: block; margin-top: 0.1rem; font-size: 0.95rem; }
.dashboard-table-wrap { overflow: auto; border: 2px solid var(--line); border-radius: 8px; background: var(--surface); }
.dashboard-table { width: 100%; min-width: 46rem; border-collapse: collapse; }
.dashboard-table th, .dashboard-table td { padding: 0.48rem 0.55rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; font-size: 0.78rem; }
.dashboard-table th { color: var(--text-muted); background: var(--surface-2); font-size: 0.7rem; white-space: nowrap; }
.dashboard-table tr:last-child td { border-bottom: none; }
.dashboard-muted { color: var(--text-muted); }
.dashboard-online { color: var(--correct); font-weight: 800; }
.dashboard-offline { color: var(--text-muted); }
.dashboard-account-filter { display: flex; gap: 0.55rem; margin-bottom: 0.6rem; }
.dashboard-account-filter input { flex: 1; min-width: 0; min-height: 2.35rem; padding: 0.45rem 0.6rem; border: 2px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; }
.dashboard-activation { white-space: nowrap; }
.dashboard-account-action { padding: 0.28rem 0.45rem; font-size: 0.72rem; }

@media (max-width: 720px) {
  .profile-panel { padding: 0.4rem; }
  .profile-panel-inner.is-ledger {
    width: calc(100vw - 0.8rem);
    height: calc(100dvh - 0.8rem);
    max-height: calc(100dvh - 0.8rem);
    padding: 0.7rem;
    border-radius: 14px;
  }
  .profile-panel-inner.is-ledger .profile-header h2 { font-size: 1.05rem; }
  .profile-panel-inner.is-ledger .profile-back,
  .profile-panel-inner.is-ledger .profile-close { width: 2.4rem; height: 2.4rem; }
  .ledger-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.35rem; }
  .ledger-summary-item { min-height: 3rem; padding: 0.4rem; }
  .ledger-summary-item span { font-size: 0.62rem; }
  .ledger-summary-item strong { font-size: 1rem; }
  .ledger-section-head { align-items: center; }
  .ledger-section h3 { font-size: 0.88rem; }
  .ledger-actions { gap: 0.25rem; }
  .ledger-actions .btn { padding: 0.3rem 0.45rem; font-size: 0.72rem; }
  .ledger-filters { grid-template-columns: 1fr 1fr; gap: 0.35rem; }
  .ledger-filters input { grid-column: 1 / -1; }
  .ledger-filters select { min-height: 2.1rem; padding: 0.3rem 0.4rem; font-size: 0.74rem; }
  .ledger-filters select:nth-of-type(3) { display: none; }
  .ledger-filters .btn { display: none; }
  .ledger-create-grid,
  .ledger-edit-grid { grid-template-columns: 1fr; gap: 0.4rem; }
  .ledger-create-grid > form { max-width: none; }
  .ledger-table-wrap { border: 0; border-radius: 0; }
  .ledger-table,
  .ledger-table tbody,
  .ledger-table tr,
  .ledger-table td { display: block; width: 100%; }
  .ledger-table thead { display: none; }
  .ledger-table tr {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.15rem 0.5rem;
    margin-bottom: 0.35rem;
    padding: 0.45rem 0.5rem;
    border: 2px solid var(--line-soft);
    border-radius: 8px;
    background: var(--surface-2);
  }
  .ledger-table td { min-width: 0; padding: 0; border: 0; white-space: nowrap; }
  .ledger-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .ledger-table td:nth-child(4) { grid-column: 2; grid-row: 1; }
  .ledger-table td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .ledger-table td:nth-child(3) { grid-column: 1; grid-row: 3; }
  .ledger-table td:nth-child(5) { display: none; }
  .ledger-table td:nth-child(6) { grid-column: 2; grid-row: 2 / span 2; align-self: end; width: auto; }
  .ledger-row-edit { padding: 0.22rem 0.45rem; }
  .ledger-pagination { margin-top: 0.2rem; }
  .ledger-generated { align-items: flex-start; }
  .ledger-generated .ledger-actions { flex-shrink: 0; }
  .ledger-generated .btn { padding: 0.28rem 0.42rem; font-size: 0.7rem; }
  .ledger-generated-codes { max-width: 13rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dashboard-summary, .dashboard-feature-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-summary-item { min-height: 3rem; padding: 0.4rem; }
  .dashboard-summary-item span, .dashboard-feature-item span { font-size: 0.68rem; }
  .dashboard-summary-item strong { font-size: 1rem; }
  .dashboard-table { min-width: 42rem; }
}

.celebration-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 90; }
.celebration-canvas.hidden { display: none; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes heart-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.38) rotate(-6deg); }
  70% { transform: scale(0.92) rotate(4deg); }
  100% { transform: scale(1); }
}
@keyframes heart-spark {
  0% { opacity: 0; transform: scale(0.55); }
  30% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1.8); }
}

@media (max-width: 1180px) {
  .layout > .app {
    max-width: none;
    padding: 1.35rem 1.1rem 2.25rem;
  }
  .podcast-player { padding: 1rem; }
  .view-learn .podcast-visual { max-height: min(50vh, 430px); }
  .podcast-srt-line { font-size: 1.72rem; }
}

@media (max-width: 1024px) and (pointer: coarse) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100% !important;
    border-right: none;
    border-bottom: 3px solid var(--line);
  }
  .sidebar-inner {
    width: 100%;
    min-height: 0;
    max-height: 42vh;
    padding: calc(1rem + env(safe-area-inset-top, 0px)) 1rem 1rem;
  }
  .layout.sidebar-collapsed .sidebar {
    width: 0 !important;
    border-bottom-color: transparent;
  }
  .sidebar-toggle {
    align-self: flex-end;
    width: 100%;
    min-height: 0;
    height: 30px;
    margin: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 10px 10px;
  }
  .layout > .app {
    padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom, 0px));
  }
  .level-list,
  .episode-list,
  .corpus-list {
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  }
  .podcast-controls-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .podcast-left-tools,
  .podcast-controls-row .podcast-controls,
  .podcast-controls-extra {
    grid-column: 1;
    justify-self: center;
  }
  .podcast-controls { flex-wrap: wrap; }
  .podcast-srt-line { font-size: 1.56rem; }
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100% !important; border-right: none; border-bottom: 3px solid var(--line); }
  .sidebar-inner { width: 100%; min-height: 0; padding: 1rem; }
  .layout.sidebar-collapsed .sidebar { width: 0 !important; border-bottom-color: transparent; }
  .sidebar-toggle {
    align-self: flex-end;
    width: 100%;
    min-height: 0;
    height: 28px;
    margin: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 10px 10px;
  }
  .corpus-list { flex-direction: row; flex-wrap: wrap; }
  .layout > .app { padding: 1rem 0.9rem 2rem; }
  .header { padding: 1rem; box-shadow: 4px 5px 0 var(--accent); }
  .learn-title-row { align-items: flex-start; }
  .podcast-controls-row { grid-template-columns: 1fr; gap: 0.8rem; }
  .podcast-left-tools,
  .podcast-srt-toggle,
  .podcast-controls-row .podcast-controls,
  .podcast-controls-extra {
    grid-column: 1;
    justify-self: center;
  }
  .sentence-card,
  .podcast-player,
  .unspaced-item {
    box-shadow: 4px 5px 0 var(--line);
  }
}

html.device-desktop .view-learn .podcast-player,
html.device-desktop .view-ear .podcast-player,
html.device-ipad .view-learn .podcast-player,
html.device-ipad .view-ear .podcast-player {
  padding: 1.15rem 1.25rem 1.35rem;
}

html.device-desktop .layout > .app {
  padding-top: 0.85rem;
  padding-bottom: 1rem;
}

html.device-desktop .header-learn {
  margin-bottom: 0.55rem;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

html.device-desktop .view-learn .podcast-player,
html.device-desktop .view-ear .podcast-player {
  padding: 0.95rem 1.1rem 1.05rem;
}

html.device-desktop .view-learn .podcast-visual,
html.device-desktop .view-ear .podcast-visual,
html.device-ipad .view-learn .podcast-visual,
html.device-ipad .view-ear .podcast-visual {
  max-height: min(56vh, 520px);
  margin-bottom: 1.15rem;
}

html.device-desktop .view-learn .podcast-visual,
html.device-desktop .view-ear .podcast-visual {
  max-height: min(54vh, 500px);
  margin-bottom: 0.95rem;
}

html.device-desktop .podcast-meta,
html.device-ipad .podcast-meta {
  margin-bottom: 1rem;
}

html.device-desktop .podcast-meta {
  margin-bottom: 0.75rem;
}

html.device-desktop .podcast-progress-wrap,
html.device-ipad .podcast-progress-wrap {
  margin-bottom: 1.3rem;
}

html.device-desktop .podcast-progress-wrap {
  margin-bottom: 1rem;
}

html.device-desktop .podcast-controls-row,
html.device-ipad .podcast-controls-row {
  grid-template-columns: minmax(14rem, 1fr) auto minmax(14rem, 1fr);
  grid-template-areas: "left controls extra";
  align-items: center;
  column-gap: 1.25rem;
  row-gap: 0;
  min-height: 3.25rem;
}

html.device-desktop .podcast-controls-row {
  min-height: 3rem;
}

html.device-desktop .podcast-left-tools,
html.device-ipad .podcast-left-tools {
  justify-self: start;
  gap: 0.75rem;
}

html.device-desktop .podcast-controls-row .podcast-controls,
html.device-ipad .podcast-controls-row .podcast-controls {
  justify-self: center;
  gap: 0.9rem;
}

html.device-desktop .podcast-controls-extra,
html.device-ipad .podcast-controls-extra {
  justify-self: end;
  gap: 0.65rem;
}

@media (max-width: 720px) {
  body { overflow-x: hidden; }
  .layout {
    flex-direction: row;
    min-height: 100dvh;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 55;
    width: min(86vw, 320px) !important;
    border-right: 3px solid var(--line);
    border-bottom: none;
    box-shadow: 8px 0 0 var(--line);
    transform: translateX(0);
    transition: transform 0.22s ease;
  }
  .sidebar-inner {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: calc(0.85rem + env(safe-area-inset-top, 0px)) 0.75rem calc(1rem + env(safe-area-inset-bottom, 0px));
  }
  .layout.sidebar-collapsed .sidebar {
    width: min(86vw, 320px) !important;
    border-right-color: var(--line);
    border-bottom-color: transparent;
    transform: translateX(-104%);
  }
  .sidebar-toggle {
    position: fixed;
    left: min(86vw, 320px);
    top: 50%;
    z-index: 56;
    width: 28px;
    min-height: 72px;
    height: 72px;
    margin: 0;
    border: 3px solid var(--line);
    border-left: none;
    border-radius: 0 12px 12px 0;
    transform: translateY(-50%);
    transition: left 0.22s ease, background 0.15s;
  }
  .layout.sidebar-collapsed .sidebar-toggle {
    left: 0;
  }
  .sidebar-start-guide {
    position: fixed;
    left: 2.65rem;
    top: 50%;
    z-index: 57;
    display: block;
    width: max-content;
    max-width: min(13rem, calc(100vw - 3.5rem));
    padding: 0.5rem 0.65rem;
    border: 2px solid var(--line);
    border-radius: 8px;
    background: var(--accent);
    color: var(--line);
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1.25;
    box-shadow: 3px 4px 0 var(--line);
    transform: translateY(-50%);
    pointer-events: none;
    animation: sidebar-guide-pulse 1.6s ease-in-out infinite;
  }
  .sidebar-start-guide.hidden { display: none; }
  .sidebar-start-guide::before {
    content: "";
    position: absolute;
    left: -0.45rem;
    top: 50%;
    width: 0.65rem;
    height: 0.65rem;
    background: var(--accent);
    border-left: 2px solid var(--line);
    border-bottom: 2px solid var(--line);
    transform: translateY(-50%) rotate(45deg);
  }
  .layout > .app { padding: 0.85rem 0.65rem calc(1.6rem + env(safe-area-inset-bottom, 0px)); }
  .sidebar-header-row { align-items: center; margin-bottom: 0.7rem; }
  .sidebar-header h2 { font-size: 1.25rem; }
  .mode-nav { gap: 0.25rem; padding: 0.25rem; }
  .mode-nav-btn { min-height: 2.5rem; padding: 0.45rem 0.5rem; font-size: 0.9rem; }
  .header {
    margin-bottom: 0.85rem;
    padding: 0.85rem 0.9rem;
    border-width: 3px;
    border-radius: 14px;
  }
  .header h1,
  .header-learn h1,
  .view-ear .header.header-learn h1,
  .view-test .header.header-learn h1,
  .learn-quiz-title-row h1 { font-size: 1.55rem; }
  .view-ear .header {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .learn-title-row .subtitle { font-size: 0.78rem; }
  html.device-mobile #learnPlayerHeader {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 0.65rem;
  }
  html.device-mobile #learnPlayerHeader .learn-title-row {
    grid-column: 1;
    flex: none;
  }
  html.device-mobile #learnPlayerHeader .mobile-player-title {
    display: block;
    grid-column: 2;
    justify-self: center;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.08rem 0.48rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.48);
    color: var(--text);
    font-size: 1.08rem;
    font-weight: 900;
    line-height: 1.25;
    text-align: center;
  }
  html.device-mobile body.theme-dark #learnPlayerHeader .mobile-player-title {
    background: rgba(255, 255, 255, 0.08);
  }
  html.device-mobile #learnPlayerHeader .header-theme-btn {
    grid-column: 3;
    justify-self: end;
  }
  .podcast-player {
    padding: 0.65rem;
    border-radius: 14px;
  }
  .view-learn .podcast-player {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 8.4rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .podcast-visual {
    aspect-ratio: 4 / 3;
    margin-bottom: 1rem;
    border-radius: 12px;
  }
  .view-learn .podcast-visual { max-height: 48vh; }
  .podcast-bg {
    transform: none;
    object-position: center center;
  }
  .podcast-srt-track {
    padding: 0.75rem 0.65rem;
    gap: 0.25rem;
  }
  .podcast-srt-line {
    font-size: 1.28rem;
    line-height: 1.16;
  }
  .podcast-meta { margin-bottom: 0.85rem; }
  .podcast-title { font-size: 1rem; }
  .podcast-time { font-size: 0.78rem; }
  .podcast-progress-wrap { margin-bottom: 1rem; }
  html.device-mobile .view-learn .podcast-visual { order: 1; margin-bottom: 0; }
  html.device-mobile .view-learn .podcast-meta { display: contents; }
  html.device-mobile .view-learn .podcast-title { display: none; }
  html.device-mobile .view-learn .podcast-time {
    order: 4;
    margin: 0.35rem 0 0.95rem;
    text-align: center;
    font-size: 0.92rem;
  }
  html.device-mobile .view-learn .podcast-progress-wrap {
    order: 3;
    margin: 0.9rem 0 0.3rem;
  }
  html.device-mobile .view-learn .podcast-controls-row {
    display: contents;
  }
  html.device-mobile .view-learn .podcast-left-tools {
    order: 2;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    justify-content: stretch;
    justify-self: stretch;
    width: 100%;
    margin-top: 0.85rem;
    gap: 0.7rem;
  }
  html.device-mobile .view-learn .podcast-srt-lang-btn {
    grid-column: 1;
    order: 1;
    justify-self: start;
  }
  html.device-mobile .view-learn .podcast-srt-toggle {
    grid-column: 2;
    order: 2;
    justify-self: start;
  }
  html.device-mobile .view-learn .podcast-favorite-btn {
    grid-column: 4;
    order: 4;
    justify-self: end;
  }
  html.device-mobile .view-learn .podcast-controls {
    order: 5;
    justify-content: center;
    width: 100%;
    gap: 0.85rem;
    margin-bottom: 1.05rem;
  }
  html.device-mobile .view-learn .podcast-controls-extra {
    order: 6;
    justify-content: center;
    width: 100%;
    gap: 0.85rem;
    margin-top: auto;
  }
  html.device-mobile .view-learn .podcast-controls .btn.btn-control {
    min-width: 3.75rem;
    height: 2.9rem;
    min-height: 2.9rem;
    max-height: 2.9rem;
    font-size: 1rem;
  }
  html.device-mobile .view-learn .podcast-controls .btn-play {
    min-width: 4.75rem;
    width: 4.75rem;
    max-width: 4.75rem;
  }
  html.device-mobile .view-ear .podcast-player {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 8.4rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  html.device-mobile .view-ear .podcast-visual {
    order: 1;
    max-height: 48vh;
    margin-bottom: 0;
  }
  html.device-mobile .view-ear .podcast-meta { display: contents; }
  html.device-mobile .view-ear .podcast-title {
    order: 2;
    margin: 0.8rem 0 0;
    font-size: 1rem;
    text-align: center;
  }
  html.device-mobile .view-ear .podcast-time {
    order: 5;
    margin: 0.35rem 0 0.95rem;
    text-align: center;
    font-size: 0.92rem;
  }
  html.device-mobile .view-ear .podcast-progress-wrap {
    order: 4;
    margin: 0.9rem 0 0.3rem;
  }
  html.device-mobile .view-ear .podcast-controls-row { display: contents; }
  html.device-mobile .view-ear .podcast-left-tools {
    order: 3;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    justify-self: stretch;
    width: 100%;
    margin-top: 0.85rem;
    gap: 0.7rem;
  }
  html.device-mobile .view-ear .podcast-srt-lang-btn {
    grid-column: 1;
    grid-row: 1;
    order: 1;
    justify-self: start;
  }
  html.device-mobile .view-ear .podcast-srt-toggle {
    grid-column: 2;
    grid-row: 1;
    order: 2;
    justify-self: start;
  }
  html.device-mobile .view-ear .podcast-favorite-btn {
    grid-column: 4;
    grid-row: 1;
    order: 4;
    justify-self: end;
  }
  html.device-mobile .view-ear .podcast-controls {
    order: 6;
    justify-content: center;
    width: 100%;
    gap: 0.85rem;
    margin-top: auto;
    margin-bottom: 1.05rem;
  }
  html.device-mobile .view-ear .podcast-controls .btn.btn-control {
    min-width: 3.75rem;
    height: 2.9rem;
    min-height: 2.9rem;
    max-height: 2.9rem;
    font-size: 1rem;
  }
  html.device-mobile .view-ear .podcast-controls .btn-play {
    min-width: 4.75rem;
    width: 4.75rem;
    max-width: 4.75rem;
  }
  .podcast-controls-row {
    margin-top: auto;
    gap: 1.05rem;
    padding-top: 0.8rem;
    padding-bottom: 0.35rem;
  }
  .podcast-left-tools {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.8rem;
  }
  .podcast-controls {
    width: 100%;
    gap: 0.72rem;
  }
  .podcast-controls-extra {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .podcast-favorite-btn,
  .podcast-srt-lang-btn,
  .podcast-controls .btn.btn-control {
    min-width: 3.05rem;
    width: auto;
    height: 2.45rem;
    min-height: 2.45rem;
    max-height: 2.45rem;
    border-radius: 12px;
  }
  .podcast-srt-lang-btn {
    width: 4.45rem;
    min-width: 4.45rem;
    max-width: 4.45rem;
  }
  .podcast-favorite-btn {
    width: 3.05rem;
    max-width: 3.05rem;
    min-height: 2.45rem;
    max-height: 2.45rem;
    padding: 0;
  }
  .header-theme-btn {
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.35rem;
    min-height: 2.35rem;
    max-height: 2.35rem;
    border-radius: 12px;
  }
  .header-theme-btn .theme-icon {
    width: 1.32rem;
    height: 1.32rem;
  }
  .header-theme-btn .theme-icon-moon {
    width: 1.18rem;
    height: 1.18rem;
  }
  .header-theme-glyph {
    width: 1.12rem;
    height: 1.12rem;
    font-size: 1.12rem;
  }
  .podcast-controls .btn.btn-control {
    padding: 0 0.8rem;
    font-size: 0.9rem;
  }
  .btn-key-phrases,
  .btn-vocab-quiz {
    min-height: 2.45rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
  }
  .sentence-card { padding: 1rem 0.75rem; }
  .test-level-panel { padding: 0 0.65rem 1.5rem; }
  .test-level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .test-level-choice { min-height: 4.2rem; font-size: 1.08rem; }
  .sentence-display { font-size: 1.05rem; }
  .quiz-tool-btn {
    min-width: 5.2rem;
    min-height: 2.8rem;
    font-size: 0.96rem;
  }
  .quiz-submit-btn {
    width: min(100%, calc(10.4rem + 0.75rem));
    min-height: 3.25rem;
    font-size: 1.05rem;
  }
  .completion-section { padding: 1rem 0.65rem; }
}

@keyframes sidebar-guide-pulse {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(4px); }
}

@media (max-width: 430px) {
  .layout > .app { padding-left: 0.45rem; padding-right: 0.45rem; }
  .podcast-player { padding: 0.6rem 0.5rem 0.75rem; }
  .view-learn .podcast-player {
    min-height: calc(100dvh - 8rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .podcast-visual { aspect-ratio: 1 / 1; }
  .podcast-srt-line { font-size: 1.12rem; }
  .podcast-controls .btn.btn-control,
  .podcast-favorite-btn,
  .podcast-srt-lang-btn {
    min-width: 2.85rem;
    height: 2.35rem;
    min-height: 2.35rem;
    max-height: 2.35rem;
  }
  .podcast-srt-lang-btn {
    width: 4.25rem;
    min-width: 4.25rem;
    max-width: 4.25rem;
  }
  .podcast-favorite-btn {
    width: 2.85rem;
    max-width: 2.85rem;
    min-height: 2.35rem;
    max-height: 2.35rem;
  }
  .header-theme-btn {
    width: 2.55rem;
    min-width: 2.55rem;
    height: 2.2rem;
    min-height: 2.2rem;
    max-height: 2.2rem;
  }
  .header-theme-btn .theme-icon {
    width: 1.22rem;
    height: 1.22rem;
  }
  .header-theme-btn .theme-icon-moon {
    width: 1.08rem;
    height: 1.08rem;
  }
  .header-theme-glyph { font-size: 1.12rem; }
  .podcast-controls-row { gap: 1rem; padding-top: 0.75rem; }
  .podcast-controls { gap: 0.6rem; }
}

html.device-iphone .layout > .app,
html.device-ipad .layout > .app,
html.device-android .layout > .app {
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

html.device-ipad.orientation-landscape .view-learn .podcast-visual,
html.device-tablet.orientation-landscape .view-learn .podcast-visual {
  max-height: 54vh;
}
