/* «Семейный календарь» — каркас интерфейса (этап 4).
   Без внешних шрифтов, картинок и библиотек. Одна колонка под телефон
   360×712 CSS-пикселей. Тёмная тема — по умолчанию (решение владельца),
   светлая — атрибутом data-theme="light" на <html>. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* ---------- палитра ----------
   Тёмная тема — значения по умолчанию. Светлая включается атрибутом
   html[data-theme="light"]. Роли одинаковые, вёрстка одна. */

:root {
  color-scheme: dark;

  --page-bg: #070a10;
  --app-bg: #0f141d;
  --surface: #151b26;
  --surface-2: #1a2230;
  --surface-3: #202a3a;

  --border: #26303f;
  --border-soft: #1e2734;

  --text: #e8edf6;
  --text-secondary: #c2ccdb;
  --text-muted: #93a0b7;
  --text-faint: #6c7a93;

  --accent: #5b9bff;
  --accent-strong: #2f66d0;
  --accent-wash: rgba(91, 155, 255, 0.12);
  --on-accent: #ffffff;

  --overlay: rgba(0, 0, 0, 0.62);
  --shadow-app: 0 18px 60px rgba(0, 0, 0, 0.55);
  --shadow-sheet: 0 -12px 40px rgba(0, 0, 0, 0.45);
  --toast-bg: rgba(42, 53, 71, 0.97);

  --danger: #ef7b7b;
  --danger-strong: #c94545;
  --danger-wash: rgba(201, 69, 69, 0.14);

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
}

html[data-theme="light"] {
  color-scheme: light;

  --page-bg: #e7ebf3;
  --app-bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --surface-3: #e7ecf5;

  --border: #dde3ee;
  --border-soft: #e8edf5;

  --text: #1c2433;
  --text-secondary: #344054;
  --text-muted: #667085;
  --text-faint: #98a2b3;

  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-wash: rgba(37, 99, 235, 0.08);
  --on-accent: #ffffff;

  --overlay: rgba(15, 23, 42, 0.46);
  --shadow-app: 0 18px 60px rgba(16, 24, 40, 0.16);
  --shadow-sheet: 0 -12px 40px rgba(16, 24, 40, 0.22);
  --toast-bg: rgba(28, 36, 51, 0.95);

  --danger: #c0392b;
  --danger-strong: #b3261e;
  --danger-wash: rgba(179, 38, 30, 0.1);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- каркас приложения ---------- */

.app {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  position: relative;
  background: var(--app-bg);
}

@media (min-width: 540px) {
  .app {
    height: calc(100% - 40px);
    margin: 20px auto;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-app);
  }
}

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

.appbar {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 8px;
  background: var(--app-bg);
}

.space-btn {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  max-width: 62%;
  padding: 4px 8px 4px 2px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
}

.space-btn:active {
  background: var(--surface-2);
}

.space-name {
  overflow: hidden;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chev {
  width: 18px;
  height: 18px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  color: var(--text-faint);
}

.appbar-tools {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 4px;
}

.icon-btn {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
}

.icon-btn:active {
  background: var(--surface-2);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

/* В тёмной теме показываем «солнце» (переход на светлую), в светлой — «луну». */
.i-moon,
.i-sun {
  display: none;
}

html[data-theme="dark"] .i-sun,
html:not([data-theme="light"]) .i-sun {
  display: block;
}

html[data-theme="light"] .i-moon {
  display: block;
}

/* ---------- панель периода и вид ---------- */

.toolbar {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  padding: 2px 12px 6px;
}

.period {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  gap: 6px;
}

.period-arrow {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
}

.period-label {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.period-label:active {
  background: var(--surface-2);
}

.segmented {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 3px;
  margin-top: 6px;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
}

.segmented button {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0px;
  flex: 1 1 0;
  min-height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

.segmented button[aria-selected="true"] {
  background: var(--accent-strong);
  color: var(--on-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

html[data-theme="light"] .segmented button[aria-selected="true"] {
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.18);
}

/* ---------- галочки людей ---------- */

.people-bar {
  -webkit-box-flex: 0;
  -ms-flex: 0 0 auto;
  flex: 0 0 auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 8px;
  padding: 8px 12px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.people-bar::-webkit-scrollbar {
  display: none;
}

.chip {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 7px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 13px 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.chip:active {
  background: var(--surface-2);
}

.chip-dot {
  width: 12px;
  height: 12px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text-faint);
}

.chip.is-on {
  border-color: transparent;
  background: var(--surface-3);
  color: var(--text);
}

.chip.is-off {
  opacity: 0.5;
}

.chip.is-off .chip-dot {
  box-shadow: inset 0 0 0 2px var(--surface);
}

/* Галочка внутри цветной точки: показать «включён». */
.chip.is-on .chip-dot {
  position: relative;
}

.chip.is-on .chip-dot::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
}

.chip-all .chip-dot {
  background: var(--accent);
}

/* ---------- область календаря ---------- */

.view-area {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  min-height: 0;
  padding: 2px 12px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.calendar {
  height: 100%;
}

/* ---------- месяц ---------- */

.month {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 6px;
  height: 100%;
}

.month-head,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.month-head {
  padding: 2px 0;
}

.weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.weekday.is-weekend {
  color: var(--text-muted);
}

.month-grid {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  grid-auto-rows: 1fr;
  row-gap: 2px;
}

.month-cell {
  position: relative;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 4px;
  min-height: 50px;
  padding: 5px 1px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.month-cell:active {
  background: var(--surface-2);
}

.month-num {
  display: block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: 50%;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.month-cell.is-out .month-num {
  color: var(--text-faint);
}

.month-cell.is-out .month-dots {
  opacity: 0.6;
}

.month-cell.is-today .month-num {
  background: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 700;
}

.month-dots {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 3px;
  height: 7px;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.dot {
  display: block;
  width: 7px;
  height: 7px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  border-radius: 50%;
}

.dot.is-private {
  background: transparent;
  border: 1.5px solid var(--text-faint);
}

/* ---------- неделя ---------- */

.week {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 12px;
}

.week-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.week-col {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 5px;
  min-height: 96px;
  padding: 8px 2px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}

.week-col:active {
  background: var(--surface-2);
}

.week-col.is-selected {
  border-color: var(--accent);
  background: var(--accent-wash);
}

.week-day {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.week-date {
  display: block;
  width: 26px;
  height: 26px;
  line-height: 26px;
  border-radius: 50%;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.week-col.is-today .week-date {
  background: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 700;
}

.week-dots {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 3px;
  min-height: 24px;
}

.week-dots .dot {
  width: 6px;
  height: 6px;
}

.week-agenda {
  padding-top: 2px;
}

.agenda-head {
  margin: 0 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---------- список событий ---------- */

.agenda-list {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 8px;
}

.agenda-item {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: stretch;
  -ms-flex-align: stretch;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 9px 12px 9px 10px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.agenda-item:active {
  background: var(--surface-2);
}

.agenda-item.is-private {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}

.agenda-bar {
  width: 4px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  border-radius: 2px;
}

.agenda-time {
  -ms-flex-negative: 0;
  flex-shrink: 0;
  width: 52px;
  padding-top: 1px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.agenda-time.is-allday {
  padding-top: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.agenda-main {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
}

.agenda-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.agenda-meta {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.badge-private {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.35;
}

/* ---------- пустой день ---------- */

.cal-empty {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  min-height: 44vh;
  padding: 28px 20px;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-lg);
  text-align: center;
}

.week-agenda .cal-empty {
  min-height: 180px;
}

.cal-empty-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  color: var(--text-faint);
}

.cal-empty-icon svg {
  width: 40px;
  height: 40px;
}

.cal-empty-text {
  max-width: 240px;
  font-size: 14px;
  color: var(--text-muted);
}

/* ---------- подробности события ---------- */

.event-sheet {
  padding: 2px 4px 6px;
}

.event-title {
  margin: 2px 6px 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.event-badges {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 6px;
  margin: 0 6px 12px;
}

.event-badge {
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
}

.event-badge-common {
  background: var(--accent-wash);
  color: var(--accent);
}

.event-badge-private {
  background: var(--surface-3);
  color: var(--text-secondary);
}

.detail-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: start;
  -ms-flex-align: start;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 6px;
  border-top: 1px solid var(--border-soft);
  font-size: 14.5px;
}

.detail-label {
  -ms-flex-negative: 0;
  flex-shrink: 0;
  width: 74px;
  padding-top: 1px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.detail-value {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-secondary);
  line-height: 1.45;
}

.detail-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
  vertical-align: 1px;
}

.event-note {
  margin: 10px 6px 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

/* ---------- затемнение и нижняя панель ---------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  -webkit-animation: fade-in 0.16s ease;
  animation: fade-in 0.16s ease;
}

.sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: 94%;
  margin: 0 auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-sheet);
  -webkit-animation: sheet-in 0.2s ease;
  animation: sheet-in 0.2s ease;
}

.sheet-head {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  padding: 14px 8px 10px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.sheet-title {
  font-size: 17px;
  font-weight: 700;
}

.sheet-body {
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-section {
  margin: 12px 6px 6px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  font-size: 15px;
}

.row:active {
  background: var(--surface-2);
}

.row-main {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.row-dot {
  width: 14px;
  height: 14px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  border-radius: 50%;
}

.row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-note {
  color: var(--text-faint);
  font-size: 13px;
}

.row-check {
  width: 22px;
  height: 22px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  color: var(--accent);
}

.row.is-active {
  background: var(--accent-wash);
}

.row.is-active .row-name {
  font-weight: 700;
}

.switch {
  position: relative;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  border-radius: 99px;
  background: var(--surface-3);
  -webkit-transition: background 0.15s ease;
  transition: background 0.15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  -webkit-transition: -webkit-transform 0.15s ease;
  transition: transform 0.15s ease;
}

.row[aria-pressed="true"] .switch {
  background: var(--accent-strong);
}

.row[aria-pressed="true"] .switch::after {
  -webkit-transform: translateX(18px);
  transform: translateX(18px);
}

.divider {
  height: 1px;
  margin: 8px 6px;
  background: var(--border-soft);
}

.sheet-about {
  padding: 14px 8px 4px;
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
}

/* ---------- кнопка «плюс» ---------- */

.fab {
  position: absolute;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-strong);
  color: var(--on-accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
}

.fab:active {
  -webkit-transform: scale(0.95);
  transform: scale(0.95);
}

.fab svg {
  width: 26px;
  height: 26px;
}

/* ---------- форма задачи ---------- */

.form {
  padding: 2px 2px 6px;
}

.field {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 8px 0;
}

.field-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 10px;
}

.field-row .field {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0;
  flex: 1 1 0;
  margin: 0;
}

.field-label {
  padding-left: 4px;
  color: var(--text-faint);
  font-size: 12.5px;
  font-weight: 600;
}

.field-hint {
  padding-left: 4px;
  color: var(--text-faint);
  font-size: 12px;
}

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
}

.input:focus {
  border-color: var(--accent);
  outline: none;
}

.input-area {
  min-height: 62px;
  resize: none;
}

.choice-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.choice-row .choice {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0;
  flex: 1 1 0;
  min-width: 0;
}

.choice {
  min-height: 42px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.choice.is-on {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--on-accent);
}

.choice-days {
  gap: 4px;
}

.choice-days .choice-day {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0;
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
  min-height: 40px;
  font-size: 13px;
}

.switch-field {
  margin: 4px 0;
}

.row-text {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.form-actions {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* В форме задачи кнопка сохранения прилипает к низу панели: длинную
   форму можно пролистать, а «Сохранить» всё время под рукой. */
.form > .form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 16px -12px 0;
  padding: 8px 12px 4px;
  background: var(--surface);
}

.form-actions.row2 {
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  -ms-flex-direction: row;
  flex-direction: row;
}

.form-actions.row2 .btn {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0;
  flex: 1 1 0;
}

.btn {
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
}

.btn:active {
  opacity: 0.9;
}

.btn-primary {
  background: var(--accent-strong);
  color: var(--on-accent);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
}

.btn-danger {
  background: var(--danger-strong);
  color: #ffffff;
}

.btn-danger-ghost {
  border: 1px solid var(--danger-wash);
  background: transparent;
  color: var(--danger);
}

.form-error {
  margin: 6px 0 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 13.5px;
}

.form-hint {
  margin: 4px 4px 0;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.4;
}

.event-actions {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 8px;
  margin: 12px 6px 4px;
}

.event-hint {
  margin: 12px 6px 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-faint);
  font-size: 13px;
}

.confirm-box {
  margin: 12px 6px 4px;
  padding: 12px;
  border-radius: 12px;
  background: var(--danger-wash);
}

.confirm-text {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- сообщение-тост ---------- */

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 80;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--toast-bg);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  -webkit-animation: toast-in 0.18s ease;
  animation: toast-in 0.18s ease;
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* ---------- вход, первая настройка, состояние связи (этап 7) ---------- */

.syncbar {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 12px 6px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}

.syncbar[hidden] {
  display: none;
}

.syncbar-text {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.3;
}

.syncbar-btn {
  -ms-flex-negative: 0;
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.gate {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  padding: 20px 16px;
  background: var(--page-bg);
  overflow-y: auto;
}

.gate[hidden] {
  display: none;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  padding: 24px 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  -webkit-box-shadow: var(--shadow-app);
  box-shadow: var(--shadow-app);
}

.gate-center {
  text-align: center;
}

.gate-logo {
  font-size: 34px;
  line-height: 1;
  text-align: center;
}

.gate-title {
  margin: 10px 0 6px;
  font-size: 21px;
  font-weight: 700;
  text-align: center;
}

.gate-hint {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
}

.gate-foot {
  margin: 12px 0 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.gate .form-error {
  text-align: left;
}

/* Подсказка «Как войти» на экране входа: раскрывается кнопкой, чтобы не
   пугать новичка длинным текстом сразу. */
.gate-help {
  margin: 4px 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.gate-help b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 13.5px;
}

.gate-help ol {
  margin: 0 0 6px;
  padding-left: 18px;
}

.gate-help li {
  margin: 0 0 3px;
}

.gate-help p {
  margin: 6px 0 0;
}

.btn-wide {
  width: 100%;
  margin-top: 10px;
}

.gate-spinner {
  width: 34px;
  height: 34px;
  margin: 6px auto 2px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  -webkit-animation: gate-spin 0.9s linear infinite;
  animation: gate-spin 0.9s linear infinite;
}

@-webkit-keyframes gate-spin {
  to { -webkit-transform: rotate(360deg); }
}

@keyframes gate-spin {
  to { transform: rotate(360deg); }
}

.row-static {
  min-height: 0;
  padding: 10px 12px;
}

.row-static .row-main {
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: start;
  -ms-flex-align: start;
  align-items: flex-start;
  gap: 3px;
}

/* ---------- приглашения, участники, ключ (этап 9) ---------- */

/* Код приглашения показывается один раз — крупно и разборчиво. */
.invite-code {
  margin: 8px 2px 4px;
  padding: 14px 10px;
  border: 1px dashed var(--accent);
  border-radius: var(--r-md);
  background: var(--accent-wash);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 3px;
  line-height: 1.3;
  text-align: center;
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
}

.invite-warn {
  margin: 8px 4px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.45;
}

.copy-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.copy-row .btn {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 0;
  flex: 1 1 0;
  min-height: 44px;
  padding: 0 10px;
  font-size: 14px;
}

/* Ссылка и ключ — длинные строки: переносим по символам, не растягиваем экран. */
.input-link,
.input-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-all;
  -webkit-user-select: text;
  user-select: text;
}

textarea.input-key {
  min-height: 96px;
  resize: none;
}

/* Палитра цветов: крупные кружки вместо мелких радиокнопок. */
.swatches {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 10px;
  padding: 2px 4px 4px;
}

.swatch {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: var(--text-faint);
}

.swatch.is-on {
  outline: 3px solid var(--text);
  outline-offset: 2px;
}

.swatch-note {
  margin: 2px 4px 0;
  color: var(--text-faint);
  font-size: 12px;
}

/* Строка участника: имя + роль, без мелких подписей. */
.row-role {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.person-row {
  -ms-flex-wrap: nowrap;
  flex-wrap: nowrap;
  gap: 8px;
}

.person-row .row-main {
  -webkit-box-flex: 1;
  -ms-flex: 1 1 auto;
  flex: 1 1 auto;
}

.person-remove {
  -ms-flex-negative: 0;
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--danger-wash);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .gate-spinner {
    -webkit-animation: none;
    animation: none;
  }
}

/* ---------- анимации ---------- */

@-webkit-keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@-webkit-keyframes sheet-in {
  from { -webkit-transform: translateY(16px); opacity: 0.6; }
  to { -webkit-transform: translateY(0); opacity: 1; }
}

@keyframes sheet-in {
  from { transform: translateY(16px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

@-webkit-keyframes toast-in {
  from { -webkit-transform: translateY(8px); opacity: 0; }
  to { -webkit-transform: translateY(0); opacity: 1; }
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .scrim,
  .sheet,
  .toast {
    -webkit-animation: none;
    animation: none;
  }
}
