/* Graceful Health Ads — employee interface design system.
 *
 * No CSS framework and no CDN. Everything below is tokens plus a small set of
 * components, which keeps the CSP able to forbid external origins outright and
 * keeps the whole visual language in one reviewable file.
 *
 * Colours are defined ONCE as custom properties so branding can change without
 * touching a component. Nothing hardcodes a hex value outside :root.
 */

:root {
  /* surfaces */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #e3e6ea;
  --border-strong: #cbd2d9;

  /* text */
  --text: #14181d;
  --text-muted: #5c6773;
  --text-subtle: #869099;

  /* brand + state */
  --primary: #2f6f62;
  --primary-hover: #275c51;
  --primary-soft: #e8f1ef;
  --success: #1f7a4d;
  --success-soft: #e6f4ec;
  --warning: #9a6206;
  --warning-soft: #fdf3e2;
  --danger: #b3261e;
  --danger-soft: #fbeae9;
  --info: #1f5c96;
  --info-soft: #e8f0f8;

  /* spacing */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 4px 12px rgba(16,24,40,.08);

  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Respects the reader's choice rather than imposing one. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161a;
    --surface: #191e24;
    --surface-alt: #1f252c;
    --border: #2b333c;
    --border-strong: #3a444f;
    --text: #eef2f5;
    --text-muted: #a4b0bb;
    --text-subtle: #7d8894;
    --primary: #5fb3a1;
    --primary-hover: #74c2b1;
    --primary-soft: #1b2f2b;
    --success: #63c48d;  --success-soft: #172c21;
    --warning: #e0a94a;  --warning-soft: #302615;
    --danger:  #f08279;  --danger-soft:  #331c1b;
    --info:    #74aee0;  --info-soft:    #16242f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lg: 0 4px 14px rgba(0,0,0,.45);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 var(--s-3); }
a { color: var(--primary); }

/* Focus is always visible. Keyboard users are not second-class here. */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute; left: -9999px; top: var(--s-2);
  background: var(--surface); color: var(--text);
  padding: var(--s-2) var(--s-4); border-radius: var(--radius-sm);
  z-index: 100; box-shadow: var(--shadow-lg);
}
.skip-link:focus { left: var(--s-4); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.brand {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s-5) var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit;
}
.brand-name { font-weight: 650; letter-spacing: -.01em; }
.brand-sub { font-size: .75rem; color: var(--text-subtle); }

.nav { padding: var(--s-3) var(--s-2); display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-subtle); padding: var(--s-4) var(--s-3) var(--s-2);
}
.nav a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-size: .9rem;
}
.nav a:hover { background: var(--surface-alt); color: var(--text); }
.nav a[aria-current="page"] {
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
}
.nav-icon { width: 18px; text-align: center; flex: 0 0 18px; }

.sidebar-footer {
  margin-top: auto; padding: var(--s-4);
  border-top: 1px solid var(--border); font-size: .82rem;
}
.who { color: var(--text-muted); }
.who strong { color: var(--text); display: block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: none; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}

.page { padding: var(--s-5); max-width: 1180px; width: 100%; }
.page-header { margin-bottom: var(--s-5); }
.page-header h1 { margin-bottom: var(--s-1); }
.page-header .lede { color: var(--text-muted); margin: 0; }
.page-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap;
}

.updated { font-size: .8rem; color: var(--text-subtle); }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--s-4); }
.card-head {
  padding: var(--s-4); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
}
.card-body { padding: var(--s-4); }

.grid { display: grid; gap: var(--s-4); }
.grid-metrics { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-cards   { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s-4); box-shadow: var(--shadow);
}
.metric-label {
  font-size: .78rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: var(--s-2);
}
.metric-value { font-size: 1.6rem; font-weight: 640; letter-spacing: -.02em; }
.metric-value.is-empty { color: var(--text-subtle); font-weight: 500; }
.metric-hint { font-size: .78rem; color: var(--text-subtle); margin-top: var(--s-1); }

.stat-row { display: flex; flex-wrap: wrap; gap: var(--s-5); }
.stat { min-width: 92px; }
.stat-label { font-size: .75rem; color: var(--text-muted); }
.stat-value { font-weight: 600; }
.stat-value.is-empty { color: var(--text-subtle); font-weight: 500; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 3px var(--s-2); border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.badge-neutral { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }

.pill {
  display: inline-block; padding: 2px var(--s-2); border-radius: var(--radius-sm);
  background: var(--surface-alt); border: 1px solid var(--border);
  font-size: .76rem; color: var(--text-muted);
}

/* --------------------------------------------------------------- buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-4); border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; font-family: inherit;
}
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
}
.button-secondary:hover { background: var(--surface-alt); }
.button-ghost { background: transparent; color: var(--text-muted); }
.button-ghost:hover { background: var(--surface-alt); color: var(--text); }
.button[disabled], .button[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed;
}
.button-sm { padding: var(--s-1) var(--s-3); font-size: .82rem; }

/* --------------------------------------------------------------- filters */
.filters { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-4); }
.filter {
  padding: var(--s-1) var(--s-3); border-radius: 999px; font-size: .84rem;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); text-decoration: none;
}
.filter:hover { background: var(--surface-alt); color: var(--text); }
.filter[aria-current="true"] {
  background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600;
}

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

dl.pairs { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: var(--s-2) var(--s-4); margin: 0; }
dl.pairs dt { color: var(--text-muted); font-size: .86rem; }
dl.pairs dd { margin: 0; }

/* ---------------------------------------------------------------- alerts */
.alert {
  display: flex; gap: var(--s-3); padding: var(--s-4);
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); margin-bottom: var(--s-3);
}
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-body { color: var(--text-muted); font-size: .9rem; }
.alert-success { border-left: 3px solid var(--success); }
.alert-info    { border-left: 3px solid var(--info); }
.alert-warning { border-left: 3px solid var(--warning); }
.alert-danger  { border-left: 3px solid var(--danger); }

/* ----------------------------------------------------- empty + technical */
.empty {
  text-align: center; padding: var(--s-7) var(--s-4); color: var(--text-muted);
}
.empty-icon { font-size: 2rem; margin-bottom: var(--s-3); opacity: .55; }
.empty h2 { margin-bottom: var(--s-2); }
.empty p { max-width: 46ch; margin-inline: auto; }

details.technical { margin-top: var(--s-4); }
details.technical summary {
  cursor: pointer; font-size: .84rem; color: var(--text-muted);
  padding: var(--s-2) 0; font-weight: 600;
}
details.technical pre {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--s-3);
  overflow-x: auto; font-size: .78rem; margin: var(--s-2) 0 0;
}

/* ------------------------------------------------------ measurement note */
.measure {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3); border-radius: var(--radius-sm);
  background: var(--surface-alt); border: 1px dashed var(--border-strong);
  font-size: .84rem;
}
.measure-label { font-weight: 600; }
.measure-detail { color: var(--text-muted); }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: var(--s-4); }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: var(--s-2); }
.field input, .field select, .field textarea {
  width: 100%; padding: var(--s-2) var(--s-3); font-size: .95rem; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.field-hint { font-size: .8rem; color: var(--text-subtle); margin-top: var(--s-1); }
.field-error { font-size: .84rem; color: var(--danger); margin-top: var(--s-1); }

/* ------------------------------------------------------------- stepper */
.stepper { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-5); }
.step {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); font-size: .84rem;
  color: var(--text-muted); text-decoration: none;
}
.step[aria-current="step"] {
  border-color: var(--primary); background: var(--primary-soft);
  color: var(--primary); font-weight: 600;
}
.step-num {
  width: 20px; height: 20px; border-radius: 999px; flex: 0 0 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-alt); font-size: .72rem; font-weight: 700;
}
.step[aria-current="step"] .step-num { background: var(--primary); color: #fff; }

/* --------------------------------------------------------------- loading */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  * { transition: none !important; }
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar[data-open="true"] { transform: translateX(0); }
  .topbar { display: flex; }
  .page { padding: var(--s-4); }
  .grid-cards { grid-template-columns: 1fr; }
  dl.pairs { grid-template-columns: 1fr; gap: var(--s-1) 0; }
  dl.pairs dt { margin-top: var(--s-2); }
  .scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30;
  }
}
@media (min-width: 861px) { .scrim { display: none; } }


/* ------------------------------------------------------- choice cards */
/* Radio inputs styled as selectable cards. The input stays a real radio so
 * keyboard navigation and screen readers work unchanged; only its presentation
 * moves. :focus-within surfaces focus on the card, not on a hidden control. */
.choice { display: block; cursor: pointer; }
.choice input {
  position: absolute; opacity: 0; width: 1px; height: 1px;
}
.choice-body {
  display: block; padding: var(--s-4);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); height: 100%;
}
.choice:hover .choice-body { border-color: var(--primary); }
.choice input:focus-visible + .choice-body {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.choice input:checked + .choice-body {
  border-color: var(--primary); background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.choice-title { display: block; font-weight: 620; margin-bottom: var(--s-1); }
.choice-blurb { display: block; font-size: .85rem; color: var(--text-muted); }

.refresh-panel {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: .8rem; color: var(--text-subtle);
}


/* ============================================================ Phase 2B
 * Forms, media, previews, ledgers. Same rules as everything above: tokens
 * only, no hardcoded colour outside :root, focus visible on every control an
 * employee can reach with a keyboard.
 */

/* -------------------------------------------------------------- forms */
.field { margin-bottom: var(--s-5); }
.field > label {
  display: block; font-weight: 620; margin-bottom: var(--s-2);
}
.field-hint, .step-intro p {
  font-size: .85rem; color: var(--text-muted); margin-top: var(--s-2);
}
.step-intro { padding: 0 var(--s-5) var(--s-4); }
.step-intro p { margin: 0 0 var(--s-2); }

input[type="text"], input[type="url"], input[type="date"],
input[type="month"], input[type="number"], input[type="email"],
input[type="file"], select, textarea {
  width: 100%; box-sizing: border-box;
  padding: var(--s-3); font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
  border-color: var(--primary);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-alt); color: var(--text-subtle); cursor: not-allowed;
}
textarea { resize: vertical; min-height: 96px; }

.field-group {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s-4); margin-bottom: var(--s-5);
}
.field-group > legend {
  font-weight: 620; padding: 0 var(--s-2);
}
.field-group .field:last-child { margin-bottom: 0; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.field-actions { display: flex; align-items: flex-end; gap: var(--s-2); }

.input-prefix {
  display: flex; align-items: stretch;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface);
}
.input-prefix:focus-within { outline: 2px solid var(--primary); outline-offset: 1px; }
.input-prefix > span {
  display: flex; align-items: center; padding: 0 var(--s-3);
  background: var(--surface-alt); color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.input-prefix input { border: 0; border-radius: 0; }
.input-prefix input:focus-visible { outline: none; }

.wizard-actions {
  display: flex; gap: var(--s-3); flex-wrap: wrap;
  margin-top: var(--s-5); align-items: center;
}
.filter-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s-4); align-items: end;
}
.filter-form .field { margin-bottom: 0; }

/* --------------------------------------------------------- step state */
.step.is-complete .step-num {
  background: var(--success-soft); color: var(--success);
  border-color: var(--success);
}

/* ------------------------------------------------------------ filters */
.filters { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-bottom: var(--s-4); }
.filter {
  padding: var(--s-2) var(--s-3); border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: .85rem; text-decoration: none; color: var(--text-muted);
}
.filter.is-active {
  background: var(--primary-soft); border-color: var(--primary);
  color: var(--primary); font-weight: 620;
}
.filter:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* -------------------------------------------------------------- media */
.grid-media {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.media-card, .media-choice {
  display: block; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.media-choice { cursor: pointer; position: relative; }
.media-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.media-choice input:focus-visible ~ .media-frame {
  outline: 2px solid var(--primary); outline-offset: -2px;
}
.media-choice input:checked ~ .media-frame {
  box-shadow: inset 0 0 0 3px var(--primary);
}
.media-choice.is-unavailable { opacity: .6; cursor: not-allowed; }

/* THE PREVIEW AREA NEVER CROPS.
 *
 * This rule pair used to read `aspect-ratio: 4 / 5` + `object-fit: cover`,
 * which forced every ad image format - 1:1, 1.91:1, 4:5 and 9:16 alike - into
 * one portrait box and let the browser centre-crop whatever did not fit. It
 * threw away 58% of a correctly composed landscape and 30% of a story frame,
 * so employees quite reasonably reported that the application was producing
 * broken images. The images were fine. This was.
 *
 * The box now takes its shape from the image's own `width`/`height`
 * attributes, and `contain` guarantees that even a mismatch letterboxes
 * rather than cuts. */
.media-frame {
  display: block; background: var(--surface-alt); overflow: hidden;
  line-height: 0;
}
/* THE IMAGE'S OWN `width` AND `height` ATTRIBUTES DECIDE THE BOX.
 *
 * Not a CSS `aspect-ratio` fed by an inline custom property: this
 * application's Content-Security-Policy is `style-src 'self'`, which blocks
 * style ATTRIBUTES, so a per-image ratio written into the markup silently
 * applies to nothing and every frame falls back to the 4:5 default - which is
 * the defect this milestone is fixing, wearing its own fix's clothes.
 *
 * `width`/`height` attributes are what the platform provides for exactly
 * this. They need no inline style, they reserve the correct box before the
 * bytes arrive, and they cannot disagree with the file. */
.media-frame img {
  width: 100%; height: auto; max-width: 100%;
  object-fit: contain; display: block;
}
.media-empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 120px; font-size: .8rem; color: var(--text-subtle);
  line-height: 1.5;
}
.media-body {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-3); font-size: .85rem;
}

/* ----------------------------------------------------------- previews */
.grid-previews {
  display: grid; gap: var(--s-5);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.preview-disclaimer { display: block; margin-bottom: var(--s-4); }
.preview {
  margin: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-alt); overflow: hidden;
}
.preview-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s-2); padding: var(--s-3); border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.preview-missing {
  padding: var(--s-3); font-size: .82rem;
  background: var(--warning-soft); color: var(--warning);
}
.preview-note {
  padding: var(--s-3); margin: 0; font-size: .78rem; color: var(--text-subtle);
}

.fake-search { padding: var(--s-4); background: var(--surface); }
.fake-search-tag { font-size: .72rem; font-weight: 700; color: var(--text); }
.fake-search-url { font-size: .78rem; color: var(--text-muted); }
.fake-search-title {
  font-size: 1.05rem; color: var(--info); margin-top: var(--s-1);
}
.fake-search-body {
  font-size: .85rem; color: var(--text-muted); margin-top: var(--s-1);
}

.fake-social { background: var(--surface); }
.fake-social-head {
  display: flex; gap: var(--s-2); align-items: center; padding: var(--s-3);
}
.fake-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--primary); color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
}
.fake-sponsored { display: block; font-size: .72rem; color: var(--text-subtle); }
.fake-social-text {
  padding: 0 var(--s-3) var(--s-3); margin: 0; font-size: .85rem;
}
/* The social mock shows the chosen derivative at ITS shape. `cover` here
 * would have re-cropped the very image the employee chose in order to avoid
 * a crop - a preview of something other than the ad. */
.fake-social-media { background: var(--surface-alt); line-height: 0; }
.fake-social-media img {
  width: 100%; height: auto; object-fit: contain; display: block;
}
.fake-social-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s-3); padding: var(--s-3); background: var(--surface-alt);
}
.fake-domain { display: block; font-size: .72rem; color: var(--text-subtle); }
.fake-desc { display: block; font-size: .78rem; color: var(--text-muted); }
.fake-cta {
  flex: none; padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm);
  background: var(--border); font-size: .78rem; font-weight: 620;
}

/* ------------------------------------------------------------ ledgers */
.ledger { margin: 0 0 var(--s-4); }
.ledger-row {
  display: flex; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-3) 0; border-bottom: 1px solid var(--border);
}
.ledger-row:last-child { border-bottom: 0; }
.ledger dt { color: var(--text-muted); }
.ledger dd { margin: 0; font-weight: 620; text-align: right; }

.review-section { margin-bottom: var(--s-6); }
.review-section h3 {
  font-size: 1rem; margin: 0 0 var(--s-3);
  padding-bottom: var(--s-2); border-bottom: 2px solid var(--border);
}
.review-section h4 {
  font-size: .85rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-subtle); margin: var(--s-4) 0 var(--s-2);
}
.platform-section {
  border-left: 3px solid var(--primary); padding-left: var(--s-4);
}
.audience-sentence {
  font-size: 1.05rem; font-weight: 620; margin: 0 0 var(--s-3);
}
.quoted {
  border-left: 3px solid var(--border-strong); padding-left: var(--s-3);
  color: var(--text-muted); margin: var(--s-2) 0;
}
.plain-list { margin: 0; padding-left: var(--s-5); }
.plain-list li { margin-bottom: var(--s-2); }
.pill-list {
  list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2);
  padding: 0; margin: 0 0 var(--s-3);
}
.alert-list { margin: var(--s-2) 0 0; padding-left: var(--s-5); font-size: .88rem; }
.checklist { list-style: none; padding-left: 0; }
.checklist .is-done { color: var(--text-muted); }
.timeline li { font-size: .88rem; }
code.wrap { word-break: break-all; font-size: .78rem; }

@media (max-width: 860px) {
  .field-row { grid-template-columns: 1fr; }
  .grid-media { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .grid-previews { grid-template-columns: 1fr; }
  .ledger-row { flex-direction: column; gap: var(--s-1); }
  .ledger dd { text-align: left; }
  .wizard-actions .button { flex: 1 1 auto; }
}

/* Figures shown by an on-demand refresh. Wrap on a phone rather than pushing
 * the card wider than the screen. */
.refresh-figures {
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  margin-top: var(--s-2); font-size: .82rem; color: var(--text-muted);
  width: 100%;
}
.refresh-identity { display: block; width: 100%; margin-top: var(--s-1); }

/* ============================================================ Phase 2D
 * Ad image formats and the focal marker.
 */
.formats { margin-top: var(--s-6); }
.formats h3 { font-size: 1rem; margin: 0 0 var(--s-2); }

.focal { margin: var(--s-4) 0 var(--s-5); }
.focal-label { margin-bottom: var(--s-2); }
.focal-stage {
  position: relative; display: inline-block; max-width: 320px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  overflow: hidden; cursor: crosshair; touch-action: none;
  background: var(--surface-alt);
}
.focal-stage img { display: block; width: 100%; height: auto; }
.focal-marker {
  position: absolute; left: 50%; top: 50%;
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border-radius: 50%; border: 3px solid var(--surface);
  background: rgba(47, 111, 98, .55);
  box-shadow: 0 0 0 2px var(--primary), var(--shadow);
  pointer-events: auto; cursor: grab;
}
.focal-marker:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

.format-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: var(--s-3);
}
.format-head { margin-bottom: var(--s-3); }
.format-head strong { display: block; }
.format-option { display: block; cursor: pointer; margin-bottom: var(--s-3); }
.format-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.format-body {
  display: block; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.format-option input:checked + .format-body {
  border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary);
}
.format-option input:focus-visible + .format-body {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
/* The format card frame inherits everything from `.media-frame`: the four
 * formats look like four different shapes because their four images are. */
.format-frame { background: var(--surface-alt); }
.format-meta {
  display: flex; flex-direction: column; gap: var(--s-1);
  padding: var(--s-3); font-size: .82rem;
}

@media (max-width: 860px) {
  .focal-stage { max-width: 100%; }
  .format-card { padding: var(--s-2); }
}

/* ------------------------------------------------- the full ad image preview
 *
 * THREE WAYS IN, because there are three kinds of person using this.
 *
 *   hover           a mouse user glances at a card
 *   keyboard focus  the same peek, on Tab, because hover alone excludes people
 *   activate        Enter, or a tap, opens a modal that Escape closes
 *
 * And a fourth for when none of that is available: the control is a real <a>
 * to a real page, so with JavaScript off it still shows the whole image.
 *
 * Every one of them CONTAINS the image. Cropping the picture inside the
 * control whose entire job is proving the picture is not cropped would be a
 * strange thing to ship. */
.preview-open {
  position: relative; display: inline-flex; align-items: center;
  gap: var(--s-1); font-size: .78rem; font-weight: 620;
  color: var(--primary); text-decoration: none;
  padding: var(--s-1) 0;
}
.preview-open:hover { text-decoration: underline; }
.preview-open:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.preview-peek {
  display: none; position: fixed; inset: 0; z-index: 60;
  place-items: center; padding: var(--s-5);
  background: rgba(18, 24, 22, .72); pointer-events: none;
}
.preview-peek img {
  max-width: min(88vw, 900px); max-height: 78vh;
  width: auto; height: auto; object-fit: contain;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
/* Hover only where hovering is a real thing. On a phone the tap opens the
 * dialog instead, and a peek stuck under a fingertip helps nobody. */
@media (hover: hover) and (pointer: fine) {
  .preview-open:hover .preview-peek,
  .preview-open:focus-visible .preview-peek { display: grid; }
}

.lightbox {
  border: 0; padding: 0; max-width: 96vw; max-height: 94vh;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5); color: var(--text);
}
.lightbox::backdrop { background: rgba(18, 24, 22, .74); }
.lightbox-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.lightbox-title { font-weight: 700; font-size: .9rem; }
.lightbox-sub { display: block; font-size: .78rem; color: var(--text-muted); }
.lightbox-figure {
  margin: 0; display: grid; place-items: center;
  padding: var(--s-4); background: var(--surface-alt);
}
.lightbox-figure img {
  max-width: min(88vw, 1100px); max-height: 68vh;
  width: auto; height: auto; object-fit: contain; display: block;
}
.lightbox-foot {
  padding: var(--s-3) var(--s-4); font-size: .78rem; color: var(--text-muted);
}
.lightbox-close {
  flex: none; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-sm); padding: var(--s-1) var(--s-3);
  font: inherit; font-size: .8rem; cursor: pointer; color: var(--text);
}
.lightbox-close:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* The badge says what THIS APPLICATION checked and nothing else. */
.badge-checked {
  background: var(--success-soft); color: var(--success);
}
/* Badges default to `white-space: nowrap`, which reads "✓ Ready for this ad
 * form…" in a narrow format card. Inside a media caption they wrap instead:
 * a truncated reassurance is not reassuring. */
.media-body .badge, .format-meta .badge {
  white-space: normal; text-align: left;
}
.checked-note {
  display: block; font-size: .74rem; color: var(--text-subtle);
  margin-top: var(--s-1);
}

@media (max-width: 860px) {
  .lightbox { max-width: 100vw; max-height: 100vh; border-radius: 0; }
  .lightbox-figure img { max-width: 94vw; max-height: 62vh; }
}

/* ------------------------------------------------------- the AI workspace
 *
 * A generate button, what the suggestion is built on, and two or three whole
 * creative directions side by side. The point of the layout is that an
 * employee compares COMPLETE advertisements rather than assembling one field
 * at a time. */
.ai-controls { margin-bottom: var(--s-4); }
.ai-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.ai-actions select {
  padding: var(--s-2) var(--s-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: .85rem;
}

.ai-using {
  margin-top: var(--s-4); padding: var(--s-3);
  background: var(--surface-alt); border-radius: var(--radius);
  font-size: .82rem;
}
.ai-using ul { margin: var(--s-2) 0 0; }
.ai-using li { display: flex; gap: var(--s-2); align-items: baseline; }
.ai-using li.is-on span[aria-hidden] { color: var(--success); }
.ai-using li.is-off span[aria-hidden] { color: var(--text-subtle); }
.ai-using .choice-blurb { color: var(--text-subtle); }

.grid-variants {
  display: grid; gap: var(--s-4); margin-top: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.variant {
  display: flex; flex-direction: column; gap: var(--s-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); padding: var(--s-4);
}
.variant-head strong { display: block; }
.variant-block {
  padding: var(--s-3); background: var(--surface-alt);
  border-radius: var(--radius-sm);
}
.variant-platform {
  display: block; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-subtle); margin-bottom: var(--s-2);
}
.variant-block ol { margin: 0; padding-left: var(--s-4); font-size: .85rem; }
.variant-block p { margin: var(--s-2) 0 0; }
.variant button { margin-top: auto; align-self: flex-start; }

.regen { display: inline-block; margin: 0 0 var(--s-3); }

@media (max-width: 860px) {
  .grid-variants { grid-template-columns: 1fr; }
  .ai-actions .button, .ai-actions select { flex: 1 1 auto; }
}

/* The full-preview page: one image, centred, never wider than the column. */
.full-preview { max-width: 960px; margin: 0 auto; }

/* Facts under the full preview. A rule rather than an inline style, because
 * `style-src 'self'` means an inline one would not apply. */
.preview-facts { margin-top: var(--s-4); }

/* ------------------------------------------------ ad format cards + compare
 *
 * The composition METHOD is the fact this screen was missing: four correct
 * pictures with nothing saying they were four different preparations. It gets
 * its own line, in employee words, under the format's name. */
.method {
  font-size: .8rem; font-weight: 620; color: var(--primary);
}
.compare { margin-top: var(--s-2); }
.compare > summary {
  cursor: pointer; font-size: .8rem; color: var(--primary); font-weight: 620;
}
.compare-pair {
  display: grid; gap: var(--s-3); margin-top: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.compare-side {
  display: flex; flex-direction: column; gap: var(--s-1);
  font-size: .76rem;
}
.compare-label {
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  font-size: .68rem; color: var(--text-subtle);
}
.compare-side .media-frame { border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ------------------------------------------------------- advertising facts */
.ledger-table {
  width: 100%; border-collapse: collapse; font-size: .85rem;
}
.ledger-table th {
  text-align: left; padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-strong);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-subtle);
}
.ledger-table td {
  padding: var(--s-3); border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.ledger-table tr:last-child td { border-bottom: 0; }
.ledger-table form { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* The AI status panel on the settings page. */
.ai-status dt { color: var(--text-muted); }
.ai-status dd { font-weight: 600; }
