:root {
  color-scheme: light;
  --ink: #1d2027;
  --muted: #626874;
  --line: #d9dde5;
  --panel: #ffffff;
  --field: #f4f6f8;
  --slot: #fbfbfd;
  --slot-hover: #eef6f1;
  --pass: #19764b;
  --park: #a46a12;
  --fail: #b53b38;
  --accent: #315f8d;
  --violet: #6e4aa6;
  --shadow: 0 12px 30px rgba(28, 32, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  min-height: 36px;
  padding: 0 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  outline: 2px solid rgba(49, 95, 141, 0.18);
  outline-offset: 1px;
}

.app-shell {
  width: min(1740px, calc(100vw - 28px));
  margin: 14px auto;
}

.topbar,
.status-strip,
.workspace,
.tray-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  padding: 18px 20px;
  border-radius: 8px 8px 0 0;
}

.eyebrow,
.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 750;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 2.2vw, 2.4rem);
  line-height: 1.1;
}

h2 {
  font-size: 0.96rem;
  line-height: 1.2;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, auto)) minmax(180px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 0;
}

.status-strip > div {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: 0;
}

.message {
  justify-content: flex-end;
  color: var(--muted);
  font-weight: 650;
}

.message.buzzer {
  color: var(--fail);
}

.message.good {
  color: var(--pass);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(720px, 2.2fr) minmax(260px, 0.8fr);
  gap: 14px;
  padding: 14px;
  border-top: 0;
}

.folio-panel,
.board-panel,
.evidence-panel,
.tray-panel {
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 10px;
  color: var(--muted);
}

.panel-head h2 {
  color: var(--ink);
}

.image-frame {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #202229;
  aspect-ratio: 0.79;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.boundary {
  margin-top: 10px;
  display: grid;
  gap: 7px;
}

.boundary p {
  margin: 0;
  padding: 9px 10px;
  border-left: 4px solid var(--accent);
  background: var(--field);
  border-radius: 5px;
  color: #333945;
  font-size: 0.9rem;
  line-height: 1.35;
}

.board-panel {
  overflow: auto;
}

.board-grid {
  display: grid;
  grid-template-columns: 64px repeat(17, minmax(34px, 1fr));
  gap: 5px;
  min-width: 732px;
}

.corner-label,
.slot-index,
.cycle-label,
.slot {
  min-height: 38px;
  border-radius: 7px;
}

.corner-label,
.slot-index,
.cycle-label {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.slot-index {
  border: 1px solid transparent;
  background: var(--field);
}

.cycle-label {
  border: 1px solid var(--line);
  background: #f9fafb;
}

.slot {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid #cbd2dc;
  background: var(--slot);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.slot:hover,
.slot.drag-over {
  background: var(--slot-hover);
  border-color: var(--accent);
}

.slot.selected {
  border-color: var(--violet);
  box-shadow: 0 0 0 2px rgba(110, 74, 166, 0.16) inset;
}

.slot.wrong {
  animation: buzz 180ms linear 2;
  border-color: var(--fail);
  background: #fff0ef;
}

.slot.pass {
  border-color: rgba(25, 118, 75, 0.45);
}

.slot.park {
  border-color: rgba(164, 106, 18, 0.55);
}

.slot.fail {
  border-color: rgba(181, 59, 56, 0.55);
}

.slot .answer {
  position: absolute;
  inset: 5px;
  display: grid;
  place-items: center;
  color: rgba(29, 32, 39, 0.28);
  font-size: 0.88rem;
  font-weight: 800;
}

.tile {
  min-width: 34px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #bfc7d3;
  background: #fff;
  color: #151922;
  border-radius: 7px;
  padding: 4px 8px;
  font-weight: 820;
  font-size: 0.98rem;
  cursor: grab;
  user-select: none;
}

.tile:active {
  cursor: grabbing;
}

.tile.selected {
  border-color: var(--violet);
  background: #f3effb;
  box-shadow: 0 0 0 2px rgba(110, 74, 166, 0.15);
}

.tile.decoy {
  border-style: dashed;
  color: #5e3b22;
  background: #fff8ef;
}

.slot .tile {
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  min-width: 0;
  min-height: 0;
  padding: 0 4px;
  cursor: pointer;
}

.tray-panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: 0 0 8px 8px;
}

.tile-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 96px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.slot-evidence {
  min-height: 248px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  font-size: 0.93rem;
  line-height: 1.42;
}

.slot-evidence.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.slot-evidence dl {
  margin: 0;
}

.slot-evidence dt {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 820;
  text-transform: uppercase;
}

.slot-evidence dd {
  margin: 3px 0 0;
}

.status-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 10px 0;
}

.status-buttons button[data-status="pass"] {
  border-color: rgba(25, 118, 75, 0.35);
}

.status-buttons button[data-status="park"] {
  border-color: rgba(164, 106, 18, 0.4);
}

.status-buttons button[data-status="fail"] {
  border-color: rgba(181, 59, 56, 0.4);
}

.sources {
  display: grid;
  gap: 7px;
}

.source-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  background: #fff;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.source-item strong {
  display: block;
  margin-bottom: 2px;
}

@keyframes buzz {
  0% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

@media (max-width: 1180px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .folio-panel {
    display: grid;
    grid-template-columns: minmax(220px, 360px) 1fr;
    gap: 12px;
    align-items: start;
  }

  .folio-panel .panel-head {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: calc(100vw - 16px);
    margin: 8px auto;
  }

  .topbar,
  .workspace,
  .tray-panel {
    padding: 10px;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }

  .message {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .folio-panel {
    display: block;
  }

  .toolbar button {
    flex: 1 1 130px;
  }
}
