/*
 * MarketingBS: space and glass.
 *
 * 1. Tokens      the whole theme is defined here and nowhere else
 * 2. Base        page, type, focus, the space behind everything
 * 3. Glass       one recipe, three elevations; every surface is built from it
 * 4. Controls    fields, buttons, chips, tags, status chips, tabs, tables
 * 5. Shell       top bar, page
 * 6. Screens     home, agencies, discover, campaigns, WhatsApp, settings, unsubscribe
 * 7. Motion      the one vocabulary, defined once
 * 8. Responsive and preferences (kept last)
 */

/* ------------------------------------------------------------------ 1. Tokens */

:root {
    color-scheme: dark; /* native parts (select lists, scrollbars, date and file pickers) follow */

    /* Space: the base, and the three colour fields of the nebula. */
    --bg: #050817;
    --neb-1: rgba(34, 84, 176, 0.52);
    --neb-2: rgba(14, 122, 138, 0.38);
    --neb-3: rgba(110, 44, 124, 0.32);

    /* Text: a soft white and two clear steps below it. All three keep 4.5:1 on every glass fill. */
    --ink: #edf2ff;
    --ink-2: #c3cdea;
    --muted: #9aa7ca;

    /* Electric cyan: links, focus, selection, anything that is working. */
    --accent: #56dcff;
    --accent-text: #86e6ff;
    --accent-soft: rgba(86, 220, 255, 0.13);
    --accent-edge: rgba(86, 220, 255, 0.45);
    --on-accent: #02212c;
    --accent-deep: #2aa9d2;
    --accent-core: #dff8ff;                    /* the bright middle of a moving light */
    --light-sweep: rgba(200, 238, 255, 0.12); /* light crossing a pane or a waiting row */

    /* Solar amber: the one main action of a view, and whatever waits for the owner. */
    --sun: #ffb23e;
    --sun-hi: #ffc86e;
    --sun-text: #ffc875;
    --sun-soft: rgba(255, 178, 62, 0.14);
    --sun-edge: rgba(255, 190, 90, 0.50);
    --on-sun: #241500;
    --sun-hover-hi: #ffd387;
    --sun-hover: #ffb94e;

    /* States: "-text" is readable on glass, "-soft" tints a small pane, "-edge" outlines it. */
    --ok: #34d399;
    --ok-text: #74e8b8;
    --ok-soft: rgba(52, 211, 153, 0.13);
    --ok-edge: rgba(52, 211, 153, 0.42);
    --bad: #ff6b88;
    --bad-text: #ff9fb2;
    --bad-soft: rgba(255, 107, 136, 0.13);
    --bad-edge: rgba(255, 107, 136, 0.45);
    --quiet-soft: rgba(154, 167, 202, 0.12);
    --quiet-edge: rgba(154, 167, 202, 0.34);

    /* The same colours as bare numbers, for a glow or a shade at any strength: rgba(var(--accent-rgb), 0.3). */
    --accent-rgb: 86, 220, 255;
    --sun-rgb: 255, 178, 62;
    --ok-rgb: 52, 211, 153;
    --bad-rgb: 255, 107, 136;
    --light-rgb: 255, 255, 255;   /* light falling on glass */
    --shade-rgb: 1, 4, 24;        /* the shadow glass throws */
    --solid: #0d1330;             /* where nothing may show through: a select's list, a remembered field */

    --focus: #9cecff;
    --focus-halo: rgba(86, 220, 255, 0.28);

    /* Glass. One material: a translucent fill, a blur of what is behind it, an edge lit from the
       top left, a faint highlight inside, a coloured shadow underneath. Three elevations. */
    --glass-1: rgba(17, 25, 56, 0.56);       /* resting: panels */
    --glass-2: rgba(34, 46, 92, 0.60);       /* raised: cards, buttons, rows on a panel */
    --glass-3: rgba(10, 15, 38, 0.70);       /* floating: the top bar, bars that stick */
    --glass-dense: rgba(8, 12, 32, 0.86);    /* long reading: a message, its English copy */
    --glass-well: rgba(3, 6, 20, 0.52);      /* recessed: fields */
    --glass-hover: rgba(44, 58, 112, 0.66);
    --row: rgba(150, 175, 255, 0.055);       /* a row on a pane: a plain fill, never a second blur */
    --row-hover: rgba(150, 175, 255, 0.10);
    --blur-1: blur(16px) saturate(150%);
    --blur-3: blur(22px) saturate(160%);
    --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0) 42%);
    --edge-lit: rgba(196, 230, 255, 0.36);   /* top */
    --edge-mid: rgba(170, 205, 255, 0.22);   /* left */
    --edge-dim: rgba(140, 168, 240, 0.13);   /* right and bottom */
    --line: rgba(140, 168, 240, 0.16);       /* a hairline inside a pane */
    --control-edge: rgba(172, 196, 255, 0.60); /* the edge of a field or button: 3:1 on glass */
    --control-edge-lit: rgba(206, 226, 255, 0.62);   /* the top edge of a button */
    --control-edge-hover: rgba(190, 215, 255, 0.72);
    --highlight: inset 0 1px 0 rgba(255, 255, 255, 0.07);
    --recess: inset 0 2px 6px rgba(0, 0, 10, 0.55);
    --shadow-1: 0 16px 44px rgba(1, 4, 24, 0.46);
    --shadow-2: 0 22px 54px rgba(1, 4, 24, 0.60), 0 0 0 1px rgba(120, 190, 255, 0.05);
    --glow-accent: 0 0 26px rgba(86, 220, 255, 0.30);
    --glow-sun: 0 6px 26px rgba(255, 170, 50, 0.30);
    --glow-sun-hi: 0 8px 34px rgba(255, 176, 60, 0.52);

    /* The globe: a planet in this sky. */
    --globe-sea: #0a1433;
    --globe-land: #223159;
    --globe-coast: rgba(150, 190, 255, 0.30);
    --globe-low: #9c7231;
    --globe-high: #ffd58a;
    --globe-rim: rgba(140, 220, 255, 0.55);
    --globe-grid: rgba(140, 180, 255, 0.10);
    --globe-lit-coast: rgba(255, 236, 200, 0.55);
    --globe-halo: rgba(60, 120, 255, 0.14);
    --star-glow: rgba(170, 220, 255, 0.75);
    --star-trail: rgba(140, 215, 255, 0.35);

    --radius: 18px;
    --radius-s: 12px;

    /* Motion: ease-out with character, no bounce. Frequent actions get the fast two. */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --t-press: 120ms;
    --t-fast: 170ms;
    --t-state: 240ms;
    --t-enter: 340ms;
}

/* Without the frosted effect, or when the owner asked for less transparency: solid panes from the same tokens. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root { --glass-1: #0d1330; --glass-2: #1a2450; --glass-3: #0b1029; --glass-dense: #090e24; --glass-well: #060a1d; --glass-hover: #243068; }
}
@media (prefers-reduced-transparency: reduce) {
    :root {
        --glass-1: #0d1330; --glass-2: #1a2450; --glass-3: #0b1029; --glass-dense: #090e24; --glass-well: #060a1d; --glass-hover: #243068;
        --blur-1: none; --blur-3: none;
    }
}

/* ------------------------------------------------------------------ 2. Base */

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* The nebula: three large soft colour fields on a fixed layer, behind the stars and everything else. */
body::before {
    content: "";
    position: fixed;
    inset: -6%;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(900px 620px at 14% 2%, var(--neb-1), transparent 62%),
        radial-gradient(820px 640px at 92% 14%, var(--neb-2), transparent 62%),
        radial-gradient(1000px 700px at 58% 108%, var(--neb-3), transparent 64%);
}

/* The star field, built by space.js. Fixed, behind the page, never in the way of a click. */
.space { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; contain: strict; }
.space-depth { position: absolute; inset: 0 0 -48px 0; }
.space-stars { position: absolute; top: 0; bottom: 0; left: 0; background-repeat: repeat; will-change: transform; }
.space-twinkle { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 1px var(--star-glow); opacity: 0.55; }
.space-shoot {
    position: absolute; width: 150px; height: 1.5px; border-radius: 2px; opacity: 0;
    background: linear-gradient(90deg, rgba(var(--light-rgb), 0.85), var(--star-trail) 30%, transparent);
    transform-origin: left center;
}

h1, h2, h3 { font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; letter-spacing: -0.02em; margin: 0 0 12px; text-wrap: balance; }
h1 { font-size: 30px; font-weight: 650; }
h2 { font-size: 19px; font-weight: 620; }
h3 { font-size: 16px; font-weight: 620; }
p { margin: 0 0 12px; }
a { color: inherit; text-decoration-color: var(--accent-edge); text-underline-offset: 3px; transition: color var(--t-fast) var(--ease); }
@media (hover: hover) and (pointer: fine) {
    a:hover { color: var(--accent-text); }
}
b, strong { font-weight: 650; }
code { padding: 1px 6px; border-radius: 6px; font-size: 13px; background: var(--glass-well); border: 1px solid var(--line); }
::selection { background: rgba(var(--accent-rgb), 0.32); color: #fff; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* Keyboard focus: one luminous ring everywhere, with a halo so it shows on any pane. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus-halo); }

.skip { position: absolute; left: -999px; padding: 8px 14px; border-radius: 10px; color: var(--on-accent); background: var(--accent); font-weight: 600; }
.skip:focus { left: 12px; top: 12px; z-index: 30; }

/* Read out by screen readers, not shown. */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------------ 3. Glass */

/* Resting glass: a panel. */
.panel, .grid.stats, .list-glass, .wa-list {
    position: relative;
    background: var(--sheen), var(--glass-1);
    -webkit-backdrop-filter: var(--blur-1);
    backdrop-filter: var(--blur-1);
    border: 1px solid var(--edge-dim);
    border-top-color: var(--edge-lit);
    border-left-color: var(--edge-mid);
    border-radius: var(--radius);
    box-shadow: var(--highlight), var(--shadow-1);
}
.panel { padding: 22px; }
.panel + .panel { margin-top: 18px; }
p.panel { margin-bottom: 0; }
.panel > :last-child { margin-bottom: 0; }

/* Raised glass on a pane: a card, a row, a draft. A plain fill and an edge, never a blur of its
   own: two hundred rows must not each blur what is behind them. Their list is the pane. */
.card, .draft, .wa-row, .checklist li, .rewrite-body {
    position: relative;
    background: var(--row);
    border: 1px solid var(--edge-dim);
    border-top-color: var(--edge-mid);
    border-radius: 14px;
}

/* The one pane behind a long list. */
.list-glass, .wa-list { padding: 10px; }
/* What a list says when it is empty sits on the list's own pane, not on a second one inside it. */
.list-glass > .panel { padding: 12px 8px; background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }

.grid { display: grid; gap: 16px; }
.auth { max-width: 420px; margin: 9vh auto 0; }

/* ------------------------------------------------------------------ 4. Controls */

label { display: block; margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }

/* Fields are recessed glass: darker than the pane, shadowed inside. */
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], select, textarea {
    display: block; width: 100%; margin-top: 5px; padding: 10px 12px; min-height: 44px;
    font: inherit; font-size: 15px; color: var(--ink);
    background: var(--glass-well); border: 1px solid var(--control-edge); border-radius: var(--radius-s);
    box-shadow: var(--recess);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
textarea { line-height: 1.55; resize: vertical; }
::placeholder { color: var(--muted); opacity: 1; }
select { appearance: auto; }
option { background: var(--solid); color: var(--ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--accent);
    box-shadow: var(--recess), 0 0 0 5px var(--focus-halo);
}
/* The browser's own fill for remembered values would paint the field white. */
input:-webkit-autofill, input:-webkit-autofill:focus, textarea:-webkit-autofill, select:-webkit-autofill {
    -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
    box-shadow: 0 0 0 100px var(--solid) inset, var(--recess);
    transition: background-color 9999s;
}
input[type=file] {
    display: block; width: 100%; max-width: 460px; margin-top: 5px; padding: 7px;
    font: inherit; font-size: 14px; color: var(--ink-2);
    background: var(--glass-well); border: 1px dashed var(--control-edge); border-radius: var(--radius-s);
}
input[type=file]::file-selector-button {
    margin-inline-end: 12px; padding: 8px 14px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
    background: var(--glass-2); border: 1px solid var(--control-edge); border-radius: 9px;
}

/* Buttons are raised glass. */
.btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; min-height: 42px;
    font: inherit; font-weight: 600; color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap;
    background: var(--sheen), var(--glass-2);
    border: 1px solid var(--control-edge); border-top-color: var(--control-edge-lit); border-radius: var(--radius-s);
    box-shadow: var(--highlight), 0 6px 18px rgba(var(--shade-rgb), 0.35);
    transition: transform var(--t-press) var(--ease), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
    .btn:hover { color: var(--ink); background-color: var(--glass-hover); border-color: var(--control-edge-hover); transform: translateY(-1px); box-shadow: var(--highlight), 0 10px 26px rgba(var(--shade-rgb), 0.5); }
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .tabs a:focus-visible, .state-tabs a:focus-visible, .nav a:focus-visible, .wa-chat:focus-visible { box-shadow: 0 0 0 5px var(--focus-halo); }

/* The one main action of a view: the lit one. The accent glows through it; the glow brightens on hover and focus. */
.btn.primary {
    color: var(--on-sun); border-color: transparent;
    background: linear-gradient(180deg, var(--sun-hi), var(--sun));
    box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.45), var(--glow-sun);
}
@media (hover: hover) and (pointer: fine) {
    .btn.primary:hover { color: var(--on-sun); background: linear-gradient(180deg, var(--sun-hover-hi), var(--sun-hover)); border-color: transparent; box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.5), var(--glow-sun-hi); }
}
.btn.primary:focus-visible { box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.5), 0 0 0 5px var(--focus-halo), var(--glow-sun-hi); }

/* The main action of one row among many (Approve on a draft, Send on WhatsApp on a row): the same
   amber, glowing through the glass instead of filling it, so a list is not a wall of lit buttons. */
.draft .btn.primary, .wa-row .btn.primary,
.page:has(form[action="/discover/start"]) .panel ~ .panel .btn.primary { /* Discover: several tasks on one screen, the first is the main one */
    color: var(--sun-text); background: var(--sheen), rgba(var(--sun-rgb), 0.19); border-color: var(--sun-edge);
    box-shadow: var(--highlight), 0 0 18px rgba(var(--sun-rgb), 0.12);
}
@media (hover: hover) and (pointer: fine) {
    .draft .btn.primary:hover, .wa-row .btn.primary:hover,
    .page:has(form[action="/discover/start"]) .panel ~ .panel .btn.primary:hover {
        color: var(--on-sun); background: linear-gradient(180deg, var(--sun-hi), var(--sun)); border-color: transparent;
        box-shadow: inset 0 1px 0 rgba(var(--light-rgb), 0.45), var(--glow-sun);
    }
}
.draft .btn.primary:focus-visible, .wa-row .btn.primary:focus-visible { box-shadow: 0 0 0 5px var(--focus-halo), var(--glow-sun); }

/* A button that should not compete with the one beside it. */
.btn.quiet { color: var(--ink-2); background: transparent; border-color: transparent; box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
    .btn.quiet:hover { color: var(--ink); background: var(--row-hover); border-color: var(--line); box-shadow: none; }
}
/* a button whose form has been sent and is waiting for the server */
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.6; cursor: progress; transform: none; }

.alert, .notice { padding: 10px 14px; border-radius: var(--radius-s); border: 1px solid; }
.alert { background: var(--bad-soft); border-color: var(--bad-edge); color: var(--bad-text); }
.notice { background: var(--ok-soft); border-color: var(--ok-edge); color: var(--ok-text); }
.alert a, .notice a { color: inherit; }
/* Something to know, neither a success nor a fault: a quiet pane. */
.heads-up { padding: 10px 14px; border-radius: var(--radius-s); border: 1px solid var(--quiet-edge); background: var(--quiet-soft); color: var(--ink-2); }

/* Chips: a tick or a choice as a small pane of tinted glass. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.chip { position: relative; margin: 0; }
.chip input { position: absolute; opacity: 0; }
.chip span {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; min-height: 36px; border-radius: 999px; font-size: 14px; cursor: pointer;
    color: var(--ink-2); background: var(--row); border: 1px solid var(--control-edge);
    transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-press) var(--ease);
}
.chip span:active { transform: scale(0.97); }
.chip input:checked + span { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.16); }
/* Chosen is said by a tick too, not by colour alone. */
.chip input:checked + span::before { content: ""; width: 9px; height: 5px; margin-top: -3px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus-halo); }
@media (hover: hover) and (pointer: fine) {
    .chip span:hover { color: var(--ink); background: var(--row-hover); }
}
/* a long list of chips (the countries) scrolls inside its own box; the padding keeps focus rings from being clipped */
.chips.scroll { max-height: 190px; overflow-y: auto; padding: 6px; border-radius: var(--radius-s); background: var(--glass-well); border: 1px solid var(--line); }
fieldset { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-size: 16px; font-weight: 620; letter-spacing: -0.01em; color: var(--ink); }

/* Tags: a fact about a row, in words, on a small tinted pane. */
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.tag, .status {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; min-height: 24px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap; border: 1px solid;
}
.tag.yes { color: var(--ok-text); background: var(--ok-soft); border-color: var(--ok-edge); }
.tag.no { color: var(--ink-2); background: var(--quiet-soft); border-color: var(--quiet-edge); }
.tag.unknown { color: var(--sun-text); background: var(--sun-soft); border-color: var(--sun-edge); }
/* "Not checked yet" is not a warning: a quiet, dashed pane. */
.tag.egypt.unknown { color: var(--muted); background: transparent; border-style: dashed; border-color: var(--quiet-edge); }

/* The status of an agency: one chip on every screen. The word says it; the colour and the small
   mark repeat it, so a list can be scanned down the page. */
.status { color: var(--ink-2); background: var(--quiet-soft); border-color: var(--quiet-edge); }
.status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
.st-contacted { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-edge); }
.st-contacted::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.st-replied { color: var(--sun-text); background: var(--sun-soft); border-color: var(--sun-edge); }
.st-replied::before { background: currentColor; }
.st-partner { color: var(--ok-text); background: var(--ok-soft); border-color: var(--ok-edge); }
.st-partner::before { background: currentColor; border-radius: 1px; transform: rotate(45deg) scale(0.86); }
.st-not-interested { color: var(--muted); background: transparent; border-color: var(--quiet-edge); }
.st-not-interested::before { height: 0; border-radius: 0; border-width: 0 0 2px; }
.st-hidden { color: var(--muted); background: transparent; border-style: dashed; border-color: var(--control-edge); }
.st-hidden::before { display: none; }

/* The small link beside a phone number that opens a chat with it. */
.wa-chat {
    position: relative; z-index: 1; /* above a card's own link */
    display: inline-flex; align-items: center; padding: 1px 9px; min-height: 24px; border-radius: 999px; vertical-align: baseline;
    font-size: 12px; font-weight: 600; line-height: 1.3; text-decoration: none; white-space: nowrap;
    color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent-edge);
    transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
    .wa-chat:hover { color: var(--on-accent); background: var(--accent); box-shadow: var(--glow-accent); }
}
.wa-chat:active { transform: scale(0.97); }

/* Tabs: views of one list, in a glass track. */
.tabs, .state-tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 24px; background: var(--glass-well); border: 1px solid var(--line); box-shadow: var(--recess); }
.tabs a, .state-tabs a {
    display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; min-height: 36px; border-radius: 999px; border: 1px solid transparent;
    color: var(--ink-2); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
    transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.tabs a b, .state-tabs a b { font-weight: 600; color: var(--muted); }
.tabs a[aria-current="page"], .state-tabs a[aria-current="page"] {
    color: var(--ink); background: var(--sheen), var(--glass-2); border-color: var(--control-edge); border-top-color: var(--control-edge-lit);
    box-shadow: var(--highlight), 0 4px 14px rgba(var(--shade-rgb), 0.4);
}
.tabs a[aria-current="page"] b, .state-tabs a[aria-current="page"] b { color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) {
    .tabs a:hover, .state-tabs a:hover { color: var(--ink); background-color: var(--row-hover); }
}

table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 560px; }
/* break-word, not anywhere: a column is never squeezed until its words break letter by letter */
th, td { text-align: start; padding: 10px 10px; border-bottom: 1px solid var(--line); font-size: 14px; overflow-wrap: break-word; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:last-child td { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) {
    tbody tr:not(.scanning):hover td { background: var(--row); }
}

.pager { display: flex; gap: 10px; align-items: center; margin-top: 18px; }
[aria-busy="true"] { opacity: 0.6; transition: opacity var(--t-fast); }

/* small helpers, so no page needs a style attribute */
.mt { margin-top: 18px; }
.mb { margin-bottom: 16px; }
.m0 { margin: 0 !important; } /* must beat ".panel + .panel" */
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.narrow { max-width: 460px; margin-inline: auto; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ 5. Shell */

/* Floating glass: the top bar. */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 22px;
    padding: 10px 28px;
    background: var(--glass-3);
    -webkit-backdrop-filter: var(--blur-3);
    backdrop-filter: var(--blur-3);
    border-bottom: 1px solid var(--edge-mid);
    box-shadow: 0 10px 34px rgba(var(--shade-rgb), 0.45);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
/* Up to ten links do not fit one line on a small laptop, a tablet or a phone: they wrap rather than widen the page. */
.nav {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 1; min-width: 0;
    /* Hides the hairline of the administrator's group when that group starts a line (see .nav-admin); glows and focus rings keep their room. */
    clip-path: inset(-60px -60px -60px -11px);
}
.nav a {
    padding: 8px 14px; border-radius: 999px; border: 1px solid transparent; text-decoration: none; color: var(--ink-2); font-weight: 500;
    transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
    .nav a:hover { background: var(--row-hover); color: var(--ink); }
}
.nav a.on {
    color: var(--ink); background: var(--sheen), var(--glass-2); border-color: var(--accent-edge);
    box-shadow: var(--highlight), 0 0 18px rgba(var(--accent-rgb), 0.18);
}
/* The administrator's screens (Settings, Users, Activity) close the bar as one group: a hairline
   before them, and they wrap together, never one by one. The room for the hairline is the margin
   of the link before the group, so a group that wraps starts its line flush with the others; its
   hairline then lies left of the bar, where .nav's clip hides it. */
.nav-admin { position: relative; display: flex; flex-wrap: nowrap; gap: 4px; }
.nav a:has(+ .nav-admin) { margin-inline-end: 20px; }
.nav-admin::before { content: ""; position: absolute; inset-block: 7px; inset-inline-start: -13px; width: 1px; background: var(--edge-mid); }
/* Replies nobody has opened: they wait for the owner, so the count is amber. */
.nav-count {
    display: inline-block; min-width: 20px; margin-inline-start: 4px; padding: 0 6px; border-radius: 999px;
    font-size: 12px; font-weight: 650; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
    color: var(--sun-text); background: var(--sun-soft); border: 1px solid var(--sun-edge);
}
.topbar form { margin: 0; }
.topbar .btn { min-height: 38px; padding: 7px 14px; }
.page { max-width: 1240px; margin: 0 auto; padding: 28px 28px 64px; }
.page > h1 { margin-bottom: 18px; }
.page > h1 + .muted { margin-top: -10px; margin-bottom: 18px; max-width: 72ch; }
.page > .notice, .page > .alert { margin-bottom: 16px; }

/* The background work, beside "Log out": a small pane with a light. Still and green when nothing
   waits; while work waits, a cyan beacon that pulses. */
.beat {
    display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--ink-2); white-space: nowrap;
    background: var(--row); border: 1px solid var(--line);
}
.beat-dot { position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px rgba(var(--ok-rgb), 0.7); transition: background-color var(--t-state) var(--ease); }
.beat.on { color: var(--accent-text); border-color: var(--accent-edge); }
.beat.on .beat-dot { background: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9); }

/* ------------------------------------------------------------------ 6. Screens */

/* --- Home --- */
/* The counters are one instrument panel: one pane of glass. On top the pipeline, where the agencies
   stand; under it nine readouts, five and four; hairlines between them. The pipeline is always the
   first child, so the readouts are children 2 to 10. */
.grid.stats { grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 0; overflow: hidden; }
.grid.stats > .stat {
    grid-column: span 4;
    display: block; margin: 0; padding: 18px 20px; color: inherit; text-decoration: none;
    background: none; border: 0; border-radius: 0; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
    -webkit-backdrop-filter: none; backdrop-filter: none;
}
.grid.stats > .stat:nth-child(n+7) { grid-column: span 5; }

/* The pipeline: the five statuses as a flow. New to Partner are four steps on one lit band with an
   arrow at each joint; "Not interested" is the way out of the flow, so it stands apart behind a
   hairline, off the band and quieter. Each step is a link to that part of the list. */
.pipeline {
    grid-column: 1 / -1;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 0.8fr);
    list-style: none; margin: 0; padding: 0; box-shadow: 0 1px 0 var(--line);
}
.pipeline li { position: relative; display: flex; background: var(--row); }
.pipeline a {
    flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0;
    padding: 16px 16px 16px 32px; color: inherit; text-decoration: none;
    transition: background-color var(--t-fast) var(--ease);
}
.pipeline li:first-child a, .pipeline-aside a { padding-inline-start: 20px; }
.pipeline .num { font-size: 30px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.pipeline a:focus-visible { outline-offset: -3px; }
@media (hover: hover) and (pointer: fine) {
    .pipeline a:hover { background: var(--row-hover); color: inherit; }
}
/* the arrow at a joint: it sits on the line between two steps */
.pipeline li + li:not(.pipeline-aside)::before {
    content: ""; position: absolute; z-index: 1; inset-inline-start: -7px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
    border-top: 2px solid var(--control-edge); border-right: 2px solid var(--control-edge);
    transform: rotate(45deg); pointer-events: none;
}
.pipeline li.pipeline-aside { background: none; box-shadow: -1px 0 0 var(--line); }
.pipeline-aside .num { color: var(--ink-2); }
.stat .num { font-size: 30px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.stat .muted { font-size: 13px; color: var(--ink-2); }
/* A counter that leads to its screen: the whole cell is the link, the underlined label says so. */
a.stat { transition: background-color var(--t-fast) var(--ease); }
a.stat .muted { text-decoration: underline; text-decoration-color: var(--accent-edge); text-underline-offset: 3px; }
a.stat .num { color: var(--accent-text); }
a.stat:focus-visible { outline-offset: -3px; }
@media (hover: hover) and (pointer: fine) {
    a.stat:hover { background: var(--row-hover); color: inherit; }
}
@media (max-width: 1000px) {
    .pipeline { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .pipeline a { padding-inline: 26px 10px; }
    .pipeline li:first-child a, .pipeline-aside a { padding-inline-start: 16px; }
}
@media (max-width: 900px) {
    .grid.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid.stats > .stat, .grid.stats > .stat:nth-child(n+7) { grid-column: auto; }
}
/* On a phone the four steps of the flow keep one line, their status as a bare mark and word;
   "Not interested" is a slim row of its own under them. */
@media (max-width: 600px) {
    .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .pipeline a { gap: 4px; padding: 12px 2px 12px 17px; }
    .pipeline li:first-child a { padding-inline-start: 12px; }
    .pipeline li + li:not(.pipeline-aside)::before { inset-inline-start: 0; width: 9px; height: 9px; margin-top: -5px; }
    .pipeline .num { font-size: 24px; }
    .pipeline .status { min-height: 0; padding: 0; gap: 4px; border: 0; background: none; font-size: 11px; }
    .pipeline li.pipeline-aside { grid-column: 1 / -1; box-shadow: 0 -1px 0 var(--line); }
    .pipeline-aside a { flex-direction: row-reverse; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 16px 8px 12px; }
    .pipeline-aside .num { font-size: 18px; }
}
@media (max-width: 480px) {
    .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.stats > .stat { padding: 14px 16px; }
    /* nine readouts in two columns: the last one (the tenth child, after the pipeline) takes the whole row */
    .grid.stats > .stat:last-child:nth-child(even) { grid-column: 1 / -1; }
}

.home { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
/* The globe is the planet of this sky: a rim of atmosphere around it, lights where the agencies are. */
/* pan-y: a finger moving up or down on the globe still scrolls the page; sideways it spins the globe */
#globe { position: relative; max-width: 560px; margin: 0 auto; cursor: grab; touch-action: pan-y; }
#globe:active { cursor: grabbing; }
#globe::before {
    content: ""; position: absolute; inset: 1.8%; border-radius: 50%; pointer-events: none;
    box-shadow: 0 0 46px 6px rgba(var(--accent-rgb), 0.22), 0 0 120px 30px var(--globe-halo);
}
#globe svg { position: relative; display: block; }
.globe-sphere { fill: var(--globe-sea); stroke: var(--globe-rim); stroke-width: 1.2; }
.globe-grid { fill: none; stroke: var(--globe-grid); stroke-width: 0.6; }
.globe-land { stroke: var(--globe-coast); stroke-width: 0.5; transition: fill var(--t-state); }
.globe-land.has { cursor: pointer; stroke: var(--globe-lit-coast); }
/* a country too small for the map: a light with a rim so it shows on land and sea alike */
.globe-dot { stroke: #fff; stroke-width: 1.2; }
.globe-land.has:hover { fill: #fff; }
/* the night side and the atmosphere, drawn over the land; never in the way of a click */
.globe-shade, .globe-air { pointer-events: none; }
.globe-tip {
    position: absolute; z-index: 2; pointer-events: none; padding: 6px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; white-space: nowrap;
    color: var(--ink); background: var(--glass-3); border: 1px solid var(--edge-lit); box-shadow: var(--shadow-1);
    -webkit-backdrop-filter: var(--blur-1); backdrop-filter: var(--blur-1);
    transition: opacity var(--t-fast);
}
.rank { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: var(--radius-s); text-decoration: none; transition: background-color var(--t-fast) var(--ease); }
.rank b { color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) {
    .rank:hover { background: var(--row-hover); color: var(--ink); }
}
@media (max-width: 900px) { .home { grid-template-columns: minmax(0, 1fr); } }

/* --- Agencies --- */
.filters { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; }
.filters > .btn { justify-self: start; min-height: 44px; }
.filters label { margin-bottom: 0; }
.panel > form + form, .panel > form + p { margin-top: 14px; }
#results > p:first-child { margin: 2px 8px 10px; }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.card {
    display: flex; flex-direction: column; gap: 3px; padding: 16px; min-width: 0;
    transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.card h3 { font-size: 16px; margin: 0 0 4px; overflow-wrap: anywhere; }
.card-link { text-decoration: none; }
/* The name is the link; it covers the whole card. */
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.card-link:focus-visible { outline: none; box-shadow: none; }
.card:has(.card-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus-halo); }
@media (hover: hover) and (pointer: fine) {
    .card:hover { transform: translateY(-2px); background: var(--row-hover); border-color: var(--accent-edge); box-shadow: 0 14px 32px rgba(var(--shade-rgb), 0.5), 0 0 18px rgba(var(--accent-rgb), 0.10); }
    .card:hover .card-link { color: var(--ink); }
}
.card:has(.card-link:active) { transform: scale(0.99); }
.card .line { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .line.phones { display: flex; flex-wrap: wrap; gap: 4px 12px; white-space: normal; overflow: visible; }
.phone { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.card .tags { margin-top: auto; padding-top: 10px; }
.panel > .tags { margin-bottom: 12px; }
/* a contact in a table, with the link and the note beside it */
td .wa-chat, td .tag { margin-inline-start: 6px; }

/* The mark of a next step's tone, before words that already say the same: amber and full for what
   waits for the owner, a cyan ring for what is under way, green for done, a rose square for blocked. */
.card .next-step::before, .next-step-label::before {
    content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted); border: 1.5px solid transparent;
}
.card .next-step[data-tone="todo"]::before, [data-tone="todo"] > .next-step-label::before { background: var(--sun); box-shadow: 0 0 8px rgba(var(--sun-rgb), 0.55); }
.card .next-step[data-tone="waiting"]::before, [data-tone="waiting"] > .next-step-label::before { background: transparent; border-color: var(--accent); }
.card .next-step[data-tone="done"]::before, [data-tone="done"] > .next-step-label::before { background: var(--ok); }
.card .next-step[data-tone="blocked"]::before, [data-tone="blocked"] > .next-step-label::before { background: var(--bad); border-radius: 1px; }

/* The next step on a card: the foot of the card, one or two short lines under the tags. Two lines
   are kept free for it, so the tags of a row of cards stay level whether the sentence is short or long. */
.card .next-step {
    display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 8px;
    margin: 10px 0 0; padding-top: 9px; min-height: calc(2.8em + 10px); /* two lines of 1.4 */
    border-top: 1px solid var(--line); font-size: 13px; line-height: 1.4; color: var(--ink-2);
}
.card .next-step::before { margin-top: calc(0.7em - 4px); /* level with the first line */ }
.card .next-step[data-tone="todo"] { color: var(--ink); }
@media (max-width: 660px) {
    .card .next-step { min-height: 0; } /* one card to a row: nothing beside it to stay level with */
}

/* --- Agency: the next step, the lead of the page --- */
/* Under the name, before anything else: what to do now, in the largest words after the name, on a
   pane tinted with its tone; the status beside it, and the one lit button of the page when there is one. */
.next-step-box {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; align-items: center;
    margin: 4px 0 16px; padding: 14px 18px 18px;
    background: var(--quiet-soft); border: 1px solid var(--quiet-edge); border-radius: 14px; box-shadow: var(--highlight);
}
.next-step-box[data-tone="todo"] { background: var(--sun-soft); border-color: var(--sun-edge); }
.next-step-box[data-tone="waiting"] { background: var(--accent-soft); border-color: var(--accent-edge); }
.next-step-box[data-tone="done"] { background: var(--ok-soft); border-color: var(--ok-edge); }
.next-step-box[data-tone="blocked"] { background: var(--bad-soft); border-color: var(--bad-edge); }
.next-step-label {
    display: flex; align-items: center; gap: 8px; margin: 0;
    font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
[data-tone="todo"] > .next-step-label { color: var(--sun-text); }
[data-tone="waiting"] > .next-step-label { color: var(--accent-text); }
[data-tone="done"] > .next-step-label { color: var(--ok-text); }
[data-tone="blocked"] > .next-step-label { color: var(--bad-text); }
.next-step-status { display: flex; align-items: center; gap: 8px; margin: 0; justify-self: end; font-size: 13px; color: var(--ink-2); }
.next-step-text {
    margin: 0; max-width: 52ch;
    font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
    font-size: 20px; font-weight: 620; line-height: 1.3; letter-spacing: -0.015em; text-wrap: balance; overflow-wrap: anywhere;
}
.next-step-text:last-child { grid-column: 1 / -1; } /* nothing to press: the sentence has the whole line */
.next-step-box > .btn { justify-self: end; }
@media (max-width: 720px) {
    .next-step-box { padding: 12px 14px 14px; }
    .next-step-text { grid-column: 1 / -1; font-size: 18px; }
    .next-step-box > .btn { grid-column: 1 / -1; justify-self: stretch; }
}

/* --- Agency: "What happened" --- */
/* The note form, then one line per entry: when, what, who. A rail joins the marks; the owner's
   own lines have a full amber mark, the tool's a cyan ring. */
#history { scroll-margin-top: 84px; } /* reached through "#history" after a note: clear of the sticky top bar */
.note-form { display: grid; gap: 8px; max-width: 720px; margin: 0 0 22px; }
.note-form label { margin: 0; }
.note-form textarea { margin-top: 0; min-height: 68px; field-sizing: content; }
.note-form .btn { justify-self: start; }
.timeline { position: relative; max-width: 960px; list-style: none; margin: 0; padding: 0; }
.timeline::before { content: ""; position: absolute; top: 18px; bottom: 18px; inset-inline-start: 4px; width: 1px; background: var(--quiet-edge); }
.timeline-entry {
    position: relative; display: grid; grid-template-columns: 10.5em minmax(0, 1fr) auto; gap: 2px 18px; align-items: baseline;
    padding: 9px 0 9px 26px; border-bottom: 1px solid var(--line);
}
.timeline-entry:last-child { border-bottom: 0; }
.timeline-entry::before {
    content: ""; position: absolute; inset-inline-start: 0; top: 15px; width: 9px; height: 9px; border-radius: 50%;
    background: var(--solid); border: 1.5px solid var(--accent);
}
.timeline-entry[data-actor="owner"]::before { background: var(--sun); border-color: var(--sun); }
.timeline-entry time { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline-text { min-width: 0; overflow-wrap: anywhere; }
.timeline-entry[data-kind="note"] .timeline-text { color: var(--ink); font-weight: 600; }
.timeline-by { font-size: 12px; color: var(--muted); white-space: nowrap; }
.timeline-entry[data-actor="owner"] .timeline-by { color: var(--sun-text); }
@media (max-width: 720px) {
    /* when and who share the first line; what happened has the whole width under them */
    .timeline-entry { grid-template-columns: minmax(0, 1fr) auto; }
    .timeline-text { grid-column: 1 / -1; grid-row: 2; }
}

/* --- Discover --- */
/* Search with Claude: "what to look for" is a sentence, so it gets two columns where there is room;
   under the form, what the chosen size costs and what is left of the month's limit. */
@media (min-width: 900px) {
    .filters > .span-2 { grid-column: span 2; }
}
.claude-cost { margin: 14px 0 0; }
.claude-cost b { color: var(--sun-text); }
/* a discovery run that is still working: a light sweeps across its row */
tr.scanning td {
    background: linear-gradient(100deg, transparent 25%, rgba(var(--accent-rgb), 0.14) 50%, transparent 75%);
    background-size: 200% 100%;
    animation: scan 1.8s linear infinite;
}
@keyframes scan { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- Campaigns --- */
/* the new-campaign form: the fields, and beside them what the campaign would do */
.campaign-new { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.campaign-preview { position: sticky; top: 84px; }
.field-hint { margin: -4px 0 12px; font-size: 13px; }
.chips + .field-hint { margin-top: 10px; }
/* The count updates by itself once the script runs; the line that held its button must not leave a gap. */
p:has(> [data-refresh][hidden]) { display: none; }
.preview-count { font-size: 16px; }
.preview-count .num { font-size: 30px; font-weight: 650; letter-spacing: -0.03em; color: var(--accent-text); }
.left-out { margin: 6px 0 14px; padding-inline-start: 20px; color: var(--ink-2); }
.left-out li { margin: 2px 0; }
.alert .left-out { color: inherit; }
.campaign-table td a { font-weight: 600; }
.campaign-table td:first-child { min-width: 220px; }

/* the top of one campaign: name, state in words, one bar, the bulk actions */
.campaign-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.campaign-title h1 { margin: 0; overflow-wrap: anywhere; }
.campaign-state { margin: 0; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--quiet-edge); background: var(--quiet-soft); color: var(--ink-2); }
.campaign-head[data-state="drafting"] .campaign-state, .campaign-head[data-state="sending"] .campaign-state { background: var(--accent-soft); border-color: var(--accent-edge); color: var(--accent-text); }
.campaign-head[data-state="review"] .campaign-state { background: var(--sun-soft); border-color: var(--sun-edge); color: var(--sun-text); }
.campaign-head[data-state="paused"] .campaign-state { background: var(--sun-soft); border-color: var(--sun-edge); color: var(--sun-text); border-style: dashed; }
.campaign-head[data-state="done"] .campaign-state { background: var(--ok-soft); border-color: var(--ok-edge); color: var(--ok-text); }
.campaign-brief { max-width: 72ch; margin: 8px 0 16px; overflow-wrap: anywhere; color: var(--ink-2); }
.paused-note { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 16px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--sun-soft); border: 1px solid var(--sun-edge); color: var(--sun-text); }
.paused-note .muted { color: var(--ink-2); }
.paused-note form { margin: 0; }
/* What the state allows is shown by the state itself, so the page script only has to change data-state. */
.campaign-head:not([data-state="paused"]) .when-paused,
.campaign-head[data-state="paused"] .when-running,
.campaign-head[data-state="done"] .when-running,
.campaign-head[data-approved-emails="0"] .when-approved-emails { display: none; }

/* Sent fills from the left, failed from the right; the script sets each one's scale. */
.progress { position: relative; height: 10px; border-radius: 999px; overflow: hidden; background: var(--glass-well); border: 1px solid var(--line); box-shadow: var(--recess); }
.progress span { position: absolute; inset: 0; transform: scaleX(0); }
.progress-sent { transform-origin: left center; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.6); }
.progress-failed { transform-origin: right center; background: var(--bad); }
.progress.ready span { transition: transform var(--t-enter) var(--ease); }
.progress-numbers { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 10px 0 14px; color: var(--ink-2); }
.progress-numbers b { font-size: 18px; color: var(--ink); }
.campaign-actions { margin-top: 14px; }
.campaign-actions form { margin: 0; }
.campaign-head .alert { margin: 14px 0 0; }

/* the drafts */
#drafts.list-glass { padding: 16px; }
.drafts-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 2px 4px 14px; }
.draft-list { display: grid; gap: 12px; }
.draft { padding: 20px; scroll-margin-top: 84px; /* the sticky top bar must not cover a draft reached by its #m<id> */ }
.draft.is-approved, .draft.is-sent { border-color: var(--ok-edge); }
.draft.is-failed { border-color: var(--bad-edge); }
.draft.is-dropped, .draft.is-skipped { background: transparent; }
.draft.is-queued { overflow: hidden; }
.draft-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 16px; }
.draft-who { min-width: 0; }
.draft-head h3 { margin: 0 0 2px; font-size: 17px; overflow-wrap: anywhere; }
.draft-head h3 a { text-decoration: none; }
.draft-head h3 a:hover { text-decoration: underline; }
.draft-meta { margin: 0; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.draft-state { max-width: 100%; margin: 0; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; border: 1px solid var(--quiet-edge); background: var(--quiet-soft); color: var(--ink-2); }
.is-drafted .draft-state { background: var(--sun-soft); border-color: var(--sun-edge); color: var(--sun-text); }
.is-queued .draft-state { background: var(--accent-soft); border-color: var(--accent-edge); color: var(--accent-text); }
.is-approved .draft-state, .is-sent .draft-state { background: var(--ok-soft); border-color: var(--ok-edge); color: var(--ok-text); }
.is-opened .draft-state { background: var(--sun-soft); border-color: var(--sun-edge); color: var(--sun-text); }
.is-failed .draft-state { border-radius: 10px; background: var(--bad-soft); border-color: var(--bad-edge); color: var(--bad-text); }
.draft-proof { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
/* The person this email goes to, when it is not a general address. */
.draft-to { margin: 10px 0 0; font-size: 14px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.draft > p.muted { margin: 12px 0 0; }
.draft .notice, .draft .alert { margin: 12px 0 0; }
.draft-form { margin: 14px 0 0; }
.draft-subject { margin: 14px 0 0; }
.draft-form .draft-subject { margin: 0 0 12px; }
.draft-subject input { font-weight: 600; }
/* The owner compares a message with its English copy for hours: two equal columns, the same
   measure and the same line height in both, on the densest glass. */
.draft-texts { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 12px; }
.draft-form .draft-texts { margin-top: 0; }
.draft-texts.single { grid-template-columns: minmax(0, 76ch); }
.draft-original { margin: 0; }
/* The message shows in full: the field grows with its text where the browser can, else its rows do it. */
.draft textarea { font-size: 15px; line-height: 1.6; resize: vertical; field-sizing: content; min-height: 7em; background: var(--glass-dense); }
.draft-label { margin: 0 0 5px; font-size: 13px; color: var(--ink-2); }
/* read-only text: the same box as the field beside it, without the field's frame */
.draft-text { padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--glass-dense); font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.draft-english .draft-text { margin-top: 5px; color: var(--ink-2); }
.draft-english .draft-label { margin: 0; }
.draft-hint { margin: 10px 0 0; font-size: 13px; }
.draft-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 14px; }
form.draft-actions { margin-bottom: 0; }
.draft-actions .btn.primary { min-width: 120px; }
.rewrite > summary { list-style: none; }
.rewrite > summary::-webkit-details-marker { display: none; }
.rewrite[open] { flex-basis: 100%; }
.rewrite[open] > summary { background: var(--glass-hover); border-color: var(--accent-edge); }
.rewrite-body { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; margin-top: 10px; padding: 12px; }
.rewrite-body label { flex: 1 1 260px; margin: 0; }

@media (max-width: 900px) {
    .campaign-new { grid-template-columns: minmax(0, 1fr); }
    .campaign-preview { position: static; }
}
@media (max-width: 820px) {
    .draft-texts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
    #drafts.list-glass { padding: 8px; }
    .draft { padding: 14px; scroll-margin-top: 12px; } /* the top bar no longer sticks */
    .campaign-preview { top: auto; }
    .draft-actions .btn { min-height: 44px; }
}

/* --- WhatsApp --- */
.wa { max-width: 1040px; margin-inline: auto; }
.wa-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.wa-title h1 { margin: 0; }
.wa > .notice { margin-bottom: 16px; }
.wa-list-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; margin: 0 6px 12px; }
.wa-note { font-size: 13px; }
.wa-empty { margin-bottom: 0; }
.wa-list { list-style: none; margin: 0; display: grid; gap: 8px; align-content: start; }
/* One row per message: who and what on the left, what to do on the right. */
.wa-row { display: grid; grid-template-columns: minmax(0, 1fr) 248px; gap: 12px 26px; align-items: start; padding: 16px 18px; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.wa-row.is-opened { border-color: var(--sun-edge); }
.wa-row.is-done { border-color: var(--ok-edge); background: var(--ok-soft); }
.wa-main { min-width: 0; }
.wa-name { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.wa-name a { text-decoration: none; }
.wa-name a:hover { text-decoration: underline; }
.wa-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 3px 0 0; font-size: 13px; color: var(--ink-2); }
.wa-number { font-size: 14px; font-weight: 600; color: var(--ink); }
/* The message as it will be sent: line breaks kept, long words broken, any script direction. */
.wa-excerpt { max-width: 70ch; margin: 10px 0 0; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; color: var(--ink-2); }
.wa-more { margin-top: 6px; }
.wa-more > summary { display: inline-flex; align-items: center; min-height: 32px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--accent-text); border-radius: 8px; }
.wa-more[open] > summary { margin-bottom: 4px; }
/* Opened, the whole text replaces its first lines. */
.wa-row:has(.wa-more.has-all[open]) .wa-excerpt { display: none; }
.wa-text { max-width: 70ch; padding: 12px 14px; font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); background: var(--glass-dense); border: 1px solid var(--line); border-radius: var(--radius-s); }
.wa-english { color: var(--ink-2); }
.wa-label { margin: 12px 0 5px; font-size: 13px; color: var(--ink-2); }
.wa-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.wa-actions .btn { min-height: 44px; }
.wa-actions .alert { margin: 0; font-size: 13px; }
.wa-open, .wa-quiet, .wa-error { grid-column: 1 / -1; }
/* The rare, lasting choice: a plain text button, still a full-size target. */
.wa-quiet {
    min-height: 44px; padding: 8px 12px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
    background: none; border: 0; border-radius: var(--radius-s); text-decoration: underline; text-decoration-color: var(--quiet-edge); text-underline-offset: 3px;
    transition: color var(--t-fast) var(--ease);
}
.wa-quiet:hover { color: var(--bad-text); }
.wa-quiet[aria-disabled="true"] { opacity: 0.6; cursor: progress; }

/* All numbers: name and number, the status in one column to scan down, the buttons. */
.wa-quick { margin-bottom: 18px; }
.wa-quick form { margin: 0; }
.wa-quick-label { margin: 0 0 2px; font-size: 16px; font-weight: 620; color: var(--ink); }
.wa-quick textarea { min-height: 84px; background: var(--glass-dense); }
.wa-quick-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: 10px; }
.wa-quick-foot .hint { margin: 0; }
.wa-filter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; gap: 12px 14px; align-items: end; margin: 0 0 14px; }
.wa-filter label { margin: 0; }
.wa-filter .chip span { min-height: 44px; }
.wa-filter .btn { min-height: 44px; }
.wa-total { margin: 0 6px 10px; font-size: 13px; }
.wa-number-row { grid-template-columns: minmax(0, 1fr) 128px 300px; align-items: center; padding-block: 12px; }
.wa-status { margin: 0; }
.wa-number-row .wa-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; align-items: center; }
.wa-numbers-pane { padding: 16px; }
.wa-numbers-pane .wa-list { padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.wa-none { margin: 8px 6px; }
.wa-number-row .wa-actions form { margin: 0; }
.wa-number-row .wa-open { min-width: 124px; }
@media (hover: hover) and (pointer: fine) {
    .wa-number-row:hover { background: var(--row-hover); border-color: var(--edge-mid); }
}

.wa-recent-panel { margin-top: 22px; }
.wa-recent { list-style: none; margin: 0; padding: 0; }
.wa-recent li {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
    padding: 10px 0; border-bottom: 1px solid var(--line);
}
.wa-recent li:last-child { border-bottom: 0; padding-bottom: 0; }
.wa-recent-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.wa-recent-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13px; }
.wa-recent form { margin: 0; }
.wa-recent .btn { min-height: 44px; }

@media (max-width: 860px) {
    .wa-number-row { grid-template-columns: minmax(0, 1fr) auto; }
    .wa-number-row .wa-actions { grid-column: 1 / -1; justify-content: flex-start; }
    .wa-filter { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
/* On a phone every row is one column, and every button a full-size target. */
@media (max-width: 720px) {
    .wa-list { padding: 6px; }
    .wa-row, .wa-number-row { grid-template-columns: minmax(0, 1fr); padding: 14px; }
    .wa-number-row .wa-actions { justify-content: stretch; }
    .wa-number-row .wa-actions > *, .wa-number-row .wa-actions form .btn { flex: 1 1 auto; }
    .wa-number-row .wa-actions > .tag, .wa-number-row .wa-actions > .muted { flex: none; }
    .wa-number-row .wa-actions .btn { min-height: 44px; width: 100%; }
    .wa-more > summary { min-height: 44px; }
    .wa-filter { grid-template-columns: minmax(0, 1fr); }
    .wa-quick-foot .btn { width: 100%; min-height: 44px; }
    .tabs { display: flex; width: 100%; }
    .tabs a { flex: 1 1 auto; justify-content: center; min-height: 44px; }
}

/* --- Settings --- */
/* A long page of forms reads best as one calm column of panes with room between them. */
.settings { max-width: 880px; margin-inline: auto; }
.settings > h1 + .muted { margin: -6px 0 18px; }
/* "margin" also replaces ".panel + .panel"; scroll-margin keeps a section reached by its link clear of the sticky top bar */
.settings .panel { margin: 0 0 24px; scroll-margin-top: 84px; background: var(--sheen), var(--glass-dense); }
.settings h2 { margin-bottom: 6px; }
.settings h2 + .muted { margin: 0 0 18px; max-width: 70ch; }
.settings textarea { min-height: 84px; }
.settings .messages { display: grid; gap: 8px; margin: 0 0 16px; }
.settings .messages p { margin: 0; }

/* fields: label above, help text under, two columns on a wide screen */
.fields { display: grid; gap: 18px 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.field > label { margin: 0; }
.field > .chip { display: inline-block; margin-top: 10px; }

/* "Ready to write to agencies?": every line says done or not done in words, the colour only repeats it */
.checklist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.checklist li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px; border-radius: var(--radius-s); }
.checklist .tag { flex: none; }
.checklist a { margin-inline-start: auto; font-weight: 600; color: var(--accent-text); }

.test-email { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.test-email .hint { margin: 0; }
.spend { margin: 18px 0 0; font-weight: 600; }

/* The one Save of the long form stays in reach at the bottom of the screen while any of its sections is in view. */
.save-bar {
    position: sticky; bottom: 12px; z-index: 5;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
    margin: 0 0 24px; padding: 12px 16px;
    background: var(--glass-3); border: 1px solid var(--edge-dim); border-top-color: var(--edge-lit); border-left-color: var(--edge-mid); border-radius: var(--radius);
    box-shadow: var(--highlight), var(--shadow-2);
    -webkit-backdrop-filter: var(--blur-3);
    backdrop-filter: var(--blur-3);
}

.never-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; max-width: 560px; }
.never-add label { margin: 0; }
.never-add .btn { min-height: 44px; }
.table-wrap table.fit { min-width: 0; }
.table-wrap table.fit td { vertical-align: middle; }
.table-wrap table.fit td:last-child { text-align: end; }
.table-wrap table.fit form { margin: 0; }

/* On a phone a row of the never-contact list is a small block: the address, why and when under it, Remove beside them. */
@media (max-width: 640px) {
    table.fit, table.fit tbody { display: block; }
    table.fit thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    table.fit tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
    table.fit tbody tr:last-child { border-bottom: 0; }
    table.fit td { display: block; padding: 0; border: 0; grid-column: 1; font-size: 13px; color: var(--ink-2); }
    table.fit td:first-child { font-size: 14px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
    table.fit td:last-child { grid-column: 2; grid-row: 1 / span 3; }
    table.fit .btn { min-height: 44px; }
}
@media (max-width: 640px) {
    .fields, .never-add { grid-template-columns: minmax(0, 1fr); }
    .never-add .btn { justify-self: start; }
    .settings .panel { margin-bottom: 18px; }
    .checklist a { margin-inline-start: 0; }
}

/* --- Users and activity --- */
/* Users, one account and My account are built like Settings (.settings, .fields, .messages);
   the activity log is a table of the usual kind. Only what those lack is here. */

/* The person's name beside "Log out": a quiet link to My account. */
.topbar-me {
    max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 8px 4px; font-size: 14px; color: var(--ink-2); text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}
.topbar-me[aria-current="page"] { color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) {
    .topbar-me:hover { color: var(--ink); text-decoration: underline; }
}
.topbar-me:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.users .messages { display: grid; gap: 8px; margin: 0 0 16px; }
.users .messages p { margin: 0; }
.users-facts { overflow-wrap: anywhere; }
.users-table td:first-child { min-width: 200px; }
.users-table td:first-child a { font-weight: 600; }
.users-table .tag { margin-inline-start: 6px; }
.users-email { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.users form.row { margin: 0; }
.users .field > .chip { margin-top: 0; }

/* The log's filter: the date fields look like every other field. */
.log-filters input[type=date] {
    display: block; width: 100%; margin-top: 5px; padding: 9px 12px; min-height: 44px;
    font: inherit; font-size: 15px; color: var(--ink);
    background: var(--glass-well); border: 1px solid var(--control-edge); border-radius: var(--radius-s);
    box-shadow: var(--recess);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.log-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 18px; }
.log-summary p { margin: 0; color: var(--ink-2); }
.log-summary a:not(.btn) { color: var(--accent-text); }

.log-table td { vertical-align: baseline; }
.log-when { width: 1%; white-space: nowrap; color: var(--ink-2); }
.log-who { width: 18%; min-width: 140px; overflow-wrap: anywhere; }
.log-what { overflow-wrap: anywhere; }
.log-what .tag { margin: 0 8px 0 0; vertical-align: 1px; }
.log-agency { display: inline-block; margin-inline-start: 8px; font-size: 13px; color: var(--accent-text); }

/* A phone: no table that scrolls sideways and hides what a line says. Each account and each line
   of the log is a small card: who or when first, then the rest, each value with its name. */
@media (max-width: 640px) {
    .topbar-me { max-width: 14ch; }
    .table-wrap table.users-table, .table-wrap table.log-table { min-width: 0; }
    .users-table, .users-table tbody, .log-table, .log-table tbody { display: block; }
    .users-table thead, .log-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .users-table tr, .log-table tr { display: grid; align-items: center; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
    .users-table tbody tr:last-child, .log-table tbody tr:last-child { border-bottom: 0; padding-bottom: 0; }
    .users-table tbody tr:first-child, .log-table tbody tr:first-child { padding-top: 4px; }
    .users-table td, .log-table td { display: block; width: auto; min-width: 0; padding: 0; border: 0; font-size: 14px; }
    .users-table tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .users-table td:first-child { grid-column: 1 / -1; min-width: 0; margin-bottom: 4px; }
    .users-table td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
    .users-table td[data-label] .tag { margin-inline-start: 0; }
    .users-table td a { display: inline-flex; align-items: center; min-height: 44px; }
    .log-table tr { grid-template-columns: auto minmax(0, 1fr); }
    .log-table .log-when, .log-table .log-who { font-size: 13px; }
    .log-table .log-what { grid-column: 1 / -1; }
    .log-table .log-who a, .log-agency { display: inline-flex; align-items: center; min-height: 44px; }
    .log-table tr:not(:has(.log-who)) { grid-template-columns: minmax(0, 1fr); }
}

/* --- Manual campaigns; WhatsApp one after another --- */
/* The new-campaign form: who writes, then that writer's fields. Without script both sets show,
   each under its small heading (.writer-for); campaign.js hides the heading and the other set. */
.writer-choice { margin: 0 0 18px; }
.writer-fields { margin: 0 0 6px; }
.writer-fields + .writer-fields { padding-top: 14px; border-top: 1px solid var(--line); }
.writer-for { margin: 0 0 8px; font-size: 13px; font-weight: 620; color: var(--sun-text); }
.writer-fields textarea[name="message"] { min-height: 180px; background: var(--glass-dense); }
.writer-fields .chips { margin-top: 4px; }
.field-hint code { white-space: nowrap; color: var(--ink); }

/* One after another: a pane above the list. The setup line first; while it runs, who is on now,
   the seconds left, a thin bar of the wait, and the buttons. */
.wa-auto { margin-bottom: 16px; }
.wa-auto-title { margin: 0 0 12px; font-size: 16px; }
.wa-auto-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.wa-auto-start { min-width: 132px; min-height: 44px; }
.wa-auto-kind { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0; }
.wa-auto-kind label { margin: 0; }
.wa-auto-kind select { width: auto; min-width: 250px; margin-top: 0; }
.wa-auto-more { margin-top: 12px; }
.wa-auto-how { margin: 0 0 12px; max-width: 70ch; color: var(--ink-2); }
.wa-auto-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.wa-auto-wait { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; }
.wa-auto-wait label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--ink-2); }
/* The same recessed field as the others, sized for three digits. */
.wa-auto-wait input[type=number] {
    width: 6.5em; min-height: 44px; padding: 8px 10px; font: inherit; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--ink);
    background: var(--glass-well); border: 1px solid var(--control-edge); border-radius: var(--radius-s); box-shadow: var(--recess);
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.wa-auto-wait input[type=number]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--accent); box-shadow: var(--recess), 0 0 0 5px var(--focus-halo); }
.wa-auto-saved { margin: 0; }
.wa-auto-limits { margin: 12px 0 0; font-size: 13px; max-width: 76ch; }

.wa-auto-run { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.wa-auto-now { margin: 0; font-size: 16px; color: var(--ink-2); overflow-wrap: anywhere; }
.wa-auto-now b { color: var(--ink); }
.wa-auto-count { margin: 6px 0 10px; color: var(--ink-2); }
.wa-auto-count b { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--sun-text); }
/* The progress bar of the campaigns, thinner; the light moves by the second. */
.wa-auto-bar { height: 6px; }
.wa-auto-bar .progress-sent { transition: transform 1s linear; }
.wa-auto-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.wa-auto-buttons .btn { min-height: 44px; }
.wa-auto-hint { margin: 10px 0 0; max-width: 70ch; }
.wa-auto-error, .wa-auto-done { margin: 12px 0 0; }
/* The row on now, in the list below: the amber of what waits for the owner. */
.wa-row.wa-auto-current { border-color: var(--sun-edge); box-shadow: 0 0 0 1px var(--sun-edge), var(--glow-sun); }

@media (max-width: 720px) {
    .wa-auto-line, .wa-auto-kind { align-items: stretch; }
    .wa-auto-start, .wa-auto-kind select, .wa-auto-buttons .btn { width: 100%; }
    .wa-auto-kind select { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .wa-auto-bar .progress-sent { transition: none; }
}

/* --- Agency: contacts, socials, details --- */
/* Each email, phone or social page is a row on the pane: what it is, then its two quiet buttons.
   Every form is folded until it is wanted (a row's label, the form to add one under the list,
   "Correct the details"), so the page reads as lists and nothing competes with the next step.
   Reached through "#contacts", "#socials" or "#details" after a form: clear of the sticky top bar. */
#contacts, #socials, #details { scroll-margin-top: 84px; }
#contacts > .notice, #contacts > .alert, #socials > .notice, #socials > .alert, .details-edit > .notice, .details-edit > .alert { margin-bottom: 14px; }
.said-link { margin: -6px 0 14px; }
.said-link a { color: var(--accent-text); font-weight: 600; }

.edit-list { display: grid; gap: 8px; list-style: none; margin: 0 0 18px; padding: 0; }
.edit-row {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
    padding: 10px 14px; background: var(--row); border: 1px solid var(--edge-dim); border-top-color: var(--edge-mid); border-radius: 14px;
    transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
    .edit-row:hover { background: var(--row-hover); }
}
.edit-what { flex: 1 1 280px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.edit-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.edit-label > summary, .edit-add-fold > summary { list-style: none; }
.edit-label > summary::-webkit-details-marker, .edit-add-fold > summary::-webkit-details-marker { display: none; }
.edit-label[open] > summary, .edit-add-fold[open] > summary { background: var(--glass-hover); border-color: var(--accent-edge); }
.edit-add-fold[open] > .edit-add { animation: fade-in var(--t-state) var(--ease) backwards; }
.edit-kind { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.edit-value { font-weight: 600; overflow-wrap: anywhere; }
.edit-note { flex-basis: 100%; font-size: 13px; color: var(--ink-2); }
.edit-source { flex-basis: 100%; font-size: 13px; overflow-wrap: anywhere; }
.tag.by-you { color: var(--sun-text); background: transparent; border-color: var(--sun-edge); }
.edit-row form { margin: 0; }
.edit-row .btn { min-height: 38px; padding: 6px 12px; }
/* A row's label field: the row's last line, there only while "Label" is open. The buttons above it stay where they are. */
.edit-label-form { display: none; flex: 1 1 100%; align-items: flex-end; gap: 8px; max-width: 520px; padding-bottom: 4px; }
.edit-row:has(.edit-label[open]) > .edit-label-form { display: flex; animation: fade-in var(--t-state) var(--ease) backwards; }
.edit-label-form label { flex: 1; min-width: 0; margin: 0; font-size: 12px; }
.edit-label-form input { min-height: 42px; padding-block: 8px; }

.edit-add-fold > .edit-add { margin-top: 14px; }
.edit-add-fold > .hint { margin-bottom: 0; }
.edit-add { display: grid; grid-template-columns: minmax(120px, 160px) minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.edit-add.social-add { grid-template-columns: minmax(0, 1fr) auto; max-width: 720px; }
.edit-add label { margin: 0; }
.edit-add .btn, .details-form .btn { min-height: 44px; }

.details-edit { margin-top: 16px; padding-top: 6px; border-top: 1px solid var(--line); }
.details-edit > summary {
    display: inline-flex; align-items: center; min-height: 44px; cursor: pointer;
    font-weight: 600; color: var(--accent-text); border-radius: 8px;
}
.details-edit[open] > summary { margin-bottom: 8px; }
.details-form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: start; }
.details-form label { margin: 0; }
.details-form > .hint, .details-form > .btn { grid-column: 1 / -1; justify-self: start; margin: 0; }

/* Adding an agency by hand: the details, then three of each kind of contact. */
.agency-new fieldset { margin-top: 22px; }
.new-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.new-list label { margin: 0; }
.agency-new > .hint { margin: 18px 0 14px; }
.field-error { margin: 6px 0 0; font-size: 13px; color: var(--bad-text); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad-edge); }

@media (max-width: 720px) {
    /* One column: what it is, its label, then its buttons, each the full width and a thumb high. */
    .edit-add, .edit-add.social-add, .details-form, .new-list { grid-template-columns: minmax(0, 1fr); }
    .edit-actions { flex-basis: 100%; justify-content: flex-start; }
    .edit-row:has(.edit-label[open]) > .edit-label-form { flex-wrap: wrap; max-width: none; }
    .edit-label-form label { flex-basis: 100%; }
    .edit-row .btn, .edit-add-fold > summary { min-height: 44px; }
    .edit-label-form .btn, .edit-add .btn, .details-form .btn, .agency-new > .btn { width: 100%; min-height: 44px; }
    .edit-label-form input { min-height: 44px; }
}

/* --- People --- */
/* The people in charge: on an agency's page, on the People screen, and the page that finds them for many agencies.
   Rows are plain fills on their pane, never a blur each. */
.people, .people-list { display: grid; gap: 8px; list-style: none; margin: 0 0 16px; padding: 0; }
.person, .person-row { padding: 14px 16px; border-radius: var(--radius-s); background: var(--row); border: 1px solid var(--line); transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.person { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 18px; scroll-margin-top: 84px; }
.person.is-primary { border-color: var(--ok-edge); }
@media (hover: hover) and (pointer: fine) {
    .person:hover, .person-row:hover { background: var(--row-hover); }
}
.person-who { flex: 1 1 260px; min-width: 0; }
.person-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.person-role { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.person-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 8px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.person-links a:not(.wa-chat) { color: var(--accent-text); }
.person-found { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.person-source { color: var(--muted); }
.person-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.person-actions form { margin: 0; }
.person-edit > summary, .person-add > summary { list-style: none; }
.person-edit > summary::-webkit-details-marker, .person-add > summary::-webkit-details-marker { display: none; }
.person-actions:has(.person-edit[open]), .person-edit[open] { flex-basis: 100%; }
.person-edit[open] > summary, .person-add[open] > summary { background: var(--glass-hover); border-color: var(--accent-edge); }
.person-form { margin: 10px 0 0; padding: 14px; border-radius: var(--radius-s); background: var(--glass-well); border: 1px solid var(--line); }
.person-form > .btn { margin-top: 14px; }
.person-edit[open] .person-form, .person-add[open] .person-form { animation: fade-in var(--t-state) var(--ease) backwards; }
.people-notice { margin: 0 0 14px; }
.people-find { margin: 0 0 16px; }
.people-find form { margin: 0 0 6px; }
.people-find p { margin: 0 0 6px; }
.people-cost { font-weight: 600; color: var(--sun-text); }
/* A search that is waiting or running: a light sweeps across it, as across a discovery run that works. */
.people-looking {
    display: inline-flex; align-items: center; min-height: 42px; padding: 8px 14px; border-radius: var(--radius-s);
    color: var(--accent-text); border: 1px solid var(--accent-edge);
    background: linear-gradient(100deg, transparent 25%, rgba(var(--accent-rgb), 0.14) 50%, transparent 75%), var(--accent-soft);
    background-size: 200% 100%, auto;
    animation: scan 1.8s linear infinite;
}

/* The People screen: who, at which agency, how to reach them. */
.person-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px 20px; align-items: start; }
.person-row .person-links { margin: 0; }
.person-agency { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.person-agency a { font-weight: 600; color: var(--ink); }
.people-roles { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 0; }
.people-roles .btn { min-height: 36px; padding: 6px 12px; }
.people-roles .btn[aria-current] { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-edge); }
.people-empty { padding: 12px 8px; max-width: 72ch; }
.people-numbers { margin: 0 0 14px; padding-inline-start: 20px; color: var(--ink-2); }
.people-numbers li { margin: 4px 0; }
.people-numbers .num { font-size: 18px; color: var(--ink); }

@media (max-width: 900px) {
    .person-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .person-row .person-links { grid-column: 1 / -1; }
}
/* On a phone: one column, and every button a full 44 pixels high. */
@media (max-width: 720px) {
    .person { flex-direction: column; align-items: stretch; }
    .person-row { grid-template-columns: minmax(0, 1fr); }
    .person-actions { flex-basis: auto; }
    .person-actions .btn, .person-add > summary, .people-find .btn, .people-roles .btn, .person-form > .btn { min-height: 44px; }
    .people-looking { min-height: 44px; }
}
@media (pointer: coarse) {
    .person-actions .btn, .person-add > summary, .people-find .btn, .people-roles .btn, .person-form > .btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    .people-looking { animation: none; background: var(--accent-soft); }
}

/* --- Mail --- */
/* The Inbox and Sent lists, one reply read inside the tool, its thread, and the mailbox choice in Settings. */
.mail-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 18px; }
.mail-search { display: flex; gap: 8px; align-items: center; flex: 1 1 280px; max-width: 460px; margin: 0; }
.mail-search input[type=search] { margin-top: 0; }
.mail-empty { margin: 8px; }
.mail-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mail-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 18px; align-items: start;
    grid-template-areas: "who meta" "subject meta" "first meta";
    padding: 12px 14px; background: var(--row); border: 1px solid var(--edge-dim); border-top-color: var(--edge-mid); border-radius: 14px;
    transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
    .mail-row:hover { background: var(--row-hover); }
    .mail-subject:hover { text-decoration: underline; }
}
/* Unread waits for the owner: the amber edge and the stronger type repeat the word "Unread". */
.mail-row.is-unread { border-color: var(--sun-edge); }
.mail-row.is-unread .mail-subject, .mail-row.is-unread .mail-from { font-weight: 700; }
.mail-who { grid-area: who; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; min-width: 0; font-size: 14px; color: var(--ink-2); }
.mail-from { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.mail-address { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.mail-subject { grid-area: subject; justify-self: start; color: var(--ink); font-size: 15px; font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
.mail-first { grid-area: first; margin: 0; min-width: 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-meta { grid-area: meta; max-width: 340px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 13px; color: var(--muted); text-align: end; overflow-wrap: anywhere; }
.mail-outcome { color: var(--ink-2); font-weight: 600; }
.mail-outcome[data-tone="ok"] { color: var(--ok-text); }
.mail-outcome[data-tone="bad"] { color: var(--bad-text); }
.mail-outcome[data-tone="wait"] { color: var(--sun-text); }
.mail-answered-link a { display: inline-flex; align-items: center; padding: 1px 10px; min-height: 24px; border-radius: 999px; font-weight: 600; text-decoration: none; color: var(--accent-text); background: var(--accent-soft); border: 1px solid var(--accent-edge); }

/* One reply: a dense pane for long reading. The text keeps its own line breaks and is never a link. */
.mail-title { margin: 0 0 14px; overflow-wrap: anywhere; }
.mail-facts { display: grid; gap: 6px; margin: 0 0 18px; }
.mail-facts > div { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.mail-facts dt { min-width: 84px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mail-facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.mail-text { max-width: 86ch; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--glass-dense); color: var(--ink); font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-answered { margin: 0 0 16px; }
.mail-answered > summary { display: flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; font-weight: 600; color: var(--accent-text); overflow-wrap: anywhere; }
.mail-answered[open] > summary { margin-bottom: 6px; }
.mail-answered .mail-text { color: var(--ink-2); }
.mail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.mail-actions form { margin: 0; }
.mail-sent-answer { margin-bottom: 20px; }
.mail-answer-head { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--ok-text); }
.mail-thread .alert, .mail-thread .heads-up { margin-bottom: 12px; }
.mail-reply { max-width: 760px; }
.mail-reply textarea { min-height: 180px; }

/* Settings: where the mailbox is, and what Google needs. */
.mail-provider { margin: 0 0 18px; }
.mail-provider .btn.is-chosen { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.16); }
.google-help { margin-top: 8px; padding: 10px 14px; border-radius: var(--radius-s); border: 1px solid var(--sun-edge); background: var(--sun-soft); color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.google-help p, .google-help ol { margin: 0 0 6px; }
.google-help ol { padding-inline-start: 20px; }
.google-help > :last-child { margin-bottom: 0; }

/* A phone: each row is one column, and everything that is pressed is at least 44 pixels high. */
@media (max-width: 720px) {
    .mail-row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "who" "subject" "first" "meta"; }
    .mail-meta { max-width: none; flex-direction: row; flex-wrap: wrap; align-items: center; text-align: start; }
    .mail-subject { display: flex; align-items: center; min-height: 44px; }
    .mail-answered-link a { min-height: 44px; padding-inline: 14px; }
    .mail-search { flex-basis: 100%; max-width: none; }
    .mail-actions .btn, .mail-provider .btn { min-height: 44px; }
    .mail-provider .row .btn { flex: 1 1 100%; white-space: normal; }
}

/* --- Unsubscribe page: for someone outside. Calm and plain: no stars, nothing that moves. --- */
.unsubscribe h1 { margin-top: 0; }
.unsubscribe-company { margin: 0 0 6px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); }
/* a long address must wrap on a phone instead of widening the page */
.unsubscribe-address { overflow-wrap: anywhere; }
.unsubscribe form { margin: 18px 0 0; }

/* ------------------------------------------------------------------ 7. Motion */
/* One vocabulary. Each effect has a job, is defined here once, and is used wherever that job comes up.
   - dock:    a pane arrives (first screenful only, staggered within its list)
   - sweep:   light crosses a pane once as it docks
   - orbit:   a light travels the edge of a pane that is working, and stops with the work
   - scan:    a soft line crosses a row that waits for Claude or for a search
   - glint:   light travels a progress bar while it is filling
   - beacon:  the top bar's status pulses while work waits
   - confirm: a short glow says "done" (a draft approved, a field saved)
   - leave / close-up: a row slides out and the list closes the gap (app.js, by transform)
   Everything visible is visible without them: they only add to a page that is already there. */

/* dock: fade, a short rise, a slight scale. Only the first ten of a list; the rest are simply there. */
@keyframes dock { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.reveal, .arrive { animation: dock var(--t-enter) var(--ease) backwards; }
.reveal:nth-child(2) { animation-delay: 30ms; }
.reveal:nth-child(3) { animation-delay: 60ms; }
.reveal:nth-child(4) { animation-delay: 90ms; }
.reveal:nth-child(5) { animation-delay: 120ms; }
.reveal:nth-child(6) { animation-delay: 150ms; }
.reveal:nth-child(7) { animation-delay: 175ms; }
.reveal:nth-child(8) { animation-delay: 200ms; }
.reveal:nth-child(9) { animation-delay: 220ms; }
.reveal:nth-child(10) { animation-delay: 240ms; }
.reveal:nth-child(n+11) { animation: none; }
/* Drawn again behind the owner's back (after background work): nothing docks. */
[data-settled] .reveal, [data-settled] .reveal::after { animation: none; }
/* A list drawn again by a filter is a frequent thing: it only fades, all at once. */
@keyframes fade-in { from { opacity: 0; } }
[data-refreshed] .reveal { animation: fade-in var(--t-fast) var(--ease) backwards; animation-delay: 0s; }
[data-refreshed] .reveal:nth-child(n+25) { animation: none; }

/* sweep: one pass of light over a pane as it docks. */
.panel.reveal::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
    background: linear-gradient(105deg, transparent 42%, var(--light-sweep) 50%, transparent 58%) no-repeat;
    background-size: 280% 100%;
    animation: sweep 900ms var(--ease) 120ms 1 backwards;
}
.panel.reveal:nth-child(n+11)::after, .stat.reveal::after { display: none; }
@keyframes sweep { from { opacity: 1; background-position: 120% 0; } to { opacity: 1; background-position: -60% 0; } }

/* orbit: the edge light of a working pane. The state is in the page, so nothing has to switch it off. */
@property --orbit { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.campaign-head[data-state="drafting"]::before,
.campaign-head[data-state="sending"]::before,
.panel:has(tr.scanning)::before,
.panel[data-working]::before {
    content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
    background: conic-gradient(from var(--orbit), transparent 0 64%, rgba(var(--accent-rgb), 0.55) 82%, var(--accent-core) 88%, rgba(var(--accent-rgb), 0.55) 92%, transparent 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    animation: orbit 6s linear infinite;
}
@keyframes orbit { to { --orbit: 360deg; } }

/* scan: a soft line crosses a draft Claude has not written yet. Only while the row is on screen (app.js marks it). */
.draft.is-queued::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 34%; pointer-events: none; opacity: 0;
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.10) 45%, var(--light-sweep) 50%, rgba(var(--accent-rgb), 0.10) 55%, transparent);
    transform: translateX(-110%);
}
.draft.is-queued.in-view::after { opacity: 1; animation: scan-line 2.6s var(--ease-in-out) infinite; }
@keyframes scan-line { from { transform: translateX(-110%); } 70%, to { transform: translateX(400%); } }
.scanning-note { color: var(--accent-text); }

/* glint: light travels the bar while the campaign is drafting or sending. */
.campaign-head[data-state="drafting"] .progress::after,
.campaign-head[data-state="sending"] .progress::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 22%;
    background: linear-gradient(90deg, transparent, rgba(var(--light-rgb), 0.5), transparent);
    animation: glint 2.2s var(--ease-in-out) infinite;
}
@keyframes glint { from { transform: translateX(-120%); } 60%, to { transform: translateX(560%); } }

/* beacon: the status in the top bar. */
.beat { animation: fade-in var(--t-state) var(--ease); }
.beat.on .beat-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent); animation: beacon 1.8s var(--ease) infinite; }
@keyframes beacon { from { transform: scale(1); opacity: 0.75; } to { transform: scale(3.2); opacity: 0; } }

/* confirm: what the last action did arrives with a short glow; an approved draft glows once in green. */
.notice, .alert { animation: fade-in var(--t-state) var(--ease); }
.draft.is-approved:has(> .notice) { animation: confirm 1100ms var(--ease) 1; }
@keyframes confirm { from { box-shadow: 0 0 0 1px var(--ok), 0 0 34px rgba(var(--ok-rgb), 0.45); } to { box-shadow: 0 0 0 1px transparent, 0 0 0 rgba(var(--ok-rgb), 0); } }
.is-confirmed { animation: confirm 900ms var(--ease) 1; }

/* What the last action did, said for a moment at the bottom of the screen when its own sentence is out of view. */
.toast {
    position: fixed; left: 50%; bottom: 24px; z-index: 30; margin: 0; padding: 10px 18px; max-width: min(92vw, 560px); border-radius: 999px;
    font-weight: 600; color: var(--ok-text); background: var(--glass-3); border: 1px solid var(--ok-edge);
    box-shadow: var(--highlight), var(--shadow-2), 0 0 24px rgba(var(--ok-rgb), 0.18);
    -webkit-backdrop-filter: var(--blur-3); backdrop-filter: var(--blur-3);
    transform: translateX(-50%); transition: opacity var(--t-state) var(--ease);
    animation: toast-in var(--t-state) var(--ease) backwards;
}
.toast.is-bad { color: var(--bad-text); border-color: var(--bad-edge); box-shadow: var(--highlight), var(--shadow-2); }
.toast.is-leaving { opacity: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* A word or number that changed in place (a status, a count): the new one comes into focus. */
.is-swapped { animation: swap var(--t-state) var(--ease) 1; }
@keyframes swap { from { opacity: 0; filter: blur(3px); } }

/* The sky: three depths drift at their own speed; a few stars twinkle. Slow enough to be felt, not watched. */
@keyframes drift { to { transform: translate3d(calc(-1 * var(--tile)), 0, 0); } }
@keyframes twinkle { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.95; } }
.space-stars { animation: drift var(--drift) linear infinite; }
.space-twinkle { animation: twinkle var(--twinkle, 4s) ease-in-out infinite; }
/* A few pixels of parallax as the page scrolls, where the browser can tie an animation to scrolling. */
@supports (animation-timeline: scroll()) {
    .space-depth { animation: parallax linear both; animation-timeline: scroll(root block); }
    @keyframes parallax { to { transform: translate3d(0, calc(-1 * var(--shift)), 0); } }
}
/* A screen that asks for a still sky (a long list being worked), and a tab nobody is looking at. */
html[data-space="still"] .space-stars, html[data-space="still"] .space-twinkle { animation: none; }
html.is-away .space-stars, html.is-away .space-twinkle, html.is-away *::before, html.is-away *::after { animation-play-state: paused; }

/* From page to page: the top bar stays where it is, the lit link slides to its new place, and the
   page under it cross-fades. Where the browser cannot do this, pages simply change. */
@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
.nav a.on { view-transition-name: nav-on; }
::view-transition-old(root) { animation: 110ms var(--ease) both vt-out; }
::view-transition-new(root) { animation: 200ms var(--ease) both fade-in; }
@keyframes vt-out { to { opacity: 0; } }
::view-transition-group(nav-on) { animation-duration: 260ms; animation-timing-function: var(--ease); }
::view-transition-old(topbar), ::view-transition-new(topbar) { animation: none; mix-blend-mode: normal; }
::view-transition-old(topbar) { display: none; }

/* ------------------------------------------------------------------ 8. Responsive and preferences: keep this block last */
/* Feature blocks keep their own media queries with them; this block holds only what applies to every page. */
@media (max-width: 720px) {
    .topbar { position: static; padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
    /* The brand, the status and "Log out" share the first line; the links take a line of their own below. */
    .brand { margin-inline-end: auto; }
    .nav { order: 1; flex-basis: 100%; }
    .nav a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 12px; }
    .topbar .btn { min-height: 44px; }
    .page { padding: 16px 16px 48px; }
    .panel { padding: 16px; }
    h1 { font-size: 26px; }
    .btn { min-height: 44px; }
}
/* The top bar has little room here: the light of the background status stays, its words are its tooltip. */
@media (min-width: 721px) and (max-width: 1000px) {
    .beat-text { display: none; }
    .beat { padding: 8px; }
    .topbar { gap: 12px; padding-inline: 18px; }
}

@media (pointer: coarse), (max-width: 720px) {
    .chip span { min-height: 44px; padding: 10px 14px; }
    .tabs a, .state-tabs a { min-height: 44px; }
    /* The small link beside a number stays small to the eye; its target reaches 44 pixels. */
    .wa-chat { min-height: 28px; padding: 3px 12px; }
    .wa-chat::after { content: ""; position: absolute; inset: -9px -4px; }
    .phone, td:has(> .wa-chat) { line-height: 2.4; }
}
@media (pointer: coarse) {
    .topbar nav a { display: inline-flex; align-items: center; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    @view-transition { navigation: none; }
    .space-stars, .space-twinkle, .space-depth { animation: none !important; }
    .panel.reveal::after, .draft.is-queued::after, .progress::after, .beat.on .beat-dot::after { display: none; }
    tr.scanning td { animation: none; background: var(--accent-soft); }
    /* a working pane keeps a still, lit edge instead of a moving one */
    .campaign-head[data-state="drafting"]::before, .campaign-head[data-state="sending"]::before, .panel:has(tr.scanning)::before, .panel[data-working]::before { animation: none; background: var(--accent-edge); }
    .draft.is-queued { border-color: var(--accent-edge); }
}
