:root {
  --ink: oklch(0.22 0.02 255);
  --muted: oklch(0.42 0.02 255);
  --paper: oklch(0.965 0.006 255);
  --card: oklch(0.995 0.002 255);
  --line: oklch(0.88 0.01 255);
  --accent: oklch(0.48 0.11 255);
  --accent-deep: oklch(0.38 0.1 255);
  --accent-soft: oklch(0.94 0.03 255);
  --strong: oklch(0.48 0.1 155);
  --steady: oklch(0.5 0.09 200);
  --mixed: oklch(0.58 0.11 70);
  --worn: oklch(0.52 0.13 35);
  --font: "Figtree", "Segoe UI", sans-serif;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
}
button { font: inherit; color: inherit; }
h2 { font-weight: 650; letter-spacing: -0.03em; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: var(--accent-deep); }
a:hover { color: var(--accent); }

.top, .why, .foot, .picker-wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}
.top { padding: 20px 0 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; letter-spacing: -0.03em; }
.mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); position: relative; flex: none;
}
.mark::before {
  content: "";
  position: absolute; left: 6px; top: 8px; width: 14px; height: 11px;
  background: oklch(0.98 0.01 255);
  clip-path: polygon(0 100%, 0 38%, 50% 0, 100% 38%, 100% 100%, 62% 100%, 62% 58%, 38% 58%, 38% 100%);
}
.top p { margin: 8px 0 0; max-width: 58ch; color: var(--muted); }

.picker-wrap { padding-top: 18px; }
.picker-label { margin: 0 0 8px; color: var(--muted); font-size: 0.88rem; }
.picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.house {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  opacity: 0.82;
  transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.house img, .house .slot {
  width: 92px; height: 68px; object-fit: cover; border-radius: 8px; display: block;
}
.house .slot {
  display: grid; place-items: center;
  background: var(--line); color: var(--muted); font-size: 0.75rem; font-weight: 650;
}
.house-meta { display: grid; gap: 2px; min-width: 0; }
.house-meta b { font-size: 0.95rem; }
.house-meta span { color: var(--muted); font-size: 0.82rem; }
.signal { display: flex; align-items: center; gap: 6px; font-weight: 650; }
.signal i, .lamp {
  width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--line);
}
.house.strong .signal i, .verdict.strong .lamp { background: var(--strong); }
.house.steady .signal i, .verdict.steady .lamp { background: var(--steady); }
.house.mixed .signal i, .verdict.mixed .lamp { background: var(--mixed); }
.house.worn .signal i, .verdict.worn .lamp { background: var(--worn); }
.house.strong .signal { color: var(--strong); }
.house.steady .signal { color: var(--steady); }
.house.mixed .signal { color: var(--mixed); }
.house.worn .signal { color: var(--worn); }
.house:hover { opacity: 0.92; }
.house.is-on {
  opacity: 1;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent);
}
.house:active { transform: scale(0.99); }

.studio {
  width: min(1180px, calc(100% - 32px));
  margin: 16px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}
.frame {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: oklch(0.9 0.01 255);
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
}
.frame > img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity 0.28s ease;
}
.frame > img[hidden] { display: none; }
.frame > img.is-ready { opacity: 1; }
.frame.is-reading > img.is-ready { opacity: 0.72; }
/* Layers: photo, leader lines, callout cards. */
.leaders {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none;
}
.leaders line { stroke: oklch(0.98 0.005 255); stroke-width: 2; fill: none; }
.leaders circle { fill: oklch(0.98 0.005 255); stroke: oklch(0.25 0.02 255); stroke-width: 1.25; }
.callouts { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.callout {
  pointer-events: auto;
  position: absolute;
  width: clamp(118px, 28%, 210px);
  margin: 0;
  padding: 5px 5px 7px;
  border: 0;
  border-radius: 12px;
  background: oklch(0.98 0.005 255);
  color: oklch(0.22 0.02 255);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 28px oklch(0.25 0.03 255 / 0.22);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.18s ease;
}
.callout.tl { left: 10px; top: 10px; }
.callout.tr { right: 10px; top: 10px; }
.callout.bl { left: 10px; bottom: 10px; }
.callout.br { right: 10px; bottom: 10px; }
.callout:active { transform: scale(0.98); }
.callout:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.callouts.is-hot .callout { opacity: 0.72; }
.callouts.is-hot .callout:hover,
.callouts.is-hot .callout:focus-visible { opacity: 1; transform: translateY(-2px); }
.leaders g { opacity: 1; }
.frame:has(.callouts.is-hot) .leaders g { opacity: 0.28; }
.frame:has(.callouts.is-hot) .leaders g.is-hot { opacity: 1; }
.crop {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: oklch(0.9 0.01 255);
}
.crop img {
  position: absolute;
  width: calc(var(--z) * 100%);
  height: calc(var(--z) * 100%);
  max-width: none;
  object-fit: cover;
  left: calc((50 - var(--x) * var(--z)) * 1%);
  top: calc((50 - var(--y) * var(--z)) * 1%);
}
.callout b {
  display: block;
  margin: 6px 4px 1px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.pending {
  margin: 0; position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  padding: 24px; color: var(--muted); max-width: 36ch; justify-self: center; align-self: center;
}
.caption { margin: 10px 2px 0; color: var(--muted); font-size: 0.92rem; max-width: 65ch; }
.caption b { font-weight: 700; }
.caption b.strong { color: var(--strong); }
.caption b.steady { color: var(--steady); }
.caption b.mixed { color: var(--mixed); }
.caption b.worn { color: var(--worn); }
.film {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.thumb {
  padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden;
  background: var(--card); cursor: pointer; opacity: 0.5;
  display: grid;
  transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.thumb img, .thumb .slot { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.thumb .slot {
  display: grid; place-items: center; background: var(--line); color: var(--muted); font-size: 0.75rem;
}
.thumb span:last-child {
  padding: 4px 6px 6px; font-size: 0.75rem; font-weight: 650; text-align: left;
}
.thumb:hover { opacity: 0.9; }
.thumb.is-on { opacity: 1; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.thumb.is-linked { opacity: 1; }
.thumb.worn.is-on, .thumb.worn.is-linked { border-color: var(--worn); box-shadow: 0 0 0 2px var(--worn); }
.thumb:active { transform: scale(0.98); }
.thumb:focus-visible, .house:focus-visible, .modes button:focus-visible {
  outline: 3px solid oklch(0.72 0.08 255); outline-offset: 2px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.modes button {
  border: 0; border-right: 1px solid var(--line);
  background: transparent; padding: 10px 8px; cursor: pointer; font-weight: 650;
}
.modes button:last-child { border-right: 0; }
.modes button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-deep); }
.modes button:active { transform: scale(0.98); }
.verdict {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px; padding: 8px 10px; border-radius: 8px;
  background: oklch(0.97 0.004 255); font-size: 0.9rem;
}
.verdict b { font-weight: 700; }
.verdict span { color: var(--muted); }
.verdict.worn { background: oklch(0.95 0.03 35); }
.mode-copy { margin: 10px 0 12px; color: var(--muted); font-size: 0.9rem; }
.scores { display: grid; gap: 8px; }
.score {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: oklch(0.97 0.004 255);
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s ease;
}
.score:hover { transform: translateX(4px); }
.score > span:first-child { grid-column: 1; grid-row: 1; color: var(--muted); font-size: 0.82rem; }
.score strong { grid-column: 2; grid-row: 1; align-self: center; font-size: 1.35rem; letter-spacing: -0.04em; }
.score.strong strong { color: var(--strong); }
.score.steady strong { color: var(--steady); }
.score.mixed strong { color: var(--mixed); }
.score.worn strong { color: var(--worn); }
.score.worn { background: oklch(0.96 0.02 35); }
.score.is-hot { box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-soft); }
.reason {
  margin: 12px 0 0; min-height: 3.2em;
  padding: 10px 12px; border-radius: 8px;
  background: oklch(0.96 0.01 255); font-size: 0.92rem;
}
.facts { display: grid; gap: 8px; margin-top: 14px; }
.facts p { margin: 0; font-size: 0.92rem; }
.facts b { font-weight: 650; }
.scale { margin: 14px 0 0; color: var(--muted); font-size: 0.82rem; }

.why { padding: 8px 0 12px; }
.why h2 { margin: 0 0 10px; font-size: 1.25rem; }
.why ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; max-width: 72ch; }
.why li { color: var(--muted); }
.why strong { color: var(--ink); font-weight: 650; }
.foot {
  padding: 8px 0 28px;
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  color: var(--muted); font-size: 0.88rem;
}
.foot p { margin: 0; max-width: 62ch; }

@media (max-width: 900px) {
  .picker, .studio { grid-template-columns: 1fr; }
  .film { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .foot { display: grid; }
}
@media (max-width: 640px) {
  .callout { width: clamp(104px, 34%, 160px); }
  .callout b { font-size: 0.75rem; }
  .picker { grid-auto-flow: column; grid-auto-columns: minmax(220px, 80%); grid-template-columns: none; overflow-x: auto; }
  .modes { grid-template-columns: 1fr; }
  .modes button { border-right: 0; border-bottom: 1px solid var(--line); }
  .modes button:last-child { border-bottom: 0; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: oklch(0.94 0.01 255);
    --muted: oklch(0.74 0.02 255);
    --paper: oklch(0.18 0.015 255);
    --card: oklch(0.22 0.015 255);
    --line: oklch(0.32 0.02 255);
    --accent: oklch(0.72 0.1 255);
    --accent-deep: oklch(0.82 0.08 255);
    --accent-soft: oklch(0.3 0.04 255);
    --strong: oklch(0.74 0.1 155);
    --steady: oklch(0.74 0.08 200);
    --mixed: oklch(0.78 0.1 75);
    --worn: oklch(0.72 0.12 35);
    color-scheme: dark;
  }
  .mark::before { background: oklch(0.16 0.02 255); }
  .score, .verdict, .reason { background: oklch(0.24 0.015 255); }
  .score.worn, .verdict.worn { background: oklch(0.3 0.04 35); }
}

@media (prefers-reduced-motion: reduce) {
  .frame > img, .house, .thumb, .score, .callout { transition: none; }
}
