/* 大画面でも広く使う。完全撤廃は 16:9 ステージがビューポートを超えるため上限は残す。 */
.ste-wrap { padding: 24px; max-width: 1600px; }
.ste-loading { color: #64748b; padding: 40px 0; }

/* --- ヘッダー --- */
.ste-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.ste-header-left { display: flex; align-items: center; gap: 12px; }
.ste-header h2 { font-size: 18px; font-weight: 700; margin: 0; white-space: nowrap; }
.ste-sub { color: #64748b; font-size: 13px; margin: 0 0 16px; }
.ste-header-actions { display: flex; align-items: center; gap: 10px; }

.ste-select {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
}
.ste-btn-primary {
  padding: 8px 20px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ste-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.ste-btn-primary:hover:not(:disabled) { background: #1d4ed8; }

/* 副ボタン (JSON ダウンロード・履歴の読み込み等) */
.ste-btn-sub {
  padding: 7px 14px;
  background: #fff;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ste-btn-sub:hover { background: #f1f5f9; }

.ste-dirty { font-size: 12px; font-weight: 700; color: #d97706; }

/* テンプレ開始時刻 (絶対時刻の基準。現状は暗黙知をラベルで明示) */
.ste-start-label {
  font-size: 12px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 5px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* --- タブ --- */
.ste-tabs {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  overflow: hidden;
}
.ste-tab {
  padding: 6px 16px;
  background: #fff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
}
.ste-tab + .ste-tab { border-left: 1px solid #cbd5e1; }
.ste-tab:hover:not(.ste-tab-active) { background: #f1f5f9; }
.ste-tab-active { background: #2563eb; color: #fff; }

/* --- プレビュー: レイアウト (左=ステージ列 / 右=チャット列) --- */
/* チャットは絶対配置でステージ列の高さ (上端〜凡例下端) に固定し、
   中身だけスクロールさせる。幅は画面比 (約 78:22) を保って伸縮。 */
.ste-preview {
  position: relative;
}
.ste-preview-main {
  width: calc(78% - 8px);
}

/* --- プレビュー: ステージ --- */
.ste-stage {
  /* 横幅は列幅に追従しつつ、高さ (= width * 9/16) が (100vh - 380px) を
     超えないよう width 側で頭打ちにする。画面が縦に狭くても見切れない。
     380px はヘッダー・トランスポート・タイムライン (BGM レーン追加で +18px)・凡例等の確保高。 */
  width: min(100%, max(360px, calc((100vh - 380px) * 16 / 9)));
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 8px;
  background: #0f172a;
}

/* --- プレビュー: トランスポート --- */
.ste-transport {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.ste-play {
  width: 40px;
  height: 36px;
  font-size: 16px;
  background: #1e293b;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.ste-play:hover { background: #334155; }
.ste-step {
  width: 34px;
  height: 36px;
  font-size: 13px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.ste-step:hover { background: #e2e8f0; }
.ste-scrubber { flex: 1; cursor: pointer; accent-color: #2563eb; }
.ste-time {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #475569;
  white-space: nowrap;
}
.ste-speed { padding: 4px 8px; }

/* --- プレビュー: 拡大シーク（現在位置の前後だけを広げたバー）と秒送り --- */
.ste-fine {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
}
.ste-fine-label { font-size: 12px; color: #475569; white-space: nowrap; cursor: help; }
.ste-fine-window { padding: 3px 6px; font-size: 12px; }
.ste-fine-edge { font-size: 11px; font-variant-numeric: tabular-nums; color: #64748b; white-space: nowrap; }
.ste-fine-scrubber { accent-color: #7c3aed; }
.ste-nudge { display: inline-flex; gap: 4px; flex-shrink: 0; }
.ste-nudge-btn { width: auto; min-width: 40px; height: 28px; font-size: 12px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.ste-time-input {
  width: 84px;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  text-align: center;
}
.ste-time-input:focus { outline: 2px solid #2563eb; outline-offset: 1px; }
@media (max-width: 900px) { .ste-fine { flex-wrap: wrap; } .ste-fine-scrubber { flex-basis: 100%; order: 10; } }

/* --- プレビュー: タイムライン --- */
/* 上から: seminar マーカー行 / 帯 / カメラレーン / BGM レーン / video マーカー行 */
.ste-timeline {
  position: relative;
  height: 140px;
  margin-top: 10px;
  cursor: pointer;
}
.ste-tl-row {
  position: absolute;
  left: 0;
  right: 0;
  height: 24px;
}
.ste-tl-seminar { top: 0; }
.ste-tl-video { top: 114px; }

.ste-timeline-track {
  position: absolute;
  top: 26px;
  left: 0;
  right: 0;
  height: 20px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.ste-band {
  position: absolute;
  top: 0;
  height: 20px;
}
.ste-band-segment { background: #93c5fd; border-right: 1px solid #fff; }
.ste-band-hold { background: #cbd5e1; }

/* カメラ ON/OFF 連続レーン (待機中も状態が一目で分かる) */
.ste-cam-lane {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
}
.ste-cam-span {
  position: absolute;
  top: 0;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  color: #fff;
}
.ste-cam-on  { background: #22c55e; }
.ste-cam-off { background: #94a3b8; }

/* マイク ON/OFF 連続レーン (segment 中 / BGM 中 = ON、それ以外 = OFF) */
.ste-mic-lane {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
}
.ste-mic-span {
  position: absolute;
  top: 0;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  color: #fff;
}
.ste-mic-on  { background: #0ea5e9; }
.ste-mic-off { background: #94a3b8; }

/* BGM ON/OFF 連続レーン (Hold/NotStarted 中に流れる BGM の active 区間) */
.ste-bgm-lane {
  position: absolute;
  top: 80px;
  left: 0;
  right: 0;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
}
.ste-bgm-span {
  position: absolute;
  top: 0;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
}
.ste-bgm-on  { background: #fb923c; color: #fff; }
.ste-bgm-off { background: #f1f5f9; color: #94a3b8; }

/* テロップ 表示/非表示 連続レーン (字幕オーバーレイの active 区間) */
.ste-telop-lane {
  position: absolute;
  top: 96px;
  left: 0;
  right: 0;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
}
.ste-telop-span {
  position: absolute;
  top: 0;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
.ste-telop-on  { background: #a78bfa; color: #fff; }
.ste-telop-off { background: #f1f5f9; color: #94a3b8; }

/* マーカー: ▶ 映像再生 / ▽ 待機画像 / 💬 チャット */
.ste-marker {
  position: absolute;
  transform: translateX(-50%);
  line-height: 1;
  pointer-events: none;
}
.ste-marker-chat { top: 2px; font-size: 12px; }
.ste-tri-segment,
.ste-tri-hold {
  display: inline-block;
  width: 0;
  height: 0;
}
.ste-tri-segment {
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 9px solid #2563eb;
}
.ste-tri-hold {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 9px solid #94a3b8;
}
.ste-tl-seminar .ste-marker { bottom: 0; }
.ste-tl-video .ste-marker:not(.ste-marker-chat) { top: 0; }

.ste-playhead {
  position: absolute;
  top: 22px;
  height: 116px;
  width: 2px;
  background: #dc2626;
  transform: translateX(-1px);
  pointer-events: none;
  z-index: 2;
}
.ste-timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 6px;
  font-size: 11px;
  color: #64748b;
}

/* 時刻合わせレーン (プレビューからの offsetSec / vpos 編集) */
.ste-align {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #cbd5e1;
}
.ste-align-lane {
  position: relative;
  /* 高さはピンの段数に応じて inline style で指定される */
  min-height: 26px;
  margin-bottom: 8px;
  background: #f8fafc;
  border-radius: 4px;
}
.ste-align-pin {
  position: absolute;
  /* top はピンの段 (row) に応じて inline style で指定される */
  transform: translateX(-50%);
  padding: 1px 3px;
  font-size: 13px;
  line-height: 1;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
}
.ste-align-pin:hover { border-color: #2563eb; }
.ste-align-pin-selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
  z-index: 2;
}
.ste-align-pin-oor { opacity: 0.55; }
.ste-align-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ste-align-info { font-size: 12px; color: #475569; }
.ste-align-axis { color: #94a3b8; }
.ste-align-btn { white-space: nowrap; }
.ste-lg-item { display: inline-flex; align-items: center; gap: 4px; }
.ste-lg {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}
.ste-lg-cam-on  { background: #22c55e; }
.ste-lg-cam-off { background: #94a3b8; }
.ste-lg-mic-on  { background: #0ea5e9; }
.ste-lg-mic-off { background: #94a3b8; }
.ste-lg-bgm-on  { background: #fb923c; }
.ste-lg-bgm-off { background: #f1f5f9; border: 1px solid #cbd5e1; }
.ste-lg-telop-on { background: #a78bfa; }

/* --- プレビュー: チャット --- */
.ste-chat {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: calc(22% - 8px);
  display: flex;
  flex-direction: column;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
}
.ste-chat-title {
  padding: 8px 14px;
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}
.ste-chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 14px;
}
.ste-chat-empty { color: #94a3b8; font-size: 13px; padding: 12px 0; }
.ste-chat-msg { padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.ste-chat-msg:last-child { border-bottom: none; }
.ste-chat-meta {
  font-size: 11px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}
.ste-chat-elapsed { color: #94a3b8; }
/* 絶対時刻は経過時間と区別できるよう琥珀色 */
.ste-chat-abs { color: #d97706; margin-left: 8px; }
.ste-chat-sender { color: #94a3b8; margin-left: 8px; }
.ste-chat-text {
  font-size: 13px;
  color: #1e293b;
  white-space: pre-wrap;
  word-break: break-word;
}
.ste-chat-next { opacity: 0.5; }
.ste-chat-next .ste-chat-text { color: #64748b; }

/* 運営コマンド (/ccw・/ccv 等)。Zoom チャットには流れず視聴者非表示。
   通常チャットと区別するため全体を灰色・コマンド文は等幅で薄く表示する。 */
.ste-chat-cmd { opacity: 0.75; }
.ste-chat-cmd-tag {
  margin-left: 8px;
  font-size: 10px;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 6px;
}
.ste-chat-cmd-text {
  color: #94a3b8 !important;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
}

.ste-mock-note {
  margin-top: 14px;
  font-size: 11px;
  color: #94a3b8;
}

/* --- 編集タブ: 簡易 / 詳細 サブタブ --- */
.ste-edit-wrap {
  padding-top: 4px;
}
.ste-subtabs {
  display: flex;
  gap: 2px;
  padding: 0 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}
.ste-subtab {
  padding: 6px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  position: relative;
  top: 1px;
}
.ste-subtab:hover { color: #1e293b; background: #f8fafc; }
.ste-subtab-active {
  background: #fff;
  color: #1e293b;
  border-color: #e2e8f0;
  font-weight: 600;
}

/* --- 編集タブ (JSON 一括編集) --- */
.ste-edit-json {
  padding: 12px 18px 18px;
}
.ste-edit-error-slot {
  /* error が無い間も高さを取り過ぎない / 出現時にレイアウトが暴れない */
  min-height: 0;
}
.ste-edit-error {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  padding: 8px 12px;
  margin-bottom: 8px;
  color: #991b1b;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
}
.ste-json-area {
  width: 100%;
  min-height: 600px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #f8fafc;
  color: #0f172a;
  resize: vertical;
  /* 横スクロール (wrap="off" と組み合わせ) */
  white-space: pre;
  overflow: auto;
  /* tab を空白でなく実 tab として扱う場合に幅を 2 にする */
  tab-size: 2;
}
.ste-json-area:focus {
  outline: none;
  border-color: #2563eb;
  background: #ffffff;
}

/* --- ヘルプタブ (JSON スキーマの人間向けドキュメント) --- */
.ste-help {
  padding: 12px 22px 32px;
  max-width: 980px;
  color: #1e293b;
}
.ste-help .ste-help-h2 {
  margin: 28px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #cbd5e1;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}
.ste-help .ste-help-h2:first-of-type { margin-top: 14px; }
.ste-help .ste-help-h3 {
  margin: 18px 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #2563eb;
}
.ste-help .ste-help-p {
  font-size: 13px;
  line-height: 1.7;
  margin: 6px 0;
  color: #334155;
}
.ste-help-code {
  display: block;
  padding: 10px 12px;
  margin: 6px 0 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  color: #0f172a;
}
.ste-help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 8px;
  font-size: 13px;
}
.ste-help-table thead th {
  background: #e2e8f0;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 2px solid #94a3b8;
  font-weight: 700;
  color: #475569;
}
.ste-help-table tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  color: #334155;
  line-height: 1.6;
}
.ste-help-table code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.ste-help-list {
  font-size: 13px;
  line-height: 1.8;
  margin: 6px 0 8px;
  padding-left: 22px;
  color: #334155;
}
.ste-help code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* --- 編集タブ (旧テーブル系。履歴 detail 等で再利用) --- */
.ste-section {
  margin-bottom: 24px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
}
.ste-section-header {
  padding: 10px 14px;
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
}
.ste-section-title { font-size: 14px; font-weight: 700; margin: 0 0 2px; color: #1e293b; }
.ste-section-desc { font-size: 11px; color: #94a3b8; margin: 0; }

.ste-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ste-table thead th {
  text-align: left;
  padding: 8px 12px;
  background: #e2e8f0;
  border-bottom: 2px solid #94a3b8;
  color: #475569;
  font-weight: 700;
  white-space: nowrap;
}
.ste-table tbody tr:hover { background: #f8fafc; }
.ste-table tbody tr { border-bottom: 1px solid #e2e8f0; }
.ste-table tbody tr:last-child { border-bottom: none; }
.ste-table tbody td {
  padding: 8px 12px;
  vertical-align: middle;
}

.ste-input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13px;
  text-align: right;
}
.ste-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px #dbeafe; }
.ste-input-hms { width: 110px; text-align: center; font-variant-numeric: tabular-nums; }
.ste-input-error { border-color: #ef4444; background: #fef2f2; }

.ste-hms { color: #64748b; font-size: 12px; white-space: nowrap; }

.ste-path {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 4px;
  word-break: break-all;
}
.ste-message {
  font-size: 12px;
  color: #475569;
  margin-left: 4px;
}

.ste-sub-fields {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}

/* --- 履歴タブ (テンプレ保存の版一覧・復元) --- */
.ste-history { padding: 4px 0; }
.ste-history-list { display: flex; flex-direction: column; gap: 8px; }
.ste-history-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.ste-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
}
.ste-hist-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: #64748b;
  padding: 2px 4px;
  flex-shrink: 0;
}
.ste-history-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
  font-size: 13px;
}

/* 履歴の 1 版を展開したときの中身 (seminarSchedule / videoSchedule) */
.ste-hist-detail {
  border-top: 1px solid #e2e8f0;
  padding: 10px 14px;
  background: #f8fafc;
}
.ste-hist-detail-inner {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.ste-hist-detail-col {
  flex: 1;
  min-width: 280px;
}
.ste-hist-detail-h {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 4px;
}
.ste-hist-entries {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
}
.ste-hist-entries li {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #eef2f6;
}
.ste-hist-pos {
  font-family: monospace;
  color: #64748b;
  flex-shrink: 0;
  min-width: 76px;
}
.ste-hist-label { color: #334155; }
.ste-hist-empty-li { color: #94a3b8; padding: 4px 0; }

/* 履歴展開パネル: 差分 / 全体 の切替 */
.ste-hist-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.ste-hist-mode {
  padding: 3px 12px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
}
.ste-hist-mode:disabled { opacity: 0.5; cursor: not-allowed; }
.ste-hist-mode-active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* GitHub 風 行差分 */
.ste-diff {
  font-family: monospace;
  font-size: 11px;
  line-height: 1.55;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow-x: auto;
}
.ste-diff-line { white-space: pre; padding: 0 8px; }
.ste-diff-add { background: #dcfce7; color: #166534; }
.ste-diff-del { background: #fee2e2; color: #991b1b; }
.ste-diff-ctx { color: #475569; }
.ste-diff-skip {
  padding: 2px 8px;
  color: #94a3b8;
  background: #f1f5f9;
  font-size: 10px;
  text-align: center;
}
.ste-history-time { font-family: monospace; color: #334155; }
.ste-history-by { color: #64748b; font-size: 12px; }
.ste-history-latest {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #2563eb;
  border-radius: 4px;
  padding: 1px 7px;
}
.ste-history-empty { color: #64748b; padding: 30px 0; text-align: center; }

/* ショートカットの案内（詳細はツールチップ。行が長くならないようラベルだけ置く） */
.ste-shortcut-hint {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  cursor: help;
  border-bottom: 1px dotted #94a3b8;
  flex-shrink: 0;
}
