: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(6, 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: 10.5px; 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: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tabbar .badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--rose); color: #1a1233; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

/* ---------- главная ---------- */
.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 { display: block; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.hero a.next { text-decoration: none; color: inherit; }
.hero a.next:active { opacity: .7; }
.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; position: relative;
  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; }
.iconbtn .badge {
  position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--rose); color: #1a1233; font-size: 9px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

/* фильтры */
.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; }

/* панель фильтра над списком: короткий переключатель + кнопка «Фильтр» */
.filterbar { display: flex; gap: 8px; align-items: stretch; margin: 2px 0 4px; }
.filterbar .segment { flex: 1; min-width: 0; }
.filter-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px; position: relative;
  padding: 0 14px; border-radius: 14px; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted);
}
.filter-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.filter-btn.on { color: var(--text); }
.filter-btn .fdot {
  position: absolute; top: 5px; right: 6px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--rose);
}

/* наборы пилюль в шторке фильтра */
.pillset { display: flex; flex-wrap: wrap; gap: 6px; }
.pillset button {
  padding: 8px 13px; border-radius: 999px; font-size: 14px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.pillset button.active { background: var(--text); color: var(--bg); border-color: transparent; font-weight: 500; }

/* «↻ ещё N повторов» под ближайшим повтором в календаре */
.repeat-toggle {
  display: block; margin: 2px 0 8px; padding: 4px 2px;
  color: var(--muted); font-size: 13px; text-align: left;
}
.repeat-toggle:active { color: var(--text); }

/* календарь: режим «Месяц» */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin: 8px 2px 10px; }
.cal-nav span { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.cal-nav button { width: 40px; height: 40px; border-radius: 12px; color: var(--muted); font-size: 22px; }
.cal-nav button:active { background: var(--surface-2); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 4px; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 12px; padding: 5px 0 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.cal-cell.empty { background: transparent; border: none; }
.cal-cell.today { border-color: var(--mint); }
.cal-cell.sel { background: var(--surface-2); border-color: var(--line-strong); }
.cal-day { font-size: 13px; line-height: 1; }
.cal-dots { display: flex; gap: 2px; min-height: 5px; flex-wrap: wrap; justify-content: center; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--mint); }
.cal-dot.rose { background: var(--rose); }
.cal-dot.both { background: linear-gradient(90deg, var(--mint), var(--rose)); }
.cal-dot.done { opacity: .35; }
.cal-add { font-size: 13px; color: var(--mint); }

/* ---------- кнопки ---------- */
.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:not([type="checkbox"]), .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 input[type="checkbox"] {
  appearance: none; width: 24px; height: 24px; flex: none; margin: 0;
  border: 1.5px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  display: grid; place-content: center; cursor: pointer;
}
.field input[type="checkbox"]::after {
  content: ""; width: 11px; height: 6px; border: 2px solid var(--bg); border-top: none;
  border-right: none; transform: rotate(-45deg) translate(1px, -1px); opacity: 0;
}
.field input[type="checkbox"]:checked {
  background: var(--mint); border-color: var(--mint);
}
.field input[type="checkbox"]:checked::after { opacity: 1; }
.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; white-space: nowrap; }
.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); }

/* отметка прочтения у своих сообщений (лента и обсуждение хотелки) */
.rr { color: var(--muted); }
.rr.seen { color: var(--mint); }

/* обсуждение внутри шторки хотелки */
.chat { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; padding-right: 2px; }
.chat .empty { padding: 18px 6px; }

/* ---------- карта ---------- */
#map:focus, .leaflet-container:focus { outline: none; }
#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); }

/* ---------- фотографии ---------- */
.photos { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.photos::-webkit-scrollbar { display: none; }
.photos img, .photos .add {
  width: 76px; height: 76px; flex: none; border-radius: 14px; object-fit: cover;
  border: 1px solid var(--line); background: var(--surface);
}
.photos .add { display: grid; place-items: center; color: var(--muted); font-size: 24px; }
.photo-wrap { position: relative; flex: none; }
.photo-wrap button {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text); font-size: 13px;
  display: grid; place-items: center;
}
.thumb {
  width: 46px; height: 46px; border-radius: 12px; object-fit: cover; flex: none;
  border: 1px solid var(--line);
}
.thumb.poster { width: 42px; height: 62px; border-radius: 8px; }
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(8, 6, 18, .92);
  display: grid; place-items: center; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 90dvh; border-radius: 16px; }

/* ---------- вход ---------- */
.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; }
