:root {
  --cream: #F5EFE0;
  --cream-deep: #EFE4CE;
  --card: #FFFBF2;
  --ink: #3A2E2A;
  --ink-soft: #7A6A60;
  --orange: #E07B39;
  --orange-deep: #C9652A;
  --green: #3E6B3E;
  --red: #8E2F2F;
  --line: rgba(58, 46, 42, .1);
  --shadow: 0 2px 10px rgba(90, 66, 40, .08);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

/* ---------- 首页 ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--cream) 72%, rgba(245, 239, 224, 0));
  padding: calc(18px + env(safe-area-inset-top)) 18px 14px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -.4px;
  font-weight: 800;
}

.brand .sub {
  font-size: 14px;
  color: var(--ink-soft);
}

.progress-strip {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

.bar {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: rgba(58, 46, 42, .1);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--green);
  transition: width .4s ease;
}

/* 继续上次 */

.quick {
  padding: 0 18px 4px;
}

.btn-continue {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--orange);
  color: #fff;
  text-align: left;
  box-shadow: 0 5px 16px rgba(224, 123, 57, .3);
  transition: transform .12s ease;
}

.btn-continue:active { transform: scale(.98); }

.btn-continue .ic {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: rgba(255, 255, 255, .22);
  font-size: 20px;
  padding-left: 3px;
}

.btn-continue .tx {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.btn-continue .tx b {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .3px;
}

.btn-continue .tx small {
  font-size: 13px;
  opacity: .9;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 14px 18px 18px;
}

.foot-tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 18px calc(28px + env(safe-area-inset-bottom));
}

.foot-tools button {
  font-size: 14px;
  color: var(--ink-soft);
  padding: 10px 20px;
  border-radius: 99px;
  background: rgba(58, 46, 42, .05);
}

@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 800px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(5, 1fr); } }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px 14px 14px;
  min-height: 112px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  text-align: left;
  transition: transform .12s ease, box-shadow .12s ease;
}

.card:active { transform: scale(.97); }

.card.watched { border-color: rgba(62, 107, 62, .35); }

.card .no {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--orange-deep);
  opacity: .85;
}

.card .en {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}

.card .zh {
  font-size: 14px;
  color: var(--ink-soft);
}

.card .ico {
  position: absolute;
  right: 12px;
  top: 12px;
  font-size: 21px;
  opacity: .55;
}

.card .dot {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--green);
  opacity: 0;
}

.card.watched .dot { opacity: 1; }

.card.missing { opacity: .5; }

.card .st {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--red);
  margin-top: auto;
  padding-top: 6px;
}

/* ---------- 播放页 ---------- */

.player {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
}

.player.open { transform: translateY(0); }

.p-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  flex: none;
}

.back {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: rgba(58, 46, 42, .07);
  font-size: 22px;
  line-height: 1;
}

.p-title {
  min-width: 0;
  flex: 1;
}

.p-title .t1 {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.p-title .t2 {
  font-size: 13px;
  color: var(--ink-soft);
}

.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
  flex: none;
}

.mode-tabs button {
  flex: 1;
  padding: 11px 8px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  background: rgba(58, 46, 42, .06);
  color: var(--ink-soft);
  transition: background .16s ease, color .16s ease;
}

.mode-tabs button.on {
  background: var(--orange);
  color: #fff;
}

.p-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 14px calc(24px + env(safe-area-inset-bottom));
}

.stage {
  border-radius: var(--radius);
  overflow: hidden;
  background: #1c1714;
  box-shadow: var(--shadow);
}

.stage video {
  display: block;
  width: 100%;
  max-height: 58vh;
  background: #1c1714;
}

.audio-stage {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.audio-stage .big-ico {
  font-size: 58px;
  line-height: 1;
}

.audio-stage .now {
  font-size: 16px;
  color: var(--ink-soft);
  text-align: center;
}

.play-big {
  width: 86px;
  height: 86px;
  border-radius: 99px;
  background: var(--orange);
  color: #fff;
  font-size: 34px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(224, 123, 57, .35);
  transition: transform .12s ease;
}

.play-big:active { transform: scale(.94); }

.a-progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.a-progress input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
}

.a-progress input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(58, 46, 42, .14);
}

.a-progress input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 99px;
  background: var(--orange);
  box-shadow: 0 1px 5px rgba(224, 123, 57, .45);
}

.a-progress input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(58, 46, 42, .14);
}

.a-progress input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 99px;
  background: var(--orange);
}

.a-time {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.controls button {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 15px;
  font-weight: 600;
}

.controls button:disabled { opacity: .35; }

.controls .speed {
  flex: 0 0 74px;
  color: var(--orange-deep);
}

.row-extra {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.row-extra button {
  flex: 1;
  min-height: 44px;
  border-radius: 12px;
  background: rgba(58, 46, 42, .06);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.row-extra button.on {
  background: rgba(62, 107, 62, .14);
  color: var(--green);
}

.text-box {
  margin-top: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.tb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.text-box h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.font-btn {
  min-width: 52px;
  height: 36px;
  border-radius: 99px;
  background: rgba(58, 46, 42, .07);
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 700;
}

.text-box .content {
  font-size: 17px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

.text-box .content em {
  font-style: normal;
  color: var(--orange-deep);
  font-weight: 700;
}

.text-box .empty {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.p-foot {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--cream);
}

.p-foot button {
  flex: 1;
  min-height: 50px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 15px;
  font-weight: 700;
}

.p-foot button.next {
  background: var(--orange);
  color: #fff;
}

.p-foot button:disabled { opacity: .35; }

/* ---------- 提示条 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: rgba(58, 46, 42, .92);
  color: #fff;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 99px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 90;
  max-width: 84vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 空状态 ---------- */

.empty-hint {
  margin: 0 18px 24px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(142, 47, 47, .07);
  color: var(--red);
  font-size: 14px;
  line-height: 1.7;
}

/* ---------- 素材检查 ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
}

.sheet.open { transform: translateY(0); }

.recheck {
  flex: none;
  height: 40px;
  padding: 0 14px;
  border-radius: 99px;
  background: rgba(58, 46, 42, .07);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 14px calc(28px + env(safe-area-inset-bottom));
}

.ck-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  margin-bottom: 8px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.ck-no {
  font-size: 13px;
  font-weight: 700;
  color: var(--orange-deep);
  opacity: .8;
  width: 20px;
  flex: none;
}

.ck-en {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ck-tags {
  display: flex;
  gap: 6px;
  flex: none;
}

.tag {
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 99px;
  background: rgba(58, 46, 42, .06);
  color: var(--ink-soft);
  white-space: nowrap;
}

.tag.ok {
  background: rgba(62, 107, 62, .13);
  color: var(--green);
}

.tag.no {
  background: rgba(142, 47, 47, .09);
  color: var(--red);
}

.ck-tip {
  margin-top: 14px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(142, 47, 47, .07);
  color: var(--red);
  font-size: 14px;
  line-height: 1.85;
}

.ck-tip code {
  font-size: 13px;
  background: rgba(58, 46, 42, .07);
  padding: 1px 5px;
  border-radius: 5px;
  word-break: break-all;
}

/* ---------- 素材来源条 ---------- */

.src-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 36px);
  margin: 6px 18px 0;
  padding: 13px 16px;
  border-radius: 14px;
  background: rgba(142, 47, 47, .08);
  color: var(--red);
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
}

.src-strip.ready {
  background: rgba(62, 107, 62, .1);
  color: var(--green);
}

.src-strip .s-ic {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 99px;
  background: rgba(255, 255, 255, .8);
  font-size: 13px;
  font-weight: 700;
}

.src-strip .s-tx {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.src-strip .s-act {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  opacity: .85;
}

/* ---------- 选素材弹层 ---------- */

.bind-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(245, 239, 224, .96);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}

.bind-mask.show {
  opacity: 1;
  visibility: visible;
}

.bind-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 12px 40px rgba(90, 66, 40, .16);
  padding: 28px 22px 22px;
  text-align: center;
}

.bind-ico {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 10px;
}

.bind-card h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.bind-lead {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.bind-lead b {
  color: var(--ink);
}

.bind-main {
  display: block;
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  background: var(--orange);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(224, 123, 57, .32);
}

.bind-main:active { transform: scale(.98); }

.bind-skip {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-soft);
}

.bind-tip {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-soft);
  min-height: 18px;
}
