:root {
  color-scheme: light;
  --bg: #eef2ef;
  --panel: #fbfcfb;
  --panel-strong: #ffffff;
  --line: #cfd7d1;
  --line-strong: #9eaba1;
  --text: #17211c;
  --muted: #4a5b51;
  --accent: #1f8a62;
  --accent-strong: #136146;
  --danger: #e45858;
  --trail: #128fa1;
  --endpoint: #f0bc42;
  --shadow: 0 18px 44px rgba(23, 33, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

button,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

button:hover {
  background: #f5f8f5;
  border-color: #819285;
}

button:active {
  transform: translateY(1px);
}

code {
  font-family: "SFMono-Regular", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.app-shell {
  min-height: 100vh;
}

.main-panel {
  min-height: 100vh;
  padding: 24px;
}

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

.board-panel,
.right-rail {
  min-width: 0;
}

.board-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.right-rail {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.rail-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.intro,
.board-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.intro h1,
.board-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2rem);
  line-height: 1.15;
}

.intro-copy,
.controls-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.section-title-row,
.board-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.board-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.board-header > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.board-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.active-image-stats {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 600;
}

.right-rail h2 {
  margin: 0;
  font-size: 1rem;
}

.status-pill,
.hover-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf6f1;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 600;
}

.hover-pill {
  background: #f3f6f4;
  color: var(--muted);
}

.board-wrap,
.detail-wrap {
  position: relative;
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.board-wrap {
  aspect-ratio: 1;
  max-width: 760px;
}

.detail-wrap {
  aspect-ratio: 1;
  max-width: 100%;
}

#boardCanvas,
#detailCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

#detailCanvas {
  cursor: cell;
}

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

.pan-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 64px));
  justify-content: start;
  gap: 8px;
}

.pan-button {
  min-height: 44px;
  font-weight: 700;
}

.pan-button.up {
  grid-column: 2;
}

.pan-button.left {
  grid-column: 1;
}

.pan-button.down {
  grid-column: 2;
}

.pan-button.right {
  grid-column: 3;
}

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

.button-row button {
  min-height: 40px;
  padding: 0 12px;
}

.image-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.image-option {
  display: grid;
  gap: 8px;
  padding: 8px;
  text-align: left;
}

.image-option.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(31, 138, 98, 0.2);
}

.image-option img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  border-radius: 6px;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  background: #dfe6e1;
}

.image-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.92rem;
}

.image-meta span:last-child {
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  line-height: 1.45;
  font-family: "SFMono-Regular", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

textarea:focus,
button:focus-visible,
.image-option:focus-visible {
  outline: 2px solid rgba(31, 138, 98, 0.25);
  outline-offset: 2px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.legend-swatch.missed {
  background: rgba(228, 88, 88, 0.7);
}

.legend-swatch.trail {
  background: var(--trail);
}

.legend-swatch.endpoint {
  background: var(--endpoint);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

@media (max-width: 720px) {
  .main-panel {
    padding: 16px;
  }

  .board-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .board-wrap {
    max-width: 100%;
  }

  .pan-pad {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
}
