/* ---------- Цвета и темы ---------- */

:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #F0EDE6;
  --text: #1C1917;
  --muted: #6B6560;
  --border: #E5E0D7;
  --accent: #6366F1;
  --danger: #DC2626;
  --shadow: 0 1px 2px rgb(28 25 23 / .06), 0 6px 18px -6px rgb(28 25 23 / .18);
  --glow: 0;
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --surface: #1E1E22;
    --surface-2: #26262B;
    --text: #F4F4F5;
    --muted: #A1A1AA;
    --border: #303036;
    --accent: #818CF8;
    --danger: #F87171;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    --glow: 1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1E1E22;
  --surface-2: #26262B;
  --text: #F4F4F5;
  --muted: #A1A1AA;
  --border: #303036;
  --accent: #818CF8;
  --danger: #F87171;
  --shadow: 0 1px 2px rgb(0 0 0 / .4);
  --glow: 1;
  color-scheme: dark;
}

/* ---------- База ---------- */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

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

/* ---------- Верхняя панель ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner,
.filters,
.board {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.today-label {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.today-label::first-letter { text-transform: uppercase; }

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 20px;
  transition: transform .15s ease, background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn-sm { width: 36px; height: 36px; font-size: 16px; border-radius: 11px; }

/* Фильтры-категории */

.filters {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.filter .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
}
.filter-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.filter.is-active {
  background: var(--c, var(--text));
  border-color: var(--c, var(--text));
  color: var(--on, var(--bg));
}
.filter.is-active .dot { background: var(--on); }
.filter.is-active .filter-count {
  background: color-mix(in srgb, var(--on, var(--bg)) 22%, transparent);
  color: inherit;
}

/* ---------- Доска ---------- */

.board {
  padding-top: 8px;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

.group { margin-top: 22px; }

.group-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.group-sub { color: var(--muted); font-weight: 700; font-size: 15px; }
.count {
  margin-left: auto;
  align-self: center;
  min-width: 26px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}
.group-overdue .group-title { color: var(--danger); }

.group-done summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
}
.group-done summary::-webkit-details-marker { display: none; }
.group-done summary::before {
  content: "›";
  display: inline-block;
  transition: transform .2s ease;
}
.group-done[open] summary::before { transform: rotate(90deg); }
.clear-done { margin-top: 14px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 16px;
  align-items: start;
}

/* ---------- Карточка-стикер ---------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 14px 16px;
  border-radius: var(--radius);
  background: var(--c);
  color: var(--on);
  box-shadow:
    var(--shadow),
    0 10px 28px -10px color-mix(in srgb, var(--c) calc(var(--glow) * 90%), transparent);
  cursor: pointer;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .2s ease, box-shadow .2s ease, opacity .25s ease;
}
.grid .card:nth-child(3n + 1) { --tilt: -0.7deg; }
.grid .card:nth-child(3n + 2) { --tilt: 0.5deg; }
.grid .card:nth-child(3n) { --tilt: -0.3deg; }

.card:hover { transform: rotate(0deg) translateY(-3px); }

/* Блик сверху — чтобы было похоже на стикер */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgb(255 255 255 / .22), transparent 45%);
  pointer-events: none;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-cat {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .82;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 2.5px solid var(--on);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 18px;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.check svg { stroke-width: 3; }
.check:hover { color: var(--on); }
.check:active { transform: scale(.9); }
.card.is-done .check,
.card.is-completing .check {
  background: var(--on);
  color: var(--c);
}

.badge {
  align-self: flex-start;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--on);
  color: var(--c);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.card-title {
  margin: 0;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.card-note {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  opacity: .88;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

/* Подзадачи на карточке */

.subs {
  position: relative;
  z-index: 1;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sub {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.sub input,
.sub-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.sub-box {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  margin-top: 1px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-radius: 6px;
  color: inherit;
  font-size: 13px;
}
.sub-box svg { opacity: 0; stroke-width: 3.2; }
input:checked + .sub-box { background: currentColor; }
input:checked + .sub-box svg { opacity: 1; stroke: var(--c, var(--surface)); }
input:focus-visible + .sub-box { outline: 3px solid currentColor; outline-offset: 2px; }
.sub.is-done .sub-text { text-decoration: line-through; opacity: .7; }
.sub-more { font-size: 13px; font-weight: 700; opacity: .75; padding-left: 27px; }

/* Значки внизу карточки */

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--on) 18%, transparent);
  font-size: 13px;
  font-weight: 800;
}
.chip svg { font-size: 14px; }

/* Состояния */

.card.is-late { outline: 3px dashed color-mix(in srgb, var(--on) 55%, transparent); outline-offset: -7px; }
.card.is-done { opacity: .55; }
.card.is-done .card-title { text-decoration: line-through; }
.card.is-completing {
  transform: scale(.94) rotate(0deg);
  opacity: 0;
  transition: transform .28s ease, opacity .28s ease;
}

/* Пустое состояние */

.empty {
  display: grid;
  justify-items: center;
  padding: 48px 16px 8px;
  text-align: center;
}
.empty-stickers { position: relative; width: 120px; height: 90px; margin-bottom: 14px; }
.empty-stickers span {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.empty-stickers span:nth-child(1) { left: 0; top: 18px; background: #6366F1; transform: rotate(-10deg); }
.empty-stickers span:nth-child(2) { left: 28px; top: 4px; background: #FB923C; transform: rotate(4deg); }
.empty-stickers span:nth-child(3) { left: 56px; top: 22px; background: #EC4899; transform: rotate(12deg); }
.empty-title { margin: 0; font-size: 20px; font-weight: 900; }
.empty-text { margin: 4px 0 0; color: var(--muted); font-weight: 600; }

/* ---------- Переключатель «Стикеры / Календарь» ---------- */

.view-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.view-switch button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.view-switch button svg { font-size: 18px; }
.view-switch button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

@media (max-width: 640px) {
  .view-label { display: none; }
  .view-switch button { padding: 0 9px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions > .icon-btn { width: 40px; height: 40px; }
  .brand h1 { font-size: 23px; }
}

/* ---------- Календарь ---------- */

.cal {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cal-title {
  margin: 0 auto 0 4px;
  font-size: 22px;
  font-weight: 900;
}
.cal-title span { color: var(--muted); font-weight: 700; }
.cal-head .icon-btn { width: 38px; height: 38px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  touch-action: pan-y;
}

.cal-wd {
  padding: 2px 0 6px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.cal-wd.is-weekend { color: var(--danger); opacity: .8; }

.cal-day {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  min-height: 104px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--bg);
  text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.cal-day:hover { border-color: var(--border); }
.cal-day.is-other { opacity: .42; }
.cal-day.is-selected { border-color: var(--accent); background: var(--surface); }

.cal-num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
}
.cal-day.is-past .cal-num { color: var(--muted); }
.cal-day.is-today .cal-num { background: var(--accent); color: #fff; }

.cal-items { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.cal-item {
  display: block;
  padding: 2px 6px;
  border: 1.5px solid var(--c);
  border-radius: 6px;
  background: var(--c);
  color: var(--on);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Будущий повтор — контурная плашка */
.cal-item.is-projected { background: transparent; color: var(--text); }
.cal-item.is-done { opacity: .45; text-decoration: line-through; }
.cal-item.is-late { box-shadow: 0 0 0 2px var(--danger); }

.cal-more {
  padding-left: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

/* На телефоне вместо названий — цветные точки */
@media (max-width: 640px) {
  .cal { padding: 10px 8px; margin-left: -4px; margin-right: -4px; }
  .cal-title { font-size: 19px; }
  .cal-grid { gap: 2px; }
  .cal-day { min-height: 58px; padding: 4px 2px; align-items: center; border-radius: 10px; }
  .cal-items { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .cal-item {
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
  }
  .cal-item.is-late { box-shadow: 0 0 0 1.5px var(--danger); }
  .cal-more { padding: 0; font-size: 10px; line-height: 8px; }
}

.cal-day-tasks .group-title { flex-wrap: wrap; }

.cal-empty {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 700;
}
.cal-empty p { margin: 0; }

.card.is-projected { opacity: .78; }
.repeat-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-size: 18px;
  opacity: .85;
}

/* ---------- Кнопка «+» ---------- */

.fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(135deg, #6366F1, #EC4899 60%, #FB923C);
  color: #fff;
  font-size: 30px;
  box-shadow: 0 10px 28px -6px rgb(236 72 153 / .55);
  transition: transform .15s ease;
}
.fab svg { stroke-width: 2.6; }
.fab:hover { transform: translateY(-2px) rotate(-4deg); }
.fab:active { transform: scale(.94); }

/* ---------- Окна (редактор, категории) ---------- */

.sheet {
  width: min(560px, 100% - 24px);
  max-height: min(90dvh, 860px);
  padding: 18px 18px 20px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / .45);
  overflow-y: auto;
}
.sheet[open] { animation: sheet-in .22s ease; }
.sheet::backdrop {
  background: rgb(15 15 20 / .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
}

/* На телефоне окно выезжает снизу */
@media (max-width: 560px) {
  .sheet {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  @keyframes sheet-in { from { transform: translateY(100%); } }
}

.sheet form { display: flex; flex-direction: column; gap: 12px; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 900; }

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-size: 16px; /* 16px — чтобы iPhone не увеличивал страницу при вводе */
  font-weight: 600;
  transition: border-color .15s ease;
}
.input:focus { outline: none; border-color: var(--accent); }
.input-title { font-size: 19px; font-weight: 800; }
.input.is-invalid { border-color: var(--danger); }
textarea.input { resize: vertical; min-height: 64px; }
.input-sm { min-height: 38px; padding: 6px 10px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -4px; }
.pill {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 700;
}
.pill:hover { border-color: var(--accent); }

.hint { margin: -6px 0 0; color: var(--muted); font-size: 14px; font-weight: 600; }

.cat-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-option {
  padding: 8px 14px;
  border: 2px solid var(--c);
  border-radius: 12px;
  background: transparent;
  font-weight: 800;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.cat-option.is-selected { background: var(--c); color: var(--on); }

.sub-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sub-list:empty { display: none; }
.sub-edit { display: flex; align-items: center; gap: 8px; }
.sub-check { position: relative; display: grid; place-items: center; cursor: pointer; color: var(--accent); }
.sub-check .sub-box { width: 22px; height: 22px; margin: 0; }
.sub-add { display: flex; gap: 8px; }
.sub-add .icon-btn { width: 44px; height: 44px; flex-shrink: 0; }

.sheet-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.btn {
  min-height: 46px;
  padding: 10px 20px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  font-size: 16px;
  transition: transform .15s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: transparent; color: var(--danger); padding-left: 4px; }
.btn-danger[hidden] { display: none; }
.btn-secondary { background: var(--surface-2); border: 1px solid var(--border); }
.btn-wide { width: 100%; margin-top: 12px; }

/* Список категорий */

.cat-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cat-row {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
}
.cat-row-top { display: flex; align-items: center; gap: 10px; }
.cat-dot { width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.swatch {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: var(--s);
  transition: transform .12s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-selected { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--s); }

/* Настройки */

.settings-title {
  margin: 22px 0 8px;
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.sheet-head + .settings-title { margin-top: 6px; }
.settings-text { margin: 0 0 12px; color: var(--muted); font-weight: 600; font-size: 15px; }
.settings-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.file-btn {
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
  text-align: center;
}
.file-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Экран входа ---------- */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(60% 40% at 15% 10%, color-mix(in srgb, #6366F1 22%, transparent), transparent),
    radial-gradient(50% 40% at 90% 90%, color-mix(in srgb, #FB923C 22%, transparent), transparent),
    var(--bg);
}
.auth[hidden] { display: none; }
.auth-card {
  width: min(420px, 100%);
  padding: 28px 22px 22px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / .35);
  text-align: center;
}
.auth-logo { display: block; margin: 0 auto 10px; border-radius: 16px; }
.auth-card h1 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -0.02em; }
.auth-sub { margin: 4px 0 18px; color: var(--muted); font-weight: 600; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: var(--surface-2);
}
.auth-tabs button {
  height: 40px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.auth-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#auth-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
#auth-form .field[hidden] { display: none; }
#auth-form .btn-primary { margin: 4px 0 0; }
.auth-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-weight: 700;
  font-size: 14px;
}
.auth-hint { margin: 14px 0 0; }
#oauth-block[hidden] { display: none; }
#oauth-block .onboard-or { margin: 16px 0 12px; }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn-google:hover { background: var(--surface-2); }
.btn-google:disabled { opacity: .6; }
.g-logo { width: 20px; height: 20px; stroke: none; }

/* ---------- Вкладки: «Для меня», «Мои», группы ---------- */

.spaces {
  display: flex;
  gap: 6px;
  max-width: 1200px;
  margin: 12px auto 0;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  overflow-x: auto;
  scrollbar-width: none;
  scroll-padding-inline: 16px;
}
.spaces::-webkit-scrollbar { display: none; }
.space {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 7px;
  height: 44px;
  max-width: 220px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.space svg { font-size: 19px; }
.space-emoji { font-size: 18px; line-height: 1; }
.space-label { overflow: hidden; text-overflow: ellipsis; }
.space[aria-pressed="true"] {
  border-color: transparent;
  background: linear-gradient(135deg, var(--g, #6366F1), color-mix(in srgb, var(--g, #6366F1) 55%, #DB2777));
  color: var(--g-on, #fff);
}
.space[data-space="forme"][aria-pressed="true"] { background: linear-gradient(135deg, #F59E0B, #F97316); color: #fff; }
.space[data-space="personal"][aria-pressed="true"] { background: linear-gradient(135deg, #6366F1, #DB2777); color: #fff; }
.space-add {
  justify-content: center;
  width: 44px;
  padding: 0;
  border-style: dashed;
  color: var(--text);
}
.space-count {
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 18%, transparent);
  font-size: 13px;
  line-height: 22px;
}
.space-count:empty { display: none; }

.offline {
  max-width: 1200px;
  margin: 10px auto 0;
  padding: 0 16px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}
.offline[hidden] { display: none; }
.filters[hidden], .fab[hidden] { display: none; }

/* ---------- Аватарки ---------- */

.ava {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--a);
  color: var(--a-on);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}
.ava-sm { width: 24px; height: 24px; font-size: 12px; }
.ava-xs { width: 18px; height: 18px; font-size: 10px; }
.ava-lg { width: 52px; height: 52px; font-size: 22px; }

/* Кто → кому на семейном стикере */
.card-people {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1.5px dashed color-mix(in srgb, var(--on) 30%, transparent);
}
.card-people .ava { box-shadow: 0 0 0 2px var(--on); }
.people-arrow { display: grid; font-size: 14px; opacity: .7; }
.people-to { display: flex; }
.people-to .ava + .ava { margin-left: -6px; }
.people-all { font-size: 13px; font-weight: 800; opacity: .9; }
.people-done {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  font-size: 13px;
  font-weight: 800;
}
.people-done svg { stroke-width: 3; }

.card.is-pending { opacity: .6; pointer-events: none; }
.filter .ava-xs { margin-left: -2px; }

/* Выбор «для кого» */
.rcpt-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.rcpt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 6px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: transparent;
  font-weight: 800;
  font-size: 14px;
  transition: border-color .15s ease, background .15s ease;
}
.rcpt[data-rcpt="all"] { padding-left: 10px; }
.rcpt svg { font-size: 18px; }
.rcpt.is-selected {
  border-color: var(--a, var(--accent));
  background: color-mix(in srgb, var(--a, var(--accent)) 16%, transparent);
}

/* Редактор: только просмотр */
.editor-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.editor-fields:disabled .quick-dates,
.editor-fields:disabled .sub-add,
.editor-fields:disabled [data-sub-remove] { display: none; }
.editor-fields:disabled .input { opacity: .85; }
.readonly-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.readonly-note[hidden] { display: none; }
.readonly-note b { color: var(--text); }
.btn-primary[hidden] { display: none; }

/* Семейная папка: создать или присоединиться */
.onboard {
  display: grid;
  justify-items: center;
  max-width: 460px;
  margin: 28px auto 0;
  padding: 24px 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  text-align: center;
}
.onboard h2 { margin: 0; font-size: 22px; font-weight: 900; }
.onboard p { margin: 6px 0 18px; color: var(--muted); font-weight: 600; }
.onboard-form { display: grid; gap: 8px; width: 100%; }
.onboard-or {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 14px 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}
.onboard-or::before, .onboard-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Настройки: профиль и семья */
.profile { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.profile-main { flex: 1; min-width: 0; }
.profile-email { margin: 4px 0 0; color: var(--muted); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
#profile-colors { margin-bottom: 12px; }
.settings-actions .btn[hidden] { display: none; }
#family-settings { display: flex; flex-direction: column; gap: 12px; }
.members { display: flex; flex-wrap: wrap; gap: 8px; }
.member {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 800;
  font-size: 14px;
}
.invite { display: flex; flex-direction: column; gap: 8px; }
.invite .settings-text { margin: 0; }
.invite .warn { color: var(--danger); font-size: 14px; }
.invite-code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; }

/* ---------- Полоска текущей группы ---------- */

.group-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1200px;
  margin: 10px auto 0;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.group-bar[hidden] { display: none; }
.gb-people {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.gb-people .ava { box-shadow: 0 0 0 2px var(--bg); }
.gb-people .ava + .ava { margin-left: -7px; }
.gb-count {
  margin-left: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill svg { font-size: 16px; }
.pill-danger { color: var(--danger); }

/* ---------- Окно «Группа»: создать / вступить / управлять ---------- */

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack .settings-title { margin: 4px 0 0; }

.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-opt {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 20px;
  transition: transform .12s ease, border-color .12s ease;
}
.emoji-opt:hover { transform: scale(1.08); }
.emoji-opt.is-selected { border-color: var(--accent); background: var(--surface); }

#gd-body { display: flex; flex-direction: column; gap: 10px; }
#gd-body .settings-title { margin: 14px 0 0; }
#gd-body > .settings-title:first-child { margin-top: 4px; }

.gm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.gm-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg);
}
.gm-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gm-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.gm-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-actions .pill { font-size: 13px; padding: 5px 10px; }
.role {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.role-owner { background: color-mix(in srgb, #F59E0B 22%, transparent); color: #B45309; }
.role-admin { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
:root[data-theme="dark"] .role-owner { color: #FBBF24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .role-owner { color: #FBBF24; } }

.btn-danger-solid { background: var(--danger); color: #fff; }

/* «Где» в редакторе */
.where-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.where {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: transparent;
  font-weight: 800;
  font-size: 14px;
}
.where svg { font-size: 16px; }
.where.is-selected {
  border-color: var(--g, var(--accent));
  background: color-mix(in srgb, var(--g, var(--accent)) 15%, transparent);
}
#rcpt-search[hidden] { display: none; }

/* ---------- Всплывающее сообщение ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  box-shadow: 0 12px 30px -8px rgb(0 0 0 / .4);
  transform: translateX(-50%);
}
.toast[hidden] { display: none; }
.toast.is-in { animation: toast-in .22s ease; }
.toast button {
  border: 0;
  background: none;
  color: #FB923C;
  font-weight: 900;
  padding: 0;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card { transform: none !important; }
}
