/* 认识加 / 减 / 乘 / 除 · 共享样式。四个入口页共用一份。 */
:root {
  --ink: #16263a;
  --ink-soft: #5a6b80;
  --card: rgba(255, 255, 255, 0.9);
  --card-edge: #b6cde6;
  --stage-left: 0px;
  --stage-right: 0px;
  --stage-top: 0px;
  --stage-bottom: 0px;
  --stage-scale: 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #d8e5f4;
}

body {
  font-family:
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", ui-sans-serif,
    system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  left: calc(var(--stage-left) + 30px);
  top: calc(var(--stage-top) + 28px);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 8px 22px rgba(60, 100, 145, 0.13);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink-soft);
  pointer-events: none;
}

.hud b {
  color: var(--ink);
  font-size: 19px;
  font-weight: 900;
}

.hud__kicker {
  font-size: 14px;
  font-weight: 800;
  color: #7c93aa;
}

.hud__step {
  padding-left: 12px;
  border-left: 1px solid rgba(150, 180, 210, 0.55);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #7c93aa;
}

/* 页面上的台词条：半透明圆角底框，和成片里烧录的字幕是同一套样式。
   位置按设计稿坐标（1600x900）换算，和画布一起等比缩放，换窗口大小不会跑位。 */
.subpreview {
  position: absolute;
  left: 50%;
  bottom: calc(var(--stage-bottom) + 135px * var(--stage-scale));
  transform: translateX(-50%);
  max-width: min(1240px, calc(100vw - 120px));
  padding: calc(8px * var(--stage-scale)) calc(22px * var(--stage-scale));
  border-radius: calc(14px * var(--stage-scale));
  background: rgba(24, 28, 36, 0.78);
  color: #fff;
  font-size: calc(24px * var(--stage-scale));
  font-weight: 700;
  line-height: 1.42;
  text-align: center;
  opacity: 0;
  transition: opacity 0.24s ease;
  pointer-events: none;
}

.subpreview.is-on {
  opacity: 1;
}

.bar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--stage-bottom) + 26px);
  transform: translateX(-50%);
  width: min(1180px, calc(100vw - 60px));
  border: 1px solid var(--card-edge);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 34px rgba(56, 96, 140, 0.16);
  overflow: hidden;
}

.bar__progress {
  height: 5px;
  background: rgba(150, 180, 210, 0.28);
}

.bar__progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, #ff8a80, #4dabf7, #12b886);
}

.bar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px;
}

.dots {
  display: flex;
  align-items: center;
  gap: 9px;
}

.dot {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #d3e0ee;
  border-radius: 50%;
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.dot:hover {
  border-color: #8fb6dc;
  color: var(--ink);
  transform: translateY(-1px);
}

.dot.is-active {
  border-color: #16263a;
  background: #16263a;
  color: #fff;
  box-shadow: 0 6px 14px rgba(22, 38, 58, 0.28);
}

.bar__controls {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tool {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #d3e0ee;
  border-radius: 13px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.tool svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool:hover {
  border-color: #8fb6dc;
  transform: translateY(-1px);
}

.tool:active {
  transform: translateY(0);
}

.tool--play {
  width: 52px;
  height: 52px;
  border-color: #16263a;
  background: #16263a;
  color: #fff;
}

.tool--play:hover {
  border-color: #24384f;
  background: #24384f;
}

.tool--play svg {
  width: 24px;
  height: 24px;
}

.tool--play .icon-play {
  fill: currentColor;
  stroke-width: 1.6;
  display: none;
}

.tool--play.is-paused .icon-play {
  display: block;
}

.tool--play.is-paused .icon-pause {
  display: none;
}

.tool--sound[hidden] {
  display: none;
}

.tool--sound .icon-sound-off {
  display: none;
}

.tool--sound.is-muted {
  color: #8ba3bb;
}

.tool--sound.is-muted .icon-sound-off {
  display: block;
}

.tool--sound.is-muted .icon-sound-on {
  display: none;
}

@keyframes sound-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 176, 32, 0.5);
  }
  60% {
    box-shadow: 0 0 0 12px rgba(255, 176, 32, 0);
  }
}

.tool--play.is-blocked {
  animation: sound-pulse 1.6s ease-out infinite;
}

.toast {
  position: absolute;
  left: 50%;
  top: calc(var(--stage-top) + 26px);
  transform: translate(-50%, -10px);
  padding: 10px 22px;
  border: 1px solid #ffd79a;
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.96);
  color: #9a6711;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 8px 20px rgba(120, 90, 30, 0.14);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 200ms ease,
    transform 200ms ease,
    visibility 200ms;
  pointer-events: none;
}

.needs-sound .toast {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.time {
  margin-left: 4px;
  padding-left: 14px;
  border-left: 1px solid rgba(150, 180, 210, 0.55);
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* ---------------- 手机端 ----------------
   画面是 1600x900 等比居中，竖屏时只会占中间一条，
   所以控件不能再按桌面像素贴在画面边缘，否则会盖住动画。 */

/* 竖屏：标题贴屏幕顶，控件贴屏幕底，台词条落在画面下沿的空白里。 */
@media (max-width: 900px) and (orientation: portrait) {
  .hud {
    left: calc(env(safe-area-inset-left, 0px) + 12px);
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    gap: 8px;
    padding: 7px 14px;
    font-size: 14px;
  }

  .hud b {
    font-size: 16px;
  }

  .hud__kicker {
    display: none;
  }

  .hud__step {
    padding-left: 9px;
    font-size: 12px;
  }

  .bar {
    left: 50%;
    right: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    width: calc(100vw - 24px);
    border-radius: 16px;
  }

  .bar__row {
    flex-direction: column;
    gap: 9px;
    padding: 10px 12px;
  }

  .dots {
    gap: 5px;
  }

  .dot {
    width: 33px;
    height: 33px;
    font-size: 13px;
  }

  .bar__controls {
    gap: 6px;
  }

  .tool {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .tool--play {
    width: 46px;
    height: 46px;
  }

  .time {
    margin-left: 0;
    padding-left: 10px;
    font-size: 13px;
  }

  /* 桌面端台词条跟着 --stage-scale 走，竖屏下这个值只有 0.24，字号会小到看不清。 */
  .subpreview {
    top: calc(50% + 28.2vw + 12px);
    bottom: auto;
    max-width: calc(100vw - 28px);
    padding: 9px 16px;
    border-radius: 12px;
    font-size: 16px;
  }

  .toast {
    top: calc(env(safe-area-inset-top, 0px) + 60px);
    bottom: auto;
    padding: 7px 15px;
    font-size: 13px;
  }
}

/* 横屏手机：高度只有 400 上下，控件压成一条细带，尽量少挡动画。 */
@media (orientation: landscape) and (max-height: 520px) {
  .hud {
    left: calc(env(safe-area-inset-left, 0px) + 8px);
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    gap: 8px;
    padding: 5px 12px;
    font-size: 12px;
  }

  .hud b {
    font-size: 14px;
  }

  .hud__kicker {
    display: none;
  }

  .hud__step {
    padding-left: 8px;
    font-size: 11px;
  }

  .bar {
    left: 50%;
    right: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    width: min(720px, calc(100vw - 20px));
    border-radius: 14px;
  }

  .bar__row {
    flex-direction: row;
    gap: 10px;
    padding: 7px 10px;
  }

  .dots {
    gap: 4px;
  }

  .dot {
    width: 29px;
    height: 29px;
    font-size: 12px;
  }

  .bar__controls {
    gap: 5px;
  }

  .tool {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .tool svg {
    width: 18px;
    height: 18px;
  }

  .tool--play {
    width: 42px;
    height: 42px;
  }

  .tool--play svg {
    width: 20px;
    height: 20px;
  }

  .time {
    margin-left: 0;
    padding-left: 9px;
    font-size: 12px;
  }

  .subpreview {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 74px);
    max-width: calc(100vw - 40px);
    padding: 6px 14px;
    border-radius: 11px;
    font-size: 15px;
  }

  .toast {
    top: calc(env(safe-area-inset-top, 0px) + 44px);
    padding: 6px 14px;
    font-size: 12px;
  }
}

/* 录制模式：逐帧导出时隐藏进度条和按钮，保留左上角章节标题 */
.is-recording .bar,
.is-recording .subpreview,
.is-recording .toast {
  display: none;
}

/* 封面模式：整页只剩画布本身 */
.is-cover .hud,
.is-cover .bar,
.is-cover .subpreview,
.is-cover .toast {
  display: none;
}
