:root {
  --bg: #17132b;
  --bg-soft: #1e1938;
  --surface: #241d44;
  --surface-2: #2c2452;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #efe9fb;
  --muted: #a297c9;
  --mint: #6fe3c4;
  --rose: #ff9ec4;
  --amber: #ffc978;
  --danger: #ff7b7b;
  --radius: 18px;
  --tap: 46px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-ui: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Unbounded", var(--font-ui);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60vw 40vh at 10% -5%, rgba(111, 227, 196, .13), transparent 70%),
    radial-gradient(55vw 38vh at 95% 0%, rgba(255, 158, 196, .14), transparent 70%);
}

.app { position: relative; z-index: 1; min-height: 100dvh; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--mint); }

/* ---------- каркас ---------- */
.screen { padding: 14px 16px calc(96px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

.topline {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 10px 2px 16px;
}
.topline h1 {
  font-family: var(--font-display); font-weight: 600; font-size: 22px;
  letter-spacing: -.01em; margin: 0;
}
.topline .sub { color: var(--muted); font-size: 13px; }

/* ---------- нижняя навигация ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + var(--safe-b));
  background: rgba(23, 19, 43, .86);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 0 5px; color: var(--muted); text-decoration: none;
  font-size: 11px; border-radius: 12px; position: relative;
}
.tabbar a.active { color: var(--text); }
.tabbar a.active::before {
  content: ""; position: absolute; top: 0; width: 22px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--mint), var(--rose));
}
.tabbar svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tabbar .dot {
  position: absolute; top: 5px; right: calc(50% - 18px);
  width: 7px; height: 7px; border-radius: 50%; background: var(--rose);
}

/* ---------- главная ---------- */
.hero {
  border-radius: 26px; padding: 20px;
  background: linear-gradient(155deg, rgba(111,227,196,.16), rgba(255,158,196,.16));
  border: 1px solid var(--line-strong);
}
.hero .days { font-family: var(--font-display); font-size: 40px; line-height: 1; letter-spacing: -.03em; }
.hero .days small { font-family: var(--font-ui); font-size: 14px; color: var(--muted); letter-spacing: 0; }
.hero .next { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.hero .next-title { font-size: 17px; font-weight: 500; }
.hero .countdown { color: var(--amber); font-size: 13px; }

.quickgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }
.quick {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.quick b { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.quick span { color: var(--muted); font-size: 13px; }

/* ---------- списки ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 8px; font-size: 14px; color: var(--muted);
}

.list { display: flex; flex-direction: column; }
.row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 2px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.row.done .title { text-decoration: line-through; color: var(--muted); }

.who {
  width: 4px; align-self: stretch; min-height: 34px; border-radius: 3px; flex: none;
  background: var(--mint);
}
.who.rose { background: var(--rose); }
.who.both { background: linear-gradient(180deg, var(--mint), var(--rose)); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line-strong); color: var(--muted);
}
.chip.mint { color: var(--mint); border-color: rgba(111,227,196,.4); }
.chip.rose { color: var(--rose); border-color: rgba(255,158,196,.4); }
.chip.amber { color: var(--amber); border-color: rgba(255,201,120,.4); }

.iconbtn {
  width: var(--tap); height: var(--tap); flex: none;
  display: grid; place-items: center; border-radius: 14px; color: var(--muted);
}
.iconbtn:active { background: var(--surface-2); }
.iconbtn.on { color: var(--rose); }
.iconbtn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.iconbtn.on svg.fillable { fill: currentColor; }

/* фильтры */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  white-space: nowrap; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted); font-size: 14px;
}
.filters button.active { color: var(--bg); background: var(--text); border-color: transparent; font-weight: 500; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line-strong); font-weight: 500;
}
.btn.primary { background: linear-gradient(120deg, var(--mint), var(--rose)); color: #1a1233; border: none; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255,123,123,.35); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }

.fab {
  position: fixed; right: 16px; bottom: calc(78px + var(--safe-b)); z-index: 45;
  width: 56px; height: 56px; border-radius: 20px;
  background: linear-gradient(135deg, var(--mint), var(--rose));
  color: #1a1233; display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.2; fill: none; }

/* ---------- шторка / формы ---------- */
.sheet-bg {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 8, 22, .6);
  backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--line-strong); border-bottom: none;
  border-radius: 26px 26px 0 0; padding: 8px 18px calc(22px + var(--safe-b));
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(18px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 6px auto 14px; }
.sheet h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin: 0 0 14px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: var(--tap); padding: 11px 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  outline: none; appearance: none;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--mint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.segment { display: grid; grid-auto-flow: column; gap: 6px; background: var(--surface); padding: 4px; border-radius: 14px; }
.segment button { padding: 10px 6px; border-radius: 11px; color: var(--muted); font-size: 14px; }
.segment button.active { background: var(--surface-2); color: var(--text); }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

/* ---------- лента ---------- */
.note {
  padding: 13px 15px; border-radius: 18px; margin-bottom: 10px; max-width: 88%;
  background: var(--surface); border: 1px solid var(--line);
}
.note.mine { margin-left: auto; background: linear-gradient(140deg, rgba(111,227,196,.18), rgba(111,227,196,.06)); }
.note .who-line { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.note .txt { overflow-wrap: anywhere; white-space: pre-wrap; }
.note.thanks { border-color: rgba(255,201,120,.4); }

/* ---------- карта ---------- */
#map { height: 240px; border-radius: 20px; border: 1px solid var(--line-strong); margin-bottom: 6px; }
.leaflet-container { background: var(--bg-soft); font-family: var(--font-ui); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }

/* Тайлы OpenStreetMap светлые — притемняем их под интерфейс.
   Фильтр применяется только к подложке, метки и подписи остаются как есть. */
.leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.92) contrast(.92) saturate(.75); }
.leaflet-control-attribution {
  background: rgba(23, 19, 43, .7); color: var(--muted); font-size: 10px; padding: 1px 6px;
}
.leaflet-control-attribution a { color: var(--muted); }

/* ---------- вход ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login h1 { font-family: var(--font-display); font-size: 34px; margin: 0 0 6px; letter-spacing: -.02em; }
.login p { color: var(--muted); margin: 0 0 26px; }

/* ---------- прочее ---------- */
.hint { color: var(--muted); font-size: 13px; line-height: 1.35; }
.empty { text-align: center; color: var(--muted); padding: 34px 20px; }
.empty b { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-b)); z-index: 80;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  padding: 11px 18px; border-radius: 14px; font-size: 14px; max-width: 88vw;
}
.error { color: var(--danger); font-size: 14px; margin-bottom: 10px; }
.spinner { text-align: center; color: var(--muted); padding: 40px; }

:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
