/* ============ токены ============ */
:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --surface-3: #eceee9;
  --border: #e3e5df;
  --border-strong: #d2d6cf;
  --text: #15171a;
  --text-2: #464b48;
  --muted: #7b817c;
  --accent: #1d7a52;
  --accent-hover: #186846;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1e9;
  --accent-soft-2: #c9e5d6;
  --done-bg: #f1f8f4;
  --done-border: #cfe6d8;
  --done-text: #4f6b5b;
  --warn: #a8570a;
  --warn-soft: #fdf0e1;
  --danger: #c0342b;
  --danger-soft: #fcebea;
  --bar: #e6e8e3;
  --shadow-sm: 0 1px 2px rgba(20, 24, 22, .05);
  --shadow: 0 1px 2px rgba(20, 24, 22, .04), 0 4px 16px rgba(20, 24, 22, .05);
  --shadow-lg: 0 12px 40px rgba(20, 24, 22, .16);
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --top-h: 60px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #111312;
    --surface: #1a1c1b;
    --surface-2: #202321;
    --surface-3: #272a28;
    --border: #2b2e2c;
    --border-strong: #3a3e3b;
    --text: #edefec;
    --text-2: #c3c7c3;
    --muted: #8d938e;
    --accent: #5cc08f;
    --accent-hover: #6fcb9d;
    --accent-ink: #0c1a13;
    --accent-soft: #1b3027;
    --accent-soft-2: #24402f;
    --done-bg: #16231c;
    --done-border: #284234;
    --done-text: #8db59e;
    --warn: #e9a35a;
    --warn-soft: #2f2418;
    --danger: #f0827a;
    --danger-soft: #3a1f1d;
    --bar: #2b2f2c;
    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ============ база ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ============ кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
  font-weight: 500; font-size: 14px; line-height: 1.2;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.btn.soft:hover { background: var(--accent-soft-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn.icon { width: 36px; min-height: 36px; padding: 0; }
.btn.icon.sm { width: 30px; min-height: 30px; }
.btn.block { width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ вход ============ */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 32px 28px 26px; box-shadow: var(--shadow);
}
.login-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin-bottom: 18px; }
.login-mark .i { width: 26px; height: 26px; stroke-width: 2.4; }
.login h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.login p { margin: 0 0 22px; color: var(--muted); }
.login .err { color: var(--danger); font-size: 14px; min-height: 21px; margin: 10px 0 0; }

/* ============ поля ============ */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .field-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
  font-size: 15px;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.field .hint { font-size: 12px; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============ каркас ============ */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.top {
  position: sticky; top: 0; z-index: 10; height: var(--top-h); flex: none;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.top-inner { height: 100%; display: flex; align-items: center; gap: 16px; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.brand-mark .i { width: 17px; height: 17px; stroke-width: 2.6; }
.top-title { display: none; font-weight: 700; font-size: 17px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 2px; background: var(--surface-3); padding: 3px; border-radius: 12px; }
.tab {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer;
  color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; display: flex; gap: 7px; align-items: center;
  transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); }
.tab .i { width: 16px; height: 16px; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.badge {
  font-size: 11px; font-weight: 700; line-height: 18px; min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-variant-numeric: tabular-nums; text-align: center;
}
.tab:not([aria-selected="true"]) .badge { background: var(--border-strong); color: var(--text-2); }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-weight: 600; font-size: 13px; margin-right: 4px; }
.user-name { margin-right: 4px; }

.offline { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 7px 16px; text-align: center; font-weight: 500; }

/* ============ сводка ============ */
.summary { display: flex; gap: 12px; padding: 16px 20px 4px; align-items: stretch; flex-wrap: wrap; }
.sum {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 16px; min-width: 170px; display: flex; flex-direction: column; gap: 2px;
}
.sum-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.sum-value { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.sum-value b { font-size: 24px; letter-spacing: -.02em; line-height: 1.2; }
.sum-value span { color: var(--muted); font-size: 14px; }
.sum .bar { margin-top: 6px; }
.sum.ok .sum-value b { color: var(--accent); }
.sum.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); flex-direction: row; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; max-width: 300px; }
.sum.warn .i { width: 22px; height: 22px; }
.summary-actions { margin-left: auto; display: flex; align-items: center; }

.bar { height: 6px; border-radius: 999px; background: var(--bar); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s ease; }

/* ============ чипы организаций ============ */
.orgbar { padding: 12px 0 0; }
.orgbar-inner { display: flex; gap: 8px; overflow-x: auto; padding: 0 20px 4px; scrollbar-width: none; }
.orgbar-inner::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 12px 5px 6px; cursor: pointer; font-size: 13px; font-weight: 500; max-width: 240px;
  transition: background .15s, border-color .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: none; }
.chip-dot .i { width: 13px; height: 13px; stroke-width: 2.8; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.chip.st-ok .chip-dot { background: var(--accent); color: var(--accent-ink); }
.chip.st-part .chip-dot { background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--bar) 0); }
.chip.st-part .chip-dot::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); }
.chip.st-empty .chip-dot { background: var(--warn-soft); color: var(--warn); }

/* ============ доска (десктоп) ============ */
.board {
  flex: 1; display: flex; gap: 16px; padding: 14px 20px 24px; overflow-x: auto; align-items: flex-start;
}
.col {
  flex: 0 0 360px; width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow); display: flex; flex-direction: column;
  max-height: calc(100vh - var(--board-offset, 230px)); max-height: calc(100dvh - var(--board-offset, 230px));
  min-height: 0; transition: box-shadow .3s, border-color .3s;
}
.col.flash { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.col-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); position: relative; flex: none; }
.col-titlebar { display: flex; align-items: flex-start; gap: 6px; }
.col-titlebar h2 { font-size: 17px; margin: 3px 0 0; flex: 1; line-height: 1.3; letter-spacing: -.01em; word-break: break-word; }
.note {
  display: flex; gap: 8px; margin-top: 10px; padding: 9px 11px; border-radius: var(--r-sm);
  background: var(--warn-soft); color: var(--text-2); font-size: 13px; line-height: 1.45;
}
.note .i { width: 16px; height: 16px; color: var(--warn); margin-top: 1px; }
.note div { white-space: pre-wrap; word-break: break-word; }
.open-link {
  display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm); text-decoration: none; color: var(--text);
  font-size: 14px; font-weight: 600; transition: background .15s, border-color .15s;
}
.open-link:hover { background: var(--surface-2); border-color: var(--border-strong); }
.open-link .host { flex: 1; min-width: 0; color: var(--muted); font-weight: 400; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.open-link .i { color: var(--accent); }

.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.plan { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px 9px; }
.plan-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.plan-top b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 14px; }
.plan.ok .plan-top b { color: var(--accent); }
.plan.ok .plan-top span::after { content: " ✓"; color: var(--accent); }
.col-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.stock { flex: 1; font-size: 12px; color: var(--muted); line-height: 1.4; }
.stock.low { color: var(--warn); font-weight: 500; }

/* меню ⋯ */
.menu {
  position: absolute; right: 12px; top: 50px; z-index: 6; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 6px; display: grid; animation: pop .14s ease-out;
}
.menu button {
  display: flex; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.menu button:hover:not(:disabled) { background: var(--surface-2); }
.menu button:disabled { opacity: .4; cursor: default; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ============ тексты ============ */
.texts { padding: 12px; overflow-y: auto; overflow-x: hidden; display: grid; gap: 10px; align-content: start; overscroll-behavior: contain; min-height: 0; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 26px 12px; display: grid; gap: 8px; justify-items: center; }
.empty .i { width: 28px; height: 28px; color: var(--accent); }

.txt {
  border: 1px solid var(--border); border-radius: var(--r); padding: 11px 12px 12px;
  background: var(--surface); transition: background .2s, border-color .2s;
}
.txt-meta { display: flex; align-items: center; gap: 4px; min-height: 22px; margin-bottom: 4px; }
.txt-no { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: auto; }
.txt-when { font-size: 12px; font-weight: 500; color: var(--done-text); margin-right: auto; display: flex; align-items: center; gap: 5px; }
.txt-when .i { width: 14px; height: 14px; stroke-width: 2.6; }
.txt-meta .btn.icon.sm { width: 26px; min-height: 26px; color: var(--muted); }
.txt-meta .btn.icon.sm .i { width: 15px; height: 15px; }
.txt-meta .btn.icon.sm.danger:hover { color: var(--danger); }
.txt-body { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.55; }
.txt-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.txt-actions .btn { min-height: 40px; }
.btn.copied { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.toggle .box {
  width: 18px; height: 18px; border-radius: 5px; border: 1.8px solid var(--border-strong);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.toggle .box .i { width: 13px; height: 13px; stroke-width: 3; opacity: 0; }
.toggle.nudge { border-color: var(--accent); }
.toggle.nudge .box { border-color: var(--accent); }

.txt.done { background: var(--done-bg); border-color: var(--done-border); }
.txt.done .txt-body { color: var(--done-text); }
.txt.done .toggle { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.txt.done .toggle .box { border-color: var(--accent-ink); }
.txt.done .toggle .box .i { opacity: 1; }
.txt.done .btn.copy { background: transparent; border-color: var(--done-border); color: var(--done-text); }

.done-toggle {
  width: 100%; border: 1px dashed var(--border-strong); background: transparent; border-radius: var(--r-sm);
  padding: 9px; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.done-toggle:hover { background: var(--surface-2); color: var(--text); }
.done-toggle .i { width: 15px; height: 15px; transition: transform .2s; }
.done-toggle.open .i { transform: rotate(180deg); }

.add-col {
  flex: 0 0 260px; min-height: 140px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px;
  display: grid; place-items: center; gap: 6px; align-content: center;
}
.add-col:hover { background: var(--surface); color: var(--text); border-color: var(--accent); }

.board-empty { flex: 1; margin: 48px auto; text-align: center; color: var(--muted); max-width: 400px; padding: 0 16px; }
.board-empty .em { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 16px; }
.board-empty .em .i { width: 28px; height: 28px; }
.board-empty h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; }
.board-empty p { margin: 0 0 18px; }

.pager { display: none; }
.bottombar { display: none; }

/* ============ модалка ============ */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 11, .45); z-index: 40;
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 560px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; padding: 22px;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: rise .18s ease-out;
}
.modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; letter-spacing: -.01em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.grab { display: none; }
.preview { background: var(--surface-2); border-radius: var(--r-sm); padding: 11px 13px; font-size: 13px; margin-bottom: 14px; color: var(--text-2); }
.preview ol { margin: 8px 0 0; padding-left: 22px; max-height: 180px; overflow: auto; }
.preview li { margin-bottom: 5px; white-space: pre-wrap; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.99); } }

/* ============ тост ============ */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(16px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ планшет ============ */
@media (max-width: 1100px) {
  .tab { padding: 7px 11px; }
  .user-name { display: none; }
}
@media (max-width: 900px) {
  .brand-text { display: none; }
}

/* ============ телефон ============ */
@media (max-width: 760px), (max-width: 960px) and (max-height: 500px) {
  :root { --top-h: 56px; }
  body { font-size: 16px; }
  .top-inner { padding: 0 8px 0 16px; gap: 10px; }
  .tabs, .avatar { display: none; }
  .top-title { display: block; flex: 1; min-width: 0; }
  .spacer { display: none; }

  .brand-text { display: none; }
  .summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 0; padding: 14px 16px 0; }
  .sum { min-width: 0; padding: 0 10px; background: transparent; border: 0; border-radius: 0; }
  .sum:first-child { padding-left: 0; }
  .sum + .sum:not(.warn) { border-left: 1px solid var(--border-strong); }
  .sum-label { font-size: 12px; color: var(--text-2); }
  .sum-value { flex-wrap: wrap; gap: 0 4px; overflow-wrap: anywhere; }
  .sum-value b { font-size: 20px; }
  .sum-value span { font-size: 12px; }
  .sum .bar { display: none; }
  .sum.warn { grid-column: 1 / -1; padding: 7px 10px; border-radius: 8px; gap: 7px; max-width: none; font-size: 12px; }
  .sum.warn .i { width: 16px; height: 16px; }
  .board { display: block; flex: none; padding: 12px 12px 16px; overflow: visible; scroll-margin-top: var(--top-h); }
  .col { width: auto; max-height: none; }
  .col-head { padding: 13px 14px; }
  .col-titlebar { align-items: center; }
  .org-picker { flex: 1; min-width: 0; }
  .org-picker label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); }
  .picker-control { position: relative; }
  .picker-control select { width: 100%; height: 44px; padding: 0 26px 0 0; border: 0; border-radius: 4px; background: transparent; appearance: none; font-size: 19px; font-weight: 650; text-overflow: ellipsis; cursor: pointer; }
  .picker-control option { background: var(--surface); color: var(--text); }
  .picker-control .i { position: absolute; right: 4px; top: 13px; color: var(--accent); pointer-events: none; }
  .col-titlebar .btn.icon, .top .btn.icon, .txt-meta .btn.icon.sm { width: 44px; min-height: 44px; flex-shrink: 0; }
  .col-foot .btn.sm, .done-toggle, .menu button, .open-link, .modal-head .btn, .seg button { min-height: 44px; }
  .col-titlebar h2 { font-size: 19px; }
  .texts { overflow: visible; padding: 12px 10px; }
  .txt { padding: 12px 13px 13px; }
  .txt-body { font-size: 16px; }
  .txt-actions { grid-template-columns: minmax(max-content, 1.2fr) minmax(max-content, 1fr); }
  .txt-actions .btn { min-height: 46px; padding-inline: 8px; font-size: 15px; border-radius: 10px; }
  .add-col { display: none; }

  .pager { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px 16px; }
  .pager .btn { min-height: 50px; justify-content: flex-start; font-size: 14px; padding: 8px 12px; min-width: 0; }
  .pager .btn span { overflow: hidden; text-overflow: ellipsis; }
  .pager .btn small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
  .pager .btn .t { display: grid; min-width: 0; text-align: left; }
  .pager .btn.next { grid-column: 2; justify-content: flex-end; }
  .pager .btn.next .t { text-align: right; }

  .bottombar {
    display: flex; position: sticky; bottom: 0; z-index: 10; margin-top: auto;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottombar button {
    flex: 1; border: 0; background: transparent; display: grid; justify-items: center; gap: 3px;
    padding: 4px 2px; border-radius: 12px; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer;
  }
  .bottombar button .i { width: 22px; height: 22px; }
  .bottombar button[aria-selected="true"] { color: var(--accent); }
  .bottombar button[aria-selected="true"] .ico-wrap { background: var(--accent-soft); }
  .ico-wrap { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background .15s; position: relative; }
  .bottombar .badge { position: absolute; top: -4px; right: 2px; }
  .bottombar button:not([aria-selected="true"]) .badge { background: var(--danger); color: #fff; }
  .has-bottombar #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }

  .overlay { place-items: end center; padding: 0; }
  .modal {
    max-width: none; border-radius: 22px 22px 0 0; border-bottom: 0;
    max-height: calc(100dvh - 24px); padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
    animation: sheet .22s cubic-bezier(.2, .8, .3, 1);
  }
  .grab { display: block; width: 40px; height: 5px; border-radius: 999px; background: var(--border-strong); margin: 4px auto 14px; }
  .modal-actions .btn { flex: 1; min-height: 46px; }
  .modal-head h3, .preview li { min-width: 0; overflow-wrap: anywhere; }
  .modal-actions .btn.danger { flex: 0 0 auto; }
  .row { gap: 10px; }
  .field input, .field textarea, .field select { font-size: 16px; } /* без автозума на iOS */

  .menu { right: 8px; top: 48px; }
  .login-card { padding: 28px 22px 22px; }
}
@media (max-width: 960px) and (max-height: 500px) {
  .top, .bottombar { position: static; }
  .board { scroll-margin-top: 0; }
}
@keyframes sheet { from { transform: translateY(100%); } }

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

/* Telegram задаёт высоту и отступы через свой WebView. */
.telegram {
  --inset-top: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px));
  --inset-bottom: calc(var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + var(--tg-content-safe-area-inset-bottom, 0px));
  --inset-left: calc(var(--tg-safe-area-inset-left, env(safe-area-inset-left, 0px)) + var(--tg-content-safe-area-inset-left, 0px));
  --inset-right: calc(var(--tg-safe-area-inset-right, env(safe-area-inset-right, 0px)) + var(--tg-content-safe-area-inset-right, 0px));
  --usable-height: calc(var(--tg-viewport-stable-height, 100dvh) - var(--inset-top) - var(--inset-bottom));
}
.telegram body { padding: var(--inset-top) var(--inset-right) var(--inset-bottom) var(--inset-left); min-height: var(--tg-viewport-stable-height, 100dvh); }
.telegram .shell, .telegram .login { min-height: var(--usable-height); }
.telegram .top { top: var(--inset-top); }
.telegram .bottombar { bottom: var(--inset-bottom); padding-bottom: 6px; }
.telegram .overlay { inset: var(--inset-top) var(--inset-right) var(--inset-bottom) var(--inset-left); }
.telegram .modal { max-height: min(calc(var(--usable-height) - 24px), calc(100dvh - var(--inset-top) - var(--inset-bottom) - 24px)); }
.telegram #toast { bottom: calc(24px + var(--inset-bottom)); }
.telegram .has-bottombar #toast { bottom: calc(84px + var(--inset-bottom)); }
