/* Echo portal: shell + theme.
 *
 * Tokens, type scale, radii and the two breakpoints below come straight
 * from .superdesign/design-system.md -- do not invent new values there
 * without updating that doc first. Every rule in this file uses logical
 * properties (margin-inline-*, padding-block-*, inset-inline-*,
 * border-inline-*, text-align: start/end, ...) instead of left/right, so
 * `<html dir="rtl">` (portal/templates/base.html, driven by
 * portal/i18n.py) reflows correctly with zero extra rules -- the only
 * exceptions are a couple of `transform: scaleX(-1)` icon flips, which
 * aren't a left/right *property* and are the normal way to mirror a
 * directional glyph (an arrow/chevron) for RTL.
 */

:root {
  --bg: #F4F4F5;
  --surface: #FFFFFF;
  --surface-2: #F7F7F8;
  --border: #ECECEE;
  --text: #111111;
  --text-2: #5F6368;
  --text-3: #9AA0A6;
  --accent: #111111;
  --accent-text: #FFFFFF;
  --positive: #2FA36B;
  --positive-soft: #E8F7EF;
  --warning: #D98A1C;
  --warning-soft: #FDF3E4;
  --negative: #D14343;
  --negative-soft: #FCECEC;
  --info: #3B6FE0;
  --info-soft: #EAF0FC;

  --radius-inner: 10px;
  --radius-card: 14px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans-ar: "IBM Plex Sans Arabic", "Inter", system-ui, sans-serif;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0F11;
    --surface: #16181B;
    --surface-2: #1C1F23;
    --border: #26292E;
    --text: #F2F2F3;
    --text-2: #A8ADB4;
    --text-3: #6E747C;
    --accent: #FFFFFF;
    --accent-text: #111111;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html[dir="rtl"] body {
  font-family: var(--font-sans-ar);
}

a {
  color: inherit;
}

/* logo.svg hardcodes a dark stroke/fill (it's loaded through <img>/
 * <link rel="icon">, so CSS custom properties can't recolor it) --
 * invert it in dark mode so the mark stays visible against --bg
 * instead of going black-on-black. */
@media (prefers-color-scheme: dark) {
  .logo-mark {
    filter: invert(1);
  }
}

button,
input {
  font-family: inherit;
  font-size: inherit;
}

/* ---------------------------------------------------------------- shell */

.shell {
  display: flex;
  min-height: 100vh;
  max-width: 1440px;
  margin-inline: auto;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.sidebar {
  flex-shrink: 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  padding: var(--space-6) var(--space-4) var(--space-4);
  background: var(--bg);
  position: sticky;
  inset-block-start: 0;
  block-size: 100vh;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-inline: var(--space-2);
  margin-block-end: var(--space-8);
}

.logo-mark {
  flex-shrink: 0;
}

.brand-name {
  font-weight: 500;
  font-size: 16px;
}

/* The صدى wordmark (templates/_wordmark.html): PNGs in static/brand, light or dark by colour scheme. */
.wordmark {
  flex-shrink: 0;
  width: 71px;
  height: 29px;
  display: block;
}

.brand-lat {
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-2);
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-block-size: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}

a.nav-item:hover {
  color: var(--text);
}

.nav-item.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.nav-item.is-disabled {
  cursor: default;
  opacity: .65;
}

.nav-icon {
  flex-shrink: 0;
}

.soon-badge {
  margin-inline-start: auto;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 2px var(--space-2);
}

html:not([dir="rtl"]) .soon-badge {
  letter-spacing: .04em;
}

.nav-section-label {
  margin-block: var(--space-6) var(--space-2);
  padding-inline: var(--space-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-3);
}

html:not([dir="rtl"]) .nav-section-label {
  letter-spacing: .08em;
}

.sidebar-user {
  margin-block-start: auto;
  padding-block-start: var(--space-4);
}

.user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-inner);
}

.avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-email,
.user-brand {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.user-brand {
  font-size: 12px;
  color: var(--text-2);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-inline-start: 1px solid var(--border);
}

.topbar {
  block-size: 64px;
  padding-inline: var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-block-end: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  inset-block-start: 0;
  z-index: 40;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-2);
  min-width: 0;
}

.breadcrumb-sep {
  color: var(--text-3);
  flex-shrink: 0;
}

html[dir="rtl"] .breadcrumb-sep {
  transform: scaleX(-1);
}

.breadcrumb-current {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-shrink: 0;
}

.period-slot:empty {
  display: none;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin: 0;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  padding: 4px var(--space-3);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.lang-btn.is-active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.logout-form {
  margin: 0;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8);
}

.page-title {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 var(--space-1);
}

html:not([dir="rtl"]) .page-title {
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-2);
  font-size: 14px;
  margin: 0;
}

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  block-size: 36px;
  transition: opacity .15s ease, background-color .15s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  opacity: .9;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-block {
  display: flex;
  inline-size: 100%;
}

/* ------------------------------------------------------------ auth shell */

.auth-shell {
  min-block-size: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--bg);
}

.auth-card {
  inline-size: 100%;
  max-inline-size: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 16px;
}

.auth-heading {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

html:not([dir="rtl"]) .auth-heading {
  letter-spacing: -0.01em;
}

.auth-copy {
  color: var(--text-2);
  font-size: 14px;
  margin: 0;
}

.auth-error {
  margin: 0;
  color: var(--negative);
  background: var(--negative-soft);
  border-radius: var(--radius-inner);
  padding: var(--space-3);
  font-size: 13px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.oauth-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.field-input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  background: var(--surface);
  color: var(--text);
}

.field-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-link {
  color: var(--text);
  font-size: 13px;
}

.auth-lang-switch {
  align-self: flex-start;
}

.auth-credit {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}

/* ----------------------------------------------------------- responsive */

.dev-banner {
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: var(--space-1) var(--space-4);
}

/* -------------------------------------------------------------- overview */

.overview {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.period {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.period-btn {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.period-btn:hover {
  color: var(--text);
}

.period-btn.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-card);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  min-inline-size: 0;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 var(--space-4);
}

.grid-hero {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.grid-kpi {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.grid-split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--space-4);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.metric-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin: 0;
}

.kpi-value {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.kpi-sub {
  font-size: 13px;
  color: var(--text-3);
  margin: 0;
}

.kpi-sub.is-positive { color: var(--positive); }
.kpi-sub.is-negative { color: var(--negative); }
.kpi-sub.is-warning { color: var(--warning); }

.metric-empty {
  background: var(--surface-2);
  box-shadow: none;
}

.metric-hero {
  background: var(--surface);
  min-block-size: 148px;
  justify-content: space-between;
}

.metric-hero .metric-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.metric-empty-copy {
  font-size: 13px;
  color: var(--text-3);
  margin: 0;
}

.metric-hero .metric-empty-copy {
  font-size: 14px;
  color: var(--text-2);
  max-inline-size: 36ch;
}

.btn-pill {
  align-self: flex-start;
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: .6;
}

.btn-sm {
  block-size: 30px;
  padding: 0 var(--space-3);
  font-size: 12px;
  flex-shrink: 0;
}

.chart-box {
  position: relative;
  block-size: 240px;
}

.chart-note {
  font-size: 12px;
  color: var(--text-3);
  margin: var(--space-3) 0 0;
}

.attention-list,
.platform-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.attention-row,
.platform-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-inner);
  font-size: 13px;
}

.attention-empty {
  color: var(--text-2);
}

.attention-thumb {
  inline-size: 36px;
  block-size: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

.attention-text {
  flex: 1;
  min-inline-size: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.attention-setup .attention-text {
  display: flex;
  flex-direction: column;
}

.attention-sub {
  color: var(--text-3);
  font-size: 12px;
}

.status-dot {
  inline-size: 8px;
  block-size: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-3);
}

.platform-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.platform-mark {
  inline-size: 20px;
  block-size: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #FFFFFF;
  flex-shrink: 0;
}

.platform-instagram { background: linear-gradient(45deg, #F58529, #DD2A7B 55%, #8134AF); }
.platform-facebook { background: #1877F2; }
.platform-linkedin { background: #0A66C2; }
.platform-tiktok { background: #111111; box-shadow: inset 0 0 0 1px var(--border); }

.platform-name {
  flex: 1;
  font-weight: 500;
}

.pill {
  font-size: 12px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
}

.pill-muted {
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
}

.draft-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
  padding: var(--space-6);
  inline-size: min(640px, calc(100vw - 32px));
  max-block-size: calc(100vh - 64px);
}

.draft-dialog::backdrop {
  background: rgba(0, 0, 0, .35);
}

.draft-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.draft-preview-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.btn-ghost {
  background: none;
  border: 0;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.draft-preview-brief {
  font-size: 14px;
  margin: var(--space-3) 0;
}

.draft-preview-slides {
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-2);
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.draft-preview-slides img {
  inline-size: 200px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius-inner);
  scroll-snap-align: start;
  background: var(--surface-2);
}

.draft-preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  margin: var(--space-4) 0 var(--space-1);
}

.draft-preview-caption,
.draft-preview-notes,
.draft-preview-empty {
  font-size: 13px;
  color: var(--text-2);
  margin: 0;
  white-space: pre-line;
}


/* ---------------------------------------------------------- brand setup */

.auth-card-wide {
  max-inline-size: 640px;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.setup-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  padding: var(--space-4);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-inline-size: 0;
}

.setup-legend {
  font-size: 14px;
  font-weight: 600;
  padding-inline: var(--space-1);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-inline-size: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.field-input {
  font: inherit;
  font-size: 14px;
  inline-size: 100%;
}

.field-area {
  resize: vertical;
  min-block-size: 72px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-3);
  margin: 0;
}

.field-optional {
  color: var(--text-3);
  font-weight: 400;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-2);
  padding-block: 2px;
}

.choice strong {
  color: var(--text);
  font-weight: 500;
}

.day-picks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-inline-start: var(--space-5);
}

.day-pick {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 13px;
  padding: 2px var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.setup-error {
  color: var(--negative);
  font-size: 12px;
  margin: 0;
}

.auth-error.setup-error {
  font-size: 13px;
}

.setup-wait {
  text-align: center;
}

.setup-logout {
  display: flex;
  justify-content: center;
}

/* --------------------------------------------------------------- content */

.content-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.tabs {
  display: flex;
  gap: var(--space-1);
  box-shadow: inset 0 -1px 0 var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: 14px;
  color: var(--text-2);
  text-decoration: none;
  border-block-end: 2px solid transparent;
  white-space: nowrap;
}

.tab.is-active {
  color: var(--text);
  font-weight: 500;
  border-block-end-color: var(--accent);
}

.tab-count {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.post-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  color: var(--text);
  text-decoration: none;
  block-size: 100%;
  transition: border-color .15s ease;
}

.post-card:hover {
  border-color: var(--text-3);
}

.post-thumb {
  inline-size: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius-inner);
  background: var(--surface-2);
  display: block;
}

.post-brief {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  font-size: 12px;
  color: var(--text-3);
  margin: 0;
}

.empty-note {
  color: var(--text-2);
  font-size: 14px;
  margin: 0;
}

.back-link {
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  align-self: flex-start;
}

.notice {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-inner);
  background: var(--positive-soft);
  color: var(--positive);
  font-size: 14px;
}

.notice.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: var(--space-4);
  align-items: start;
}

.post-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.post-slides {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}

/* One image (a single-image post) gets the whole column. */
.post-slides:has(> li:only-child) {
  grid-template-columns: minmax(0, 480px);
}

.slide-link {
  position: relative;
  display: block;
  border-radius: var(--radius-inner);
  overflow: hidden;
  cursor: zoom-in;
}

.slide-link img {
  display: block;
  inline-size: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--surface-2);
}

.slide-zoom {
  position: absolute;
  inset-block-end: var(--space-2);
  inset-inline-end: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, .6);
  color: #FFFFFF;
  font-size: 11px;
  opacity: 0;
  transition: opacity .15s ease;
}

.slide-link:hover .slide-zoom,
.slide-link:focus-visible .slide-zoom {
  opacity: 1;
}

.post-title {
  font-size: 16px;
  font-weight: 600;
  margin: var(--space-3) 0 var(--space-2);
}

.post-caption {
  font-size: 14px;
  color: var(--text-2);
  white-space: pre-line;
  margin: 0;
}

.pill-status {
  display: inline-block;
  margin: 0;
  background: var(--surface-2);
  color: var(--text-2);
}

.pill-status.is-draft { background: var(--warning-soft); color: var(--warning); }
.pill-status.is-approved { background: var(--positive-soft); color: var(--positive); }
.pill-status.is-posted { background: var(--info-soft); color: var(--info); }

.post-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.action-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.btn-danger {
  background: var(--surface);
  color: var(--negative);
  border-color: var(--border);
}

.btn-danger:hover {
  background: var(--negative-soft);
}

/* Fullscreen slide viewer (static/echo.js) */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.viewer-open {
  overflow: hidden;
}

.viewer[hidden] {
  display: none;
}

.viewer-img {
  max-inline-size: 100vw;
  max-block-size: 100vh;
  object-fit: contain;
}

.viewer-btn {
  position: absolute;
  inline-size: 44px;
  block-size: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .14);
  color: #FFFFFF;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.viewer-btn:hover {
  background: rgba(255, 255, 255, .26);
}

.viewer-close {
  inset-block-start: var(--space-4);
  inset-inline-end: var(--space-4);
}

.viewer-prev,
.viewer-next {
  inset-block-start: 50%;
  transform: translateY(-50%);
}

.viewer-prev { inset-inline-start: var(--space-4); }
.viewer-next { inset-inline-end: var(--space-4); }

html[dir="rtl"] .viewer-prev,
html[dir="rtl"] .viewer-next {
  transform: translateY(-50%) scaleX(-1);
}

.viewer-count {
  position: absolute;
  inset-block-end: var(--space-4);
  margin: 0;
  color: rgba(255, 255, 255, .8);
  font-size: 13px;
}

/* ---------------------------------------------------------------- trends */

.trend-offer {
  align-items: flex-start;
  border: 2px solid var(--a, var(--accent));
  background: var(--surface);
}

.trend-thumb {
  inline-size: 72px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.trend-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-inline-size: 0;
}

.trend-link {
  font-size: 12px;
  color: var(--text-2);
}

.trend-actions {
  display: flex;
  gap: var(--space-2);
  margin-block-start: var(--space-2);
  flex-wrap: wrap;
}

.trend-accounts {
  grid-template-columns: minmax(0, 1fr);
  margin-block-end: var(--space-5);
}

.trend-add {
  max-inline-size: 420px;
}

/* Connections page */
.notice.is-neutral {
  background: var(--surface-2);
  color: var(--text-2);
}

.connections-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.connection-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.connection-card.is-soon {
  color: var(--text-2);
}

.connection-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.connection-head .card-title {
  flex: 1;
  margin: 0;
}

.connection-account {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.connection-avatar {
  inline-size: 44px;
  block-size: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.connection-meta {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
}

.connection-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.connection-handle {
  color: var(--text-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.connection-note {
  margin: 0;
  font-size: 14px;
  color: var(--text-2);
}

.connection-missing {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-inner);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
}

.connection-missing-title {
  margin: 0 0 var(--space-1);
  font-weight: 600;
}

.connection-missing ul {
  margin: 0;
  padding-inline-start: var(--space-5);
}

.connection-btn {
  align-self: flex-start;
  text-decoration: none;
}

.confirm > summary {
  list-style: none;
  display: inline-flex;
}

.confirm > summary::-webkit-details-marker {
  display: none;
}

.confirm-body {
  margin-block-start: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: 14px;
}

.confirm-body p {
  margin: 0;
}

.pill-status.is-connected { background: var(--positive-soft); color: var(--positive); }
.pill-status.is-expiring { background: var(--warning-soft); color: var(--warning); }
.pill-status.is-needs_reconnect { background: var(--negative-soft); color: var(--negative); }
.pill-status.is-not_connected { background: var(--surface-2); color: var(--text-2); }

@media (max-width: 899.98px) {
  .menu-toggle {
    display: inline-flex;
    position: fixed;
    inset-block-start: var(--space-4);
    inset-inline-start: var(--space-4);
    z-index: 60;
  }

  .sidebar {
    display: none;
  }

  .sidebar.is-open {
    display: flex;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 55;
    inline-size: 240px;
    max-inline-size: 85vw;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35);
  }

  .main {
    border-inline-start: 0;
  }

  .topbar {
    padding-inline-start: 60px;
  }

  .grid-kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-split,
  .post-layout,
  .connections-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .platform-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .topbar {
    block-size: auto;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    padding-inline-start: 60px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .content {
    padding: var(--space-4);
  }

  .page-title {
    font-size: 22px;
  }

  .grid-hero,
  .grid-kpi,
  .platform-list,
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-card {
    padding: var(--space-6);
  }
}

/* Results pages (portal/templates/results*.html). Phone first: the 1-hour
 * link opens from Telegram, so the ticket pages use a bare shell (no
 * sidebar, no forms) and every grid starts as one column. */
.bare-shell {
  min-height: 100vh;
  max-width: 1080px;
  margin-inline: auto;
  background: var(--surface-2);
}

.bare-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border-block-end: 1px solid var(--border);
  background: var(--surface);
}

.bare-content {
  padding: var(--space-4);
}

.result-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: var(--space-2) var(--space-3);
  margin: 0;
}

.result-numbers dt {
  font-size: 12px;
  color: var(--text-3);
}

.result-numbers dd {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.results-section .attention-sub {
  display: block;
}

.post-meta.is-warning {
  color: var(--warning);
}

.result-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.results-post-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.results-post-card .post-thumb {
  max-block-size: 480px;
}

.audience-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.audience-list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 14px;
}

.audience-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
}

.audience-pct {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Two platforms (results.html, results_post.html): the list card's
 * per-platform line under each sum, and a post's platform tabs. Without JS
 * the tab bar stays hidden and every panel shows, each under its own title. */
.result-numbers .result-breakdown {
  margin-block-start: 2px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
}

.platform-tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
}

.platform-tabs[hidden],
.platform-panel[hidden] {
  display: none;
}

.platform-tab {
  flex: 1 1 0;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.platform-tab[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-text);
}

.platform-tab:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.platform-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.platform-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.platform-head .card-title,
.platform-head .notice,
.platform-head .post-meta {
  margin: 0;
}

.audience-platform {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

@media (min-width: 900px) {
  .bare-content {
    padding: var(--space-8);
  }

  .audience-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Facebook Page picker (fb_pick.html) */
.pick-list {
  border: 0;
  margin: 0 0 var(--space-4);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pick-list .choice {
  font-size: 15px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Stories (1080x1920): thumbnails show the whole image inside the usual 4:5
 * box; the detail image is 9:16 and is never cropped. Feed posts keep 4:5. */
.pill-story {
  display: inline-block;
  align-self: flex-start;
  margin: 0;
  background: var(--surface-2);
  color: var(--text-2);
}

.post-thumb.is-story,
.attention-thumb.is-story,
.draft-preview-slides.is-story img {
  object-fit: contain;
  background: var(--surface-2);
}

.post-slides.is-story:has(> li:only-child) {
  grid-template-columns: minmax(0, 360px);
}

.post-slides.is-story .slide-link img,
.draft-preview-slides.is-story img {
  aspect-ratio: 9 / 16;
  object-fit: contain;
}

.post-apps {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.post-apps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.post-app {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.post-app-name {
  font-weight: 600;
}

.topbar-link {
  color: var(--text-2);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-link:hover,
.topbar-link.is-active {
  color: var(--text);
}

.notice-link {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.video-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-inline-size: 640px;
}

.video-form .field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Videos (reels and animations, 1080x1920, V9): lists show the cover frame whole with a play badge, like a
 * story; the post page and the draft preview play the MP4 in a 9:16 box. */
.post-thumb-wrap {
  position: relative;
  display: block;
}

.post-thumb.is-video,
.attention-thumb.is-video {
  object-fit: contain;
  background: var(--surface-2);
}

.play-badge {
  position: absolute;
  inset: 0;
  margin: auto;
  inline-size: 44px;
  block-size: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .6);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.post-video,
.draft-preview-video {
  display: block;
  inline-size: 100%;
  max-inline-size: 360px;
  aspect-ratio: 9 / 16;
  background: #000000;
  border-radius: var(--radius-inner);
}

.draft-preview-video {
  max-inline-size: 240px;
  margin-block-end: var(--space-2);
}

/* The Request page. The file fields only apply to a Reel or an Animation. */
.request-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-inline-size: 640px;
}

.request-form fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

.request-kind-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-start: var(--space-1);
}

.request-kind {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 14px;
  cursor: pointer;
}

.request-kind:has(input:checked) {
  border-color: var(--accent);
}

.request-files {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.request-files legend {
  margin-block-end: var(--space-3);
  font-weight: 600;
  color: var(--text);
}

.request-files input[type="file"] {
  max-inline-size: 100%;
}

.request-form:has(input[name="kind"][value="post"]:checked) .request-files,
.request-form:has(input[name="kind"][value="story"]:checked) .request-files {
  display: none;
}
