:root {
  --bg: #1d1a16; --panel: #2a2520; --line: #4a4036; --text: #eee4d3; --muted: #a8998a;
  --accent: #c9a25b; --danger: #b3261e;
  color-scheme: dark;
  font: 15px/1.4 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.credit { font-size: 12px; }

input, textarea, select, button {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
}
textarea { resize: vertical; }
button { cursor: pointer; background: var(--accent); color: #1d1a16; border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); font-weight: normal; }
button.danger { background: transparent; color: #ff8a80; border-color: var(--danger); }
.row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }

/* ---- index ---- */
.index main { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
#upload { display: grid; gap: 10px; }
#upload h2 { margin: 0; }
#maps { list-style: none; padding: 0; display: grid; gap: 8px; }
#maps li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#maps li a { font-size: 17px; overflow-wrap: anywhere; }

/* ---- map page ---- */
.mapview { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
header { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
header > a { text-decoration: none; font-size: 20px; }
#map-name { flex: 1; min-width: 0; font-weight: 600; background: transparent; border-color: transparent; }
#map-name:hover, #map-name:focus { border-color: var(--line); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: #4caf50; }
.dot.off { background: var(--danger); }

#map { flex: 1; background: #111; }
.leaflet-container { font: inherit; }

#panel {
  position: absolute; top: 60px; right: 12px; bottom: 12px; width: 320px; max-width: calc(100vw - 24px);
  z-index: 1000; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.5);
}
#panel > * { flex-shrink: 0; }
#line-opts { display: grid; gap: 10px; }
#presets { justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
#presets button { padding: 3px 10px; }
#f-weight { flex: 1; padding: 0; }
#icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin-top: 8px; }
#icon-grid h4 { grid-column: 1 / -1; margin: 8px 0 0; font-size: 12px; color: var(--muted); text-transform: uppercase; }
#icon-grid .icon { padding: 6px; background: #3a332b; border-color: transparent; aspect-ratio: 1; }
#icon-grid .icon.active { border-color: var(--accent); background: #5a4a33; }
#icon-grid img { width: 100%; height: 100%; display: block; }
#icon-search { width: 100%; }

/* pins */
.pin span {
  display: flex; width: 34px; height: 34px; border-radius: 50%; padding: 6px;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / 0.6);
}
.pin img { width: 100%; height: 100%; }
.pin.selected span { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- login ---- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
#login { display: grid; gap: 12px; width: min(340px, 100%); padding: 28px 24px; text-align: center; }
#login h1 { margin: 0 0 8px; font-size: 22px; }
#login .logo { width: 56px; height: 56px; margin: 0 auto; padding: 10px; border-radius: 50%; background: #8e2c1c; }
.error { color: #ff8a80; margin: 0; min-height: 1.4em; }

/* text labels: span centered on the point; --scale (map zoom) is set on the map container */
.label span {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; line-height: 1.1;
  font-size: calc(var(--size) * var(--scale, 1) * 1px); cursor: pointer;
  text-shadow: 0 0 2px var(--halo), 0 0 4px var(--halo), 0 0 8px var(--halo);
}
.label.fixed span { font-size: calc(var(--size) * 1px); }
.label.selected span { outline: 2px dashed var(--accent); outline-offset: 4px; }
.font-serif, .font-italic, .font-caps { font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif; font-weight: 700; }
.font-italic { font-style: italic; }
.font-sans { font-family: system-ui, sans-serif; font-weight: 700; }
.font-caps { text-transform: uppercase; letter-spacing: 0.3em; }
#text-opts { display: grid; gap: 10px; }
#f-size { flex: 1; padding: 0; }
