/* =========================================================
   プロンプター

   配色は暗い側だけに絞っている。読む面は黒地・白文字でなければ
   顔に画面が映り込むうえ、明るいUIと行き来すると目が慣れない。
   撮影現場は暗いことも多い。テーマ切替は持たず、暗い配色で通す。

   アクセントはスタジオのキューランプの琥珀。録画を示す赤とは
   役割を分けてあり、赤は「録画中」の意味だけに取っておく。
   ========================================================= */

:root {
  --bg: #0d1011;
  --panel: #171c1d;
  --panel-2: #1f2627;
  --line: #2c3536;
  --line-strong: #3d4849;

  --text: #e9eeee;
  --text-soft: #9aa8a8;
  --text-faint: #6c7a7b;

  --accent: #d9a441;          /* キューランプの琥珀 */
  --accent-ink: #1a1405;
  --accent-soft: #33280f;

  --danger: #d4655a;
  --danger-soft: #331916;

  --radius: 8px;
  --radius-sm: 6px;

  /* 読む面。ここだけは最大コントラストで固定する */
  --stage-bg: #000000;
  --stage-text: #ffffff;

  --ui-font: system-ui, -apple-system, "Hiragino Kaku Gothic ProN",
             "Noto Sans JP", "Yu Gothic", sans-serif;
  --read-font: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui-font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

/* ---- 画面切替 ---- */
.view { display: none; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.view.is-active { display: block; }

/* ---- 上部バー ---- */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar-title {
  flex: 1 1 auto; min-width: 0;
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ---- 区画 ---- */
.pane { padding: 20px 0; border-bottom: 1px solid var(--line); }
.pane:last-of-type { border-bottom: 0; }
.pane-danger { border-bottom: 0; padding-top: 28px; }
.pane-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.pane-title { flex: 1 1 auto; margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .04em; color: var(--text-soft); }
.pane-note { margin: 0 0 10px; font-size: 12.5px; color: var(--text-faint); line-height: 1.65; }
.label { display: block; font-size: 12.5px; color: var(--text-soft); margin-bottom: 5px; }
.meta { margin: 8px 0 0; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---- 入力 ---- */
.field {
  width: 100%; padding: 11px 12px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit; font-size: 15px; line-height: 1.7;
}
.field::placeholder { color: var(--text-faint); }
.field-area { resize: vertical; min-height: 88px; }
.field:focus-visible, .btn:focus-visible, .hud-btn:focus-visible,
.playpause:focus-visible, .chk:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---- ボタン ---- */
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row-tight { margin-top: 0; }

.btn {
  padding: 9px 14px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-soft); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-icon {
  padding: 6px 10px; font-size: 15px; line-height: 1;
  background: transparent; border-color: var(--line); color: var(--text-soft);
}
.btn:disabled { opacity: .4; cursor: default; }

/* ---- 原稿一覧 ---- */
.list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.item-main { flex: 1 1 auto; min-width: 0; }
.item-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.item-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.empty { margin: 12px 0 0; font-size: 13px; color: var(--text-faint); line-height: 1.7; }

/* ---- 章 ---- */
.block {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-top: 10px;
}
.block.is-off { opacity: .5; }
.block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.chk { width: 19px; height: 19px; flex: 0 0 auto; accent-color: var(--accent); }
.block-title {
  flex: 1 1 auto; min-width: 0; padding: 7px 10px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
}
.block-body {
  width: 100%; min-height: 120px; padding: 10px 12px; resize: vertical;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14.5px; line-height: 1.8;
}
.block-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; }
.block-count { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* =========================================================
   プロンプター本体
   ========================================================= */
.prompter {
  position: fixed; inset: 0; z-index: 50;
  background: var(--stage-bg); color: var(--stage-text);
  overflow: hidden;
}
.prompter[hidden] { display: none; }

.prompter-stage { position: absolute; inset: 0; overflow: hidden; }

/* 原稿のパネル。幅と位置は JS が書く */
.panel {
  position: absolute; top: 0; bottom: 0;
  overflow: hidden;
  background: rgba(0, 0, 0, .55);
  border-radius: 0 18px 18px 0;
}
.panel.is-right { border-radius: 18px 0 0 18px; }
.panel.is-center { border-radius: 18px; }
/* カメラを出していないときは全面が黒なので、パネルの縁は要らない */
.prompter:not(.has-cam) .panel { background: transparent; border-radius: 0; }

/* 幅を変えるつまみ。内側の縁に置く */
.grip {
  position: absolute; top: 0; bottom: 0; width: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: ew-resize; touch-action: none; z-index: 2;
}
.grip { right: -17px; }
.panel.is-right .grip { right: auto; left: -17px; }
.grip span {
  width: 5px; height: 64px; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(0,0,0,.45);
}
.grip.is-dragging span { height: 96px; }

/* 反転はこの要素に掛ける。HUD には掛からないので操作は常に正しい向き */
.prompter-scroll {
  position: absolute; left: 0; right: 0; top: 0;
  /* 左右の余白は設定で変える（padding を JS が書く） */
  font-family: var(--read-font);
  font-weight: 700;
  color: var(--stage-text);
  white-space: pre-wrap;
  word-break: break-word;
  will-change: transform;
}
.prompter-scroll.mirror-h { transform-origin: center; }

/* 読んでいない行は少し落とし、現在行だけを白のまま出す。
   コントラストで位置を示すので、色を足さずに済む */
.prompter-scroll .line { opacity: .55; transition: opacity .12s linear; }
.prompter-scroll .line.is-active { opacity: 1; }

.chapter-label {
  font-size: .42em; font-weight: 400; color: var(--accent);
  letter-spacing: .04em; margin-bottom: .25em;
}
.chapter + .chapter { margin-top: 1.1em; }

/* 読む位置の目印。中央より少し上に置くと、次の行が視野に入る */
.readline {
  position: absolute; left: 0; right: 0; top: 38%;
  border-top: 2px solid var(--accent);
  opacity: .55; pointer-events: none;
}
.readline::before,
.readline::after {
  content: ""; position: absolute; top: -7px;
  border: 6px solid transparent;
}
.readline::before { left: 0; border-left-color: var(--accent); }
.readline::after { right: 0; border-right-color: var(--accent); }

/* ---- 操作パネル ---- */
.hud {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: opacity .18s ease;
}
.hud.is-hidden { opacity: 0; }
.hud > * { pointer-events: auto; }

.hud-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,.82), rgba(0,0,0,0));
}
.hud-stat {
  flex: 1 1 auto; text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 19px; font-weight: 700; line-height: 1.2;
}
.hud-stat-sub { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-soft); letter-spacing: .08em; }

.hud-bottom {
  display: flex; align-items: flex-end;
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  justify-content: flex-end;          /* 既定は右寄せ。原稿が右のときは左へ回す */
}
.hud-bottom.to-left { justify-content: flex-start; }
.hud-bottom.to-center { justify-content: center; }

/* 操作のまとまり。浮いた小さな塊にして、原稿と重ならないようにする */
.dock {
  display: flex; flex-wrap: wrap; align-items: center; gap: 9px;
  max-width: 100%;
  padding: 10px 12px;
  background: rgba(12, 16, 16, .72);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
}
.hud-group { display: flex; align-items: center; gap: 6px; }

/* ---- 速さのつまみ ---- */
.speed { display: flex; align-items: center; gap: 9px; flex: 0 1 190px; min-width: 150px; }
.speed-end { font-size: 12px; color: var(--text-soft); flex: 0 0 auto; }
.speed input[type=range] {
  flex: 1 1 auto; min-width: 0; height: 34px;
  -webkit-appearance: none; appearance: none; background: transparent;
}
.speed input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: rgba(255,255,255,.3);
}
.speed input[type=range]::-moz-range-track {
  height: 4px; border-radius: 2px; background: rgba(255,255,255,.3);
}
.speed input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 6px; height: 26px; margin-top: -11px; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,.5);
}
.speed input[type=range]::-moz-range-thumb {
  width: 6px; height: 26px; border: 0; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,.5);
}
.speed-val { flex: 0 0 auto; text-align: right; line-height: 1.1; }
.speed-val b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.speed-val small { font-size: 10px; color: var(--text-soft); }
.hud-label { font-size: 11px; color: var(--text-soft); letter-spacing: .06em; }
.hud-val { min-width: 2.6em; text-align: center; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

.hud-btn {
  padding: 9px 13px; min-height: 42px;
  background: rgba(255,255,255,.1); color: var(--text);
  border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.hud-btn.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hud-btn-sq { min-width: 44px; padding: 9px 0; font-size: 18px; }

.playpause {
  flex: 0 0 auto; min-width: 104px; min-height: 48px; padding: 10px 18px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: var(--radius);
  font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
}

.prompter-hint {
  position: absolute; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom));
  margin: 0; text-align: center; font-size: 12px; color: var(--text-faint);
  pointer-events: none; transition: opacity .3s ease;
}
.prompter-hint.is-gone { opacity: 0; }

/* ---- カメラ ---- */
.cam {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; z-index: 0;
}
.cam[hidden] { display: none; }
/* 自撮りは鏡像のほうが向きを合わせやすい。録画される映像はこの見た目の
   影響を受けない（CSSの変形は表示だけで、記録するのは元のカメラ映像） */
.cam.is-selfie { transform: scaleX(-1); }

/* パネルの地で読ませるので、影は控えめでよい */
.prompter.has-cam .prompter-scroll { text-shadow: 0 1px 4px rgba(0,0,0,.8); }

/* ---- 録画中の表示 ---- */
.rec-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: rgba(0,0,0,.6); border: 1px solid var(--danger);
  color: #fff; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rec-badge[hidden] { display: none; }
.rec-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); animation: recblink 1.4s steps(1, end) infinite;
}
@keyframes recblink { 50% { opacity: .25; } }
.hud-btn.is-rec { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---- 撮れた映像の確認 ---- */
.review {
  position: absolute; inset: 0; z-index: 6;
  background: rgba(4,7,7,.94);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.review[hidden] { display: none; }
.review-inner { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 12px; }
.review-head { display: flex; align-items: baseline; gap: 10px; }
.review-meta { flex: 0 0 auto; font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.review-video {
  width: 100%; max-height: 52vh; background: #000;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.review-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.review-note { margin: 0; font-size: 11.5px; color: var(--text-faint); line-height: 1.6; }
.review-actions .hud-btn { flex: 0 0 auto; }

/* ---- 進み具合 ---- */
.progress {
  position: absolute; left: 0; right: 0; top: 0; z-index: 4;
  height: 3px; background: rgba(255,255,255,.12); pointer-events: none;
}
.progress span {
  display: block; height: 100%; width: 0;
  background: var(--accent);
}

/* ---- 章の一覧 ---- */
.chapter-item {
  display: flex; align-items: baseline; gap: 10px; width: 100%;
  padding: 12px 12px; text-align: left;
  background: rgba(255,255,255,.06); color: var(--text);
  border: 1px solid rgba(255,255,255,.14); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.chapter-item + .chapter-item { margin-top: 7px; }
.chapter-item .ci-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-item .ci-time { flex: 0 0 auto; font-size: 12px; font-weight: 400; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.chapter-item.is-here { border-color: var(--accent); color: var(--accent); }

/* ---- 表示の設定（下から出るシート） ---- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  background: #0b0e0e; border-top: 1px solid var(--line-strong);
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 9px;
  max-height: 70%; overflow-y: auto;
}
.sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.sheet-title { flex: 1 1 auto; font-size: 13px; font-weight: 700; color: var(--text-soft); letter-spacing: .04em; }
.sheet-row { display: flex; align-items: center; gap: 8px; }
.sheet-label { flex: 1 1 auto; font-size: 14px; color: var(--text); }
.sheet-hint { display: block; font-size: 11px; color: var(--text-faint); font-weight: 400; }

/* ---- カウントダウン ---- */
.countdown {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.72);
  font-size: 24vw; font-weight: 700; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.countdown[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
