/* fram — 絵コンテ作成補助ツール
   スタイル基準: 社内UIガイドライン(本文16px+/行間1.5+/余白8px単位/コントラスト4.5:1) */

:root {
  --ink: #1a1a1a;
  --ink-sub: #666666;
  --paper: #f5f1e6;        /* コンテ用紙のケント紙色 */
  --paper-line: #4a4436;   /* 用紙の罫線 */
  --bg: #fafafa;
  --panel: #ffffff;
  --border: #cccccc;
  --primary: #8a6d1d;      /* 鉛筆・帯の焦げ茶金(白に対し4.5:1以上) */
  --primary-dark: #6f5713;
  --accent-bg: #f0e6c8;
  --success: #197a4b;
  --error: #ce0000;
  --warn: #927200;
  --focus: #0031d8;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* display指定を持つ要素でも hidden 属性を必ず優先する */
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--bg);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

/* ---------- ヘッダー ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 24px;
  background: #262319;
  color: #f5f1e6;
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-header a { color: #f5f1e6; }

.brand {
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
}

.header-title { font-weight: 700; }
.header-sub { color: #cfc9b8; font-size: 0.875rem; }

.header-metrics {
  display: flex;
  gap: 16px;
  align-items: baseline;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.metric-label { font-size: 0.875rem; color: #cfc9b8; margin-right: 4px; }
.metric-value { font-weight: 700; }
.metric-over { color: #ffb3b3; }
.metric-ok { color: #b9e4c9; }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  color: var(--ink);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: #ffffff;
}
.btn-outline:hover { background: var(--accent-bg); }

.btn-ghost {
  border-color: #8c8672;
  color: #f5f1e6;
  background: transparent;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.btn-text {
  color: var(--primary-dark);
  text-decoration: underline;
  min-height: 44px;
}

.btn-danger-text { color: var(--error); text-decoration: underline; }

.btn-small { min-height: 36px; padding: 4px 8px; font-size: 0.875rem; }

/* ---------- 通知 ---------- */

.banner {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 16px 24px 0;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--success);
  background: #e6f4ec;
  color: var(--success);
  font-weight: 700;
}

.save-indicator {
  font-size: 0.875rem;
  color: #cfc9b8;
  min-width: 6em;
}
.save-indicator[data-state='saving'] { color: #ffe9a8; }
.save-indicator[data-state='error'] { color: #ffb3b3; font-weight: 700; }

/* ---------- プロジェクト一覧 ---------- */

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

.page h1 { font-size: 1.75rem; line-height: 1.4; }
.page h2 { font-size: 1.25rem; line-height: 1.4; margin-top: 40px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 16px;
}

.project-list { list-style: none; margin: 16px 0 0; padding: 0; }

.project-list li {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 8px;
}

.project-list .title { font-size: 1.125rem; font-weight: 700; text-decoration: underline; color: var(--primary-dark); }
.project-list .meta { color: var(--ink-sub); font-size: 0.875rem; }
.project-list .spacer { margin-left: auto; }

/* ---------- フォーム ---------- */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.field .req { font-weight: 400; font-size: 0.875rem; color: var(--ink-sub); margin-left: 8px; }
.field .support { font-size: 0.875rem; color: var(--ink-sub); margin: 4px 0; }

.field input[type='text'],
.field input[type='email'],
.field input[type='password'],
.field select,
.field textarea {
  width: 100%;
  max-width: 480px;
  min-height: 48px;
  padding: 8px 12px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid #767676;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
}

.field textarea { min-height: 120px; }
.field-wide textarea { max-width: 100%; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

/* ---------- コンテ用紙 ---------- */

.sheet-wrap {
  max-width: 1400px;
  margin: 16px auto 120px;
  padding: 0 16px;
}

.sheet {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  color: var(--ink);
}

.sheet-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 16px 24px 8px;
  border-bottom: 2px solid var(--paper-line);
  font-weight: 700;
}

.sheet-cols {
  display: grid;
  grid-template-columns: 72px minmax(280px, 380px) 1fr minmax(200px, 320px) 168px;
  border-bottom: 2px solid var(--paper-line);
  font-weight: 700;
  text-align: center;
}
.sheet-cols > div { padding: 4px 8px; border-left: 1px solid var(--paper-line); }
.sheet-cols > div:first-child { border-left: none; }

/* シーン帯 */
.scene-band {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--paper-line);
  padding: 8px 16px;
}

.scene-band .scene-no { font-weight: 700; white-space: nowrap; }

.scene-band input {
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  padding: 4px 8px;
  color: var(--ink);
}
.scene-band input:hover, .scene-band input:focus { background: #ffffff; border-color: #767676; }
.scene-band .scene-number-input { width: 4em; font-weight: 700; }
.scene-band .scene-location-input { width: 22em; }
.scene-band .scene-time-input { width: 5em; }

.scene-band .scene-subtotal {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.scene-band .scene-actions { display: flex; gap: 4px; }

/* カット行 */
.cut-row {
  display: grid;
  grid-template-columns: 72px minmax(280px, 380px) 1fr minmax(200px, 320px) 168px;
  border-bottom: 1px solid var(--paper-line);
  background: var(--paper);
}

.cut-row > div { padding: 8px; border-left: 1px solid var(--paper-line); min-width: 0; }
.cut-row > div:first-child { border-left: none; }

.cut-row.is-omitted { background: #e3ded1; }
.cut-row.is-omitted .cell-picture,
.cut-row.is-omitted .cell-content,
.cut-row.is-omitted .cell-dialogue { opacity: 0.45; }

.cut-row.drag-over { border-top: 3px solid var(--focus); }

.cell-no { text-align: center; }

.cut-no-input {
  width: 100%;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  padding: 4px 2px;
}
.cut-no-input:hover, .cut-no-input:focus { background: #ffffff; border-color: #767676; }

.status-select {
  width: 100%;
  margin-top: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  min-height: 36px;
  border: 1px solid #767676;
  border-radius: 4px;
  background: #ffffff;
}

.drag-handle {
  cursor: grab;
  color: var(--ink-sub);
  font-size: 0.875rem;
  margin-top: 8px;
  user-select: none;
  display: inline-block;
  padding: 8px;
}

/* 画面(絵) */
.cell-picture .frame {
  position: relative;
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--paper-line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.frame .no-image { color: #767676; font-size: 0.875rem; }
.frame.drop-target { outline: 3px dashed var(--focus); outline-offset: -4px; }

.picture-actions { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }

/* 内容セル */
.cell-content textarea,
.cell-dialogue textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  padding: 4px 8px;
  resize: vertical;
  min-height: 3.2em;
  color: var(--ink);
}
.cell-content textarea:hover, .cell-content textarea:focus,
.cell-dialogue textarea:hover, .cell-dialogue textarea:focus {
  background: #ffffff;
  border-color: #767676;
}

.subfield-label {
  display: block;
  font-size: 0.875rem;
  color: var(--ink-sub);
  margin: 8px 0 0;
}

.tag-group { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.tag {
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1;
  padding: 8px;
  min-height: 36px;
  border: 1px solid #767676;
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}
.tag[aria-pressed='true'] {
  background: #3d3627;
  border-color: #3d3627;
  color: #ffffff;
  font-weight: 700;
}

/* 秒セル */
.cell-tc { text-align: center; }

.tc-display {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-align: center;
  font-family: inherit;
  padding: 4px;
}
.tc-display:hover, .tc-display:focus { background: #ffffff; border-color: #767676; }

.tc-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 8px;
}

.tc-btn {
  font-family: inherit;
  font-size: 0.875rem;
  min-height: 36px;
  border: 1px solid #767676;
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.tc-btn:hover { background: var(--accent-bg); }

.tc-running {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--ink-sub);
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
  justify-content: center;
}

.icon-btn {
  font-family: inherit;
  font-size: 0.875rem;
  min-width: 44px;
  min-height: 36px;
  padding: 4px;
  border: 1px solid #767676;
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { background: var(--accent-bg); }

.sheet-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.add-scene-row { margin: 16px 0; display: flex; gap: 8px; }

/* ---------- シーン一覧テーブル ---------- */

.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}
.overview-table th {
  text-align: left;
  border-bottom: 2px solid var(--ink);
  padding: 8px 16px;
  white-space: nowrap;
}
.overview-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  vertical-align: top;
}
.overview-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.overview-table td.is-full { color: var(--success); font-weight: 700; }
.overview-table td.is-none { color: var(--ink-sub); }
.overview-table a { color: var(--primary-dark); }

/* ---------- モーダル ---------- */

dialog.modal {
  border: 1px solid #767676;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 640px;
  width: calc(100% - 32px);
  box-shadow: 0 8px 24px 5px rgba(0, 0, 0, 0.1), 0 2px 10px 0 rgba(0, 0, 0, 0.3);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog.modal h2 { margin-top: 0; font-size: 1.25rem; }

.image-history { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.image-history figure { margin: 0; border: 1px solid var(--border); border-radius: 4px; padding: 8px; }
.image-history figure.active { border: 3px solid var(--primary); }
.image-history img { width: 100%; display: block; }
.image-history figcaption { font-size: 0.875rem; color: var(--ink-sub); display: flex; justify-content: space-between; align-items: center; gap: 4px; }

/* ---------- スピナー・トースト ---------- */

.spinner {
  width: 20px;
  height: 20px;
  flex: none;
  border: 3px solid var(--accent-bg);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

.toast-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #e6f4ec;
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 8px 24px;
  font-weight: 700;
  box-shadow: 0 4px 16px 3px rgba(0, 0, 0, 0.1), 0 1px 6px 0 rgba(0, 0, 0, 0.3);
}

.cut-row.jump-highlight { outline: 4px solid var(--focus); outline-offset: -2px; }

/* ---------- ビュー切り替え ---------- */

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  overflow: hidden;
}
.view-toggle-btn {
  font-family: inherit;
  font-size: 1rem;
  min-height: 44px;
  min-width: 72px;
  padding: 8px 16px;
  border: none;
  background: #ffffff;
  color: var(--primary-dark);
  cursor: pointer;
}
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--primary); }
.view-toggle-btn[aria-pressed='true'] {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

/* ---------- ロケ場所 ---------- */

.location-card {
  display: grid;
  grid-template-columns: minmax(320px, 46%) 1fr;
  gap: 24px;
}
@media (max-width: 900px) { .location-card { grid-template-columns: 1fr; } }

.loc-main {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 240px;
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.loc-main.is-empty { color: var(--ink-sub); }
.loc-main-link { display: flex; width: 100%; height: 100%; max-height: 480px; align-items: center; justify-content: center; }
.loc-main-link[hidden] { display: none; }
.loc-main-link img { max-width: 100%; max-height: 480px; object-fit: contain; display: block; }

.loc-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.loc-thumb {
  width: 88px;
  height: 66px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
}
.loc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.loc-thumb.is-active { border: 3px solid var(--primary); }

.loc-photo-add { margin-top: 16px; }
.loc-info .field input[type='text'] { max-width: 100%; }
.loc-admin { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 8px; }

/* ---------- 脚本2ペイン ---------- */

.script-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) { .script-pane { grid-template-columns: 1fr; } }

.script-lines, .script-cuts { list-style: none; margin: 0; padding: 0; }
.script-lines li, .script-cuts li { border-bottom: 1px solid var(--border); }
.script-lines label, .script-cuts label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 8px;
  cursor: pointer;
}
.script-lines label:hover, .script-cuts label:hover { background: var(--accent-bg); }
.script-lines .is-dialogue span { color: #1d4f8a; }

/* ---------- シーンナビ ---------- */

.scene-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.scene-nav-pos { font-weight: 700; font-variant-numeric: tabular-nums; }
.scene-nav-edge { color: var(--ink-sub); }

/* ---------- シーン移動 ---------- */

.scene-jump-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.scene-jump-item {
  display: flex;
  gap: 16px;
  align-items: baseline;
  width: 100%;
  min-height: 44px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 1rem;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}
.scene-jump-item:hover { background: var(--accent-bg); }
.scene-jump-item .jump-title { text-decoration: underline; color: var(--primary-dark); }
.scene-jump-item.is-current {
  background: var(--accent-bg);
  border-left: 6px solid var(--primary);
  font-weight: 700;
}
.scene-jump-item .jump-no { font-weight: 700; min-width: 4em; }
.scene-jump-item .jump-title { flex: 1; }
.scene-jump-item .jump-sub { color: var(--ink-sub); font-size: 0.875rem; white-space: nowrap; }

.scene-band.jump-highlight { outline: 4px solid var(--focus); outline-offset: -2px; }

/* ---------- 出力・分割・一括系モーダル ---------- */

.export-list { list-style: none; margin: 0 0 24px; padding: 0; }
.export-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.export-list a { color: var(--primary-dark); }

.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .split-grid { grid-template-columns: 1fr; } }

.generate-refs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.generate-refs label {
  display: block;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  font-size: 0.875rem;
}
.generate-refs label:has(input:checked) { border: 3px solid var(--primary); padding: 2px; }
.generate-refs img { width: 100%; display: block; }

/* ---------- プレイヤー ---------- */

.player {
  position: fixed;
  inset: 0;
  background: #000000;
  color: #ffffff;
  z-index: 100;
  display: none;
  flex-direction: column;
}
.player.open { display: flex; }

.player-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start; /* 再生画面は左寄せ(右に内容・メモパネルの余地) */
  gap: 24px;
  padding: 0 24px;
  position: relative;
  min-height: 0;
}

.player-frame {
  position: relative;
  background: #000000;
  height: min(72vh, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.15s linear;
}
.player-frame img.visible { opacity: 1; }

.player-frame .blank-label {
  color: #b5b5b5;
  font-size: 2rem;
  font-weight: 700;
}

.player-fade {
  position: absolute;
  inset: 0;
  background: #000000;
  opacity: 0;
  pointer-events: none;
}

.player-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid #767676;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-variant-numeric: tabular-nums;
  font-size: 1.125rem;
}
.player-overlay .cam { color: #ffd97a; font-size: 1rem; }

.player-subtitle {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  background: rgba(0, 0, 0, 0.65);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 1.25rem;
  text-align: center;
  white-space: pre-wrap;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: #16130c;
  border-top: 1px solid #4a4436;
}

.player-controls .btn-ghost { border-color: #8c8672; }
.player-controls .tc-btn { background: #262319; color: #f5f1e6; border-color: #8c8672; }
.player-controls .tc-btn:hover { background: #3d3627; }

.player-tc { font-variant-numeric: tabular-nums; font-size: 1.125rem; margin-left: auto; }

.player-range { display: flex; align-items: center; gap: 8px; }
.player-range select {
  font-family: inherit;
  font-size: 1rem;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid #8c8672;
  background: #262319;
  color: #f5f1e6;
  max-width: 220px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .sheet-cols { display: none; }
  .cut-row { grid-template-columns: 72px 1fr; }
  .cut-row > div { border-left: none; border-top: 1px dotted #767676; }
  .cut-row .cell-no { border-top: none; }
  .cut-row .cell-picture { border-top: none; }
}

/* ---------- ログイン ---------- */

.login-wrap { max-width: 480px; margin: 0 auto; }

.login-wrap .support { color: var(--ink-sub); font-size: 0.875rem; margin-top: 16px; }

.alert-error,
.field-error {
  color: var(--error);
  background: #ffffff;
  font-weight: 700;
  margin: 8px 0;
}

.alert-error {
  border: 2px solid var(--error);
  border-radius: var(--radius);
  padding: 8px 16px;
}

.check-label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.check-label input[type='checkbox'] { width: 20px; height: 20px; }

.header-user { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.header-metrics ~ .header-user, #app-header-right ~ .header-user { margin-left: 0; }
.header-user-name { color: #cfc9b8; font-size: 0.875rem; }

/* ---------- ユーザー管理 ---------- */

.user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.user-actions form { margin: 0; }
.you-badge { color: var(--ink-sub); font-size: 0.875rem; }

.issued-card { border: 2px solid var(--success); }

.issued-password {
  font-size: 1.125rem;
  font-weight: 700;
  background: var(--accent-bg);
  padding: 4px 8px;
  border-radius: 4px;
  user-select: all;
}

/* ---------- 言語切替 ---------- */

.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.header-right .header-user { margin-left: 0; }
.header-lang { margin: 0; }

/* ---------- 動画カット ---------- */

.player-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  background: #000;
}
.player-frame video.visible { opacity: 1; }


.video-badge {
  position: absolute;
  right: 4px;
  top: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 4px;
  pointer-events: none;
}

#history-grid video { width: 100%; }

/* ---------- プレイヤーのタイムラインバー ---------- */

.player-timeline {
  width: 100%;
  overflow-x: auto;
  background: #1b1914;
  border-top: 1px solid #4a4436;
  padding: 8px 8px 12px;
  scrollbar-color: #6b6350 #1b1914;
}

.timeline-strip { display: flex; gap: 2px; width: max-content; }

.timeline-tile {
  position: relative;
  flex: 0 0 auto;
  height: 76px;
  padding: 0;
  border: 1px solid #4a4436;
  border-radius: 2px;
  background-color: #262319;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  overflow: hidden;
}
.timeline-tile:hover { border-color: #8c8672; }
.timeline-tile.current { outline: 3px solid #ffd97a; outline-offset: -3px; }

.tile-label,
.tile-tc {
  position: absolute;
  left: 2px;
  max-width: calc(100% - 4px);
  padding: 0 4px;
  font-size: 0.875rem;
  line-height: 1.3;
  color: #f5f1e6;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-label { top: 2px; }
.tile-tc { bottom: 2px; font-variant-numeric: tabular-nums; }

.tile-video {
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 0 4px;
  font-size: 0.875rem;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 2px;
}

.tile-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ff5b4a;
  display: none;
  pointer-events: none;
}


/* ---------- プレイヤーの内容・メモパネル ---------- */

.player-top-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  display: flex;
  gap: 8px;
}

.player-side {
  flex: 0 1 400px;
  min-width: 280px;
  max-width: 40%;
  margin-left: auto;
  align-self: stretch;
  overflow-y: auto;
  background: #1b1914;
  border-left: 1px solid #4a4436;
  padding: 72px 24px 24px; /* 上部は切替ボタンと重ならないよう空ける */
  color: #f5f1e6;
}

.player-side .side-cutno {
  margin: 0 0 16px;
  font-size: 1.125rem;
  line-height: 1.4;
  color: #ffd97a;
}

.player-side .side-block { margin-bottom: 24px; }

.player-side h4 {
  margin: 0 0 8px;
  padding: 2px 8px;
  font-size: 0.8rem;
  color: #f5f1e6;
  background: #444444;
  border-radius: 4px;
}

.player-side .side-content {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.6;
}

.player-side textarea {
  width: 100%;
  min-height: 160px;
  padding: 8px 12px;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  color: #f5f1e6;
  background: #262319;
  border: 1px solid #767676;
  border-radius: var(--radius);
}

.player-side .side-memo-state {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: #cfc9b8;
  min-height: 1.4em;
}

/* ---------- 動画の開始位置モーダル ---------- */

.vs-controls { margin-top: 16px; }

.vs-controls input[type='range'] {
  width: 100%;
  height: 32px;
  accent-color: var(--primary);
  cursor: pointer;
}

.vs-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.vs-info { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- 再生画面への書き込み ---------- */

.annotate-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  cursor: crosshair;
  touch-action: none;
}

.note-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}

.annotate-bar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid #767676;
  border-radius: var(--radius);
  z-index: 7;
}
.annotate-bar [aria-pressed='true'] { background: rgba(255, 217, 122, 0.25); border-color: #ffd97a; }
.anno-spacer { width: 16px; }

.anno-text-input {
  position: absolute;
  z-index: 5;
  min-width: 160px;
  padding: 2px 8px;
  font-size: 1rem;
  font-family: inherit;
  color: #1a1a1a;
  background: #ffffff;
  border: 2px solid #ff3b30;
  border-radius: 4px;
}

.side-notes { list-style: none; margin: 0; padding: 0; }
.side-notes-empty { color: #8f8a7a; font-size: 0.875rem; }

.side-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #3d3627;
}

.side-note-view {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: none;
  color: #f5f1e6;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.side-note-view img {
  width: 96px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
  border: 1px solid #4a4436;
  border-radius: 4px;
  flex: 0 0 auto;
}
.side-note-view:hover img { border-color: #ffd97a; }
.side-note-meta {
  font-size: 0.875rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---------- VFX列(トグル表示) ---------- */

.col-vfx, .cell-vfx { display: none; }

#board.vfx-on .sheet-cols,
#board.vfx-on .cut-row {
  grid-template-columns: 72px minmax(280px, 380px) 1fr minmax(200px, 320px) 168px minmax(260px, 340px);
}
#board.vfx-on .col-vfx { display: block; }
#board.vfx-on .cell-vfx { display: block; background: #eef3f8; }

.vfx-field {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  color: #33506b;
}

.vfx-top-row { display: flex; gap: 8px; }
.vfx-top-row .vfx-field { flex: 1; margin-bottom: 8px; }

.vfx-field input[type='text'],
.vfx-field textarea,
.vfx-field select {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 4px 8px;
  font-size: 0.875rem;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.5;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #9db2c7;
  border-radius: 4px;
}

.vfx-difficulty select { width: auto; min-width: 6em; }

#btn-vfx-toggle[aria-pressed='true'] { background: rgba(255, 217, 122, 0.25); border-color: #ffd97a; }

/* VFX列オン時はコンテ用紙を全幅で使う */
#board.vfx-on {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

/* カットイメージ(画のイメージメモ) */
.image-note-field {
  display: block;
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink-sub);
}
.image-note-field textarea {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 4px 8px;
  font-size: 0.875rem;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.5;
  color: var(--ink);
  background: #fffdf5;
  border: 1px solid #b8ae95;
  border-radius: 4px;
}

/* 書き込みの重ね表示(再生連動)と表示の長さ */
.note-overlays { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
/* .player-frame img の opacity:0 を打ち消す(書き込みは常に表示) */
.note-overlays img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: none;
}

.anno-display {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.875rem;
  color: #f5f1e6;
}
.anno-display select,
.note-display {
  font-size: 0.875rem;
  font-family: inherit;
  padding: 2px 4px;
  border-radius: 4px;
  background: #262319;
  color: #f5f1e6;
  border: 1px solid #767676;
}
.side-note-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

/* サイドパネルのアコーディオン */
.side-acc { margin-bottom: 16px; border: 1px solid #3d3627; border-radius: var(--radius); }
.side-acc > summary {
  cursor: pointer;
  padding: 8px 16px;
  font-weight: 700;
  color: #ffd97a;
  list-style-position: inside;
}
.side-acc > summary:hover { background: rgba(255, 217, 122, 0.08); }
.side-acc[open] > summary { border-bottom: 1px solid #3d3627; }
.side-acc > section, .side-acc > .side-block { padding: 8px 16px; margin-bottom: 8px; }

/* VFX権限: 無効化された入力は薄く */
#board.role-vfx input:disabled,
#board.role-vfx textarea:disabled,
#board.role-vfx select:disabled { opacity: 0.55; background: #f1ede2; cursor: not-allowed; }

/* シーン一覧のサムネイル切替 */
#ov-card .ov-thumb-cell { display: none; }
#ov-card.thumbs-on .ov-thumb-cell { display: table-cell; }
.ov-thumb {
  height: 50px;
  width: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
}

/* ヘルプ用語集 */
.help-h { margin: 24px 0 8px; font-size: 1rem; }
.help-table th { width: 7em; white-space: nowrap; vertical-align: top; }
.help-table td { color: var(--ink); }
