:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #cbd5e1;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #f0f9ff;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --text: #0f172a;
  --muted: #475569;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
* { 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: 16px; overflow-wrap: anywhere; }
.container { max-width: 1320px; margin: 0 auto; }
a { color: var(--primary-dark); }
h1 { font-size: 1.55rem; line-height: 1.4; letter-spacing: -0.3px; }
h2 { font-size: 1.1rem; line-height: 1.5; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
p, ul, ol, table { margin-bottom: 10px; }
ul, ol { padding-left: 1.4em; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 0.85rem; }

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

/* ヒーロー */
.hero { margin-bottom: 16px; }
.hero-sub { font-size: 1.05rem; font-weight: 600; color: var(--muted); margin: 4px 0 10px; }
.hero-points { list-style: none; padding: 0; display: grid; gap: 4px; font-size: 0.92rem; }
.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: 12px; padding: 16px; box-shadow: var(--shadow); }
.btn, .chip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 40px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line); background: #f1f5f9; color: var(--text); font: inherit; font-size: 0.9rem; 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: #bfdbfe; }
.btn:disabled, .chip:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.danger { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: 0.82rem; }
.btn.big { min-height: 48px; padding: 8px 22px; font-size: 1rem; }
.chip.active { 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 10px; border-radius: 8px; font-size: 0.88rem; margin: 8px 0; }
.msg.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.msg.info { background: var(--primary-light); border: 1px solid #bfdbfe; }
.warn-box, .hint { background: var(--warn-bg); border-left: 4px solid var(--warn-line); padding: 8px 10px; border-radius: 6px; font-size: 0.86rem; margin: 10px 0; }
.field { display: block; margin: 10px 0; font-size: 0.88rem; font-weight: 700; }
.field select { display: block; margin-top: 4px; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 12px; }
.field-row .field { flex: 1 1 150px; }
.val { color: var(--primary-dark); font-weight: 800; }
select { width: 100%; min-height: 40px; background: #fff; border: 1px solid var(--line); color: var(--text); padding: 6px 10px; border-radius: 8px; font: inherit; font-size: 0.9rem; }
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: 12px; }
.panel h2 { font-size: 1rem; }
[hidden] { display: none !important; }
.viewer { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 72vh; min-height: 200px; background: #000; border-radius: 10px; overflow: hidden; display: flex; user-select: none; -webkit-user-select: none; outline: none; }
.viewer:focus-visible { box-shadow: 0 0 0 3px var(--primary); }
.viewer.dragging { outline: 3px dashed var(--primary); outline-offset: -6px; }
.viewer.has-video { cursor: pointer; }
.viewer-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px; color: #cbd5e1; 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: 6px; font-size: 0.72rem; font-weight: 800; color: #fff; background: rgba(15, 23, 42, 0.7); padding: 1px 8px; border-radius: 4px; pointer-events: none; }
.pane-a .pane-label { left: 6px; }
.pane-b .pane-label { right: 6px; }
.divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #38bdf8; box-shadow: 0 0 8px rgba(0,0,0,0.8); z-index: 10; cursor: ew-resize; touch-action: none; }
.divider::before { content: ""; position: absolute; top: 0; bottom: 0; left: -14px; right: -14px; }
.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 var(--primary); border-radius: 50%; pointer-events: none; z-index: 20; box-shadow: 0 6px 16px rgba(0,0,0,0.5); 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: 10px; z-index: 50; color: #fff; text-align: center; padding: 16px; cursor: default; }
.export-overlay progress { width: min(300px, 80%); height: 10px; }

.timeline { position: relative; height: 32px; margin-top: 10px; }
.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(2, 132, 199, 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: #2563eb; }
.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 6px; }
.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: 0.88rem; }
.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: 6px; font-size: 0.85rem; font-weight: 700; }
.inline-field select { width: auto; }
.toggle[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.range-big { font-size: 1.1rem; font-weight: 800; color: var(--primary-dark); font-variant-numeric: tabular-nums; margin: 4px 0; }
.range-big.empty { font-size: 0.88rem; font-weight: 400; color: var(--muted); }
.save-row { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 0.88rem; 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: 6px; flex-wrap: wrap; }
.offset-row input[type="number"] { width: 7.5em; min-height: 36px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-variant-numeric: tabular-nums; }
.keys { font-size: 0.85rem; }
kbd { font-family: ui-monospace, monospace; background: #f1f5f9; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 0.8rem; }
@media (max-width: 600px) {
  .viewer { aspect-ratio: 4 / 3; }
  .readout .tc { font-size: 1.05rem; }
  .transport .btn { padding: 6px 10px; }
}
.ad-below-tool { margin-top: 20px; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px dashed var(--line); border-radius: 10px; padding: 14px 10px; text-align: center; cursor: pointer; background: #fafafa; }
.drop:hover, .drop.dragging { border-color: var(--primary); background: var(--primary-light); }
.drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-label { font-weight: 700; color: var(--primary-dark); }
.drop-file { font-size: 0.82rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop.loaded { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; background: #fff; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
thead th { background: #f1f5f9; white-space: nowrap; }
table.small { font-size: 0.82rem; }
/* 説明・静的ページ */
.explain { margin-top: 28px; max-width: 900px; }
.explain h2, .page h2 { margin-top: 28px; padding-left: 10px; border-left: 4px solid var(--primary); }
.steps li { margin-bottom: 6px; }
.notes li { margin-bottom: 4px; font-size: 0.92rem; }
.link-list li { margin-bottom: 4px; }
.page { max-width: 820px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.page .lead { font-size: 1rem; margin-top: 10px; }
.cta { margin: 16px 0; }
.pending { background: var(--primary-light); border: 1px solid #bfdbfe; padding: 8px 12px; border-radius: 8px; font-size: 0.9rem; }
.tip-box { background: var(--ok-bg); border: 1px solid #a7f3d0; border-radius: 8px; padding: 10px 14px; }
.tip-h { font-weight: 800; margin-bottom: 4px; }
.checked-os { display: inline-flex; gap: 8px; flex-wrap: wrap; font-size: 0.88rem; background: #f1f5f9; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; margin-top: 10px; }
.checked-os span { font-weight: 700; }
.crumbs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 0.82rem; margin-bottom: 10px; }
.crumbs li + li::before { content: "›"; margin-right: 4px; color: var(--muted); }

/* フッター（サイト内） */
.site-footer { margin-top: 32px; 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.88rem; }
.site-footer h2 { font-size: 0.95rem; margin-bottom: 6px; }
.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.75rem; font-weight: 800; color: #fff; background: #16a34a; border-radius: 4px; padding: 0 8px; }
.src-info { font-size: 0.8rem; color: var(--muted); margin: -2px 0 6px; }
.fps-detected { font-size: 0.9rem; margin-bottom: 4px; }
.b-readout { font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--muted); margin: 2px 0; }
#exportCard h3 { font-size: 0.92rem; margin: 14px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
