/* ============================================================
   ビッグタイマー for Zoom
   1) ステージ … カメラ映像に合成される大きい表示（背景は必ず透過）
   2) パネル   … サイドパネルの操作画面（幅 320〜400px 前提）
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", Meiryo, sans-serif;
}

/* ステージ表示中は「アプリの地色」を出してはいけない。出すとカメラ映像を覆ってしまう。 */
body.mode-stage,
body.mode-stage html {
  background: transparent !important;
}
body.mode-panel {
  background: #12151c;
  color: #e8ecf3;
}

/* ============================ 1) ステージ ============================ */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: transparent;
  /* 位置とサイズは JS が --left/--top/--w/--h を書き込む */
}

/* ブラウザ確認用のダミー背景（Zoom 内では付かない） */
.stage.demo {
  background: radial-gradient(circle at 50% 38%, #6f7f9c 0%, #4a5670 28%, #2b3345 55%, #171c28 100%);
}
.stage.demo::before {
  content: "カメラ映像（ダミー）";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.28);
  font-size: 20px;
  letter-spacing: 0.2em;
}

.tbox {
  position: absolute;
  left: var(--left, 25%);
  top: var(--top, 70%);
  width: var(--w, 50%);
  height: var(--h, 22%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  padding: 1.2% 2%;
  border-radius: 18px;
  opacity: var(--alpha, 0.92);
  /* 位置とサイズだけ滑らかに動かす。色は「残り時間の合図」なので即座に切り替える。 */
  transition: left 0.35s ease, top 0.35s ease, width 0.35s ease, height 0.35s ease;
  container-type: size;
}

/* --- テーマ --- */
.tbox.theme-dark {
  background: rgba(10, 12, 18, 0.86);
  color: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.tbox.theme-light {
  background: rgba(255, 255, 255, 0.92);
  color: #10131a;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.tbox.theme-neon {
  background: rgba(4, 8, 20, 0.9);
  color: #7cf5c8;
  box-shadow: 0 0 0 3px rgba(124, 245, 200, 0.5), 0 10px 50px rgba(0, 0, 0, 0.6);
}
.tbox.theme-clear {
  background: transparent;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 22px rgba(0, 0, 0, 0.75);
  box-shadow: none;
}

/* --- 残り時間による色替え --- */
.tbox.phase-warn { color: #ffd34d; }
.tbox.phase-danger { color: #ff6b6b; }
.tbox.phase-over { color: #fff; background: rgba(190, 30, 40, 0.9); }
.tbox.theme-clear.phase-over { background: transparent; color: #ff8080; }

/* 残りわずかのときだけ静かに脈打つ。超過表示は点滅させない（読めることを優先） */
.tbox.phase-danger .tbox-time {
  animation: pulse 1s steps(2, end) infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  .tbox.phase-danger .tbox-time { animation: none; }
  .tbox { transition: none; }
}

/* 文字は箱の大きさに追従させる。cqh = コンテナ高さの1% */
.tbox-time {
  font-size: 52cqh;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.tbox-label {
  font-size: 13cqh;
  font-weight: 700;
  opacity: 0.85;
  max-width: 96%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tbox-next {
  font-size: 10cqh;
  opacity: 0.6;
  max-width: 96%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tbox-label:empty, .tbox-next:empty { display: none; }

.tbox-bar {
  width: 90%;
  height: 4cqh;
  min-height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}
.tbox.theme-light .tbox-bar { background: rgba(0, 0, 0, 0.15); }
.tbox-bar > i {
  display: block;
  height: 100%;
  width: 100%;
  background: currentColor;
  transform-origin: left center;
  border-radius: inherit;
}

/* 全画面サイズのときは箱の飾りを消して、ど真ん中に数字だけ出す */
.tbox.size-full {
  border-radius: 0;
  padding: 0;
}

/* ============================ 2) パネル ============================ */

.panel-root {
  padding: 10px 12px 28px;
  max-width: 720px;
  margin: 0 auto;
  font-size: 14px;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 10px;
}
.head h1 { font-size: 17px; margin: 0; }
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #232a38;
  color: #9fb0c9;
  white-space: nowrap;
}
.badge.on { background: #1c5c3a; color: #b9f5d4; }

.notice {
  background: #3a2a12;
  border: 1px solid #6b4a1c;
  color: #ffd9a3;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
}

.card {
  background: #1a1f2b;
  border: 1px solid #2a3243;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.card h2 {
  font-size: 13px;
  margin: 0 0 8px;
  color: #9fb0c9;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hint { font-size: 12px; color: #8a99b0; margin: 4px 0 8px; line-height: 1.6; }
.hint.warn { color: #ffc978; }
.hint code { background: #222a38; padding: 1px 5px; border-radius: 4px; }

.lbl {
  display: block;
  font-size: 11.5px;
  color: #8a99b0;
  margin: 10px 0 5px;
  font-weight: 700;
}
.lbl.inline { display: inline; margin: 0 8px 0 0; }

/* --- 現在のタイマー --- */
.now { text-align: center; }
.now-label { font-size: 13px; color: #9fb0c9; min-height: 18px; }
.now-time {
  font-size: 48px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  margin: 2px 0 6px;
}
.now.phase-warn .now-time { color: #ffd34d; }
.now.phase-danger .now-time { color: #ff6b6b; }
.now.phase-over .now-time { color: #ff6b6b; }
.now-bar {
  height: 6px;
  background: #2a3243;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.now-bar > i {
  display: block;
  height: 100%;
  width: 100%;
  background: #4c8dff;
  transform-origin: left center;
}
.now.phase-warn .now-bar > i { background: #ffd34d; }
.now.phase-danger .now-bar > i, .now.phase-over .now-bar > i { background: #ff6b6b; }

/* --- ボタン --- */
button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid #33405a;
  background: #222a38;
  color: #e8ecf3;
  padding: 8px 12px;
  cursor: pointer;
  transition: filter 0.12s;
}
button:hover:not(:disabled) { filter: brightness(1.18); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: #2f6bff; border-color: #2f6bff; color: #fff; font-weight: 700; }
button.ghost { background: #202634; }
button.small { padding: 5px 9px; font-size: 12px; }
button.big { padding: 11px 16px; font-size: 15px; }
button.wide { width: 100%; }
button.danger { color: #ff9d9d; border-color: #5a2b33; }
button.on { background: #1c5c3a; border-color: #2b8a58; color: #c9ffe4; }

.btn-row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.btn-row > button { flex: 1 1 auto; }
.btn-row.right { justify-content: flex-end; }
.btn-row.right > button { flex: 0 0 auto; }

.row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
.opt { font-size: 12.5px; color: #c3cede; display: inline-flex; align-items: center; gap: 5px; }
.mono { font-variant-numeric: tabular-nums; font-size: 12px; color: #8a99b0; }
input[type="range"] { flex: 1; accent-color: #2f6bff; }

input[type="text"], input[type="number"], input[type="time"] {
  font: inherit;
  background: #131822;
  border: 1px solid #33405a;
  color: #e8ecf3;
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 0;
}
input:focus { outline: 2px solid #2f6bff; outline-offset: 1px; }

/* --- 位置の3×3グリッド --- */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  aspect-ratio: 16 / 9;
  background: #131822;
  border: 1px solid #2a3243;
  border-radius: 10px;
  padding: 4px;
}
.pos-grid button {
  border-radius: 6px;
  border: 1px dashed #33405a;
  background: transparent;
  padding: 0;
  font-size: 10px;
  color: #6c7c95;
}
.pos-grid button.sel {
  background: #2f6bff;
  border: 1px solid #2f6bff;
  color: #fff;
  font-weight: 700;
}

.chip-row { display: flex; gap: 5px; flex-wrap: wrap; }
.chip-row button { padding: 6px 10px; font-size: 12.5px; }
.chip-row button.sel { background: #2f6bff; border-color: #2f6bff; color: #fff; font-weight: 700; }

/* --- プレビュー --- */
.preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #2b3345, #1b2130);
  border: 1px solid #2a3243;
  border-radius: 10px;
  overflow: hidden;
}
.preview-person {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #55627a;
}
.preview-box {
  position: absolute;
  left: var(--left, 25%);
  top: var(--top, 70%);
  width: var(--w, 50%);
  height: var(--h, 22%);
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(10, 12, 18, 0.86);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  transition: all 0.25s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.preview-box.back { opacity: 0.5; }
.preview-box.theme-light { background: rgba(255, 255, 255, 0.92); color: #10131a; }
.preview-box.theme-neon { background: rgba(4, 8, 20, 0.9); color: #7cf5c8; box-shadow: 0 0 0 2px rgba(124,245,200,.5); }
.preview-box.theme-clear { background: transparent; box-shadow: none; text-shadow: 0 1px 3px #000; }

/* --- 予定リスト --- */
.queue { list-style: none; margin: 0; padding: 0; }
.qitem {
  border: 1px solid #2a3243;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 7px;
  background: #161b25;
}
.qitem.active { border-color: #2f6bff; box-shadow: 0 0 0 1px #2f6bff inset; }
.qitem .qhead { display: flex; align-items: center; gap: 6px; }
.qitem .qhead input[type="text"] { flex: 1; }
.qitem .qgrid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 5px 6px;
  align-items: center;
  margin-top: 7px;
}
.qitem .qgrid label { font-size: 11px; color: #8a99b0; white-space: nowrap; }
.qitem .qgrid input { width: 100%; }
.qitem .qopts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 7px; }
.qitem .qacts { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.qitem .qacts button { font-size: 11.5px; padding: 4px 8px; }
.qitem .qnum {
  width: 20px; height: 20px; flex: 0 0 20px;
  border-radius: 999px; background: #2a3243; color: #9fb0c9;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.qitem.active .qnum { background: #2f6bff; color: #fff; }

.foot { text-align: center; font-size: 11px; color: #55627a; padding: 6px 0 0; }
.foot a { color: #6c7c95; }

/* --- ダイアログ --- */
.dlg {
  border: 1px solid #2a3243;
  border-radius: 14px;
  background: #1a1f2b;
  color: #e8ecf3;
  padding: 16px;
  max-width: 340px;
  width: calc(100% - 32px);
}
.dlg::backdrop { background: rgba(0, 0, 0, 0.55); }
.dlg h3 { margin: 0 0 8px; font-size: 15px; }
.dlg input[type="number"] { width: 80px; }
.mono-list { color: #b6c4da; line-height: 1.8; word-break: break-all; }
