/* FitFest admin console. Hand-written, no build step, no external assets. */

:root {
  color-scheme: dark;
  --bg: #0b0d11;
  --surface: #12151b;
  --surface-2: #171b23;
  --border: #262c36;
  --text: #e7ebf2;
  --muted: #9aa4b2;
  --accent: #4f8cff;
  --accent-ink: #06121f;
  --danger: #ff6b6b;
  --ok: #44d19d;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

.brand-name {
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-soon {
  color: var(--muted);
  font-size: 13px;
}

.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 13px;
  color: var(--muted);
}

.who-email {
  font-family: var(--mono);
  font-size: 12px;
}

.inline-form {
  margin: 0;
}

.link-button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 0.25rem 0.6rem;
}

.link-button:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* Layout */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card.tight {
  padding: 0.9rem 1rem;
}

.login-card {
  max-width: 420px;
  margin: 3rem auto;
}

.grid-4 {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.grid-2 {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-value {
  margin: 0.25rem 0 0;
  font-size: 14px;
  word-break: break-word;
}

.roadmap-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

/* Forms */

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 0.55rem 0.7rem;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(79, 140, 255, 0.25);
  outline-offset: 1px;
}

button.primary {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: var(--accent-ink);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0.6rem 1rem;
}

button.primary:hover {
  filter: brightness(1.08);
}

button.secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 0.5rem 0.9rem;
}

.alert {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.4);
  border-radius: 8px;
  color: #ffc2c2;
  font-size: 13px;
  padding: 0.6rem 0.8rem;
  margin-top: 0.75rem;
}

.ok {
  color: var(--ok);
}

/* Phase C: pack list, drafts and detail */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
}

a.button,
button.button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-size: 13px;
  padding: 0.45rem 0.8rem;
  text-decoration: none;
}

a.button:hover,
button.button:hover {
  border-color: var(--muted);
  text-decoration: none;
}

a.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.danger {
  background: #7a1f1f;
  border: 1px solid #a33;
  border-radius: 8px;
  color: #ffe3e3;
  cursor: pointer;
  font: inherit;
  padding: 0.5rem 0.9rem;
}

button.danger:hover {
  background: #932626;
}

.card.narrow {
  max-width: 620px;
}

.card.flush {
  padding: 0;
  overflow-x: auto;
}

table.data {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

table.data.compact {
  font-size: 13px;
}

table.data.compact th,
table.data.compact td {
  padding: 0.55rem 0.7rem;
}

table.data th,
table.data td {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem;
  text-align: left;
  vertical-align: middle;
}

table.data th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

table.data tr:last-child td {
  border-bottom: none;
}

.badge-draft,
.badge-published,
.badge-revoked {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.5rem;
  text-transform: uppercase;
}

.badge-draft {
  background: rgba(154, 164, 178, 0.16);
  color: var(--muted);
}

.badge-published {
  background: rgba(68, 209, 157, 0.16);
  color: var(--ok);
}

.badge-revoked {
  background: rgba(255, 107, 107, 0.16);
  color: var(--danger);
}

.notice {
  background: rgba(68, 209, 157, 0.1);
  border: 1px solid rgba(68, 209, 157, 0.35);
  border-radius: 8px;
  color: #b8f3dc;
  font-size: 13px;
  padding: 0.6rem 0.8rem;
}

.row-actions {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.pre-wrap {
  white-space: pre-wrap;
}

ul.issues {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 13px;
}

li.issue-error {
  color: #ffb4b4;
}

li.issue-warning {
  color: #ffd79a;
}

/* Challenge editor */

.grid-3 {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.field.checkbox {
  align-items: center;
  flex-direction: row;
  gap: 0.5rem;
}

.field.checkbox input {
  width: auto;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rows .row {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 140px 1fr 1fr auto;
  align-items: center;
}

.rows .row input,
.rows .row select {
  font-size: 13px;
  padding: 0.4rem 0.5rem;
}

.rows .row .link-button {
  white-space: nowrap;
}

.mono-input {
  font-family: var(--mono);
  font-size: 13px;
}

.challenge-actions {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.6rem 1rem;
}

button.small-button {
  background: #7a1f1f;
  border: 1px solid #a33;
  border-radius: 8px;
  color: #ffe3e3;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 0.3rem 0.7rem;
}

table.data.compact th,
table.data.compact td {
  padding: 0.45rem 0.7rem;
}

table.data.compact {
  font-size: 13px;
}

/* Route picker */

.map {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 320px;
  margin: 0.75rem 0;
  background: #0f141b;
}

.map-toolbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.field.inline-field {
  align-items: center;
  flex-direction: row;
  gap: 0.5rem;
}

.field.inline-field select {
  width: auto;
}

/* Preview and published manifest */

.code-block {
  background: #0f141b;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  padding: 0.9rem;
  white-space: pre;
}

.preview-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.preview-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.preview-head h2 {
  margin: 0;
}

.route-sketch {
  margin-top: auto;
  padding-top: 0.5rem;
}

.map-status {
  background: rgba(255, 214, 128, 0.12);
  border: 1px solid rgba(255, 214, 128, 0.45);
  border-radius: 8px;
  color: #ffd79a;
  font-size: 12px;
  left: 50%;
  max-width: 420px;
  padding: 0.5rem 0.7rem;
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
  z-index: 500;
}

.map {
  position: relative;
}

/* Full screen map and map controls */

.map-fullscreen {
  background: var(--bg);
  border: none;
  border-radius: 0;
  height: 100dvh;
  inset: 0;
  margin: 0;
  position: fixed;
  width: 100vw;
  z-index: 2000;
}

.map-fs-button,
.map-fit-button {
  font-size: 15px;
  line-height: 1;
}

.maplibregl-ctrl-group button.map-fs-button,
.maplibregl-ctrl-group button.map-fit-button {
  color: #e7ebf2;
  font-size: 15px;
}

.map-fullscreen .map-status {
  top: 54px;
}

.map:fullscreen {
  border: none;
  border-radius: 0;
  height: 100vh;
  margin: 0;
  width: 100vw;
}

.map:fullscreen .map-status {
  top: 54px;
}

.field.inline-field.grow {
  flex: 1 1 320px;
}

.field.inline-field.grow input {
  min-width: 240px;
}

.table-actions {
  text-align: right;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.card.flush table.data {
  min-width: 100%;
}

.confirm-panel {
  align-items: center;
  background: rgba(147, 38, 38, 0.18);
  border: 1px solid rgba(255, 107, 107, 0.5);
  border-radius: 8px;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

.confirm-question {
  color: #ffd7d7;
  font-size: 13px;
}


.traffic-bars {
  align-items: flex-end;
  display: flex;
  gap: 2px;
  height: 44px;
  margin: 0.5rem 0;
}

.traffic-bar {
  background: var(--accent, #4f8cff);
  border-radius: 1px;
  flex: 1;
  min-width: 3px;
  opacity: 0.8;
}

.card.tight.good {
  border-left: 3px solid #4f8cff;
}

.card.tight.attention {
  border-left: 3px solid #f0a742;
}

.card.tight.warning {
  border-left: 3px solid #ff6b6b;
}

.card.tight.good .panel-label {
  color: #a9c7ff;
}

.card.tight.attention .panel-label {
  color: #ffcf8a;
}

.card.tight.warning .panel-label {
  color: #ffb3b3;
}


.chart-svg {
  display: block;
  height: auto;
  margin-top: 0.6rem;
  max-width: 100%;
}

/* Metric help: info icon in the card corner with a hover/focus tooltip. */
.card.tight {
  position: relative;
}

.card.tight .panel-label {
  padding-right: 20px;
}

.info {
  background: transparent;
  border: 1px solid #39414f;
  border-radius: 50%;
  color: #8a94a6;
  cursor: help;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-style: italic;
  height: 16px;
  line-height: 13px;
  position: absolute;
  right: 8px;
  text-align: center;
  top: 8px;
  width: 16px;
}

.info:hover,
.info:focus-visible {
  border-color: #4f8cff;
  color: #a9c7ff;
  outline: none;
}

.info::after {
  background: #11161f;
  border: 1px solid #2a3040;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  color: #d7dee9;
  content: attr(data-tooltip);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-style: normal;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.45;
  opacity: 0;
  padding: 0.55rem 0.65rem;
  pointer-events: none;
  position: absolute;
  right: 0;
  text-align: left;
  top: 22px;
  transition: opacity 0.12s;
  visibility: hidden;
  white-space: normal;
  width: 250px;
  z-index: 40;
}

.info:hover::after,
.info:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

/* Dashboard logical groups. */
.dash-group {
  margin: 0 0 1.7rem;
}

.dash-group > h2 {
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  margin: 0 0 0.2rem;
}

.dash-group > .group-note {
  margin: 0 0 0.8rem;
}

.dash-group > .card + .card,
.dash-group > .card + .dash-group {
  margin-top: 0.9rem;
}

.dash-group .grid-4,
.dash-group .grid-2 {
  margin-bottom: 0.9rem;
}

/* Dashboard tabs: all panels visible without JS, one panel at a time with JS. */
.tabs {
  border-bottom: 1px solid #232937;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 1rem 0 1.4rem;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  color: #8a94a6;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
}

.tab:hover {
  color: #d7dee9;
}

.tab[aria-selected="true"] {
  border-bottom-color: #4f8cff;
  color: #a9c7ff;
}

.tab:focus-visible {
  outline: 2px solid #4f8cff;
  outline-offset: -2px;
}

.dash-group[role="tabpanel"][hidden] {
  display: none;
}

/* Chart value tooltip bubble (positioned by chart-tooltip.js). */
.chart-tip {
  background: #11161f;
  border: 1px solid #2a3040;
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  color: #e3e9f2;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  line-height: 1.35;
  padding: 4px 7px;
  pointer-events: none;
  position: fixed;
  white-space: nowrap;
  z-index: 80;
}

/* Notification bell and notification levels. */
.bell {
  align-items: center;
  color: #8a94a6;
  display: inline-flex;
  padding: 0.25rem;
  position: relative;
}

.bell:hover,
.bell:focus-visible {
  color: #d7dee9;
}

.bell.has-unread {
  color: #f0a742;
}

.bell-badge {
  background: #ff6b6b;
  border-radius: 8px;
  color: #11161f;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  min-width: 14px;
  padding: 2px 4px;
  position: absolute;
  right: -4px;
  text-align: center;
  top: -3px;
}

.notif-level {
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  text-transform: uppercase;
}

.notif-level.info {
  background: rgba(79, 140, 255, 0.16);
  color: #a9c7ff;
}

.notif-level.warning {
  background: rgba(240, 167, 66, 0.16);
  color: #ffcf8a;
}

.notif-level.critical {
  background: rgba(255, 107, 107, 0.16);
  color: #ffb3b3;
}

/* Map editor Stage A: point table, segment list, warnings and extra toolbar controls. */
.map-file-input {
  display: none;
}

.map-route-panels {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 0.9rem;
}

@media (max-width: 900px) {
  .map-route-panels {
    grid-template-columns: minmax(0, 1fr);
  }
}

.map-side-panel {
  border: 1px solid #232937;
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}

.map-side-panel h3 {
  font-size: 0.9rem;
  margin: 0 0 0.2rem;
}

.map-points {
  max-height: 220px;
  overflow: auto;
}

.map-point {
  align-items: center;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 1.4rem 1fr 1fr 1.4rem 1.4rem 1.6rem 1.6rem;
  margin: 0.25rem 0;
}

.map-point-index {
  color: #8a94a6;
  font-size: 11px;
  text-align: right;
}

.map-point input {
  background: #0f141b;
  border: 1px solid #2a3040;
  border-radius: 4px;
  color: #d7dee9;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  min-width: 0;
  padding: 0.25rem 0.35rem;
}

.map-point-action {
  background: transparent;
  border: 1px solid #2a3040;
  border-radius: 4px;
  color: #8a94a6;
  cursor: pointer;
  font-size: 12px;
  padding: 0.2rem 0;
}

.map-point-action:hover:not(:disabled) {
  border-color: #4f8cff;
  color: #a9c7ff;
}

.map-segments {
  max-height: 220px;
  overflow: auto;
}

.map-segment {
  background: transparent;
  border: 1px solid #232937;
  border-radius: 4px;
  color: #d7dee9;
  cursor: pointer;
  display: block;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  margin: 0.2rem 0;
  padding: 0.3rem 0.45rem;
  text-align: left;
  width: 100%;
}

.map-segment:hover {
  border-color: #4f8cff;
}

.map-segment.attention {
  border-color: #f0a742;
}

.map-warning {
  background: rgba(240, 167, 66, 0.12);
  border: 1px solid #f0a742;
  border-radius: 4px;
  color: #ffcf8a;
  cursor: pointer;
  display: block;
  font-size: 11px;
  margin: 0.25rem 0;
  padding: 0.3rem 0.45rem;
  text-align: left;
  width: 100%;
}


.map-ghost-actions {
  align-items: center;
  background: #11161f;
  border: 1px solid #f0a742;
  border-radius: 8px;
  bottom: 12px;
  display: flex;
  gap: 0.5rem;
  left: 12px;
  padding: 0.45rem 0.6rem;
  position: absolute;
  right: 12px;
  z-index: 5;
}

.map-ghost-label {
  color: #ffcf8a;
  flex: 1;
  font-size: 12px;
}


.map-draft-recovery {
  align-items: center;
  background: #11161f;
  border: 1px solid #4f8cff;
  border-radius: 8px;
  bottom: 12px;
  display: flex;
  gap: 0.5rem;
  left: 12px;
  padding: 0.45rem 0.6rem;
  position: absolute;
  right: 12px;
  z-index: 6;
}

.map-draft-recovery span {
  color: #a9c7ff;
  flex: 1;
  font-size: 12px;
}

.map-search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 340px;
}

.map-search-result {
  background: #11161f;
  border: 1px solid #2a3040;
  border-radius: 4px;
  color: #d7dee9;
  cursor: pointer;
  font-size: 11px;
  overflow: hidden;
  padding: 0.3rem 0.45rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-search-result:hover {
  border-color: #4f8cff;
}

/* Map-first challenge editor: full-height map with a scrollable dock. Step 1 keeps the
   existing dock content and ids; later steps move the toolbar onto the map. */
.page:has(.editor-shell) {
  display: block;
  max-width: none;
  padding: 0;
}

.editor-shell {
  --dock-width: 420px;
  display: grid;
  grid-template-columns: var(--dock-width) minmax(0, 1fr);
  height: calc(100dvh - 64px);
  position: relative;
  transition: grid-template-columns 0.18s ease;
}

.editor-shell.is-dock-collapsed {
  --dock-width: 0px;
}

.editor-shell.is-dock-collapsed .editor-dock {
  border-right: 0;
  opacity: 0;
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
  pointer-events: none;
  visibility: hidden;
}

.editor-shell.is-dock-collapsed .editor-map-pane {
  grid-column: 1 / -1;
}

.dock-collapse {
  align-items: center;
  transition: left 0.18s ease;
  background: #e9edf5;
  border: 1px solid #b9c3d4;
  border-radius: 0 8px 8px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  color: #17202b;
  cursor: pointer;
  display: flex;
  height: 64px;
  justify-content: center;
  left: var(--dock-width);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  z-index: 7;
}

.dock-collapse:hover {
  background: #ffffff;
}

.editor-shell.is-dock-collapsed .dock-collapse {
  border-radius: 0 8px 8px 0;
  left: 0;
}

.dock-collapse-icon {
  font-size: 16px;
  line-height: 1;
}

.editor-dock {
  border-right: 1px solid var(--border);
  min-width: 0;
  opacity: 1;
  transition: opacity 0.18s ease, padding 0.18s ease;
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem 1rem 2.5rem;
}

.editor-map-pane {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  position: relative;
}

.editor-map-pane .map {
  border: 0;
  border-radius: 0;
  height: 100%;
  margin: 0;
}

@media (max-width: 900px) {
  .page:has(.editor-shell) {
    padding: 1rem;
  }

  .editor-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 45dvh auto;
    height: auto;
  }

  .editor-map-pane {
    grid-column: 1;
    grid-row: 1;
  }

  .editor-map-pane .map {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: 45dvh;
  }

  .editor-dock {
    border-right: 0;
    grid-column: 1;
    grid-row: 2;
    overflow: visible;
    padding: 1rem 0 2rem;
  }
}



/* Right-edge route rail: icon-only collapsed, labels and parameters when open. */
.map-rail {
  background: rgba(17, 22, 31, 0.94);
  border: 1px solid var(--border);
  border-radius: 10px;
  bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
  padding: 0.35rem;
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  transition: width 0.18s ease;
  width: 52px;
  z-index: 6;
}

.map-rail.is-open {
  overflow: auto;
  width: 300px;
}

.rail-toggle {
  align-items: center;
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #a9c7ff;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  min-height: 34px;
  padding: 0.25rem 0.35rem;
}

.rail-toggle .rail-icon {
  transition: transform 0.18s ease;
}

.map-rail.is-open .rail-toggle .rail-icon {
  transform: rotate(180deg);
}

.rail-row {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #d7dee9;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  gap: 0.5rem;
  min-height: 34px;
  padding: 0.25rem 0.35rem;
  text-align: left;
  width: 100%;
}

.rail-row:hover {
  background: rgba(79, 140, 255, 0.12);
}

.rail-row:disabled {
  cursor: default;
  opacity: 0.45;
}

.rail-icon {
  color: #a9c7ff;
  flex: 0 0 26px;
  font-size: 15px;
  text-align: center;
}

.rail-label {
  display: none;
  white-space: nowrap;
}

.map-rail.is-open .rail-label {
  display: inline;
}

.rail-control {
  display: none;
}

.map-rail.is-open .rail-control {
  align-items: center;
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
}

.rail-control select,
.rail-control input {
  background: #0f141b;
  border: 1px solid #2a3040;
  border-radius: 4px;
  color: #d7dee9;
  max-width: 130px;
  padding: 0.2rem 0.3rem;
}

.rail-hint {
  display: none;
  margin: 0.4rem 0.2rem 0;
}

.map-rail.is-open .rail-hint {
  display: block;
}

/* Transparent place-search bar, top-left. */
.map-search-bar {
  align-items: flex-start;
  background: transparent;
  display: flex;
  gap: 0.35rem;
  left: 0.75rem;
  position: absolute;
  top: 0.75rem;
  z-index: 6;
}

.map-search-input {
  backdrop-filter: blur(6px);
  background: rgba(17, 22, 31, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #e3e9f2;
  padding: 0.45rem 0.6rem;
  width: 260px;
}

.map-search-input::placeholder {
  color: rgba(227, 233, 242, 0.6);
}

.map-search-button {
  backdrop-filter: blur(6px);
  background: rgba(17, 22, 31, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #e3e9f2;
  padding: 0.45rem 0.7rem;
}

.map-search-results {
  backdrop-filter: blur(6px);
  background: rgba(17, 22, 31, 0.8);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  left: 0;
  max-height: 260px;
  overflow: auto;
  position: absolute;
  top: 110%;
  width: 300px;
}


/* Route rail footer: autosave state plus save/cancel. */
.rail-footer {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: auto;
  padding-top: 0.4rem;
}

.rail-autosave {
  color: #8a94a6;
  display: none;
  font-size: 10px;
  margin: 0.15rem 0.35rem;
  white-space: nowrap;
}

.map-rail.is-open .rail-autosave {
  display: block;
}

.rail-save .rail-icon {
  color: #44d19d;
}

.rail-cancel .rail-icon {
  color: #ff9b9b;
}

/* Editor dock polish: fieldsets must not draw their default light border, and cards keep a gap. */
.stack.editor fieldset,
.editor-dock fieldset {
  border: 0;
  margin: 0;
  min-width: 0;
  padding: 0;
}

.editor-dock .card + .card,
.stack.editor fieldset > .card + .card {
  margin-top: 1rem;
}

/* Inline parameter help inside the editor dock: static "i" with a left-aligned tooltip. */
.field-label {
  align-items: center;
  display: flex;
  gap: 0.35rem;
  position: relative;
}

.field-label .info,
.card h2 .info {
  height: 14px;
  line-height: 11px;
  position: static;
  width: 14px;
}

.card h2 .info {
  margin-left: 0.4rem;
}

.field-label .info::after,
.card h2 .info::after {
  left: 0;
  right: auto;
  top: 20px;
}

/* Active basemap preset in the rail. */
.rail-row.is-active {
  background: rgba(79, 140, 255, 0.2);
  color: #ffffff;
}


/* Basemap presets: one row below export, separated by a margin. */
.rail-basemap {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.15rem;
  margin-top: 1rem;
  padding-top: 0.6rem;
}

.rail-basemap .rail-row {
  flex: 1 1 0;
  justify-content: center;
  min-width: 0;
  padding: 0.3rem 0.1rem;
}

.map-rail.is-open .rail-basemap .rail-label {
  display: inline;
  font-size: 10px;
}

.map-rail:not(.is-open) .rail-basemap .rail-icon {
  flex-basis: auto;
  font-size: 10px;
}
