:root {
  --bg: #0b0e10;
  --panel: #11161a;
  --panel-2: #161d21;
  --raised: #1c252a;
  --line: #222d33;
  --line-2: #2f3d44;
  --text: #e7ece9;
  --muted: #8a979b;
  --faint: #5d6a6f;
  --accent: #f2b632;
  --accent-ink: #1a1305;
  --danger: #ff5a4e;
  --ok: #5fd38d;
  --warn: #f2b632;
  --map-bg: #080b0d;
  --radius: 10px;
  --topbar: 56px;
  --font-head: 'Rajdhani', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --shadow: 0 16px 48px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-family: var(--font-head); font-weight: 700; letter-spacing: 0.01em; }

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

/* Lucide icons are drawn through a mask so they take the text colour. */
.ico {
  display: inline-block;
  flex: none;
  width: 1.15em;
  height: 1.15em;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

/* ---------- buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--raised);
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #24303a; border-color: #3b4b54; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #ffc54a; }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #1c0605; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn .ico { width: 18px; height: 18px; }

.input {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(242 182 50 / 0.18); }
textarea.input { resize: vertical; min-height: 96px; line-height: 1.5; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus-visible { outline: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
textarea.input[rows='2'] { min-height: 62px; }

/* A row of mutually exclusive choices (custom, never a native select). */
.seg { display: flex; padding: 3px; gap: 3px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); }
.seg-btn {
  flex: 1;
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed='true'] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  border-radius: 10px;
  background: var(--line-2);
  transition: background 0.15s;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar);
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='16' cy='16' r='7' fill='none' stroke='%231a1305' stroke-width='3'/%3E%3Cpath d='M16 4v6M16 22v6M4 16h6M22 16h6' stroke='%231a1305' stroke-width='3'/%3E%3C/svg%3E") center / 22px no-repeat;
}
.brand-name { font-family: var(--font-head); font-size: 20px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.brand-name b { color: var(--accent); font-weight: 700; }

.map-picker .dd-btn { min-width: 150px; }

.topbar-meta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }

.only-mobile { display: none; }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100dvh - var(--topbar));
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 20px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.panel-section { display: grid; gap: 10px; padding-bottom: 14px; }
.panel-section + .panel-section { padding-top: 14px; border-top: 1px solid var(--line); }

.section-label {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.section-head { display: flex; align-items: center; justify-content: space-between; }
.links { display: flex; gap: 6px; color: var(--faint); font-size: 12px; }
.links button, .group-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.links button:hover, .group-toggle:hover { color: var(--accent); }

.search { position: relative; }
.search .input { padding-left: 36px; }
.search .ico { position: absolute; left: 12px; top: 50%; translate: 0 -50%; color: var(--faint); pointer-events: none; }

.results { display: grid; gap: 2px; }
.result {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.result:hover, .result:focus-visible { background: var(--raised); }
.result-title { font-weight: 600; }
.result-sub { color: var(--muted); font-size: 12px; }
.results-empty { padding: 8px; color: var(--muted); }

.filter-group { display: grid; gap: 2px; margin-top: 6px; }
.filter-group-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 4px; }
.filter-group-name { font-weight: 600; font-size: 13px; }

.filter-row {
  display: grid;
  grid-template-columns: 16px 22px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.filter-row:hover { background: var(--raised); }
.filter-row .check {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-2);
  border-radius: 4px;
  color: var(--accent-ink);
}
.filter-row .check .ico { width: 12px; height: 12px; opacity: 0; }
.filter-row[aria-pressed='true'] .check { background: var(--accent); border-color: var(--accent); }
.filter-row[aria-pressed='true'] .check .ico { opacity: 1; }
.filter-row[aria-pressed='false'] .pin, .filter-row[aria-pressed='false'] .filter-name { opacity: 0.4; }
.filter-row .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.filter-row .count.zero { color: var(--faint); }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.link-btn .ico { width: 14px; height: 14px; }
.link-btn:hover { color: #ffc54a; }

.routes { display: grid; gap: 6px; }
.route-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  text-align: left;
}
.route-item:hover { border-color: var(--line-2); background: var(--raised); }
.route-item[aria-pressed='true'] { border-color: var(--accent); background: rgb(242 182 50 / 0.06); }
.route-badge {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--r);
  color: #0b0e10;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bg);
}
.card-head .route-badge { margin-top: 2px; }
.route-text { display: grid; min-width: 0; }
.route-name { font-family: var(--font-head); font-size: 16px; font-weight: 700; line-height: 1.15; }
.route-sub { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.route-group { display: grid; gap: 6px; }
.route-group-head {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.route-group-head:hover { background: var(--raised); }
.route-group-head .ico { width: 16px; height: 16px; color: var(--muted); transition: rotate 0.15s; }
.route-group-head[aria-expanded='true'] .ico { rotate: 90deg; }
.route-group-name { font-weight: 600; font-size: 13px; }
.route-group-head .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.route-group > .routes { padding-left: 12px; }

.legend { display: grid; gap: 6px; margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--panel-2); color: var(--muted); font-size: 12px; }
.legend > span { display: flex; align-items: center; gap: 8px; }
.legend-pin { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.legend-pin.dashed { outline: 1.5px dashed var(--accent); outline-offset: 2px; }

.sidebar-foot { margin: auto 0 0; padding-top: 12px; color: var(--faint); font-size: 12px; }
.sidebar-foot code { color: var(--muted); }

/* ---------- map ---------- */

.map-wrap { position: relative; min-width: 0; overflow: hidden; }

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--map-bg);
  background-image:
    linear-gradient(rgb(255 255 255 / 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  font: inherit;
}
.editing #map { cursor: crosshair; }
.editing #map .leaflet-interactive { cursor: pointer; }
.editing #map .leaflet-marker-draggable { cursor: grab; }

.map-image { border-radius: 4px; box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgb(0 0 0 / 0.6); }

.leaflet-bar { border: 1px solid var(--line-2) !important; border-radius: 8px !important; overflow: hidden; box-shadow: var(--shadow) !important; }
.leaflet-bar a {
  width: 36px !important;
  height: 36px !important;
  line-height: 34px !important;
  border-bottom-color: var(--line-2) !important;
  background: var(--panel) !important;
  color: var(--text) !important;
  font-size: 20px !important;
}
.leaflet-bar a:hover { background: var(--raised) !important; }
.leaflet-bar a.leaflet-disabled { color: var(--faint) !important; }
.leaflet-top.leaflet-left { top: 4px; left: 4px; }

/* Pins */
.pin-wrap { background: none; border: 0; }
.pin {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c);
  color: #0b0e10;
  box-shadow: 0 0 0 2px #0b0e10, 0 3px 8px rgb(0 0 0 / 0.6);
  transition: transform 0.12s ease-out;
}
.pin .ico { width: 16px; height: 16px; }
/* Dashed colour ring outside a solid dark one, so it reads on both dark and light map art. */
.pin.unconfirmed {
  outline: 2px dashed var(--c);
  outline-offset: 2px;
}
.pin.mini { width: 22px; height: 22px; box-shadow: 0 0 0 1.5px #0b0e10; }
.pin.mini .ico { width: 12px; height: 12px; }
.pin.mini.unconfirmed { outline-width: 1.5px; outline-offset: 1.5px; }
#map.zoomed-out .pin:not(.selected):not(.draft) { width: 20px; height: 20px; margin: 5px; box-shadow: 0 0 0 1.5px #0b0e10, 0 2px 5px rgb(0 0 0 / 0.6); }
#map.zoomed-out .pin:not(.selected):not(.draft) .ico { width: 11px; height: 11px; }
#map.zoomed-out .pin.unconfirmed:not(.selected):not(.draft) { outline-width: 1.5px; outline-offset: 1.5px; }
.leaflet-marker-icon:hover .pin { transform: scale(1.12); }
.pin.selected { transform: scale(1.28) !important; box-shadow: 0 0 0 2px #0b0e10, 0 0 0 4.5px #fff, 0 6px 16px rgb(0 0 0 / 0.6); }
.pin.draft { box-shadow: 0 0 0 2px #0b0e10, 0 0 0 4.5px var(--accent), 0 6px 16px rgb(0 0 0 / 0.6); animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* Route stop number, pinned to the marker's top-right corner. */
.pin-num {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--r);
  color: #0b0e10;
  font: 700 11px/18px var(--font-body);
  font-variant-numeric: tabular-nums;
  text-align: center;
  box-shadow: 0 0 0 1.5px #0b0e10;
  pointer-events: none;
}
#map.zoomed-out .pin-num { top: -3px; right: -6px; }
.pin-wrap.dim { opacity: 0.28; }
.pin-wrap.dim:hover { opacity: 0.9; }

.route-line { animation: march 0.9s linear infinite; }
@keyframes march { to { stroke-dashoffset: -18; } }
/* Item finder hit: a pulsing accent halo behind the pin. */
.pin-wrap.found::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: rgb(242 182 50 / 0.2);
  box-shadow: 0 0 0 2px rgb(242 182 50 / 0.9);
  animation: halo 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes halo { from { transform: scale(0.8); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .route-line, .pin.draft, .pin-wrap.found::before { animation: none; }
}

.pin-label.leaflet-tooltip {
  padding: 3px 9px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.5);
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pin-label.leaflet-tooltip-top::before { border-top-color: var(--line-2); }

.edit-banner {
  position: absolute;
  top: 12px;
  left: 56px;
  z-index: 10;
  max-width: calc(100% - 68px);
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.empty-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  translate: -50% 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.empty-hint.plain { padding-right: 16px; }

/* ---------- detail card ---------- */

.card {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 360px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.card-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.card-head .pin { margin-top: 2px; }
.card-kicker { font-family: var(--font-head); font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.card-title { font-size: 24px; line-height: 1.1; overflow-wrap: anywhere; }
.card-head .icon-btn { margin: -6px -6px 0 0; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge .ico { width: 13px; height: 13px; }
.badge.ok { background: rgb(95 211 141 / 0.13); color: var(--ok); }
.badge.warn { background: rgb(242 182 50 / 0.13); color: var(--warn); }
.badge.spawn { background: var(--raised); color: var(--text); padding-left: 9px; }
.badge.spawn::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.badge.spawn.always { --dot: var(--ok); }
.badge.spawn.random { --dot: var(--warn); }

/* Floor, key and similar one-line facts under a spot's badges. */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; }
.facts dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.facts dd { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts .ico { width: 14px; height: 14px; color: var(--accent); flex: none; }

.source-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.source-list a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.source-list a:hover { border-color: var(--accent); color: var(--accent); }
.source-list .ico { width: 12px; height: 12px; }

.card-image { display: block; margin-top: 14px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.card-image img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.card-desc { margin: 14px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-desc a { color: var(--accent); text-decoration: underline; text-decoration-color: rgb(242 182 50 / 0.4); text-underline-offset: 2px; }
.card-desc a:hover { text-decoration-color: currentColor; }
.badges-date { margin-left: auto; align-self: center; }
.card-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.card-foot .share-btn { margin-left: auto; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -2px 0 10px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.back-link:hover { color: var(--accent); }

.card-kicker.accent { color: var(--accent); }
.card-section { display: grid; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.card-section .stops, .card-section .card-desc { margin: 0; }
.card-section-title {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Item pictures sit on a dark tile so transparent game icons read on any background. */
.item-thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 35%, #26323a, #12181c);
  object-fit: contain;
}
.item-thumb.small { width: 30px; height: 30px; border-radius: 7px; }
.item-thumb.large { width: 52px; height: 52px; border-radius: 12px; }
.item-thumb.tiny { width: 24px; height: 24px; border-radius: 6px; }
.item-thumb.route-thumb { border: 2px solid var(--r); }
.item-thumb.fallback { color: var(--muted); }
.item-thumb.fallback .ico { width: 55%; height: 55%; }
.item-thumb.kind-ingredient { color: #7fd1c7; }
.item-thumb.kind-valuable { color: var(--accent); }
.item-thumb.kind-commander { color: #ff8a7a; }
.item-thumb.kind-resource { color: #9fb3bd; }

.item-list, .needs { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.item-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.item-row:hover, .item-row:focus-visible { background: var(--raised); }
.item-text { display: grid; min-width: 0; }
.item-name { font-weight: 600; }
.item-note { color: #c4ccc8; font-size: 12px; line-height: 1.35; }
.item-go { width: 15px; height: 15px; color: var(--faint); }
.item-row:hover .item-go, .need:hover .item-go { color: var(--accent); }

.need {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.need:not(:disabled):hover { background: var(--raised); }
.need:disabled { cursor: default; color: var(--muted); }
.need-qty { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.need-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.needs-label { margin: 10px 0 2px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

.item-picker { display: flex; gap: 6px; align-items: center; }
.item-picker .dd-btn { flex: 1; min-width: 0; }
.item-picker .dd-value > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-placeholder { color: var(--faint); font-weight: 500; }
.dd-count { margin-left: auto; padding-left: 10px; color: var(--muted); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.dd-value .dd-count { display: none; }

.stops { display: grid; gap: 2px; margin: 14px 0 0; padding: 0; list-style: none; }
.card-form .stops { margin: 0; }
.stop { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.stop-num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--r);
  color: #0b0e10;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stop-main {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 5px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
}
.stop-main:hover { background: var(--raised); }
.stop-main > span:last-child { display: grid; min-width: 0; }
.stop-title { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.stop-sub { color: var(--muted); font-size: 12px; }
.stop-note { color: #c4ccc8; font-size: 12px; line-height: 1.35; }
.stop-note-input { grid-column: 2 / -1; min-height: 32px; padding: 0 10px; font-size: 12px; }
.stops.editable { gap: 8px; }
.stop-tools { display: flex; }
.stop-tools .icon-btn { width: 28px; height: 28px; }
.stop-tools .icon-btn .ico { width: 15px; height: 15px; }
.stop-tools .icon-btn:disabled { opacity: 0.25; background: none; cursor: default; }
/* Guide routes: a walk-through under each stop, written from a creator's video. */
.guide-source {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raised);
  font-size: 13px;
}
.guide-source > .ico { width: 16px; height: 16px; color: var(--accent); }
.guide-source > span { flex: 1; min-width: 0; }
.guide-source a:not(.btn) { color: var(--accent); font-weight: 600; }
.guide-source .btn, .guide-at { text-decoration: none; }
.stops.guide { gap: 18px; }
.stops.guide .stop { align-items: start; }
.stops.guide .stop-num { margin-top: 9px; }
.guide-step { display: grid; gap: 10px; grid-column: 2 / -1; padding: 2px 8px 0; }
.guide-at { display: inline-flex; align-items: center; gap: 5px; justify-self: start; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.guide-at .ico { width: 12px; height: 12px; }
.guide-at:hover { color: var(--accent); }
.guide-stills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.guide-still { padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #000; overflow: hidden; cursor: zoom-in; }
.guide-still img { display: block; width: 100%; aspect-ratio: 6 / 5; object-fit: cover; }
.guide-still:hover { border-color: var(--accent); }
.guide-text { display: grid; gap: 8px; color: #d9dfdc; font-size: 13px; line-height: 1.5; }
.guide-text p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.guide-text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.stop-guide-input { grid-column: 2 / -1; padding: 8px 10px; font-size: 12px; line-height: 1.45; resize: vertical; }
.still-full { display: block; max-width: 100%; max-height: 78vh; margin: 0 auto; border-radius: 8px; }
.stops-empty { padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 8px; color: var(--muted); font-size: 13px; }

.card-form { display: grid; gap: 14px; }
.card-form h2 { font-size: 22px; }
.form-head { display: flex; justify-content: space-between; align-items: center; }
.form-hint { margin: -4px 0 0; color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

.image-field { display: flex; align-items: center; gap: 10px; }
.image-field img { width: 72px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); }

/* ---------- dropdown & popover ---------- */

.dd-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 6px 10px 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg);
  text-align: left;
}
.dd-btn:hover { border-color: #3b4b54; }
.dd-btn[aria-expanded='true'] { border-color: var(--accent); }
.dd-value { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; font-weight: 600; }
.dd-value > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-caret { color: var(--muted); }

.popover {
  position: fixed;
  z-index: 2000;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.dd-list, .menu { display: grid; gap: 1px; }
.dd-group { padding: 8px 8px 4px; color: var(--faint); font-family: var(--font-head); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.dd-item, .menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 5px 10px 5px 8px;
  border: 0;
  border-radius: 7px;
  background: none;
  text-align: left;
  white-space: nowrap;
}
.dd-item:hover, .dd-item:focus, .menu-item:hover, .menu-item:focus { background: var(--raised); outline: none; }
.dd-item[aria-selected='true'] { color: var(--accent); }
.dd-check { margin-left: auto; padding-left: 12px; }
.menu-item .ico { color: var(--muted); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ico { color: var(--danger); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--line); }

/* ---------- modal ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(4 6 7 / 0.7);
  backdrop-filter: blur(3px);
}
.modal {
  width: min(460px, 100%);
  max-height: min(86dvh, 760px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.modal.wide { width: min(640px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 22px; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-actions.start { justify-content: flex-start; }
.stack { display: grid; gap: 14px; }

.settings-section { display: grid; gap: 10px; padding: 16px 0; }
.settings-section:first-child { padding-top: 0; }
.settings-section + .settings-section { border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }

.map-preview {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
}
.map-preview img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line-2); background: var(--map-bg); }

.cat-group { display: grid; gap: 2px; margin-top: 14px; }
.cat-row {
  display: grid;
  grid-template-columns: 22px 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 3px 4px 3px 8px;
  border-radius: 8px;
}
.cat-row:hover { background: var(--panel-2); }
.cat-row .count { color: var(--muted); font-size: 12px; min-width: 52px; text-align: right; }
.cat-row .icon-btn { width: 32px; height: 32px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.chip:hover, .chip[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 28px;
  height: 28px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line-2);
}
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--text); }
.swatch-custom { position: relative; display: grid; place-items: center; overflow: hidden; background: conic-gradient(#ff4d3d, #f2b632, #5fd38d, #4fb4e8, #a78bfa, #ff4d3d); }
.swatch-custom input { position: absolute; inset: -8px; opacity: 0; cursor: pointer; }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.icon-choice {
  display: grid;
  place-items: center;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
}
.icon-choice:hover { color: var(--text); border-color: #3b4b54; }
.icon-choice[aria-pressed='true'] { border-color: var(--accent); color: var(--accent); background: rgb(242 182 50 / 0.08); }
.icon-choice .ico { width: 18px; height: 18px; }

.preview-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: var(--panel-2); font-weight: 600; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  translate: -50% 0;
  z-index: 3000;
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--raised);
  box-shadow: var(--shadow);
  font-weight: 600;
  transition: opacity 0.3s, translate 0.3s;
}
.toast.ok { border-color: rgb(95 211 141 / 0.5); }
.toast.error { border-color: rgb(255 90 78 / 0.6); color: #ffb3ad; }
.toast.out { opacity: 0; translate: 0 6px; }

.fatal { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; color: var(--muted); }

/* ---------- small screens ---------- */

/* Mid widths: the banner and the card would collide, and the card already shows edit controls. */
@media (min-width: 821px) and (max-width: 1240px) {
  .map-wrap:has(.card:not([hidden])) .edit-banner { display: none !important; }
}
.map-wrap:has(.card:not([hidden])) .edit-banner { max-width: calc(100% - 56px - 384px); }

@media (max-width: 820px) {
  .only-mobile { display: inline-grid; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar-meta { display: none; }
  .map-picker .dd-btn { min-width: 0; max-width: 150px; }
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: var(--topbar);
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(320px, 88vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: var(--topbar) 0 0; z-index: 25; background: rgb(4 6 7 / 0.55); }

  .card {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 60%;
  }
  .edit-banner,
  .map-wrap:has(.card:not([hidden])) .edit-banner { top: 10px; left: 56px; right: 10px; max-width: none; font-size: 12px; padding: 6px 12px; }
}

@media (max-width: 480px) {
  .brand-name { display: none; }
  #edit-toggle .label-long { display: none; }
}
