/* src/web/base.css */
:root {
  --buncss-light: initial;
  --buncss-dark: ;
  color-scheme: light dark;
  -webkit-font-smoothing: antialiased;
  --bg: #f4f5ee;
  --surface: #fffef9;
  --ink: #192820;
  --muted: #5e6d63;
  --line: #d9e0d7;
  --accent: #176a42;
  --accent-ink: #fff;
  --soft: #e7f3e7;
  --danger: #a93227;
  --amber: #e6aa3a;
  --ready: #64df93;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --buncss-light: ;
    --buncss-dark: initial;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  margin: 0;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:where(a, button, input, select, summary):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.site-header {
  display: flex;
  padding: 1rem max(1rem, calc((100vw - var(--page, 1020px)) / 2));
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  align-items:  center;
  gap: 1rem;
}

.brand {
  letter-spacing: -.03em;
  text-decoration: none;
  font-size: 1.13rem;
  font-weight: 800;
}

.brand span {
  color: var(--accent);
}

.header-note {
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  font-size: .75rem;
  font-weight: 700;
}

.eyebrow {
  color: var(--accent);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 0 .65rem;
  font-size: .78rem;
  font-weight: 800;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: 0 4px 18px #0e2d1b0a;
}

.card h2 {
  letter-spacing: -.02em;
  margin: 0;
  font-size: 1.15rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1510;
    --surface: #17231a;
    --ink: #ebf3e9;
    --muted: #a4b9a7;
    --line: #314536;
    --accent: #8bdca2;
    --accent-ink: #0e2114;
    --soft: #203d2a;
    --danger: #ff8a7e;
  }

  .card {
    box-shadow: none;
  }
}

:root:not([data-advanced]) .advanced-only {
  display: none !important;
}

/* src/web/styles.css */
:root {
  --page: 1232px;
}

:root[data-login="true"] body > header, :root[data-login="true"] body > main {
  display: none;
}

.login-screen {
  display: grid;
  place-items:  center;
  min-height: 100svh;
  padding: 24px;
}

.login-card {
  width: min(100%, 390px);
  padding: 24px;
}

.login-card h1 {
  letter-spacing: -.05em;
  margin: 0;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  line-height: 1.05;
}

.login-card > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

.login-card form {
  display: grid;
  gap: 12px;
}

.login-card label {
  font-size: .85rem;
  font-weight: 800;
}

.login-card input {
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 100%;
  min-height: 44px;
  padding: 12px;
}

.login-card button {
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  margin-top: 4px;
  font-weight: 800;
}

.login-card button:disabled {
  opacity: .6;
}

#login-error {
  color: var(--danger);
  min-height: 1.3em;
  margin: 0;
  font-size: .85rem;
}

.lab-main {
  width: min(100%, 1280px);
  margin-inline-start: auto;
  margin-inline-end: auto;
  padding: 32px 24px 64px;
}

.lab-heading {
  display: flex;
  justify-content: space-between;
  align-items:  end;
  gap: 24px;
}

.lab-heading h1 {
  letter-spacing: -.06em;
  text-wrap: balance;
  margin: 0;
  font-size: clamp(2.8rem, 5vw, 4.4rem);
  line-height: 1.03;
}

.lab-heading p:last-child {
  color: var(--muted);
  max-width: 40rem;
  margin: 16px 0 0;
  font-size: 1.05rem;
  line-height: 1.45;
}

.live-link {
  display: inline-flex;
  color: var(--accent-ink);
  background: var(--accent);
  text-decoration: none;
  border-radius: 12px;
  flex: none;
  justify-content: space-between;
  align-items:  center;
  gap: 20px;
  min-height: 48px;
  padding: 12px 20px;
  font-weight: 800;
}

.live-link:hover {
  filter: brightness(1.08);
}

.live-link:active {
  scale: .96;
}

.sample-section {
  margin-top: 32px;
}

.sample-heading {
  display: flex;
  justify-content: space-between;
  align-items:  end;
  gap: 16px;
}

.sample-heading h2 {
  letter-spacing: -.035em;
  margin: 0;
  font-size: 1.5rem;
}

.sample-heading p {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: .9rem;
}

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

.secondary-button {
  position: relative;
  display: inline-flex;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  white-space: nowrap;
  cursor: pointer;
  border-radius: 10px;
  justify-content: center;
  align-items:  center;
  min-height: 44px;
  padding: 10px 16px;
  font-size: .9rem;
  font-weight: 700;
}

.secondary-button:hover {
  border-color: var(--accent);
}

.secondary-button:active {
  scale: .96;
}

.file-button {
  overflow: hidden;
}

.file-button input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  inset: 0;
}

.file-button:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 10px;
  margin-top: 20px;
}

.sample-loading {
  border: 1px dashed var(--line);
  color: var(--muted);
  border-radius: 14px;
  margin: 0;
  padding: 24px;
}

.sample-card {
  display: grid;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  border-radius: 18px;
  align-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 76px;
  padding: 14px 16px;
  transition: border-color .15s, background-color .15s, scale .15s;
}

.sample-card:hover {
  border-color: var(--accent);
}

.sample-card:active {
  scale: .96;
}

.sample-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.sample-card-name {
  overflow-wrap: anywhere;
  letter-spacing: -.025em;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.2;
}

.sample-card-view {
  color: var(--muted);
  letter-spacing: .09em;
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
}

.settings {
  width: -moz-fit-content;
  width: fit-content;
  max-width: 100%;
  margin: 20px 0 24px;
}

.settings > summary {
  display: inline-flex;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
  border-radius: 99px;
  align-items:  center;
  gap: 16px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: .85rem;
  font-weight: 800;
}

.settings > summary::-webkit-details-marker {
  display: none;
}

.settings > summary svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  width: 16px;
  height: 16px;
  transition: transform .15s;
}

.settings[open] > summary svg {
  transform: rotate(180deg);
}

.settings-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 18px;
  gap: 20px 24px;
  width: min(640px, 100vw - 48px);
  margin-top: 12px;
  padding: 24px;
}

.setting-label {
  grid-column: 1 / -1;
  margin-bottom: -16px;
  font-size: .82rem;
  font-weight: 800;
}

.settings select {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--bg);
  border-radius: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
}

.setting-group {
  border: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.setting-group legend {
  margin-bottom: 8px;
  font-size: .82rem;
  font-weight: 800;
}

.setting-group:has(input[name="view"]) {
  grid-column: 1 / -1;
}

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

.segments label {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.segments input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segments span {
  display: inline-grid;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--bg);
  white-space: nowrap;
  border-radius: 10px;
  place-items:  center;
  min-height: 44px;
  padding: 10px 14px;
  font-size: .85rem;
  font-weight: 700;
}

.segments input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--soft);
}

.segments input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.segments input:disabled + span {
  opacity: .45;
  cursor: not-allowed;
}

.setting-toggles {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  align-items:  center;
  gap: 16px;
}

.setting-toggles label {
  display: inline-flex;
  cursor: pointer;
  align-items:  center;
  gap: 8px;
  min-height: 44px;
  font-size: .85rem;
  font-weight: 700;
}

.setting-toggles input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

.lab-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items:  start;
  gap: 20px;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.views {
  display: grid;
  gap: 12px;
}

.views.pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lane {
  container-type: inline-size;
  position: relative;
  display: grid;
  overflow: hidden;
  background: #070e09;
  border-radius: 18px;
  place-items:  center;
  min-width: 0;
  min-height: 360px;
  margin: 0;
}

.lane > video, .lane > canvas {
  grid-area: 1 / 1;
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
}

.views.pair .lane > video, .views.pair .lane > canvas {
  max-height: calc(100vh - 300px);
}

.lane > canvas {
  pointer-events: none;
}

.phase {
  position: absolute;
  color: #f3f7f3;
  background: #000000a6;
  border-radius: 99px;
  padding: 8px 12px;
  font-size: .8rem;
  top: 12px;
  left: 12px;
}

.stage.is-empty .lane {
  border: 1px solid var(--line);
  background: var(--surface);
}

.stage.is-empty .lane > video, .stage.is-empty .lane > canvas {
  visibility: hidden;
}

.stage.is-empty .phase {
  color: var(--muted);
  text-align: center;
  background: none;
  padding: 0;
  font-size: 1rem;
  line-height: 1.45;
  top: calc(50% + 20px);
  left: 20px;
  right: 20px;
}

.empty-mark {
  display: none;
  position: absolute;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 56px;
  height: 56px;
  top: calc(50% - 56px);
  left: calc(50% - 28px);
}

.stage.is-empty .empty-mark {
  display: block;
}

.tag {
  position: absolute;
  color: #fff;
  letter-spacing: .08em;
  text-shadow: 0 1px 3px #000;
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
  top: 12px;
  right: 12px;
}

.tag:empty {
  display: none;
}

.word {
  position: absolute;
  color: #0f1411;
  border-radius: .22em;
  padding: .12em .35em .16em;
  font-size: clamp(22px, 9cqw, 56px);
  font-weight: 800;
  line-height: 1;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
}

.vcaption {
  position: absolute;
  color: #fff;
  text-align: center;
  -webkit-text-stroke: .04em #000;
  paint-order: stroke fill;
  text-shadow: 0 2px 6px #000000e6;
  font-size: clamp(15px, 5.2cqw, 34px);
  font-weight: 800;
  line-height: 1.15;
  bottom: 6%;
  left: 8px;
  right: 8px;
}

.compare {
  display: grid;
  grid-template-columns: minmax(0, 480px);
  justify-content: center;
}

.compare figure {
  overflow: hidden;
  background: var(--surface);
  border-radius: 18px;
  margin: 0;
}

.compare canvas {
  display: block;
  width: 100%;
}

.compare figcaption {
  display: grid;
  justify-content: center;
  padding: 12px;
}

.compare-options span {
  background: var(--surface);
}

.strip {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.strip .row {
  display: grid;
  grid-template-columns: 14px repeat(3, minmax(0, 1fr)) repeat(2, minmax(0, .7fr));
  align-items:  start;
  gap: 6px;
}

.rowlabel {
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  align-self:  center;
  font-size: 11px;
  transform: rotate(180deg);
}

.tile {
  overflow: hidden;
  border: 2px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  min-width: 0;
  margin: 0;
}

.tile.marked {
  border-width: 3px;
}

.tile canvas {
  display: block;
  width: 100%;
}

.tile figcaption {
  color: var(--ink);
  padding: 4px 8px 6px;
  font-size: clamp(10px, 1.1vw, 12px);
  line-height: 1.25;
}

.tile:not(.marked) figcaption {
  color: var(--muted);
}

.path {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 18px;
  padding: 12px;
}

.path p {
  margin: 0 0 8px;
  font-weight: 700;
}

.pathFrames {
  display: flex;
  overflow-x: auto;
  gap: 4px;
}

.pathFrames img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 120px;
  width: 120px;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.cue, .claude {
  padding: 20px;
}

.cue {
  border-color: var(--accent);
}

.label {
  display: flex;
  color: var(--accent);
  letter-spacing: .12em;
  text-transform: uppercase;
  align-items:  center;
  gap: 8px;
  font-size: .72rem;
  font-weight: 800;
}

.say {
  letter-spacing: -.035em;
  margin: 12px 0 8px;
  font-size: clamp(1.5rem, 2.3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
}

.claude .say {
  font-size: 1.15rem;
  font-weight: 700;
}

.what, .why {
  margin: 8px 0 0;
  font-size: .9rem;
  line-height: 1.45;
}

.why, .source, .claude .what {
  color: var(--muted);
}

.source {
  margin: 12px 0 0;
  font-size: .75rem;
}

.verdict {
  letter-spacing: 0;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: .7rem;
}

.verdict.agree {
  color: var(--accent);
  background: var(--soft);
}

.verdict.overrule {
  color: var(--ink);
  background: var(--soft);
}

.metrics, .history-card {
  padding: 16px 20px;
}

.latency {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  width: 100%;
  font-size: .8rem;
}

.latency caption {
  color: var(--muted);
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
  padding: 0 0 8px;
  font-size: .72rem;
  font-weight: 800;
}

.latency td {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.latency td:last-child {
  text-align: right;
}

.history-card h2 {
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .72rem;
  font-weight: 800;
}

.history {
  color: var(--muted);
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: .8rem;
  line-height: 1.45;
}

.history li {
  margin: 6px 0;
}

.dot {
  display: inline-block;
  vertical-align: 1px;
  border-radius: 50%;
  width: 9px;
  height: 9px;
  margin-right: 6px;
}

@media (max-width: 900px) {
  .lab-workspace {
    grid-template-columns: 1fr;
  }

  .results {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .lab-main {
    padding: 24px 16px 48px;
  }

  .lab-heading, .sample-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .live-link {
    width: -moz-fit-content;
    width: fit-content;
  }

  .sample-section {
    margin-top: 32px;
  }

  .source-actions {
    width: 100%;
  }

  .source-actions > * {
    flex: 1;
  }

  .settings-content {
    grid-template-columns: 1fr;
    width: calc(100vw - 32px);
    padding: 20px;
  }

  .setting-label, .settings select, .setting-toggles {
    grid-column: 1;
  }

  .setting-group:has(input[name="view"]) {
    grid-column: 1;
  }

  .views.pair {
    grid-template-columns: 1fr;
  }

  .lane {
    min-height: 280px;
  }

  .strip .row {
    grid-template-columns: 14px repeat(5, 40vw);
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .tile {
    scroll-snap-align: start;
  }

  .results {
    display: flex;
  }
}
