:root {
    --bg: #f6f7fb; --surface: #ffffff; --text: #1d1f2b; --muted: #6b7083; --border: #e3e5ee;
    --accent: #4f46e5; --accent-text: #ffffff; --accent-soft: #eef0ff; --danger: #c2283c;
    --ok: #127a4b; --ok-soft: #e3f6ec; --warn: #9a5b00; --warn-soft: #fdf2dc; --radius: 10px;
    color-scheme: light;
    /*
     * Layout scale, shared by every theme (themes change colour and shape, not these):
     * - spacing steps 4, 8, 12, 16, 24, 32, 48;
     * - page gutters grow with the window, 16px on a phone to 40px on a large screen;
     * - page widths: data pages up to 1560px (1840px on very large screens), step-by-step pages (campaign overview, segment rules) 1160px,
     *   form pages 880px, reading pages 760px (~70 characters); the full-screen builders up to 1920px;
     * - headings scale smoothly with clamp() instead of jumping at a breakpoint.
     */
    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
    --gutter: clamp(16px, 3vw, 40px);
    --page-max: clamp(1560px, 72vw, 1840px); --page-mid: 1160px; --page-form: 880px; --page-read: 760px;
    --h1: clamp(1.45rem, 1.1rem + 1.1vw, 1.95rem);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12131a; --surface: #1b1d27; --text: #e8e9f1; --muted: #9a9eb2; --border: #2c2f3d;
        --accent: #8b85ff; --accent-text: #0f0f1a; --accent-soft: #26264a; --danger: #ff7a8a;
        --ok: #5bd69a; --ok-soft: #173326; --warn: #f2c063; --warn-soft: #3a2e14;
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: var(--h1); line-height: 1.2; margin: .1rem 0 .3rem; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
code { background: var(--accent-soft); padding: .05rem .3rem; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .right { text-align: right; } .grow { flex: 1; }
.danger { color: var(--danger) !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-flex; color: var(--accent); }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { color: var(--text); padding: 8px 10px; border-radius: 8px; }
.sidebar nav a.active, .sidebar nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.logout { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
.logout a.active { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.main { padding: clamp(20px, 2.4vw, 32px) var(--gutter) 64px; max-width: calc(var(--page-max) + 2 * var(--gutter)); width: 100%; margin-inline: auto; min-width: 0; }
/* The content column is a container, so blocks can add columns when the page (not the window) is wide enough. */
.main { container: main / inline-size; }
/* Dashboard: one column, then on a wide page the numbers on top, recent campaigns beside the checklist and channels. */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.dash-grid > * { margin-bottom: 0; }
@container main (min-width: 1100px) {
    .dash-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); grid-template-areas: "stats stats" "recent onboarding" "recent channels"; grid-template-rows: auto auto 1fr; align-items: start; }
    .dash-grid:not(:has(> .onboarding)) { grid-template-areas: "stats stats" "recent channels"; grid-template-rows: auto 1fr; }
    .dash-grid > .stats { grid-area: stats; }
    .dash-grid > .onboarding { grid-area: onboarding; }
    .dash-grid > .dash-channels { grid-area: channels; }
    .dash-grid > .dash-recent { grid-area: recent; }
    .dash-grid > .dash-channels > .report-numbers:has(> div) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Page types (layouts/app, @section('page')): forms and reading pages get a calmer, narrower column. */
.main[data-page="mid"] { max-width: calc(var(--page-mid) + 2 * var(--gutter)); }
.main[data-page="form"] { max-width: calc(var(--page-form) + 2 * var(--gutter)); }
.main[data-page="read"] { max-width: calc(var(--page-read) + 2 * var(--gutter)); }
.main[data-page="form"] .narrow { max-width: none; }
/* Long text never runs the full width of a wide card: about 75 characters a line. */
.main p:not(.row, .row-between, .actions, .flash) { max-width: 75ch; }
/* Menu groups (Campaigns, Audience, Content, Analytics), Help and Support, and the profile menu with the account items. */
.sidebar .nav-main { display: grid; gap: 10px; min-height: 0; }
.nav-group { display: grid; gap: 2px; }
.nav-group-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px; }
.sidebar .nav-footer { margin-top: auto; }
.sidebar-foot { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.profile-menu { position: relative; min-width: 0; }
.profile-menu summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 40px; min-width: 0;
    padding: 6px 8px; border-radius: 10px; color: inherit; font-weight: 600; font-size: .88rem;
}
.profile-menu summary::-webkit-details-marker { display: none; }
.profile-menu summary:hover, .profile-menu[open] summary, .profile-menu[data-active] summary { background: var(--accent-soft); color: var(--accent); }
.profile-menu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.profile-initial {
    display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
    background: var(--text); color: var(--bg); font-weight: 800; font-size: .8rem;
}
.profile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.profile-panel {
    position: absolute; z-index: 40; bottom: calc(100% + 6px); left: 0; width: min(240px, calc(100vw - 32px));
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 10px 30px rgb(0 0 0 / .18); padding: 8px; display: grid; gap: 4px;
}
.sidebar .profile-panel nav { display: grid; gap: 2px; }
.sidebar .profile-panel nav a { color: var(--text); display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; min-height: 40px; }
.sidebar .profile-panel nav a.active, .sidebar .profile-panel nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.profile-panel .nav-icon { display: block; }
.profile-panel .logout { margin: 0; padding: 4px 10px 2px; border-top: 1px solid var(--border); }
.profile-panel .logout .link { min-height: 36px; color: var(--text); }
.sidebar .profile-panel nav a.phone-only { display: none; }

@media (max-width: 820px) {
    .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; } /* a short page doesn't stretch the menu bar */
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px var(--gutter); border-right: 0; border-bottom: 1px solid var(--border); }
    /* Phones: the menu is one row that scrolls sideways, so every page starts near the top. */
    .sidebar nav { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; flex: 1 1 100%; order: 3; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar nav a { flex: 0 0 auto; white-space: nowrap; }
    .sidebar .nav-main { display: flex; }
    .sidebar .profile-panel nav { display: grid; flex: none; order: 0; overflow: visible; }
    .nav-group { display: contents; }
    .nav-group-label { display: none; }
    .sidebar .nav-footer { display: none; } /* Help and Support move into the profile menu on phones */
    .sidebar .profile-panel nav a.phone-only { display: flex; }
    .sidebar-foot { margin-left: auto; order: 2; flex-direction: row; flex-wrap: nowrap; flex: none; }
    .profile-panel { bottom: auto; top: calc(100% + 6px); left: auto; right: 0; }
    .profile-name { max-width: 30vw; }
    .logout { margin: 0 0 0 auto; gap: 8px; }
    .main { padding: 20px var(--gutter) 48px; }
}

/* Building blocks */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3) var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-head > h1 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.page-head > div:first-child:has(> h1) { min-width: 0; flex: 0 1 auto; }
.page-head > .help-link { flex: none; }
.page-head > div:first-child:has(> h1) + .help-link:last-child { margin-right: auto; align-self: flex-end; }
/* The same when the help button sits alone in an actions row (shared page heads such as channels._nav). */
.page-head > div:first-child:has(> h1) + .row:last-child:has(> .help-link:only-child) { margin-right: auto; align-self: flex-end; }
.page-head > div:first-child > h1 { margin-bottom: 2px; }
/* A help button that is the only action sits with the title instead of floating at the far edge. */
.page-head > h1 + .help-link:last-child { margin-right: auto; }
.page-head > .row, .page-head > .head-actions { gap: var(--space-2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; align-content: start; } /* rows keep their size when a grid parent stretches the stack (equal-height cards) */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; min-width: 0; }
.narrow { max-width: 720px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.empty { color: var(--muted); padding: 18px 0; margin: 0; }
.flash { background: var(--ok-soft); color: var(--ok); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.flash-error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* Forms */
label { display: grid; gap: 5px; font-weight: 600; font-size: .9rem; }
label small { font-weight: 400; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
    width: 100%; font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-weight: 400;
}
/* A select next to buttons in a header or row sizes to its options; full width would push the others onto new lines. */
.page-head select, .row > select { width: auto; max-width: 100%; }
/* In a table a full-width select shrinks with its column and cuts off the chosen option ("Autho"). */
.cell-select select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
textarea { resize: vertical; }
/* File pickers: the native "Choose file" button takes the .btn look (theme files round it like their buttons). */
input:not([type=checkbox]):not([type=radio])[type=file] { padding: 5px 6px; cursor: pointer; }
input[type=file]::file-selector-button {
    font: inherit; font-weight: 600; padding: 6px 14px; margin-right: 12px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.hp { position: absolute; left: -5000px; }

/* Data */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
/* Four tiles never leave one alone on a row: 4, then 2 by 2. */
.stats:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* The same for the smaller number tiles (.report-numbers) and for six or eight tiles: even rows, no orphan. */
.report-numbers:has(> :nth-child(4):last-child), .stats:has(> :nth-child(8):last-child), .report-numbers:has(> :nth-child(8):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats:has(> :nth-child(6):last-child), .report-numbers:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats:has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@container main (max-width: 900px) { .stats:has(> :nth-child(5):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Seven tiles (an audience's contact counts): four a row and the last one twice as wide, so both rows end flush. */
.stats:has(> :nth-child(7):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats:has(> :nth-child(7):last-child) > :last-child { grid-column: span 2; }
@container main (max-width: 900px) { .stats:has(> :nth-child(7):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container main (min-width: 1200px) { .stats:has(> :nth-child(6):last-child), .report-numbers:has(> :nth-child(6):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 640px) {
    .report-numbers:has(> :nth-child(4):last-child), .stats:has(> :nth-child(8):last-child), .report-numbers:has(> :nth-child(8):last-child),
    .stats:has(> :nth-child(6):last-child), .report-numbers:has(> :nth-child(6):last-child), .stats:has(> :nth-child(5):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stats:has(> :nth-child(5):last-child) > :last-child { grid-column: 1 / -1; }
    /* Phones: tiles two by two; an odd last tile takes the whole row. */
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 2px; color: var(--text); }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.7rem; }
.stat small { color: var(--muted); }
/* The headline metric of a row (.stat-key, set in the view). Themes may fill it more strongly. */
.stats .stat-key { border-color: var(--accent); background: var(--accent-soft); }
/* Page header actions (help, a filter, an export) stay on one row next to the title. */
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; margin: 0; }
.head-actions select { width: auto; max-width: 220px; min-width: 0; }
@media (max-width: 640px) { .head-actions { flex-wrap: wrap; } .head-actions select { max-width: 100%; flex: 1 1 160px; } }
/* Phones: the title gets its own line, the actions follow on one row with the primary action first. */
@media (max-width: 640px) {
    .page-head { align-items: flex-start; margin-bottom: var(--space-4); }
    .page-head > .row, .page-head > .head-actions { flex: 1 1 100%; flex-wrap: wrap; min-width: 0; }
    .page-head > .row > .btn-primary, .page-head > .head-actions > .btn-primary { order: -1; }
    .page-head > .row > .help-link, .page-head > .head-actions > .help-link { order: 9; }
    /* Without a primary action the help button leads the row, so it never ends up alone on a line. */
    .page-head > .row:not(:has(> .btn-primary)) > .help-link, .page-head > .head-actions:not(:has(> .btn-primary)) > .help-link { order: -1; }
    /* With two or more other actions the primary one takes the whole first row, the rest share the next. */
    .page-head > .row:has(> :nth-child(3)) > .btn-primary { flex: 1 1 100%; }
    /* A row that only holds the help button stays beside the title. */
    .page-head > .row:has(> .help-link:only-child) { flex: none; }
    /* Text-only actions get an outline so a wrapped row still reads as a set of buttons. */
    .page-head .btn-ghost { border-color: var(--border); }
}
/* Required fields and inline validation messages (js/forms.js). */
.req { color: var(--danger); font-weight: 700; margin: 0 2px; }
.field-error { color: var(--danger); font-size: .85rem; margin: 4px 0 0; }
[aria-invalid="true"]:is(input, select, textarea) { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.empty-state { text-align: left; }
/* Empty states: what goes here, how to start, and a sketch of the finished screen beside it (partials.empty-art). */
.empty-state.has-art { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-5) var(--space-6); align-items: center; padding: clamp(20px, 3vw, 40px); }
/* Inside a list card the card already pads it. */
.card > .empty-state.has-art { padding: clamp(4px, 2vw, 24px) clamp(0px, 1.5vw, 20px); }
.empty-state-body { display: grid; gap: var(--space-3); justify-items: start; min-width: 0; }
.empty-state-body > * { margin: 0; }
.empty-state h2 { font-size: 1.2rem; margin: 0; }
.empty-state-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: var(--space-2); }
.empty-state-steps li { counter-increment: step; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--space-2); align-items: baseline; }
.empty-state-steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); font-size: .75rem; font-weight: 700; color: var(--muted); }
.empty-state-actions { margin-top: var(--space-1); }
.empty-state-art { width: clamp(160px, 22vw, 260px); }
.empty-art { display: block; width: 100%; height: auto; }
.ea-sheet { fill: var(--bg); stroke: var(--border); }
.ea-line { fill: color-mix(in srgb, var(--muted) 22%, transparent); }
.ea-line-strong { fill: color-mix(in srgb, var(--text) 55%, transparent); }
.ea-soft { fill: var(--accent-soft); }
.ea-accent { fill: var(--accent); }
.ea-on-accent { fill: var(--accent-text); opacity: .8; }
.ea-ok { fill: var(--ok-soft); }
.ea-warn { fill: var(--warn-soft); }
.ea-field { fill: var(--surface); stroke: var(--border); }
.ea-link { stroke: var(--border); stroke-width: 2; fill: none; }
@media (max-width: 640px) {
    .empty-state.has-art { grid-template-columns: minmax(0, 1fr); }
    .empty-state-art { display: none; } /* the text and the first step come first on a phone */
}
/* Campaign overview (campaigns/overview): one row per part with a status, details folded open to edit. */
.campaign-launch { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.campaign-launch h2 { margin: 0 0 2px; }
.sending-setup h2 { margin: 0; font-size: 1.05rem; }
.sending-tip { border-color: var(--accent-soft); background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.sending-tip .row { flex-wrap: wrap; }
.campaign-overview { display: grid; gap: 10px; }
.check-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 12px; min-width: 0; }
.check-section > summary, .check-row { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; min-width: 0; }
.check-row { cursor: default; }
.check-section > summary::-webkit-details-marker { display: none; }
.check-section > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.check-section[open] > summary .check-edit { visibility: hidden; }
.check-icon { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-weight: 800; font-size: .85rem; background: var(--ok-soft); color: var(--ok); }
.check-section.is-warning .check-icon { background: var(--warn-soft); color: var(--warn); }
.check-section.is-error .check-icon { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.check-section.is-settings .check-icon { background: var(--accent-soft); color: var(--accent); }
.check-section.is-todo .check-icon { background: var(--accent-soft); color: var(--accent); }
.check-section.is-error { border-color: var(--danger); }
.check-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.check-summary { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-edit { flex: none; }
.check-note { margin: 0; font-size: .88rem; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); overflow-wrap: anywhere; }
.check-note.is-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.check-note.is-ok { background: var(--ok-soft); color: var(--ok); }
.content-thumb { display: block; height: 260px; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: #ffffff; position: relative; }
.content-thumb iframe { width: 200%; height: 520px; border: 0; transform: scale(.5); transform-origin: 0 0; pointer-events: none; }
.confirm-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 22px; }
.confirm-dialog::backdrop { background: rgb(0 0 0 / .45); }
.confirm-dialog h2 { margin-top: 0; }
.confirm-summary dd { overflow-wrap: anywhere; }
.confirm-checks { display: grid; gap: 6px; }
.confirm-checks h3 { margin: 4px 0 0; font-size: .95rem; }
/* Without JavaScript the Schedule and Send links jump to their dialog, shown as part of the page. */
.confirm-dialog:target { display: block; position: static; margin: 18px 0; }
@media (max-width: 640px) { .check-summary { white-space: normal; } .content-thumb { height: 200px; } }

/* Focus mode (the full-screen email builder): no menu, the whole width for the work. */
.focus-mode .shell, html[data-theme] .focus-mode .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
.focus-mode .sidebar { display: none; }
html[data-theme] .focus-mode .main, .focus-mode .main { max-width: 1960px; }
.empty-state h2 { margin-top: 0; }
.empty-state-actions { flex-wrap: wrap; gap: 8px; }
.bar { height: 6px; background: var(--accent-soft); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.table-wrap { overflow-x: auto; position: relative; } /* keeps .sr-only cells inside the scroller instead of widening the page */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge-sent, .badge-subscribed { background: var(--ok-soft); color: var(--ok); }
.badge-scheduled, .badge-pending, .badge-sending, .badge-waiting { background: var(--warn-soft); color: var(--warn); }
.badge-unsubscribed, .badge-cleaned { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.chip { font: inherit; font-size: .78rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 99px; padding: 2px 9px; cursor: pointer; margin: 0 4px 4px 0; display: inline-block; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.static { cursor: default; }
.chips { display: flex; flex-wrap: wrap; align-items: center; }
.sms-count { font-variant-numeric: tabular-nums; } /* the live count (channels.js) doesn't jitter as it changes */
.logo-mark { display: block; flex: none; }
/* A small panel that opens from a button in a page header (the merge tags in the email builder). */
.head-popover { position: relative; }
.head-popover > summary { list-style: none; }
.head-popover > summary::-webkit-details-marker { display: none; }
.head-popover-panel {
    position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; width: min(440px, calc(100vw - 32px));
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 12px 32px rgb(0 0 0 / .16); padding: 12px 14px; display: grid; gap: 8px;
}
.head-popover-panel p { margin: 0; }
/* "More" in a page head (campaign report): secondary actions sit inline when they fit on one row and
   fold into a menu when they don't (rail.js measures and sets .is-inline; without JavaScript it stays a menu).
   Escape, a tap outside or picking an item closes the menu. */
.more-menu { position: relative; }
.more-menu > summary { list-style: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu > summary svg { transition: transform .15s; }
.more-menu[open] > summary svg { transform: rotate(180deg); }
.more-menu > summary:focus-visible, .more-menu-panel .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.more-menu-panel form { margin: 0; }
.more-menu:not(.is-inline) { order: 2; }
.more-menu:not(.is-inline)[open] > summary { border-color: var(--accent); color: var(--accent); }
.more-menu:not(.is-inline) > .more-menu-panel {
    position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; min-width: 220px; max-width: calc(100vw - 32px);
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 12px 32px rgb(0 0 0 / .16); padding: 6px; display: grid; gap: 2px;
}
.more-menu:not(.is-inline) .more-menu-panel .btn { justify-content: flex-start; width: 100%; min-height: 44px; border-color: transparent !important; font-weight: 500; }
.more-menu:not(.is-inline) .more-menu-panel .btn:hover { background: var(--accent-soft); color: var(--accent); }
.more-menu.is-inline { display: flex; }
.more-menu.is-inline > summary { display: none; }
.more-menu.is-inline > .more-menu-panel { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.merge-tags-more { margin: 2px 0 6px; }
.merge-tags-more summary { cursor: pointer; color: var(--muted); margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
/* The pages inside one Settings section (settings/_tabs), under the section tabs. */
.subtabs { display: flex; gap: 6px; margin: -6px 0 18px; overflow-x: auto; }
.subtabs a { padding: 4px 11px; font-size: .85rem; color: var(--muted); border: 1px solid var(--border); border-radius: 99px; white-space: nowrap; }
.subtabs a:hover { text-decoration: none; color: var(--text); }
.subtabs a.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
/* Scroll hints: rail.js marks a menu, tab row or table wrapper that overflows; the edge with more to see fades out. */
[data-fade] { --fade-start: 0px; --fade-end: 0px; }
[data-fade~="start"] { --fade-start: 32px; }
[data-fade~="end"] { --fade-end: 32px; }
[data-fade][data-fade-axis="x"] { -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); }
[data-fade][data-fade-axis="y"] { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.filters, .bulk-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { max-width: 260px; }
.filters select, .bulk-bar select, .bulk-bar input { width: auto; max-width: 200px; }
.pager { display: flex; justify-content: space-between; padding-top: 14px; }
.link-row { padding: 7px 0; border-bottom: 1px solid var(--border); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0 0 16px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.histogram { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.histogram .col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.histogram i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.condition { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; gap: 8px; }
@media (max-width: 640px) { .condition { grid-template-columns: 1fr 1fr; } }
.condition[hidden] { display: none; }
.condition > * { min-width: 0; }
.condition-values { display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.condition-values > * { flex: 1 1 120px; min-width: 0; }
.condition-values > [hidden], .condition-group [hidden] { display: none; }
@media (max-width: 640px) { .condition .condition-values { grid-column: 1 / -1; } .condition [data-remove] { grid-column: 1 / -1; justify-self: end; } }
.condition-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 0; display: grid; gap: 10px; background: var(--bg); min-width: 0; }
.condition-group .condition-group { background: var(--surface); }
.condition-group-match { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.condition-group-match select { width: auto; max-width: 100%; }
.preset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.preset-list form { display: grid; gap: 6px; align-content: space-between; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-width: 0; }

/* Campaign editor */
.editor .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 1000px) { .editor .split { grid-template-columns: 1fr; } }
#html { min-height: 560px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.preview-wrap { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; gap: 8px; justify-items: center; }
#preview { width: 100%; max-width: 100%; height: 560px; border: 0; background: #fff; border-radius: 6px; transition: max-width .2s; }
.device-toggle { display: flex; gap: 4px; }
.device-toggle button { font: inherit; font-size: .8rem; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.device-toggle button.active { color: var(--accent); border-color: var(--accent); }
.recipients { align-self: end; padding: 10px 12px; background: var(--accent-soft); border-radius: 8px; }
.actions { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); display: flex; justify-content: flex-end; }

/* Public pages */
body.public { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.public-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; width: 100%; max-width: 460px; }
.public-card h1 { display: flex; align-items: center; gap: 10px; }
.error-card .brand { margin: 0 0 18px; }
.error-card .error-code { margin: 0; font-size: 3rem; font-weight: 700; line-height: 1; color: var(--accent); letter-spacing: .02em; }
.error-card .error-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* Visual email builder */
.builder { display: grid; grid-template-columns: 200px minmax(0, 1fr) 280px; gap: 14px; margin-top: 12px; }
/* Laptops keep all three panels (narrower side panels); only below 900px does the design panel move under the email. */
@media (max-width: 1279px) { .builder { grid-template-columns: 168px minmax(0, 1fr) 248px; gap: 12px; } }
@media (max-width: 900px) { .builder { grid-template-columns: 168px minmax(0, 1fr); } .builder-inspector { grid-column: 1 / -1; } }
@media (max-width: 700px) { .builder { grid-template-columns: minmax(0, 1fr); } }
.builder h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0; }
.builder-palette { display: grid; gap: 6px; align-content: start; }
.palette-item { font: inherit; text-align: left; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: grab; }
.palette-item:hover { border-color: var(--accent); color: var(--accent); }
.outline { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; min-height: 60px; }
.outline-item { display: grid; grid-template-columns: auto 1fr; column-gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: .82rem; background: var(--surface); }
.outline-item .muted { grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-item .grip { grid-row: span 2; color: var(--muted); cursor: grab; }
.outline-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.outline-item.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.builder-canvas { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: grid; gap: 8px; justify-items: center; align-content: start; }
#builder-preview { width: 100%; height: 680px; border: 0; background: #fff; border-radius: 6px; transition: max-width .2s; }
.builder-inspector { display: grid; gap: 12px; align-content: start; }
.builder-inspector input[type=color] { height: 36px; padding: 2px; }
.builder-inspector output { font-weight: 400; color: var(--muted); }
.block-actions .btn { padding: 5px 9px; }
.rich-field { display: grid; gap: 4px; }
.rich-field .label { font-weight: 600; font-size: .9rem; }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 2px; }
.rich-toolbar button { font: inherit; font-size: .78rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 5px; padding: 2px 8px; cursor: pointer; }
.rich { min-height: 110px; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; background: var(--surface); }
.rich:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.rich p { margin: 0 0 8px; }
.thumb { max-width: 100%; max-height: 140px; border-radius: 6px; border: 1px solid var(--border); }
.stack-sm { display: grid; gap: 8px; align-content: start; }
.media-dialog { width: min(720px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; }
.media-dialog::backdrop { background: rgb(0 0 0 / .45); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 50vh; overflow: auto; }
.media-item { padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg); cursor: pointer; aspect-ratio: 1; }
.media-item:hover { border-color: var(--accent); }
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn.small { padding: 5px 10px; font-size: .82rem; }

/* Review page */
.review { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .review { grid-template-columns: minmax(0, 1fr); } }
.review .stack > .card { margin-bottom: 0; }
label.inline { display: flex; align-items: center; gap: 8px; }
label.inline select { width: auto; max-width: 220px; }
.inbox-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; }
.review-frame { display: grid; justify-items: center; background: var(--bg); border-radius: 8px; padding: 10px; }
#review-html { width: 100%; height: 720px; border: 0; background: #fff; border-radius: 6px; }
#review-text { width: 100%; white-space: pre-wrap; margin: 0; padding: 16px; background: var(--surface); border-radius: 6px; max-height: 720px; overflow: auto; font-size: 13px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checklist li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.check-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.check-ok .check-icon { background: var(--ok-soft); color: var(--ok); }
.check-warning .check-icon { background: var(--warn-soft); color: var(--warn); }
.check-error .check-icon { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.checklist .muted { overflow-wrap: anywhere; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.template-card iframe { width: 100%; height: 300px; border: 1px solid var(--border); border-radius: 6px; background: #fff; pointer-events: none; margin-bottom: 10px; }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
.flash-warn a { color: inherit; text-decoration: underline; }
.smtp-fields[hidden], .api-fields[hidden], .login-fields[hidden], .builtin-fields[hidden] { display: none; }

/* Automations */
.presets { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.presets legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.preset { display: flex; flex-direction: row; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-weight: 400; cursor: pointer; }
.preset:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.preset span { display: grid; }
.trigger-tag[hidden] { display: none; }
.journey { display: grid; justify-items: center; gap: 0; }
.journey-node { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 14px 16px; display: grid; gap: 8px; }
.node-kind { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.trigger-node { border-left-color: var(--ok); }
.node-wait { border-left-color: var(--warn); }
/* Message steps: email in the accent colour, a text message in the ok colour with a dashed edge (goal steps are ok but filled). */
.node-email { border-left-color: var(--accent); }
.node-sms { border-left-color: var(--ok); border-left-style: dashed; }
.node-tag, .node-untag { border-left-color: var(--muted); }
.end-node { border-left-color: var(--border); text-align: center; }
.node-tools { gap: 6px; }
.node-tools form { display: inline; }
.node-tools button:disabled { opacity: .3; cursor: default; }
.journey-add { display: grid; justify-items: center; position: relative; padding: 6px 0; }
.journey-add::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 2px solid var(--border); }
.journey-add summary { list-style: none; position: relative; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); display: grid; place-items: center; cursor: pointer; color: var(--muted); font-weight: 700; }
.journey-add summary::-webkit-details-marker { display: none; }
.journey-add details[open] summary { border-color: var(--accent); color: var(--accent); }
.add-menu { position: relative; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 8px; margin-top: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.w-num { width: 90px !important; }
.w-tag { width: 200px !important; }
.journey-node .row { flex-wrap: nowrap; }
.journey-node .row input, .journey-node .row select { width: auto; }
.journey-add details { display: grid; justify-items: center; }
.ab-fields[hidden], .ab-variable[hidden], .ab-variant[hidden] { display: none; }
.badge-testing { background: var(--warn-soft); color: var(--warn); }
.trigger-date[hidden] { display: none; }
.field-row { border-bottom: 1px solid var(--border); padding: 10px 0; }
.field-row summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.field-row form { margin-top: 10px; }
#field-options[hidden] { display: none; }
.consent { align-items: flex-start; }
.breakdown { display: grid; grid-template-columns: 140px 1fr 48px; gap: 10px; align-items: center; padding: 4px 0; }
.breakdown .bar { margin: 0; }
.breakdown strong { text-align: right; }
.stars { color: var(--warn); letter-spacing: 1px; white-space: nowrap; }
/* Off stars are outlines in the muted text colour: at least 3:1 against the card in every theme (--border was ~1.3:1). */
.stars .off { color: var(--muted); }
/* A few campaigns spread over the width instead of bunching up on the left of a wide card. */
.compare-chart { display: flex; align-items: flex-end; justify-content: space-evenly; gap: 6px; height: 160px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.compare-col { flex: 1; height: 100%; display: flex; align-items: flex-end; gap: 2px; max-width: 64px; }
.compare-col i { flex: 1; display: block; border-radius: 3px 3px 0 0; min-height: 2px; }
.compare-col .open, .legend.open { background: var(--accent); }
.compare-col .click, .legend.click { background: var(--ok); }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
td.good { color: var(--ok); font-weight: 600; }
td.bad { color: var(--danger); }
.histogram.growth { height: 90px; }
.inline-form { display: inline; margin-left: 8px; }
.url-field { display: flex; align-items: center; gap: 4px; font-weight: 400; min-width: 0; }
.url-field .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.url-field .muted.url-suffix { max-width: none; flex-shrink: 0; }
.url-field input { min-width: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; }
.api-doc { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: var(--bg); padding: 12px; border-radius: 8px; margin: 8px 0 0; }
body.public.embed { min-height: 0; padding: 0; display: block; }
body.public.embed .public-card { border: 0; border-radius: 0; max-width: none; }
.card p, .card code { overflow-wrap: anywhere; }

/* Help center */
.help-link { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 700; font-size: .95rem; line-height: 1; }
.help-link:hover, .help-link:focus-visible { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.help-link.static { width: 22px; height: 22px; font-size: .8rem; vertical-align: middle; }
.help-list { list-style: none; padding: 0; margin: 0; display: grid; }
.help-list li { display: grid; gap: 2px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.help-list li:last-child { border-bottom: 0; }
.prose { line-height: 1.65; overflow-wrap: break-word; }
.prose > * { max-width: 78ch; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 1.75rem; margin: 0 0 .9rem; }
.prose h2 { font-size: 1.3rem; margin: 2rem 0 .7rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.prose h3 { font-size: 1.06rem; margin: 1.6rem 0 .5rem; }
.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: .3rem 0; }
.prose li > p { margin: 0 0 .4rem; }
.prose li::marker { color: var(--muted); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose code { overflow-wrap: anywhere; }
.prose pre { max-width: 100%; overflow-x: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }
.prose pre code { background: none; padding: 0; font-size: inherit; white-space: pre; overflow-wrap: normal; }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.prose th { text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--text); background: var(--bg); }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; }
.prose tr:last-child td { border-bottom: 1px solid var(--border); }
.prose blockquote { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; padding: 10px 14px; }
.prose blockquote > :last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 1.6rem 0; }
.prose img { max-width: 100%; height: auto; }

/* Interest groups, preference center and unsubscribe question */
fieldset.interests, fieldset.choices { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 6px; min-width: 0; }
fieldset.interests legend, fieldset.choices legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
fieldset.choices label.check { align-items: flex-start; }
fieldset.choices label.check input { margin-top: 3px; }
.public-card .divider { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.public-card .links-row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.reason-list { display: grid; gap: 8px; }
.reason-list .breakdown { grid-template-columns: minmax(0, 1.5fr) minmax(40px, 1fr) 40px; font-size: .9rem; }

/* Designed signup forms (hosted form, pop-up and the form builder preview). Own colours only
   apply when set (has-* classes); otherwise the form follows the theme in light and dark mode. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.signup-form { margin: -32px; padding: 32px; border-radius: inherit; min-width: 0; }
.signup-form.has-bg { background: var(--form-bg); }
.signup-form.has-text, .signup-form.has-text h1, .signup-form.has-text label { color: var(--form-text); }
.signup-form.has-text .muted { color: color-mix(in srgb, var(--form-text) 72%, transparent); }
html .signup-form.has-button .signup-button { background: var(--form-button); border-color: var(--form-button); color: #ffffff; box-shadow: none; }
html .signup-form.has-button-text .signup-button { color: var(--form-button-text); }
/* Brand kit defaults: its accent colours the button and its font sets the text, unless the form picks its own colour. */
html .signup-form.has-brand-button:not(.has-button) .signup-button { background: var(--brand-button); border-color: var(--brand-button); color: #ffffff; box-shadow: none; }
html .signup-form.has-brand-button.has-button-text:not(.has-button) .signup-button { color: var(--form-button-text); }
.signup-form.has-brand-font, .signup-form.has-brand-font :is(h1, input, select, textarea, button) { font-family: var(--brand-font); }
.signup-logo { display: block; max-width: min(180px, 100%); max-height: 72px; object-fit: contain; margin-bottom: 14px; }
.signup-form fieldset, .bare-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.signup-form .signup-step[hidden], .signup-form [data-preview][hidden], .signup-actions [hidden] { display: none; }
.signup-actions .signup-button { flex: 1 1 auto; }
.form-builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 18px; align-items: start; }
.form-builder .preview-pane { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.form-qr { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.form-qr .qr-code { width: 132px; height: 132px; flex: none; border-radius: 8px; border: 1px solid var(--border); }
.form-qr .stack-sm { flex: 1 1 180px; min-width: 0; justify-items: start; }
.form-builder .public-card { padding: 32px; max-width: none; }
.color-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.color-field { display: flex; gap: 6px; align-items: center; }
.color-field input[type=color] { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); flex: none; }
.system-email { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding: 12px 0; }
.system-email:last-child { border-bottom: 0; }
.system-email > div { min-width: 0; flex: 1 1 260px; }
@media (max-width: 900px) {
    .form-builder { grid-template-columns: minmax(0, 1fr); }
    .form-builder .preview-pane { position: static; }
}
@media (max-width: 480px) {
    .public-card { padding: 22px; }
    .signup-form, .form-builder .public-card .signup-form { margin: -22px; padding: 22px; }
    .form-builder .public-card { padding: 22px; }
}
/* Email content: brand kit preview, builder sections, visibility and list editors */
#brand-kit input[type=color] { height: 40px; padding: 3px; cursor: pointer; }
.brand-preview { padding: 16px; border-radius: 8px; border: 1px solid var(--border); }
.brand-preview > div { padding: 18px; border-radius: 6px; display: grid; gap: 8px; justify-items: start; overflow-wrap: anywhere; }
.brand-preview img { max-width: 160px; max-height: 60px; height: auto; }
.brand-preview p { margin: 0; }
.brand-button { color: #fff; padding: 8px 14px; border-radius: 6px; font-weight: 600; }
.builder-palette .palette-section { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; align-items: center; }
.builder-palette .palette-section .palette-item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inspector-group { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: grid; gap: 10px; min-width: 0; margin: 0; }
.inspector-group legend { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 4px; }
.list-editor { display: grid; gap: 8px; }
.list-editor-item { border: 1px dashed var(--border); border-radius: 8px; padding: 8px; display: grid; gap: 8px; min-width: 0; }
.poll-results .breakdown { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.poll-results .breakdown span { overflow-wrap: anywhere; }
.section-dialog .check { display: flex; gap: 8px; align-items: center; }
@media (max-width: 700px) {
    /* Phones: the blocks fit three to a row, so the canvas starts sooner; a tap adds a block (no dragging needed). */
    .builder-palette { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
    .builder-palette h3, .builder-palette .outline, .builder-palette .palette-sections { grid-column: 1 / -1; }
    .builder-palette .palette-item { min-height: 40px; padding: 6px 8px; font-size: .82rem; line-height: 1.2; overflow-wrap: anywhere; }
    .outline-item { min-height: 40px; }
    #builder-preview { height: min(680px, 70vh); }
}
/* Report insights: recipient lists, benchmarks, click map */
.insight-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.insight-list { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); min-width: 0; }
.insight-list strong { color: var(--text); font-size: 1.2rem; }
.insight-list:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.benchmark { margin-bottom: 12px; }
.benchmark h3 { margin: 0 0 4px; font-size: .95rem; }
.bar-muted i { background: var(--muted); }
.clickmap-frame { width: 100%; height: 720px; border: 0; background: #fff; border-radius: 6px; }
.clickmap-number { display: inline-block; min-width: 2em; padding: 1px 6px; border-radius: 999px; background: #ffd43b; color: #1a1a1a; font-weight: 700; text-align: center; font-size: .8rem; }
.list-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.list-actions form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.list-actions input { width: auto; max-width: 220px; }
@media (max-width: 520px) { .breakdown { grid-template-columns: 96px 1fr 44px; } .clickmap-frame { height: 560px; } }
/* Domains: DNS records and check results */
.domain-row { padding: 12px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.domain-row:last-of-type { border-bottom: 0; }
.domain-row h3 { margin: 0; font-size: 1rem; }
.domain-add { align-items: flex-end; }
.meta.record { margin: 0; }
.meta.record dd, .dns-result code, .domain-row code { overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.dns-result { border-left: 3px solid var(--border); padding: 4px 0 4px 12px; }
.dns-pass { border-left-color: var(--ok); }
.dns-warning { border-left-color: var(--warn); }
.dns-fail { border-left-color: var(--danger); }
.code-input { width: 9em !important; letter-spacing: .2em; }
.badge-paused { background: var(--warn-soft); color: var(--warn); }
.badge-cancelled { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.delivery-progress { display: grid; gap: 8px; }
.delivery-options { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; min-width: 0; }
.delivery-options legend { font-weight: 600; font-size: .9rem; padding: 0 4px; }
/* Audit log and security settings */
.audit-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.audit-filter-buttons { grid-column: 1 / -1; }
.audit-description { margin-top: 4px; overflow-wrap: anywhere; }
.audit-agent { overflow-wrap: anywhere; max-width: 260px; }
.nowrap { white-space: nowrap; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; padding: 12px 16px; margin: 0; list-style: none; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.recovery-codes li { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
/* Always dark on white, whatever the theme, so phone cameras can read it. */
.qr-code { display: block; width: 200px; max-width: 100%; height: auto; padding: 10px; background: #ffffff; border-radius: var(--radius); border: 1px solid var(--border); }
.secret-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; letter-spacing: .06em; }
.status-on { color: var(--ok); font-weight: 600; }
.status-off { color: var(--muted); font-weight: 600; }
.sso-button { width: 100%; }
.or-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
@media (max-width: 480px) { .recovery-codes { grid-template-columns: 1fr; } }
.audit-table .badge { white-space: nowrap; }
@media (max-width: 640px) {
    .audit-table, .audit-table tbody, .audit-table tr, .audit-table td { display: block; }
    .audit-table thead { display: none; }
    .audit-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
    .audit-table td { border: 0; padding: 2px 0; }
    .audit-table td.nowrap { display: flex; gap: 8px; flex-wrap: wrap; }
    .audit-agent { display: none; }
}

/* Translations can make button labels longer (Dutch especially): on phones a long label wraps instead of widening the page. */
@media (max-width: 600px) {
    .btn { white-space: normal; max-width: 100%; text-align: center; }
}

/* Push notifications on the profile: buttons are shown by js/push.js, so [hidden] must win over .btn. */
[data-push] [hidden] { display: none !important; }
.push-topics { border: 0; padding: 0; margin: 0; }
.push-topics legend { font-weight: 600; margin-bottom: 6px; }

/* Phones: the move and delete buttons on journey steps get a finger-sized tap area. */
@media (max-width: 820px) {
    .node-tools { gap: 2px; }
    .node-tools button.link { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
}

/* A preview opened on its own page: the email fills the height below the header. */
.preview-page #preview { height: max(480px, calc(100vh - 220px)); }

/* The light/dark switch (partials.mode-toggle): a moon in light mode, a sun in dark mode. */
.mode-toggle-form { display: contents; }
.mode-toggle {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; padding: 0; border-radius: 12px; cursor: pointer;
    font: inherit; color: inherit; background: transparent; border: 1px solid var(--border);
}
.mode-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.mode-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-icon { width: 20px; height: 20px; }
.mode-icon-sun { display: none; }
html[data-mode="dark"] .mode-icon-sun { display: block; }
html[data-mode="dark"] .mode-icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    html[data-mode="auto"] .mode-icon-sun { display: block; }
    html[data-mode="auto"] .mode-icon-moon { display: none; }
}

/* Terms and policies (cloud edition): the box on the signup form and the texts on the review page. */
.legal-accept { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; min-width: 0; }
.legal-accept legend { font-weight: 600; padding: 0 4px; }
.legal-accept ul { margin: 0; padding-left: 1.2rem; }
.legal-scroll { max-height: 45vh; overflow: auto; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--surface); }
.legal-scroll h1 { font-size: 1.2rem; }
.legal-scroll h2 { font-size: 1.05rem; }
/* The language switch for visitors (partials.language-switch): one button per other language. */
.language-switch { display: contents; }
.public-card > .language-switch { display: flex; justify-content: center; margin-top: 16px; }

/*
 * Phones and small tablets (≤ 820px, where the menu becomes a top bar). Checked at 390 and 360px in every
 * theme, light and dark (MobileLayoutTest guards these rules):
 * - form fields use 16px text, so iOS doesn't zoom the page in when one gets focus;
 * - buttons, tabs, links in rows and checkboxes get a finger-sized tap area (40px, chips 36px);
 * - hints and small print stay readable (13px at least);
 * - the top bar keeps the logo, workspace, light/dark switch and profile on one row above the menu.
 */
@media (max-width: 820px) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px; }
    html textarea.mono, html input.mono, html textarea.code, #html, html .move-folder select, html .tx-editor textarea.mono { font-size: 16px; }
    td > input[type=checkbox], th > input[type=checkbox] { width: 24px; height: 24px; }
    input[type=checkbox], input[type=radio] { width: 20px; height: 20px; flex: none; margin: 0; }
    label.check { min-height: 40px; }
    .btn { min-height: 40px; }
    .btn.small { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
    button.link { min-height: 36px; display: inline-flex; align-items: center; gap: .3em; }
    .help-link { width: 40px; height: 40px; }
    .help-link.static { width: 28px; height: 28px; }
    .tabs a, .subtabs a { min-height: 40px; display: inline-flex; align-items: center; gap: .3em; }
    .chip { min-height: 36px; display: inline-flex; align-items: center; gap: .3em; padding: 4px 12px; }
    th a.sort-link { min-height: 36px; display: inline-flex; align-items: center; gap: .3em; }
    details > summary { padding-top: 8px; padding-bottom: 8px; }
    .device-toggle button { min-height: 36px; padding: 6px 12px; }
    small, .small { font-size: max(.82rem, 13px); }
    .small code, small code { font-size: 1em; }
    /* Top bar: logo only, the menu name moves into the link's label for screen readers. */
    .sidebar { gap: 8px; }
    .sidebar .brand { min-width: 40px; min-height: 40px; justify-content: center; }
    .sidebar .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .workspace-switcher { flex: 0 1 auto; }
    .sidebar nav a { min-height: 40px; display: flex; align-items: center; }
    /* Dialogs never grow past the screen; their content scrolls inside. */
    .media-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; padding: 16px; }
    /* Journeys: the + between steps is a full-size button. */
    .journey-add summary { width: 40px; height: 40px; padding: 0; }
    .node-tools button.link { min-width: 40px; min-height: 40px; }
}
@media (max-width: 820px) {
    html[data-theme] .sidebar .sidebar-foot .profile-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/*
 * Tables on phones: a list table that doesn't fit the screen turns into one card per row, each value
 * under its column name (rail.js copies the names into data-label and adds .stack-cards only when the table
 * would scroll sideways). Sort links stay above the cards as a row of buttons.
 */
@media (max-width: 640px) {
    table.stack-cards, table.stack-cards tbody, table.stack-cards tfoot, table.stack-cards tr, table.stack-cards td, table.stack-cards th[scope=row] { display: block; width: 100%; }
    table.stack-cards { min-width: 0; } /* a table that sets a minimum width for scrolling fits as cards */
    table.stack-cards thead { display: block; }
    table.stack-cards thead tr { display: flex; flex-wrap: wrap; gap: 4px 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
    table.stack-cards thead th { border: 0; padding: 0; }
    table.stack-cards thead th:not(:has(a, button, input)) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    table.stack-cards tbody tr, table.stack-cards tfoot tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
    table.stack-cards tbody tr:last-child { border-bottom: 0; }
    table.stack-cards td, table.stack-cards tbody th { border: 0; padding: 3px 0; overflow-wrap: anywhere; text-align: left; }
    table.stack-cards td[data-label]:not([data-label=""]) { position: relative; padding-left: calc(36% + 10px); min-height: 26px; }
    table.stack-cards td[data-label]:not([data-label=""])::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 36%; overflow-wrap: anywhere; color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
    table.stack-cards .truncate, table.stack-cards .nowrap { white-space: normal; overflow-wrap: anywhere; }
    table.stack-cards td:first-child { font-size: 1.02rem; }
    table.stack-cards td:first-child[data-label]:not([data-label=""]) { padding-left: 0; }
    table.stack-cards td:first-child::before { display: none; }
    table.stack-cards td:empty { display: none; }
    table.stack-cards .right { text-align: left; }
}
