/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #111;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  overflow: hidden;
}

/* ── App shell: 動画ステージ(hero) + コントロールドック (Phase E) ────────────── */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Video stage — 主役。動画 + 常時プレビューオーバーレイ。 */
.stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #0c0c0c;
}
/* 16:9 を厳密に保ちつつ、幅か高さの小さい方に収める（プレビュー整合のため厳密16:9） */
.stage .video-wrap,
.stage .time-display { width: min(100%, calc((100vh - 64px) * 16 / 9)); }

/* Control dock — PC: 動画に重ならない右ドック（スクロール） */
.dock {
  flex: 0 0 auto;
  width: clamp(380px, 40vw, 660px);
  overflow-y: auto;
  border-left: 1px solid #2a2a2a;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dock-grip { display: none; }   /* mobile sheet handle */
.tabbar    { display: none; }   /* mobile tab bar (PCでは非表示) */

/* Scoreboard control iframe — dock 内で一定の高さを確保 */
.scoreboard-wrap {
  position: relative;
  width: 100%;
  height: 50vh;
  min-height: 300px;
}
/* Scale scoreboard to ~75% so controls are compact but still usable */
.scoreboard-wrap #scoreboard-frame {
  width:  133.34%;   /* 100% ÷ 0.75 — oversized so it fills the wrap after scaling */
  height: 133.34%;
  transform: scale(0.75);
  transform-origin: top left;
  border: none;
  background: #000;
  display: block;
}

/* Script / Jobs テーブルは内部スクロール */
.card-script { display: flex; flex-direction: column; }
.card-script .table-wrap { max-height: 40vh; overflow-y: auto; }
.jobs-list { display: flex; flex-direction: column; }
.card-jobs .jobs-list { max-height: 42vh; overflow-y: auto; }

/* AVCHD 準備状況の表示 */
.prepare-status { font-size: 11px; color: #9ca3af; }

/* ジョブのダウンロードリンク（完了時に表示） */
.btn-download {
  display: inline-block;
  background: #14532d; border: 1px solid #15803d; color: #86efac;
  border-radius: 4px; padding: 4px 10px; font-size: 12px;
  text-decoration: none; white-space: nowrap;
}
.btn-download:hover { background: #15803d; color: #fff; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.card h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 5px;
}

/* ── Video — 16:9, no letterbox ────────────────────────────────────────────── */
.video-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  border-radius: 4px;
  position: relative;
}
.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* Scoreboard preview overlay — scaled to fit the video-wrap */
.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  border: none;
  background: transparent;
  pointer-events: none;
}

.time-display {
  font-size: 11px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 6px;
}
.time-display .timecode { margin-left: auto; font-family: monospace; }
.time-display .game-time { font-weight: 700; color: #e0e0e0; font-size: 12px; }

.refresh-btn {
  font-size: 10px;
  padding: 2px 7px;
  flex-shrink: 0;
}

/* ── Rows ──────────────────────────────────────────────────────────────────── */
.row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
button {
  background: #2e2e2e;
  color: #ddd;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
button:hover:not(:disabled) { background: #3a3a3a; }
button:disabled { opacity: 0.4; cursor: default; }

.record-btn {
  background: #7f1d1d;
  border-color: #991b1b;
  color: #fca5a5;
  font-weight: 600;
}
.record-btn:hover:not(:disabled) { background: #991b1b; }
.record-btn.flash { background: #14532d; border-color: #15803d; color: #86efac; }

.render-btn {
  background: #1e3a5f;
  border-color: #1d4ed8;
  color: #93c5fd;
  font-weight: 600;
  padding: 6px 16px;
}
.render-btn:hover:not(:disabled) { background: #1d4ed8; color: #fff; }

/* ── Inputs ────────────────────────────────────────────────────────────────── */
input[type="text"], input[type="number"] {
  background: #111;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
}
input:focus { outline: 1px solid #666; }

.output-row { align-items: center; }
.output-label { white-space: nowrap; color: #888; font-size: 11px; min-width: 52px; }
.output-input { flex: 1; min-width: 0; }

/* ── Path label ────────────────────────────────────────────────────────────── */
.path-label {
  font-size: 11px;
  color: #666;
  word-break: break-all;
  flex: 1;
}

.record-status { font-size: 11px; color: #4ade80; }

/* ── Script table ──────────────────────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
/* Fixed layout + column widths apply ONLY to the script table, so they don't
   leak into other tables (e.g. the SuperSoccer import modal). */
#script-table { table-layout: fixed; }
/* Column widths — チェック最小, 時刻・種別 narrow, 内容 takes the rest */
#script-table thead th:nth-child(1), #script-table tbody td:nth-child(1) { width: 26px; padding: 0; text-align: center; }
#script-table thead th:nth-child(2), #script-table tbody td:nth-child(2) { width: 92px; }
#script-table thead th:nth-child(3), #script-table tbody td:nth-child(3) { width: 30px; }
/* nth-child(4) = 内容: no explicit width → fills remaining space */
thead th {
  background: #111;
  color: #777;
  padding: 3px 6px;
  text-align: left;
  position: sticky;
  top: 0;
  white-space: nowrap;
  overflow: hidden;
}
tbody tr:nth-child(even) { background: #1a1a1a; }
tbody tr:hover { background: #222; cursor: pointer; }
tbody tr.selected { background: #1e3a5f !important; }
td {
  padding: 2px 6px;
  color: #bbb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.empty-msg { color: #555; font-style: italic; text-align: center; padding: 12px; }
@keyframes rowflash { 0% { background: #2a5a8a; } 100% { background: transparent; } }
#script-tbody tr.row-flash { animation: rowflash 1.3s ease-out; }

/* ── Editable time cell ─────────────────────────────────────────────────────── */
.time-cell { cursor: pointer; }
.time-cell .tc { color: #60a5fa; }
.time-cell:hover .tc { text-decoration: underline; }
.time-input { width: 56px; }
.seek-btn {
  background: none; border: none; color: #888; cursor: pointer;
  font-size: 6px; padding: 0 3px 0 0; line-height: 1; vertical-align: middle;
}
.seek-btn:hover { color: #60a5fa; }

/* ── Params column — formatted state summary ────────────────────────────────── */
.params-col { cursor: help; color: #c8d0e0; }
.params-mode  { color: #fbbf24; font-weight: 600; }   /* 準備/LIVE/HT… */
.params-score { color: #86efac; font-weight: 600; }   /* 2–1 */
.params-half  { color: #93c5fd; }                     /* 前半/後半 */
.params-timer { color: #fb923c; font-weight: 600; }   /* ⏱ timer running */
.params-timer-start { color: #4ade80; font-weight: 600; }   /* ▶ 開始 */
.params-timer-stop  { color: #f87171; font-weight: 600; }   /* ■ 停止 */
.params-timer-reset { color: #fb923c; font-weight: 600; }   /* ↺ リセット */
.params-at          { color: #e879f9; font-weight: 600; }   /* +AT */
.params-goal-min    { color: #fde047; font-weight: 600; }   /* 前半4分 */
.params-telop { color: #c084fc; }                     /* telop text */
.params-teams { color: #94a3b8; }                     /* team names */

/* ── Delete row button ──────────────────────────────────────────────────────── */
.del-btn {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 14px;
  padding: 0 3px;
  line-height: 1;
}
.del-btn:hover { color: #f87171; }

/* ── Script multi-select ──────────────────────────────────────────────────── */
.sel-count { font-size: 10px; color: #38bdf8; margin-left: auto; white-space: nowrap; }
.sel-col { width: 26px; text-align: center; }
.sel-box { cursor: pointer; vertical-align: middle; margin: 0; }

/* ── Mode buttons ─────────────────────────────────────────────────────────── */
.mode-btn { flex: 1; }
.mode-btn.mode-active-standby   { background:#1e3a5f; border-color:#2563eb; color:#93c5fd; font-weight:700; }
.mode-btn.mode-active-recording { background:#7f1d1d; border-color:#991b1b; color:#fca5a5; font-weight:700; }
.mode-btn.mode-active-playback  { background:#14532d; border-color:#15803d; color:#86efac; font-weight:700; }

/* ── Render mode buttons ──────────────────────────────────────────────────── */
.render-mode-active { background:#1e3a5f; border-color:#2563eb; color:#93c5fd; font-weight:700; }
.timer-offset-input { width:72px; }

/* ── Playback lock: block interaction with the scoreboard control panel ─────── */
.scoreboard-wrap.playback-locked::after {
  content: '▶ PLAYBACK';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 6px 8px;
  color: #86efac;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  pointer-events: all;
  cursor: not-allowed;
  z-index: 10;
}

/* ── Job cards ─────────────────────────────────────────────────────────────── */
.job-card {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 5px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 11px;
}

.job-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  gap: 6px;
}

.job-filename {
  color: #aaa;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.job-mode-badge {
  font-size: 10px;
  color: #94a3b8;
  white-space: nowrap;
  background: #1e2a3a;
  border: 1px solid #2a3a50;
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.job-status {
  font-weight: 600;
  white-space: nowrap;
  font-size: 11px;
}
.job-elapsed {
  font-size: 10px;
  color: #666;
  white-space: nowrap;
}
.job-started {
  font-size: 10px;
  color: #555;
  white-space: nowrap;
  margin-left: auto;
}
.job-status.pending   { color: #888; }
.job-status.running   { color: #fbbf24; }
.job-status.done      { color: #4ade80; }
.job-status.error     { color: #f87171; }
.job-status.cancelled { color: #94a3b8; }

/* ── Progress bar ──────────────────────────────────────────────────────────── */
.progress-track {
  background: #222;
  border-radius: 3px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 5px;
}
.progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 3px;
  transition: width 0.4s;
}

/* ── ETA row ───────────────────────────────────────────────────────────────── */
.job-eta-row {
  font-size: 9px;
  color: #666;
  text-align: right;
  min-height: 11px;
  margin-top: 2px;
  margin-bottom: 2px;
  font-family: monospace;
}

/* ── Job log ───────────────────────────────────────────────────────────────── */
.job-log {
  background: #0d0d0d;
  border-radius: 3px;
  padding: 4px 6px;
  font-family: monospace;
  font-size: 10px;
  color: #888;
  max-height: 72px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 5px;
}

/* ── Job action buttons ────────────────────────────────────────────────────── */
.job-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.job-actions button {
  font-size: 11px;
  padding: 2px 8px;
}
.btn-cancel  { border-color: #7f1d1d; color: #fca5a5; }
.btn-cancel:hover:not(:disabled) { background: #7f1d1d; }
.btn-rerun   { border-color: #1e3a5f; color: #93c5fd; }
.btn-rerun:hover:not(:disabled) { background: #1e3a5f; }
/* ── Notice box ────────────────────────────────────────────────────────────── */
.notice {
  background: #1c1200;
  border: 1px solid #5c3d00;
  border-radius: 4px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.6;
  color: #d97706;
}
.notice code {
  background: #0d0d0d;
  border-radius: 2px;
  padding: 1px 3px;
  font-size: 10px;
}

/* ── SuperSoccer import modal ──────────────────────────────────────────────── */
.ss-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.ss-modal {
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  width: min(720px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.ss-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #2a2a2a;
}
.ss-modal-head h3 { margin: 0; font-size: 14px; color: #ddd; }
.ss-modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.ss-modal-close:hover { color: #ddd; }
.ss-modal-status {
  padding: 8px 14px;
  font-size: 11px;
  color: #888;
}
.ss-modal-status.error { color: #f87171; }
.ss-modal-body {
  overflow-y: auto;
  padding: 0 14px 14px;
}
/* 動画ペイン: ① を開き直すボタン */
.wiz-edit-btn {
  border-color: #3f3f46;
  color: #e4e4e7;
  font-weight: 600;
}
.wiz-edit-btn:hover:not(:disabled) { background: #27272a; }

/* ── Wizard (Phase G) ─────────────────────────────────────────────────────────── */
.stage { position: relative; }

/* ウィザード操作列: 案内チップ＋「＋ イベントを追加」ボタン（動画の横に常時表示） */
.wiz-row {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  width: min(100%, calc((100vh - 64px) * 16 / 9));
}
.record-fab {
  flex-shrink: 0;
  width: 78px; height: 78px; border-radius: 50%;
  background: #dc2626; color: #fff;
  border: 2px solid #f87171;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 6px 22px rgba(220, 38, 38, 0.5);
  cursor: pointer; padding: 0;
}
.record-fab .fab-plus { font-size: 30px; font-weight: 800; line-height: 1; }
.record-fab .fab-label { font-size: 9px; font-weight: 700; letter-spacing: 0.02em; margin-top: 1px; }
.record-fab:hover { background: #ef4444; }
.record-fab:active { transform: scale(0.95); }

/* 案内チップ（ボタンの左に置く「次の一手」） */
.wiz-bar {
  background: rgba(30, 58, 95, 0.55);
  border: 1px solid #1d4ed8; border-radius: 8px;
  padding: 9px 12px; color: #cfe3ff; font-size: 13px; font-weight: 600;
}

/* ウィザードシートの大きい選択ボタン */
.wiz-sheet {
  max-width: 480px;
  max-height: 88vh; max-height: 88dvh;   /* 小画面では内部スクロール（はじめる が届くように） */
  overflow-y: auto;
}
.wiz-body { display: flex; flex-direction: column; gap: 6px; padding: 4px 2px 6px; }
.wiz-choice {
  display: block; width: 100%;
  padding: 15px 14px; margin: 2px 0;
  font-size: 16px; font-weight: 700; text-align: center;
  border-radius: 10px; border: 1px solid #444;
  background: #2e2e2e; color: #e5e5e5;
}
.wiz-choice:hover:not(:disabled) { background: #3a3a3a; }
.wiz-primary { background: #1e3a5f; border-color: #1d4ed8; color: #bfdbfe; }
.wiz-primary:hover:not(:disabled) { background: #1d4ed8; color: #fff; }
.wiz-goal    { background: #14532d; border-color: #16a34a; color: #bbf7d0; }
.wiz-goal:hover:not(:disabled) { background: #16a34a; color: #fff; }
.wiz-danger  { background: #7f1d1d; border-color: #b91c1c; color: #fecaca; }
.wiz-danger:hover:not(:disabled) { background: #b91c1c; color: #fff; }
.wiz-note { font-size: 12px; color: #9ca3af; text-align: center; }
.wiz-time-chip {
  align-self: center; font-family: monospace; font-size: 13px; color: #cfe3ff;
  background: #16233a; border: 1px solid #1d4ed8; border-radius: 999px; padding: 4px 14px;
}

/* デザイン選択（①フォーム内・横スクロールカード） */
.wiz-design-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; }
.wiz-design-card {
  flex: 0 0 auto; width: 132px; cursor: pointer;
  background: #161616; border: 2px solid #333; border-radius: 8px; padding: 6px;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.wiz-design-card img { width: 120px; height: 68px; object-fit: cover; border-radius: 4px; background: #000; }
.wiz-design-card span { font-size: 11px; color: #ccc; }
.wiz-design-card.selected { border-color: #1d4ed8; background: #16233a; }
.wiz-design-card.selected span { color: #bfdbfe; }

/* 試合情報フォーム */
.wiz-form-grid { display: flex; flex-direction: column; gap: 8px; }
.wiz-form-grid select {
  background: #111; color: #e0e0e0; border: 1px solid #444; border-radius: 4px;
  padding: 9px 10px; font-size: 15px;
}
.wiz-format-detail { display: flex; gap: 10px; }
.wiz-format-detail label { flex: 1; }
/* PKモードへ（試合前スーパーの右上に置く小ボタン） */
.wiz-pre-wrap { position: relative; }
.wiz-pk-btn {
  position: absolute; top: -6px; right: 0;
  font-size: 11px; padding: 4px 10px; min-height: 0;
  background: #2e2e2e; border: 1px solid #555; border-radius: 999px; color: #ccc;
}
.wiz-form-grid label, .wiz-team label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: #9ca3af;
}
.wiz-form-grid input, .wiz-team input { padding: 9px 10px; font-size: 15px; }
.wiz-team-row { display: flex; gap: 10px; margin: 8px 0; }
.wiz-team { flex: 1; display: flex; flex-direction: column; gap: 6px;
  background: #161616; border: 1px solid #2a2a2a; border-radius: 8px; padding: 10px; }
.wiz-team h4 { font-size: 12px; color: #bbb; }
.wiz-team input[type="color"] { padding: 2px; height: 38px; }

/* ── Login overlay (Phase F) ──────────────────────────────────────────────────── */
.login-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.login-card {
  background: #1c1c1c; border: 1px solid #333; border-radius: 10px;
  padding: 22px 20px; width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.login-card h3 { font-size: 15px; color: #e0e0e0; }
.login-card input {
  width: 100%; padding: 9px 10px; font-size: 14px;
}
.login-actions { display: flex; gap: 8px; }
.login-actions button { flex: 1; padding: 8px 0; font-size: 13px; }
.login-error { color: #fca5a5; font-size: 12px; min-height: 15px; }

/* ── Responsive (Phase E): スマホは全面動画ステージ + ペイン別シート ───────────
   狭幅(<=900px) または 低背(<=520px: スマホ横持ち。iPhone Pro Max 横は幅932px
   なので幅だけでは拾えない)では動画ステージを画面いっぱいにし、コントロールを
   タブバー + シートに変える。縦持ち=下から / 横持ち=右から（後続ブロックで上書き）。 */
@media (max-width: 900px), (max-height: 520px) {
  html, body { overflow: hidden; height: 100%; }

  .app { display: block; height: 100%; }

  /* 動画ステージは画面いっぱい（シートを閉じれば全面プレビュー）。下のタブバー分を空ける。 */
  .stage {
    height: 100vh; height: 100dvh;
    padding: 8px 8px 64px;
  }
  .stage .video-wrap,
  .stage .time-display { width: 100%; }

  /* 下部タブバー（5ペイン切替） */
  .tabbar {
    display: flex; z-index: 60;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: rgba(14,14,14,0.96);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid #2a2a2a;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-btn {
    flex: 1 1 0; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    background: none; border: none; color: #9aa0a6;
    font-size: 10px; padding: 7px 2px; height: 56px;
  }
  .tab-btn .tab-ico { font-size: 18px; line-height: 1; }
  .tab-btn.active { color: #cfe3ff; background: rgba(30,58,95,0.45); }

  /* ボトムシート（タブバーの上に重なる・既定は隠れている） */
  .dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    width: auto;
    max-height: 80vh; max-height: 80dvh;
    border-left: none;
    border-top: 1px solid #333;
    border-radius: 14px 14px 0 0;
    background: rgba(18,18,18,0.96);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    box-shadow: 0 -8px 28px rgba(0,0,0,0.6);
    transform: translateY(100%);
    transition: transform 0.28s ease;
    /* 下端はタブバー(56px)+セーフエリアの分だけ内側に余白を取り、内容が隠れないように */
    padding: 6px 10px calc(56px + env(safe-area-inset-bottom) + 12px);
  }
  .dock.open { transform: translateY(0); }

  .dock-grip {
    display: block; flex: none;
    width: 44px; height: 5px; margin: 4px auto 8px;
    border-radius: 3px; background: #555; cursor: pointer;
  }

  /* ペイン別表示: 既定で全カードを隠し、アクティブなペインのカードだけ表示する。
     設定タブはスコアボードと同じ iframe を共有し、JS が設定モーダルを開く。 */
  .dock > section { display: none; }
  .dock[data-active="video"]      > section[data-pane="video"],
  .dock[data-active="scoreboard"] > section[data-pane="scoreboard"],
  .dock[data-active="settings"]   > section[data-pane="scoreboard"],
  .dock[data-active="events"]     > section[data-pane="events"],
  .dock[data-active="jobs"]       > section[data-pane="jobs"] { display: flex; }

  /* シート内は各表を控えめな高さで内部スクロール */
  .scoreboard-wrap { height: 58vh; min-height: 300px; }
  .card-script .table-wrap { max-height: 50vh; }
  .card-jobs .jobs-list { max-height: 42vh; }
}

/* ── スマホ横持ち（低背ビューポート）: タブバーは右端の縦列、シートは右から ──────
   下からのシートは横持ちだと動画を覆いすぎるため、左右スライドのドロワーにする。 */
@media (max-height: 520px) and (orientation: landscape) {
  /* タブバー: 右端に縦配置 */
  .tabbar {
    left: auto; top: 0; right: 0; bottom: 0;
    flex-direction: column;
    width: 64px;
    border-top: none; border-left: 1px solid #2a2a2a;
    padding-bottom: 0;
    padding-right: env(safe-area-inset-right);
  }
  .tab-btn { flex: 1 1 0; height: auto; padding: 4px 2px; }

  /* 動画ステージ: 右のタブバー分だけ空ける（下は空けない） */
  .stage { padding: 8px calc(72px + env(safe-area-inset-right)) 8px 8px; }

  /* シート → 右ドロワー（タブバーの左隣に、右からスライドイン） */
  .dock {
    left: auto; top: 0; bottom: 0;
    right: calc(64px + env(safe-area-inset-right));
    width: min(440px, 62vw);
    max-height: none;
    border-top: none; border-left: 1px solid #333;
    border-radius: 14px 0 0 14px;
    transform: translateX(120%);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }
  .dock.open { transform: translateX(0); }
  .dock-grip { display: none; }   /* 縦グリップは無意味なので消す（タブ再タップで閉じる） */

  /* 低い画面では各表の高さも絞る */
  .scoreboard-wrap { height: 70vh; min-height: 200px; }
  .card-script .table-wrap { max-height: 46vh; }
  .card-jobs .jobs-list { max-height: 40vh; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }       /* タッチで読みやすく */
  .row { flex-wrap: wrap; }       /* ボタン列を折り返す */
}

/* ── スマホのタッチターゲット拡大（Phase G GUI整理） ─────────────────────────── */
@media (max-width: 900px), (max-height: 520px) {
  button { min-height: 42px; font-size: 14px; padding: 8px 14px; }
  .refresh-btn { min-height: 32px; font-size: 12px; }
  input[type="text"], input[type="number"], input[type="email"], input[type="password"] {
    font-size: 16px; padding: 9px 10px;   /* 16px未満だとiOSがズームするため */
  }
  #script-table td, #script-table th { padding: 9px 8px; font-size: 13px; }
  .wiz-bar { font-size: 14px; padding: 11px 12px; }
  /* 操作列はタブバーの上に固定（画面遷移しても常に見える） */
  .wiz-row {
    position: fixed; right: 14px; left: 14px; width: auto;
    bottom: calc(56px + env(safe-area-inset-bottom) + 14px);
    z-index: 55;
  }
  /* ただしボトムシート（動画/イベント/レンダー）を開いている間は隠す。
     固定配置のままだとシート上部のボタンに重なって押せなくなるため。 */
  body.dock-open .wiz-row { display: none; }
}

/* ── 法定ページへのリンク（ログイン画面・アカウントカード） ──────────────── */
.legal-links { margin-top: 14px; font-size: 12px; opacity: .7; }
.legal-links a { margin-right: 14px; }
