/* БроньБлок — дизайн.
   Цвета в два слоя: палитра (--c-*, светлая/тёмная по классу .dark) → смысловые токены (--bg, --text, …).
   В Telegram (класс .tg) смысловые токены берутся из темы Telegram, палитра остаётся запасным вариантом. */

:root {
  --c-bg: #f2f3f7;
  --c-surface: #ffffff;
  --c-text: #0f172a;
  --c-text-2: #475569;
  --c-hint: #8a94a6;
  --c-accent: #3b6cf6;
  --c-accent-text: #ffffff;
  --c-danger: #e5484d;
  --c-free: #12a150;
  --c-busy: #e5484d;
  --c-warn: #dd7a00;
  --shadow-1: 0 1px 2px rgb(15 23 42 / .04), 0 2px 8px rgb(15 23 42 / .05);
  --shadow-2: 0 18px 44px rgb(15 23 42 / .16), 0 2px 8px rgb(15 23 42 / .08);
  --hl-keyword: #cf222e; --hl-string: #0a3069; --hl-number: #0550ae; --hl-comment: #6e7781;
  --hl-title: #8250df; --hl-attr: #0550ae; --hl-builtin: #953800; --hl-tag: #116329; --hl-meta: #6e7781;
  color-scheme: light;
}

:root.dark {
  --c-bg: #0d0f13;
  --c-surface: #171a21;
  --c-text: #e8ebf0;
  --c-text-2: #a4acb9;
  --c-hint: #6f7887;
  --c-accent: #5b82ff;
  --c-accent-text: #ffffff;
  --c-danger: #ff6369;
  --c-free: #3dd68c;
  --c-busy: #ff6369;
  --c-warn: #ffa94d;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .35);
  --shadow-2: 0 18px 44px rgb(0 0 0 / .6);
  --hl-keyword: #ff7b72; --hl-string: #a5d6ff; --hl-number: #79c0ff; --hl-comment: #8b949e;
  --hl-title: #d2a8ff; --hl-attr: #79c0ff; --hl-builtin: #ffa657; --hl-tag: #7ee787; --hl-meta: #8b949e;
  color-scheme: dark;
}

/* Monokai: классическая тёмная (фон #272822, розовый/зелёный/жёлтый/голубой) и светлая — тёплая «бумага»
   с теми же акцентами, притемнёнными ради контраста. Классы ставит applyTheme() в app.js. */
:root.theme-monokai {
  --c-bg: #1f201b;
  --c-surface: #272822;
  --c-text: #f8f8f2;
  --c-text-2: #cfcfc2;
  --c-hint: #8f8b72;
  --c-accent: #66d9ef;
  --c-accent-text: #1f201b;
  --c-danger: #f92672;
  --c-free: #a6e22e;
  --c-busy: #f92672;
  --c-warn: #fd971f;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 18px 44px rgb(0 0 0 / .6);
  --hl-keyword: #f92672; --hl-string: #e6db74; --hl-number: #ae81ff; --hl-comment: #75715e;
  --hl-title: #a6e22e; --hl-attr: #a6e22e; --hl-builtin: #66d9ef; --hl-tag: #f92672; --hl-meta: #75715e;
  color-scheme: dark;
}
:root.theme-monokai-light {
  --c-bg: #f3f1ea;
  --c-surface: #fdfcf8;
  --c-text: #272822;
  --c-text-2: #56554a;
  --c-hint: #8f8c7c;
  --c-accent: #0a7c98;
  --c-accent-text: #ffffff;
  --c-danger: #d81b60;
  --c-free: #5b9a00;
  --c-busy: #d81b60;
  --c-warn: #d97706;
  --shadow-1: 0 1px 2px rgb(60 50 20 / .06), 0 2px 8px rgb(60 50 20 / .07);
  --shadow-2: 0 18px 44px rgb(60 50 20 / .16), 0 2px 8px rgb(60 50 20 / .08);
  --hl-keyword: #d81b60; --hl-string: #8f7f00; --hl-number: #7e57c2; --hl-comment: #9a978a;
  --hl-title: #4f8a00; --hl-attr: #4f8a00; --hl-builtin: #0f8bab; --hl-tag: #d81b60; --hl-meta: #9a978a;
  color-scheme: light;
}

:root {
  --bg: var(--c-bg);
  --surface: var(--c-surface);
  --text: var(--c-text);
  --text-2: var(--c-text-2);
  --hint: var(--c-hint);
  --accent: var(--c-accent);
  --accent-text: var(--c-accent-text);
  --link: var(--c-accent);
  --danger: var(--c-danger);
  --free: var(--c-free);
  --busy: var(--c-busy);
  --warn: var(--c-warn); /* поломки */
  /* запасные значения для старых WebView без color-mix */
  --border: rgb(128 128 128 / .2);
  --surface-2: rgb(128 128 128 / .08);
  --bg-2: rgb(128 128 128 / .12);
  --accent-soft: rgb(59 108 246 / .12);
  --free-soft: rgb(18 161 80 / .12);
  --busy-soft: rgb(229 72 77 / .12);
  --warn-soft: rgb(221 122 0 / .14);
  --glass: var(--surface);
  --radius: 18px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-h: 56px;
  --tabbar-h: 58px;
}

:root.tg {
  --bg: var(--tg-theme-secondary-bg-color, var(--c-bg));
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--c-surface)));
  --text: var(--tg-theme-text-color, var(--c-text));
  --text-2: var(--tg-theme-subtitle-text-color, var(--tg-theme-hint-color, var(--c-text-2)));
  --hint: var(--tg-theme-hint-color, var(--c-hint));
  --accent: var(--tg-theme-button-color, var(--c-accent));
  --accent-text: var(--tg-theme-button-text-color, var(--c-accent-text));
  --link: var(--tg-theme-link-color, var(--c-accent));
  --danger: var(--tg-theme-destructive-text-color, var(--c-danger));
}

@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --border: color-mix(in srgb, var(--text) 10%, transparent);
    --surface-2: color-mix(in srgb, var(--text) 5%, var(--surface));
    --bg-2: color-mix(in srgb, var(--text) 7%, var(--bg));
    --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
    --free-soft: color-mix(in srgb, var(--free) 15%, transparent);
    --busy-soft: color-mix(in srgb, var(--busy) 14%, transparent);
    --warn-soft: color-mix(in srgb, var(--warn) 16%, transparent);
    --glass: color-mix(in srgb, var(--surface) 86%, transparent);
  }
}

/* ---------- основа ---------- */
*, *::before, *::after { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.15; font-weight: 750; letter-spacing: -.025em; }
h2 { font-size: 18px; line-height: 1.25; font-weight: 700; letter-spacing: -.015em; }
button, input, select, textarea { font: inherit; color: inherit; }
pre, code { font-family: var(--mono); }
pre code { font: inherit; } /* иначе у <code> свой системный monospace (Courier без кириллицы) */
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
a { color: var(--link); text-decoration: none; }
b { font-weight: 650; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.hint { font-size: 13px; color: var(--hint); line-height: 1.4; }
.center { text-align: center; }
.pre { white-space: pre-line; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.contents { display: contents; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: var(--radius-sm);
  font-weight: 650; font-size: 15px; white-space: nowrap; user-select: none;
  transition: transform .12s, background-color .15s, opacity .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn .i { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-ok { background: var(--free); color: #fff; }
.dark .btn-warn, .dark .btn-ok { color: #111317; } /* в тёмной теме эти цвета светлые — белый текст не читается */
.btn.danger { color: var(--danger); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { height: 50px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 10px; color: var(--text-2);
  transition: background-color .15s;
}
.link { color: var(--link); font-size: 14px; font-weight: 500; }
@media (hover: hover) {
  .btn-primary:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
  .btn-soft:hover, .btn-ghost:hover { filter: brightness(.97); }
  .icon-btn:hover { background: var(--surface-2); }
  .link:hover { text-decoration: underline; }
}

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-2); border-radius: 12px; }
.segmented button {
  height: 30px; padding: 0 12px; border-radius: 9px;
  font-size: 13px; font-weight: 650; color: var(--text-2);
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 550;
  border: 1.5px solid transparent; transition: background-color .15s, color .15s, border-color .15s;
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700; line-height: 1.6;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.muted-badge { background: var(--surface-2); color: var(--hint); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--person, var(--accent)); color: #fff;
  font-size: 14px; font-weight: 700; letter-spacing: .02em; line-height: 1;
}
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.xs { width: 22px; height: 22px; font-size: 10px; }
.avatar.xl { width: 96px; height: 96px; font-size: 34px; }
.avatar { background-size: cover; background-position: center; }
.avatar.emoji { font-size: 21px; }
.avatar.sm.emoji { font-size: 18px; }
.avatar.xs.emoji { font-size: 13px; }
.avatar.xl.emoji { font-size: 56px; }

/* ---------- поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.label i { font-style: normal; font-weight: 450; color: var(--hint); }
input:not([type=checkbox]), select, textarea {
  width: 100%; min-height: 46px; margin: 0; padding: 11px 14px;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 16px; /* 16px: иначе iOS зумит поле при фокусе */
  outline: none; appearance: none; -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--hint); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
input:disabled, select:disabled { opacity: .55; }
input::-webkit-date-and-time-value { text-align: left; }
input[type=date], input[type=time], input[type=datetime-local] { display: block; line-height: 22px; }
textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
select {
  cursor: pointer; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.field-row > .grow { flex: 2; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 500; background: var(--busy-soft); padding: 10px 12px; border-radius: 10px; }
.form-note { color: var(--text-2); font-size: 13px; }
.form-warn { color: var(--warn); font-size: 14px; font-weight: 500; background: var(--warn-soft); padding: 10px 12px; border-radius: 10px; }
.inc-chip {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 12px;
  background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 600; text-align: left;
}
.inc-chip .i { width: 18px; height: 18px; }
.phase.broken { background: var(--warn-soft); color: var(--warn); }
.phase.fixed { background: var(--free-soft); color: var(--free); }
.timeline { display: flex; flex-direction: column; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.tl-item { display: flex; gap: 10px; font-size: 14px; }
.tl-body { min-width: 0; overflow-wrap: anywhere; }
.tl-text { color: var(--text-2); }
.note-form { display: flex; flex-direction: column; gap: 10px; }
.chips-label { align-self: center; margin-right: 2px; }
.chip-sm { height: 30px; padding: 0 11px; font-size: 13px; }

.switch { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.feature-switch b { color: var(--text); font-weight: 650; }
.feature-switch + .feature-switch { margin-top: 12px; }
.switch input {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0;
  width: 46px; height: 28px; border-radius: 99px; background: var(--border); cursor: pointer;
  transition: background-color .2s;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:disabled { opacity: .5; }

/* ---------- загрузка, вход, «нет доступа» ---------- */
.splash { position: fixed; inset: 0; display: grid; place-items: center; }
.splash-logo { width: 56px; height: 56px; border-radius: 16px; animation: breathe 1.3s ease-in-out infinite; }
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 390px; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border-radius: 26px; padding: 30px 24px 24px; box-shadow: var(--shadow-2);
}
.auth-card.center { align-items: center; text-align: center; }
.auth-logo { width: 52px; height: 52px; border-radius: 15px; }
.auth-title { display: flex; flex-direction: column; gap: 6px; }
.auth-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.auth-icon.warn { background: var(--busy-soft); color: var(--busy); }
.auth-icon .i { width: 30px; height: 30px; }
.id-chip {
  display: inline-flex; align-items: center; gap: 12px; padding: 14px 20px; border-radius: 16px;
  background: var(--surface-2); font: 700 22px var(--mono); letter-spacing: .04em;
  transition: transform .12s;
}
.id-chip:active { transform: scale(.97); }
.id-chip .i { color: var(--accent); }

/* ---------- каркас ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 16px;
  background: var(--glass); backdrop-filter: saturate(1.5) blur(16px); -webkit-backdrop-filter: saturate(1.5) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; color: var(--text); letter-spacing: -.015em; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; }
.topnav { display: none; gap: 4px; }
.topnav a {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 650; font-size: 14px; transition: background-color .15s, color .15s;
}
.topnav a .i { width: 18px; height: 18px; }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
.zone-switch { margin-left: auto; flex: none; }
.zone-switch button { height: 28px; padding: 0 10px; }
.me { position: relative; }
.theme-pick { position: relative; }
.theme-menu { min-width: 250px; }
.menu-item.active { color: var(--accent); }
.menu-item .check { width: 18px; height: 18px; margin-left: auto; color: var(--accent); }
.swatch { position: relative; flex: none; width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }
.swatch i { position: absolute; right: 3px; bottom: 3px; width: 9px; height: 9px; border-radius: 50%; }
.theme-label { display: flex; flex-direction: column; line-height: 1.25; text-align: left; }
.theme-label small { font-size: 12px; }
@media (max-width: 400px) { .brand-text { display: none; } }
.me-btn { display: flex; align-items: center; gap: 8px; padding: 3px; border-radius: 999px; }
.me-name { display: none; font-weight: 650; font-size: 14px; }
.me-chev { display: none; width: 16px; height: 16px; color: var(--hint); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-2);
}
.menu-head { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 10px; font-weight: 550; }
.menu-note { padding: 8px 12px; font-size: 13px; color: var(--hint); }
@media (hover: hover) { .menu-item:hover { background: var(--surface-2); } }

.page {
  flex: 1; width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 92px);
}
.page--fill {
  flex: none; /* при flex: 1 высота бралась бы по содержимому, и календарь не прокручивался бы сам */
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--topbar-h)); min-height: 560px;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 10px);
}
.view { display: flex; flex-direction: column; gap: 14px; }
.view-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.view-head h1 { margin-right: auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--glass); backdrop-filter: saturate(1.5) blur(16px); -webkit-backdrop-filter: saturate(1.5) blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 650; color: var(--hint); transition: color .15s;
}
.tabbar button .i { width: 24px; height: 24px; }
.tabbar button.active { color: var(--accent); }
.tab-icon { position: relative; display: inline-flex; }
.nav-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px;
  border-radius: 999px; background: var(--busy); color: #fff; font-size: 11px; font-weight: 750; line-height: 1;
}
.tab-icon .nav-badge { position: absolute; top: -5px; right: -12px; margin: 0; box-shadow: 0 0 0 2px var(--surface); }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 15;
  display: grid; place-items: center; width: 58px; height: 58px; border-radius: 20px;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--accent) 40%, transparent), var(--shadow-1);
  transition: transform .12s;
}
.fab:active { transform: scale(.94); }
.fab .i { width: 26px; height: 26px; stroke-width: 2.4; }
.desktop-only { display: none !important; }

/* ---------- стенды ---------- */
.stands { flex: 1; min-height: 0; }
.strip {
  display: flex; gap: 10px; flex: none;
  margin: 0 -16px; padding: 2px 16px 6px;
  overflow-x: auto; scroll-snap-type: x proximity; scroll-padding: 0 16px; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.block-card {
  position: relative; flex: 0 0 150px; scroll-snap-align: start; overflow: hidden;
  display: flex; flex-direction: column; gap: 5px; padding: 12px 12px 13px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-1);
  transition: transform .12s, box-shadow .15s;
}
.block-card:active { transform: scale(.98); }
.bc-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.bc-name { font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.bc-until { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--busy); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--free); box-shadow: 0 0 0 3px var(--free-soft); }
.busy .dot { background: var(--busy); box-shadow: 0 0 0 3px var(--busy-soft); animation: beat 2.2s ease-in-out infinite; }
.bc-who { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: 14px; min-width: 0; }
.free-text { color: var(--free); }
.warn-text { color: var(--warn); }
.warn-btn { color: var(--warn); }
.bc-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.block-card.broken { box-shadow: inset 0 0 0 1.5px var(--warn), var(--shadow-1); }
.block-card.broken .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); animation: none; }
.bc-warn { width: 17px; height: 17px; margin-left: auto; color: var(--warn); }
.bc-problem { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; }
.bc-sub { font-size: 12px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--busy); border-radius: 0 3px 3px 0; opacity: .8; transition: width .6s; }
.skeleton, .skeleton-card, .skeleton-block, .skeleton-row {
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) !important;
  background-size: 300% 100% !important; animation: shimmer 1.3s linear infinite;
}
.skeleton > * { visibility: hidden; }
.skeleton-card { min-height: 230px; }
.skeleton-block { height: 320px; border-radius: var(--radius); }
.skeleton-row { height: 56px; border-radius: 12px; }

.cal-card {
  flex: 1; min-height: 340px; display: flex; flex-direction: column; overflow: hidden;
  margin: 0 -16px; background: var(--surface); border-radius: 0; box-shadow: var(--shadow-1);
}
.cal-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--border); flex: none; }
.cal-title {
  position: relative; display: inline-flex; align-items: center; gap: 4px; min-width: 0;
  padding: 6px 8px; border-radius: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; cursor: pointer;
}
.cal-title .i { width: 16px; height: 16px; color: var(--hint); }
.cal-title input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; opacity: 0; cursor: pointer; }
.today-btn { margin-left: auto; }
.cal-body { flex: 1; min-height: 0; }
#calendar { height: 100%; }

/* EventCalendar в наших цветах */
.ec {
  --ec-bg-color: var(--surface);
  --ec-text-color: var(--text);
  --ec-border-color: var(--border);
  --ec-today-bg-color: transparent;
  --ec-highlight-color: var(--accent-soft);
  --ec-now-indicator-color: var(--busy);
  --ec-event-bg-color: var(--accent);
  --ec-event-text-color: var(--accent-text);
  --ec-bg-event-color: var(--surface-2);
  --ec-popup-bg-color: var(--surface);
  --ec-event-col-gap: 3px;
  color-scheme: inherit;
  font-size: 12px;
}
.ec .ec-main { border: 0; }
.ec .ec-col-head { padding: 8px 2px; font-weight: 750; font-size: 13px; color: var(--text); }
.ec .ec-sidebar { color: var(--hint); font-size: 11px; font-variant-numeric: tabular-nums; }
.ec-time-grid .ec-sidebar { padding-inline: 8px 6px; }
.ec .ec-row-head { padding: 14px 12px; font-weight: 750; font-size: 13px; align-items: center; }
.ec-timeline .ec-sidebar { color: var(--text); }
/* «Неделя»: EventCalendar отдаёт всю лишнюю высоту последней строке — делим её поровну между блоками */
.ec-timeline .ec-main { grid-template-rows: max-content repeat(var(--bb-rows, 1), minmax(52px, 1fr)); }
.ec-timeline.ec-month-view .ec-col-group { display: none; } /* строка «сентябрь» над днями не нужна */
.ec-timeline .ev-who { flex: none; }
.ec-timeline .ev-what { flex: 1; min-width: 0; }
.ec .ec-event.bb-event {
  background: color-mix(in srgb, var(--person) 16%, var(--surface));
  color: var(--text); border-radius: 8px; padding: 4px 6px 4px 8px;
  box-shadow: inset 3px 0 0 var(--person); cursor: pointer; overflow: hidden;
}
.ec .ec-event.bb-event.is-mine { background: color-mix(in srgb, var(--person) 26%, var(--surface)); }
.ec .ec-event.bb-event.is-past { opacity: .55; }
.ec .ec-event.bb-event.is-broken { box-shadow: inset 3px 0 0 var(--person), inset 0 0 0 1.5px var(--warn); }
.ec .ec-bg-event.bb-incident { /* поломка: штриховка поверх колонки блока, брони видны над ней */
  opacity: 1; box-shadow: inset 0 2px 0 var(--warn);
  background: repeating-linear-gradient(-45deg, var(--warn-soft) 0 7px, transparent 7px 14px);
}
.inc-label { padding: 4px 6px; font-size: 11px; font-weight: 700; color: var(--warn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ec .ec-event.ec-preview { /* выделенный интервал, пока открыта форма новой брони */
  background: var(--accent-soft); color: var(--accent); border-radius: 8px;
  box-shadow: inset 0 0 0 1.5px var(--accent); opacity: 1;
}
.ec-list .ec-event.bb-event { background: transparent; box-shadow: none; border-radius: 0; padding: 10px 16px; }
.ec .ec-list .ec-day-head { padding: 8px 16px; font-weight: 700; font-size: 13px; color: var(--text-2); background: var(--surface-2); }
.ec .ec-no-events { color: var(--hint); font-size: 14px; }
.ec-timeline .ec-slot { color: var(--hint); font-size: 11px; }
.ec-timeline .ec-col-head { font-size: 12px; }
.ev { display: flex; flex-direction: column; gap: 1px; min-width: 0; overflow: hidden; line-height: 1.25; }
.ev > * { flex: none; } /* строки не сжимаются: лишнее обрезается снизу, а не сплющивает имя */
.ev-who { font-weight: 750; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-what { font-size: 12px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
.ev-when { font-size: 11px; color: var(--hint); } /* в узкой колонке переносится после тире: «23:00–» / «02:00» */
.ev-block { display: inline-block; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); font-weight: 750; font-size: 12px; }
.ec-list .ev, .ec-timeline .ev { flex-direction: row; align-items: center; gap: 6px; }
.ec-timeline .ev-when { color: var(--text-2); font-variant-numeric: tabular-nums; }
.ec-list .ev-who::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--person); }
.ec-list .ev-who, .ec-list .ev-what { font-size: 14px; }
.ev-time { min-width: 96px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ec-list .ec-event.bb-event.is-mine { background: color-mix(in srgb, var(--person) 8%, transparent); }
.ec-list .ev-what, .ec-timeline .ev-what { display: block; white-space: nowrap; text-overflow: ellipsis; }
.ec-list .ec-main { grid-template-columns: minmax(0, 1fr); } /* иначе колонка растягивается по самому длинному заголовку */
.ec-list .ev { width: 100%; min-width: 0; }
.ec-list .ev-time, .ec-list .ev-block, .ec-list .ev-who { flex: none; }
.ec-list .ev-what { flex: 1; min-width: 0; }

/* ---------- пасты ---------- */
.paste-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.paste-card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); color: var(--text);
  transition: transform .15s, box-shadow .15s;
}
.paste-card:active { transform: scale(.99); }
.pc-meta, .pv-meta { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; flex-wrap: wrap; }
.pc-author { font-weight: 650; }
.lang-badge {
  padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.pc-meta .lang-badge { margin-left: auto; }
.pc-title { font-weight: 700; font-size: 16px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--hint); }
.code {
  margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2);
  font: 12.5px/1.6 var(--mono); tab-size: 4; white-space: pre; overflow-x: auto;
}
.code-preview { max-height: 176px; overflow: hidden; }
.code-preview.faded { -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.back-link { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; margin-left: -6px; color: var(--link); font-weight: 650; }
.paste-view { display: flex; flex-direction: column; gap: 14px; }
.pv-head { display: flex; flex-direction: column; gap: 8px; }
.pv-head h1 { word-break: break-word; }
.pv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pv-actions .btn-ghost { background: var(--surface); box-shadow: var(--shadow-1); }
.code-view {
  display: grid; grid-template-columns: auto minmax(0, 1fr); overflow: hidden;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.code-view pre { margin: 0; padding: 14px 16px; font: 13px/1.6 var(--mono); }
.code-view .code { border-radius: 0; background: transparent; }
.gutter { text-align: right; color: var(--hint); user-select: none; background: var(--surface-2); border-right: 1px solid var(--border); padding-right: 12px !important; }
.code-input { min-height: 44vh; font: 13px/1.55 var(--mono) !important; tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto; }

/* подсветка кода — цвета из токенов, поэтому сама подстраивается под тему */
.hljs { color: var(--text); }
.hljs-keyword, .hljs-selector-tag, .hljs-type, .hljs-doctag, .hljs-template-tag { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-template-variable, .hljs-selector-attr { color: var(--hl-string); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--hl-number); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-title, .hljs-section { color: var(--hl-title); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-variable, .hljs-params, .hljs-selector-class, .hljs-selector-id { color: var(--hl-attr); }
.hljs-built_in, .hljs-meta .hljs-keyword { color: var(--hl-builtin); }
.hljs-name, .hljs-tag, .hljs-selector-pseudo { color: var(--hl-tag); }
.hljs-meta { color: var(--hl-meta); }
.hljs-addition { color: var(--hl-tag); background: var(--free-soft); }
.hljs-deletion { color: var(--hl-keyword); background: var(--busy-soft); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- журнал ---------- */
.hist-view { width: 100%; max-width: 820px; margin: 0 auto; }
.hist-title { display: flex; flex-direction: column; gap: 4px; margin-right: auto; }
.hist-filter { align-self: flex-start; }
.hist-day { display: flex; flex-direction: column; gap: 8px; }
.hist-day-title { padding: 0 4px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.hist-list { gap: 0; padding: 2px 16px; }
.hist-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.hist-item:last-child { border-bottom: 0; }
.hist-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.hist-head { display: flex; align-items: baseline; gap: 8px; }
.hist-who { flex: 1; min-width: 0; }
.hist-action { color: var(--text-2); }
.hist-time { flex: none; font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; }
.hist-text { font-size: 14px; }
.hist-note, .hist-change { font-size: 13px; color: var(--text-2); }
.hist-label { color: var(--hint); }
.hist-change s { color: var(--hint); }
.hist-more { align-self: center; }

/* ---------- чат ---------- */
.chat-view { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.chat-view.has-channel .chat-channels, .chat-view.has-thread .chat-main { display: none; } /* телефон: один экран за раз */
.chat-channels { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.channel-list { display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.channel { display: flex; align-items: center; gap: 6px; padding: 12px 12px; border-radius: 12px; color: var(--text-2); font-size: 16px; font-weight: 550; }
.channel.active { background: var(--accent-soft); color: var(--accent); }
.channel.unread { color: var(--text); font-weight: 750; }
.ch-hash { color: var(--hint); font-weight: 450; }
.ch-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-mention { margin-left: auto; color: var(--warn); font-weight: 800; }
.ch-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; display: grid; place-items: center; border-radius: 999px; background: var(--busy); color: #fff; font-size: 12px; font-weight: 750; }
.ch-mention + .ch-badge { margin-left: 6px; }
@media (hover: hover) { .channel:not(.active):hover { background: var(--surface-2); } }

.page--chat { padding-top: 0; } /* на телефоне чат встык к шапке */
.chat-channels .view-head { padding-top: 16px; }
.chat-pane { display: flex; flex-direction: column; min-height: 0; margin: 0 -16px; background: var(--surface); box-shadow: var(--shadow-1); overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 14px; border-bottom: 1px solid var(--border); flex: none; }
.chat-head h2 { font-size: 17px; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 0 14px; }
.chat-main .chat-scroll { background: var(--bg); } /* на фоне ленты плитки сообщений видны отчётливо */
.load-older { display: flex; margin: 8px auto; }
.day-divider, .thread-divider { display: flex; align-items: center; gap: 10px; margin: 14px 16px 4px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.day-divider::before, .day-divider::after, .thread-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.thread-divider { margin-top: 6px; color: var(--hint); }

.msg { position: relative; display: flex; gap: 10px; padding: 6px 16px; transition: background-color .12s; }
.msg.grouped { padding-top: 1px; padding-bottom: 1px; }
.msg.selected { background: var(--surface-2); }
.msg-side { flex: none; width: 34px; display: flex; justify-content: center; }
.msg-side .avatar { margin-top: 2px; }
.msg-side-time { visibility: hidden; padding-top: 3px; font-size: 10.5px; color: var(--hint); font-variant-numeric: tabular-nums; }
.msg.selected .msg-side-time { visibility: visible; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-head b { font-weight: 700; }
.msg-time { font-size: 12px; color: var(--hint); font-variant-numeric: tabular-nums; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
/* длинное сообщение свёрнуто до 260px (CLAMP_PX в app.js); класс .long ставит ResizeObserver */
.msg-text.long:not(.expanded) {
  max-height: 260px; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 64px), transparent); mask-image: linear-gradient(#000 calc(100% - 64px), transparent);
}
.more-btn { display: none; align-items: center; gap: 4px; margin-top: 4px; padding: 2px 0; font-size: 13.5px; font-weight: 650; color: var(--link); }
.msg-text.long ~ .more-btn { display: inline-flex; }
.more-btn .i { width: 16px; height: 16px; transition: transform .15s; }
.msg-text.expanded ~ .more-btn .i { transform: rotate(180deg); }
.msg-text.is-deleted { color: var(--hint); font-style: italic; }
.msg-text a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.chat-inline { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); font: .88em var(--mono); }
.chat-code { margin: 6px 0 2px; white-space: pre; font-size: 12.5px; }
.mention { padding: 0 3px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.mention.me { background: var(--warn-soft); color: var(--warn); }
.msg-edited { font-size: 12px; color: var(--hint); }
.msg-edit { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.msg-edit textarea { min-height: 44px; resize: none; }
.msg-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* лента канала — плитки: каждое сообщение отдельной карточкой, внизу всегда строка комментариев.
   Корень треда в панели комментариев — такая же плитка. */
.msg.tile, .msg.root {
  flex-wrap: wrap; row-gap: 0; margin: 10px 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-1);
}
.msg.tile.selected, .msg.root.selected { background: var(--surface); }
.msg.tile.open { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-1); }
.msg.tile .msg-actions, .msg.root .msg-actions { top: 8px; right: 8px; }
.msg-foot {
  display: flex; align-items: center; gap: 8px; flex: 0 0 calc(100% + 28px); min-width: 0; /* во всю ширину плитки */
  margin: 12px -14px -12px; padding: 10px 14px; border-top: 1px solid var(--border); border-radius: 0 0 15px 15px;
  font-size: 13.5px; color: var(--link); text-align: left;
}
.msg-foot:not(.has) { color: var(--text-2); }
.msg-foot b { font-weight: 650; white-space: nowrap; }
.msg-foot > .i { width: 18px; height: 18px; }
.foot-last { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--hint); }
.foot-chev { margin-left: auto; color: var(--hint); }
.msg.open .msg-foot { background: var(--accent-soft); color: var(--accent); }

.msg-actions {
  position: absolute; top: -16px; right: 14px; z-index: 2; display: none; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-1);
}
.msg.selected .msg-actions { display: flex; }
.msg-actions .icon-btn { width: 32px; height: 32px; }
.msg-actions .icon-btn .i { width: 18px; height: 18px; }
.msg-actions .icon-btn.danger { color: var(--danger); }
@media (hover: hover) {
  .msg:hover { background: var(--surface-2); }
  .msg.tile:hover, .msg.root:hover { background: var(--surface); }
  .msg-foot:hover { background: var(--surface-2); }
  .msg:hover .msg-actions { display: flex; }
  .msg:hover .msg-side-time { visibility: visible; }
}
.msg-wrap:first-child .msg-actions { top: 2px; }

.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.reaction {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px;
}
.reaction b { font-size: 12px; font-weight: 700; color: var(--text-2); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction.mine b { color: var(--accent); }
.reaction-picker {
  display: flex; flex-wrap: wrap; gap: 2px; width: max-content; max-width: 100%; margin-top: 6px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-2);
}
.reaction-picker button { width: 36px; height: 36px; border-radius: 10px; font-size: 19px; }
@media (hover: hover) { .reaction-picker button:hover { background: var(--surface-2); } }
.av-stack { display: inline-flex; }
.av-stack .avatar { margin-left: -5px; box-shadow: 0 0 0 2px var(--surface); }
.av-stack .avatar:first-child { margin-left: 0; }

.composer { position: relative; flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.composer textarea { min-height: 44px; max-height: 240px; resize: none; padding: 11px 16px; border-radius: 22px; line-height: 1.4; }
.send-btn { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-text); transition: opacity .15s, transform .12s; }
.send-btn:disabled { opacity: .35; }
.send-btn:active { transform: scale(.94); }
.send-btn .i { width: 20px; height: 20px; }
.mention-pop {
  position: absolute; left: 12px; right: 64px; bottom: calc(100% + 6px); z-index: 5; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-2);
}
/* большое поле (⤢): для длинных постов вроде дейли — занимает бо́льшую часть панели, на телефоне всю */
.expand-btn { width: 38px; height: 44px; color: var(--hint); }
.composer-head, .composer-foot { display: flex; align-items: center; gap: 10px; }
.composer-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-chip { flex: none; align-self: center; display: inline-flex; align-items: center; gap: 6px; }
.tpl-chip .i, .tpl-btn .i { width: 17px; height: 17px; }
.tpl-input { min-height: 300px; resize: vertical; line-height: 1.5; }
.composer-foot .muted { font-size: 12.5px; }
.composer.big { flex: 1 1 62%; flex-direction: column; align-items: stretch; }
.composer.big textarea { flex: 1; max-height: none; border-radius: 14px; }
.composer.big .mention-pop { bottom: 64px; right: 12px; }
.chat-main.composing .chat-scroll { flex: 1 1 38%; }
@media (max-width: 767px) { .chat-main.composing .chat-scroll { display: none; } }
.mention-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 10px; }
.mention-item.active { background: var(--accent-soft); }

.av-preview { display: flex; justify-content: center; padding: 4px 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.emoji-grid button { display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; font-size: 22px; background: var(--surface-2); border: 1.5px solid transparent; }
.emoji-grid button.active { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- админка ---------- */
.admin-grid { display: grid; gap: 14px; align-items: start; }
.admin-side { display: grid; gap: 14px; }
.panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin-bottom: 2px; }
.list { display: flex; flex-direction: column; margin: 0 -8px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 8px; border-radius: 12px; transition: background-color .15s; }
.row.dim { opacity: .5; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 650; }
.row-sub { font-size: 13px; color: var(--hint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 18px; height: 18px; color: var(--hint); }
.block-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; background: var(--surface-2); color: var(--text-2); }
.block-icon .i { width: 18px; height: 18px; }
.ttl-form { display: flex; align-items: center; gap: 10px; }
.ttl-form .ttl-input { width: 92px; text-align: center; font-weight: 700; }
.ttl-form .btn { margin-left: auto; }
@media (hover: hover) { .row:hover { background: var(--surface-2); } }

/* ---------- окна: шторка снизу на телефоне, окно по центру на компьютере ---------- */
dialog.sheet {
  width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; padding: 0;
  border: 0; border-radius: 24px 24px 0 0; overflow: hidden;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-2);
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .28s cubic-bezier(.2, .9, .3, 1); }
dialog.sheet::backdrop { background: rgb(8 10 16 / .45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); animation: fade .2s; }
.sheet-body { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px calc(20px + var(--safe-bottom)); }
.sheet-grip { flex: none; width: 40px; height: 5px; margin: 2px auto -4px; border-radius: 99px; background: var(--border); }
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet-head h2 { margin-right: auto; }
.push { margin-left: auto; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet-actions .btn { flex: 1 1 auto; }
.sheet-confirm .sheet-body { padding-top: 22px; }
.confirm-actions { display: flex; gap: 10px; margin-top: 4px; }
.confirm-actions .btn { flex: 1; height: 46px; }

.block-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.block-pick button {
  min-width: 58px; height: 42px; padding: 0 14px; border-radius: 12px;
  background: var(--surface-2); font-weight: 750; border: 1.5px solid transparent;
  transition: background-color .15s, color .15s, border-color .15s;
}
.block-pick button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.block-pick button:disabled { opacity: .35; cursor: default; }

.block-tag { padding: 4px 10px; border-radius: 9px; background: var(--surface-2); font-weight: 750; font-size: 14px; }
.phase { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.phase.live { background: var(--busy-soft); color: var(--busy); }
.phase.future { background: var(--accent-soft); color: var(--accent); }
.phase.past { background: var(--surface-2); color: var(--hint); }
.detail-title { font-size: 21px; line-height: 1.3; word-break: break-word; }
.detail-when { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; color: var(--text-2); }
.detail-when .i { width: 18px; height: 18px; color: var(--hint); }
.detail-desc { white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.person { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface-2); }
.person-main { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.person-name { font-weight: 700; }
.secret-box { display: grid; gap: 12px; padding: 16px; border-radius: 16px; background: var(--surface-2); }
.secret-box > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.secret-box code { font: 700 18px var(--mono); letter-spacing: .03em; user-select: all; word-break: break-all; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 16px; text-align: center; }
.empty .muted { max-width: 340px; }
.empty .btn { margin-top: 8px; }
.empty-icon { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 6px; border-radius: 22px; background: var(--accent-soft); color: var(--accent); }
.empty-icon .i { width: 30px; height: 30px; }

.toast {
  position: fixed; inset: auto; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 22px);
  z-index: 100; margin: 0; border: 0; width: max-content; max-width: min(92vw, 440px);
  padding: 12px 18px; border-radius: 14px; background: #1c2130; color: #fff;
  font-size: 14px; font-weight: 550; line-height: 1.35; text-align: center; box-shadow: var(--shadow-2);
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.dark .toast:not(.error) { background: #eef0f4; color: #0f172a; }

/* ---------- компьютер ---------- */
@media (min-width: 768px) {
  h1 { font-size: 28px; }
  .tabbar, .mobile-only { display: none !important; }
  .desktop-only { display: inline-flex !important; }
  .topbar { padding: 0 24px; gap: 20px; }
  .topnav { display: flex; }
  .me-btn { padding: 3px 10px 3px 3px; }
  .me-name, .me-chev { display: inline; }
  .page { padding: 24px 24px 48px; }
  .page--fill { padding-bottom: 20px; }
  .view { gap: 18px; }
  .strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin: 0; padding: 0; overflow: visible; }
  .block-card { padding: 14px 16px 15px; }
  .cal-card { margin: 0; border-radius: var(--radius); }
  .ec { font-size: 13px; }
  .paste-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
  .admin-grid { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); }
  .chat-view { grid-template-columns: 230px minmax(0, 1fr); gap: 16px; }
  .chat-view.has-thread { grid-template-columns: 230px minmax(0, 1fr) minmax(320px, 400px); }
  .chat-view.has-channel .chat-channels { display: flex; }
  .chat-view.has-thread .chat-main { display: flex; }
  .chat-pane { margin: 0; border-radius: var(--radius); }
  .page--chat { padding-top: 24px; }
  .chat-channels .view-head { padding-top: 0; }
  .chat-channels .view-head { min-height: 52px; }
  .toast { bottom: 28px; }
  dialog.sheet { width: 500px; max-width: calc(100vw - 32px); max-height: 88vh; margin: auto; border-radius: 24px; }
  dialog.sheet[open] { animation: pop-in .22s cubic-bezier(.2, .9, .3, 1); }
  dialog.sheet-wide { width: 820px; }
  dialog.sheet-confirm { width: 420px; }
  .sheet-grip { display: none; }
  .sheet-body { padding: 22px 24px 24px; }
  .code-input { min-height: 380px; }
  @media (hover: hover) {
    .block-card:hover, .paste-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
    .topnav a:not(.active):hover { background: var(--surface-2); color: var(--text); }
  }
}

@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(6px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes beat { 50% { box-shadow: 0 0 0 6px var(--busy-soft); } }
@keyframes breathe { 50% { transform: scale(.9); opacity: .6; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
