/* ============ токены ============ */
:root {
  color-scheme: light;
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #f6f8fc; --ink: #0c1222; --ink-2: #39425a; --muted: #6a7489;
  --line: #e3e7f0; --line-strong: #cdd3e2; --hover: #eef1f8;
  --accent: #2f6df6; --accent-2: #6a5cff; --accent-ink: #ffffff; --accent-soft: #e8f0ff; --accent-line: #c3d6ff;
  --ok: #0f7a56; --ok-soft: #ddf4ea; --bad: #cf2e26; --bad-soft: #fde8e6;
  --warn: #8f5200; --warn-soft: #fff0d0; --info: #3659d6; --info-soft: #e7ecff;
  --r-sm: 10px; --r: 14px; --r-lg: 20px;
  --sh-1: 0 1px 2px rgba(12, 18, 34, .05);
  --sh-2: 0 12px 32px -14px rgba(12, 18, 34, .22), 0 2px 8px rgba(12, 18, 34, .05);
  --sh-3: 0 28px 70px -24px rgba(12, 18, 34, .45);
  --nav-h: 62px; --top-h: 56px; --safe-b: env(safe-area-inset-bottom, 0px);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --chat-bg: #dfe9f3; --bubble: #ffffff; --bubble-ink: #0c1222;
}
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="dark"], :root:not([data-theme="light"]) {
  /* значения тёмной темы задаются ниже в одном медиазапросе и в явном выборе */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #090c13; --surface: #111621; --surface-2: #151b29; --ink: #e9edf6; --ink-2: #c1c9da; --muted: #8993a8;
    --line: #222a3a; --line-strong: #2f3a52; --hover: #1a2132;
    --accent: #6d9bff; --accent-2: #9582ff; --accent-ink: #061024; --accent-soft: #172240; --accent-line: #29407a;
    --ok: #67d19b; --ok-soft: #123225; --bad: #ff8f86; --bad-soft: #3a1c1a;
    --warn: #f0be57; --warn-soft: #36290f; --info: #9db4ff; --info-soft: #1a2342;
    --sh-1: none; --sh-2: 0 14px 34px -14px rgba(0, 0, 0, .7); --sh-3: 0 30px 80px -20px rgba(0, 0, 0, .8);
    --chat-bg: #0d1420; --bubble: #1b2535; --bubble-ink: #e9edf6;
  }
}
:root[data-theme="dark"] {
  --bg: #090c13; --surface: #111621; --surface-2: #151b29; --ink: #e9edf6; --ink-2: #c1c9da; --muted: #8993a8;
  --line: #222a3a; --line-strong: #2f3a52; --hover: #1a2132;
  --accent: #6d9bff; --accent-2: #9582ff; --accent-ink: #061024; --accent-soft: #172240; --accent-line: #29407a;
  --ok: #67d19b; --ok-soft: #123225; --bad: #ff8f86; --bad-soft: #3a1c1a;
  --warn: #f0be57; --warn-soft: #36290f; --info: #9db4ff; --info-soft: #1a2342;
  --sh-1: none; --sh-2: 0 14px 34px -14px rgba(0, 0, 0, .7); --sh-3: 0 30px 80px -20px rgba(0, 0, 0, .8);
  --chat-bg: #0d1420; --bubble: #1b2535; --bubble-ink: #e9edf6;
}

/* ============ база ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  background: radial-gradient(1100px 480px at 85% -8%, color-mix(in srgb, var(--accent) 9%, transparent), transparent), var(--bg);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 750; letter-spacing: -.025em; }
h2 { font-size: 16px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 650; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 0; min-width: 0; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ============ каркас ============ */
.shell { min-height: 100dvh; display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.rail {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 16px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 16px -6px var(--accent);
}
.brand-text { display: grid; line-height: 1.2; }
.brand-text b { font-size: 16px; letter-spacing: -.01em; }
.brand-text small { color: var(--muted); font-size: 12.5px; }
.nav { display: grid; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); color: var(--ink-2);
  font-weight: 560; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--hover); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a svg { flex: none; }
.nav a .dot-warn { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.acct-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); min-width: 0;
}
.acct-chip:hover { text-decoration: none; border-color: var(--line-strong); }
.acct-chip .who { min-width: 0; line-height: 1.25; }
.acct-chip .who b { display: block; font-size: 14px; }
.acct-chip .who span { font-size: 12.5px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar, .tabbar { display: none; }
.page { width: 100%; max-width: 1200px; margin: 0 auto; padding: 32px 40px 72px; outline: none; }
.demo-bar { background: var(--warn-soft); color: var(--warn); padding: 8px 40px; font-size: 13px; text-align: center; }
.banners { display: grid; gap: 10px; }
.banners:not(:empty) { margin-bottom: 20px; }
#content > * { animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-title .sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 560; margin-bottom: 10px; }
.back:hover { color: var(--accent); text-decoration: none; }

/* ============ поверхности ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--sh-1); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head .hint { margin: 2px 0 0; }
.stack { display: grid; gap: 20px; align-content: start; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: minmax(0, 1.55fr) repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

.stat { display: grid; gap: 4px; align-content: start; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 560; display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 30px; font-weight: 760; letter-spacing: -.03em; line-height: 1.15; }
.stat .note { color: var(--muted); font-size: 13px; }
.stat-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat.today { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 18px; }
.stat.today .label { color: var(--ink); font-size: 15px; font-weight: 650; }

/* ============ формы ============ */
label.l { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px; }
input[type=text], input[type=number], input[type=search], input[type=time], input[type=datetime-local], input[type=password],
textarea, select {
  width: 100%; min-height: 42px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 9px 12px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
select { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238993a8' stroke-width='2.4' 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; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; cursor: pointer; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row.center { align-items: center; }
.row.between { justify-content: space-between; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 500; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > input { padding-left: 40px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  font: inherit; font-weight: 640; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  color: var(--accent-ink); border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  box-shadow: 0 6px 16px -8px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.soft:hover:not(:disabled) { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--bad); }
.btn.danger-solid { background: var(--bad); border-color: transparent; color: #fff; }
.btn.sm { min-height: 34px; padding: 5px 12px; font-size: 14px; }
.btn.icon { width: 40px; padding: 0; }
.btn.icon.sm { width: 34px; }
.btn.block { width: 100%; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn.sm { min-height: 38px; } input[type=checkbox] { width: 22px; height: 22px; } }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--hover); border-radius: 12px; max-width: 100%; }
.seg button {
  font: inherit; font-weight: 620; color: var(--ink-2); background: transparent; border: 0; padding: 7px 14px; border-radius: 9px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .15s, color .15s;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1), 0 0 0 1px var(--line); }
.seg.full { display: flex; } .seg.full button { flex: 1; justify-content: center; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn {
  flex: none; font: inherit; font-weight: 600; font-size: 14px; padding: 6px 13px; border-radius: 99px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap;
}
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-btn .n { opacity: .65; margin-left: 6px; font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; background: var(--hover); color: var(--ink-2); font-size: 12.5px; font-weight: 560; }

/* ============ значки, аватары, индикаторы ============ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft, .badge.queued { background: var(--hover); color: var(--muted); }
.badge.scheduled { background: var(--info-soft); color: var(--info); }
.badge.running { background: var(--accent-soft); color: var(--accent); }
.badge.running::before { animation: pulse 1.1s ease-in-out infinite; }
.badge.stopped, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.done, .badge.sent, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.failed, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.plain::before { display: none; }
@keyframes pulse { 50% { opacity: .2; transform: scale(.7); } }

.avatar {
  --h: 220; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 15px;
  background: hsl(var(--h) 85% 92%); color: hsl(var(--h) 55% 34%);
}
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 80% 78%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 35% 22%); color: hsl(var(--h) 80% 78%); } }

.bar { height: 8px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .5s cubic-bezier(.3, .8, .3, 1); }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); }
.bar.thin { height: 6px; }
.ring { position: relative; flex: none; display: grid; place-items: center; }
.ring svg { display: block; }
.ring-bg { fill: none; stroke: var(--hover); }
.ring-fg { fill: none; stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.3, .8, .3, 1); }
.ring.ok .ring-fg { stroke: var(--ok); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: 22px; letter-spacing: -.03em; }
.ring-label span { font-size: 12px; color: var(--muted); margin-top: 2px; }

.banner { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r); border: 1px solid; }
.banner svg { flex: none; margin-top: 2px; }
.banner .body { flex: 1; min-width: 0; }
.banner b { display: block; }
.banner p { font-size: 14px; margin-top: 2px; opacity: .92; }
.banner.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.banner .btn { flex: none; }
.notice { padding: 11px 14px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.notice.error { background: var(--bad-soft); color: var(--bad); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice + .notice { margin-top: 8px; }

.empty { display: grid; justify-items: center; gap: 8px; padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .ico { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.empty h3 { color: var(--ink); font-size: 17px; }
.empty p { max-width: 380px; }
.empty .btn { margin-top: 8px; }

.skel { border-radius: var(--r); background: linear-gradient(100deg, var(--hover) 30%, var(--surface-2) 50%, var(--hover) 70%);
  background-size: 300% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { to { background-position: -100% 0; } }

/* ============ списки ============ */
.items { display: grid; }
.item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
a.item { color: inherit; } a.item:hover { background: var(--surface-2); text-decoration: none; }
.item.off .item-main { opacity: .5; }
.item-main { flex: 1; min-width: 0; line-height: 1.35; }
.item-title { font-weight: 620; }
.item-sub { color: var(--muted); font-size: 13.5px; }
.item-side { display: flex; align-items: center; gap: 10px; flex: none; }
.item-name { width: min(220px, 34%); flex: none; }
.item-name input { min-height: 36px; padding: 6px 10px; font-size: 14px; }

.camp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.camp { display: grid; gap: 14px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line);
  color: inherit; box-shadow: var(--sh-1); transition: transform .15s, box-shadow .15s, border-color .15s; }
.camp:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--line-strong); }
.camp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.camp-name { font-weight: 680; font-size: 16px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.camp-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; }
.camp-meta b { color: var(--ink); font-weight: 650; }

/* ============ редактор ============ */
.editor { display: grid; gap: 20px; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); grid-template-areas: "msg rec" "opt rec"; align-items: start; }
.a-msg { grid-area: msg; } .a-rec { grid-area: rec; } .a-opt { grid-area: opt; }
.vars { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.vars button { font: 12.5px ui-monospace, Menlo, monospace; border: 1px dashed var(--line-strong); background: transparent; color: var(--accent);
  border-radius: 8px; padding: 4px 9px; cursor: pointer; }
.vars button:hover { background: var(--accent-soft); border-style: solid; border-color: var(--accent-line); }
.chat { border-radius: var(--r); padding: 18px 14px; background: var(--chat-bg); background-image:
  radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 40%),
  radial-gradient(circle at 80% 80%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 45%); }
.msg { position: relative; max-width: 92%; padding: 9px 12px 7px; border-radius: 16px 16px 16px 4px; background: var(--bubble); color: var(--bubble-ink);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.msg img { display: block; max-width: 100%; border-radius: 10px; margin-bottom: 8px; }
.msg .file { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: var(--hover); margin-bottom: 8px; font-size: 13.5px; color: var(--muted); }
.msg time { display: block; text-align: right; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.dock {
  position: sticky; bottom: 16px; z-index: 20; margin-top: 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 14px 12px 18px; border-radius: var(--r-lg); border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--sh-2);
}
.dock .sum { line-height: 1.3; }
.dock .sum b { font-size: 16px; }
.dock .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.picker-list { border: 1px solid var(--line); border-radius: var(--r); overflow: auto; max-height: min(58vh, 620px); background: var(--surface); }

/* ============ страница рассылки ============ */
.hero { display: flex; gap: 28px; align-items: center; }
.hero-body { flex: 1; min-width: 0; display: grid; gap: 14px; }
.hero-title { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pills { display: flex; gap: 10px; flex-wrap: wrap; }
.pill { display: grid; gap: 1px; padding: 10px 16px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); min-width: 104px; }
.pill b { font-size: 21px; letter-spacing: -.02em; line-height: 1.2; }
.pill span { color: var(--muted); font-size: 12.5px; font-weight: 560; }
.pill.ok b { color: var(--ok); } .pill.bad b { color: var(--bad); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 26px 0 8px; align-items: center; }
.tabs button { font: inherit; font-weight: 640; color: var(--muted); background: none; border: 0; padding: 10px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-color: var(--accent); }
.tabs select { width: auto; margin-left: auto; min-height: 36px; padding-top: 5px; padding-bottom: 5px; }
.log { max-height: 460px; overflow: auto; padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line);
  font: 12.5px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace; }
.log div { white-space: pre-wrap; overflow-wrap: anywhere; }
.log time { color: var(--muted); margin-right: 10px; }

/* ============ аккаунты, прокси ============ */
.acct { display: grid; gap: 14px; padding: 18px; }
.acct-top { display: flex; gap: 14px; align-items: center; min-width: 0; }
.acct-top .grow b { font-size: 16px; }
.acct-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.proxy-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.proxy-ico.bad { background: var(--bad-soft); color: var(--bad); } .proxy-ico.ok { background: var(--ok-soft); color: var(--ok); }
.kv { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; }

/* ============ шторки и всплывающие окна ============ */
dialog.sheet {
  border: 0; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: min(88dvh, 780px); color: var(--ink);
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden; flex-direction: column;
}
dialog.sheet[open] { display: flex; animation: pop .2s cubic-bezier(.2, .9, .3, 1.1); }
dialog.sheet::backdrop { background: rgba(7, 10, 20, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.sheet-head h3 { font-size: 18px; letter-spacing: -.01em; }
.sheet-body { padding: 8px 20px 20px; overflow: auto; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.grab { display: none; width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 8px auto 0; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 560; box-shadow: var(--sh-2); animation: rise .2s ease; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ шаблоны ============ */
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.tpl-list { padding: 8px; display: grid; gap: 2px; }
.tpl-list button { text-align: left; font: inherit; padding: 11px 12px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); cursor: pointer; }
.tpl-list button:hover { background: var(--hover); }
.tpl-list button.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.tpl-list .pv { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.show-mobile { display: none; }

/* ============ адаптив ============ */
/* ============ вход ============ */
.login-mode .rail, .login-mode .tabbar, .login-mode .topbar, .login-mode .demo-bar { display: none !important; }
.login-mode .shell { grid-template-columns: minmax(0, 1fr); }
.login { max-width: 380px; margin: 12vh auto 0; display: grid; gap: 14px; text-align: center; }
.login .brand-mark { width: 60px; height: 60px; border-radius: 20px; margin: 0 auto 4px; }
.login form { text-align: left; }

@media (max-width: 1100px) {
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
}
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 30; height: var(--top-h);
    padding: 0 14px; background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
  .topbar-actions { display: flex; align-items: center; gap: 4px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    padding: 6px 6px calc(6px + var(--safe-b)); background: color-mix(in srgb, var(--surface) 90%, transparent); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 6px 2px; border-radius: 12px; color: var(--muted); font-size: 11.5px; font-weight: 600; position: relative; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a.on svg { stroke-width: 2.4; }
  .tabbar a .dot-warn { position: absolute; top: 4px; right: calc(50% - 16px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); }
  .page { padding: 20px 16px calc(var(--nav-h) + var(--safe-b) + 28px); }
  .demo-bar { padding: 8px 16px; }
  h1 { font-size: 23px; }
  .page-head { margin-bottom: 18px; }
  .page-head .page-actions { width: 100%; }
  .page-head .page-actions .btn.primary { flex: 1; }
  .toolbar .page-actions { width: 100%; }
  .toolbar .page-actions .btn.primary { flex: 1; }
  .editor { grid-template-columns: minmax(0, 1fr); grid-template-areas: "msg" "rec" "opt"; }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .camp-grid { grid-template-columns: minmax(0, 1fr); }
  .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 16px); }
  .dock { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); margin: 0; }
  .with-dock .page, .page.with-dock { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 150px); }
  .hero { gap: 18px; }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split .pane-edit { display: none; }
  .split.editing .pane-list { display: none; }
  .split.editing .pane-edit { display: block; }
  .show-mobile { display: inline-flex; }
}
@media (max-width: 640px) {
  .card { padding: 16px; border-radius: 18px; }
  .grid.stats { gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.stats > .stat.today { grid-column: 1 / -1; }
  .stat .value { font-size: 26px; }
  .hero { flex-direction: column; align-items: stretch; text-align: left; }
  .hero .ring { align-self: center; }
  .pill { min-width: 0; flex: 1; padding: 9px 12px; }
  .item { padding: 12px 14px; gap: 12px; flex-wrap: wrap; }
  .item-name { flex: 0 0 100%; width: 100%; order: 5; margin-left: 0; }
  .tabs { overflow-x: auto; }
  .banner { flex-wrap: wrap; }
  .banner .btn { width: 100%; }
  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; }
  dialog.sheet[open] { animation: slide .26s cubic-bezier(.2, .9, .3, 1); }
  .grab { display: block; }
  .sheet-foot { padding-bottom: calc(14px + var(--safe-b)); }
  .sheet-foot .btn { flex: 1; }
  .dock { padding: 10px 12px; }
  .dock .acts { width: 100%; }
  .dock .acts .btn { flex: 1; padding-left: 10px; padding-right: 10px; }
  .dock .acts .btn.primary { flex: 1.6; }
  .seg button { padding: 7px 11px; }
}
