/* Aksharum Social – dashboard styles.
   Theme follows aksharum.com: lavender/purple palette, DM Sans text, Playfair Display headings,
   pill buttons and soft glassy cards. Layout: full sidebar ≥1024px, icon rail 768–1023px,
   top bar + bottom tab bar + slide-in drawer below 768px. Components respond to the width of the
   content area (container queries), so they fit whatever the sidebar takes. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --p50: #faf8ff; --p100: #f1ecff; --p200: #e5dcff; --p300: #d0c0fa; --p400: #b8a4f0;
  --p500: #9d83e6; --p600: #7c5fd6; --p700: #5d3fb8; --p800: #3f2885; --p900: #251552;
  --bg: #f6f3fe;
  --bg-glow-1: rgba(199, 179, 255, .32);
  --bg-glow-2: rgba(157, 131, 230, .20);
  --surface: #ffffff;
  --surface-2: #f8f5ff;
  --surface-3: #f1ecff;
  --glass: rgba(255, 255, 255, .78);
  --border: #ece6fb;
  --border-strong: #ddd2f7;
  --text: #1a1230;
  --text-2: #4a4063;
  --muted: #7a7095;
  --accent: #6650c4;
  --accent-strong: #5d3fb8;
  --accent-ink: #ffffff;
  --accent-soft: #f1ecff;
  --accent-soft-2: #e5dcff;
  --link: #5d3fb8;
  --grad: linear-gradient(135deg, #7c5fd6 0%, #5d3fb8 100%);
  --grad-hero: linear-gradient(155deg, #8468dc 0%, #6650c4 42%, #3f2885 100%);
  --focus: 0 0 0 4px rgba(124, 95, 214, .22);
  --good: #15803d; --good-ink: #12703a; --good-soft: #e6f6ec;
  --warn: #f2a516; --warn-ink: #855400; --warn-soft: #fff4d9;
  --serious: #ec835a;
  --bad: #c62828; --bad-ink: #b42323; --bad-soft: #fdecec;
  --grid: #ece6fb;
  --axis: #cfc4ee;
  /* platform identity = categorical slots 1..5 (validated order) */
  --p-instagram: #2a78d6;
  --p-facebook: #eb6834;
  --p-x: #1baf7a;
  --p-linkedin: #eda100;
  --p-youtube: #e87ba4;
  /* sequential brand-purple ramp (heatmaps, mix bars): light -> dark */
  --seq-0: #f3effc; --seq-1: #e5dcff; --seq-2: #d0c0fa; --seq-3: #b8a4f0; --seq-4: #9d83e6;
  --seq-5: #7c5fd6; --seq-6: #5d3fb8; --seq-7: #3f2885;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(37, 21, 82, .05);
  --shadow: 0 1px 2px rgba(37, 21, 82, .04), 0 8px 28px rgba(93, 63, 184, .07);
  --shadow-lg: 0 24px 64px rgba(37, 21, 82, .18);
  --shadow-btn: 0 8px 22px rgba(124, 95, 214, .30);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Playfair Display", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --appbar-h: 60px;
  --tabbar-h: 64px;
  --sidebar-w: 264px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0a1c; --bg-glow-1: rgba(93, 63, 184, .22); --bg-glow-2: rgba(124, 95, 214, .14);
    --surface: #171126; --surface-2: #1d1530; --surface-3: #261c3d; --glass: rgba(23, 17, 38, .82);
    --border: rgba(222, 210, 255, .11); --border-strong: rgba(222, 210, 255, .2);
    --text: #fbf8ff; --text-2: #ded6f3; --muted: #a99dc2;
    --accent: #b69cff; --accent-strong: #c7b3ff; --accent-soft: rgba(157, 131, 230, .15); --accent-soft-2: rgba(157, 131, 230, .26);
    --link: #c7b3ff; --focus: 0 0 0 4px rgba(182, 156, 255, .25);
    --good-ink: #4ade80; --good-soft: rgba(34, 197, 94, .14); --warn-ink: #fbbf24; --warn-soft: rgba(251, 191, 36, .13);
    --bad-ink: #f87171; --bad-soft: rgba(248, 113, 113, .13);
    --grid: rgba(222, 210, 255, .09); --axis: rgba(222, 210, 255, .22);
    --p-instagram: #3987e5; --p-facebook: #d95926; --p-x: #199e70; --p-linkedin: #c98500; --p-youtube: #d55181;
    --seq-0: #211735; --seq-1: #31224f; --seq-2: #4b3477; --seq-3: #7455b8; --seq-4: #9d83e6;
    --seq-5: #b69cff; --seq-6: #c7b3ff; --seq-7: #ded2ff;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0a1c; --bg-glow-1: rgba(93, 63, 184, .22); --bg-glow-2: rgba(124, 95, 214, .14);
  --surface: #171126; --surface-2: #1d1530; --surface-3: #261c3d; --glass: rgba(23, 17, 38, .82);
  --border: rgba(222, 210, 255, .11); --border-strong: rgba(222, 210, 255, .2);
  --text: #fbf8ff; --text-2: #ded6f3; --muted: #a99dc2;
  --accent: #b69cff; --accent-strong: #c7b3ff; --accent-soft: rgba(157, 131, 230, .15); --accent-soft-2: rgba(157, 131, 230, .26);
  --link: #c7b3ff; --focus: 0 0 0 4px rgba(182, 156, 255, .25);
  --good-ink: #4ade80; --good-soft: rgba(34, 197, 94, .14); --warn-ink: #fbbf24; --warn-soft: rgba(251, 191, 36, .13);
  --bad-ink: #f87171; --bad-soft: rgba(248, 113, 113, .13);
  --grid: rgba(222, 210, 255, .09); --axis: rgba(222, 210, 255, .22);
  --p-instagram: #3987e5; --p-facebook: #d95926; --p-x: #199e70; --p-linkedin: #c98500; --p-youtube: #d55181;
  --seq-0: #211735; --seq-1: #31224f; --seq-2: #4b3477; --seq-3: #7455b8; --seq-4: #9d83e6;
  --seq-5: #b69cff; --seq-6: #c7b3ff; --seq-7: #ded2ff;
  --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
}

/* light/dark icon swap for the theme toggle */
.i-sun { display: none !important; }
:root[data-theme="dark"] .i-sun { display: inline-flex !important; }
:root[data-theme="dark"] .i-moon { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: inline-flex !important; }
  :root:not([data-theme="light"]) .i-moon { display: none !important; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }
html, body { margin: 0; }
body {
  min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(1100px 560px at 105% -8%, var(--bg-glow-2), transparent 62%),
    radial-gradient(900px 520px at -12% -4%, var(--bg-glow-1), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
}
::selection { background: var(--p200); color: var(--p900); }
a { color: var(--link); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
img, video, svg { max-width: 100%; }
.icon { flex: none; display: inline-block; vertical-align: middle; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; color: var(--text); }
h1 { font-family: var(--display); font-weight: 700; font-size: clamp(1.55rem, 1.15rem + 1.3vw, 2.15rem); letter-spacing: -.015em; }
h2 { font-family: var(--display); font-weight: 700; font-size: 1.2rem; letter-spacing: -.005em; }
h3 { font-weight: 650; font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); } .text-2 { color: var(--text-2); }
code, pre { font-family: var(--mono); font-size: .85em; }
code { background: var(--surface-3); padding: .1em .35em; border-radius: 6px; }
pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); padding: .85rem 1rem; border-radius: var(--radius-sm); margin: .5rem 0 0; line-height: 1.5; }
pre code { background: none; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
ul, ol { padding-left: 1.2rem; }
details > summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--p600); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--surface); color: var(--text); padding: .6rem 1rem; border-radius: 999px; box-shadow: var(--shadow-lg); }
.skip-link:focus { top: 12px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--p400); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: .7rem; color: var(--text); text-decoration: none !important; min-width: 0; }
.brand-logo { width: 42px; height: auto; flex: none; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-text b { font-family: var(--font); font-weight: 700; font-size: 1.22rem; letter-spacing: -.02em; color: var(--p600); }
.brand-text small { font-size: .68rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: .2rem; }
:root[data-theme="dark"] .brand-text b { color: var(--p500); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-text b { color: var(--p500); } }
:root[data-theme="dark"] .brand-logo:not([src*="white"]) { filter: brightness(1.35) saturate(1.1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo:not([src*="white"]) { filter: brightness(1.35) saturate(1.1); } }

/* ---------- app shell ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.appbar, .tabbar, .icon-btn.drawer-close { display: none; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 30;
  display: flex; flex-direction: column; gap: .35rem;
  padding: 1.25rem .9rem 1rem;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border-right: 1px solid var(--border);
  overflow-y: auto; overscroll-behavior: contain;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: .1rem .45rem .9rem; }
.create-btn { width: 100%; min-height: 46px; margin: .2rem 0 .8rem; }
.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav a, .nav-btn {
  position: relative; display: flex; align-items: center; gap: .75rem; width: 100%;
  min-height: 44px; padding: .55rem .8rem; border-radius: 12px;
  color: var(--text-2); font: inherit; font-weight: 550; font-size: .94rem; text-align: left;
  background: none; border: 0; cursor: pointer; text-decoration: none;
  transition: background-color .15s, color .15s;
}
.nav a .icon, .nav-btn .icon { color: var(--muted); transition: color .15s; }
.nav a:hover, .nav-btn:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.nav a:hover .icon, .nav-btn:hover .icon { color: var(--accent); }
.nav a.active { background: linear-gradient(90deg, var(--accent-soft-2), var(--accent-soft)); color: var(--accent-strong); font-weight: 650; }
.nav a.active .icon { color: var(--accent); }
.nav a.active::before { content: ""; position: absolute; left: -.9rem; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); }
.nav .count { margin-left: auto; background: var(--grad); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 700; padding: .05rem .5rem; min-width: 1.5rem; text-align: center; line-height: 1.5; }
.nav .count.bad { background: var(--bad); }
.nav-btn .label { display: inline-flex; }
.sidebar-foot { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .15rem; }
.sidebar-foot form { margin: 0; }
.scrim { display: none; }

.main { min-width: 0; container: main / inline-size; outline: none; }
.main-inner { max-width: 1360px; margin: 0 auto; padding: clamp(1.25rem, 2.6vw, 2.25rem) clamp(1rem, 3vw, 2.5rem) 3.5rem; }

/* page header */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem 1.25rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.topbar > div:first-child { min-width: 0; flex: 1 1 320px; }
.topbar h1 { margin-bottom: .25rem; }
.topbar .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 1.1rem; }
.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)); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem; box-shadow: var(--shadow); min-width: 0;
}
a.card { color: inherit; text-decoration: none; transition: transform .18s, box-shadow .18s, border-color .18s; }
a.card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: 0 14px 36px rgba(93, 63, 184, .13); text-decoration: none; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: .85rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head > a { font-weight: 600; font-size: .85rem; }
.stat { position: relative; display: flex; flex-direction: column; gap: .2rem; overflow: hidden; }
.stat::before { content: ""; width: 34px; height: 4px; border-radius: 4px; background: var(--grad); margin-bottom: .55rem; }
.stat::after { content: ""; position: absolute; right: -28px; bottom: -28px; width: 96px; height: 96px; border-radius: 50%; border: 14px solid var(--accent-soft); pointer-events: none; z-index: 0; }
.stat > * { position: relative; z-index: 1; }
.stat .label { color: var(--text-2); font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; }
.stat .value { font-family: var(--display); font-size: clamp(1.75rem, 1.4rem + 1vw, 2.35rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums lining-nums; color: var(--text); }
.stat .sub { color: var(--muted); font-size: .82rem; }
.delta-up { color: var(--good-ink); } .delta-down { color: var(--bad-ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px; padding: .45rem 1.05rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2; letter-spacing: -.005em;
  cursor: pointer; white-space: nowrap; text-decoration: none !important; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--p400); color: var(--accent-strong); background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-btn); }
.btn.primary:hover { color: #fff; box-shadow: 0 12px 28px rgba(124, 95, 214, .38); transform: translateY(-1px); }
.btn.good { background: var(--good); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(21, 128, 61, .22); }
.btn.good:hover { background: #136f35; color: #fff; }
.btn.danger { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad-ink) 30%, transparent); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad-ink); color: var(--bad-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { min-height: 34px; padding: .3rem .8rem; font-size: .82rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: background-color .15s, color .15s; -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .35rem; color: var(--text-2); }
.field { margin-bottom: 1rem; min-width: 0; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; line-height: 1.45; }
.field-check { display: flex; align-items: flex-end; padding-bottom: .55rem; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], input[type=tel],
input[type=datetime-local], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: .6rem .85rem;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:hover, select:hover, textarea:hover { border-color: var(--p400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--p600); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-2); cursor: not-allowed; }
select {
  padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c5fd6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center;
}
textarea { resize: vertical; min-height: 7rem; line-height: 1.55; }
input[type=color] { width: 3.2rem; height: 44px; border: 1px solid var(--border-strong); border-radius: 12px; padding: 4px; background: var(--surface); cursor: pointer; }
input[type=file] { font: inherit; font-size: .82rem; color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; font-size: .8rem; margin-right: .6rem; padding: .4rem .85rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--accent-soft); color: var(--accent-strong); }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; color: var(--text); margin-bottom: .5rem; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--p600); margin: 0; flex: none; cursor: pointer; }
.checks-inline { display: flex; gap: .5rem 1rem; flex-wrap: wrap; }
.pill-check { margin: 0; padding: .45rem .85rem .45rem .7rem; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); font-size: .88rem; }
.pill-check:has(input:checked) { background: var(--accent-soft); border-color: var(--p400); color: var(--accent-strong); font-weight: 600; }
.counter { font-size: .76rem; color: var(--muted); text-align: right; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad-ink); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 650; line-height: 1.5;
  padding: .12rem .6rem; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.s-pending_review { background: var(--accent-soft-2); color: var(--accent-strong); }
.badge.s-scheduled, .badge.s-publishing { background: var(--warn-soft); color: var(--warn-ink); }
.badge.s-published { background: var(--good-soft); color: var(--good-ink); }
.badge.s-ready_to_post { background: var(--accent-soft); color: var(--accent-strong); }
/* "post it yourself" hand-off */
.handoff { border-color: var(--accent); }
.handoff textarea { width: 100%; font: inherit; resize: vertical; }
.manual-add { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.manual-add p { margin: 0 0 .5rem; }
.connect-card .btn { max-width: 100%; white-space: normal; text-align: center; }
.banner.ready { background: var(--accent-soft); color: var(--text); align-items: center; flex-wrap: wrap; }
.banner.ready .grow { flex: 1 1 220px; }
.badge.s-failed { background: var(--bad-soft); color: var(--bad-ink); }
.badge.s-rejected { background: var(--surface-3); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: .45rem; font-weight: 650; font-size: .86rem; color: var(--text); white-space: nowrap; }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--chip, var(--muted)); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--chip, var(--muted)) 18%, transparent); }
.chip.instagram, .slot.instagram { --chip: var(--p-instagram); }
.chip.facebook, .slot.facebook { --chip: var(--p-facebook); }
.chip.x, .slot.x { --chip: var(--p-x); }
.chip.linkedin, .slot.linkedin { --chip: var(--p-linkedin); }
.chip.youtube, .slot.youtube { --chip: var(--p-youtube); }

/* ---------- alerts & notices ---------- */
.flashes { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.1rem; }
.alert { padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); border-left-width: 4px; background: var(--surface); font-size: .9rem; display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .75rem; }
.flashes .alert { margin: 0; }
.alert.success { background: var(--good-soft); border-color: transparent; border-left-color: var(--good-ink); color: var(--good-ink); }
.alert.error { background: var(--bad-soft); border-color: transparent; border-left-color: var(--bad-ink); color: var(--bad-ink); }
.alert.info { background: var(--accent-soft); border-color: transparent; border-left-color: var(--accent); color: var(--accent-strong); }
.alert.warn { background: var(--warn-soft); border-color: transparent; border-left-color: var(--warn); color: var(--warn-ink); }
.warnings { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.warnings li { font-size: .83rem; padding: .45rem .75rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn-ink); }
.warnings li.block { background: var(--bad-soft); color: var(--bad-ink); }
.banner { display: flex; gap: .5rem; align-items: flex-start; background: var(--warn-soft); color: var(--warn-ink); padding: .65rem 1rem; border-radius: var(--radius); font-size: .88rem; margin-bottom: 1.1rem; }
.working { display: inline-flex; align-items: center; gap: .5rem; color: var(--accent-strong); font-weight: 600; font-size: .88rem; background: var(--accent-soft); padding: .35rem .8rem; border-radius: 999px; }
.spinner { width: 15px; height: 15px; border: 2px solid var(--accent-soft-2); border-top-color: var(--p600); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables & lists ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.25rem; padding: 0 .25rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .7rem .65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 650; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: .7rem 0; border-bottom: 1px solid var(--border); display: flex; gap: .75rem; align-items: center; min-width: 0; }
.list li:last-child { border-bottom: 0; }
a.text-link { color: var(--text); font-weight: 500; }
a.text-link:hover { color: var(--accent-strong); }
.list li > .small { flex: none; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.checklist li .tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; flex: none; border: 2px solid var(--border-strong); color: transparent; }
.checklist li.done .tick { background: var(--grad); border-color: transparent; color: #fff; }
.checklist li.done a { color: var(--muted); text-decoration: line-through; }

/* ---------- post cards ---------- */
.idea-group { margin-bottom: 2.25rem; }
.idea-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.idea-head > div:first-child { flex: 1 1 380px; min-width: 0; }
.idea-head h2 { font-size: clamp(1.15rem, 1rem + .6vw, 1.45rem); }
.idea-head .rationale { color: var(--text-2); font-size: .9rem; max-width: 75ch; margin: 0; }
.idea-head .stack { flex: 0 1 420px; }
.card.post-card { padding: 0; overflow: hidden; container: card / inline-size; }
.post-card + .post-card { margin-top: 1.1rem; }
.post-card header { display: flex; align-items: center; gap: .6rem; padding: .8rem 1.2rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--surface-2); }
.post-body { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
.post-media { background: linear-gradient(180deg, var(--surface-3), var(--surface-2)); padding: 1.1rem; display: flex; flex-direction: column; gap: .7rem; border-right: 1px solid var(--border); min-width: 0; }
.post-media img, .post-media video { width: 100%; border-radius: 12px; display: block; max-height: 520px; object-fit: contain; box-shadow: 0 10px 30px rgba(37, 21, 82, .16); }
.post-media img { width: auto; max-width: 100%; height: auto; margin: 0 auto; }
.post-media video { background: #0f0a1c; }
.post-media .empty { aspect-ratio: 1; border: 2px dashed var(--border-strong); border-radius: 12px; display: grid; place-items: center; color: var(--muted); font-size: .85rem; text-align: center; padding: 1rem; }
.post-media form { margin: 0; }
.post-editor { padding: 1.15rem 1.25rem 1.25rem; min-width: 0; }
.post-editor textarea { min-height: 13rem; }
.schedule-row { display: flex; gap: .75rem 1rem; align-items: flex-end; flex-wrap: wrap; margin-top: .25rem; }
.schedule-row .field { margin: 0; flex: 0 1 260px; min-width: 200px; }
.button-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.1rem; }
.regen { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px dashed var(--border-strong); }
.regen input[type=text] { width: 100%; }
.idea-regen { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: 0; }
.idea-regen input[type=text] { width: auto; min-width: 200px; flex: 1; }
details.preview summary { font-size: .85rem; color: var(--accent-strong); font-weight: 600; margin-top: .25rem; }
.reason { font-size: .82rem; color: var(--muted); }
.schedule-row .reason { color: var(--accent-strong); background: var(--accent-soft); padding: .45rem .8rem; border-radius: 999px; margin-bottom: .1rem; }

/* ---------- calendar ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem; min-height: 132px; box-shadow: var(--shadow-sm); }
.day .date { font-size: .8rem; color: var(--text-2); font-weight: 700; margin-bottom: .5rem; }
.day.today { border-color: var(--p400); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 60%); }
.day.today .date { color: var(--accent-strong); }
.slot { font-size: .78rem; font-weight: 550; padding: .35rem .5rem; border-radius: 8px; background: var(--surface-2); margin-bottom: .35rem; display: block; color: var(--text); border-left: 3px solid var(--chip, var(--muted)); }
.slot:hover { text-decoration: none; background: var(--accent-soft); }

/* ---------- heatmap & charts ---------- */
.heatmap { border-collapse: separate; border-spacing: 3px; font-size: .7rem; width: 100%; table-layout: fixed; }
.heatmap th, .heatmap td { padding: 0; border: 0; text-align: center; color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.heatmap tbody tr:hover { background: none; }
.heatmap th.dayname { width: 38px; text-align: left; font-size: .75rem; }
.heatmap td.cell { height: 24px; border-radius: 5px; cursor: default; }
.heatmap td.cell.best { outline: 2px solid var(--text); outline-offset: -2px; }
.heat-legend { display: flex; align-items: center; gap: 3px; font-size: .75rem; color: var(--muted); margin-top: .6rem; flex-wrap: wrap; }
.heat-legend span.sw { width: 22px; height: 10px; border-radius: 3px; }
.lv0 { background: var(--seq-0); } .lv1 { background: var(--seq-1); } .lv2 { background: var(--seq-2); } .lv3 { background: var(--seq-3); }
.lv4 { background: var(--seq-4); } .lv5 { background: var(--seq-5); } .lv6 { background: var(--seq-6); } .lv7 { background: var(--seq-7); }
.tabs { display: flex; gap: .25rem; padding: .3rem; margin-bottom: 1.1rem; background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .tabs a { background: none; border: 0; padding: .5rem .95rem; border-radius: 999px; font: inherit; font-weight: 600; font-size: .88rem; color: var(--text-2); cursor: pointer; white-space: nowrap; text-decoration: none; }
.tabs button:hover, .tabs a:hover { color: var(--accent-strong); text-decoration: none; }
.tabs .on { background: var(--surface); color: var(--accent-strong); box-shadow: 0 2px 8px rgba(37, 21, 82, .1); }
.chart-box { position: relative; height: 280px; }
.legend { display: flex; gap: .5rem 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--text-2); margin-bottom: .6rem; }
.tip { position: fixed; z-index: 90; pointer-events: none; background: #251552; color: #fbf8ff; padding: .4rem .65rem; border-radius: 8px; font-size: .78rem; max-width: 260px; opacity: 0; transition: opacity .08s; box-shadow: 0 8px 24px rgba(15, 10, 28, .3); }
.tip.show { opacity: 1; }
.bars-wrap { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: 220px auto; gap: 0 .5rem; }
.bars-y { display: flex; flex-direction: column; justify-content: space-between; font-size: .72rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; transform: translateY(-.45em); height: calc(100% + .9em); }
.bars { position: relative; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid var(--axis);
  background: linear-gradient(to bottom, var(--grid) 1px, transparent 1px) 0 0 / 100% 50%; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; border-radius: 4px 4px 0 0; }
.bar-col:hover { background: var(--accent-soft); }
.bar-stack { width: 100%; max-width: 22px; margin: 0 auto; display: flex; flex-direction: column-reverse; gap: 2px; min-height: 0; }
.bar-stack .seg { min-height: 2px; }
.bar-stack .seg:last-child { border-radius: 4px 4px 0 0; }
.bars-x { grid-column: 2; display: flex; gap: 3px; font-size: .7rem; color: var(--muted); padding-top: .3rem; }
.bars-x span { flex: 1; min-width: 0; text-align: center; white-space: nowrap; overflow: visible; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.mixbar { position: relative; height: 10px; border-radius: 99px; background: var(--surface-3); min-width: 80px; }
.mixbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--seq-5); }
.mixbar .target { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 2px; }

/* ---------- settings ---------- */
.settings-nav {
  position: sticky; top: .75rem; z-index: 20; display: flex; gap: .25rem; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  width: max-content; max-width: 100%; margin: 0 0 1.25rem; padding: .3rem;
  background: var(--glass); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
}
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav a { padding: .45rem .95rem; border-radius: 999px; color: var(--text-2); font-size: .86rem; font-weight: 600; white-space: nowrap; }
.settings-nav a:hover { color: var(--accent-strong); background: var(--accent-soft); text-decoration: none; }
section.settings { scroll-margin-top: 4.5rem; margin-bottom: 1.4rem; }
section.settings > h2, section.settings .card > h2 { margin-bottom: .9rem; }
.settings h3 { margin-top: 1.25rem; color: var(--text); }
.platform-row { display: grid; grid-template-columns: 180px minmax(0, 1fr) auto; gap: .75rem 1rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.platform-row:last-child { border-bottom: 0; }
.platform-row details { grid-column: 1 / -1; }
.platform-row details form { margin-top: .75rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.kv { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: .45rem 1rem; font-size: .9rem; }
.kv dt { color: var(--text-2); font-weight: 550; } .kv dd { margin: 0; word-break: break-word; }
.ok { color: var(--good-ink); font-weight: 650; } .no { color: var(--bad-ink); font-weight: 650; }
.logo-row { display: flex; gap: 1rem; align-items: center; padding: .9rem; margin-bottom: 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); flex-wrap: wrap; }
.logo-preview { width: 148px; height: 76px; border-radius: 12px; background: #fff; display: grid; place-items: center; border: 1px solid var(--border); flex: none; }
.logo-preview img { max-width: 124px; max-height: 58px; object-fit: contain; }
.ai-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.ai-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; background: var(--surface-2); min-width: 0; }
.ai-block h3 { margin-bottom: .8rem; }

/* ---------- dialogs ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 24px; background: var(--surface); color: var(--text);
  padding: 1.4rem 1.5rem; width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .18s ease-out; }
dialog::backdrop { background: rgba(15, 10, 28, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog-head { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1rem; }
.dialog-head h2 { margin-bottom: .25rem; font-size: 1.35rem; outline: none; }
.dialog-head p { margin: 0; }
.dialog-head > div { flex: 1; min-width: 0; }
.dialog-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--grad); color: #fff; flex: none; box-shadow: var(--shadow-btn); }
.dialog-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; flex-wrap: wrap; }

/* ---------- live job progress ---------- */
.jobbar:empty { display: none; }
.jobbar { margin: -.5rem 0 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
.jobbar .job { display: flex; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--p300); border-left: 4px solid var(--p600); color: var(--text); border-radius: var(--radius); padding: .75rem 1rem; font-size: .9rem; box-shadow: var(--shadow); flex-wrap: wrap; }
.jobbar .job .grow { flex: 1 1 240px; }

.pagination { display: flex; gap: .5rem; justify-content: center; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }

/* ---------- login ---------- */
.login-page { background: var(--bg); }
.login { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.login-hero { position: relative; overflow: hidden; background: var(--grad-hero); color: #fff; padding: clamp(2rem, 4vw, 3.5rem); display: flex; flex-direction: column; }
.hero-waves { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.brand.on-dark .brand-text b { color: #fff; }
.brand.on-dark .brand-text small { color: rgba(255, 255, 255, .72); }
.brand.on-dark .brand-logo { width: 52px; }
.hero-copy { position: relative; margin: auto 0; max-width: 520px; padding: 2.5rem 0; }
.hero-copy h1 { color: #fff; font-size: clamp(2.2rem, 1.4rem + 2.6vw, 3.6rem); font-weight: 800; line-height: 1.04; letter-spacing: -.03em; margin-bottom: 1.1rem; }
.hero-copy h1 em { font-style: italic; font-weight: 700; color: #e5dcff; }
.hero-copy p { color: rgba(255, 255, 255, .86); font-size: 1.05rem; line-height: 1.6; max-width: 46ch; }
.hero-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-direction: column; gap: .7rem; }
.hero-points li { display: flex; gap: .7rem; align-items: center; color: rgba(255, 255, 255, .92); font-weight: 500; }
.hero-points .icon { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); }
.glass-note { position: absolute; display: flex; gap: .65rem; align-items: center; padding: .7rem .95rem; border-radius: 16px; background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .35); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 12px 32px rgba(15, 10, 28, .2); color: #fff; }
.glass-note .icon { width: 30px; height: 30px; padding: 7px; border-radius: 50%; background: #fff; color: var(--p700); }
.glass-note b { display: block; font-size: .85rem; }
.glass-note small { display: block; font-size: .74rem; opacity: .8; }
.glass-note.n1 { right: 8%; top: 16%; animation: float 6s ease-in-out infinite; }
.glass-note.n2 { right: 14%; bottom: 12%; animation: float 7s ease-in-out -2s infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem clamp(1rem, 4vw, 3rem); gap: 1.5rem; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: clamp(1.5rem, 3vw, 2.25rem); box-shadow: var(--shadow); }
.login-card h2 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2rem); margin-bottom: .3rem; }
.login-card .btn.primary { min-height: 48px; margin-top: .4rem; font-size: .98rem; }
.login-brand { display: none; margin-bottom: 1.5rem; }
.login-foot { margin: 0; text-align: center; }

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

/* ============================================================
   Responsive: components (by content width – container queries)
   ============================================================ */
@container main (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-grid { grid-template-columns: minmax(0, 1fr); }
}
@container main (max-width: 920px) {
  .week { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .4rem; -webkit-overflow-scrolling: touch; }
  .day { scroll-snap-align: start; min-height: 120px; }
}
@container main (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .platform-row details form { grid-template-columns: minmax(0, 1fr); }
  .platform-row { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .kv dd { margin-bottom: .6rem; }
  .idea-head .stack { flex: 1 1 100%; align-items: stretch !important; }
  .idea-head .stack form, .idea-head .stack .btn { width: 100%; }
  .field-check { padding-bottom: 0; }
  /* tables become compact cards: <table class="table-stack">, the title cell has class="cell-main",
     other cells flow on one wrapped line (cells with data-label get a small label) */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody { display: block; width: 100%; }
  .table-stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .9rem; padding: .9rem 0; border-bottom: 1px solid var(--border); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack tbody tr:hover { background: none; }
  .table-stack td { display: inline-flex; align-items: center; gap: .35rem; padding: 0; border: 0; text-align: left; flex: 0 1 auto; min-width: 0; width: auto !important; }
  .table-stack td:empty { display: none; }
  .table-stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .76rem; font-weight: 600; }
  .table-stack td.cell-main { order: -1; display: block; flex: 1 1 100%; }
  .table-stack td.cell-bar, .table-stack td.cell-actions { flex: 1 1 100%; }
  .table-stack td.cell-actions { flex-wrap: wrap; }
  .table-stack td.cell-actions > form, .table-stack td.cell-actions > .btn { margin: 0; }
  .table-stack td.cell-bar .mixbar { width: 100%; }
  .table-stack td.cell-actions form.row { flex-wrap: nowrap; width: 100%; }
  .table-stack td.cell-actions input { flex: 1; min-width: 0; width: auto !important; }
  .table-stack td form.row { justify-content: flex-end; }
}
@container main (max-width: 420px) {
  .grid-4 { gap: .7rem; }
  .grid-4 .card { padding: 1rem; }
  .stat .label { font-size: .7rem; }
}
@container card (max-width: 740px) {
  .post-body { grid-template-columns: minmax(0, 1fr); }
  .post-media { border-right: 0; border-bottom: 1px solid var(--border); }
  .post-media img, .post-media video { max-height: 440px; margin: 0 auto; }
  .post-media .empty { aspect-ratio: auto; min-height: 140px; }
}
@container card (max-width: 520px) {
  .post-card header { padding: .75rem 1rem; }
  .post-editor { padding: 1rem; }
  .post-media { padding: .9rem; }
  .button-row .btn { flex: 1 1 calc(50% - .5rem); }
  .schedule-row .field { flex: 1 1 100%; }
}

/* ============================================================
   Responsive: app shell (by screen width)
   ============================================================ */
/* tablets: icon rail */
@media (min-width: 768px) and (max-width: 1023.98px) {
  :root { --sidebar-w: 92px; }
  .sidebar { padding: 1rem .55rem; align-items: stretch; }
  .sidebar-head { justify-content: center; padding: .1rem 0 .7rem; }
  .sidebar .brand-text { display: none; }
  .sidebar .brand-logo { width: 46px; }
  .create-btn { width: 52px; height: 52px; min-height: 52px; padding: 0; border-radius: 16px; margin: .2rem auto .9rem; }
  .create-btn .label { display: none; }
  .nav a, .nav-btn { flex-direction: column; gap: .3rem; padding: .55rem .2rem; min-height: 58px; justify-content: center; font-size: .7rem; text-align: center; border-radius: 14px; line-height: 1.15; }
  .nav a.active::before { left: -.55rem; }
  .nav .count { position: absolute; top: 4px; right: 12px; margin: 0; font-size: .62rem; padding: 0 .35rem; min-width: 1.2rem; }
  .sidebar-foot .nav-btn .label { font-size: .7rem; }
}
/* phones: top app bar + bottom tab bar + slide-in drawer */
@media (max-width: 767.98px) {
  body { font-size: 15px; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], input[type=tel],
  input[type=datetime-local], input[type=date], input[type=time], input[type=search], select, textarea { font-size: 16px; } /* no iOS zoom */
  .layout { grid-template-columns: minmax(0, 1fr); }
  .appbar {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    position: sticky; top: 0; z-index: 40; height: calc(var(--appbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
    border-bottom: 1px solid var(--border);
  }
  .appbar .brand-logo { width: 36px; }
  .appbar .brand-text b { font-size: 1.12rem; }
  .appbar-actions { display: flex; gap: .4rem; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: auto; width: min(86vw, 320px); z-index: 70;
    background: var(--surface); box-shadow: var(--shadow-lg); border-right: 0;
    padding: calc(1rem + env(safe-area-inset-top)) .9rem calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-104%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; }
  body.drawer-open { overflow: hidden; }
  .icon-btn.drawer-close { display: inline-grid; }
  .nav a.active::before { display: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(15, 10, 28, .45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .main-inner { padding: 1.1rem 16px 2rem; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .topbar { margin-bottom: 1.1rem; align-items: flex-start; }
  .topbar > div:first-child { flex-basis: 100%; }
  .topbar .actions { width: 100%; }
  .topbar .actions > .btn.primary[data-open="generate-dialog"] { display: none; } /* the tab bar has Create */
  .topbar > form.row { width: 100%; }
  .topbar > form.row select { flex: 1 1 140px; width: auto !important; }
  .card { padding: 1.05rem 1rem; border-radius: 18px; }
  .settings-nav { top: calc(var(--appbar-h) + env(safe-area-inset-top) + .5rem); width: 100%; margin-bottom: 1rem; }
  section.settings { scroll-margin-top: calc(var(--appbar-h) + 4rem); }
  html { scroll-padding-top: calc(var(--appbar-h) + 1rem); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: end;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
    border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(37, 21, 82, .06);
  }
  .tabbar a, .tabbar button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: var(--tabbar-h); font: inherit; font-size: .68rem; font-weight: 600; color: var(--muted);
    background: none; border: 0; cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
  }
  .tabbar a.active, .tabbar button.active { color: var(--accent-strong); }
  .tabbar a.active .icon, .tabbar button.active .icon { color: var(--accent); }
  .tabbar .dot { position: absolute; top: 7px; left: calc(50% + 5px); font-style: normal; font-size: .62rem; font-weight: 700; color: #fff; background: var(--grad); border-radius: 99px; padding: 0 .35rem; min-width: 1.15rem; line-height: 1.45; text-align: center; border: 2px solid var(--surface); }
  .tabbar .dot.bad { background: var(--bad); }
  .tabbar .tab-create { align-self: center; justify-self: center; width: 54px; height: 54px; border-radius: 18px; background: var(--grad); color: #fff; box-shadow: var(--shadow-btn); transform: translateY(-14px); }
  .tabbar .tab-create:active { transform: translateY(-12px) scale(.97); }
  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 92dvh; padding: 1.2rem 16px calc(1.2rem + env(safe-area-inset-bottom)); border-bottom: 0; }
  dialog.sheet[open] { animation: sheet .24s cubic-bezier(.2, .8, .2, 1); }
  .dialog-actions .btn { flex: 1; }
  .button-row .btn { flex: 1 1 calc(50% - .5rem); }
  .regen .row .btn { flex: 1 1 calc(50% - .5rem); }
  .jobbar .job .btn { width: 100%; }
  /* login */
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-hero { display: none; }
  .login-brand { display: flex; }
  .login-page { background: var(--grad-hero) top / 100% 230px no-repeat, var(--bg); }
  .login-panel { justify-content: flex-start; padding-top: max(4.5rem, 12vh); }
  .login-card { box-shadow: var(--shadow-lg); }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 768px) and (max-width: 1023.98px) {
  .login { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .glass-note { display: none; }
}
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
}
@media print {
  .sidebar, .appbar, .tabbar, .scrim, .topbar .actions, .regen, .button-row { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
}

/* ======================================================================
   SaaS: workspace/brand switcher, auth extras, management pages
   ====================================================================== */
.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; }
.space-between { justify-content: space-between; }
.center-text { text-align: center; }
.err-text { color: var(--bad-ink); }
.ok-badge { background: var(--good-soft); color: var(--good-ink); }
.text-link { color: var(--link); cursor: pointer; font-weight: 600; }
.btn.link { background: none; border: 0; box-shadow: none; color: var(--link); padding: .25rem .5rem; min-height: 0; }

/* switcher (sidebar) */
.switcher { display: flex; flex-direction: column; gap: .4rem; margin: 0 0 .8rem; }
.switch-row { position: relative; display: flex; align-items: center; margin: 0; }
.switch-icon { position: absolute; left: .7rem; color: var(--accent); display: inline-flex; pointer-events: none; }
.switch-row select {
  width: 100%; min-height: 42px; padding: .45rem 2rem .45rem 2.2rem; border-radius: 12px;
  background-color: var(--surface); border: 1px solid var(--border-strong); font-weight: 600; font-size: .9rem;
  text-overflow: ellipsis;
}
.switch-row select:focus-visible { outline: none; box-shadow: var(--focus); border-color: var(--accent); }
.avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex: none; }
.nav-btn .ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.nav-btn { text-decoration: none; }
a.nav-btn.active { background: var(--accent-soft); color: var(--accent-strong); }

/* auth pages */
.google-btn { gap: .65rem; background: var(--surface); border: 1px solid var(--border-strong); font-weight: 650; }
.google-btn:hover { background: var(--surface-2); }
.or { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; color: var(--muted); font-size: .82rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.login-card.wide { max-width: 520px; }
.hero-steps { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: .6rem; counter-reset: step; }
.hero-steps li { counter-increment: step; display: flex; align-items: center; gap: .7rem; opacity: .78; }
.hero-steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.55); font-size: .8rem; font-weight: 700; flex: none; }
.hero-steps li.done::before { content: "✓"; background: rgba(255,255,255,.22); }
.hero-steps li.now { opacity: 1; font-weight: 650; }
.hero-steps li.now::before { background: #fff; color: var(--p700); border-color: #fff; }
.kind-pick { border: 0; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.kind-pick legend { font-weight: 650; font-size: .88rem; margin-bottom: .4rem; }
.kind-option { position: relative; display: block; cursor: pointer; }
.kind-option input { position: absolute; opacity: 0; inset: 0; }
.kind-option > span { display: grid; grid-template-columns: auto 1fr; column-gap: .7rem; align-items: center; padding: .7rem .9rem; border: 1.5px solid var(--border-strong); border-radius: 14px; background: var(--surface); transition: border-color .15s, background-color .15s; }
.kind-option > span .icon { grid-row: span 2; color: var(--accent); }
.kind-option > span small { color: var(--muted); }
.kind-option input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.kind-option input:focus-visible + span { box-shadow: var(--focus); }

/* workspaces */
.ws-item.current { background: var(--accent-soft); border-radius: 12px; padding-left: .6rem; padding-right: .6rem; }
.ws-avatar, .brand-swatch, .acct-avatar {
  display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad); color: #fff; font-weight: 750; font-size: 1.05rem;
}
.danger-zone { border-color: color-mix(in srgb, var(--bad-ink) 28%, var(--border)); }
.danger-zone .row input { flex: 1 1 220px; }
.empty-state { text-align: center; padding: 2rem 1rem; }

/* brands */
.brand-grid, .connect-grid, .plan-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }
.connect-grid { margin-bottom: 1rem; }
.brand-card { display: flex; flex-direction: column; gap: .7rem; }
.brand-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.brand-card.archived { opacity: .7; }
.brand-card-head { display: flex; align-items: center; gap: .75rem; }
.brand-card-head h2 { margin: 0; font-size: 1.08rem; }
.brand-swatch { background: linear-gradient(135deg, var(--c1), var(--c2)); }
.brand-desc { margin: 0; flex: 1; }
.brand-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; }
.brand-stats div { background: var(--surface-2); border-radius: 12px; padding: .5rem .6rem; }
.brand-stats dt { font-size: .72rem; color: var(--muted); }
.brand-stats dd { margin: 0; font-weight: 750; font-size: 1.1rem; }
.new-brand { border-style: dashed; justify-content: center; }
.new-brand h2 { display: flex; align-items: center; gap: .4rem; }

/* team */
.invite-link { border-color: var(--accent); margin-bottom: 1rem; }
.invite-link .row input { flex: 1 1 260px; font-family: var(--mono); font-size: .85rem; }
.inline-details summary { list-style: none; display: inline; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] form, .inline-details[open] div { margin-top: .5rem; }
.perm-matrix { width: 100%; border-collapse: collapse; font-size: .85rem; }
.perm-matrix th, .perm-matrix td { padding: .4rem .55rem; border-bottom: 1px solid var(--border); text-align: center; }
.perm-matrix thead th { font-size: .74rem; color: var(--text-2); vertical-align: bottom; white-space: normal; min-width: 64px; max-width: 96px; line-height: 1.25; }
.perm-matrix tbody th[scope=row] { text-align: left; font-weight: 500; color: var(--text-2); min-width: 200px; text-transform: none; letter-spacing: 0; font-size: .85rem; }
.perm-matrix tr.cat th { text-align: left; background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* social accounts */
.connect-card { display: flex; flex-direction: column; gap: .6rem; }
.connect-card .btn { align-self: flex-start; }
.connect-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.connect-head { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: .4rem; }
.pdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pdot.instagram { background: var(--p-instagram); } .pdot.facebook { background: var(--p-facebook); }
.pdot.x { background: var(--p-x); } .pdot.linkedin { background: var(--p-linkedin); } .pdot.youtube { background: var(--p-youtube); }
.pdot + .pdot { margin-left: -.25rem; }
.pdot:last-of-type { margin-right: .2rem; }
.acct { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.acct-avatar { border-radius: 50%; object-fit: cover; }
.acct-avatar.instagram { background: var(--p-instagram); } .acct-avatar.facebook { background: var(--p-facebook); }
.acct-avatar.x { background: var(--p-x); } .acct-avatar.linkedin { background: var(--p-linkedin); } .acct-avatar.youtube { background: var(--p-youtube); }
/* row actions: the cell stays a real table cell (display:flex on a <td> breaks the row's borders) */
.cell-actions { text-align: right; }
.cell-actions > form, .cell-actions > .btn { display: inline-flex; vertical-align: middle; margin: .175rem 0 .175rem .35rem; }

/* billing */
.usage-grid { display: grid; gap: 1rem 1.5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: .4rem; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--grad); min-width: 2px; }
.meter span.full { background: var(--bad); }
.plan-card { display: flex; flex-direction: column; gap: .5rem; }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan-card h2 { margin: 0; }
.plan-price { font-family: var(--display); font-size: 1.9rem; font-weight: 700; color: var(--accent-strong); }
.plan-price small { font-family: var(--font); font-size: .85rem; color: var(--muted); font-weight: 500; }
.plan-limits { margin: 0; padding-left: 1.1rem; flex: 1; }

/* tablet icon rail: the switcher needs room - use the Brands/Workspaces pages instead */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .switcher { display: none; }
  .nav-btn .avatar { width: 24px; height: 24px; }
}
@media (max-width: 767.98px) {
  .brand-stats dd { font-size: 1rem; }
  .cell-actions { justify-content: flex-start; }
}

/* ---------- platform admin ---------- */
.settings-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.plain-link { text-decoration: none; color: inherit; }
.plain-link:hover { text-decoration: none; }
.bad-text { color: var(--bad-ink); }
.admin-filter { margin-bottom: 1rem; }
.admin-filter input[type="search"] { flex: 1 1 240px; min-width: 0; }
.admin-filter select { flex: 0 1 auto; width: auto; }
.compact-kv { grid-template-columns: minmax(0, 1fr) auto; }
.compact-kv dd { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.list .acct-avatar { width: 34px; height: 34px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .85rem; }
.banner.support { align-items: center; flex-wrap: wrap; background: var(--accent-soft); color: var(--text); border: 1px solid var(--p400); }
.banner.support .grow { flex: 1 1 260px; }
.banner.support form { margin: 0; }
