:root {
  --moss: #355256;
  --forest: #41907f;
  --pollen: #fad21c;
  --ink: #141414;
  --paper: #efebe3;
  --panel: #f7f4ee;
  --line: #d5cec2;
  --rail: #2c4347;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; }

body.atlas-app {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  overflow: hidden;
}

.chrome {
  background: linear-gradient(120deg, #24383b 0%, var(--moss) 55%, #3f6a62 100%);
  color: #fff;
  padding: 14px 20px 16px;
}

.chrome-brand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.chrome-brand .crumb {
  color: var(--pollen);
  text-decoration: none;
}

.chrome-brand .crumb:hover { text-decoration: underline; }

.chrome h1 {
  margin: 8px 0 4px;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  letter-spacing: -0.02em;
}

.chrome-note {
  margin: 0;
  max-width: 42rem;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.92rem;
  line-height: 1.35;
}

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  height: 100%;
}

.rail {
  background: var(--rail);
  color: #fff;
  padding: 16px 12px;
  overflow: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.rail-label {
  margin: 0 8px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.rail-list {
  display: grid;
  gap: 6px;
}

.rail-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  text-align: left;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.rail-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.rail-btn[aria-selected="true"] {
  background: rgba(65, 144, 127, 0.35);
  border-color: rgba(250, 210, 28, 0.55);
  color: #fff;
}

.rail-btn small {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
}

.stage {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  min-height: 0;
  background: #1a1a1a;
}

.theme-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.theme-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--moss);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.theme-btn:hover { border-color: var(--forest); }

.theme-btn[aria-selected="true"] {
  background: var(--moss);
  border-color: var(--moss);
  color: #fff;
}

.theme-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stage-map {
  position: relative;
  min-height: 0;
}

.stage-map .map {
  position: absolute;
  inset: 0;
}

.stage-tools {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 12px;
  right: 56px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.map-title {
  pointer-events: none;
  background: rgba(20, 20, 20, 0.82);
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.solo-link {
  pointer-events: auto;
  background: rgba(250, 210, 28, 0.95);
  color: #141414;
  text-decoration: none;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
}

.solo-link:hover { filter: brightness(1.05); }

.legend {
  position: absolute;
  z-index: 2;
  left: 12px;
  bottom: 12px;
  max-width: min(320px, calc(100% - 24px));
  max-height: 42%;
  overflow: auto;
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.legend strong {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend ul { margin: 0; padding: 0; }
.legend li { margin: 3px 0; list-style: none; }
.legend label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  line-height: 1.3;
}
.legend input { margin-top: 2px; accent-color: #41907f; }
.swatch {
  width: 18px;
  height: 8px;
  margin-top: 4px;
  border-radius: 2px;
  flex: none;
}

/* Standalone map pages keep the older sheet layout */
body.sheet {
  min-height: 100vh;
  overflow: auto;
}

body.sheet .top {
  background: var(--moss);
  color: #fff;
  padding: 28px 32px 22px;
}

body.sheet .top .eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

body.sheet .top .eyebrow a {
  color: var(--pollen);
  text-decoration: none;
}

body.sheet .top h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

body.sheet .top p {
  max-width: 760px;
  margin: 0;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.88);
}

body.sheet .wrap { padding: 8px 32px 64px; }
body.sheet .group { margin-top: 36px; }
body.sheet .group h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--moss);
}
body.sheet .group > p { margin: 0 0 16px; color: #3d3d3d; }
body.sheet .map-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 0 0 22px;
  overflow: hidden;
}
body.sheet .map-block header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 18px 10px;
}
body.sheet .map-block h3 { margin: 0 0 4px; font-size: 18px; }
body.sheet .map-block header p { margin: 0; color: #444; line-height: 1.4; }
body.sheet .map-frame { height: 640px; position: relative; }
body.sheet .map-frame .map { position: absolute; inset: 0; }
body.sheet .layers { display: none; }

body.one .map-frame { height: calc(100vh - 92px); }
body.one .top { padding: 16px 22px; }
body.one .top h1 { font-size: 22px; }
body.one .wrap { padding: 0; }
body.one .map-block { margin: 0; border: 0; border-radius: 0; }

.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 860px) {
  body.atlas-app { overflow: auto; }
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: calc(100vh - 110px);
  }
  .rail {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }
  .rail-list {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .rail-btn { white-space: nowrap; }
  .rail-btn small { display: none; }
  .stage-map { min-height: 68vh; }
}
