/* ============================================================================
   vortextual.com — shared design system
   One stylesheet, linked by every screen. No CDN, no font import, no framework.
   Token families: --c-* colour, --s-* spacing, --t-* type, --r-* radii, --sh-* shadow.
   ============================================================================ */

/* ---- Design tokens --------------------------------------------------------- */
:root {
  /* Surfaces */
  --c-bg:            #f5f7fb;
  --c-surface:       #ffffff;
  --c-surface-2:     #fafbfe;
  --c-sunken:        #eef1f7;
  --c-border:        #e2e7f0;
  --c-border-strong: #d0d8e6;

  /* Text */
  --c-ink:   #0f1626;
  --c-ink-2: #333e52;
  --c-ink-3: #5a6579;
  --c-ink-4: #8590a3;

  /* Accent — vortex violet */
  --c-accent:     #6d3df5;
  --c-accent-600: #5b2ee0;
  --c-accent-soft: #f0eafe;
  --c-accent-ink: #4a1fb0;

  /* Feedback */
  --c-danger:      #d92d20;  --c-danger-soft:  #fdecea;
  --c-success:     #067a54;  --c-success-soft: #dcf5ec;
  --c-warn:        #b54708;  --c-warn-soft:    #fdf1de;
  --c-info:        #175cd3;  --c-info-soft:    #e7f0ff;

  /* Article states — one pair per ArticleState (see docs/02-article-lifecycle.md).
     The badge modifier suffix is the enum as_str(), so these names track it. */
  --c-st-pending-generation:      #6b7280;  --c-st-pending-generation-soft: #eef0f4;
  --c-st-generated:               #175cd3;  --c-st-generated-soft:          #e7f0ff;
  --c-st-scheduled:               #6941c6;  --c-st-scheduled-soft:          #f0eafe;
  --c-st-published:               #067a54;  --c-st-published-soft:          #dcf5ec;
  --c-st-failed:                  #d92d20;  --c-st-failed-soft:             #fdecea;

  /* Type */
  --t-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --t-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --t-xs:   11px;
  --t-sm:   12.5px;
  --t-base: 14px;
  --t-md:   15px;
  --t-lg:   17px;
  --t-xl:   20px;
  --t-2xl:  26px;
  --t-3xl:  33px;

  /* Spacing — 4/8 scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 48px; --s-10: 64px;

  /* Radii */
  --r-sm: 6px; --r-md: 9px; --r-lg: 13px; --r-xl: 18px; --r-full: 999px;

  /* Shadows */
  --sh-xs: 0 1px 2px rgba(15,22,38,.05);
  --sh-sm: 0 1px 3px rgba(15,22,38,.07), 0 1px 2px rgba(15,22,38,.04);
  --sh-md: 0 4px 12px rgba(15,22,38,.08), 0 2px 4px rgba(15,22,38,.04);
  --sh-lg: 0 12px 32px rgba(15,22,38,.12), 0 4px 8px rgba(15,22,38,.05);
  --sh-accent: 0 6px 20px rgba(109,61,245,.24);

  --header-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg:            #0a0f1a;
    --c-surface:       #131a28;
    --c-surface-2:     #0f1622;
    --c-sunken:        #0d1420;
    --c-border:        #222b3c;
    --c-border-strong: #2e3849;

    --c-ink:   #eef2f8;
    --c-ink-2: #c2cbd9;
    --c-ink-3: #93a0b3;
    --c-ink-4: #6b7688;

    --c-accent:      #9b77fa;
    --c-accent-600:  #8b60f8;
    --c-accent-soft: #211a3d;
    --c-accent-ink:  #c3adfd;

    --c-danger-soft:  #2c1517;
    --c-success-soft: #0d2a21;
    --c-warn-soft:    #2b2010;
    --c-info-soft:    #14233c;

    --c-st-pending-generation:      #9aa3b2;  --c-st-pending-generation-soft: #1a2130;
    --c-st-generated:               #6ba1f5;  --c-st-generated-soft:          #14233c;
    --c-st-scheduled:               #b195fb;  --c-st-scheduled-soft:          #211a3d;
    --c-st-published:               #47c79b;  --c-st-published-soft:          #0d2a21;
    --c-st-failed:                  #f5827a;  --c-st-failed-soft:             #2c1517;

    --sh-xs: 0 1px 2px rgba(0,0,0,.4);
    --sh-sm: 0 1px 3px rgba(0,0,0,.5);
    --sh-md: 0 4px 14px rgba(0,0,0,.45);
    --sh-lg: 0 14px 36px rgba(0,0,0,.55);
    --sh-accent: 0 6px 22px rgba(139,96,248,.32);
  }
}

/* ---- Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--t-font);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; color: var(--c-ink); }
p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---- Brand wordmark -------------------------------------------------------- */
.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: var(--t-lg); letter-spacing: -.03em; color: var(--c-ink);
}
.wordmark__glyph {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--c-accent), #a273ff 92%);
  box-shadow: var(--sh-accent);
  display: grid; place-items: center;
}
.wordmark__glyph svg { width: 17px; height: 17px; display: block; }
.wordmark .thin { color: var(--c-ink-3); font-weight: 560; }

/* ---- App header (authenticated chrome) ------------------------------------- */
.appheader {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 20;
}
.appheader .nav { display: flex; align-items: center; gap: var(--s-1); margin-left: var(--s-4); }
.appheader .nav a {
  padding: 7px 12px; border-radius: var(--r-sm);
  color: var(--c-ink-3); font-weight: 560; font-size: var(--t-base);
}
.appheader .nav a:hover { background: var(--c-sunken); color: var(--c-ink); }
.appheader .nav a.active { background: var(--c-accent-soft); color: var(--c-accent-ink); font-weight: 620; }
.appheader__right { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }

/* Tenant switcher */
.switcher {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 11px; border: 1px solid var(--c-border); border-radius: var(--r-md);
  background: var(--c-surface); color: var(--c-ink);
  font-family: inherit; font-weight: 600; font-size: var(--t-base); cursor: pointer;
  box-shadow: var(--sh-xs);
}
.switcher:hover { background: var(--c-sunken); }
.switcher__dot { width: 8px; height: 8px; border-radius: 3px; background: var(--c-accent); flex: none; }
.switcher svg { width: 14px; height: 14px; color: var(--c-ink-4); }

/* User menu */
.usermenu { display: inline-flex; align-items: center; gap: var(--s-2); padding: 4px 8px 4px 4px; border-radius: var(--r-full); }
.usermenu:hover { background: var(--c-sunken); }
.usermenu__name { font-size: var(--t-sm); font-weight: 560; color: var(--c-ink-2); }
.avatar {
  width: 30px; height: 30px; border-radius: var(--r-full); flex: none;
  display: grid; place-items: center; font-weight: 650; font-size: var(--t-sm); color: #fff;
  background: linear-gradient(135deg, #6d3df5, #a273ff);
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 40px; height: 40px; font-size: var(--t-base); }

/* ---- Page layout ----------------------------------------------------------- */
.content { padding: var(--s-7) var(--s-6) var(--s-10); max-width: 1200px; width: 100%; margin: 0 auto; }
.content--narrow { max-width: 860px; }

.pagehead { display: flex; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.pagehead__main { flex: 1; min-width: 240px; }
.pagehead h1 { font-size: var(--t-2xl); }
.pagehead__sub { color: var(--c-ink-3); margin-top: 6px; font-size: var(--t-md); }
.pagehead__actions { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: var(--t-sm); color: var(--c-ink-4); margin-bottom: 10px; flex-wrap: wrap; }
.breadcrumb a { color: var(--c-ink-3); }
.breadcrumb a:hover { color: var(--c-ink); text-decoration: underline; }
.breadcrumb svg { width: 13px; height: 13px; flex: none; }
.breadcrumb__current { color: var(--c-ink-2); font-weight: 560; }

.section-title {
  font-size: var(--t-xs); font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
  color: var(--c-ink-4); margin-bottom: var(--s-3);
}

/* ---- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-weight: 600; font-size: var(--t-base); line-height: 1;
  padding: 9px 15px; border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--c-accent); color: #fff; box-shadow: var(--sh-accent); }
.btn--primary:hover { background: var(--c-accent-600); }
.btn--ghost { background: var(--c-surface); color: var(--c-ink-2); border-color: var(--c-border-strong); box-shadow: var(--sh-xs); }
.btn--ghost:hover { background: var(--c-sunken); color: var(--c-ink); }
.btn--subtle { background: var(--c-sunken); color: var(--c-ink-2); }
.btn--subtle:hover { background: var(--c-border); }
.btn--danger { background: var(--c-surface); color: var(--c-danger); border-color: var(--c-border-strong); }
.btn--danger:hover { background: var(--c-danger-soft); border-color: var(--c-danger); }
.btn--sm { padding: 6px 11px; font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn--lg { padding: 12px 20px; font-size: var(--t-md); }
.btn--block { width: 100%; }
.btn[disabled], .btn:disabled {
  opacity: .5; cursor: not-allowed; box-shadow: none;
  background: var(--c-sunken); color: var(--c-ink-4); border-color: var(--c-border);
}

/* ---- Cards ----------------------------------------------------------------- */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card__head {
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
}
.card__head h2, .card__head h3 { font-size: var(--t-lg); }
.card__head .grow { flex: 1; min-width: 160px; }
.card__body { padding: var(--s-5); }
.card__foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--c-border); display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

.grid { display: grid; gap: var(--s-5); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid.cols-4 { grid-template-columns: repeat(2,1fr); } .grid.cols-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 700px)  { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---- KPI tiles ------------------------------------------------------------- */
.kpi { padding: var(--s-5); }
.kpi__label { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); font-weight: 560; color: var(--c-ink-3); }
.kpi__label .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--c-accent-soft); color: var(--c-accent); flex: none; }
.kpi__label .ic svg { width: 15px; height: 15px; }
.kpi__value { font-size: var(--t-3xl); font-weight: 700; letter-spacing: -.03em; margin-top: 12px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi__meta { margin-top: 10px; font-size: var(--t-sm); color: var(--c-ink-3); }
.kpi--danger .kpi__label .ic { background: var(--c-danger-soft); color: var(--c-danger); }
.kpi--danger .kpi__value { color: var(--c-danger); }

/* ---- Badges ---------------------------------------------------------------- */
/* Colour never carries meaning alone: a badge is always dot + text label. */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--t-xs); font-weight: 650; padding: 3px 9px;
  border-radius: var(--r-full); white-space: nowrap;
}
.badge__dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: currentColor; }

/* Article states — suffix == ArticleState::as_str() */
.badge--pending_generation { color: var(--c-st-pending-generation); background: var(--c-st-pending-generation-soft); }
.badge--generated          { color: var(--c-st-generated);          background: var(--c-st-generated-soft); }
.badge--scheduled          { color: var(--c-st-scheduled);          background: var(--c-st-scheduled-soft); }
.badge--published          { color: var(--c-st-published);          background: var(--c-st-published-soft); }
.badge--failed             { color: var(--c-st-failed);             background: var(--c-st-failed-soft); }

/* Non-domain badges */
.badge--neutral { color: var(--c-ink-3);      background: var(--c-sunken); }
.badge--ok      { color: var(--c-success);    background: var(--c-success-soft); }
.badge--warn    { color: var(--c-warn);       background: var(--c-warn-soft); }
.badge--danger  { color: var(--c-danger);     background: var(--c-danger-soft); }
.badge--accent  { color: var(--c-accent-ink); background: var(--c-accent-soft); }

/* ---- Tables ---------------------------------------------------------------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--t-base); }
table.data thead th {
  text-align: left; font-weight: 600; font-size: var(--t-xs); letter-spacing: .05em; text-transform: uppercase;
  color: var(--c-ink-4); padding: 11px var(--s-4); border-bottom: 1px solid var(--c-border);
  white-space: nowrap; background: var(--c-surface-2);
}
table.data tbody td { padding: 13px var(--s-4); border-bottom: 1px solid var(--c-border); color: var(--c-ink-2); vertical-align: middle; }
table.data tbody tr:hover { background: var(--c-surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .primary { color: var(--c-ink); font-weight: 560; }
.cell-title { display: flex; flex-direction: column; gap: 3px; min-width: 220px; }
.cell-title .t { color: var(--c-ink); font-weight: 580; }
.cell-title .m { color: var(--c-ink-4); font-size: var(--t-sm); }
.cell-media { display: flex; align-items: center; gap: var(--s-3); }

/* ---- Thumbnails (inline SVG placeholders, never a binary asset) ------------ */
.thumb {
  width: 48px; height: 48px; flex: none; border-radius: var(--r-md);
  background: var(--c-sunken); border: 1px solid var(--c-border);
  display: grid; place-items: center; overflow: hidden; color: var(--c-accent);
}
.thumb__svg { width: 100%; height: 100%; display: block; }
.thumb--empty { color: var(--c-ink-4); border-style: dashed; background: var(--c-surface-2); }
.thumb--lg { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: var(--r-lg); }

/* ---- Lists of linked rows -------------------------------------------------- */
.listrow {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border);
}
.listrow:last-child { border-bottom: 0; }
.listrow:hover { background: var(--c-surface-2); }
.listrow__main { flex: 1; min-width: 0; }
.listrow__title { color: var(--c-ink); font-weight: 600; font-size: var(--t-md); }
.listrow__meta { color: var(--c-ink-4); font-size: var(--t-sm); margin-top: 3px; }

/* ---- Definition list (read-back of configuration) -------------------------- */
.deflist { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: var(--s-3) var(--s-4); }
.deflist dt { color: var(--c-ink-4); font-size: var(--t-sm); font-weight: 560; }
.deflist dd { margin: 0; color: var(--c-ink-2); }
@media (max-width: 620px) { .deflist { grid-template-columns: 1fr; gap: var(--s-1); } .deflist dd { margin-bottom: var(--s-3); } }

/* ---- Forms ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: var(--s-5); }
.field > label { font-weight: 600; font-size: var(--t-sm); color: var(--c-ink-2); }
.field__hint { font-size: var(--t-sm); color: var(--c-ink-4); }
.field__error { font-size: var(--t-sm); color: var(--c-danger); font-weight: 560; display: flex; align-items: flex-start; gap: 6px; }
.field__error svg { width: 14px; height: 14px; flex: none; margin-top: 1px; }

.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: var(--t-base); color: var(--c-ink);
  padding: 10px 12px; border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface); transition: border-color .12s, box-shadow .12s;
}
.input::placeholder, .textarea::placeholder { color: var(--c-ink-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.input.is-invalid, .textarea.is-invalid, .select.is-invalid {
  border-color: var(--c-danger); box-shadow: 0 0 0 3px var(--c-danger-soft);
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.55; }
.textarea--tall { min-height: 240px; font-family: var(--t-mono); font-size: var(--t-sm); }
.select {
  appearance: none;
  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='%238590a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px;
}

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track { position: absolute; inset: 0; background: var(--c-border-strong); border-radius: var(--r-full); transition: background .16s; cursor: pointer; }
.switch__track::before { content: ""; position: absolute; width: 19px; height: 19px; left: 3px; top: 3px; background: #fff; border-radius: 50%; box-shadow: var(--sh-sm); transition: transform .16s; }
.switch input:checked + .switch__track { background: var(--c-accent); }
.switch input:checked + .switch__track::before { transform: translateX(19px); }

/* ---- Exclusive visual options (choice cards) ------------------------------- */
/* Used for source kind and image_mode. The native radio stays the control so
   keyboard and assistive technology behave without any JS. */
.choices { display: grid; gap: var(--s-3); }
.choices--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 760px) { .choices--2 { grid-template-columns: 1fr; } }

.choice {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4); border: 1px solid var(--c-border-strong); border-radius: var(--r-lg);
  background: var(--c-surface); cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s;
  /* A .choice is a <label> when it selects a value inside a form, and an <a>
     when picking it *is* the navigation (step 1 of source creation, where each
     kind leads to its own step-2 form). Both render identically. */
  text-decoration: none; color: inherit;
}
.choice:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.choice__go { margin-left: auto; align-self: center; color: var(--c-ink-4); flex: none; }
.choice__go svg { width: 18px; height: 18px; }
.choice:hover { border-color: var(--c-accent); background: var(--c-surface-2); }
.choice input[type="radio"] { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--c-accent); flex: none; }
.choice__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.choice__title { font-weight: 640; color: var(--c-ink); font-size: var(--t-md); display: flex; align-items: center; gap: 8px; }
.choice__title svg { width: 17px; height: 17px; color: var(--c-accent); flex: none; }
.choice__desc { font-size: var(--t-sm); color: var(--c-ink-3); line-height: 1.5; }
.choice:has(input:checked) { border-color: var(--c-accent); background: var(--c-accent-soft); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.choice:has(input:disabled) { opacity: .55; cursor: not-allowed; background: var(--c-sunken); }
.choice--lg { padding: var(--s-5); }

/* ---- Alerts ---------------------------------------------------------------- */
.alert {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4); border-radius: var(--r-md); border: 1px solid transparent;
  font-size: var(--t-base); line-height: 1.55;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert__title { font-weight: 640; margin-bottom: 3px; }
.alert__body { min-width: 0; }
.alert--info   { background: var(--c-info-soft);    color: var(--c-info);    border-color: color-mix(in srgb, var(--c-info) 24%, transparent); }
.alert--ok     { background: var(--c-success-soft); color: var(--c-success); border-color: color-mix(in srgb, var(--c-success) 24%, transparent); }
.alert--warn   { background: var(--c-warn-soft);    color: var(--c-warn);    border-color: color-mix(in srgb, var(--c-warn) 24%, transparent); }
.alert--danger { background: var(--c-danger-soft);  color: var(--c-danger);  border-color: color-mix(in srgb, var(--c-danger) 24%, transparent); }
.alert__body .muted { color: inherit; opacity: .85; }
/* A link inside a coloured alert inherits the alert's ink (same hue as the text),
   so it needs an underline + weight to read AS a link and stay legible on the
   tinted background. */
.alert__body a { color: inherit; font-weight: 640; text-decoration: underline; text-underline-offset: 2px; }
.alert__body a:hover { text-decoration-thickness: 2px; }

/* ---- Empty state ----------------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s-3); padding: var(--s-9) var(--s-5);
}
.empty__icon {
  width: 52px; height: 52px; border-radius: var(--r-lg); display: grid; place-items: center;
  background: var(--c-accent-soft); color: var(--c-accent); margin-bottom: var(--s-1);
}
.empty__icon svg { width: 26px; height: 26px; }
.empty__title { font-size: var(--t-lg); }
.empty__desc { color: var(--c-ink-3); max-width: 460px; font-size: var(--t-md); }

/* ---- Modal / confirmation dialog (native <dialog>) ------------------------- */
.modal {
  border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: 0;
  background: var(--c-surface); color: var(--c-ink);
  box-shadow: var(--sh-lg); max-width: 460px; width: calc(100% - var(--s-6));
}
.modal::backdrop { background: rgba(15,22,38,.5); }
.modal__inner { padding: var(--s-5); margin: 0; }
.modal__title { font-size: var(--t-lg); margin-bottom: var(--s-2); }
.modal__body { color: var(--c-ink-3); font-size: var(--t-md); line-height: 1.55; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--s-3); margin-top: var(--s-5); }

/* ---- Segmented / filter controls ------------------------------------------- */
.segmented { display: inline-flex; background: var(--c-sunken); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segmented a, .segmented button {
  font-family: inherit; font-size: var(--t-sm); font-weight: 560; color: var(--c-ink-3);
  padding: 6px 13px; border-radius: 6px; border: 0; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.segmented a:hover, .segmented button:hover { color: var(--c-ink); }
.segmented .on { background: var(--c-surface); color: var(--c-ink); box-shadow: var(--sh-xs); }

/* ---- Steps indicator ------------------------------------------------------- */
.steps { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-6); flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); color: var(--c-ink-4); font-weight: 560; }
.step__num {
  width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--c-sunken); color: var(--c-ink-3); font-size: var(--t-xs); font-weight: 700;
}
.step--done .step__num { background: var(--c-success-soft); color: var(--c-success); }
.step--done { color: var(--c-ink-3); }
.step--on .step__num { background: var(--c-accent); color: #fff; }
.step--on { color: var(--c-ink); }
.steps__sep { width: 26px; height: 1px; background: var(--c-border-strong); }

/* ---- Article body (read-only rendering) ------------------------------------ */
/* Article images (task 09): the cover renders wide, inline images stack below. */
.article-images { display: flex; flex-direction: column; gap: var(--s-4); }
.article-image { margin: 0; }
.article-image__img { width: 100%; height: auto; border-radius: var(--r-lg); display: block; }
.article-image__cap { font-size: var(--t-sm); color: var(--c-ink-4); margin-top: var(--s-2); }

.article-body { font-size: var(--t-md); line-height: 1.72; color: var(--c-ink-2); }
.article-body h2 { font-size: var(--t-xl); margin: var(--s-6) 0 var(--s-3); }
.article-body p { margin-bottom: var(--s-4); }
.article-body figure { margin: var(--s-5) 0; }
.article-body figcaption { font-size: var(--t-sm); color: var(--c-ink-4); margin-top: var(--s-2); }

.citation {
  border-left: 3px solid var(--c-accent); background: var(--c-accent-soft);
  padding: var(--s-4); border-radius: 0 var(--r-md) var(--r-md) 0;
}
.citation__label { font-size: var(--t-xs); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--c-accent-ink); margin-bottom: 5px; }
.citation a { color: var(--c-accent-ink); font-weight: 560; text-decoration: underline; }

/* ---- Auth screens ---------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth__aside { display: none; } }
.auth__form { display: flex; align-items: center; justify-content: center; padding: var(--s-8) var(--s-6); background: var(--c-surface); }
.auth__inner { width: 100%; max-width: 400px; }
.auth__aside {
  padding: var(--s-9) var(--s-8); color: #eef1ff; display: flex; flex-direction: column;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(162,115,255,.55), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(80,200,255,.22), transparent 55%),
    linear-gradient(160deg, #2b1d63, #150f33);
}
.auth__aside .quote { margin-top: auto; }
.auth__aside .quote p { font-size: var(--t-xl); font-weight: 560; line-height: 1.45; letter-spacing: -.01em; }
.auth__aside .quote .by { margin-top: 16px; font-size: var(--t-sm); color: #c9c2f5; }
.auth__stats { display: flex; gap: var(--s-7); margin-top: var(--s-7); flex-wrap: wrap; }
.auth__stats .v { font-size: var(--t-2xl); font-weight: 700; letter-spacing: -.02em; }
.auth__stats .l { font-size: var(--t-sm); color: #bcb6ee; }

/* ---- Public landing -------------------------------------------------------- */
.publicnav {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-6); max-width: 1160px; margin: 0 auto;
}
.publicnav__right { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }

.hero { padding: var(--s-10) var(--s-6) var(--s-9); max-width: 900px; margin: 0 auto; text-align: center; }
.hero h1 { font-size: var(--t-3xl); line-height: 1.14; letter-spacing: -.03em; }
@media (min-width: 800px) { .hero h1 { font-size: 46px; } }
.hero__sub { font-size: var(--t-lg); color: var(--c-ink-3); margin-top: var(--s-4); }
.hero__cta { display: flex; align-items: center; justify-content: center; gap: var(--s-3); margin-top: var(--s-7); flex-wrap: wrap; }

.flowline { display: flex; align-items: center; justify-content: center; gap: var(--s-3); flex-wrap: wrap; margin-top: var(--s-8); }
.flowline__node {
  display: inline-flex; align-items: center; gap: var(--s-2);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-full);
  padding: 8px 15px; font-size: var(--t-sm); font-weight: 560; color: var(--c-ink-2); box-shadow: var(--sh-xs);
}
.flowline__node svg { width: 15px; height: 15px; color: var(--c-accent); }
.flowline__arrow { color: var(--c-ink-4); display: inline-flex; }
.flowline__arrow svg { width: 16px; height: 16px; }

.features { max-width: 1160px; margin: 0 auto; padding: var(--s-9) var(--s-6); }
.feature__ic { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--c-accent-soft); color: var(--c-accent); margin-bottom: var(--s-4); }
.feature__ic svg { width: 19px; height: 19px; }
.feature h3 { font-size: var(--t-md); margin-bottom: 6px; }
.feature p { color: var(--c-ink-3); font-size: var(--t-sm); line-height: 1.6; }

.publicfoot { border-top: 1px solid var(--c-border); padding: var(--s-6); text-align: center; color: var(--c-ink-4); font-size: var(--t-sm); }

/* ---- Meter (billing consumption) ------------------------------------------- */
.meter { display: flex; flex-direction: column; gap: 7px; }
.meter__top { display: flex; align-items: baseline; gap: var(--s-3); font-size: var(--t-sm); }
.meter__label { font-weight: 600; color: var(--c-ink-2); }
.meter__value { margin-left: auto; color: var(--c-ink-3); font-variant-numeric: tabular-nums; }
.meter__bar { height: 8px; border-radius: var(--r-full); background: var(--c-sunken); overflow: hidden; }
/* display:block is load-bearing: the fill is a <span>, and on an inline box
   height has no effect, so the bar rendered empty at every fill percentage. */
.meter__fill { display: block; height: 100%; border-radius: var(--r-full); background: var(--c-accent); }
.meter--warn .meter__fill { background: var(--c-warn); }
.meter--danger .meter__fill { background: var(--c-danger); }

/* ---- Plan card (billing) ---------------------------------------------------
   One card per SubscriptionPlan. The amount shown here is illustrative: the
   source of truth for the amount lives in the application code (STYLE §14),
   never in a Stripe sync script. "Ilimitado" is rendered as the word, never as
   a magic number. */
.plan { display: flex; flex-direction: column; }
.plan__name { font-size: var(--t-md); display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.plan__price { display: flex; align-items: baseline; gap: 6px; margin-top: var(--s-3); }
.plan__amount { font-size: var(--t-2xl); font-weight: 680; color: var(--c-ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.plan__period { font-size: var(--t-sm); color: var(--c-ink-3); }
.plan__tax { font-size: var(--t-xs); color: var(--c-ink-4); margin-top: 2px; }
.plan__pitch { color: var(--c-ink-3); font-size: var(--t-sm); line-height: 1.6; margin-top: var(--s-3); }
.plan__limits { list-style: none; margin: 0; padding: 0; font-size: var(--t-sm); color: var(--c-ink-2); }
.plan__limits li { display: flex; align-items: baseline; gap: var(--s-2); padding: 5px 0; }
.plan__limits li + li { border-top: 1px solid var(--c-border); }
.plan__limit-label { color: var(--c-ink-3); }
.plan__limit-value { margin-left: auto; font-weight: 620; font-variant-numeric: tabular-nums; }
.plan__cta { margin-top: auto; padding-top: var(--s-5); }
.plan--current { border-color: var(--c-accent); box-shadow: 0 0 0 1px var(--c-accent); }

/* ---- Utilities ------------------------------------------------------------- */
.row { display: flex; align-items: center; }
.row.gap-2 { gap: var(--s-2); } .row.gap-3 { gap: var(--s-3); } .row.gap-4 { gap: var(--s-4); }
.stack { display: flex; flex-direction: column; }
.stack.gap-3 { gap: var(--s-3); } .stack.gap-4 { gap: var(--s-4); } .stack.gap-5 { gap: var(--s-5); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.center { text-align: center; }
.muted { color: var(--c-ink-3); }
.muted-4 { color: var(--c-ink-4); }
.mono { font-family: var(--t-mono); font-size: var(--t-sm); }
.tabnum { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--c-border); border: 0; margin: var(--s-5) 0; }
.mt-2{margin-top:var(--s-2)} .mt-3{margin-top:var(--s-3)} .mt-4{margin-top:var(--s-4)} .mt-5{margin-top:var(--s-5)} .mt-6{margin-top:var(--s-6)} .mt-7{margin-top:var(--s-7)}
.mb-2{margin-bottom:var(--s-2)} .mb-3{margin-bottom:var(--s-3)} .mb-4{margin-bottom:var(--s-4)} .mb-5{margin-bottom:var(--s-5)} .mb-6{margin-bottom:var(--s-6)} .mb-9{margin-bottom:var(--s-9)}
.ml-3{margin-left:var(--s-3)}

/* Documentation surface (webhook docs): a scrollable code block and a spaced list. */
.code-block {
  font-family: var(--t-mono); font-size: var(--t-sm); line-height: 1.55;
  background: var(--c-sunken); border: 1px solid var(--c-border); border-radius: var(--r-md);
  padding: var(--s-4); margin: var(--s-3) 0; overflow-x: auto; color: var(--c-ink-2);
  white-space: pre; tab-size: 2;
}
.code-block code { font-family: inherit; background: none; padding: 0; color: inherit; }
.doc-list { margin: var(--s-3) 0 0; padding-left: var(--s-5); display: grid; gap: var(--s-2); color: var(--c-ink-2); }
.doc-list li { line-height: 1.55; }
.card__body table.data td code, .card__body p code, .doc-list code {
  font-family: var(--t-mono); font-size: 0.92em; background: var(--c-sunken);
  border-radius: var(--r-sm); padding: 1px 5px; color: var(--c-accent-ink);
}
.pill-key {
  font-family: var(--t-mono); font-size: var(--t-sm); background: var(--c-sunken);
  border: 1px solid var(--c-border); border-radius: var(--r-sm); padding: 3px 9px; color: var(--c-ink-2);
  word-break: break-all;
}
.help-text { font-size: var(--t-sm); color: var(--c-ink-4); line-height: 1.5; max-width: 52ch; }

/* Variant panels: the webhook test authors its three outcomes in the markup and
   app.js only flips which one is visible. No result is computed client-side. */
[data-variant-panel][hidden] { display: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
