/* ---- tokens -------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --bg: #eef1ef;
  --panel: #ffffff;
  --panel-sunken: #e6eae7;
  --border: #d3d9d5;
  --ink: #12140f;
  --muted: #5d655f;

  --kill: #c93a26;
  --kill-ink: #ffffff;
  --scan: #12857a;
  --scan-ink: #ffffff;

  --shadow: rgba(20, 28, 24, 0.10);
  --radius: 4px;

  --font-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151a;
    --panel: #181f24;
    --panel-sunken: #12171b;
    --border: #2a343a;
    --ink: #eef1ee;
    --muted: #8b9aa0;

    --kill: #ff6a4d;
    --kill-ink: #1a0a05;
    --scan: #35d1c2;
    --scan-ink: #04211d;

    --shadow: rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --bg: #10151a;
  --panel: #181f24;
  --panel-sunken: #12171b;
  --border: #2a343a;
  --ink: #eef1ee;
  --muted: #8b9aa0;
  --kill: #ff6a4d;
  --kill-ink: #1a0a05;
  --scan: #35d1c2;
  --scan-ink: #04211d;
  --shadow: rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
  --bg: #eef1ef;
  --panel: #ffffff;
  --panel-sunken: #e6eae7;
  --border: #d3d9d5;
  --ink: #12140f;
  --muted: #5d655f;
  --kill: #c93a26;
  --kill-ink: #ffffff;
  --scan: #12857a;
  --scan-ink: #ffffff;
  --shadow: rgba(20, 28, 24, 0.10);
}

/* ---- base ------------------------------------------------------------ */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  padding: clamp(1.25rem, 4vw, 3rem) 1rem 5rem;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

button:focus-visible,
input:focus-visible,
.file-drop:focus-within {
  outline: 2px solid var(--scan);
  outline-offset: 2px;
}

/* ---- console shell: corner-reticle frame ------------------------------ */

.console {
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  padding: 1.75rem clamp(1rem, 4vw, 2.25rem) 2rem;
}

.console::before,
.console::after,
.console-header::before,
.console-header::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--scan);
  border-style: solid;
  border-width: 0;
  opacity: 0.55;
}
.console::before { top: 0; left: 0; border-top-width: 2px; border-left-width: 2px; }
.console::after  { top: 0; right: 0; border-top-width: 2px; border-right-width: 2px; }

.console-header {
  text-align: left;
  margin-bottom: 2rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--scan);
  margin: 0 0 0.6rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 7vw, 3.1rem);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  line-height: 0.95;
  margin: 0 0 0.6rem;
  text-wrap: balance;
}

.subtitle {
  color: var(--muted);
  max-width: 46ch;
  margin: 0;
  font-size: 0.95rem;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* ---- panels ------------------------------------------------------------ */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem 1.5rem;
  box-shadow: 0 1px 2px var(--shadow);
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.panel-index {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.15rem 0.4rem;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 1.15rem;
  margin: 0;
}

/* ---- upload dropzone --------------------------------------------------- */

.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 150px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--muted);
  transition: border-color 120ms ease, background 120ms ease;
}
.file-drop::before,
.file-drop::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--border);
  border-style: solid;
  border-width: 0;
  transition: border-color 120ms ease;
}
.file-drop::before { bottom: 8px; left: 8px; border-bottom-width: 2px; border-left-width: 2px; }
.file-drop::after  { bottom: 8px; right: 8px; border-bottom-width: 2px; border-right-width: 2px; }

.file-drop.dragover,
.file-drop:hover {
  border-color: var(--scan);
  background: color-mix(in srgb, var(--scan) 6%, transparent);
}
.file-drop.dragover::before,
.file-drop.dragover::after,
.file-drop:hover::before,
.file-drop:hover::after { border-color: var(--scan); }

.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { width: 30px; height: 30px; color: var(--muted); }
.file-drop:hover .drop-icon, .file-drop.dragover .drop-icon { color: var(--scan); }
#fileLabel { font-weight: 500; color: var(--ink); }
.drop-hint { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.02em; }

/* ---- settings ----------------------------------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.stepper { display: flex; flex-direction: column; gap: 0.35rem; }

.stepper-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stepper-input {
  display: flex;
  align-items: center;
  background: var(--panel-sunken);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15rem 0.7rem;
}

.stepper-input input {
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  width: 100%;
  padding: 0.4rem 0;
}
.stepper-input input:focus { outline: none; }
.stepper-input .unit { color: var(--muted); font-family: var(--font-mono); font-size: 0.85rem; }

/* ---- buttons -------------------------------------------------------------- */

button {
  font-family: var(--font-body);
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.95rem;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--scan);
  color: var(--scan-ink);
  padding: 0.7rem 1.2rem;
  font-weight: 600;
}
.btn-primary svg { width: 18px; height: 18px; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-kill {
  background: var(--kill);
  color: var(--kill-ink);
  padding: 0.55rem 0.9rem;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
.btn-kill:hover:not(:disabled) { filter: brightness(1.08); }

/* ---- progress: scan head ------------------------------------------------ */

.scan-track {
  position: relative;
  height: 8px;
  background: var(--panel-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.scan-fill {
  height: 100%;
  width: 0%;
  background: var(--scan);
  transition: width 120ms linear;
}
.scan-head {
  position: absolute;
  top: -3px;
  left: 0%;
  width: 2px;
  height: 14px;
  background: var(--scan);
  box-shadow: 0 0 6px 1px var(--scan);
  transition: left 120ms linear;
}
@media (prefers-reduced-motion: reduce) {
  .scan-fill, .scan-head { transition: none; }
}

.scan-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- timeline ------------------------------------------------------------ */

.timeline-wrap {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--panel-sunken);
  margin-bottom: 1.2rem;
  padding: 0.5rem;
}
#timelineCanvas { display: block; width: 100%; height: 72px; }

/* ---- results list --------------------------------------------------------- */

.results-list { display: flex; flex-direction: column; }

.result-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
  opacity: 0;
  transform: translateY(4px);
  animation: rise 260ms ease forwards;
}
.result-item:first-child { border-top: none; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .result-item { animation: none; opacity: 1; transform: none; }
}

.result-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 92px;
  height: 52px;
}
.result-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
  background: var(--panel-sunken);
  border: 1px solid var(--border);
  display: block;
}
.result-thumb-wrap::before,
.result-thumb-wrap::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: var(--kill);
  border-style: solid;
  border-width: 0;
}
.result-thumb-wrap::before { top: -3px; left: -3px; border-top-width: 2px; border-left-width: 2px; }
.result-thumb-wrap::after  { bottom: -3px; right: -3px; border-bottom-width: 2px; border-right-width: 2px; }

.result-info { flex: 1; min-width: 0; }

.result-time {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 600;
}
.kill-chip {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  background: var(--kill);
  color: var(--kill-ink);
  border-radius: 2px;
  padding: 0.12rem 0.4rem;
}
.result-range { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.result-text {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-actions { display: flex; flex-direction: column; gap: 0.4rem; align-items: stretch; }
.result-actions a {
  font-size: 0.82rem;
  text-align: center;
  color: var(--scan);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--scan);
  border-radius: 3px;
  padding: 0.5rem 0.7rem;
}
.result-actions a:hover { background: color-mix(in srgb, var(--scan) 12%, transparent); }
.error-detail { color: var(--kill); font-size: 0.7rem; text-align: right; max-width: 160px; }
.timing-detail { color: var(--muted); font-size: 0.7rem; text-align: right; }

.clip-progress {
  width: 100%;
  height: 4px;
  background: var(--panel-sunken);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.clip-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--kill);
  transition: width 150ms linear;
}
@media (prefers-reduced-motion: reduce) {
  .clip-progress-fill { transition: none; }
}

#videoEl, #canvasEl { display: none; }
