:root {
  --ink: #20262e;
  --ink-soft: #55606f;
  --card: rgba(255, 255, 255, 0.92);
  --card-edge: #c9d6e6;
  --stage-left: 0px;
  --stage-right: 0px;
  --stage-top: 0px;
  --stage-bottom: 0px;
}

* {
  box-sizing: border-box;
}

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

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(50, 80, 130, 0.14);
  backdrop-filter: blur(6px);
}

.hud__kicker {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #2f5fbf;
}

.hud b {
  font-size: 20px;
  font-weight: 800;
}

.hud__step {
  padding-left: 12px;
  border-left: 1px solid var(--card-edge);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* 预览用的台词条：只在正常浏览时出现，录制模式下由 .is-recording 隐藏。 */
.subpreview {
  position: absolute;
  left: 50%;
  bottom: calc(var(--stage-bottom) + 150px);
  transform: translateX(-50%);
  max-width: min(1180px, 78vw);
  padding: 10px 22px;
  border-radius: 14px;
  background: rgba(24, 28, 36, 0.78);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transition: opacity 0.24s ease;
  pointer-events: none;
}

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

.bar {
  position: absolute;
  left: calc(var(--stage-left) + 30px);
  right: calc(var(--stage-right) + 30px);
  bottom: calc(var(--stage-bottom) + 24px);
  padding: 12px 18px 14px;
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 12px 30px rgba(50, 80, 130, 0.16);
  backdrop-filter: blur(6px);
}

.bar__progress {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: #dde6f1;
  overflow: hidden;
}

.bar__progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #6f9be8, #2f5fbf);
}

.bar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 10px;
}

.dots {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.dots button {
  width: 22px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #cbd8e8;
  cursor: pointer;
  transition:
    width 0.2s ease,
    background 0.2s ease;
}

.dots button.is-active {
  width: 40px;
  background: #2f5fbf;
}

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

.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition:
    background 0.16s ease,
    transform 0.16s ease;
}

.tool:hover {
  background: #eef3fb;
}

.tool:active {
  transform: scale(0.95);
}

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

.tool--play .icon-play {
  fill: currentColor;
  stroke-width: 1.4;
}

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

.tool--play.is-paused .icon-pause,
.tool--sound.is-off .icon-sound-on {
  display: none;
}

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

.time {
  min-width: 96px;
  margin-left: 4px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  text-align: right;
}

.toast {
  position: absolute;
  left: 50%;
  top: calc(var(--stage-top) + 30px);
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(32, 38, 46, 0.86);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

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

/* 录制模式：只留画面，控件、台词条、提示都不进成片。 */
.is-recording .bar,
.is-recording .toast,
.is-recording .subpreview,
.is-recording .hud {
  display: none;
}

/* ---------------- 手机端 ----------------
   画面是 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__kicker {
    font-size: 12px;
  }

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

  .hud__step,
  .time {
    display: none;
  }

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

  .bar__row {
    gap: 10px;
    margin-top: 8px;
  }

  .dots {
    gap: 5px;
  }

  .dots button {
    width: 18px;
    height: 7px;
  }

  .dots button.is-active {
    width: 30px;
  }

  .bar__controls {
    gap: 6px;
  }

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

  .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);
    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__kicker {
    font-size: 11px;
  }

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

  .hud__step,
  .time {
    display: none;
  }

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

  .bar__row {
    gap: 10px;
    margin-top: 6px;
  }

  .dots {
    gap: 4px;
  }

  .dots button {
    width: 14px;
    height: 6px;
  }

  .dots button.is-active {
    width: 24px;
  }

  .bar__controls {
    gap: 5px;
  }

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

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

  .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;
  }
}
