/* Website-style chrome: forest-green terminal palette, Courier, no gradient soup. */
:root[data-theme="dark"] {
  --bg: #10150f;
  --panel: #182017;
  --line: #3f6a3c;
  --text: #d6f3c8;
  --muted: #92b38b;
  --accent: #ff9f3d;
  --ok: #89ff89;
  --shadow: rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] {
  --bg: #f2f5ee;
  --panel: #ffffff;
  --line: #8fb489;
  --text: #1d2a19;
  --muted: #5c7258;
  --accent: #b85d1e;
  --ok: #2e7d32;
  --shadow: rgba(40, 60, 35, 0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  font-size: 15px;
}
#app { display: flex; flex-direction: column; height: 100vh; }

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-weight: 700; letter-spacing: 0.02em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.muted { color: var(--muted); }
.error { color: var(--accent); }
.spacer { flex: 1; }

/* chrome */
.chrome {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 700; letter-spacing: 0.12em; color: var(--ok); }
.chrome-title { color: var(--muted); }
.chrome-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 3px 10px;
  cursor: pointer;
}
.chrome-btn:hover { border-color: var(--accent); color: var(--accent); }
.hidden { display: none !important; }

.view { flex: 1; min-height: 0; display: flex; }

/* picker */
.picker { padding: 24px; max-width: 1100px; margin: 0 auto; width: 100%; overflow-y: auto; }
.intro { max-width: 640px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; }
.card {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  display: block;
  transition: transform 0.08s ease-in-out;
}
.card:hover { border-color: var(--accent); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
.card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; border-bottom: 1px solid var(--line); }
.card-body { padding: 10px 12px 12px; }
.card-body h3 { margin: 0 0 6px; text-transform: none; color: var(--text); font-size: 15px; }
.card-body p { margin: 0; color: var(--muted); font-size: 13px; }

/* mode select */
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 24px; max-width: 720px; }
.mode-card {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  display: block;
  padding: 22px 20px;
  transition: transform 0.08s ease-in-out;
}
.mode-card:hover { border-color: var(--accent); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
.mode-card h3 { margin: 10px 0 8px; text-transform: none; color: var(--text); font-size: 17px; }
.mode-card p { margin: 0; color: var(--muted); font-size: 13px; }
.mode-icon { font-size: 34px; line-height: 1; color: var(--ok); }

/* viewer */
.viewer { flex: 1; display: flex; min-height: 0; width: 100%; }
.stage { flex: 1; position: relative; min-width: 0; }
.map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.panel {
  width: 300px;
  order: -1; /* left of the map on desktop; DOM order keeps it below on mobile */
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.panel-content { padding: 14px 16px; }
.panel-toggle {
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  text-align: left;
  flex: none;
}
.panel-toggle-chevron {
  font-size: 22px;
  line-height: 1;
  color: var(--accent);
  flex: none;
}
.choices { display: flex; flex-direction: column; gap: 6px; }
.choice { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.choice input { accent-color: var(--accent); }
.choice.slider { margin-top: 6px; justify-content: space-between; }
.choice.slider input { width: 120px; }
.classdot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.panel-actions { margin-top: 14px; }
.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 4px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.hint { font-size: 12px; }
.attribution { font-size: 11px; }

.scalebar {
  position: absolute;
  left: 14px;
  bottom: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 6px 10px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  opacity: 0.92;
  pointer-events: none;
  box-shadow: 2px 2px 0 var(--shadow);
}
.scalebar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.scalebar-line {
  height: 7px;
  border: 2px solid var(--text);
  border-top: none;
}

.feature-chip {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--accent);
  padding: 5px 10px;
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 2px 2px 0 var(--shadow);
}

/* 3D viewer */
.viewer3d-loading { padding: 24px; }
.hud3d {
  position: absolute;
  left: 14px;
  bottom: 12px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  opacity: 0.92;
  pointer-events: none;
  box-shadow: 2px 2px 0 var(--shadow);
}
.help3d {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.help3d-card {
  width: 100%;
  max-width: 440px;
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--accent);
  box-shadow: 4px 4px 0 var(--shadow);
}
.help3d-card p { margin: 6px 0 0; font-size: 13px; }
.help3d-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  align-items: baseline;
  margin: 16px 0 4px;
  font-size: 14px;
}
.help3d-keys { color: var(--ok); font-weight: 700; white-space: nowrap; }
.help3d-start { margin-top: 18px; width: 100%; padding: 8px 12px; border-color: var(--accent); color: var(--accent); font-weight: 700; }
.help3d-start:hover, .help3d-start:focus-visible { background: var(--accent); color: var(--panel); outline: none; }
.controls-help { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); }
.controls-help li { margin: 2px 0; }
.choice .count { font-size: 12px; }
.legend-classes { display: flex; flex-direction: column; gap: 6px; }
.legend-class { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend-swatch { width: 34px; height: 14px; border: 1px solid var(--line); display: inline-block; flex: none; }

/* legend */
.legend-bar { display: flex; gap: 8px; align-items: stretch; }
.colorbar { border: 1px solid var(--line); width: 16px; height: 128px; }
.legend-ticks { display: flex; flex-direction: column; justify-content: space-between; font-size: 12px; color: var(--muted); }

@media (max-width: 720px) {
  .viewer { flex-direction: column; }
  .panel { width: 100%; order: 0; border-right: none; border-top: 1px solid var(--line); max-height: 55%; flex: none; }
  .panel-toggle { display: flex; }
  .panel.collapsed .panel-content { display: none; }
  .chrome { gap: 8px; padding: 8px 10px; }
  .chrome-title { display: none; }
  .brand { letter-spacing: 0.06em; }
}
