:root {
  --bg: #14171a;
  --panel: #1c2024;
  --panel-raised: #21262b;
  --border: #2b3238;
  --accent: #ff8a34;
  --accent-soft: rgba(255, 138, 52, 0.14);
  --text: #e8e6de;
  --text-dim: #8a9098;
  --good: #5eead4;

  --font-display: "Big Shoulders", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ---- Header ---- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 40px;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 0 transparent;
}

.status-dot.ready {
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
}

.status-dot.busy {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.status-dot.error {
  background: #f26d6d;
  box-shadow: 0 0 8px #f26d6d;
}

.clear-cache-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.clear-cache-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ---- Mode select ---- */

.mode-select {
  display: inline-flex;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 24px;
  gap: 4px;
}

.mode-btn {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent);
  color: #1a1206;
}

/* ---- Workspace ---- */

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 720px) {
  .workspace {
    grid-template-columns: 500px 1fr;
    align-items: start;
  }
}

/* ---- Viewfinder (signature element) ---- */

.viewfinder {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1 / 1;
  background: #000;
  border: 1px solid var(--border);
  overflow: hidden;
}

.viewfinder canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  z-index: 2;
  pointer-events: none;
}

.corner.tl {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
}
.corner.tr {
  top: 8px;
  right: 8px;
  border-left: none;
  border-bottom: none;
}
.corner.bl {
  bottom: 8px;
  left: 8px;
  border-right: none;
  border-top: none;
}
.corner.br {
  bottom: 8px;
  right: 8px;
  border-left: none;
  border-top: none;
}

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%; /* matches the viewfinder's height, so translateY(100%) below moves it exactly one container-height down */
  opacity: 0;
  z-index: 3;
  pointer-events: none;
}

/* The actual visible line — pinned to the top edge of .scanline, which is
   what we animate via transform below. */
.scanline::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.scanline.active {
  opacity: 1;
  animation: scan 1.1s linear infinite;
}

@keyframes scan {
  0% {
    transform: translateY(0%);
  }
  100% {
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .scanline.active {
    animation: none;
    opacity: 0.6;
    transform: translateY(50%);
  }
  .status-dot.busy {
    animation: none;
  }
}

.upload-btn {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.upload-btn:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Readout panel ---- */

.readout {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  min-height: 120px;
}

.readout h3 {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 14px;
  font-weight: 500;
}

.readout-empty {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}

.result-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child {
  border-bottom: none;
}

.result-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.result-label {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex: 1;
}

.result-row.top .result-label {
  color: var(--accent);
}

.result-bar-track {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.result-bar-fill {
  display: block;
  height: 100%;
  background: var(--good);
}

.result-row.top .result-bar-fill {
  background: var(--accent);
}

.result-pct {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  width: 44px;
  text-align: right;
  flex-shrink: 0;
}

.result-coords {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  width: 100%;
  margin-top: 2px;
}

/* ---- Footer ---- */

.footnote {
  margin-top: 32px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
