/* Social Posts. Self-hosted fonts, no external requests. */

@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #06090e;
  --bg-side: #090d14;
  --card: #0c1118;
  --card-2: #111822;
  --line: #18212d;
  --line-2: #27344a;
  --text: #f1f4f8;
  --muted: #8d99a9;
  --dim: #5f6b7c;
  --accent: #5ec4a8;
  --accent-2: #3fd0e6;
  --accent-ink: #04211a;
  --accent-soft: rgba(94, 196, 168, 0.12);
  --hot: #8f82ff;
  --hot-soft: rgba(143, 130, 255, 0.16);
  --warn: #e7b04c;
  --warn-soft: rgba(231, 176, 76, 0.14);
  --bad: #f0707e;
  --bad-soft: rgba(240, 112, 126, 0.14);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --side-w: 296px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1f4f8;
  --bg-side: #ffffff;
  --card: #ffffff;
  --card-2: #f4f7fa;
  --line: #dde4ec;
  --line-2: #c3cedb;
  --text: #0d1622;
  --muted: #566376;
  --dim: #8492a4;
  --accent: #0c8a6d;
  --accent-2: #0a93b0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(12, 138, 109, 0.1);
  --hot: #5b4be0;
  --hot-soft: rgba(91, 75, 224, 0.12);
  --warn: #a86a00;
  --warn-soft: rgba(168, 106, 0, 0.12);
  --bad: #c7334a;
  --bad-soft: rgba(199, 51, 74, 0.1);
  --shadow: 0 18px 44px rgba(20, 40, 70, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.brand { fill: currentColor; stroke: none; }
.ico.sm { width: 16px; height: 16px; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.app.is-collapsed { --side-w: 76px; }

.side {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-side); border-right: 1px solid var(--line);
  min-width: 0; z-index: 40;
}
.side-head { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid var(--line); min-height: 76px; }
.logo { width: 34px; height: 34px; border-radius: 10px; flex: none; }
.brand-name { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 1px solid transparent; border-radius: 10px; background: none; color: var(--muted);
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--card-2); border-color: var(--line); }
.app.is-collapsed .side-collapse .ico { transform: rotate(180deg); }

.nav { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 11px 14px; border: 1px solid transparent; border-radius: 12px;
  background: none; color: var(--muted); font-weight: 500; text-align: left; white-space: nowrap;
  transition: color .15s, background .15s, border-color .15s, box-shadow .2s;
}
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { color: var(--text); background: var(--card-2); text-decoration: none; }
.nav-item.is-active {
  color: var(--text); background: var(--card-2);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 0 22px -6px var(--accent);
}
.nav-item.is-active .ico { color: var(--accent); }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -11px; top: 22%; bottom: 22%; width: 3px;
  border-radius: 0 3px 3px 0; background: linear-gradient(var(--accent-2), var(--accent));
}
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }

.side-foot { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.who-text { min-width: 0; }
.who-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-mail { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .nav-item { padding: 9px 12px; }
.ver { font-family: var(--mono); font-size: 11px; color: var(--dim); padding-left: 12px; }

.app.is-collapsed .brand-name,
.app.is-collapsed .nav-item span,
.app.is-collapsed .who-text,
.app.is-collapsed .ver { display: none; }
.app.is-collapsed .side-head { flex-direction: column; padding: 14px 8px; gap: 8px; }
.app.is-collapsed .nav-item { justify-content: center; padding: 11px 0; }
.app.is-collapsed .who { justify-content: center; }
.app.is-collapsed .side-foot { padding: 14px 10px; }

.topbar { display: none; }
.scrim { display: none; }

.main { min-width: 0; padding: 40px clamp(20px, 3.2vw, 44px) 56px; }
.page { max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 30px; }
.page-head h1 { font-size: clamp(26px, 3vw, 36px); line-height: 1.15; }
.page-head p { color: var(--muted); font-size: 17px; margin-top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--card-2); color: var(--text);
  font-weight: 600; white-space: nowrap;
  transition: transform .08s, border-color .15s, box-shadow .2s, background .15s;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 18px -6px var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); border-color: var(--hot); box-shadow: 0 0 0 3px var(--hot-soft); }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; border-color: var(--line-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { box-shadow: 0 0 24px -4px var(--accent); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-soft); }
.btn.danger:hover { border-color: var(--bad); box-shadow: 0 0 18px -6px var(--bad); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line-2); box-shadow: none; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }

/* The Create a post button: a gradient line slowly draws itself around the edge. */
.btn-draw { position: relative; display: inline-flex; border-radius: 13px; padding: 3px; }
.btn-draw .btn { min-height: 46px; padding: 0 20px; font-size: 16px; }
.btn-draw svg.draw { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.btn-draw .draw rect {
  fill: none; stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  filter: drop-shadow(0 0 5px var(--accent-2));
  animation: draw-line 7s cubic-bezier(.45, 0, .2, 1) infinite;
}
@keyframes draw-line {
  0%   { stroke-dashoffset: 100; opacity: 1; }
  62%  { stroke-dashoffset: 0; opacity: 1; }
  82%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-draw .draw rect { animation: none; stroke-dashoffset: 0; }
  * { transition-duration: 0s !important; }
}

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.plats { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 14px; }

.stat {
  display: flex; flex-direction: column; justify-content: space-between; gap: 22px;
  min-height: 150px; padding: 20px; text-align: left; width: 100%; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .18s, box-shadow .25s, transform .12s, background .18s;
}
.stat:hover { border-color: color-mix(in srgb, var(--accent) 65%, transparent); box-shadow: 0 0 0 1px var(--accent-soft), 0 0 30px -10px var(--accent); }
.stat:active { transform: scale(.992); }
.stat.is-selected {
  border-color: var(--hot); background: linear-gradient(180deg, var(--hot-soft), transparent 70%), var(--card);
  box-shadow: 0 0 0 1px var(--hot-soft), 0 0 34px -8px var(--hot);
}
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat-label { color: var(--muted); font-weight: 500; font-size: 16px; }
.stat-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.stat.is-selected .stat-ico { background: var(--hot-soft); color: var(--hot); }
.stat-num { font-size: 38px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-family: var(--mono); font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; margin-top: 8px; }
.stat-sub.on { color: var(--accent); }
.stat-sub.warn { color: var(--warn); }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; margin-top: 44px; }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sec-head h2 { font-size: 23px; }
.sec-head p { color: var(--muted); margin-top: 4px; }
.more { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; background: none; border: 0; color: var(--accent); padding: 4px; border-radius: 6px; }
.more:hover { text-decoration: underline; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.row-card {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .18s, box-shadow .25s;
}
.row-card:hover { border-color: color-mix(in srgb, var(--accent) 65%, transparent); box-shadow: 0 0 30px -12px var(--accent); }
.row-body { min-width: 0; flex: 1; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: 14px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); font-size: 13px; font-weight: 500; margin-bottom: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--card-2); color: var(--muted); flex: none; }
.go { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); border: 1px solid var(--line); color: var(--accent); flex: none; }

.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }
.chip.scheduled { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.published, .chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.failed, .chip.off { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.hot { background: var(--hot-soft); color: var(--hot); border-color: transparent; }

.empty { padding: 34px 22px; text-align: center; border: 1px dashed var(--line-2); border-radius: var(--radius); color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.empty .stat-ico { margin: 0 auto 14px; }

/* ---------- Panels, forms ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.tab { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-weight: 600; transition: border-color .15s, box-shadow .2s, color .15s; }
.tab:hover { color: var(--text); border-color: var(--line-2); }
.tab.is-active { color: var(--text); border-color: var(--hot); box-shadow: 0 0 0 1px var(--hot-soft), 0 0 22px -8px var(--hot); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; min-width: 0; }
.panel h2 { font-size: 19px; margin-bottom: 4px; }
.panel > p { color: var(--muted); margin-bottom: 18px; max-width: 70ch; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.form { display: grid; gap: 16px; max-width: 520px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .label { font-size: 14px; font-weight: 600; color: var(--muted); }
.input, select.input {
  width: 100%; min-height: 44px; padding: 9px 13px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text);
  transition: border-color .15s, box-shadow .2s;
}
.input:hover { border-color: var(--dim); }
.input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent); }
.input.code { font-family: var(--mono); font-size: 20px; letter-spacing: .18em; text-align: center; }
.hint { font-size: 13px; color: var(--dim); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.msg { padding: 11px 14px; border-radius: 10px; font-size: 15px; background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--accent-soft); color: var(--accent); }

.theme-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 14px; }
.theme-opt { padding: 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card-2); text-align: left; font-weight: 600; display: grid; gap: 10px; color: var(--text); transition: border-color .15s, box-shadow .2s; }
.theme-opt:hover { border-color: var(--accent); }
.theme-opt.is-active { border-color: var(--hot); box-shadow: 0 0 0 1px var(--hot-soft), 0 0 24px -8px var(--hot); }
.swatch { height: 64px; border-radius: 8px; border: 1px solid var(--line-2); display: grid; grid-template-columns: 28% 1fr; overflow: hidden; }
.swatch i { display: block; }
.swatch.dark { background: #06090e; } .swatch.dark i { background: #0c1118; border-right: 1px solid #18212d; }
.swatch.light { background: #f1f4f8; } .swatch.light i { background: #fff; border-right: 1px solid #dde4ec; }

.conn { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.conn-card { padding: 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card-2); display: grid; gap: 14px; }
.conn-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.conn-top strong { display: block; }
.conn-top small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list { display: grid; gap: 10px; }
.user-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); min-width: 0; }
.user-row .who-text { flex: 1 1 200px; }
.user-row .chips, .user-row .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.log { display: grid; gap: 0; font-size: 14px; }
.log-row { display: grid; grid-template-columns: 190px 200px minmax(0, 1fr) 120px; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.log-row:last-child { border-bottom: 0; }
.log-row > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.log-row .mono { font-size: 12.5px; color: var(--muted); }

.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-family: var(--mono); font-size: 16px; padding: 16px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line-2); }
.qr { display: grid; place-items: center; padding: 14px; background: #fff; border-radius: 12px; width: max-content; max-width: 100%; }
.qr canvas { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
.secret { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line-2); }

/* ---------- Dialog, toast ---------- */
dialog.dlg {
  width: min(560px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 0;
  border: 1px solid var(--line-2); border-radius: 18px; background: var(--card); color: var(--text);
  box-shadow: var(--shadow), 0 0 60px -20px var(--accent);
}
dialog.dlg::backdrop { background: rgba(3, 6, 10, 0.72); backdrop-filter: blur(4px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.dlg-head h2 { font-size: 20px; }
.dlg-body { padding: 18px 22px 22px; display: grid; gap: 16px; }
.dlg-body .form { max-width: none; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.toasts { position: fixed; right: 18px; bottom: 18px; left: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 90; pointer-events: none; }
.toast { max-width: min(420px, 100%); padding: 12px 16px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--accent); box-shadow: var(--shadow); font-weight: 500; }
.toast.bad { border-color: var(--bad); }

/* ---------- Login and installer ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.auth-card { width: min(430px, 100%); padding: 32px 28px; border-radius: 20px; background: var(--card); border: 1px solid var(--line-2); box-shadow: var(--shadow); display: grid; gap: 20px; }
.auth-card.wide { width: min(640px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; }
.auth-card h1 { font-size: 26px; }
.auth-card .form { max-width: none; }
.steps { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }
.steps li { display: flex; gap: 10px; align-items: baseline; overflow-wrap: anywhere; }
.steps .ok { color: var(--accent); font-family: var(--mono); }
.steps .no { color: var(--bad); font-family: var(--mono); }
pre.snip { margin: 0; padding: 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line-2); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .plats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr); gap: 34px; }
}
@media (max-width: 900px) {
  .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); --side-w: 296px; }
  .side {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(296px, 86vw);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .app.nav-open .side { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(3, 6, 10, 0.6); z-index: 30; border: 0; }
  .side-collapse { display: none; }
  .app.is-collapsed .brand-name, .app.is-collapsed .nav-item span, .app.is-collapsed .who-text { display: revert; }
  .app.is-collapsed .side-head { flex-direction: row; padding: 20px 18px; }
  .app.is-collapsed .nav-item { justify-content: flex-start; padding: 11px 14px; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand-name { font-size: 17px; }
  .topbar .logo { width: 30px; height: 30px; border-radius: 9px; }
  .main { padding: 22px 16px calc(40px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 22px; }
  .page-head p { font-size: 16px; }
  .log-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 12px; }
}
@media (max-width: 560px) {
  .plats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { min-height: 124px; padding: 16px; gap: 14px; }
  .stat-label { font-size: 14px; }
  .stat-ico { width: 38px; height: 38px; border-radius: 10px; }
  .stat-num { font-size: 31px; }
  .btn-draw, .btn-draw .btn { width: 100%; }
  .panel { padding: 18px 16px; }
  .row-card { padding: 14px; gap: 12px; }
  .go, .round-ico { width: 38px; height: 38px; }
  .theme-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .codes { font-size: 14px; }
  .sec-head h2 { font-size: 21px; }
}

/* ================= Phase 2: composer, My Posts, Calendar ================= */

.row-card.btnlike { width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.row-card.btnlike:active { border-color: var(--hot); box-shadow: 0 0 0 3px var(--hot-soft); }
.chip.partial { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.publishing { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.flip .ico, .ico.flip { transform: rotate(180deg); }
.icon-btn.bordered { border-color: var(--line-2); }
.grow { flex: 1; }
.tabs.sm { margin-bottom: 0; }
.tabs.sm .tab { padding: 7px 12px; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; }
.tab-n { margin-left: 8px; font-family: var(--mono); font-size: 12px; color: var(--dim); }
.tab.is-active .tab-n { color: var(--hot); }
.dot-on, .dot-off { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot-on { background: var(--hot); }
.dot-off { background: var(--dim); }

/* Composer dialog */
dialog.dlg.wide { width: min(780px, calc(100vw - 28px)); }
.dlg-foot.spread { justify-content: space-between; }
.plat-row { display: flex; flex-wrap: wrap; gap: 8px; }
.plat-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 13px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--card-2); color: var(--muted); font-weight: 600; font-size: 14px;
  transition: border-color .15s, box-shadow .2s, color .15s, background .15s;
}
.plat-chip:hover { border-color: var(--accent); color: var(--text); }
.plat-chip.is-on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 16px -8px var(--accent); }
.plat-chip.is-on .ico { color: var(--accent); }
.plat-chip[disabled] { cursor: default; opacity: .75; }

.parts { display: grid; gap: 12px; }
.part { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); min-width: 0; transition: border-color .15s, box-shadow .2s; }
.part:focus-within { border-color: var(--line-2); }
.part.is-drop { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent); }
.part-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--dim); letter-spacing: .06em; }
.ta { resize: vertical; min-height: 110px; line-height: 1.5; display: block; }
.part-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.part-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.count { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count .ico { width: 13px; height: 13px; }
.count.near { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.count.over { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.add-part { justify-self: start; }

.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 108px; height: 108px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-2); background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.alt-btn { position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: 6px; border: 1px solid rgba(255,255,255,.35); background: rgba(3, 6, 10, .78); color: #fff; font-family: var(--mono); font-size: 11px; font-weight: 500; }
.alt-btn.has { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.thumb-tools { position: absolute; top: 5px; right: 5px; display: flex; gap: 3px; }
.thumb-tools button { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; border: 0; background: rgba(3, 6, 10, .78); color: #fff; padding: 0; }
.thumb-tools button[disabled] { opacity: .35; cursor: default; }
.thumb-tools button:hover:not([disabled]) { background: var(--hot); }
.alt-preview { max-width: 100%; max-height: 300px; border-radius: 10px; justify-self: center; display: block; }

.tag-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag-row:empty { display: none; }
.tag-btn { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: none; color: var(--accent); font-size: 13px; font-weight: 500; }
.tag-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.when-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.when-row .input { width: auto; flex: 1 1 220px; min-width: 0; }
.msg ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; }

/* My Posts */
.filters { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 10px; margin-bottom: 16px; }
.post-row { padding: 12px 14px 12px 12px; gap: 12px; }
.row-open { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; background: none; border: 0; padding: 4px; border-radius: 10px; color: inherit; text-align: left; }
.row-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; border: 1px solid var(--line-2); background: var(--bg); }
.post-row .row-meta { display: flex; align-items: center; gap: 8px; }
.plat-icons { display: inline-flex; gap: 5px; flex: none; color: var(--muted); }
.row-actions { display: flex; gap: 2px; flex: none; }
.more-wrap { display: grid; place-items: center; margin-top: 16px; }

/* Calendar */
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.cal-title { font-size: 21px; margin-left: 6px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 2px 8px; }
.cal-cell {
  min-height: 118px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; gap: 4px; min-width: 0; cursor: pointer;
  transition: border-color .15s, box-shadow .2s;
}
.cal.week .cal-cell { min-height: 260px; }
.cal-cell:hover { border-color: color-mix(in srgb, var(--accent) 65%, transparent); box-shadow: 0 0 24px -12px var(--accent); }
.cal-cell.is-out { background: none; }
.cal-cell.is-out .cal-num { color: var(--dim); }
.cal-cell.is-today .cal-num { background: var(--accent); color: var(--accent-ink); }
.cal-cell.is-selected { border-color: var(--hot); box-shadow: 0 0 0 1px var(--hot-soft), 0 0 26px -10px var(--hot); }
.cal-day { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cal-num { font-weight: 700; font-size: 14px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; display: inline-grid; place-items: center; }
.cal-count { display: none; font-family: var(--mono); font-size: 11px; color: var(--accent); }
.cal-chip {
  display: flex; gap: 6px; align-items: baseline; width: 100%; min-width: 0; padding: 3px 7px; border-radius: 7px;
  border: 0; border-left: 3px solid var(--dim); background: var(--card-2); color: var(--text); font-size: 12.5px; text-align: left;
}
.cal-chip:hover { background: var(--line); }
.cal-chip .mono { font-size: 11px; color: var(--muted); flex: none; }
.cal-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cal-chip.scheduled, .cal-chip.partial { border-left-color: var(--warn); }
.cal-chip.published { border-left-color: var(--accent); }
.cal-chip.failed { border-left-color: var(--bad); }
.cal-chip.publishing { border-left-color: var(--hot); }
.cal-more { font-size: 12px; color: var(--muted); padding-left: 8px; }
.day-panel { margin-top: 30px; }

@media (max-width: 900px) {
  .cal.week { grid-template-columns: minmax(0, 1fr); }
  .cal.week .cal-dow { display: none; }
  .cal.week .cal-cell { min-height: 0; }
}
@media (max-width: 700px) {
  dialog.dlg.wide { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .cal.month { gap: 4px; }
  .cal.month .cal-dow { padding: 2px 0; text-align: center; font-size: 10.5px; letter-spacing: 0; }
  .cal.month .cal-cell { min-height: 58px; padding: 5px 2px; align-items: center; border-radius: 10px; }
  .cal.month .cal-day { flex-direction: column; gap: 2px; }
  .cal.month .cal-chip, .cal.month .cal-more { display: none; }
  .cal.month .cal-count { display: block; }
  .cal-title { font-size: 18px; flex-basis: 100%; margin: 4px 0 0; order: 5; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .post-row { flex-wrap: wrap; }
  .post-row .row-open { flex-basis: 100%; }
  .post-row .row-actions { margin-left: auto; }
  .dlg-foot.spread { gap: 12px; }
  .dlg-foot.spread .actions { flex: 1 1 100%; }
  .dlg-foot.spread .actions .btn { flex: 1; }
  .thumb { width: 92px; height: 92px; }
  .counts { justify-content: flex-start; flex-basis: 100%; }
}
