:root {
  --bg: #120a1f;
  --bg2: #1c1030;
  --card: #241540;
  --line: #3a2660;
  --text: #f5eefe;
  --muted: #b3a3cf;
  --pink: #ff3d9a;
  --cyan: #22e3f0;
  --sun: #ffb347;
  --ok: #3ef0a0;
  --danger: #ff5a5a;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 500px at 80% -10%, #ff3d9a22, transparent 60%),
    radial-gradient(900px 400px at -10% 0%, #22e3f022, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  max-width: 960px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: .5px; text-transform: uppercase; font-weight: 800; }
.brand h1 span { color: var(--pink); text-shadow: 0 0 12px #ff3d9a88; }
.tag { margin: 0; font-size: 11px; color: var(--muted); }
.overall { width: 150px; flex-shrink: 0; }
.overall-num { display: flex; justify-content: space-between; align-items: baseline; }
.overall-num b { font-size: 20px; color: var(--cyan); }
.overall-num small { color: var(--muted); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--sun)); transition: width .4s; }

/* Tabs */
.tabs {
  position: sticky; top: 0; z-index: 1000;
  display: flex; gap: 6px; padding: 8px 16px;
  max-width: 960px; margin: 0 auto;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.tabs button {
  flex: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg2); color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink) inset, 0 0 16px #ff3d9a44; }

main { max-width: 960px; margin: 0 auto; padding: 8px 16px 96px; }
.view { display: none; }
.view.active { display: block; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
#search {
  flex: 1 1 220px; min-width: 0; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit;
}
#search:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.toggles { display: flex; gap: 14px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; cursor: pointer; user-select: none; }
.chk input { accent-color: var(--pink); width: 16px; height: 16px; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--c, var(--pink)); background: color-mix(in srgb, var(--c, var(--pink)) 18%, var(--bg2)); }
.chip small { opacity: .7; }
.chips.compact .chip { padding: 5px 10px; font-size: 12px; }

.note {
  margin: 6px 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px;
  background: #ffb34714; border: 1px dashed #ffb34766; color: #ffd9a3;
}

/* List */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--c);
  transition: opacity .2s, transform .1s;
}
.item.done { opacity: .55; }
.item.done .name { text-decoration: line-through; text-decoration-color: var(--ok); }
.check {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--c); background: transparent;
  cursor: pointer; display: grid; place-items: center; color: #120a1f; font-weight: 900; padding: 0;
}
.item.done .check { background: var(--ok); border-color: var(--ok); }
.name { font-weight: 600; }
.meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hintTxt { font-size: 13px; color: #d9cdee; margin-top: 6px; }
.hintTxt.blur { filter: blur(5px); cursor: pointer; user-select: none; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: #22e3f022; color: var(--cyan); margin-left: 6px; vertical-align: middle; }
.icon-btn {
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted);
  border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { color: var(--text); border-color: var(--cyan); }
.actions { display: flex; flex-direction: column; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* Map */
.map-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.map-tools .chips { flex: 1; min-width: 0; }
#map {
  height: calc(100dvh - 230px); min-height: 360px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #0b1c33;
}
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-content b { display: block; margin-bottom: 2px; }
.leaflet-popup-content .meta { margin-bottom: 8px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-bar a { background: var(--card); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--bg2); }
.leaflet-control-attribution { background: #120a1fcc !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--cyan) !important; }
#map.adding { cursor: crosshair; }
.hint { text-align: center; color: var(--sun); margin: 8px 0 0; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.stat h3 { margin: 0 0 6px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.stat h3 .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .num small { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .bar i { background: var(--c); }
.stat.complete { border-color: var(--ok); box-shadow: 0 0 18px #3ef0a033; }
.card { padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.card h2 { margin: 0 0 6px; font-size: 16px; }
.card p { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.legal { font-size: 11px; color: var(--muted); margin-top: 20px; opacity: .8; }

/* Buttons */
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.row.end { justify-content: flex-end; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: linear-gradient(135deg, var(--pink), #c22bd8); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #ff5a5a55; background: transparent; }
.link { background: none; border: 0; color: var(--cyan); font: inherit; text-decoration: underline; cursor: pointer; }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 1100;
  width: 56px; height: 56px; border-radius: 50%; border: 0; font-size: 28px; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--pink), #c22bd8); box-shadow: 0 6px 24px #ff3d9a66;
}

/* Dialog */
dialog {
  border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--text);
  width: min(440px, calc(100vw - 32px)); padding: 18px;
}
dialog::backdrop { background: #05020acc; backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
dialog input, dialog select, dialog textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit;
}
.muted { color: var(--muted); font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 2000; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .overall { width: 104px; }
  .overall-num b { font-size: 17px; }
  .brand h1 { font-size: 15px; }
  .brand img { width: 26px; height: 26px; }
  .tabs button { padding: 9px 4px; font-size: 14px; }
  .item { grid-template-columns: auto 1fr; }
  .actions { grid-column: 2; flex-direction: row; }
  #map { height: calc(100dvh - 210px); }
}
