:root {
  --bg: #0d1015;
  --surface: #161b22;
  --surface-2: #1e252e;
  --border: #2a323d;
  --text: #e8ecf1;
  --muted: #8b95a3;
  --accent: #f0a32c;
  --accent-strong: #ffb84d;
  --accent-ink: #1a1203;
  --danger: #e5534b;
  --ok: #3fb950;
  --radius: 12px;
  --gap: 12px;
  --header-h: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}

a { color: var(--accent); }

img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  background: rgba(13, 16, 21, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header__title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  text-decoration: none;
}

.header__title span { color: var(--accent); }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }

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

.btn--primary:hover { background: var(--accent-strong); }
.btn--danger { color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--icon { width: 40px; padding: 0; }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn--sm.btn--icon { width: 34px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; color: var(--muted); }

.input, select.input, textarea.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* prevents zoom on iOS */
}

textarea.input { min-height: 110px; resize: vertical; }

.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.checkbox { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--accent); }

.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }
.error-text { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---------- Login ---------- */

.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse at top, rgba(240, 163, 44, .15), transparent 60%),
    var(--bg);
}

.login__card {
  width: 100%;
  max-width: 380px;
  padding: 28px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.login__logo { margin: 0 0 4px; font-size: 26px; text-align: center; }
.login__logo span { color: var(--accent); }
.login__subtitle { margin: 0 0 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Map cards ---------- */

.page-title { margin: 4px 0 16px; font-size: 22px; }

.maps-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
}

@media (min-width: 600px) {
  .maps-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.map-card {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.map-card img, .map-card .placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .25s;
}

.map-card:hover img { transform: scale(1.04); }

.map-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent 55%);
}

.map-card__name {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 1;
  font-weight: 700;
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #222a35, #141920);
  color: var(--muted);
  font-size: 32px;
  font-weight: 700;
}

/* ---------- Map page ---------- */

.map-hero {
  position: relative;
  height: 140px;
  margin: -16px -16px 16px;
  overflow: hidden;
  background: var(--surface-2);
}

.map-hero img { width: 100%; height: 100%; object-fit: cover; }

.map-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg), rgba(13, 16, 21, .2));
}

.map-hero__name {
  position: absolute;
  left: 16px;
  bottom: 12px;
  z-index: 1;
  margin: 0;
  font-size: 28px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

@media (min-width: 760px) {
  .map-hero { margin: 0 0 16px; border-radius: var(--radius); height: 180px; }
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px 16px;
  padding: 0 16px 4px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.tab__count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
  font-size: 12px;
  text-align: center;
}

.tab[aria-selected="true"] .tab__count { background: rgba(0, 0, 0, .15); }

/* ---------- Entries ---------- */

.entries { display: flex; flex-direction: column; gap: 10px; }

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.entry > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.entry > summary::-webkit-details-marker { display: none; }

.entry > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s;
}

.entry[open] > summary::after { transform: rotate(-135deg); }

.entry__kind {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.entry__body { padding: 0 14px 14px; }

.entry__heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entry__title { word-break: break-word; }
.entry__author { font-size: 13px; font-weight: 400; color: var(--muted); }

.entry__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.entry__description { margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; color: #cfd6df; }

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---------- Media ---------- */

.media { margin-bottom: 10px; }

.media__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.media__frame--vertical { aspect-ratio: 9 / 16; max-width: 360px; margin: 0 auto; }
.media__frame--tall { aspect-ratio: 9 / 18; max-width: 360px; margin: 0 auto; background: #fff; }

.media__frame iframe, .media__frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.media__image { border-radius: 10px; margin: 0 auto; max-height: 75vh; }

.media__source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  word-break: break-all;
}

/* ---------- Admin ---------- */

.admin-tabs { margin-bottom: 16px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar .input { flex: 1 1 140px; width: auto; }

.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.row__thumb {
  flex: 0 0 auto;
  width: 64px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
}

.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__actions { display: flex; gap: 4px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 480px) {
  .row { flex-wrap: wrap; }
  .row__actions { width: 100%; justify-content: flex-end; }
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(240, 163, 44, .15);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}

dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: rgba(0, 0, 0, .6); }

.dialog__form { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
.dialog__header { padding: 16px 18px 6px; font-size: 18px; font-weight: 700; }
.dialog__body { padding: 10px 18px; overflow-y: auto; }

.dialog__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
}

.preview { margin-top: 8px; }
.preview img { max-height: 160px; border-radius: 8px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast--show { opacity: 1; transform: translate(-50%, 0); }
.toast--error { border-color: var(--danger); }
.toast--ok { border-color: var(--ok); }

.loader { padding: 40px 0; text-align: center; color: var(--muted); }
