/* Палитра своя, как в панели Gremlin: темы две, тёмная – по умолчанию
   (index.html ставит data-theme до отрисовки, кнопка в шапке переключает).
   Цвет – сигнал, а не украшение: акцент только у «сегодня», выбранного,
   включённого и ссылок. Главные кнопки почти чёрные (в тёмной – почти
   белые), наведение и мягкие кнопки – нейтральная заливка. Цвета событий и
   подсветки дней – данные пользователя, их палитра не трогает. */
:root {
  --r-lg: 24px;
  --r-md: 14px;
  --r-sm: 10px;
  --spring: cubic-bezier(.32, .72, 0, 1);
  /* Отступы под вырез, часы и кнопки Telegram (как в Gremlin). В полном экране
     мини-приложения Telegram ставит --tg-safe-area-inset-* (вырез телефона) и
     --tg-content-safe-area-inset-* (его кнопки «закрыть» и «⋯» поверх страницы).
     Вне Telegram и в обычном окне они пустые – остаётся env() браузера */
  --safe-top: calc(max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px))
    + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  /* шрифт: системный, своя тема ставит --font (Google Fonts или загруженный) */
  --font-sys: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, sans-serif;
  --font: var(--font-sys);
}

/* тёмная: фон почти чёрный, слой выше – светлее; тени на тёмном не видны */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --card: #151517;
  --card-2: #222226;        /* поле и плитка внутри карточки */
  --sheet: #111113;         /* лист поверх затемнения */
  --ink: #ededed;
  --ink-2: #a1a1a6;
  --ink-3: #6b6b70;
  --line: rgb(255 255 255 / 8%);
  --fill: rgb(255 255 255 / 7%);
  --fill-strong: rgb(255 255 255 / 12%);
  --accent: #b2a6fa;
  --accent-ink: #c4bbff;
  --accent-soft: rgb(178 166 250 / 16%);
  --on-accent: #0a0a0b;
  --btn: #ededed;
  --btn-text: #0a0a0b;
  --seg-on: #3a3a3f;
  --danger: #f28b82;
  --scrim: rgb(0 0 0 / 60%);
  --shadow: 0 0 #0000;
  --shadow-lg: 0 24px 64px rgb(0 0 0 / 60%), 0 0 0 1px var(--line);
  --shadow-pop: 0 10px 28px rgb(0 0 0 / 50%);
}

/* светлая: фон не белый, слои белые, высоту показывает тень */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f2f5;
  --card: #ffffff;
  --card-2: #f2f2f5;
  --sheet: #f2f2f5;
  --ink: #1d1b20;
  --ink-2: #5f5c66;
  --ink-3: #a3a1a8;
  --line: #e7e7ec;
  --fill: rgb(29 27 32 / 6%);
  --fill-strong: rgb(29 27 32 / 11%);
  --accent: #6f5fe0;
  --accent-ink: #5a4bd1;
  --accent-soft: rgb(111 95 224 / 12%);
  --on-accent: #ffffff;
  --btn: #1d1b20;
  --btn-text: #ffffff;
  --seg-on: #ffffff;
  --danger: #d0353a;
  --scrim: rgb(0 0 0 / 32%);
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 6px 20px rgb(0 0 0 / 5%);
  --shadow-lg: 0 24px 64px rgb(0 0 0 / 18%);
  --shadow-pop: 0 10px 28px rgb(0 0 0 / 16%);
}

* { box-sizing: border-box; }

/* свой ползунок прокрутки: тонкий, скруглённый, нейтральный – в цвет темы */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--fill-strong) padding-box; border: 3px solid transparent; border-radius: 99px; min-height: 40px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--ink-3); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--fill-strong) transparent; }
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  transition: background-color .2s ease, color .2s ease;
  color: var(--ink);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 1em; height: 1em; fill: currentColor; flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
small.muted { display: block; font-size: 12px; margin-top: 2px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 9px 16px;
  font-weight: 600; background: var(--card-2); color: var(--ink);
  transition: transform .12s ease-out, background .15s, opacity .15s;
}
.btn:active, .icon-btn:active, .avatar:active, .fab:active { transform: scale(.96); }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.primary:hover { background: color-mix(in srgb, var(--btn) 86%, var(--bg)); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--fill); }
.btn.danger { background: color-mix(in srgb, var(--danger) 10%, var(--card)); color: var(--danger); }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn.wide { width: 100%; padding: 13px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: transparent; color: var(--ink-2);
  font-size: 18px; transition: background .15s, transform .12s ease-out;
}
.icon-btn:hover { background: var(--fill); color: var(--ink); }
.icon-btn.soft { background: var(--fill); color: var(--ink-2); }
.theme-btn svg { font-size: 20px; }
.theme-btn.turn svg { animation: theme-turn .32s cubic-bezier(.23, 1, .32, 1); }
@keyframes theme-turn { from { transform: rotate(-120deg) scale(.5); opacity: 0; } }
.auth-card { position: relative; }
.auth-theme { position: absolute; top: 20px; right: 20px; z-index: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- вход ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(400px, 100%); background: var(--card);
  border-radius: 28px; padding: 12px 12px 24px; box-shadow: var(--shadow);
  animation: rise .6s var(--spring);
}
.auth-card h1 { margin: 18px 12px 16px; font-size: 26px; letter-spacing: -.02em; }
.auth-card > p { margin: 0 12px 18px; }
.auth-card form, .auth-card .seg { margin: 0 12px; }
.auth-art {
  position: relative; height: 190px; background: var(--card-2); border-radius: 18px; overflow: hidden;
  color: var(--accent);
}
.auth-art svg { position: absolute; }
.auth-art .s1 { width: 120px; height: 160px; left: 26px; top: 20px; animation: twinkle 4s ease-in-out infinite; }
.auth-art .s2 { width: 90px; height: 120px; right: 50px; top: 10px; animation: twinkle 4s ease-in-out .8s infinite; }
.auth-art .s3 { width: 22px; height: 28px; left: 150px; top: 26px; animation: twinkle 3s ease-in-out .4s infinite; }
.auth-art .s4 { width: 22px; height: 28px; left: 190px; bottom: 26px; animation: twinkle 3s ease-in-out 1.4s infinite; }
@keyframes twinkle { 0%, 100% { transform: scale(1); } 50% { transform: scale(.88) rotate(4deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.seg {
  display: flex; background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 12px; padding: 3px; margin-bottom: 14px;
}
.seg button {
  flex: 1; border: 0; background: transparent; padding: 7px 10px; border-radius: 9px;
  font-weight: 600; color: var(--ink-2); transition: background .2s, color .2s, box-shadow .2s;
}
.seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 4px rgb(0 0 0 / 8%); }
.seg.small { margin: 0; flex: none; }
.seg.small button { padding: 4px 14px; font-size: 14px; }
/* Плашка выбранного пункта – отдельный слой, переезжает пружиной, как
   бегунок переключателя и пилюля нижней панели в Gremlin. Ставит её скрипт
   (segThumb); пока скрипта нет, подсвечена сама кнопка */
.seg.thumbed { position: relative; isolation: isolate; }
.seg.thumbed button { position: relative; z-index: 1; }
.seg.thumbed button.on { background: transparent; box-shadow: none; }
.seg-thumb {
  position: absolute; left: 0; top: 3px; bottom: 3px; z-index: 0; pointer-events: none;
  border-radius: 9px; will-change: translate;
}
.seg-thumb::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--seg-on); box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
}
.seg-thumb[hidden] { display: none; }
.seg.still .seg-thumb { transition: none; }
@media (prefers-reduced-motion: no-preference) {
  /* та же пружина: затухание 0.65, перелёт ~7% пути (скрипт подбирает под прыжок) */
  .seg-thumb {
    transition-property: translate, width, scale;
    transition-duration: 420ms;
    transition-timing-function: linear(0, 0.025, 0.09, 0.181, 0.287, 0.4, 0.511, 0.616, 0.712,
      0.796, 0.867, 0.927, 0.973, 1.009, 1.035, 1.053, 1.063, 1.068, 1.068, 1.065, 1.059,
      1.052, 1.045, 1.037, 1.03, 1.023, 1.017, 1.011, 1.007, 1.003, 1);
  }
  /* на разгоне тянется по ходу, у цели поджимается к краю, куда приехала */
  .seg-thumb.go-r::before { transform-origin: right center; animation: pill var(--pill-ms, 420ms) ease; }
  .seg-thumb.go-l::before { transform-origin: left center; animation: pill var(--pill-ms, 420ms) ease; }
}

.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 13px; color: var(--ink-2); margin: 0 4px 4px; }
.field input {
  width: 100%; border: 1px solid transparent; background: var(--card-2); border-radius: var(--r-md);
  padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field.bad input { border-color: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent); }
.tg-choice .field { margin: 0 0 2px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; margin: 6px 4px; }
.form-error:empty { display: none; }

/* ---------- приложение ---------- */
.app { height: 100%; display: flex; flex-direction: column; padding: 14px 18px 18px; gap: 14px; }
.topbar { display: flex; align-items: center; gap: 16px; position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--ink); }
.brand svg { color: var(--accent); font-size: 22px; }
.month-title { margin: 0 0 0 12px; font-size: 26px; font-weight: 700; letter-spacing: -.025em; flex: 1 1 0; min-width: 0; white-space: nowrap; }
.month-title .yr { color: var(--ink-3); font-weight: 600; }
/* Слева год, по центру пилюля, справа всё остальное: края делят свободное
   место поровну, поэтому пилюля стоит ровно посередине шапки */
.top-right { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.tb-break { display: none; }
.nav { display: flex; align-items: center; gap: 2px; background: var(--card); border-radius: 999px; padding: 3px; box-shadow: var(--shadow);
  flex: none; overflow: hidden; }
.nav .btn { padding: 6px 12px; }
/* Период в пилюле. Текст уезжает и въезжает только между стрелками */
.nav-label { position: relative; overflow: hidden; flex: 1 1 auto; min-width: 0; white-space: nowrap; }
.nav-label > span { display: block; }
.nav-label > span.out { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.nav-label[aria-expanded="true"] { background: var(--fill); }
/* панель вида под пилюлей: стекло, как нижняя панель */
.view-pop {
  position: absolute; z-index: 30; translate: -50% 0; transform-origin: 50% 0; padding: 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--card) 72%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: 0 12px 34px rgb(0 0 0 / 22%);
}
.view-pop[hidden] { display: none; }
.view-pop .view-seg { display: flex; background: none; }
.view-pop:not([hidden]) { display: flex; align-items: center; }
.vp-today { flex: none; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; position: relative; margin-right: 5px; }
.vp-today::after { content: ""; position: absolute; right: -3px; top: 25%; bottom: 25%; width: 1px; background: var(--line); }
.vp-today:hover { background: var(--fill); }
.vp-today:active { transform: scale(.95); }
.add-btn svg { font-size: 16px; }
/* Тесная шапка: правые кнопки ужимаются по ступеням, чтобы пилюля осталась
   посередине. 1 – «Событие» становится круглым плюсом, 2 – ещё и уже
   переключатель вида и промежутки. Ступень выбирает fitTopbar() */
.add-btn span { transition: opacity .16s; }
@media (min-width: 641px) {
  .topbar.sq1 .add-btn { position: relative; width: var(--add-h, 38px); height: var(--add-h, 38px); padding: 0; overflow: hidden; }
  .topbar.sq1 .add-btn span { position: absolute; opacity: 0; pointer-events: none; }
  .topbar.sq2 .top-right { gap: 8px; }
  .topbar.sq2 .top-actions { gap: 4px; }
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center;
  color: var(--ink); font-weight: 700; font-size: 16px; background: var(--fill-strong); transition: transform .12s ease-out;
}
.avatar.big { width: 76px; height: 76px; font-size: 32px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 340px; gap: 14px; }
.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); }

.month { display: flex; flex-direction: column; overflow: hidden; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); padding: 12px 6px 6px; }
.weekdays div { text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; min-height: 0; }
.cell {
  position: relative; border-top: 1px solid var(--line); padding: 4px 4px 2px; min-width: 0; min-height: 0;
  overflow: hidden; cursor: pointer; transition: background .15s; user-select: none;
}
.cell:not(:nth-child(7n + 1)) { border-left: 1px solid var(--line); }
.cell:hover { background: color-mix(in srgb, var(--fill) 55%, transparent); }
.cell.sel { background: var(--fill); }
.cell.other .num { color: var(--ink-3); }
.cell .num {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px;
  border-radius: 13px; font-size: 14px; font-weight: 600; margin: 0 0 3px 2px;
}
.cell.today .num { background: var(--accent); color: var(--on-accent); }
.chips { display: flex; flex-direction: column; gap: 2px; }
.chip {
  display: flex; align-items: center; gap: 5px; font-size: 12px; line-height: 18px; padding: 0 6px;
  border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.chip.allday {
  background: color-mix(in srgb, var(--c) 24%, var(--card));
  color: color-mix(in srgb, var(--c) 45%, var(--ink));
  font-weight: 600;
}
.chip.timed { color: var(--ink); }
.chip.timed::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.chip .t { color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }
.chip span:not(.t) { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cell { container-type: inline-size; }
@container (max-width: 110px) {
  .chip .t { display: none; }
  .chip { gap: 4px; padding: 0 4px; }
}
.more { font-size: 11px; color: var(--ink-3); padding: 0 6px; font-weight: 600; }

/* панель дня */
.day { display: flex; flex-direction: column; overflow: hidden; }
.day-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 18px 10px; }
.day-num { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.day-sub { color: var(--ink-2); margin-top: 4px; text-transform: capitalize; }
.agenda { list-style: none; margin: 0; padding: 4px 10px 14px; overflow-y: auto; flex: 1; }
.agenda .empty { text-align: center; color: var(--ink-3); padding: 40px 10px; }
.agenda .empty svg { display: block; margin: 0 auto 10px; font-size: 34px; color: var(--ink-3); }
.ag {
  display: flex; gap: 12px; padding: 10px; border-radius: var(--r-md); cursor: pointer;
  transition: background .15s, transform .12s ease-out; animation: rise .35s var(--spring) both;
}
.ag:hover { background: var(--card-2); }
.ag:active { transform: scale(.985); }
.ag .bar { width: 4px; border-radius: 2px; background: var(--c); flex: none; }
.ag .when { width: 52px; flex: none; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 1px; }
.ag .when b { display: block; color: var(--ink); font-weight: 600; }
.ag .what { min-width: 0; flex: 1; }
.ag .what b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.ag .what p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.fab {
  display: none; position: fixed; right: 18px; bottom: calc(18px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--btn); color: var(--btn-text);
  font-size: 26px; place-items: center; box-shadow: var(--shadow-pop);
  transition: transform .12s ease-out; z-index: 5;
}

/* ---------- листы (диалоги) ---------- */
dialog.sheet {
  border: 0; padding: 0; background: var(--sheet); color: var(--ink); border-radius: 22px;
  width: min(460px, calc(100% - 32px)); max-height: min(760px, calc(100% - 48px));
  box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .45s var(--spring); }
dialog.sheet.closing { animation: sheet-out .2s ease-in forwards; }
dialog.sheet > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); animation: fade .3s ease-out; }
dialog.closing::backdrop { animation: fade .2s ease-in reverse forwards; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }

.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 12px 12px 8px;
}
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-head strong { font-size: 16px; }
.sheet-body { padding: 4px 16px 18px; overflow-y: auto; }

.group { background: var(--card); border-radius: var(--r-md); margin: 0 0 14px; padding: 0 14px; list-style: none; }
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; margin: 18px 6px 6px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px;
  padding: 6px 0;
}
.row + .row { border-top: 1px solid var(--line); }
.row.end { justify-content: flex-end; }
.title-input { width: 100%; border: 0; outline: none; background: transparent; font-size: 20px; font-weight: 600; padding: 14px 0; }
.group textarea { width: 100%; border: 0; outline: none; resize: vertical; background: transparent; padding: 12px 0; min-height: 90px; }
.inline-input { border: 0; outline: none; background: transparent; text-align: right; min-width: 0; flex: 1; color: var(--ink-2); }
.inline-input:focus { color: var(--ink); }
.dt { display: flex; gap: 6px; }
.dt input {
  border: 0; background: var(--card-2); border-radius: 8px; padding: 6px 8px; outline: none;
  font-variant-numeric: tabular-nums;
}
.dt input:focus { box-shadow: 0 0 0 2px var(--accent); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sw {
  width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--c); padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06); transition: transform .15s var(--spring), box-shadow .15s;
  position: relative;
}
.sw:hover { transform: scale(1.1); }
.sw.on { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--c); }
.sw.custom { background: conic-gradient(#f5c242, #7fcf8f, #6cc3ee, #9b8cf5, #f39ac7, #f0524f, #f5c242); overflow: hidden; }
.sw.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }

.switch {
  appearance: none; width: 51px; height: 31px; border-radius: 16px; background: color-mix(in srgb, var(--ink) 16%, transparent);
  position: relative; cursor: pointer; transition: background .25s; flex: none; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); transition: transform .3s var(--spring);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

.profile-hero { text-align: center; padding: 8px 0 18px; }
.profile-hero .avatar { margin: 0 auto 10px; }
.p-name { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.id-row span { font-weight: 500; }
.id-chip {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: var(--fill); color: var(--ink);
  border-radius: 10px; padding: 7px 10px; font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .08em;
  transition: transform .12s ease-out;
}
.id-chip:active { transform: scale(.96); }
.sessions li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 6px 0; }
.sessions li + li { border-top: 1px solid var(--line); }
.sessions .cur { color: var(--accent-ink); font-size: 12px; font-weight: 600; }

/* ---------- подсветка дней ---------- */
.cell.marked { background: color-mix(in srgb, var(--m) 26%, var(--card)); }
.cell.marked:hover { background: color-mix(in srgb, var(--m) 34%, var(--card)); }
.cell.marked.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cell .mlabel {
  position: absolute; top: 7px; right: 6px; max-width: calc(100% - 38px); font-size: 10px; font-weight: 700;
  color: color-mix(in srgb, var(--m) 55%, var(--ink)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-transform: uppercase; letter-spacing: .03em;
}
.cell.pv { box-shadow: inset 0 0 0 2px var(--pv, var(--accent)); background: color-mix(in srgb, var(--pv, var(--accent)) 30%, var(--card)); }
.cell.pv.erase { background: var(--card); box-shadow: inset 0 0 0 2px var(--ink-3); }
.painting .grid { touch-action: none; cursor: crosshair; }
.painting .cell { cursor: crosshair; }
.painting .cell:hover:not(.pv) { background: color-mix(in srgb, var(--pv, var(--accent)) 14%, transparent); }
.painting .cell.marked:hover:not(.pv) { background: color-mix(in srgb, var(--m) 34%, var(--card)); }
.icon-btn.tool[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.mark-pill {
  display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: color-mix(in srgb, var(--m) 28%, var(--card)); color: color-mix(in srgb, var(--m) 50%, var(--ink));
}

.paintbar {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%);
  width: min(440px, calc(100% - 24px)); z-index: 20; padding: 12px 14px;
  background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-radius: 22px; box-shadow: var(--shadow-lg); border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  animation: bar-in .45s var(--spring);
}
.paintbar.closing { animation: bar-out .2s ease-in forwards; }
@keyframes bar-in { from { opacity: 0; transform: translate(-50%, 30px); } }
@keyframes bar-out { to { opacity: 0; transform: translate(-50%, 30px); } }
.pb-hint { font-size: 13px; color: var(--ink-2); text-align: center; margin-bottom: 8px; }
.pb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pb-row + .pb-row { margin-top: 10px; }
.pb-row .swatches { justify-content: flex-start; }
.paintbar.erasing .swatches { opacity: .35; }
.icon-btn.eraser { background: var(--card-2); flex: none; }
.icon-btn.eraser[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.pb-label {
  flex: 1; min-width: 0; border: 0; outline: none; background: var(--card-2); border-radius: 10px; padding: 8px 12px;
}
.pb-label:focus { box-shadow: 0 0 0 2px var(--accent); }
.painting .fab { display: none; }
.painting .layout { padding-bottom: 150px; }
/* на широком экране панель встаёт поверх панели дня и не закрывает сетку */
@media (min-width: 901px) {
  .painting .layout { padding-bottom: 0; }
  .paintbar { left: auto; right: 18px; bottom: 18px; transform: none; width: 340px; animation-name: bar-in-side; }
  .paintbar.closing { animation-name: bar-out-side; }
  @keyframes bar-in-side { from { opacity: 0; transform: translateY(30px); } }
  @keyframes bar-out-side { to { opacity: 0; transform: translateY(30px); } }
}

/* ---------- выбор событий ---------- */
.picking .grid { touch-action: none; }
.picking .cell { cursor: pointer; }
.chip.picked { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 1.5px var(--accent); }
.chip.picked::after {
  content: ""; width: 12px; height: 12px; flex: none; margin-left: auto; border-radius: 50%; background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 9px no-repeat;
}
.picking.has-sel .chip:not(.picked) { opacity: .45; }
.picking .cell.pv { --pv: var(--accent); }

.ag .tick { display: none; }
.picking .ag .tick {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none; align-self: center;
  box-shadow: inset 0 0 0 2px var(--ink-3); color: transparent; font-size: 15px; transition: background .15s, box-shadow .15s;
}
.picking .ag.picked .tick { background: var(--accent); box-shadow: none; color: var(--on-accent); animation: pop .3s var(--spring); }
.picking .ag.picked { background: var(--accent-soft); }
@keyframes pop { from { transform: scale(.6); } }

.selbar b { font-size: 15px; }
.sb-quick { display: flex; align-items: center; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.sb-quick .muted { font-size: 13px; flex: none; }
.sb-colors { display: flex; gap: 6px; }
.sb-colors button {
  width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--c); flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform .12s ease-out;
}
.sb-colors button:active { transform: scale(.9); }
.pill-btn {
  flex: none; border: 0; border-radius: 999px; padding: 5px 12px; background: var(--card-2); color: var(--ink);
  font-weight: 600; font-size: 13px; transition: background .15s, transform .12s ease-out;
}
.pill-btn:hover { background: var(--fill); color: var(--ink); }
.pill-btn:active { transform: scale(.95); }
.sb-recolor { justify-content: flex-start; margin-top: 10px; padding: 8px 0 2px; border-top: 1px solid var(--line); }
.sb-actions { display: flex; gap: 6px; margin-top: 10px; }
.act {
  flex: 1; border: 0; border-radius: 12px; padding: 8px 4px; background: var(--card-2); color: var(--ink); font-weight: 600;
  font-size: 14px; transition: background .15s, transform .12s ease-out, opacity .15s;
}
.act:hover { background: var(--fill-strong); color: var(--ink); }
.act:active { transform: scale(.96); }
.act.on { background: var(--accent); color: var(--on-accent); }
.act.danger { color: var(--danger); }
.act.danger:hover { background: color-mix(in srgb, var(--danger) 12%, var(--card)); }
.act:disabled { opacity: .4; pointer-events: none; }
.picking .fab { display: none; }
.picking .layout { padding-bottom: 190px; }
@media (min-width: 901px) { .picking .layout { padding-bottom: 0; } }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper b { min-width: 76px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper .icon-btn { font-size: 20px; font-weight: 600; }
.quick-row { justify-content: flex-start; flex-wrap: wrap; gap: 6px; }

.toast { display: flex; align-items: center; gap: 14px; white-space: nowrap; max-width: calc(100% - 24px); }
@media (max-width: 900px) {
  body:has(.app.picking) .toast { bottom: calc(210px + var(--safe-bottom)); }
  body:has(.app.painting) .toast { bottom: calc(170px + var(--safe-bottom)); }
}
.toast.has-act { pointer-events: auto; padding-right: 8px; }
#toast-act {
  border: 0; background: color-mix(in srgb, var(--card) 18%, transparent); color: var(--card); border-radius: 999px;
  padding: 5px 12px; font-weight: 700;
}

/* ---------- чек-лист ---------- */
.checklist { padding: 4px 6px 6px; }
.cl-items { list-style: none; margin: 0; padding: 0; position: relative; }
.cl-item {
  display: flex; align-items: flex-start; gap: 6px; padding: 3px 0; background: var(--card); border-radius: 10px;
  position: relative; transition: transform .22s var(--spring);
}
.cl-item.dragging { z-index: 2; transition: none; box-shadow: var(--shadow-pop); }
.cl-grip {
  width: 22px; height: 32px; display: grid; place-items: center; color: var(--ink-3); cursor: grab; flex: none;
  touch-action: none; opacity: .5; transition: opacity .15s;
}
.cl-item:hover .cl-grip, .cl-item.dragging .cl-grip { opacity: 1; }
.cl-item.dragging .cl-grip { cursor: grabbing; }
.done .cl-grip { visibility: hidden; }
.cl-check {
  width: 22px; height: 22px; margin: 5px 2px 0; border-radius: 7px; border: 0; flex: none; padding: 0;
  box-shadow: inset 0 0 0 2px var(--ink-3); background: transparent; color: transparent; display: grid; place-items: center;
  font-size: 14px; transition: background .15s, box-shadow .15s, transform .12s ease-out;
}
.cl-check:active { transform: scale(.88); }
.done .cl-check { background: var(--accent); box-shadow: none; color: var(--on-accent); }
.checklist .cl-text {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; resize: none; overflow: hidden;
  padding: 6px 0; line-height: 1.35; min-height: 32px;
}
.checklist .done .cl-text { text-decoration: line-through; color: var(--ink-3); }
.cl-del {
  width: 28px; height: 28px; margin-top: 2px; border: 0; background: transparent; color: var(--ink-3); border-radius: 50%;
  font-size: 18px; flex: none; opacity: 0; transition: opacity .15s, background .15s;
}
.cl-item:hover .cl-del, .cl-item:focus-within .cl-del { opacity: 1; }
.cl-del:hover { background: var(--card-2); color: var(--ink); }
@media (hover: none) { .cl-del { opacity: .6; } }
.cl-add {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: var(--ink-2);
  padding: 9px 4px 9px 30px; text-align: left; border-radius: 10px;
}
.cl-add svg { font-size: 16px; }
.cl-add:hover { color: var(--ink); background: var(--fill); }
.cl-done-wrap { border-top: 1px solid var(--line); margin-top: 2px; padding-top: 2px; }
.cl-done-toggle {
  display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--ink-2); padding: 8px 4px;
  font-weight: 600; font-size: 14px;
}
.cl-done-toggle svg { transition: transform .25s var(--spring); }
.cl-done-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }

.checklist.readonly .cl-grip, .checklist.readonly .cl-del { display: none; }
.checklist.readonly .cl-item { padding-left: 6px; }

/* чек-лист в панели дня */
.ag .prog { display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--ink-2);
  background: var(--fill); border-radius: 999px; padding: 1px 7px; vertical-align: 2px; }
.ag-cl { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ag-ci { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--ink); }
.ag-ci .ag-check {
  width: 18px; height: 18px; margin-top: 1px; border-radius: 6px; border: 0; flex: none; padding: 0; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1.8px var(--ink-3); background: transparent; color: transparent; font-size: 12px;
  transition: background .15s, transform .12s ease-out;
}
.ag-ci .ag-check:active { transform: scale(.85); }
.ag-ci.on .ag-check { background: var(--c); box-shadow: none; color: #fff; }
.ag-ci.on span { text-decoration: line-through; color: var(--ink-3); }
.ag-ci span { overflow-wrap: anywhere; }
.ag-more { font-size: 12px; color: var(--ink-3); padding-left: 26px; }

/* ---------- календари и доступ ---------- */
.cals-btn { position: relative; }
.badge {
  position: absolute; top: -2px; right: -2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--bg); animation: pop .35s var(--spring);
}
.cal-list li, .members li, .invites li {
  display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 6px 0;
}
.cal-list li + li, .members li + li, .invites li + li { border-top: 1px solid var(--line); }
.cal-vis {
  width: 24px; height: 24px; border-radius: 7px; border: 0; flex: none; padding: 0; display: grid; place-items: center;
  background: var(--c); color: #fff; font-size: 15px; transition: background .15s, box-shadow .15s, transform .12s ease-out;
}
.cal-vis:active { transform: scale(.88); }
.cal-vis.off { background: transparent; box-shadow: inset 0 0 0 2px var(--c); color: transparent; }
.cal-open { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 4px 0; display: flex; align-items: center; gap: 8px; }
.cal-open > div { flex: 1; min-width: 0; }
.cal-open b, .members b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cal-open small, .members small, .invites small { display: block; color: var(--ink-2); font-size: 12px; margin-top: 1px; }
.cal-open::after { content: "›"; color: var(--ink-3); font-size: 20px; }
.mini-av {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-weight: 700; font-size: 14px; background: var(--c);
}
.members .who { flex: 1; min-width: 0; }
.members select { max-width: 120px; }
.members .pending { opacity: .7; }
.invites .who { flex: 1; min-width: 0; }
.invites .btns { display: flex; gap: 6px; flex: none; }
.id-input { text-align: left; font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.link-input { text-align: left; font-size: 13px; color: var(--ink-2); }
.row.end { gap: 8px; }
.pb-cal { margin-bottom: 8px; }
.pb-cal select { flex: 1; text-align: right; }

/* автор в общем календаре */
.ag-meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--ink-3); }
.ag-meta i { width: 7px; height: 7px; border-radius: 2px; background: var(--cc); flex: none; }

/* только просмотр */
#ev-dlg.readonly #ev-form input, #ev-dlg.readonly #ev-form textarea, #ev-dlg.readonly #ev-form select { pointer-events: none; }
#ev-dlg.readonly .swatches, #ev-dlg.readonly #days-open { pointer-events: none; }
#ev-dlg.readonly .sheet-head .btn.primary, #ev-dlg.readonly #ev-scope, #ev-dlg.readonly #tpls { display: none; }

/* ---------- общие списки: как Заметки ---------- */
.app.lists-mode .layout, .app.lists-mode .nav { display: none; }
.lists-view { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
.lists-view[hidden] { display: none; }

/* колонка списков */
.nb-side { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.nb-search {
  display: flex; align-items: center; gap: 8px; margin: 12px 12px 6px; padding: 8px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink-3);
}
.nb-search svg { flex: none; font-size: 16px; }
.nb-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); font: inherit; }
.nb-list { list-style: none; margin: 0; padding: 4px 8px 12px; overflow-y: auto; flex: 1; }
.nb-none { color: var(--ink-3); text-align: center; padding: 24px 8px; font-size: 14px; }
.nb-item {
  position: relative; display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink);
  padding: 10px 12px 10px 18px; border-radius: 12px; cursor: pointer; transition: background .15s;
}
.nb-item::before { content: ""; position: absolute; left: 6px; top: 17px; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.nb-item:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
.nb-item.on { background: var(--fill); }
.nb-item b { display: block; font-weight: 650; font-size: 15px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 18px; }
.nb-sub { display: flex; gap: 8px; margin-top: 2px; font-size: 13px; color: var(--ink-3); min-width: 0; }
.nb-sub time { flex: none; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.nb-sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-shared { position: absolute; right: 10px; top: 13.5px; font-size: 13px; color: var(--ink-3); }

/* открытый список */
.nb-main { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.nb-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 0 18px; min-height: 46px; }
.nb-back { display: none; width: auto; gap: 2px; padding: 0 8px 0 2px; color: var(--accent-ink, var(--accent)); font-weight: 600; }
.nb-state { flex: 1; font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-peers { display: flex; }
.nb-peers .mini-av { width: 26px; height: 26px; font-size: 12px; margin-left: -6px; box-shadow: 0 0 0 2px var(--card); }
.nb-main.empty .nb-head, .nb-main.empty .nb-doc { display: none; }
.nb-doc { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 28px 60px; }
.nb-empty { margin: auto; text-align: center; color: var(--ink-2); padding: 24px; display: grid; justify-items: center; gap: 12px; }
.nb-empty svg { font-size: 44px; color: var(--ink-3); }
.nb-empty[hidden] { display: none; }

/* сам документ */
.nb-pm { outline: none; max-width: 760px; margin: 0 auto; font-size: 16px; line-height: 1.55; color: var(--ink); caret-color: var(--accent); }
.nb-pm > * + * { margin-top: .35em; }
.nb-pm p { margin: 0; }
.nb-pm h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.02em; margin: 6px 0 10px; }
.nb-pm h2 { font-size: 21px; line-height: 1.3; margin: 18px 0 4px; }
.nb-pm h3 { font-size: 17px; line-height: 1.35; margin: 14px 0 2px; color: var(--ink-2); }
.nb-pm ul, .nb-pm ol { margin: .2em 0; padding-left: 1.4em; }
.nb-pm li > p { margin: 0; }
.nb-pm a { color: var(--accent); }
.nb-pm s { color: var(--ink-3); }
.nb-pm .is-empty::before {
  content: attr(data-placeholder); float: left; height: 0; pointer-events: none; color: var(--ink-3);
}
/* чек-лист: круглая галочка, как в Заметках */
.nb-pm ul[data-type="taskList"] { list-style: none; padding-left: 0; }
.nb-pm ul[data-type="taskList"] ul[data-type="taskList"] { padding-left: 1.6em; }
.nb-pm ul[data-type="taskList"] > li { display: flex; align-items: flex-start; gap: 10px; }
.nb-pm ul[data-type="taskList"] > li > label { flex: none; margin-top: .2em; cursor: pointer; user-select: none; }
.nb-pm ul[data-type="taskList"] > li > label input {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 0; border-radius: 50%;
  border: 1.6px solid color-mix(in srgb, var(--ink) 35%, transparent); display: grid; place-items: center; cursor: pointer;
  transition: background .2s, border-color .2s, transform .12s;
}
.nb-pm ul[data-type="taskList"] > li > label input:active { transform: scale(.9); }
.nb-pm ul[data-type="taskList"] > li > label input:checked { background: var(--accent); border-color: var(--accent); }
.nb-pm ul[data-type="taskList"] > li > label input:checked::after {
  content: ""; width: 9px; height: 5px; border: 2px solid var(--on-accent, #fff); border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.nb-pm ul[data-type="taskList"] > li > div { flex: 1; min-width: 0; }
.nb-pm ul[data-type="taskList"] > li[data-checked="true"] > div { color: var(--ink-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink) 30%, transparent); }
/* метка дня и значок «в календарь» у пункта */
.nb-chip, .nb-cal { border: 0; font: inherit; vertical-align: 1px; margin-left: 8px; cursor: pointer; }
.nb-chip {
  font-size: 12px; font-weight: 650; padding: 1px 8px; border-radius: 999px; color: var(--accent-ink, var(--accent));
  background: var(--accent-soft); text-decoration: none; display: inline-block;
}
.nb-cal {
  display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border-radius: 6px;
  background: none; color: var(--ink-3); opacity: 0; transition: opacity .15s, background .15s;
}
.nb-cal svg { font-size: 15px; }
.nb-pm ul[data-type="taskList"] > li:hover > div .nb-cal, .nb-cal:focus-visible { opacity: 1; }
.nb-cal:hover { background: var(--fill); color: var(--ink); }
@media (hover: none) { .nb-cal { opacity: .55; } }
/* курсоры других людей */
.nb-caret { position: relative; margin: 0 -1px; border-left: 2px solid var(--c); pointer-events: none; word-break: normal; }
.nb-caret-name {
  position: absolute; left: -2px; top: -1.35em; padding: 1px 6px; border-radius: 6px 6px 6px 0; white-space: nowrap;
  font-size: 11px; font-weight: 650; line-height: 1.4; color: #fff; background: var(--c); user-select: none;
}
.ProseMirror-yjs-selection { background: color-mix(in srgb, currentColor 18%, transparent); }

/* панель форматирования: появляется пружиной из точки над выделением */
.fmt-bar {
  position: fixed; z-index: 60; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-radius: 14px; box-shadow: 0 8px 28px rgb(0 0 0 / 22%), 0 0 0 1px color-mix(in srgb, var(--ink) 8%, transparent);
  opacity: 0; scale: .7; transition: opacity .14s ease-out;
}
.fmt-bar[hidden] { display: none; }
.fmt-bar.show { opacity: 1; scale: 1; }
@media (prefers-reduced-motion: no-preference) {
  .fmt-bar { transition: opacity .14s ease-out, scale 380ms linear(0, 0.025, 0.09, 0.181, 0.287, 0.4, 0.511, 0.616, 0.712,
      0.796, 0.867, 0.927, 0.973, 1.009, 1.035, 1.053, 1.063, 1.068, 1.068, 1.065, 1.059,
      1.052, 1.045, 1.037, 1.03, 1.023, 1.017, 1.011, 1.007, 1.003, 1); }
}
.fmt-bar button {
  border: 0; background: none; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; min-width: 32px; height: 32px;
  padding: 0 8px; border-radius: 9px; display: inline-grid; place-items: center; cursor: pointer; transition: background .12s;
}
.fmt-bar button[hidden] { display: none; }
.fmt-bar button svg { font-size: 17px; }
.fmt-bar button:hover { background: var(--fill); }
.fmt-bar button.on { background: var(--accent-soft); color: var(--accent-ink, var(--accent)); }
.fmt-bar > i { width: 1px; height: 18px; margin: 0 3px; background: color-mix(in srgb, var(--ink) 14%, transparent); }

.send-what { font-weight: 650; margin: 2px 4px 12px; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .lists-view { grid-template-columns: 240px 1fr; }
  .nb-doc { padding: 6px 18px 60px; }
}
/* телефон: сначала колонка, открытый список – на весь экран с «‹ Списки» */
@media (max-width: 640px) {
  .lists-view { grid-template-columns: 1fr; gap: 0; }
  .lists-view .card { border-radius: 20px; }
  .lists-view.nb-open .nb-side, .lists-view:not(.nb-open) .nb-main { display: none; }
  .nb-back { display: inline-flex; }
  .nb-head { padding: 8px 10px 0 6px; }
  .nb-doc { padding: 4px 16px 120px; }
  .nb-list { padding-bottom: 120px; }
  .nb-pm h1 { font-size: 25px; }
  .fmt-bar { max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; }
}

/* ---------- виды: переключатель, нижние вкладки ---------- */
.view-seg { margin: 0; flex: none; }
.view-seg button { padding: 7px 16px; }
.tabbar, .tab-fade { display: none; }
.app.view-week .day { display: none; }
.app.view-week .layout { grid-template-columns: 1fr; }

/* ---------- сетка времени (неделя / день) ---------- */
.tview { --hour: 48px; --gut: 52px; display: flex; flex-direction: column; overflow: hidden; touch-action: pan-y; }
.tg-head, .tg-allday, .tg-body { display: grid; grid-template-columns: var(--gut) repeat(var(--n, 7), minmax(0, 1fr)); }
.tg-head { padding: 10px 0 8px; border-bottom: 1px solid var(--line); }
.tg-dh {
  border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0;
  border-radius: 12px; cursor: pointer; transition: background .15s; min-width: 0;
}
.tg-dh:hover { background: var(--fill); }
.tg-dh span { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--ink-3); letter-spacing: .04em; }
.tg-dh b { font-size: 20px; font-weight: 700; min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 17px; }
.tg-dh.sel b { background: var(--fill-strong); color: var(--ink); }
.tg-dh.today b { background: var(--accent); color: var(--on-accent); }
.tg-dh i { font-style: normal; font-size: 10px; font-weight: 700; color: color-mix(in srgb, var(--m) 55%, var(--ink)); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px; }
.tg-allday { border-bottom: 1px solid var(--line); max-height: 30%; overflow-y: auto; }
.tg-allday > div { display: flex; flex-direction: column; gap: 2px; padding: 3px 2px; min-width: 0; border-left: 1px solid var(--line); }
.tg-allday > .tg-gut { border: 0; font-size: 10px; color: var(--ink-3); text-align: right; padding: 6px 8px 0 0; line-height: 1.1; }
.tg-allday .chip { cursor: pointer; }
.tg-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tg-body { position: relative; height: calc(var(--hour) * 24); }
.tg-hours { position: relative; }
.tg-hours span {
  position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.tg-col {
  position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour));
}
.tg-col.marked { background-color: color-mix(in srgb, var(--m) 14%, transparent); }
.tg-col.today { background-color: var(--fill); }
.tg-ev {
  position: absolute; border-radius: 8px; padding: 3px 6px 3px 7px; font-size: 12px; line-height: 1.25; overflow: hidden;
  background: color-mix(in srgb, var(--c) 26%, var(--card)); color: color-mix(in srgb, var(--c) 40%, var(--ink));
  border-left: 3px solid var(--c); box-shadow: 0 0 0 1px var(--card); cursor: pointer; z-index: 1;
  transition: transform .12s ease-out, box-shadow .15s;
}
.tg-ev:hover { z-index: 2; box-shadow: 0 0 0 1px var(--card), var(--shadow-pop); }
.tg-ev:active { transform: scale(.98); }
.tg-ev b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev span { font-variant-numeric: tabular-nums; opacity: .8; white-space: nowrap; }
.tg-ev.short { display: flex; gap: 6px; align-items: center; padding-top: 0; padding-bottom: 0; }
.tg-ev.short b { flex: 1; min-width: 0; }
.tg-ev.picked { box-shadow: 0 0 0 2px var(--accent); }
.tg-now { position: absolute; left: -1px; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.tg-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* ---------- поиск ---------- */
dialog.search-sheet { height: min(680px, calc(100% - 48px)); width: min(560px, calc(100% - 32px)); }
.search-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 9px 12px;
  color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line);
}
.search-box:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--ink); }
.search-res { flex: 1; }
.sr-empty { text-align: center; color: var(--ink-3); padding: 50px 20px; }
.sr-date { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 14px 6px 6px; }
.sr-date::first-letter { text-transform: uppercase; }
.sr-date.past { color: var(--ink-3); }
.sr-sep { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; margin: 20px 6px 0; }
.sr-item {
  width: 100%; display: flex; gap: 12px; align-items: stretch; text-align: left; border: 0; background: var(--card);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 6px; transition: transform .12s ease-out, background .15s;
}
.sr-item:hover { background: var(--fill); }
.sr-item:active { transform: scale(.985); }
.sr-item .bar { width: 4px; border-radius: 2px; background: var(--c); flex: none; }
.sr-when { width: 58px; flex: none; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 1px; }
.sr-what { flex: 1; min-width: 0; }
.sr-what b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.sr-what small { display: block; color: var(--ink-2); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.search-res mark { background: color-mix(in srgb, var(--accent) 32%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

@media (max-width: 900px) {
  .app.view-day .day { display: none; }
  .app.view-day .layout, .app.view-week .layout { grid-template-rows: 1fr; }
}

@media (max-width: 640px) {
  /* строка 1: год, по центру экрана пилюля, справа поиск и тема;
     строка 2: Месяц / Неделя / День и инструменты */
  .topbar { flex-wrap: wrap; row-gap: 0; position: relative; }
  .top-right { display: contents; }
  .month-title { order: 1; flex: 1 1 0; }
  .search-btn { order: 2; }
  .topbar .theme-btn { order: 2; }
  .topbar > .avatar { order: 3; }
  .tb-break { display: block; order: 3; flex: 1 1 100%; height: 0; }
  .nav { position: absolute; left: 50%; top: 0; translate: -50% 0; }
  .top-actions { order: 5; flex: none; margin-top: 8px; }
  /* в списках вторая строка не нужна: переключателя нет, а значок календарей
     встаёт в первую, рядом с поиском */
  .app.lists-mode .top-actions { order: 2; margin-top: 0; }
  .app.lists-mode .tb-break { display: none; }
  #lists-btn { display: none; }
  .top-actions { margin-left: auto; }
  .view-seg button { padding: 7px 13px; }
  .agenda { padding-bottom: 80px; }
  .day { border-radius: 20px; }
  .tview { --hour: 44px; --gut: 40px; border-radius: 20px; }
  .tg-dh b { font-size: 16px; min-width: 28px; height: 28px; }
  .tg-ev { font-size: 11px; padding: 2px 4px 2px 5px; }
  .app.view-week .tg-ev span { display: none; }
  dialog.search-sheet { width: 100%; height: calc(100% - 40px); }
}

/* ---------- Telegram ---------- */
.btn.tg { background: #2aabee; color: #fff; text-decoration: none; }
.btn.tg:hover { background: #229ed9; }
.btn.tg svg { font-size: 18px; }
.tg-login { margin: 14px 12px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tg-login .muted { font-size: 13px; }
.tg-choice { margin: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.tg-hello { margin: 0 4px 8px; font-weight: 600; }
html.in-tg #logout { display: none; }
html.in-tg body { overscroll-behavior: none; }

/* строки-кнопки и выпадашки в листах */
.link-row { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; }
a.link-row { color: inherit; text-decoration: none; }
.link-row .val, .inline-select { color: var(--ink-2); }
.link-row .val::after { content: "›"; margin-left: 8px; color: var(--ink-3); font-size: 18px; }
.link-row .val.on { color: var(--accent-ink); font-weight: 600; }
.inline-select { border: 0; background: transparent; outline: none; text-align: right; cursor: pointer; padding: 4px 0; }
.inline-select option { background: var(--card); color: var(--ink); }
.seg.scope { margin-bottom: 14px; }

/* шаблоны */
.tpls { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 4px; scrollbar-width: none; }
.tpls::-webkit-scrollbar { display: none; }
.tpls-label { flex: none; align-self: center; font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tpl {
  flex: none; display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--c) 22%, var(--card)); color: color-mix(in srgb, var(--c) 45%, var(--ink));
  border-radius: 999px; padding: 6px 6px 6px 12px; font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform .12s ease-out;
}
.tpl:active { transform: scale(.95); }
.tpl small { font-weight: 500; opacity: .75; font-variant-numeric: tabular-nums; }
.tpl .x {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; line-height: 1;
  background: color-mix(in srgb, var(--c) 30%, transparent); opacity: .7;
}
.tpl .x:hover { opacity: 1; }

/* мини-календарь выбора дней */
.picker { padding: 8px 10px 12px; user-select: none; }
.picker-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 8px; }
.picker-head strong { font-size: 16px; }
.pk-wd, .pk-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.pk-wd div { text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; padding-bottom: 6px; }
.pk-grid { gap: 4px 0; touch-action: none; }
.pk-day {
  aspect-ratio: 1; max-height: 46px; display: grid; place-items: center; border: 0; background: transparent; padding: 0;
  font-weight: 600; font-size: 15px; border-radius: 50%; margin: 0 auto; width: 100%; max-width: 46px;
  transition: background .15s, color .15s, transform .25s var(--spring);
}
.pk-day.other { color: var(--ink-3); }
.pk-day.today { color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.pk-day.on { background: var(--accent); color: var(--on-accent); transform: scale(.92); }
.pk-day.first { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.picker-foot { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 6px; }
.hint { font-size: 13px; margin: 6px 6px 0; }

/* вопрос */
dialog.sheet.ask { width: min(340px, calc(100% - 32px)); }
.ask .sheet-body { padding: 22px 18px 16px; text-align: center; }
.ask strong { font-size: 17px; }
.ask p { margin: 6px 0 18px; }
.ask-btns { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 640px) {
  dialog.sheet.ask { width: calc(100% - 24px); margin: auto; border-radius: 22px; }
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  transition: opacity .2s, transform .35s var(--spring); z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- узкие экраны ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: minmax(360px, 1.3fr) 1fr; }
}
@media (max-width: 640px) {
  .app { padding: 10px 10px 0; gap: 10px; }
  .brand, .add-btn { display: none; }
  .topbar { gap: 8px; }
  .top-actions { gap: 8px; }
  .month-title { font-size: 22px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .nav .btn { padding: 5px 8px; font-size: 14px; }
  .nav .icon-btn { width: 30px; height: 30px; font-size: 16px; }
  .avatar { width: 34px; height: 34px; font-size: 15px; }
  .fab { display: grid; }
  .layout { grid-template-rows: auto 1fr; gap: 10px; }
  .month { border-radius: 20px; }
  /* высоту недель считает скрипт (phoneRowH): месяц – на весь экран.
     Число дня – по центру сверху, события – от края до края ячейки */
  .grid { grid-auto-rows: 64px; }
  .cell { padding: 3px 0 0; }
  .cell .num { display: grid; width: max-content; font-size: 12px; min-width: 21px; height: 21px; padding: 0 3px; margin: 0 auto 2px; }
  .chips { gap: 1px; }
  .chip { font-size: 11px; line-height: 16px; padding: 0 3px; margin: 0 1px; border-radius: 3px; }
  .more { font-size: 10px; line-height: 14px; padding: 0 3px; text-align: center; }
  .chip.timed::before, .chip .t { display: none; }
  .chip.timed { background: color-mix(in srgb, var(--c) 18%, var(--card)); }
  .day { border-radius: 20px 20px 0 0; }
  .agenda { padding-bottom: 90px; }
  dialog.sheet {
    width: 100%; max-width: 100%; max-height: calc(100% - 40px); margin: auto 0 0; border-radius: 22px 22px 0 0;
  }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
  .sheet-body { padding-bottom: calc(18px + var(--safe-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::backdrop { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ================= оболочка: боковое меню + страницы ================= */
.shell { display: flex; height: 100%; }
.shell-main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; }
.shell-main > .app { height: auto; flex: 1; min-height: 0; }

.side {
  width: 232px; flex: none; display: flex; flex-direction: column; gap: 6px; padding: 14px 10px 14px 12px;
  transition: width .3s var(--spring); overflow: hidden;
}
/* отступы подобраны так, что звезда, иконки и аватар стоят в одном столбце – ровно по центру
   свёрнутого меню (68px): при сворачивании ничего не едет, только прячутся подписи */
.side-top { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 2px 0 11.5px; margin-bottom: 10px; }
.side-items { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-bottom { display: flex; flex-direction: column; gap: 2px; }
.side-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent;
  color: var(--ink-2); font-weight: 600; text-align: left; padding: 10px 12px; border-radius: 12px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.side-item svg { font-size: 21px; }
.side-item:hover { background: var(--fill); color: var(--ink); }
.side-item.on { background: var(--fill-strong); color: var(--ink); }
.side-item:active { transform: scale(.98); }
.side-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; margin-left: auto; font-style: normal;
}
.side-me { padding: 8px 10px 8px 7.5px; }
/* «Приложение для Windows» – как «Событие»: заливка кнопки на всю ширину; свёрнутое
   меню прячет подпись, иконка остаётся в общем столбце */
.side-app { background: var(--btn); color: var(--btn-text); text-decoration: none; margin: 4px 0; }
.side-app:hover { background: color-mix(in srgb, var(--btn) 86%, var(--bg)); color: var(--btn-text); }
.side-app svg { font-size: 19px; margin: 0 1px; }
/* подпись длинная: чуть мельче и плотнее, а на широком шрифте темы – многоточие, не обрезка */
.side-app { gap: 10px; padding-right: 8px; }
.side-app > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* сворачивание и тема – без подписей, подсветка по размеру иконки */
.side-fold, .side .theme-btn { width: 45px; justify-content: center; padding: 10px 0; }
.side-me-text { display: flex; flex-direction: column; min-width: 0; }
.side-me-text b { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.side-me-text small { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.avatar.small { width: 30px; height: 30px; font-size: 13px; flex: none; color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / 25%); }

/* свёрнутое меню – только иконки; на средних экранах – само */
.shell.folded .side { width: 68px; }
.shell.folded .side-item > span:not(.avatar), .shell.folded .side-top .brand span { display: none; }
.shell.folded .side-badge { position: absolute; top: 4px; right: 6px; }
@media (max-width: 1100px) and (min-width: 641px) {
  .side { width: 68px; }
  .side-item > span:not(.avatar), .side-top .brand span, .side-fold { display: none; }
  .side-item { justify-content: center; padding: 10px 0; }
  .side-top { justify-content: center; padding: 0; }
  .side-badge { position: absolute; top: 4px; right: 6px; }
}

/* меню рядом – лишнее из шапки календаря убираем */
@media (min-width: 641px) {
  .topbar .brand, .topbar > .theme-btn, .topbar > .avatar, #lists-btn { display: none; }
  .month-title { margin-left: 0; }
  .shell-main > .app { padding-left: 6px; }
}
@media (max-width: 640px) {
  .side { display: none; }
}

.banner {
  display: flex; align-items: center; gap: 10px; margin: 12px 18px 0 6px; padding: 6px 6px 6px 16px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 14px;
}
.banner span { flex: 1; }
.banner .icon-btn { color: inherit; }
@media (max-width: 640px) { .banner { margin: 10px 12px 0; } }
.auth-note { text-align: center; margin: 4px 8px 12px; font-size: 14px; }
#auth-form.reg-closed .field, #auth-form.reg-closed #auth-submit { display: none; }

/* ---------- страницы ---------- */
.page { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 40px 6px; }
.page-col { max-width: 900px; margin: 0 auto; }
.page-col.wide { max-width: 1200px; }
.page-head { display: flex; align-items: center; gap: 12px; min-height: 40px; margin: 0 0 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.025em; flex: 1; }
.page-back { display: none; }
.page-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
.hint { font-size: 13px; margin: 6px 6px 0; }
.pad { padding: 20px 8px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .06em; }
.nowrap { white-space: nowrap; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-left: 6px;
  background: var(--fill-strong); color: var(--ink-2); vertical-align: 2px; white-space: nowrap;
}
.tag.acc { background: var(--accent-soft); color: var(--accent-ink); }
.tag.bad { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.link-row { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; }
.link-row span { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; }
.link-row span svg { font-size: 19px; color: var(--ink-2); }
.link-row:hover span { color: var(--accent-ink); }
.group .row > small.muted { margin: 0; }
.inline-input.left { text-align: left; }
.btn svg { font-size: 16px; }

.prof-hero { display: flex; align-items: center; gap: 18px; padding: 20px; }
.prof-hero.flat { box-shadow: none; padding: 6px 4px 14px; background: transparent; }
.prof-hero .avatar.big { flex: none; color: #fff; text-shadow: 0 1px 3px rgb(0 0 0 / 25%); }
.prof-who { flex: 1; min-width: 0; }
.prof-tags { margin-top: 6px; }
.prof-tags:empty { display: none; }
.prof-tags .tag:first-child { margin-left: 0; }
.blocked-note { padding: 14px 18px; margin-top: 14px; border-left: 4px solid var(--danger); }
.sup-list .blocked-note { margin: 0 0 8px; }
.blocked-note p { margin: 4px 0 0; }
#logout { margin-top: 10px; }

@media (max-width: 900px) {
  .page-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page { padding: 10px 12px calc(30px + var(--safe-bottom)); }
  .page-back { display: grid; margin-left: -6px; }
  .page-head h1 { font-size: 22px; }
  .prof-hero { flex-direction: column; text-align: center; gap: 10px; padding: 18px 16px; }
  .prof-hero .prof-who { width: 100%; }
  .shell.blocked .page-back { display: none; }
}
html.in-tg .page-back { display: none; }

/* ---------- поддержка ---------- */
#page-support .page-col { height: 100%; display: flex; flex-direction: column; }
.sup { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; gap: 14px; }
.sup-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px 2px 10px; }
.sup-list .group-title { margin-top: 8px; }
.sup-list .group-title:first-child { margin-top: 0; }
.sup-item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; border: 0; text-align: left; padding: 12px;
  border-radius: var(--r-md); background: var(--card); box-shadow: var(--shadow); transition: background .15s, transform .12s;
}
.sup-item:hover { background: color-mix(in srgb, var(--fill) 60%, var(--card)); }
.sup-item.on { box-shadow: 0 0 0 2px var(--accent); }
.sup-item:active { transform: scale(.99); }
.sup-ic { width: 36px; height: 36px; flex: none; border-radius: 11px; background: var(--fill); display: grid; place-items: center; color: var(--ink-2); }
.sup-ic svg { font-size: 19px; }
.sup-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sup-top { display: flex; align-items: center; gap: 6px; }
.sup-top b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-top small { color: var(--ink-3); font-size: 12px; }
.sup-top .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sup-txt > small.muted { margin: 0; }
.sup-last { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-item.unread .sup-last { color: var(--ink); font-weight: 600; }
.sup-item .side-badge { margin-top: 8px; }
.sup-item .wait { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 14px; flex: none; }
.faq-edit-btn { margin-top: 8px; }
.sup-pane { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.sup-empty { margin: auto; text-align: center; padding: 30px; max-width: 360px; }
.sup-empty svg { font-size: 44px; color: var(--ink-3); }
.sup-empty p { margin: 10px 0 0; }

.faq { overflow-y: auto; padding: 18px 20px 24px; }
.faq h2 { margin: 0 0 4px; font-size: 20px; }
.faq .group { background: var(--card-2); }
.faq-item { border-top: 1px solid var(--line); }
.faq-item:first-child { border-top: 0; }
.faq-item summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 13px 0; font-weight: 600;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary svg { color: var(--ink-3); transition: transform .25s var(--spring); }
.faq-item[open] summary svg { transform: rotate(180deg); }
.faq-item ol { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); }
.faq-item li + li { margin-top: 4px; }
.faq-cta { text-align: center; margin-top: 24px; }
.faq-cta p { margin: 0 0 10px; }
.group textarea.faq-text { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 13px; min-height: 360px; }

.thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.thread-head small { display: block; }
.thread-head > div:not(.sup-ic), .th-title { flex: 1; min-width: 0; }
.thread-back { display: none; }
.faq .thread-head { padding: 0 0 12px; border: 0; }
.person {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; border: 0; text-align: left;
  background: var(--card-2); padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.person > span:nth-child(2) { flex: 1; min-width: 160px; display: flex; flex-direction: column; }
.person > span:nth-child(2) small { margin: 0; }
.person:hover { background: var(--fill); }
.th-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.m-date { align-self: center; font-size: 12px; color: var(--ink-3); background: var(--fill); padding: 3px 10px; border-radius: 99px; margin: 8px 0 4px; }
.msg { display: flex; align-items: flex-end; gap: 4px; max-width: 78%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--card-2); border-radius: 18px 18px 18px 6px; padding: 8px 12px 6px; min-width: 70px; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--accent-soft); border-radius: 18px 18px 6px 18px; }
.m-text { white-space: pre-wrap; }
.m-author { font-size: 12px; font-weight: 700; color: var(--accent-ink); margin-bottom: 2px; }
.m-time { display: block; text-align: right; font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.m-reply { border-left: 3px solid var(--accent); padding: 2px 8px; margin: 2px 0 6px; font-size: 13px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.m-reply b { display: block; color: var(--accent-ink); font-size: 12px; }
.m-img img { display: block; max-width: min(320px, 100%); max-height: 260px; border-radius: 12px; margin: 2px 0 4px; }
.m-file { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-ink); text-decoration: none; font-weight: 600; padding: 4px 0; }
.m-file small { color: var(--ink-3); font-weight: 500; }
.m-act { width: 30px; height: 30px; opacity: 0; transition: opacity .15s; }
.msg:hover .m-act { opacity: 1; }
@media (hover: none) { .m-act { opacity: .5; } }
.th-closed { text-align: center; padding: 14px; margin: 0; border-top: 1px solid var(--line); }
.composer { border-top: 1px solid var(--line); padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.tpl-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tpl-chips::-webkit-scrollbar { display: none; }
.tpl-chips .pill-btn { white-space: nowrap; }
.c-reply, .c-file { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 4px 4px 4px 10px;
  background: var(--fill); border-radius: 10px; }
.c-reply span, .c-file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-reply .icon-btn, .c-file .icon-btn { width: 28px; height: 28px; }
.c-row { display: flex; align-items: flex-end; gap: 6px; }
.c-row textarea {
  flex: 1; resize: none; border: 0; outline: none; background: var(--card-2); border-radius: 18px; padding: 9px 14px;
  max-height: 160px; line-height: 1.4;
}
.c-row textarea:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.c-attach { cursor: pointer; }
.c-send { background: var(--btn); color: var(--btn-text); }
.c-send:hover { background: color-mix(in srgb, var(--btn) 86%, var(--bg)); color: var(--btn-text); }

.topics { display: grid; gap: 8px; }
.topic {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; text-align: left; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--card); transition: box-shadow .15s;
}
.topic svg { font-size: 21px; color: var(--ink-2); }
.topic span { display: flex; flex-direction: column; }
.topic small.muted { margin: 0; }
.topic.on { box-shadow: 0 0 0 2px var(--accent); }
.topic.on svg { color: var(--accent-ink); }
.attach { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--r-md); background: var(--card);
  cursor: pointer; color: var(--ink-2); font-weight: 500; }
.attach:hover { color: var(--ink); }

@media (max-width: 900px) {
  .sup { grid-template-columns: 1fr; grid-template-rows: auto; }
  #page-support .page-col { height: auto; min-height: 100%; }
  .sup-list { overflow: visible; }
  .sup.threading .sup-list { display: none; }
  .sup-pane:has(.sup-empty) { display: none; }
  .sup.threading .sup-pane { height: calc(100dvh - 130px); }
  .thread-back { display: grid; }
  .msg { max-width: 90%; }
}

/* ---------- админка ---------- */
.adm-tabs { margin: 0 0 18px; display: inline-flex; flex-wrap: wrap; }
.adm-tabs button { padding: 7px 16px; }
.seg-badge { margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px;
  background: var(--danger); color: #fff; display: inline-grid; place-items: center; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--card); border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.tile.go { cursor: pointer; transition: transform .12s, background .15s; }
.tile.go:hover { background: color-mix(in srgb, var(--fill) 60%, var(--card)); }
.tile.go:active { transform: scale(.98); }
.tile small { color: var(--ink-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile b { font-size: 30px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile span { font-size: 13px; }
.adm-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
.kv .row b { font-weight: 600; text-align: right; }
.kv .row b small { font-weight: 500; }
.kv .row span { display: inline-flex; align-items: center; gap: 8px; }
.kv .row span svg { color: var(--ink-3); }
.kv .row.end { gap: 8px; }
.adm-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.adm-tools .search-box { flex: 1; min-width: 220px; max-width: 420px; background: var(--card); }
.ulist { display: flex; flex-direction: column; gap: 6px; }
.urow {
  display: flex; align-items: center; gap: 14px; width: 100%; border: 0; text-align: left; padding: 10px 14px;
  border-radius: var(--r-md); background: var(--card); box-shadow: var(--shadow); transition: background .15s;
}
.urow:hover { background: color-mix(in srgb, var(--fill) 60%, var(--card)); }
.urow .avatar.small { width: 36px; height: 36px; font-size: 15px; }
.u-main { flex: 1; min-width: 0; }
.u-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-num, .u-seen { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.u-num b { font-variant-numeric: tabular-nums; }
.u-num small, .u-seen small { margin: 0 !important; }
.u-seen { width: 130px; }
.adm-narrow { max-width: 640px; }
.code-box { display: inline-flex; align-items: center; gap: 6px; }
.code-box b { font-size: 16px; }
#set-max { max-width: 120px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.adm-log li > div { flex: 1; min-width: 0; }
.adm-log li > div small { display: block; }
.errs { display: flex; flex-direction: column; gap: 8px; }
.err summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.err summary::-webkit-details-marker { display: none; }
.err.done { opacity: .6; }
.err-hits { flex: none; min-width: 42px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); border-radius: 8px; padding: 3px 6px; }
.err.done .err-hits { background: var(--fill); color: var(--ink-2); }
.err-main { flex: 1; min-width: 0; }
.err-main b { display: block; overflow-wrap: anywhere; font-weight: 600; }
.err-main small { margin: 2px 0 0; }
.err-body { padding: 0 14px 10px; }
.err-trace { margin: 0; background: var(--card-2); border-radius: 10px; padding: 12px; font-size: 12px; overflow-x: auto;
  max-height: 340px; white-space: pre; font-family: ui-monospace, "SF Mono", Consolas, monospace; }
#user-dlg { width: min(560px, calc(100% - 32px)); }
#user-dlg .group textarea { min-height: 60px; }

@media (max-width: 900px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .adm-cols { grid-template-columns: 1fr; }
  .u-seen { display: none; }
}
@media (max-width: 640px) {
  .adm-tabs { display: flex; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .adm-tabs button { white-space: nowrap; }
  .tile b { font-size: 24px; }
  .u-num { display: none; }
}

/* ================= нижняя панель (как в Gremlin) =================
   Телефон и мини-приложение Telegram (там и с компьютера – как на телефоне).
   Стекло: полупрозрачная пилюля с размытием, под ней полоса размытия,
   в которую уходит страница. Подсветка вкладки переезжает пружиной. */
html.use-tabs .side { display: none; }
html.use-tabs .topbar > .avatar, html.use-tabs #lists-btn { display: none; }
html.use-tabs .tabbar {
  position: fixed; z-index: 22; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + var(--safe-bottom));
  width: min(360px, calc(100% - 32px));
  display: flex; align-items: center; justify-content: space-between; padding: 7px;
  background: color-mix(in srgb, var(--card) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  border-radius: 999px;
  backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: 0 10px 30px rgb(0 0 0 / 18%);
}
.tab {
  position: relative; z-index: 1; flex: 1; height: 50px; border: 0; border-radius: 999px; background: none;
  display: grid; place-items: center; color: var(--ink); opacity: .6; font-size: 24px;
  transition: opacity .25s, transform .12s ease-out;
}
.tab:active { transform: scale(.92); }
.tab.on { opacity: 1; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab-me {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; font-size: 13px; line-height: 1; text-shadow: 0 1px 2px rgb(0 0 0 / 25%); background: var(--fill-strong);
}
.tab.on .tab-me { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.tab-dot {
  position: absolute; top: 9px; left: calc(50% + 7px); width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--card);
}
.tab-pill {
  position: absolute; left: 0; top: 7px; height: 50px; z-index: 0; pointer-events: none; border-radius: 999px;
  will-change: translate, scale;
  transition: translate .3s ease-out, scale .3s ease-out;
}
.tab-pill::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
}
.tab-pill[hidden] { display: none; }
.tabbar.still .tab-pill { transition: none; }
@media (prefers-reduced-motion: no-preference) {
  .tab-pill {
    transition-property: translate, scale;
    transition-duration: 420ms;
    transition-timing-function: linear(0, 0.025, 0.09, 0.181, 0.287, 0.4, 0.511, 0.616, 0.712,
      0.796, 0.867, 0.927, 0.973, 1.009, 1.035, 1.053, 1.063, 1.068, 1.068, 1.065, 1.059,
      1.052, 1.045, 1.037, 1.03, 1.023, 1.017, 1.011, 1.007, 1.003, 1);
  }
  .tab-pill.go-r::before { transform-origin: right center; animation: pill var(--pill-ms, 420ms) ease; }
  .tab-pill.go-l::before { transform-origin: left center; animation: pill var(--pill-ms, 420ms) ease; }
}
@keyframes pill {
  20% { scale: var(--s, 1.12) 1; }
  50% { scale: .92 1; }
  75% { scale: 1.02 1; }
}

/* Прогрессивное размытие у нижнего края: шесть слоёв, размытие растёт к краю
   вдвое, у каждого своя полоса маски, поверх – лёгкая заливка цветом фона */
.blur-edge { position: fixed; left: 0; right: 0; pointer-events: none; --dir: to bottom; }
.blur-edge > i { position: absolute; inset: 0; -webkit-mask-image: var(--m); mask-image: var(--m); }
.blur-edge > i:nth-child(1) { --m: linear-gradient(var(--dir), transparent 0%, #000 16.7%, #000 33.3%, transparent 50%);
  backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px); }
.blur-edge > i:nth-child(2) { --m: linear-gradient(var(--dir), transparent 16.7%, #000 33.3%, #000 50%, transparent 66.7%);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.blur-edge > i:nth-child(3) { --m: linear-gradient(var(--dir), transparent 33.3%, #000 50%, #000 66.7%, transparent 83.3%);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.blur-edge > i:nth-child(4) { --m: linear-gradient(var(--dir), transparent 50%, #000 66.7%, #000 83.3%, transparent 100%);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.blur-edge > i:nth-child(5) { --m: linear-gradient(var(--dir), transparent 66.7%, #000 83.3%, #000 100%);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.blur-edge > i:nth-child(6) { --m: linear-gradient(var(--dir), transparent 83.3%, #000 100%);
  backdrop-filter: blur(28px); -webkit-backdrop-filter: blur(28px); }
.blur-edge::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(var(--dir), transparent 30%, color-mix(in srgb, var(--bg) 72%, transparent)); }
html.use-tabs .tab-fade { display: block; bottom: 0; z-index: 21; height: calc(100px + var(--safe-bottom)); }

/* место под панель: страница уходит под стекло, но последнее не прячется */
html.use-tabs .shell-main > .app { padding-bottom: calc(84px + var(--safe-bottom)); }
html.use-tabs .page { padding-bottom: calc(110px + var(--safe-bottom)); }
html.use-tabs .agenda { padding-bottom: 30px; }
html.use-tabs .fab { bottom: calc(92px + var(--safe-bottom)); }
html.use-tabs .paintbar { bottom: calc(88px + var(--safe-bottom)); z-index: 23; }
html.use-tabs .toast { bottom: calc(100px + var(--safe-bottom)); }
html.use-tabs .sup.threading .sup-pane { height: calc(100dvh - 130px - 84px - var(--safe-bottom)); }
html.use-tabs #page-support .page-col { height: auto; min-height: 100%; }
/* выбор и кисть занимают низ – панель уступает им место */
html.use-tabs body:has(.app.picking) .tabbar, html.use-tabs body:has(.app.painting) .tabbar,
html.use-tabs body:has(.app.picking) .tab-fade, html.use-tabs body:has(.app.painting) .tab-fade { display: none; }
html.use-tabs body:has(.app.picking) .paintbar, html.use-tabs body:has(.app.painting) .paintbar {
  bottom: calc(18px + var(--safe-bottom)); }

/* страница появляется мягко */
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.page.enter > .page-col { animation: page-in .28s ease-out backwards; }
@media (prefers-reduced-motion: reduce) { .page.enter > .page-col { animation: none; } }
@media (max-width: 640px) { .adm-tools .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; } .adm-tools .seg button { white-space: nowrap; } }
/* Telegram с компьютера: меню нет – отступ слева как справа */
@media (min-width: 641px) { html.use-tabs .shell-main > .app, html.use-tabs .page { padding-left: 18px; } html.use-tabs .banner { margin-left: 18px; } }

/* Полный экран в Telegram: шапка календаря и страниц – ниже часов и кнопок Telegram */
.shell-main > .app { padding-top: calc(14px + var(--safe-top)); }
.page { padding-top: calc(14px + var(--safe-top)); }
.banner { margin-top: calc(12px + var(--safe-top)); }
.banner:not([hidden]) ~ .app, .banner:not([hidden]) ~ .page { padding-top: 14px; }
dialog.sheet { max-height: min(760px, calc(100% - 48px - var(--safe-top))); }
@media (max-width: 640px) {
  .shell-main > .app { padding-top: calc(10px + var(--safe-top)); }
  .page { padding-top: calc(10px + var(--safe-top)); }
  .banner { margin-top: calc(10px + var(--safe-top)); }
  .banner:not([hidden]) ~ .app, .banner:not([hidden]) ~ .page { padding-top: 10px; }
  dialog.sheet { max-height: calc(100% - 40px - var(--safe-top)); }
  .auth { padding-top: calc(16px + var(--safe-top)); }
}

/* ---------- фото профиля ---------- */
.avatar, .mini-av, .tab-me { overflow: hidden; }
.avatar img, .mini-av img, .tab-me img {
  width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit;
  pointer-events: none; user-select: none;
}
.has-photo { text-shadow: none; }
button.p-avatar { cursor: pointer; padding: 0; font-family: inherit; position: relative; }
button.p-avatar:active { transform: scale(.95); }
button.p-avatar::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: rgb(0 0 0 / 0%); transition: background .15s;
}
@media (hover: hover) { button.p-avatar:hover::after { background: rgb(0 0 0 / 18%); } }
button.p-avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (min-width: 641px) { dialog.crop-sheet { width: min(420px, calc(100% - 32px)); } }
.crop-stage {
  position: relative; width: min(340px, 100%); aspect-ratio: 1; margin: 4px auto 0; overflow: hidden;
  border-radius: var(--r-lg); background: #000; touch-action: none; cursor: grab; user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; will-change: transform; }
/* круг – то, что попадёт в аватар; вокруг затемнение */
.crop-stage::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 999px rgb(0 0 0 / 55%), inset 0 0 0 2px rgb(255 255 255 / 85%);
}
.crop-zoom { display: flex; align-items: center; gap: 10px; width: min(340px, 100%); margin: 14px auto 0; color: var(--ink-2); }
.crop-zoom svg { width: 18px; height: 18px; flex: none; }
.crop-zoom svg:last-child { width: 22px; height: 22px; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.crop-hint { text-align: center; }

/* Телефон с нижней панелью, как в Gremlin: содержимое уходит под стекло и
   размывается, внизу нет пустой чёрной полосы. В месяце листается вся
   страница (шапка, сетка, список дня), в неделе, дне и списках – свой
   прокручиваемый блок, но он тоже доходит до низа экрана. Отступ снизу –
   чтобы последнее не пряталось под панелью. */
@media (max-width: 640px) {
  html.use-tabs .shell-main > .app { padding-bottom: 0; }
  html.use-tabs .shell-main > .app.view-month:not(.lists-mode) { overflow-y: auto; overscroll-behavior: contain; }
  /* карточка дня тянется до низа экрана, даже когда день пустой */
  html.use-tabs .app.view-month:not(.lists-mode) .layout { flex: 1 0 auto; grid-template-rows: auto 1fr; }
  html.use-tabs .app.view-month:not(.lists-mode) .day { overflow: visible; }
  html.use-tabs .app.view-month:not(.lists-mode) .agenda {
    overflow: visible; flex: 1 0 auto; padding-bottom: calc(110px + var(--safe-bottom));
  }
  html.use-tabs .app.view-week .tview, html.use-tabs .app.view-day .tview { border-radius: 20px 20px 0 0; }
  html.use-tabs .tg-scroll { padding-bottom: calc(96px + var(--safe-bottom)); }
  html.use-tabs .nb-list, html.use-tabs .nb-doc { padding-bottom: calc(110px + var(--safe-bottom)); }
  html.use-tabs .lists-view .card { border-radius: 20px 20px 0 0; }
}

/* ================= вложения ================= */
/* фото и файлы в документе списка */
.nb-pm .nb-img, .nb-pm .nb-file { position: relative; margin: .6em 0; }
.nb-img {
  border-radius: 12px; overflow: hidden; background: var(--fill); cursor: zoom-in; width: 100%;
  max-height: 520px; display: block;
}
.nb-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nb-img.gone { aspect-ratio: auto !important; height: 60px; cursor: default; }
.nb-img.gone::after { content: "Фото удалили"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 13px; }
.nb-file, .ef-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  background: color-mix(in srgb, var(--ink) 5%, transparent); max-width: 420px; transition: background .15s;
}
.nb-file:hover, .ef-row:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.nb-file-ic {
  flex: none; width: 38px; height: 44px; border-radius: 7px; display: grid; place-items: center; font-size: 10px;
  font-weight: 800; letter-spacing: .02em; color: var(--accent-ink); background: var(--accent-soft);
}
.nb-file-meta { min-width: 0; display: flex; flex-direction: column; }
.nb-file-meta b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-file-meta small { color: var(--ink-3); font-size: 12px; }
.ProseMirror-selectednode.nb-img, .ProseMirror-selectednode.nb-file { box-shadow: 0 0 0 2px var(--accent); }
.nb-x, .ef-x {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0;
  display: grid; place-items: center; cursor: pointer; color: #fff; background: rgb(0 0 0 / 55%);
  backdrop-filter: blur(6px); opacity: 0; transition: opacity .15s;
}
.nb-x svg, .ef-x svg { font-size: 14px; }
.nb-pm[contenteditable="false"] .nb-x { display: none; }
.nb-img:hover .nb-x, .nb-file:hover .nb-x, .ef-tile:hover .ef-x, .ef-row:hover .ef-x, .nb-x:focus-visible { opacity: 1; }
.nb-file .nb-x, .ef-row .ef-x { position: static; margin-left: auto; flex: none; color: var(--ink-2); background: var(--fill); }
@media (hover: none) { .nb-x, .ef-x { opacity: .9; } }

/* вложения в заметке календаря: фото плиткой, файлы строками */
.ev-files { padding: 8px; }
.ev-files[hidden] { display: none; }
.ev-files-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ev-files-list:empty { display: none; }
.ev-files-list:not(:empty) + .ev-attach { margin-top: 8px; }
.ef-tile { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; background: var(--fill); cursor: zoom-in; }
.ef-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ef-row { width: 100%; max-width: none; }
.ef-tile.wait, .ef-row.wait { opacity: .6; cursor: default; }
.ev-attach { width: 100%; border: 0; background: none; color: var(--accent-ink); font: inherit; font-weight: 600; gap: 8px; justify-content: flex-start; cursor: pointer; }
.ev-attach[hidden] { display: none; }
.ev-attach svg { font-size: 18px; }
.ag .prog.clip { display: inline-flex; align-items: center; gap: 3px; }
.ag .prog.clip svg { font-size: 12px; }

/* просмотр фото: по центру, фон затемнён, как у карточки события */
dialog.photo-dlg {
  border: 0; padding: 0; background: none; max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh;
  overflow: hidden; color: #fff;
}
dialog.photo-dlg[open] { display: grid; place-items: center; animation: photo-in .32s var(--spring); }
dialog.photo-dlg.closing { animation: photo-out .18s ease-in forwards; }
dialog.photo-dlg::backdrop { background: rgb(0 0 0 / 72%); backdrop-filter: blur(6px); }
.photo-dlg img {
  max-width: min(94vw, 1600px); max-height: calc(100dvh - 120px); border-radius: 10px; object-fit: contain;
  box-shadow: 0 20px 60px rgb(0 0 0 / 45%); background: rgb(255 255 255 / 4%);
}
.photo-bar { position: fixed; top: calc(14px + var(--safe-top, 0px)); right: 14px; display: flex; gap: 8px; z-index: 1; }
.photo-bar .icon-btn { width: 40px; height: 40px; color: #fff; background: rgb(255 255 255 / 14%); backdrop-filter: blur(10px); text-decoration: none; }
.photo-bar .icon-btn:hover { background: rgb(255 255 255 / 24%); }
.photo-name {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom, 0px)); translate: -50% 0; margin: 0; max-width: 80vw;
  font-size: 13px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes photo-in { from { opacity: 0; transform: scale(.94); } }
@keyframes photo-out { to { opacity: 0; transform: scale(.97); } }

/* ---------- год ---------- */
.yview { overflow: hidden auto; padding: 16px 18px; }
.yv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 22px; }
.yv-name { border: 0; background: none; color: var(--ink); font: inherit; font-weight: 700; font-size: 16px; padding: 2px 4px;
  margin: 0 0 4px; border-radius: 8px; cursor: pointer; }
.yv-name:hover { background: var(--fill); }
.yv-m.cur .yv-name { color: var(--accent-ink, var(--accent)); }
.yv-wd, .yv-days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.yv-wd i { font-style: normal; font-size: 10px; color: var(--ink-3); padding-bottom: 2px; }
.yv-d {
  position: relative; border: 0; background: none; color: var(--ink); font: inherit; font-size: 12px; line-height: 1;
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; cursor: pointer; font-variant-numeric: tabular-nums;
  font-weight: 500; min-width: 0; padding: 0;
}
.yv-d:hover { background: var(--fill); }
.yv-d.marked { background: color-mix(in srgb, var(--m) 30%, transparent); }
.yv-d.today { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 700; }
.yv-d i { position: absolute; bottom: 8%; left: 50%; translate: -50% 0; width: 4px; height: 4px; border-radius: 50%; background: var(--c); }
@media (max-width: 1100px) { .yv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .yview { border-radius: 20px; padding: 12px; }
  .yv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .yv-d { font-size: 11px; }
}
html.use-tabs .app.view-year .layout { grid-template-rows: auto 1fr; }

/* Неделя и день на широком экране: панель дня уезжает вправо, календарь
   пружиной вытягивается на её место. В Telegram и на телефоне панель под
   календарём – там как было */
@media (min-width: 901px) {
  html:not(.use-tabs) .layout {
    transition: grid-template-columns .6s linear(0, 0.157, 0.438, 0.68, 0.851, 0.956, 1.013, 1.037, 1.04, 1.033, 1.022, 1.012, 1.004, 1, 0.998, 0.998, 1),
                column-gap .6s var(--spring);
    overflow: clip; overflow-clip-margin: 24px;
  }
  html:not(.use-tabs) .layout .day { min-width: 340px; transition: transform .5s var(--spring), opacity .3s, filter .3s; }
  html:not(.use-tabs) .app.view-week .layout, html:not(.use-tabs) .app.view-day .layout { grid-template-columns: 1fr 0px; column-gap: 0; }
  html:not(.use-tabs) .app.view-week .day, html:not(.use-tabs) .app.view-day .day {
    display: flex; transform: translateX(40px); opacity: 0; filter: blur(6px); pointer-events: none; visibility: hidden;
    transition: transform .5s var(--spring), opacity .3s, filter .3s, visibility 0s .5s;
  }
}

/* кнопку поддержки внизу можно убрать – ширина панели по числу кнопок */
html.use-tabs .tabbar { width: min(calc(90px * var(--tabs, 4)), calc(100% - 32px)); }
html:not(.use-tabs) #p-suptab-row { display: none; }

/* подпись под группой – вровень с текстом строк */
#list-meta { margin: -6px 14px 14px; }
#list-meta:empty { display: none; }

/* календарь списка – плашка у скрепки, поверх неё прозрачный системный выбор */
.nb-calpick { position: relative; display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 40%;
  height: 32px; padding: 0 10px; border-radius: 999px; background: var(--fill); color: var(--ink-2); font-size: 13px; cursor: pointer; }
.nb-calpick[hidden] { display: none; }
.nb-calpick:hover { color: var(--ink); }
.nb-calpick span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.nb-calpick svg { flex: none; width: 14px; height: 14px; }
.nb-calpick .nb-cal-chev { width: 11px; height: 11px; opacity: .7; }
.nb-calpick select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.nb-calpick.ro { cursor: default; }
.nb-calpick.ro .nb-cal-chev { display: none; }
.nb-calpick.ro select { pointer-events: none; }

/* ---------- календарь, в котором человек сейчас ---------- */
.cal-dot { flex: none; width: 12px; height: 12px; margin: 0 4px; border-radius: 50%; background: var(--c); }
.month-title .space-tag { display: inline-flex; align-items: center; gap: 5px; margin-left: 10px; vertical-align: 4px;
  font-size: 13px; font-weight: 600; letter-spacing: 0; color: var(--ink-2); }
.month-title .space-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sc); }
.space-dot { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--sc); pointer-events: none; }
.space-dot[hidden] { display: none; }
.space-dot.all { background: conic-gradient(#f5c84b, #7fd08a, #63b8f0, #a58cf5, #f07a8c, #f5c84b); }
#tabbar .tab { position: relative; -webkit-touch-callout: none; user-select: none; }
#tabbar .space-dot { top: 9px; left: calc(50% + 9px); box-shadow: 0 0 0 2px color-mix(in srgb, var(--card) 80%, transparent); }
.side-item[data-page] { position: relative; }
.side-item .space-dot { left: 26px; top: 9px; box-shadow: 0 0 0 2px var(--bg); }

.space-pop {
  position: fixed; z-index: 60; width: 270px; max-height: min(70vh, 520px); overflow: auto; padding: 6px; border-radius: 18px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: 0 16px 40px rgb(0 0 0 / 28%);
}
.space-pop[hidden] { display: none; }
.sp-row { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--ink);
  font: inherit; text-align: left; padding: 8px 10px; border-radius: 12px; cursor: pointer; }
.sp-row:hover { background: var(--fill); }
.sp-t { flex: 1; min-width: 0; }
.sp-t b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-t small { display: block; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-dot { flex: none; width: 12px; height: 12px; margin: 0 5px; border-radius: 50%; background: var(--c); }
.sp-ic { flex: none; width: 22px; height: 22px; display: grid; place-items: center; color: var(--ink-2); }
.sp-ic svg { width: 18px; height: 18px; }
.sp-ok { flex: none; width: 16px; height: 16px; color: var(--accent); opacity: 0; }
.sp-row.on .sp-ok { opacity: 1; }
.sp-manage .sp-t b { font-weight: 500; color: var(--ink-2); }
.sp-sep { height: 1px; margin: 4px 10px; background: var(--line); }
.sp-layers { padding: 0 6px 4px 40px; }
.sp-layer { display: flex; align-items: center; gap: 9px; padding: 5px 4px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.sp-layer span:last-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-layer input { position: absolute; opacity: 0; pointer-events: none; }
.sp-box { flex: none; width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px var(--c); color: transparent; transition: background .15s, color .15s; }
.sp-box svg { width: 12px; height: 12px; }
.sp-layer input:checked + .sp-box { background: var(--c); color: #fff; }
.sp-layer input:focus-visible + .sp-box { outline: 2px solid var(--accent); outline-offset: 2px; }

/* корзина дня – справа в шапке панели дня */
.day-head .day-clear { margin-left: auto; align-self: flex-start; color: var(--ink-3); }
.day-head .day-clear:hover { color: var(--danger, #e5534b); }
.day-clear[hidden] { display: none; }

@media (max-width: 640px) {
  .view-pop { padding: 4px; }
  .view-pop .view-seg button { padding: 7px 9px; font-size: 14px; }
  .vp-today { padding: 7px 9px; margin-right: 4px; font-size: 14px; }
}
/* на телефоне рядом с годом мало места – только точка цвета календаря */
@media (max-width: 640px) {
  .month-title .space-tag { font-size: 0; gap: 0; margin-left: 8px; }
}

/* тост – popover в верхнем слое: снимаем стандартные рамку, отступы и центровку */
.toast[popover] { top: auto; right: auto; margin: 0; border: 0; overflow: visible; }
.toast[popover]:not(:popover-open) { display: none; }

/* ---------- свои темы ---------- */
/* своя тема: светлая или тёмная задана ей самой – кнопки день/ночь нет */
html[data-custom] .theme-btn { display: none !important; }

.tp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px 12px;
  padding: 14px 0 16px; border-top: 1px solid var(--line); }
.tp-item { position: relative; min-width: 0; }
.tp-card { display: block; width: 100%; border: 0; background: none; padding: 0; color: var(--ink-2); text-align: center;
  transition: transform .15s ease-out; }
.tp-card:active { transform: scale(.96); }
.tp-card .tp-mini { height: 98px; transition: box-shadow .2s ease; }
.tp-card.on .tp-mini { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.tp-name { display: block; margin-top: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-card.on .tp-name { color: var(--ink); }
.tp-new .tp-mini { display: grid; place-items: center; background: var(--fill); color: var(--ink-3); font-size: 26px;
  box-shadow: inset 0 0 0 1.5px var(--fill-strong); }
.tp-edit { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: rgb(0 0 0 / 42%); color: #fff; font-size: 15px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: transform .12s ease-out; }
.tp-edit:active { transform: scale(.9); }

/* мини-календарь в цветах темы: --t-* ставит app.js у каждой карточки */
.tp-mini { position: relative; overflow: hidden; border-radius: 14px; padding: 8px; text-align: left;
  background: var(--t-bg); color: var(--t-ink); font-family: var(--t-font, var(--font-sys));
  box-shadow: 0 0 0 1px var(--line); }
.tm-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 2px 6px;
  font-size: 12px; font-weight: 700; line-height: 1; }
.tm-head i { width: 22px; height: 8px; border-radius: 4px; background: var(--t-acc); }
.tm-cal { background: var(--t-card); border-radius: 9px; padding: 4px 3px 3px; box-shadow: 0 0 0 1px var(--t-line); }
.tm-wd, .tm-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.tm-wd { font-size: 8px; font-weight: 600; color: var(--t-ink3); line-height: 12px; }
.tm-grid { isolation: isolate; }
.tm-grid span { position: relative; font-size: 10px; line-height: 18px; }
.tm-grid .now { color: var(--t-on); font-weight: 700; }
.tm-grid .now::before { content: ""; position: absolute; z-index: -1; top: 50%; left: 50%; width: 17px; height: 17px;
  margin: -8.5px 0 0 -8.5px; border-radius: 50%; background: var(--t-acc); }
.tm-grid .ev::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: 1px; height: 2px; border-radius: 2px;
  background: var(--t-acc); opacity: .7; }
.tp-mini.big { padding: 14px; border-radius: 18px; }
.tp-mini.big .tm-head { font-size: 18px; margin-bottom: 10px; }
.tp-mini.big .tm-head i { width: 34px; height: 12px; border-radius: 6px; }
.tp-mini.big .tm-cal { border-radius: 12px; padding: 6px 4px 4px; }
.tp-mini.big .tm-wd { font-size: 11px; line-height: 20px; }
.tp-mini.big .tm-grid span { font-size: 14px; line-height: 30px; }
.tp-mini.big .tm-grid .now::before { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
.th-preview { margin: 4px 0 14px; }

.th-color { position: relative; cursor: pointer; }
.th-color input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.th-color i { width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgb(127 127 127 / 35%); }
#th-own { display: grid; gap: 10px; }
#th-own .btn svg { font-size: 18px; }

/* выбор шрифта: popover в верхнем слое */
.font-pop { position: fixed; inset: auto; margin: 0; padding: 6px; border: 0; border-radius: 18px;
  width: min(340px, calc(100vw - 24px)); max-height: min(460px, calc(100dvh - 24px));
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-pop), 0 0 0 1px var(--line); overflow: hidden; }
.font-pop:popover-open { display: flex; flex-direction: column; }
.fp-search { display: flex; align-items: center; gap: 8px; margin: 2px 2px 6px; padding: 9px 11px; border-radius: 12px;
  background: var(--fill); color: var(--ink-3); }
.fp-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--ink); }
.fp-search input::-webkit-search-cancel-button { display: none; }
.fp-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.fp-head { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.fp-row { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--ink);
  text-align: left; padding: 9px 10px; border-radius: 10px; }
.fp-row:hover { background: var(--fill); }
.fp-row b { flex: 1; min-width: 0; font-size: 17px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-row small { flex: none; font: 11px/1 var(--font-sys); color: var(--ink-3); }
.fp-row.on b { color: var(--accent-ink); }
.fp-row .fp-ok { flex: none; width: 16px; height: 16px; color: var(--accent); opacity: 0; }
.fp-row.on .fp-ok { opacity: 1; }
.fp-del { flex: none; width: 26px; height: 26px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: none; color: var(--ink-3); font-size: 14px; }
.fp-del:hover { background: var(--fill-strong); color: var(--danger); }
.fp-empty { padding: 18px 10px; text-align: center; font-size: 14px; color: var(--ink-3); }
.fp-upload { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 12px 10px; border: 0;
  border-top: 1px solid var(--line); background: none; color: var(--accent-ink); font-weight: 600; text-align: left; }
.fp-upload svg { font-size: 18px; }

/* виджет рабочего стола (только в программе для Windows) */
#p-widget-op { width: 140px; accent-color: var(--accent); }
