/* 실험 영상 비교용 화면: 왼쪽 prompt 목록, 오른쪽 입력(문장·레퍼런스)과 같은 시점으로 맞춘 영상 격자 */
:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #15181e;
  --muted: #5b626e;
  --line: #dcdfe5;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --ours: #1f6f5c;
  --other: #6b7280;
  --sel: #e3efe9;
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --panel: #191c21; --ink: #e9ebef; --muted: #9aa1ad; --line: #2a2e35;
    --accent: #4fb495; --accent-ink: #0d1512; --ours: #4fb495; --other: #9aa1ad; --sel: #1e2b26;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --panel: #191c21; --ink: #e9ebef; --muted: #9aa1ad; --line: #2a2e35;
  --accent: #4fb495; --accent-ink: #0d1512; --ours: #4fb495; --other: #9aa1ad; --sel: #1e2b26;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
button, select, input { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-name { font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 8px; border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.tabs button:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout {
  display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  max-width: 1800px; margin: 0 auto;
}
.side {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; position: sticky; top: 64px; max-height: calc(100vh - 80px);
}
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 2px 10px;
  font-size: 12px; cursor: pointer; color: var(--muted);
}
.filters button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.search input { width: 100%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.plist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.plist li button {
  width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 8px; border-radius: 6px;
  cursor: pointer; display: grid; gap: 1px;
}
.plist li button:hover { background: var(--bg); }
.plist li button[aria-current="true"] { background: var(--sel); }
.plist .k { font-family: var(--mono); font-size: 12px; }
.plist .s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pselect { display: none; }

.main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.info, .player { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.info-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: 0.02em; }
h1 { margin: 2px 0 0; font-size: 18px; font-family: var(--mono); font-weight: 600; text-wrap: balance; }
.ptext { margin: 10px 0 12px; max-width: 95ch; }
.nav-btns { display: flex; gap: 6px; }
button.ghost { border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 5px 10px; cursor: pointer; }
button.ghost:hover { background: var(--bg); }
button.primary { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 6px 14px; cursor: pointer; font-weight: 600; }
.refs { margin: 0; }
.refs-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.refs-row img { height: 92px; width: auto; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); flex: none; }
.refs-row .anchor { position: relative; flex: none; }
.refs-row .anchor span {
  position: absolute; left: 6px; bottom: 6px; font-size: 11px; padding: 0 6px; border-radius: 4px;
  background: rgba(0,0,0,0.6); color: #fff;
}
.refs figcaption { color: var(--muted); font-size: 12px; margin-top: 6px; }

.grid { display: grid; gap: 12px; }
.grid.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile-head { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--other); flex: none; }
.tile.is-ours .dot { background: var(--ours); }
.tile-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-src { grid-column: 2; color: var(--muted); font-family: var(--mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frame { position: relative; aspect-ratio: 832 / 480; max-width: 100%; background: #000; border-radius: 6px; overflow: hidden; }
.frame video { width: 100%; height: 100%; display: block; }
.load {
  position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 13px;
  background: rgba(0,0,0,0.55); font-variant-numeric: tabular-nums;
}
.load[hidden] { display: none; }

.controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.controls input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.time { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 96px; }
.speed { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.speed select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

@media (max-width: 1100px) {
  .grid.n3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; }
  .plist { display: none; }
  .pselect { display: block; width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
  .grid.n2, .grid.n3 { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
