/* Video Inspector Pro のスタイル。見た目の決まりは docs/design-rules.md（デジタル庁デザインシステムに沿う）。
   動画の表示枠（黒い背景）と、動画の上に重ねる部品・描き込みは、映像を見るためのものなので背景の決まりの対象外。 */
:root {
  --bg: #ffffff; /* 背景は白。灰色は #f2f2f2・#e6e6e6・#ccc だけを使う */
  --card: #ffffff;
  --line: #cccccc;
  --line-hover: #999999;
  --primary: #2563eb; /* 青はリンクとボタン（操作できる部品）だけに使う */
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --ok: #047857;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --text: #0f172a;
  --muted: #555555;
  --keyword: #b45309; /* 重要なキーワード・計算結果の数値 */
  --link-visited: #7e22ce;
  --control-border: #767676; /* 入力欄・ボタンの枠。白の背景とのコントラスト比 4.5:1 */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; padding: 24px 16px; overflow-wrap: anywhere; }
.container { max-width: 1320px; margin: 0 auto; }
/* リンクは青と下線、見たリンクは紫 */
a { color: var(--primary); text-underline-offset: 3px; }
a:visited { color: var(--link-visited); }
a:hover { text-decoration-thickness: 2px; }
/* フォーカス表示：黒 4px の枠と黄色 #ffd43d の 2 重。リンクは背景も黄色にし、文字を黒にする */
:focus-visible { outline: 4px solid #000; outline-offset: 2px; box-shadow: 0 0 0 2px #ffd43d; }
a:focus-visible { background-color: #ffd43d; color: var(--text); }
h1 { font-size: 1.75rem; line-height: 1.4; letter-spacing: -0.3px; }
h2 { font-size: 1.25rem; line-height: 1.5; margin: 0 0 16px; }
h3 { font-size: 1.125rem; margin: 16px 0 8px; }
p, ul, ol, table { margin-bottom: 8px; }
ul, ol { padding-left: 1.4em; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 0.875rem; }

/* サイトのヘッダー */
.site-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.logo, .logo:visited { font-size: 1.375rem; font-weight: 800; color: var(--text); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 1rem; font-weight: 700; }
.site-nav a, .site-nav a:visited { color: var(--primary); }

/* ヒーロー */
.hero { margin-bottom: 16px; }
.hero-sub { font-size: 1.0625rem; font-weight: 600; color: var(--text); margin: 4px 0 8px; }
.hero-points { list-style: none; padding: 0; display: grid; gap: 4px; font-size: 1rem; }
.hero-points li { padding-left: 1.4em; position: relative; }
.hero-points li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 800; }

/* カード・ボタン */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
/* ボタン：ふだんは白地に濃い灰色の枠。主な操作（.primary）と選択中のボタンは青地に白い文字 */
.btn, .chip, .btn:visited { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 40px; padding: 4px 16px; border-radius: 4px; border: 1px solid var(--control-border); background: #fff; color: var(--text); font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover:not(:disabled), .chip:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn:disabled, .chip:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary, .btn.primary:visited { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 32px; padding: 4px 8px; font-size: 0.875rem; }
.btn.big { min-height: 48px; padding: 8px 24px; font-size: 1.0625rem; }
.chip.active, .chip.active:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-row, .chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.msg { padding: 8px 16px; border-radius: 8px; font-size: 1rem; margin: 8px 0; }
.msg.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.msg.info { background: #f2f2f2; border: 1px solid var(--line); }
.warn-box, .hint { background: var(--warn-bg); border-left: 4px solid var(--warn-line); padding: 8px 16px; border-radius: 4px; font-size: 1rem; margin: 8px 0; }
.field { display: block; margin: 8px 0; font-size: 1rem; font-weight: 700; }
.field select { display: block; margin-top: 4px; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 16px; }
.field-row .field { flex: 1 1 150px; }
.val { color: var(--keyword); font-weight: 800; }
select { width: 100%; min-height: 40px; background: #fff; border: 1px solid var(--control-border); color: var(--text); padding: 4px 8px; border-radius: 4px; font: inherit; font-size: 1rem; }
input[type="range"] { width: 100%; accent-color: var(--primary); height: 28px; }

/* プレイヤー */
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .tool-grid { grid-template-columns: minmax(0, 1fr); } }
.panel { display: grid; gap: 16px; }
.panel h2 { font-size: 1.125rem; }
[hidden] { display: none !important; }
.viewer { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 72vh; min-height: 200px; background: #000; border-radius: 8px; overflow: hidden; display: flex; user-select: none; -webkit-user-select: none; }
.viewer.dragging { outline: 4px dashed var(--primary); outline-offset: -8px; }
.viewer.has-video { cursor: pointer; }
.viewer-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 16px; color: #e6e6e6; z-index: 5; }
.viewer-empty-h { font-weight: 700; color: #fff; }
.pane { position: relative; flex: 1 1 100%; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pane video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.viewer[data-mode="split"] .pane-b { position: absolute; inset: 0; background: #000; } /* B の余白・範囲外で A が透けないように */
.viewer[data-mode="side"] .pane { flex-basis: 50%; }
.pane-label { position: absolute; top: 8px; font-size: 0.875rem; font-weight: 800; color: #fff; background: rgba(15, 23, 42, 0.7); padding: 0 8px; border-radius: 4px; pointer-events: none; }
.pane-a .pane-label { left: 8px; }
.pane-b .pane-label { right: 8px; }
/* 分割線は動画の明るさに関係なく見えるよう、水色の線の両側に濃い縁を付ける（影は使わない） */
.divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px; background: #38bdf8; border-left: 1px solid rgba(0, 0, 0, 0.6); border-right: 1px solid rgba(0, 0, 0, 0.6); z-index: 10; cursor: ew-resize; touch-action: none; }
.divider::before { content: ""; position: absolute; top: 0; bottom: 0; left: -16px; right: -16px; }
.divider-handle { position: absolute; top: 50%; left: -15px; transform: translateY(-50%); width: 32px; height: 32px; background: var(--primary); border: 2px solid #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 800; pointer-events: none; }
.loupe { position: absolute; width: 180px; height: 180px; border: 2px solid #fff; outline: 2px solid rgba(0, 0, 0, 0.6); border-radius: 50%; pointer-events: none; z-index: 20; background: #000; }
.export-overlay { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.86); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; z-index: 50; color: #fff; text-align: center; padding: 16px; cursor: default; }
.export-overlay progress { width: min(300px, 80%); height: 8px; }

/* タイムライン：範囲（IN〜OUT）はキーワードの色、IN の印は茶色、OUT の印は赤 */
.timeline { position: relative; height: 32px; margin-top: 8px; }
.timeline input[type="range"] { position: absolute; inset: 0; width: 100%; height: 32px; z-index: 2; background: transparent; }
.trim-band { position: absolute; top: 12px; height: 8px; background: rgba(180, 83, 9, 0.3); border-radius: 2px; z-index: 1; pointer-events: none; }
.trim-mark { position: absolute; top: 2px; width: 3px; height: 28px; margin-left: -1px; z-index: 3; pointer-events: none; border-radius: 1px; }
.trim-mark.in { background: var(--keyword); }
.trim-mark.out { background: #dc2626; }
.readout { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; font-variant-numeric: tabular-nums; margin: 4px 0 8px; }
.readout .tc { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.25rem; font-weight: 800; }
.readout .frame-no { font-weight: 700; }
.readout .secs { color: var(--muted); font-size: 1rem; }
.transport { align-items: center; }
.transport .btn { min-width: 44px; }
.transport select { width: auto; min-height: 40px; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; }
.inline-field select { width: auto; }
.toggle[aria-pressed="true"], .toggle[aria-pressed="true"]:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); color: #fff; }
.range-big { font-size: 1.125rem; font-weight: 800; color: var(--keyword); font-variant-numeric: tabular-nums; margin: 4px 0; }
.range-big.empty { font-size: 1rem; font-weight: 400; color: var(--muted); }
.save-row { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 8px; font-size: 1rem; font-variant-numeric: tabular-nums; }
.kv dt { color: var(--muted); font-weight: 700; }
.drops { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.drop { position: relative; }
.offset-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.offset-row input[type="number"] { width: 7.5em; min-height: 40px; padding: 4px 8px; border: 1px solid var(--control-border); border-radius: 4px; font: inherit; font-variant-numeric: tabular-nums; }
.keys { font-size: 1rem; }
kbd { font-family: ui-monospace, monospace; background: #f2f2f2; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; font-size: 0.875rem; }
@media (max-width: 600px) {
  .viewer { aspect-ratio: 4 / 3; }
  .readout .tc { font-size: 1.125rem; }
  .transport .btn { padding: 4px 8px; }
}
.ad-below-tool { margin-top: 24px; }

/* 動画を選ぶ場所（ファイル選択のボタンの代わり）。操作できる部品なので枠は濃い灰色、案内の文字は青 */
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px dashed var(--control-border); border-radius: 8px; padding: 16px 8px; text-align: center; cursor: pointer; background: #f2f2f2; }
.drop:hover, .drop.dragging { border-color: var(--primary); background: var(--primary-light); }
.drop:focus-within { outline: 4px solid #000; outline-offset: 2px; box-shadow: 0 0 0 2px #ffd43d; }
.drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-label { font-weight: 700; color: var(--primary); }
.drop-file { font-size: 0.875rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop.loaded { border-style: solid; border-color: var(--ok); background: #fff; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 16px; }
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; background: #fff; }
th, td { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
thead th { background: #f2f2f2; white-space: nowrap; }
table.small { font-size: 0.875rem; }
/* 説明・静的ページ */
.explain { margin-top: 24px; max-width: 900px; }
.explain h2, .page h2 { margin-top: 40px; padding-left: 8px; border-left: 4px solid var(--text); }
.steps li { margin-bottom: 8px; }
.notes li { margin-bottom: 4px; font-size: 1rem; }
.link-list li { margin-bottom: 4px; }
.page { max-width: 820px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.page .lead { font-size: 1.0625rem; margin-top: 8px; }
.cta { margin: 16px 0; }
.pending { background: #f2f2f2; border: 1px solid var(--line); padding: 8px 16px; border-radius: 8px; font-size: 1rem; }
.tip-box { background: #f2f2f2; border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; }
.tip-h { font-weight: 800; margin-bottom: 4px; }
.checked-os { display: inline-flex; gap: 8px; flex-wrap: wrap; font-size: 0.875rem; background: #f2f2f2; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; margin-top: 8px; }
.checked-os span { font-weight: 700; }
.crumbs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 0.875rem; margin-bottom: 16px; }
.crumbs li + li::before { content: "›"; margin-right: 8px; color: #767676; }
@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  .page { padding: 24px 16px; }
}

/* フッター（サイト内） */
.site-footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; font-size: 0.875rem; }
.site-footer h2 { font-size: 1rem; margin-bottom: 8px; }
.site-footer ul { padding-left: 1.1em; }

/* フレームを直接デコードしたコマ・描き込み・比較 */
.frame-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.draw-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 8; pointer-events: none; }
.draw-layer.drawing { pointer-events: auto; cursor: crosshair; touch-action: none; }
.pane.outside video, .pane.outside canvas { visibility: hidden; }
.viewer[data-mode="overlay"] .pane-b { position: absolute; inset: 0; }
.trim-mark.sync { background: #16a34a; }
.badge { display: inline-block; font-size: 0.875rem; font-weight: 800; color: #fff; background: var(--ok); border-radius: 4px; padding: 0 8px; }
.src-info { font-size: 0.875rem; color: var(--muted); margin: -4px 0 8px; }
.fps-detected { font-size: 1rem; margin-bottom: 4px; }
.b-readout { font-size: 0.875rem; font-variant-numeric: tabular-nums; color: var(--muted); margin: 4px 0; }
#exportCard h3 { font-size: 1rem; margin: 16px 0 8px; padding-top: 8px; border-top: 1px solid var(--line); }
