/* Castline UI — design tokens, layout and shared components. No external resources.
   Per-area sheets (pages/*.css) are linked after this one in index.html. */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f4f4f6;
  --surface-3: #ebebef;
  --hover: rgba(24, 24, 27, 0.045);
  --border: #e4e4e8;
  --border-strong: #d1d1d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #74747e;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-ink: #4338ca;
  --accent-contrast: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, var(--surface));
  --focus: color-mix(in srgb, var(--accent) 45%, transparent);
  --danger: #dc2626;
  --danger-ink: #b91c1c;
  --warning: #d97706;
  --warning-ink: #92400e;
  --success: #16a34a;
  --success-ink: #15803d;
  --info: #2563eb;
  --overlay: rgba(15, 15, 20, 0.42);
  --shadow-overlay: 0 18px 48px rgba(15, 15, 30, 0.16), 0 3px 10px rgba(15, 15, 30, 0.08);
  --shadow-pop: 0 8px 24px rgba(15, 15, 30, 0.12), 0 2px 6px rgba(15, 15, 30, 0.06);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  /* status colours */
  --st-draft: #71717a;
  --st-review: #d97706;
  --st-scheduled: #2563eb;
  --st-publishing: #7c3aed;
  --st-published: #16a34a;
  --st-partially_failed: #ea580c;
  --st-failed: #dc2626;
  --st-rejected: #e11d48;
  --st-missed_review: #e11d48;

  /* chart chrome (see dataviz reference palette) */
  --chart-grid: #e7e6e1;
  --chart-axis: #c3c2b7;
  --chart-ink: #74747e;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --seq-lo: #cde2fb;
  --seq-hi: #104281;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e11;
    --surface: #17171b;
    --surface-2: #1e1e23;
    --surface-3: #27272d;
    --hover: rgba(255, 255, 255, 0.05);
    --border: #2a2a31;
    --border-strong: #3a3a43;
    --text: #f2f2f4;
    --text-2: #b4b4bd;
    --text-3: #8d8d98;
    --accent: #8b85ff;
    --accent-hover: #a19cff;
    --accent-ink: #aaa5ff;
    --accent-contrast: #0e0e14;
    --danger: #f05252;
    --danger-ink: #fca5a5;
    --warning: #f59e0b;
    --warning-ink: #fcd34d;
    --success: #22c55e;
    --success-ink: #86efac;
    --info: #60a5fa;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow-overlay: 0 18px 48px rgba(0, 0, 0, 0.55), 0 3px 10px rgba(0, 0, 0, 0.4);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
    --st-draft: #a1a1aa;
    --st-review: #f59e0b;
    --st-scheduled: #60a5fa;
    --st-publishing: #a78bfa;
    --st-published: #4ade80;
    --st-partially_failed: #fb923c;
    --st-failed: #f87171;
    --st-rejected: #fb7185;
    --st-missed_review: #fb7185;
    --chart-grid: #2c2c2a;
    --chart-axis: #45454a;
    --chart-ink: #9a9aa3;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --seq-lo: #1e2a3a;
    --seq-hi: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e11;
  --surface: #17171b;
  --surface-2: #1e1e23;
  --surface-3: #27272d;
  --hover: rgba(255, 255, 255, 0.05);
  --border: #2a2a31;
  --border-strong: #3a3a43;
  --text: #f2f2f4;
  --text-2: #b4b4bd;
  --text-3: #8d8d98;
  --accent: #8b85ff;
  --accent-hover: #a19cff;
  --accent-ink: #aaa5ff;
  --accent-contrast: #0e0e14;
  --danger: #f05252;
  --danger-ink: #fca5a5;
  --warning: #f59e0b;
  --warning-ink: #fcd34d;
  --success: #22c55e;
  --success-ink: #86efac;
  --info: #60a5fa;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow-overlay: 0 18px 48px rgba(0, 0, 0, 0.55), 0 3px 10px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
  --st-draft: #a1a1aa;
  --st-review: #f59e0b;
  --st-scheduled: #60a5fa;
  --st-publishing: #a78bfa;
  --st-published: #4ade80;
  --st-partially_failed: #fb923c;
  --st-failed: #f87171;
  --st-rejected: #fb7185;
  --st-missed_review: #fb7185;
  --chart-grid: #2c2c2a;
  --chart-axis: #45454a;
  --chart-ink: #9a9aa3;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --seq-lo: #1e2a3a;
  --seq-hi: #86b6ef;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 13.5px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
h4 { font-size: 13px; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, kbd, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon-wrap { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; }
.icon { display: block; }

/* ---------- utilities ---------- */
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-wrap { flex-wrap: wrap; }
.row-top { align-items: flex-start; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.stack-lg { gap: 16px; }
.stack-xl { gap: 24px; }
.stack-sm { gap: 4px; }
.gap-0 { gap: 0; } .gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.grow { flex: 1 1 auto; min-width: 0; }
.none { flex: none; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; word-break: break-word; }
.text-danger { color: var(--danger-ink); }
.text-warning { color: var(--warning-ink); }
.text-success { color: var(--success-ink); }
.text-accent { color: var(--accent-ink); }
.right { text-align: right; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
@media (max-width: 520px) { .hide-sm { display: none; } }
.divider { height: 1px; background: var(--border); margin: 8px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: currentColor; }
.swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; flex: none; border: 1px solid color-mix(in srgb, var(--text) 12%, transparent); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.split-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.split-side { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 1000px) { .split-main, .split-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .grid-4.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger-ghost, .btn-ghost.btn-danger-ghost, .btn-danger-ghost:hover { color: var(--danger-ink); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 4px; }
.btn-lg { height: 40px; padding: 0 18px; font-size: 15px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-icon.btn-xs { width: 24px; }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-3); border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--accent-contrast); border-right-color: transparent; }
.btn-group { display: inline-flex; }
.btn-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.btn-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-right-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- form controls ---------- */
.input, .select, .textarea {
  width: 100%; min-width: 0; height: 34px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.select { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select[multiple] { height: auto; min-height: 90px; padding: 4px; background-image: none; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input-sm, .select.input-sm { height: 28px; font-size: 12.5px; border-radius: 7px; }
.input[type="color"] { padding: 2px; width: 44px; height: 34px; cursor: pointer; }
.input[type="file"] { padding: 5px 8px; height: auto; }
.input.is-invalid, .textarea.is-invalid, .select.is-invalid { border-color: var(--danger); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); }
.error-text { font-size: 12px; color: var(--danger-ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.input-group { display: flex; min-width: 0; }
.input-group > .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.input-affix { position: relative; display: flex; align-items: center; min-width: 0; }
.input-affix > .icon-wrap { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-affix > .input { padding-left: 32px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; min-width: 0; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.check-list { display: flex; flex-direction: column; gap: 6px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 550; color: var(--text-2); height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.segmented.sm button { height: 24px; padding: 0 9px; font-size: 12.5px; }

.datetime { display: flex; gap: 6px; min-width: 0; }
.datetime .input { min-width: 0; }
.datetime .input[type="time"] { max-width: 130px; }

.color-row { display: flex; gap: 6px; flex-wrap: wrap; }
.color-row button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.color-row button[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }

/* token / chip input */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 550; line-height: 1;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; max-width: 100%;
}
.chip > .label-text { overflow: hidden; text-overflow: ellipsis; }
.chip button { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; display: inline-flex; opacity: .7; }
.chip button:hover { opacity: 1; }
.chip-color { --c: var(--accent); background: color-mix(in srgb, var(--c) 13%, var(--surface)); color: color-mix(in srgb, var(--c) 70%, var(--text)); border-color: color-mix(in srgb, var(--c) 25%, var(--surface)); }
.chip.is-toggle { cursor: pointer; }
.chip.is-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* status chips */
.status { --c: var(--st-draft); display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: color-mix(in srgb, var(--c) 13%, var(--surface)); color: color-mix(in srgb, var(--c) 78%, var(--text)); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.status-draft { --c: var(--st-draft); }
.status-review { --c: var(--st-review); }
.status-scheduled { --c: var(--st-scheduled); }
.status-publishing { --c: var(--st-publishing); }
.status-published { --c: var(--st-published); }
.status-partially_failed { --c: var(--st-partially_failed); }
.status-failed { --c: var(--st-failed); }
.status-rejected, .status-missed_review { --c: var(--st-rejected); }
.status-pending { --c: var(--st-scheduled); }
.status-skipped { --c: var(--st-draft); }
.status-active, .status-valid, .status-approved, .status-joined, .status-open, .status-completed { --c: var(--st-published); }
.status-paused, .status-invited, .status-expired { --c: var(--st-review); }
.status-invalid { --c: var(--st-failed); }
.status-done, .status-archived { --c: var(--st-draft); }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--accent); color: var(--accent-contrast); line-height: 1; }
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.badge-danger { background: var(--danger); color: #fff; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; font-size: 11px; font-weight: 600; border-radius: 5px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag-accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag-warning { background: color-mix(in srgb, var(--warning) 15%, var(--surface)); color: var(--warning-ink); }
.tag-danger { background: color-mix(in srgb, var(--danger) 13%, var(--surface)); color: var(--danger-ink); }
.tag-success { background: color-mix(in srgb, var(--success) 13%, var(--surface)); color: var(--success-ink); }

/* platform badges */
.pbadge {
  --pc: #71717a; --size: 26px;
  width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: calc(var(--size) * 0.4); font-weight: 750; letter-spacing: -0.02em; line-height: 1;
  background: color-mix(in srgb, var(--pc) 17%, var(--surface)); color: color-mix(in srgb, var(--pc) 80%, var(--text));
  border: 1px solid color-mix(in srgb, var(--pc) 28%, var(--surface));
}
.pbadge.sm { --size: 20px; }
.pbadge.xs { --size: 16px; border-width: 0; }
.pbadge.lg { --size: 36px; }
.p-facebook { --pc: #1877f2; } .p-instagram { --pc: #d62976; } .p-twitter { --pc: #52525b; } .p-linkedin { --pc: #0a66c2; }
.p-pinterest { --pc: #e60023; } .p-tumblr { --pc: #36465d; } .p-gmb { --pc: #1e8e3e; } .p-youtube { --pc: #e00000; }
.p-tiktok { --pc: #0e9f9a; } .p-threads { --pc: #3f3f46; } .p-bluesky { --pc: #1185fe; } .p-telegram { --pc: #229ed9; }

.avatar { --size: 32px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; position: relative; display: inline-flex; align-items: center; justify-content: center; font-size: calc(var(--size) * .38); font-weight: 650; background: var(--surface-3); color: var(--text-2); overflow: visible; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.sm { --size: 24px; } .avatar.xs { --size: 20px; } .avatar.lg { --size: 40px; }
.avatar > .pbadge { position: absolute; right: -4px; bottom: -4px; --size: 15px; font-size: 7px; border: 1.5px solid var(--surface); }
.avatar.has-warning::after { content: "!"; position: absolute; top: -4px; right: -4px; width: 14px; height: 14px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.avatar-stack { display: inline-flex; }
.avatar-stack > * { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); border-radius: 50%; }
.avatar-stack > *:first-child { margin-left: 0; }

/* ---------- cards & surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); min-width: 0; flex-wrap: wrap; }
.card-header h2, .card-header h3 { font-size: 14px; }
.card-body { padding: 16px; min-width: 0; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.card-flush .card-body { padding: 0; }
.card.is-clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.card.is-clickable:hover { border-color: var(--border-strong); }
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.callout > .icon-wrap { margin-top: 1px; }
.callout-info { border-color: color-mix(in srgb, var(--info) 30%, var(--surface)); background: color-mix(in srgb, var(--info) 8%, var(--surface)); }
.callout-info > .icon-wrap { color: var(--info); }
.callout-warning { border-color: color-mix(in srgb, var(--warning) 35%, var(--surface)); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.callout-warning > .icon-wrap { color: var(--warning); }
.callout-danger { border-color: color-mix(in srgb, var(--danger) 30%, var(--surface)); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.callout-danger > .icon-wrap { color: var(--danger); }
.callout-success { border-color: color-mix(in srgb, var(--success) 30%, var(--surface)); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.callout-success > .icon-wrap { color: var(--success); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13px; }
.kv > dt { color: var(--text-3); }
.kv > dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-rows > * { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.list-rows > *:last-child { border-bottom: 0; }
.list-rows > .is-clickable { cursor: pointer; }
.list-rows > .is-clickable:hover { background: var(--hover); }
.secret-box { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2); font-family: var(--mono); font-size: 12.5px; word-break: break-all; }

/* ---------- tables ---------- */
/* position: relative keeps absolutely positioned children (e.g. .sr-only labels) inside the scroller */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr:hover td { background: var(--hover); }
.table tr.is-selected td { background: var(--accent-soft); }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 550; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs button:hover, .tabs a:hover { color: var(--text); text-decoration: none; }
.tabs [aria-selected="true"] { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; font-weight: 650; color: var(--text-3); background: var(--surface-3); border-radius: 999px; padding: 1px 6px; }
.tabs [aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- app shell: main sidebar (rail) + section sidebar (subnav) + content ---------- */
:root { --rail-w: 248px; --subnav-w: 228px; }
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.app.has-subnav { grid-template-columns: var(--rail-w) var(--subnav-w) minmax(0, 1fr); }
.app.rail-collapsed { --rail-w: 64px; }
.app.has-subnav.subnav-collapsed { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.app:not(.has-subnav) .subnav, .app.subnav-collapsed .subnav { display: none; }

.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 12px 10px 10px; background: var(--surface); border-right: 1px solid var(--border); z-index: 40; min-width: 0; }
.rail-top { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; }
.ws-switch { flex: 1; min-width: 0; height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.ws-switch:hover { background: var(--surface-2); }
.ws-name { flex: 1; min-width: 0; }
.ws-logo { width: 28px; height: 28px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 750; font-size: 12px; background: var(--accent); color: var(--accent-contrast); overflow: hidden; }
.ws-logo img { width: 100%; height: 100%; object-fit: cover; }
.rail-nav { display: flex; flex-direction: column; gap: 3px; }
.rail > .rail-nav { flex: 1; overflow-y: auto; min-height: 0; }
.rail-link { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font: inherit; font-weight: 500; text-align: left; text-decoration: none; white-space: nowrap; cursor: pointer; }
.rail-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.rail-link[aria-current="page"], .rail-settings[data-active] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.rail-link .badge { margin-left: auto; }
.rail-bottom { display: flex; flex-direction: column; gap: 3px; padding-top: 8px; border-top: 1px solid var(--border); }
.rail-foot { display: flex; align-items: center; gap: 4px; }
.rail-settings { flex: 1; min-width: 0; }
.rail-settings > .rail-label:last-child { margin-left: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 15px; color: var(--text); }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; background: var(--accent); color: var(--accent-contrast); display: inline-flex; align-items: center; justify-content: center; }

/* collapsed rail: icons only, labels as tooltips */
.app.rail-collapsed .rail { padding-inline: 8px; }
.app.rail-collapsed :is(.rail-label, .ws-name, .ws-chev) { display: none; }
.app.rail-collapsed .rail-top, .app.rail-collapsed .rail-foot { flex-direction: column; align-items: stretch; }
.app.rail-collapsed .ws-switch { justify-content: center; padding: 0; border-color: transparent; }
.app.rail-collapsed .rail-link { justify-content: center; padding: 0; }
.app.rail-collapsed .rail-link .badge { position: absolute; top: 2px; right: 4px; min-width: 15px; height: 15px; font-size: 9.5px; padding: 0 3px; }
.app.rail-collapsed .rail-toggle, .app.rail-collapsed .icon-btn-badge { align-self: center; }

/* section sidebar */
.subnav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; min-width: 0; background: var(--surface); border-right: 1px solid var(--border); z-index: 39; }
.subnav-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 10px 8px 16px; }
.subnav-title { font-size: 15px; font-weight: 650; }
.subnav-action { padding: 2px 12px 10px; }
.subnav-action:empty { display: none; }
.compose-split { display: flex; width: 100%; }
.compose-split > .grow { justify-content: center; }
.subnav-body { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.subnav-group { display: flex; flex-direction: column; gap: 2px; }
.subnav-group-head { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 6px 8px; border: 0; border-radius: 7px; background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 650; cursor: pointer; }
.subnav-group-head:hover { color: var(--text); }
.subnav-group-head svg { transition: transform .15s ease; }
.subnav-group-head[aria-expanded="false"] svg { transform: rotate(-90deg); }
.subnav-items { display: flex; flex-direction: column; gap: 1px; padding-top: 2px; }
.subnav-link { display: flex; align-items: center; gap: 9px; min-width: 0; height: 32px; padding: 0 8px 0 10px; border-radius: 7px; color: var(--text-2); font-size: 13px; text-decoration: none; }
.subnav-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.subnav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.subnav-empty, .subnav-loading { padding: 6px 10px; font-size: 12px; color: var(--text-3); }
.subnav-loading .spinner { width: 14px; height: 14px; }
.subnav-foot { padding: 12px 16px 14px; border-top: 1px solid var(--border); }
.meter-bar { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter-bar.is-danger > span { background: var(--danger); }
.subnav-count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.subnav-reveal { display: none; }
.app.has-subnav.subnav-collapsed .subnav-reveal { display: inline-flex; position: absolute; top: 18px; left: 12px; z-index: 20; background: var(--surface); }
.app.has-subnav.subnav-collapsed .main:not(.is-wide) { padding-left: 52px; }

/* settings popover (sidebar → Settings) */
.settings-pop { width: min(520px, calc(100vw - 16px)); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.settings-pop-head { display: flex; align-items: center; gap: 10px; }
.role-chip { display: inline-flex; width: fit-content; margin-top: 3px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.settings-pop-theme { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-block: 1px solid var(--border); }
.settings-pop-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-pop-label { padding: 0 8px 4px; font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.settings-pop-link { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; color: var(--text-2); font-size: 13px; text-decoration: none; }
.settings-pop-link:hover { background: var(--hover); color: var(--text); text-decoration: none; }

.main-col { position: relative; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: none; position: sticky; top: 0; z-index: 30; height: var(--topbar-h); align-items: center; gap: 8px; padding: 0 12px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .page-title { font-size: 15px; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-section { gap: 6px; flex: none; }
.icon-btn-badge { position: relative; }
.icon-btn-badge .badge { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
.main { padding: 24px 28px; min-width: 0; flex: 1; }
.main.is-wide { padding: 0; }
.page { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.page.narrow { max-width: 820px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-header h1 { font-size: 21px; }
.page-header .sub { color: var(--text-2); margin-top: 4px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 20px; font-size: 13px; font-weight: 550; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.banner-warning { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); color: var(--warning-ink); }
.banner-danger { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger-ink); }
.scrim { display: none; }

/* full-screen pages (composer) */
.app.is-focus, .app.is-focus.has-subnav { grid-template-columns: minmax(0, 1fr); }
.app.is-focus :is(.rail, .subnav, .topbar, .subnav-reveal) { display: none !important; }
.app.is-focus .main { padding: 0; }

@media (max-width: 1023px) {
  :root { --topbar-h: 52px; }
  .app, .app.has-subnav, .app.has-subnav.subnav-collapsed { grid-template-columns: minmax(0, 1fr); }
  .rail, .subnav { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 86vw); transform: translateX(-105%); transition: transform .2s ease; z-index: 50; }
  .app.has-subnav.subnav-collapsed .subnav { display: flex; }
  .app.nav-open .rail, .app.subnav-open .subnav { transform: none; box-shadow: var(--shadow-overlay); }
  .app:is(.nav-open, .subnav-open) .scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 45; }
  .app.rail-collapsed { --rail-w: 248px; }
  .app.rail-collapsed .rail { padding-inline: 10px; }
  .app.rail-collapsed :is(.rail-label, .ws-name) { display: inline; }
  .app.rail-collapsed .ws-chev { display: inline-block; }
  .app.rail-collapsed .rail-top, .app.rail-collapsed .rail-foot { flex-direction: row; align-items: center; }
  .app.rail-collapsed .ws-switch { justify-content: flex-start; padding: 0 8px; border-color: var(--border); }
  .app.rail-collapsed .rail-link { justify-content: flex-start; padding: 0 10px; }
  .app.rail-collapsed .rail-link .badge { position: static; }
  .rail-toggle, .subnav-toggle, .subnav-reveal { display: none !important; }
  .topbar { display: flex; }
  .topbar .menu-btn { display: inline-flex; }
  .main, .app.has-subnav.subnav-collapsed .main:not(.is-wide) { padding: 16px; }
}
@media (min-width: 1024px) {
  :root { --topbar-h: 0px; }
}
@media (max-width: 560px) {
  .topbar .compose-label, .topbar-section > svg:last-child { display: none; }
  .settings-pop-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .main { padding: 12px; }
  .page { gap: 16px; }
  .page-header h1 { font-size: 19px; }
  .card-body { padding: 12px; }
  .card-header { padding: 12px; }
}

/* ---------- overlays: modal, drawer, menus, toasts ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--overlay); animation: fade .12s ease; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-overlay); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; min-width: 0; animation: pop .14s ease; }
.modal.sm { max-width: 420px; } .modal.lg { max-width: 760px; } .modal.xl { max-width: 1100px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; min-height: 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@media (max-width: 640px) {
  .modal-root { padding: 0; align-items: flex-end; }
  .modal { max-height: 92vh; border-radius: 14px 14px 0 0; max-width: none !important; }
  .modal-body { padding: 16px; }
}
.drawer-root { position: fixed; inset: 0; z-index: 90; background: var(--overlay); animation: fade .12s ease; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-overlay); display: flex; flex-direction: column; animation: slide-in .18s ease; min-width: 0; }
.drawer.sm { width: min(440px, 100vw); }
.drawer-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; min-height: 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes slide-in { from { transform: translateX(30px); opacity: .4; } }

.menu { position: fixed; z-index: 120; min-width: 180px; max-width: min(340px, calc(100vw - 16px)); max-height: min(70vh, 480px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-pop); padding: 4px; animation: fade .1s ease; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 6px; font: inherit; color: var(--text); text-align: left; cursor: pointer; text-decoration: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; text-decoration: none; }
.menu-item.is-danger { color: var(--danger-ink); }
.menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--accent-ink); font-weight: 700; }
.menu-item:disabled { opacity: .5; cursor: not-allowed; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-label { font-size: 11px; font-weight: 700; color: var(--text-3); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .04em; }
.popover { position: fixed; z-index: 115; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); animation: fade .1s ease; max-width: calc(100vw - 16px); }

.toasts { position: fixed; z-index: 200; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 13px; animation: pop .15s ease; }
.toast .icon-wrap { margin-top: 1px; }
.toast-error { background: var(--danger); color: #fff; }
.toast-success .icon-wrap { color: var(--success); }
.toast .toast-close { margin-left: auto; background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0; }

.tip { position: fixed; z-index: 150; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 9px; border-radius: 7px; font-size: 12px; line-height: 1.4; box-shadow: var(--shadow-pop); max-width: 260px; }

/* ---------- empty, skeleton ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--text-2); }
.empty .empty-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); margin-bottom: 4px; }
.empty h3 { color: var(--text); font-size: 15px; }
.empty p { max-width: 420px; font-size: 13px; }
.empty.sm { padding: 20px 12px; }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: 6px; }
.skel-line { height: 12px; margin: 8px 0; }
.skel-block { height: 80px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading-center { display: flex; justify-content: center; padding: 40px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- KPI tiles & meters ---------- */
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.kpi .kpi-delta { font-size: 12px; font-weight: 600; }
.delta-up { color: var(--success-ink); }
.delta-down { color: var(--danger-ink); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter.is-warning > span { background: var(--warning); }
.meter.is-danger > span { background: var(--danger); }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--chart-axis); stroke-width: 1; }
.chart .tick { fill: var(--chart-ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { opacity: .12; }
.chart .crosshair { stroke: var(--chart-axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-dot { stroke: var(--surface); stroke-width: 2; }
.chart .bar { transition: opacity .1s; }
.chart .bar:hover { opacity: .8; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--text-2); }
.heatmap { display: grid; grid-template-columns: 36px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10.5px; color: var(--chart-ink); min-width: 520px; }
.heatmap .cell { aspect-ratio: 1; border-radius: 3px; background: color-mix(in oklab, var(--seq-hi) calc(var(--v) * 100%), var(--surface-2)); }
.heatmap .hlabel { text-align: center; }
.heatmap .dlabel { display: flex; align-items: center; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- auth screens ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-body { padding: 28px; }
@media (max-width: 480px) { .auth-card .card-body { padding: 20px; } }

/* ---------- post bits (lists, previews) ---------- */
.post-row { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.post-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-3); overflow: hidden; }
.post-thumb img, .post-thumb video { width: 100%; height: 100%; object-fit: cover; }
.post-thumb.sm { width: 40px; height: 40px; }
.targets-inline { display: inline-flex; gap: 3px; flex-wrap: wrap; }

.preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 13.5px; min-width: 0; }
.preview-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.preview-head .who { min-width: 0; }
.preview-head .name { font-weight: 650; font-size: 13.5px; }
.preview-head .handle { font-size: 12px; color: var(--text-3); }
.preview-text { padding: 0 14px 10px; white-space: pre-wrap; word-break: break-word; }
.preview-text .lnk { color: var(--accent-ink); }
.preview-text .over { background: color-mix(in srgb, var(--danger) 22%, transparent); border-radius: 2px; }
.preview-media { display: grid; gap: 2px; background: var(--surface-3); }
.preview-media.n2 { grid-template-columns: 1fr 1fr; }
.preview-media.n3, .preview-media.n4 { grid-template-columns: 1fr 1fr; }
.preview-media > * { width: 100%; aspect-ratio: 1.6; object-fit: cover; display: block; background: var(--surface-3); }
.preview-media.square > * { aspect-ratio: 1; }
.preview-media.tall > * { aspect-ratio: 9/14; }
.preview-link { margin: 0 14px 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.preview-link img { width: 100%; aspect-ratio: 1.91; object-fit: cover; display: block; background: var(--surface-3); }
.preview-link .meta { padding: 8px 10px; font-size: 12px; }
.preview-actions { display: flex; gap: 18px; padding: 8px 14px 12px; color: var(--text-3); font-size: 12px; }
.preview-thread { border-top: 1px dashed var(--border); }
.preview-title { padding: 0 14px 6px; font-weight: 650; }

/* ---------- composer ---------- */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.composer-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - var(--topbar-h) - 32px); overflow-y: auto; }
@media (max-width: 1100px) { .composer { grid-template-columns: minmax(0, 1fr); } .composer-side { position: static; max-height: none; } }
.editor-box { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); }
.editor-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.editor-box textarea { border: 0; outline: 0; box-shadow: none !important; width: 100%; min-height: 150px; resize: vertical; padding: 12px 14px; font: inherit; font-size: 14.5px; background: transparent; color: var(--text); line-height: 1.55; display: block; }
.editor-tools { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.counters { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.counter { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--danger-ink); }
.counter.is-near { color: var(--warning-ink); }
.media-strip { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px; }
.media-tile { position: relative; width: 92px; height: 92px; border-radius: 8px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); flex: none; cursor: grab; }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.media-tile .tile-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.media-tile .tile-actions button { width: 22px; height: 22px; border-radius: 6px; border: 0; background: rgba(0,0,0,.6); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.media-tile .tile-badge { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; }
.media-tile.is-dragging { opacity: .4; }
.media-tile.is-over { outline: 2px solid var(--accent); }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 16px; text-align: center; color: var(--text-3); font-size: 13px; transition: border-color .12s, background .12s; }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.net-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.net-tab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px 0 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.net-tab[aria-selected="true"] { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.net-tab .dot { width: 6px; height: 6px; }
.issue-list { display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; }
.issue.is-error { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger-ink); }
.issue.is-warning { background: color-mix(in srgb, var(--warning) 11%, var(--surface)); color: var(--warning-ink); }
.section-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 16px; background: none; border: 0; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.section-toggle:hover { background: var(--hover); }
.section-toggle .chev { margin-left: auto; transition: transform .15s; color: var(--text-3); }
.section-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.thread-item { border-left: 2px solid var(--border-strong); padding-left: 12px; }
.composer-footer { position: sticky; bottom: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--border); padding: 12px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* account picker */
.acct-groups { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-start; }
.acct-group { min-width: 0; max-width: 100%; }
.acct-group-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.acct-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.acct-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 12.5px; color: var(--text); cursor: pointer; max-width: 100%; }
.acct-chip:hover { border-color: var(--border-strong); }
.acct-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.acct-chip[aria-pressed="false"] .avatar { filter: grayscale(.8); opacity: .7; }
.acct-chip:disabled { opacity: .45; cursor: not-allowed; }
.acct-chip .ellipsis { max-width: 160px; }

/* ---------- planner ---------- */
.cal { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-head div { padding: 8px; font-size: 12px; font-weight: 650; color: var(--text-3); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day { min-height: 118px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; position: relative; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-other { background: var(--surface-2); }
.cal-day.is-other .cal-date { color: var(--text-3); }
.cal-day.is-today .cal-date span { background: var(--accent); color: var(--accent-contrast); }
.cal-day.is-drop { background: var(--accent-soft); }
.cal-day.is-past { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.cal-date { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 650; color: var(--text-2); padding: 2px 2px 2px 4px; }
.cal-date span { min-width: 22px; height: 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.cal-add { opacity: 0; }
.cal-day:hover .cal-add, .cal-add:focus-visible { opacity: 1; }
.cal-chip { --c: var(--st-draft); overflow: hidden; display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 6px; font-size: 11.5px; line-height: 1.3; background: color-mix(in srgb, var(--c) 12%, var(--surface)); border-left: 3px solid var(--c); color: var(--text); cursor: pointer; min-width: 0; border-top: 0; border-right: 0; border-bottom: 0; font-family: inherit; text-align: left; width: 100%; }
.cal-chip:hover { background: color-mix(in srgb, var(--c) 20%, var(--surface)); }
.cal-chip[draggable="true"] { cursor: grab; }
.cal-chip .t { font-weight: 650; color: var(--text-2); flex: none; font-variant-numeric: tabular-nums; }
.cal-chip .x { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cal-more { font-size: 11.5px; color: var(--text-3); padding: 0 6px; background: none; border: 0; text-align: left; cursor: pointer; font-family: inherit; }
.week { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.week-scroll { overflow: auto; max-height: calc(100vh - 260px); min-width: 0; border-radius: var(--r-lg); }
.week-colhead { position: sticky; top: 0; z-index: 2; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 6px; text-align: center; font-size: 12px; font-weight: 650; color: var(--text-2); }
.week-colhead.is-today { color: var(--accent-ink); }
.week-hour { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); min-height: 52px; padding: 2px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.week-hour.is-drop { background: var(--accent-soft); }
.week-label { font-size: 11px; color: var(--text-3); text-align: right; padding: 2px 6px 0 0; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
@media (max-width: 760px) {
  .cal-day { min-height: 74px; }
  .cal-chip .x { display: none; }
  .cal-chip { padding: 2px 4px; }
  .cal-head div { padding: 6px 2px; font-size: 11px; }
  .week { grid-template-columns: 40px repeat(7, minmax(64px, 1fr)); }
}
.feed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.bulk-bar { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 6; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); }
.bulk-bar .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.bulk-bar .btn:hover { background: color-mix(in srgb, var(--bg) 12%, transparent); }
.filters-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 14px; }

/* ---------- post detail ---------- */
.target-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.target-row:last-child { border-bottom: 0; }
.metric-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.metric-row b { color: var(--text); font-weight: 650; }
.level { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.level.is-current { border-color: color-mix(in srgb, var(--warning) 50%, var(--border)); background: color-mix(in srgb, var(--warning) 6%, var(--surface)); }
.level.is-done { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-body { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.comment.is-resolved .comment-body { opacity: .6; }
.comment .mention { color: var(--accent-ink); font-weight: 600; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.reaction { height: 22px; padding: 0 7px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.reaction[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.timeline { position: relative; display: flex; flex-direction: column; gap: 14px; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline > div { position: relative; font-size: 13px; }
.timeline > div::before { content: ""; position: absolute; left: -17px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.mention-menu { position: absolute; z-index: 20; }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 210px 340px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); min-width: 0; }
.inbox > * { min-width: 0; min-height: 0; }
.inbox-filters { border-right: 1px solid var(--border); padding: 12px 8px; overflow-y: auto; background: var(--surface); }
.inbox-list { border-right: 1px solid var(--border); overflow-y: auto; background: var(--surface); }
.inbox-detail { overflow-y: auto; display: flex; flex-direction: column; background: var(--bg); }
.inbox-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; min-width: 0; background: none; border-left: 3px solid transparent; width: 100%; text-align: left; font: inherit; color: inherit; border-top: 0; border-right: 0; }
.inbox-item:hover { background: var(--hover); }
.inbox-item[aria-selected="true"] { background: var(--accent-soft); border-left-color: var(--accent); }
@media (max-width: 1100px) { .inbox { grid-template-columns: 300px minmax(0, 1fr); } .inbox-filters { display: none; } }
@media (max-width: 760px) {
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; min-height: calc(100vh - var(--topbar-h)); }
  .inbox.has-selection .inbox-list { display: none; }
  .inbox:not(.has-selection) .inbox-detail { display: none; }
}

/* ---------- media library ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); position: relative; min-width: 0; }
.media-card .thumb { aspect-ratio: 1; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-3); overflow: hidden; }
.media-card .thumb img, .media-card .thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-card .meta { padding: 8px; font-size: 12px; min-width: 0; }
.media-card.is-selected { outline: 2px solid var(--accent); outline-offset: -1px; }
.media-card .sel { position: absolute; top: 6px; left: 6px; }
.media-card .card-menu { position: absolute; top: 6px; right: 6px; }

/* ---------- weekly slots editor ---------- */
.slots { display: flex; flex-direction: column; gap: 8px; }
.slot-day { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; align-items: start; }
.slot-times { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
@media (max-width: 520px) { .slot-day { grid-template-columns: minmax(0, 1fr); gap: 4px; } }

/* ---------- public share ---------- */
.share-wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 60px; display: flex; flex-direction: column; gap: 20px; }

/* two-step verification */
.otp-input { font-variant-numeric: tabular-nums; letter-spacing: .3em; font-size: 18px; text-align: center; max-width: 14ch; }
.otp-qr-wrap { display: flex; justify-content: center; }
.otp-qr { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--border); max-width: 100%; height: auto; }

/* ---------- page bar: the header card at the top of a content area ---------- */
.page-bar { position: sticky; top: var(--topbar-h); z-index: 8; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.page-bar > .page-bar-start, .page-bar > .page-bar-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.page-bar > .page-bar-start { flex: 1 1 auto; }
.page-bar > .page-bar-end { margin-left: auto; }
.page-bar-title { font-size: 15px; font-weight: 650; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.page-bar-sep { width: 1px; height: 18px; background: var(--border); flex: none; }
