/* 家人共学 — mobile-first */
:root {
  --bg: #f7f4ef;
  --bg-card: #ffffff;
  --bg-soft: #efeae2;
  --text: #2c2419;
  --text-muted: #7a6f62;
  --accent: #5c4a3a;
  --accent-deep: #3d3228;
  --teal: #3d6b66;
  --teal-soft: #d8ebe8;
  --bar-track: #e5ddd2;
  --bar-fill: #3d6b66;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(44, 36, 25, 0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  /* 字幕默认「大」：手机约 34px */
  --caption-size: 2.125rem;
  --caption-line: 1.4;
}

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

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100%;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.view {
  padding: calc(20px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
}

/* —— 首页 —— */
.page-header {
  margin-bottom: 20px;
}

.title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-deep);
}

.subtitle {
  margin-top: 4px;
  font-size: 1.05rem;
  color: var(--accent);
  font-weight: 500;
}

.meta {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.install-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  padding: 15px 16px;
  background: var(--teal-soft);
  border: 1px solid rgba(61, 107, 102, 0.18);
  border-radius: var(--radius);
}

.install-card-content {
  min-width: 0;
  flex: 1;
}

.install-card-title {
  color: var(--accent-deep);
  font-size: 1.05rem;
  font-weight: 700;
}

.install-card-hint {
  margin-top: 3px;
  color: var(--teal);
  font-size: 0.84rem;
  line-height: 1.45;
}

.btn-install {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 9px 13px;
  background: var(--teal);
  color: #fff;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-install:active {
  background: var(--accent-deep);
}

.title-sm {
  font-size: 1.55rem;
}

.album-page-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.album-page-text {
  min-width: 0;
  flex: 1;
}

/* —— 专辑列表 —— */
.album-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.album-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 16px;
  min-height: 64px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 1px solid transparent;
}

.album-item:active {
  background: var(--bg-soft);
}

.album-item:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.album-body {
  flex: 1;
  min-width: 0;
}

.album-item-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent-deep);
  line-height: 1.4;
}

.album-item-meta {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.album-badges {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.badge-subs {
  background: var(--teal-soft);
  color: var(--teal);
}

.badge-transcript {
  background: #efe6d6;
  color: var(--accent);
}

.badge-muted {
  background: var(--bg-soft);
  color: var(--text-muted);
}

.album-progress-note {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--teal);
  font-weight: 500;
}

.continue-card {
  background: linear-gradient(135deg, #3d6b66 0%, #5c4a3a 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
}

.continue-card:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.continue-label {
  font-size: 0.85rem;
  opacity: 0.9;
  letter-spacing: 0.06em;
}

.continue-title {
  margin-top: 6px;
  font-size: 1.25rem;
  font-weight: 600;
}

.continue-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.continue-progress .bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.continue-progress .bar-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  transition: width 0.2s ease;
}

.continue-pct {
  font-size: 0.8rem;
  opacity: 0.9;
  min-width: 2.5em;
  text-align: right;
}

.episode-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ep-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 16px;
  min-height: 60px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}

.ep-item:active {
  background: var(--bg-soft);
}

.ep-item:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.ep-num {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
}

.ep-item.completed .ep-num {
  background: var(--teal-soft);
  color: var(--teal);
}

.ep-body {
  flex: 1;
  min-width: 0;
}

.ep-title {
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent-deep);
}

.ep-status {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ep-status .bar {
  flex: 1;
  max-width: 120px;
  height: 3px;
  background: var(--bar-track);
  border-radius: 2px;
  overflow: hidden;
}

.ep-status .bar-fill {
  height: 100%;
  background: var(--bar-fill);
  border-radius: 2px;
  width: 0%;
}

.ep-status.done {
  color: var(--teal);
  font-weight: 500;
}

.ep-chevron {
  flex-shrink: 0;
  color: #c4b8a8;
}

/* —— 播放页 —— */
#view-player {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(20px + var(--safe-bottom));
}

#view-player.hidden {
  display: none !important;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.btn-icon {
  background: var(--bg-soft);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

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

.player-header-text {
  min-width: 0;
}

.player-album {
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 500;
}

.player-ep-num {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-deep);
}

.player-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 8px 0 4px;
  gap: 12px;
  min-height: 0;
}

/* —— 大字字幕（约 5 行窗口，主导画面） —— */
.caption-stage {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 14rem;
  width: 100%;
  padding: 2px 0;
}

.caption-bar {
  width: 100%;
  max-width: 100%;
  background: rgba(28, 22, 16, 0.9);
  border-radius: 16px;
  padding: 0.85em 0.9rem;
  min-height: calc(var(--caption-size) * var(--caption-line) * 5.2 + 1.6em);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(28, 22, 16, 0.22);
  overflow: hidden;
}

.caption-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18em;
  width: 100%;
}

.caption-line {
  width: 100%;
  text-align: center;
  line-height: var(--caption-line);
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  transition: color 0.15s ease, opacity 0.15s ease;
}

.caption-line.near {
  font-size: calc(var(--caption-size) * 0.72);
  font-weight: 500;
  color: rgba(245, 240, 230, 0.38);
  -webkit-line-clamp: 1;
  min-height: calc(var(--caption-size) * 0.72 * var(--caption-line));
}

.caption-line.current {
  font-size: var(--caption-size);
  font-weight: 700;
  color: #f7f2e8;
  letter-spacing: 0.02em;
  -webkit-line-clamp: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.12em 0.35em;
  margin: 0.08em 0;
}

.caption-line.placeholder {
  min-height: calc(var(--caption-size) * 0.72 * var(--caption-line));
  visibility: hidden;
}

.caption-empty {
  font-size: calc(var(--caption-size) * 0.78);
  font-weight: 600;
  color: rgba(245, 240, 230, 0.55);
  text-align: center;
  line-height: var(--caption-line);
}

/* 字号：小 / 中 / 大（默认大，适老）；由 −/+ 步进 */
.caption-stage[data-size="sm"] {
  --caption-size: 1.375rem; /* ~22px */
}

.caption-stage[data-size="md"] {
  --caption-size: 1.75rem; /* ~28px */
}

.caption-stage[data-size="lg"] {
  --caption-size: 2.125rem; /* ~34px phone */
}
.caption-stage[data-size="xl"] {
  --caption-size: 2.5rem; /* ~40px phone */
}

.caption-stage[data-size="xxl"] {
  --caption-size: 2.875rem; /* ~46px phone */
}


.caption-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-shrink: 0;
  padding: 0 2px;
}

.btn-size-step {
  font-family: inherit;
  font-size: 1.75rem;
  font-weight: 700;
  width: 64px;
  height: 56px;
  border-radius: 16px;
  border: 1.5px solid var(--bar-track);
  background: var(--bg-card);
  color: var(--accent-deep);
  cursor: pointer;
  line-height: 1;
  box-shadow: var(--shadow);
}

.btn-size-step:active {
  background: var(--bg-soft);
  opacity: 0.92;
}

.seek-block {
  width: 100%;
  padding: 0 4px;
  flex-shrink: 0;
}

.seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bar-track);
  outline: none;
  cursor: pointer;
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.seek::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.transport-extras {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  padding: 0 2px;
}

.btn-transport {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  min-height: 52px;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1.5px solid var(--bar-track);
  background: var(--bg-card);
  color: var(--accent-deep);
  cursor: pointer;
  line-height: 1.2;
  box-shadow: var(--shadow);
}

.btn-transport:active {
  background: var(--bg-soft);
  opacity: 0.92;
}

#btn-speed {
  flex: 1.15;
  min-width: 7.5em;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-top: 2px;
  flex-shrink: 0;
}

.btn-nav {
  background: transparent;
  border: none;
  color: var(--accent);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-nav:not(:disabled):active {
  background: var(--bg-soft);
}

.btn-play {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: none;
  background: var(--accent-deep);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(61, 50, 40, 0.3);
}

.btn-play:active {
  transform: scale(0.96);
}

.btn-play.playing {
  background: var(--teal);
}

.btn-resume {
  margin-top: 4px;
  padding: 14px 32px;
  min-height: 52px;
  border-radius: 999px;
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  align-self: center;
}

.btn-resume:active {
  opacity: 0.9;
}

.player-hint {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.player-hint:empty {
  display: none !important;
}

/* —— Toast —— */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(44, 36, 25, 0.88);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 100;
  max-width: 90%;
  pointer-events: none;
}

@media (min-width: 481px) {
  #app {
    max-width: 560px;
    border-left: 1px solid #ebe4da;
    border-right: 1px solid #ebe4da;
  }

  .caption-stage[data-size="sm"] {
    --caption-size: 1.5rem;
  }

  .caption-stage[data-size="md"] {
    --caption-size: 2rem;
  }

  .caption-stage[data-size="lg"] {
    --caption-size: 2.5rem; /* ~40px tablet */
  }

  .caption-stage[data-size="xl"] {
    --caption-size: 3rem; /* ~48px tablet */
  }

  .caption-stage[data-size="xxl"] {
    --caption-size: 3.5rem; /* ~56px tablet */
  }
}

@media (min-width: 768px) {
  #app {
    max-width: 640px;
  }

  .caption-stage[data-size="lg"] {
    --caption-size: 2.75rem;
  }

  .caption-stage[data-size="xl"] {
    --caption-size: 3.25rem;
  }

  .caption-stage[data-size="xxl"] {
    --caption-size: 3.75rem;
  }
}


/* 首页全局继续收听 */
.home-continue {
  margin-bottom: 18px;
}
.home-continue .continue-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.35;
}
.home-continue .continue-ep {
  margin-top: 6px;
  font-size: 1.15rem;
  font-weight: 600;
  opacity: 0.92;
}
