/*
 * cx-admin.css B.2.19 — cx-pack-index: column headings sort the table
 * (.sortable, .sorted), Composer and Work columns, and long pack names wrap.
 *
 * cx-admin.css B.2.18 — the toolbar text field rule is scoped to Cues from
 * Log (.cx-cues), the one page it was added for.
 *
 * cx-admin.css B.2.17 — the field menu is .cx-field-menu (cx-admin.js
 * fieldMenu); cx-combo.js is gone.
 *
 * cx-admin.css B.2.16 — the pack menu is shared (cx-combo.js): .imp-combo is
 * .cx-combo, and a text field in a .toolbar is styled like its selects.
 *
 * cx-admin.css B.2.15 — cx-import: the pack and column menus are the page's own
 * (.imp-combo), in place of a datalist whose popup the browser keeps small.
 *
 * cx-admin.css B.2.14 — the cx-build, cx-media and cx-sheets-import blocks go,
 * with the pages: Import (cx-import) replaced all three.
 *
 * cx-admin.css B.2.13 — cx-import: a small drop zone (subtitle files in the Film tab).
 *
 * cx-admin.css B.2.12 — cx-import step number: text through var(--cx-bg), as on the other brand-filled controls.
 *
 * cx-admin.css B.2.11 — cx-import: numbered steps (the Film tab).
 *
 * cx-admin.css B.2.10 — cx-import: the Film tab's stream table and progress bars.
 *
 * cx-admin.css B.2.9 — cx-import: tabs (Pack, Media, Score, Check) and the
 * Pack tab's source buttons; the folded-away source blocks are gone.
 *
 * cx-admin.css B.2.8 — the cx-import tool page gains its own scoped block,
 * covering what it took over from cx-build, cx-media and cx-sheets-import.
 * Those pages' blocks stay until the pages are retired.
 *
 * cx-admin.css B.2.7 — the cx-qr tool page gains its own scoped block. The page
 * had been relying on classes that were never defined here, so its textarea
 * fell back to the browser default width and its code grid had no layout.
 * The remaining hex values are physical requirements and are commented as
 * such.
 * Requires cx-base.css and a theme file loaded before this.
 *
 * Covers: body scroll override, header/brand/tagline/main layout,
 * section headings, card grid, buttons, toolbar, form primitives,
 * selects (all contexts), status bar, progress, table base, drop-zone,
 * empty/loading states, site footer, page index (QR, pills, tags),
 * QR tool page.
 *
 * Page-specific CSS (charts, param bars, etc.) stays inline.
 */

:root { --cx-admin-version: 'B.2.18'; }

/* ── Body ── */
body {
    height: auto;
    overflow: auto;
    padding: 2.5rem 2rem 6rem;
}

/* ── Header (three-zone: org left / brand centre / menu right) ── */
.site-header,
[data-cx~="header"] {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    padding-left: 3rem;   /* breathing room; left zone is absolute (out of flow) */
    padding-right: 3rem;  /* breathing room; hamburger is absolute (out of flow) */
    border-bottom: 1px solid var(--cx-border);
}

/* Centre zone — brand + tagline stacked, the visual centre of the header. */
.cx-hdr-centre {
    text-align: center;
}

/* Left zone — org logo + name, pinned left, vertically centred. */
.cx-hdr-left {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 2rem;            /* match header padding-bottom so it centres on the brand row */
    display: flex;
    align-items: center;
}
.cx-hdr-org {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    text-decoration: none;
    max-width: 160px;
}
.cx-hdr-org:hover { text-decoration: none; }
.cx-org-logo {
    max-height: 28px;
    max-width: 150px;
    width: auto;
    height: auto;
    display: block;
}
.cx-org-name {
    font-family: var(--cx-font-body);
    font-size: 0.7rem;
    color: var(--cx-text-mid);
    line-height: 1.15;
    text-align: center;
    max-width: 150px;
    overflow-wrap: break-word;
}

/* Right zone — hamburger button + drop menu, pinned right. */
.cx-hdr-right {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 2rem;
    display: flex;
    align-items: center;
}

.cx-hdr-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 28px;
    height: 28px;
    padding: 4px;
    cursor: pointer;
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius);
    background: var(--cx-surface);
}
.cx-hdr-burger:hover { background: var(--cx-surface-mid); }
.cx-hdr-burger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--cx-text-mid);
    border-radius: 1px;
}

.cx-hdr-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 1000;
    padding: 0.35rem 0;
    text-align: left;
}
/* CSS-only toggle: checked checkbox reveals the menu. */
.cx-hdr-toggle:checked ~ .cx-hdr-menu { display: block; }

.cx-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 1rem;
    font-family: var(--cx-font-body);
    font-size: 0.85rem;
    color: var(--cx-text);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
}
.cx-menu-item:hover { background: var(--cx-surface-mid); text-decoration: none; }

.cx-menu-who {
    padding: 0.5rem 1rem;
    font-family: var(--cx-font-mono);
    font-size: 0.72rem;
    color: var(--cx-text-dim);
    border-top: 1px solid var(--cx-border);
    margin-top: 0.35rem;
    word-break: break-all;
}
.cx-menu-logout { margin: 0; }
.cx-menu-logout-btn { color: var(--cx-negative); }

/* Narrow screens — keep the burger usable, let the centre shrink. */
@media (max-width: 640px) {
    .site-header,
    [data-cx~="header"] { padding-left: 0.5rem; padding-right: 2.75rem; }
    .cx-hdr-left { display: none; }   /* org zone hidden on small screens */
}

.brand,
[data-cx~="brand"] {
    font-family: var(--cx-font-serif-title);
    font-size: 2.2rem;
    color: var(--cx-text-strong);
    text-decoration: none;
    display: block;
    margin-bottom: 0.3rem;
}

.brand span,
[data-cx~="brand"] span { color: var(--cx-brand); }

.page-title {
    font-family: var(--cx-font-serif-title);
    font-size: 1.3rem;
    color: var(--cx-text);
    margin-top: 0.4rem;
}

.tagline,
[data-cx~="tagline"] {
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
    margin-top: 0.5rem;
}

/* ── Main layout ── */
.main,
[data-cx~="main"] {
    padding: 0 3rem;
}

/* ── Section headings ── */
.section {
    margin-bottom: 2.5rem;
}

.section-heading,
.cx-heading {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--cx-brand);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--cx-border);
}

.cx-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Card grid ── */
.cx-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1px;
    background: var(--cx-bg);
    border: 1px solid var(--cx-border);
}

.cx-card {
    background: var(--cx-surface);
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    cursor: pointer;
    transition: background var(--cx-transition-fast);
}

.cx-card:hover { background: var(--cx-surface-mid); }

.cx-card[data-cx~="inactive"] {
    cursor: default;
    opacity: 0.4;
}
.cx-card[data-cx~="inactive"]:hover { background: var(--cx-surface); }

.cx-card-title {
    font-family: var(--cx-font-serif-title);
    font-size: 1rem;
    color: var(--cx-text-strong);
}

.cx-card-desc {
    font-size: 0.8rem;
    color: var(--cx-text);
    line-height: 1.5;
}

/* ── Buttons ── */
.btn {
    padding: 0.3rem 0.75rem;
    border-radius: var(--cx-radius);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    border: 1px solid var(--cx-border);
    background: var(--cx-surface-mid);
    color: var(--cx-text);
    transition: background var(--cx-transition-fast);
}
.btn:hover { background: var(--cx-surface-high); }

.btn-danger {
    border-color: var(--cx-negative-dim);
    color: var(--cx-negative);
    background: transparent;
}
.btn-danger:hover { background: var(--cx-red-bg); color: var(--cx-red-color); }

/* .btn-primary — card/index pages (accent yellow) */
.btn-primary {
    background: var(--cx-accent);
    color: var(--cx-on-accent);
    border-color: var(--cx-accent);
    font-weight: 600;
}
.btn-primary:hover { background: var(--cx-accent-dim); }

/* .btn-secondary — muted secondary action */
.btn-secondary {
    background: var(--cx-bg-high);
    color: var(--cx-text);
    border: 1px solid var(--cx-border-dim);
}
.btn-secondary:hover { background: var(--cx-surface); }

/* button.primary — tool pages (brand colour) */
button.primary {
    background: var(--cx-brand);
    color: var(--cx-bg);
    border: none;
    padding: 0.55rem 1.25rem;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}
button.primary:hover { opacity: 0.85; }
button.primary:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary {
    background: var(--cx-bg-high);
    color: var(--cx-text);
    border: 1px solid var(--cx-border);
    padding: 0.55rem 1.25rem;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}
button.secondary:hover { background: var(--cx-surface); }
button.secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.toolbar label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
}

/* Cues from Log: the pack field in its toolbar (a fieldMenu) matches the
   toolbar's selects. */
.cx-cues .toolbar input[type="text"] {
    flex: 0 1 22rem;
    min-width: 12rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text-strong);
    font-family: var(--cx-font-mono);
    font-size: 0.85rem;
    padding: 0.3rem 0.6rem;
}
.cx-cues .toolbar input[type="text"]:focus { outline: none; border-color: var(--cx-brand); }

.toolbar button {
    background: var(--cx-brand);
    color: var(--cx-bg);
    border: none;
    padding: 0.35rem 0.9rem;
    font-family: var(--cx-font-body);
    font-size: 0.85rem;
    cursor: pointer;
}
.toolbar button:hover { opacity: 0.85; }
.toolbar button:disabled { opacity: 0.4; cursor: default; }

.toolbar button.secondary {
    background: var(--cx-surface);
    color: var(--cx-text);
    border: 1px solid var(--cx-border);
}
.toolbar button.secondary:hover { background: var(--cx-surface-mid); }

/* ── Selects — base (all tool contexts) ── */
/* Shared appearance, arrow, colours. Specific contexts override padding only. */
.toolbar select,
.row select,
.org-field select,
[data-cx~="main"] select,
main.cx-tool select {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--cx-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    border: 1px solid var(--cx-border);
    color: var(--cx-text);
    font-family: var(--cx-font-mono);
    font-size: 0.85rem;
    cursor: pointer;
}
.toolbar select:focus,
.row select:focus,
.org-field select:focus,
[data-cx~="main"] select:focus,
main.cx-tool select:focus { outline: none; border-color: var(--cx-brand); }

/* Context-specific padding */
.toolbar select       { padding: 0.3rem 1.8rem 0.3rem 0.6rem; color: var(--cx-text-strong); }
.row select           { padding: 0.5rem 2rem 0.5rem 0.75rem; flex: 1; }
.org-field select     { padding: 0.4rem 2rem 0.4rem 0.5rem; width: 100%; }
[data-cx~="main"] select,
main.cx-tool select   { padding: 0.4rem 2rem 0.4rem 0.6rem; }

/* ── Form rows (.row) ── */
.row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}
.row label,
.row .field-label {
    font-size: 0.75rem;
    color: var(--cx-text-dim);
    width: 160px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.row input {
    flex: 1;
    font-family: var(--cx-font-mono);
    font-size: 0.85rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text);
    padding: 0.5rem 0.75rem;
}
.row input:focus { outline: none; border-color: var(--cx-brand); }
.row .hint {
    font-size: 0.72rem;
    color: var(--cx-text-dim);
    flex: 1;
}

/* ── Form primitives (.form-field) ── */
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    min-width: 180px;
}

.form-field label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
}

.form-field input,
.form-field select {
    background: var(--cx-bg);
    border: 1px solid var(--cx-border);
    color: var(--cx-text-strong);
    padding: 0.45rem 0.6rem;
    font-family: inherit;
    font-size: 0.88rem;
    border-radius: var(--cx-radius);
}

.form-field input:focus,
.form-field select:focus {
    border-color: var(--cx-accent-dim);
    outline: none;
}

.form-field .hint {
    font-size: 0.72rem;
    color: var(--cx-text-dim);
    margin-top: 0.15rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.25rem;
}

.form-msg { font-size: 0.82rem; }
.form-msg.ok  { color: var(--cx-ok); }
.form-msg.err { color: var(--cx-negative); }

/* ── Status bar ── */
.status-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-bg-high);
    margin: 1.25rem 0;
    min-height: 2.5rem;
    font-size: 0.82rem;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--cx-border);
}
.status-dot.ok   { background: var(--cx-ok); }
.status-dot.err  { background: var(--cx-err); }
.status-dot.warn { background: var(--cx-accent); }
.status-dot.busy { background: var(--cx-brand); animation: cx-pulse 1s infinite; }

.status-text { color: var(--cx-text-mid); }
.status-text.ok   { color: var(--cx-ok); }
.status-text.err  { color: var(--cx-err); }
.status-text.warn { color: var(--cx-accent); }

@keyframes cx-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Progress (inside status bar) ── */
.progress-track {
    flex: 1;
    height: 6px;
    background: var(--cx-bg-high);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--cx-brand);
    transition: width 0.25s ease;
}

/* ── Table base ── */
.cx-table-wrap { margin-bottom: 1.5rem; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
table th {
    font-family: var(--cx-font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--cx-border);
    font-weight: normal;
}
table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--cx-border);
    color: var(--cx-text);
    font-family: var(--cx-font-mono);
    vertical-align: top;
}
table tr:hover td { background: var(--cx-surface); }

/* ── cx-cues-from-log (scoped) ── */
.cx-cues tr.run-header td {
    color: var(--cx-brand);
    background: var(--cx-surface);
    font-size: 0.75rem;
}
.cx-cues .preview-row {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--cx-border);
    font-size: 0.8rem;
}
.cx-cues .preview-line {
    font-family: var(--cx-font-mono);
    color: var(--cx-text-dim);
    width: 3rem;
    flex: none;
    text-align: right;
}
.cx-cues .preview-cue {
    font-family: var(--cx-font-mono);
    color: var(--cx-ok);
    width: 7rem;
    flex: none;
}
.cx-cues .preview-prev {
    font-family: var(--cx-font-mono);
    color: var(--cx-text-dim);
    font-size: 0.72rem;
}
.cx-cues .preview-content {
    color: var(--cx-text);
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Negative cueIn — a line that was up before the timing origin. */
.cx-cues .preview-row.negative .preview-cue { color: var(--cx-warn); }

/* A run excluded from the save: visible, but clearly not being written. */
.cx-cues tr.excluded td { opacity: 0.45; }

/* Long-pause toggles. Stacked in their cell, one per pause, each a button —
   they carry a border and hover so they do not read as static text. */
.cx-cues .pauses {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-start;
}
/* A pause is a description plus its own action button. The whole row used to be one
   button labelled with its current state, which read as a static caption and
   gave no hint that clicking would change anything. */
.cx-cues .pause {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.55rem;
    background: var(--cx-bg-high);
    border: 1px solid var(--cx-border);
    font-size: 0.75rem;
}
.cx-cues .pause-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.cx-cues .pause-what  { font-family: var(--cx-font-mono); color: var(--cx-text); }
.cx-cues .pause-state { font-size: 0.7rem; }
.cx-cues .pause.is-cut  .pause-state { color: var(--cx-warn); }
.cx-cues .pause.is-kept .pause-state { color: var(--cx-text-dim); }

.cx-cues .pause-toggle {
    margin-left: auto;
    flex: none;
    background: var(--cx-surface);
    color: var(--cx-text);
    border: 1px solid var(--cx-border);
    padding: 0.25rem 0.7rem;
    font-family: var(--cx-font-body);
    font-size: 0.72rem;
    cursor: pointer;
}
.cx-cues .pause-toggle:hover:not(:disabled) { background: var(--cx-surface-mid); }
.cx-cues .pause-toggle:disabled { opacity: 0.4; cursor: not-allowed; }

/* Hint under a section heading — explains an interaction that is not obvious. */
.cx-cues .section-hint {
    font-size: 0.75rem;
    color: var(--cx-text-dim);
    margin: -0.5rem 0 0.75rem;
}

/* Save sits in the status bar, so the confirmation appears where you are
   already looking rather than at the far end of a long preview. */
.cx-cues .status-bar button { margin-left: auto; flex: none; }

/* Empty/no-result line (mono, dim) */
.empty {
    font-family: var(--cx-font-mono);
    font-size: 0.85rem;
    color: var(--cx-text-dim);
    padding: 1rem 0;
}

/* ── cx-engagement (scoped) ── */
/* Section heading with an inline select (e.g. the sort dropdown) */
.cx-engagement .section-heading {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.cx-engagement .section-heading select {
    font-size: 0.7rem;
    background: var(--cx-surface);
    color: var(--cx-text);
    border: 1px solid var(--cx-border);
    padding: 0.15rem 0.4rem;
    font-family: var(--cx-font-mono);
}

/* Summary stat grid */
.cx-engagement .summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1px;
    background: var(--cx-bg);
    border: 1px solid var(--cx-border);
    margin-bottom: 2rem;
}
.cx-engagement .summary-cell { background: var(--cx-surface); padding: 0.8rem 1rem; }
.cx-engagement .summary-value {
    font-family: var(--cx-font-mono);
    font-size: 1.6rem;
    color: var(--cx-text-strong);
    line-height: 1;
}
.cx-engagement .summary-label {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
    margin-top: 0.3rem;
}

/* Canvas charts */
.cx-engagement .chart-wrap { position: relative; }
.cx-engagement .chart-wrap canvas { display: block; width: 100% !important; }
.cx-engagement .chart-note {
    font-size: 0.85rem;
    color: var(--cx-text-dim);
    margin: 0.5rem 0 0;
    line-height: 1.5;
}
.cx-engagement .chart-tooltip {
    position: fixed;
    background: var(--cx-surface-high);
    border: 1px solid var(--cx-border);
    padding: 0.3rem 0.6rem;
    font-family: var(--cx-font-mono);
    font-size: 0.75rem;
    color: var(--cx-text);
    pointer-events: none;
    display: none;
    z-index: 100;
    white-space: nowrap;
}

/* Pack digest table */
.cx-engagement .pack-title {
    font-family: var(--cx-font-mono);
    font-size: 0.9rem;
    color: var(--cx-text-strong);
    margin-bottom: 0.5rem;
}
.cx-engagement tr.summary-row td {
    color: var(--cx-text-strong);
    background: var(--cx-surface);
}

/* ── cx-export-media (scoped) ── */
.cx-export .note {
    margin: -1rem 0 1.75rem;
    padding: 0.6rem 0.9rem;
    border-left: 3px solid var(--cx-brand);
    background: var(--cx-surface);
    color: var(--cx-text-dim);
    font-size: 0.85rem;
    line-height: 1.5;
}
.cx-export .note a { color: var(--cx-brand); }

.cx-export .section-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 0.5rem 0 1.5rem;
}
.cx-export .section-tabs button {
    flex: 1;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text-dim);
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.cx-export .section-tabs button.active {
    background: var(--cx-bg-high);
    color: var(--cx-text-strong);
    border-color: var(--cx-brand);
}

.cx-export .panel { display: none; }
.cx-export .panel.active { display: block; }

.cx-export .track-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
}
.cx-export .track-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text);
    padding: 0.45rem 0.7rem;
    cursor: pointer;
    font-family: var(--cx-font-mono);
    font-size: 0.82rem;
    user-select: none;
}
.cx-export .track-item:hover { border-color: var(--cx-text-dim); }
.cx-export .track-item.selected {
    border-color: var(--cx-brand);
    background: var(--cx-bg-high);
    color: var(--cx-text-strong);
}
.cx-export .track-item .tick {
    width: 1rem;
    flex: none;
    color: var(--cx-brand);
    opacity: 0;
}
.cx-export .track-item.selected .tick { opacity: 1; }
.cx-export .track-empty {
    font-family: var(--cx-font-mono);
    font-size: 0.8rem;
    color: var(--cx-text-dim);
    padding: 0.4rem 0;
}

.cx-export fieldset.text-opts {
    border: 1px solid var(--cx-border);
    padding: 0.75rem 1rem 0.25rem;
    margin: 0.5rem 0 1rem;
}
.cx-export fieldset.text-opts legend {
    font-size: 0.7rem;
    color: var(--cx-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 0.4rem;
}

.cx-export .row-top { align-items: flex-start; }

/* ── cx-pack-index (scoped) ── */
.cx-pack-index .pack-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.cx-pack-index .pack-table th {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cx-brand);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--cx-bg-mid);
    text-align: left;
    font-weight: normal;
}
.cx-pack-index .pack-table td {
    padding: 0.45rem 1rem;
    border-bottom: 1px solid var(--cx-bg-high);
    vertical-align: middle;
}
.cx-pack-index .pack-row:hover { background: var(--cx-surface); cursor: pointer; }
.cx-pack-index .pack-row td.star-cell { width: 2rem; padding-right: 0; text-align: center; cursor: pointer; }
.cx-pack-index .star { font-size: 1rem; line-height: 1; color: var(--cx-border); transition: color 0.15s; }
.cx-pack-index .star.on { color: var(--cx-brand); }
.cx-pack-index .star:hover { color: var(--cx-text-mid); }
.cx-pack-index .pack-id    { font-family: var(--cx-font-mono); color: var(--cx-text); }
.cx-pack-index .pack-title { color: var(--cx-text-mid); }
.cx-pack-index .pack-lang  { font-family: var(--cx-font-mono); font-size: 0.72rem; color: var(--cx-text-dim); }
.cx-pack-index .pack-count { font-family: var(--cx-font-mono); font-size: 0.72rem; color: var(--cx-text-dim); text-align: right; }
.cx-pack-index .pack-mtime { font-size: 0.72rem; color: var(--cx-text-dim); text-align: right; }
/* B.2.19 — sorting, and the Composer and Work columns. */
.cx-pack-index .pack-table th.num { text-align: right; }
.cx-pack-index .pack-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.cx-pack-index .pack-table th.sortable:hover { color: var(--cx-text); }
.cx-pack-index .pack-table th.sorted { color: var(--cx-text); }
.cx-pack-index .pack-table th.sorted::after { content: ' ▲'; font-size: 0.6rem; color: var(--cx-brand); }
.cx-pack-index .pack-table th.sorted.down::after { content: ' ▼'; }
.cx-pack-index .pack-id { overflow-wrap: anywhere; }
.cx-pack-index .pack-mtime, .cx-pack-index .pack-lang { white-space: nowrap; }
.cx-pack-index .pack-composer { color: var(--cx-text-mid); }
.cx-pack-index .pack-work { font-family: var(--cx-font-mono); font-size: 0.72rem; color: var(--cx-text-dim); overflow-wrap: anywhere; }

/* ── cx-merge (scoped) ── */
.cx-merge .pack-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--cx-bg-mid);
    border: 1px solid var(--cx-bg-mid);
}
.cx-merge .pack-item {
    background: var(--cx-surface);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background var(--cx-transition-fast);
}
.cx-merge .pack-item:hover { background: var(--cx-surface-mid); }
.cx-merge .pack-item.selected { background: var(--cx-focus-bg); border-left: 2px solid var(--cx-brand); }
.cx-merge .pack-item.in-queue { opacity: 0.4; cursor: default; }
.cx-merge .pack-name {
    font-family: var(--cx-font-mono);
    font-size: 0.8rem;
    color: var(--cx-text-strong);
    flex: none;
    min-width: 10rem;
}
.cx-merge .pack-title { font-size: 0.85rem; color: var(--cx-text-dim); }
.cx-merge .pack-merged-badge {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cx-brand);
    border: 1px solid var(--cx-brand);
    padding: 0.1rem 0.4rem;
    flex: none;
}

.cx-merge .queue {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--cx-bg-mid);
    border: 1px solid var(--cx-bg-mid);
    min-height: 3rem;
}
.cx-merge .queue-empty {
    padding: 0.75rem 1rem;
    color: var(--cx-text-muted);
    font-size: 0.85rem;
    font-style: italic;
}
.cx-merge .queue-item {
    background: var(--cx-surface);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.cx-merge .queue-pos {
    font-family: var(--cx-font-mono);
    font-size: 0.75rem;
    color: var(--cx-text-dim);
    flex: none;
    width: 1.5rem;
    text-align: right;
}
.cx-merge .queue-name { font-family: var(--cx-font-mono); font-size: 0.8rem; color: var(--cx-text-strong); flex: 1; }
.cx-merge .queue-title { font-size: 0.8rem; color: var(--cx-text-dim); }
.cx-merge .queue-remove {
    font-size: 0.75rem;
    color: var(--cx-text-dim);
    cursor: pointer;
    flex: none;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--cx-border-dim);
    background: none;
    transition: color var(--cx-transition-fast), border-color var(--cx-transition-fast);
}
.cx-merge .queue-remove:hover { color: var(--cx-brand); border-color: var(--cx-brand); }
.cx-merge .queue-move {
    font-size: 0.75rem;
    color: var(--cx-text-muted);
    cursor: pointer;
    flex: none;
    padding: 0.1rem 0.3rem;
    border: 1px solid var(--cx-bg-high);
    background: none;
    transition: color var(--cx-transition-fast);
}
.cx-merge .queue-move:hover { color: var(--cx-text-strong); }

.cx-merge .id-row { display: flex; align-items: center; gap: 0.75rem; }
.cx-merge .id-label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cx-text-mid);
    flex: none;
}
.cx-merge .id-input {
    flex: 1;
    background: var(--cx-bg);
    color: var(--cx-text-strong);
    border: 1px solid var(--cx-border-dim);
    padding: 0.4rem 0.6rem;
    font-family: var(--cx-font-mono);
    font-size: 0.9rem;
}
.cx-merge .id-input:focus { border-color: var(--cx-border); outline: none; }
.cx-merge .id-error { font-size: 0.8rem; color: var(--cx-brand); margin-top: 0.4rem; min-height: 1.2rem; }

.cx-merge .action-bar { display: flex; gap: 1rem; align-items: center; margin-top: 2rem; }

.cx-merge .status { font-size: 0.8rem; color: var(--cx-text-dim); font-style: italic; }
.cx-merge .status.ok  { color: var(--cx-ok); font-style: normal; }
.cx-merge .status.err { color: var(--cx-brand); font-style: normal; }

/* ── cx-import (scoped) ── */
/* The page shows and hides its blocks with the hidden attribute and with
   .visible; a display rule below must never override hidden. */
.cx-import [hidden] { display: none !important; }

/* Tabs: one per job. */
.cx-import .imp-tabs {
    display: flex;
    gap: 1px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--cx-border);
    margin-bottom: 0.25rem;
}
.cx-import .imp-tab {
    flex: 1;
    min-width: 90px;
    padding: 0.6rem 1rem;
    background: var(--cx-surface);
    color: var(--cx-text-mid);
    border: none;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
}
.cx-import .imp-tab:hover { color: var(--cx-text); }
.cx-import .imp-tab.on { color: var(--cx-text-strong); border-bottom-color: var(--cx-brand); }

/* Pack tab: where the text comes from. */
.cx-import .imp-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}
.cx-import .imp-src {
    font-family: inherit;
    font-size: 0.78rem;
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--cx-border-dim);
    border-radius: 1rem;
    background: none;
    color: var(--cx-text-mid);
    cursor: pointer;
}
.cx-import .imp-src:hover { color: var(--cx-text); }
.cx-import .imp-src.on { color: var(--cx-text-strong); border-color: var(--cx-brand); }
.cx-import .imp-source { margin-bottom: 1.5rem; }
.cx-import .imp-source .imp-note { margin-top: -0.25rem; }

/* Film: the streams inside a film, one row each, and progress bars for the
   upload and the extraction. */
.cx-import .imp-streams { margin-bottom: 1rem; }
.cx-import .imp-streams td { vertical-align: middle; }
.cx-import .imp-streams .imp-lang {
    width: 7rem;
    font-family: var(--cx-font-mono);
    font-size: 0.78rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text);
    padding: 0.2rem 0.4rem;
}
.cx-import .imp-streams .imp-lang:focus { outline: none; border-color: var(--cx-brand); }
.cx-import .imp-progress {
    width: 100%;
    height: 6px;
    margin: 0.4rem 0 1rem;
    accent-color: var(--cx-brand);
}

/* Steps: one open at a time. A finished step shows only its summary line, a
   step not reached yet only its heading. */
.cx-import .imp-step {
    position: relative;
    margin-left: 0.75rem;
    padding: 0 0 1.4rem 1.6rem;
    border-left: 1px solid var(--cx-border-dim);
}
.cx-import .imp-step:last-child { border-left-color: transparent; }
.cx-import .imp-step-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: -2.35rem;
    margin-bottom: 0.6rem;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cx-text-strong);
}
.cx-import .imp-step-num {
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    background: var(--cx-bg);
    border: 1px solid var(--cx-border);
    color: var(--cx-text-mid);
}
.cx-import .imp-step[data-state="current"] .imp-step-num { background: var(--cx-brand); border-color: var(--cx-brand); color: var(--cx-bg); }
.cx-import .imp-step[data-state="done"] .imp-step-num    { border-color: var(--cx-ok); color: var(--cx-ok); }
.cx-import .imp-step[data-state="done"] .imp-step-num::before { content: '✓'; }
.cx-import .imp-step[data-state="done"] .imp-step-num { font-size: 0; }
.cx-import .imp-step[data-state="done"] .imp-step-num::before { font-size: 0.8rem; }
.cx-import .imp-step[data-state="pending"] .imp-step-head { color: var(--cx-text-dim); }
.cx-import .imp-step-summary {
    display: none;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.82rem;
    color: var(--cx-text-mid);
    overflow-wrap: anywhere;
}
.cx-import .imp-step-summary b { color: var(--cx-text); font-weight: 500; }
.cx-import .imp-step-body { display: none; }
.cx-import .imp-step[data-state="done"]    .imp-step-summary { display: flex; }
.cx-import .imp-step[data-state="current"] .imp-step-body    { display: block; }
.cx-import .imp-step .imp-step-summary span:empty + button { display: none; }

/* A drop zone for a few small files, sitting inside a step. */
.cx-import .imp-drop-small { padding: 0.6rem 1rem; margin: 0 0 1rem; }
.cx-import .imp-drop-small .drop-label { font-size: 0.78rem; }

/* Audit: one sub-heading per media column. */
.cx-import .imp-audit-col {
    font-family: var(--cx-font-mono);
    font-size: 0.8rem;
    color: var(--cx-text-strong);
    margin: 1rem 0 0.2rem;
}

.cx-import .field-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}
.cx-import .field-label {
    font-size: 0.75rem;
    color: var(--cx-text);
    width: 120px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.cx-import .field-row input[type="text"] {
    flex: 1;
    font-family: var(--cx-font-mono);
    font-size: 0.8rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text);
    padding: 0.5rem 0.75rem;
}
.cx-import .field-row input:focus { outline: none; border-color: var(--cx-brand); }

/* The pack and column menus (cx-admin.js fieldMenu). On <body>, outside any tool's
   scope, so unscoped; fixed to the viewport, and the script sets its place,
   width and height. */
.cx-field-menu {
    position: fixed;
    z-index: 50;
    overflow-y: auto;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.35); /* cx-colour-ok: a shadow, not a theme colour */
    font-family: var(--cx-font-mono);
    font-size: 0.8rem;
}
.cx-field-menu[hidden] { display: none !important; }
.cx-field-menu-item {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    white-space: nowrap;
}
.cx-field-menu-item:hover { background: var(--cx-surface-mid); }
.cx-field-menu-item.on { background: var(--cx-surface-high); box-shadow: inset 2px 0 0 var(--cx-brand); }
.cx-field-menu-value { color: var(--cx-text-strong); flex-shrink: 0; }
.cx-field-menu-label {
    color: var(--cx-text-dim);
    font-family: var(--cx-font-body);
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.cx-import .field-row select { flex: 1; padding: 0.5rem 0.75rem; }
.cx-import .field-hint {
    font-size: 0.7rem;
    color: var(--cx-text);
    margin-bottom: 0.75rem;
    font-style: italic;
    padding-left: 128px;
}
.cx-import .field-hint:empty { display: none; }
.cx-import .btn-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin: 0.5rem 0 1.5rem;
}
.cx-import .imp-gap    { margin-top: 1.5rem; }
.cx-import .imp-gap-sm { margin-top: 1rem; }
.cx-import .imp-dim    { opacity: 0.6; }
.cx-import .imp-note   { font-size: 0.75rem; color: var(--cx-text-dim); line-height: 1.5; }

.cx-import .paste-area {
    width: 100%;
    min-height: 160px;
    box-sizing: border-box;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text);
    font-family: var(--cx-font-mono);
    font-size: 0.8rem;
    padding: 0.75rem;
    resize: vertical;
}
.cx-import .paste-area:focus { outline: none; border-color: var(--cx-brand); }
.cx-import .url-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}
.cx-import .url-row input {
    flex: 1;
    font-family: var(--cx-font-mono);
    font-size: 0.8rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    color: var(--cx-text);
    padding: 0.5rem 0.75rem;
}
.cx-import .url-row input:focus { outline: none; border-color: var(--cx-brand); }

/* Blocks that appear when there is something in them. */
.cx-import .imp-block,
.cx-import .report,
.cx-import .preview-wrap { display: none; }
.cx-import .imp-block.visible,
.cx-import .report.visible,
.cx-import .preview-wrap.visible { display: block; }
.cx-import .imp-block { margin-bottom: 1.5rem; }

.cx-import .download-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
    padding-left: 1.5rem;
    border-left: 1px solid var(--cx-border);
}
.cx-import .download-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--cx-text-mid);
}
.cx-import .actions { margin-bottom: 1.25rem; }

.cx-import .report {
    background: var(--cx-bg);
    border: 1px solid var(--cx-bg-high);
    margin-bottom: 1.5rem;
}
.cx-import .report-heading {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--cx-brand);
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--cx-bg-mid);
}
.cx-import .report-body { padding: 0.75rem 1rem; font-size: 0.8rem; line-height: 1.8; }
.cx-import .report-row {
    display: flex;
    gap: 1rem;
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--cx-bg-high);
}
.cx-import .report-row:last-child { border-bottom: none; }
.cx-import .report-field {
    font-family: var(--cx-font-mono);
    font-size: 0.75rem;
    color: var(--cx-text);
    width: 240px;
    flex-shrink: 0;
    overflow-wrap: anywhere;
}
.cx-import .report-value { color: var(--cx-text); }
.cx-import .report-value.warn { color: var(--cx-accent); }
.cx-import .report-empty { color: var(--cx-text); font-style: italic; padding: 0.3rem 0; }

.cx-import .preview-wrap { margin-bottom: 1.5rem; }
.cx-import .preview-heading {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--cx-brand);
    margin-bottom: 0.5rem;
}
.cx-import .preview-box {
    background: var(--cx-bg);
    border: 1px solid var(--cx-bg-high);
    padding: 1rem;
    font-family: var(--cx-font-mono);
    font-size: 0.72rem;
    color: var(--cx-text);
    max-height: 320px;
    overflow-y: auto;
    white-space: pre;
    line-height: 1.6;
}

/* Programme workbook */
.cx-import .meta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}
.cx-import .meta-table td { padding: 0.3rem 1rem; border-bottom: 1px solid var(--cx-bg-high); }
.cx-import .meta-table td:first-child { font-family: var(--cx-font-mono); color: var(--cx-text-dim); width: 140px; }
.cx-import .unit-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--cx-bg-high);
    font-size: 0.82rem;
}
.cx-import .unit-row:last-child { border-bottom: none; }
.cx-import .unit-name  { font-family: var(--cx-font-mono); color: var(--cx-text); flex: 1; }
.cx-import .unit-label { color: var(--cx-text-dim); font-size: 0.75rem; min-width: 160px; }
.cx-import .unit-exists {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cx-accent);
    border: 1px solid var(--cx-accent);
    padding: 0.1rem 0.4rem;
    flex: none;
}
.cx-import .unit-status { font-size: 0.75rem; color: var(--cx-text-dim); min-width: 80px; text-align: right; }
.cx-import .unit-status.ok   { color: var(--cx-ok); }
.cx-import .unit-status.err  { color: var(--cx-err); }
.cx-import .unit-status.warn { color: var(--cx-accent); }
.cx-import .unit-status.busy { color: var(--cx-brand); }

/* Media waiting to upload */
.cx-import .file-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 1rem;
    border-bottom: 1px solid var(--cx-bg-high);
    font-size: 0.82rem;
}
.cx-import .file-row:last-child { border-bottom: none; }
.cx-import .file-name {
    font-family: var(--cx-font-mono);
    color: var(--cx-text);
    flex: 1;
    word-break: break-all;
}
.cx-import .file-size {
    color: var(--cx-text-dim);
    font-size: 0.75rem;
    min-width: 70px;
    text-align: right;
}
.cx-import .file-status {
    font-size: 0.75rem;
    color: var(--cx-text-dim);
    min-width: 90px;
    text-align: right;
}
.cx-import .file-status.ok   { color: var(--cx-ok); }
.cx-import .file-status.err  { color: var(--cx-err); }
.cx-import .file-status.warn { color: var(--cx-accent); }
.cx-import .file-status.busy { color: var(--cx-brand); }
.cx-import .file-url {
    font-family: var(--cx-font-mono);
    font-size: 0.7rem;
    color: var(--cx-text-dim);
    cursor: pointer;
    min-width: 80px;
    text-align: right;
}
.cx-import .file-url:hover { color: var(--cx-brand); }

/* Audit: heading and count on one line, the filenames wrapping full width. */
.cx-import .imp-audit-group   { margin-bottom: 0.9rem; }
.cx-import .imp-audit-head    { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.82rem; }
.cx-import .imp-audit-head .n { font-family: var(--cx-font-mono); color: var(--cx-text-mid); }
.cx-import .imp-audit-head.miss { color: var(--cx-err); }
.cx-import .imp-audit-files {
    font-family: var(--cx-font-mono);
    font-size: 0.72rem;
    color: var(--cx-text-mid);
    line-height: 1.5;
    overflow-wrap: anywhere;
    margin-top: 0.15rem;
}
.cx-import .imp-audit-sub { padding-left: 1rem; }

/* One row per file wherever a file can be acted on. */
.cx-import .imp-file-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--cx-font-mono);
    font-size: 0.72rem;
    padding: 0.12rem 0;
    overflow-wrap: anywhere;
}
.cx-import .imp-file-row .nm  { flex: 1 1 auto; }
.cx-import .imp-file-row .tag { color: var(--cx-text-mid); font-size: 0.66rem; }
.cx-import .imp-file-row .st  { font-size: 0.66rem; color: var(--cx-text-mid); min-width: 5rem; text-align: right; }
.cx-import .imp-file-row .imp-play { flex: 0 0 auto; white-space: nowrap; }
.cx-import .imp-mini { font-size: 0.66rem; padding: 0.1rem 0.4rem; }
/* A column can hold hundreds of images: the list scrolls. */
.cx-import .imp-file-list { max-height: 20rem; overflow-y: auto; }

.cx-import .imp-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.4rem 0; }
.cx-import .imp-chip {
    font-family: var(--cx-font-mono);
    font-size: 0.68rem;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--cx-border-dim);
    border-radius: 0.8rem;
    cursor: pointer;
    background: none;
    color: var(--cx-text-mid);
}
.cx-import .imp-chip.on { color: var(--cx-text); border-color: var(--cx-text-mid); }
/* One faint box per folder, so the masters are never read as just another
   extension beside the delivery files. */
.cx-import .imp-chip-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--cx-border-dim);
    border-radius: 0.4rem;
    padding: 0.3rem 0.5rem;
}
.cx-import .imp-chip-box-label { font-size: 0.66rem; color: var(--cx-text-mid); margin-right: 0.2rem; }

.cx-import .imp-param-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.25rem 0; }
.cx-import .imp-param-row label { font-size: 0.75rem; color: var(--cx-text-mid); min-width: 11rem; }
.cx-import .imp-param-row input[type="number"] { width: 7rem; }
.cx-import .imp-proc-out {
    font-family: var(--cx-font-mono);
    font-size: 0.7rem;
    color: var(--cx-text-mid);
    line-height: 1.5;
    overflow-wrap: anywhere;
    margin-top: 0.3rem;
    white-space: pre-wrap;
}
.cx-import .imp-warn { color: var(--cx-accent); }

/* ── cx-user-admin (scoped) ── */
/* NOTE: .main below targets class="main", but the page uses <main data-cx="main">
   (no .main class) — this rule was dead in the original inline style too;
   preserved as-is rather than silently "fixed" during the lift. */
.cx-user-admin .main { display: flex; flex-direction: column; gap: 2.5rem; }

.cx-user-admin .cx-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--cx-border);
    background: var(--cx-surface);
}
.cx-user-admin .cx-table th {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
    padding: 0.5rem 0.85rem;
    text-align: left;
    background: var(--cx-bg-mid);
    border-bottom: 1px solid var(--cx-border);
    font-weight: 400;
}
.cx-user-admin .cx-table td {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--cx-border-dim);
    font-size: 0.88rem;
    color: var(--cx-text);
    vertical-align: middle;
}
.cx-user-admin .cx-table tr:last-child td { border-bottom: none; }
.cx-user-admin .cx-table tr:hover td { background: var(--cx-surface-mid); }

.cx-user-admin .role-pill {
    display: inline-block;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.15em 0.5em;
    border-radius: 2px;
}
.cx-user-admin .role-admin  { background: var(--cx-red-bg);  color: var(--cx-red-color); }
.cx-user-admin .role-client { background: var(--cx-bg-high); color: var(--cx-accent); }
.cx-user-admin .role-user   { background: var(--cx-bg-high); color: var(--cx-text-mid); }

.cx-user-admin .pending-pill {
    display: inline-block;
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.1em 0.45em;
    border: 1px solid var(--cx-border);
    color: var(--cx-text-dim);
    margin-left: 0.4rem;
}

.cx-user-admin .org-block {
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}
.cx-user-admin .org-block-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.cx-user-admin .org-slug { font-family: var(--cx-font-mono); font-size: 1rem; color: var(--cx-text-strong); }
.cx-user-admin .org-token { font-size: 0.78rem; color: var(--cx-text-dim); }

.cx-user-admin .cx-form {
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.cx-user-admin .form-heading {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
}

.cx-user-admin .admin-only { display: none; }
body.is-admin .cx-user-admin .admin-only { display: block; }

/* Accounts list — the All Accounts index and its row expander.
   The list is an index: the row carries only what is scanned, and the
   expander holds the fields, the history and the destructive actions. */
.cx-user-admin .acct-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.6rem;
}
.cx-user-admin .acct-toolbar input { flex: 0 1 22rem; }
.cx-user-admin .acct-count { font-size: 0.78rem; color: var(--cx-text-dim); }

.cx-user-admin th.sortable { cursor: pointer; user-select: none; }
.cx-user-admin th.sortable:hover { color: var(--cx-brand); }
.cx-user-admin th.sortable .arrow {
    opacity: 0.5;
    font-size: 0.75em;
    padding-left: 0.25em;
}

.cx-user-admin .acct-row { cursor: pointer; }
/* An open row and its detail row read as one block. */
.cx-user-admin .acct-row.open > td { border-bottom: none; }
.cx-user-admin .acct-caret { width: 1.6rem; padding-right: 0; }
.cx-user-admin .row-toggle {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.85em;
    line-height: 1;
    padding: 0.15rem 0.3rem;
}

.cx-user-admin .name-dim { color: var(--cx-text-dim); }
/* Admin is red in .role-admin above; the star follows it. */
.cx-user-admin .admin-star { color: var(--cx-red-color); }

.cx-user-admin .org-chip {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.05rem 0.4rem;
    margin: 0 0.25rem 0.15rem 0;
    border: 1px solid var(--cx-border-dim);
    border-radius: 1rem;
    white-space: nowrap;
}
.cx-user-admin .org-chip .chip-role { color: var(--cx-text-dim); }

.cx-user-admin .detail-row > td {
    background: var(--cx-surface-mid);
    padding: 1rem;
}
.cx-user-admin .detail-grid { display: flex; gap: 2rem; flex-wrap: wrap; }
.cx-user-admin .detail-col { flex: 1 1 22rem; min-width: 0; }
.cx-user-admin .detail-col textarea {
    width: 100%;
    font: inherit;
    font-size: 0.85rem;
}
.cx-user-admin .detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--cx-border-dim);
}
/* Delete sits apart from the two link actions, not beside them. */
.cx-user-admin .detail-actions .btn-danger { margin-left: auto; }
.cx-user-admin .detail-label {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cx-brand);
    margin: 0 0 0.3rem;
}
.cx-user-admin .detail-created { font-size: 0.8rem; margin-bottom: 1rem; }

.cx-user-admin .hist-list {
    font-size: 0.78rem;
    line-height: 1.5;
    max-height: 14rem;
    overflow: auto;
}
.cx-user-admin .hist-entry { padding: 0.1rem 0; }
.cx-user-admin .hist-when { color: var(--cx-text-dim); }

/* ── cx-org-index (scoped) ── */
.cx-org-index .pack-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0 3rem 2.5rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    padding: 0.75rem 1.25rem;
}
.cx-org-index .pack-bar label {
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
    white-space: nowrap;
}
.cx-org-index .pack-bar select {
    flex: 1;
    appearance: none;
    -webkit-appearance: none;
    background: var(--cx-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    color: var(--cx-text-strong);
    border: 1px solid var(--cx-border);
    padding: 0.4rem 2rem 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Section headings (org-index uses JS-built sections) */
.cx-org-index .cx-heading { margin-left: 0; margin-right: 0; }

/* Lives inside the shared header's #cx-tagline slot, not .cx-org-index —
   the header is appended directly to <body>, ahead of .cx-org-index. */
#cx-tagline .status-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--cx-font-mono);
    font-size: 0.72rem;
    color: var(--cx-text-dim);
}
#cx-tagline .status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cx-text-dim); flex: none; }
#cx-tagline .status-dot.active { background: var(--cx-ok); }

.cx-org-index .param-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--cx-surface);
    border-top: 1px solid var(--cx-border);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.6rem 1.5rem;
    flex-wrap: wrap;
}
.cx-org-index .param-bar label {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
    white-space: nowrap;
}
.cx-org-index .param-bar select,
.cx-org-index .param-bar input {
    appearance: none;
    -webkit-appearance: none;
    background: var(--cx-bg);
    color: var(--cx-text-strong);
    border: 1px solid var(--cx-border);
    padding: 0.3rem 0.5rem;
    font-family: inherit;
    font-size: 0.85rem;
}
.cx-org-index .param-bar select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.5rem;
    cursor: pointer;
}
.cx-org-index .param-bar input[type="number"] { width: 5rem; }
.cx-org-index .param-group { display: flex; align-items: center; gap: 0.4rem; }
.cx-org-index .param-bar .sim-note { font-size: 0.7rem; color: var(--cx-text-dim); font-style: italic; }

/* ── cx-login (scoped) ── */
.cx-login-wrap {
    width: 100%;
    max-width: 360px;
    margin: 2rem auto 4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.cx-login-note {
    display: none;
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: var(--cx-text-mid);
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius);
    padding: 0.5rem 0.75rem;
}
.cx-login-note.visible { display: block; }

.cx-login-card {
    width: 100%;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    padding: 1.75rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cx-login-heading {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--cx-text-dim);
    margin-bottom: 0.25rem;
}

.cx-login-error {
    font-size: 0.85rem;
    color: var(--cx-negative);
    background: var(--cx-bg);
    border: 1px solid var(--cx-negative-dim);
    padding: 0.4rem 0.65rem;
    border-radius: var(--cx-radius);
    display: none;
}
.cx-login-error.visible { display: block; }

.cx-login-submit {
    margin-top: 1.25rem;
    width: 100%;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
}
.cx-login-submit:active { transform: scale(0.98); }

.cx-login-reset-toggle {
    display: block;
    margin-top: 0.9rem;
    font-size: 0.78rem;
    color: var(--cx-text-dim);
    text-decoration: none;
    border-bottom: 1px solid var(--cx-border);
    width: fit-content;
}
.cx-login-reset-toggle:hover { color: var(--cx-text-mid); border-color: var(--cx-border-dim); }

.cx-login-reset {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--cx-border-dim);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.cx-login-reset[hidden] { display: none; }
.cx-login-reset-hint {
    font-size: 0.8rem;
    color: var(--cx-text-dim);
    margin: 0;
}

/* ── Drop zone ── */
.drop-zone {
    border: 1px dashed var(--cx-border);
    padding: 2.5rem 2rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 1.25rem;
    transition: border-color var(--cx-transition-mid), background var(--cx-transition-mid);
}
.drop-zone:hover,
.drop-zone.over,
.drop-zone.drag-over { border-color: var(--cx-brand); background: var(--cx-focus-bg); }
.drop-zone input { display: none; }
.drop-icon { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.4; }
.drop-label { font-size: 0.85rem; color: var(--cx-text); }
.drop-label strong { color: var(--cx-text); font-weight: 400; }

/* ── cx-tool main wrapper ── */
main.cx-tool { padding: 0 3rem; }
main.cx-tool > .row:first-of-type { margin-top: 1.5rem; }
.cx-lead { margin-bottom: 1.75rem; }

/* ── Summary (post-action result text) ── */
.summary {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--cx-text-dim);
    line-height: 1.6;
}
.summary code { color: var(--cx-text); }

/* ── Empty / loading states ── */
.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--cx-text-muted);
    font-size: 0.88rem;
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
}

.loading {
    color: var(--cx-text-dim);
    font-size: 0.85rem;
    padding: 1rem 0;
}

/* ── Footer ── */
.site-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--cx-text-dim);
    margin-top: 2rem;
}

/* ── Page index (built by cx-index.js buildPageIndex) ── */
.cx-section {
    margin: 0 0 2.5rem;
}

.cx-print-link {
    font-size: 0.7rem;
    letter-spacing: 0;
    text-transform: none;
    color: var(--cx-text-mid);
    text-decoration: none;
    transition: color var(--cx-transition-fast);
}
.cx-print-link:hover { color: var(--cx-brand); }

/* Pills */
.cx-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.cx-pill {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--cx-border-dim);
    background: var(--cx-surface);
    color: var(--cx-text-dim);
    cursor: pointer;
    transition: background var(--cx-transition-fast), color var(--cx-transition-fast);
    white-space: nowrap;
}
.cx-pill:hover { color: var(--cx-text); border-color: var(--cx-border); }
.cx-pill[data-active="true"] {
    background: var(--cx-focus-bg);
    color: var(--cx-text-strong);
    border-color: var(--cx-brand);
}

/* Tag chips on cards */
.cx-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.3rem;
}

.cx-tag {
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--cx-border-dim);
    color: var(--cx-text-muted);
    background: var(--cx-bg);
}

/* Card header row (title + QR thumb) */
.cx-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.cx-card-header .cx-card-title { flex: 1; }

/* QR thumbnail */
.cx-qr-wrap { position: relative; flex-shrink: 0; }

.cx-qr-thumb {
    width: 36px;
    height: 36px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity var(--cx-transition-fast);
    border: 1px solid var(--cx-border-dim);
    display: block;
    overflow: hidden;
}
.cx-qr-thumb canvas,
.cx-qr-thumb svg { width: 36px !important; height: 36px !important; }
.cx-qr-tooltip-inner canvas,
.cx-qr-tooltip-inner svg { width: 160px !important; height: 160px !important; }
#cx-qr-img canvas,
#cx-qr-img svg { width: 240px !important; height: 240px !important; }
.cx-qr-wrap:hover .cx-qr-thumb { opacity: 0.9; }

/* QR hover tooltip.
 *
 * The literals here and in the lightbox blocks below are deliberate and must not
 * become variables: a QR code needs a white quiet zone to scan, and the
 * screenshot lightbox shows a page thumbnail on a neutral card. Both are
 * physical requirements, not theme choices — which is why the text colours
 * inside them are literal too, and why they disable text-shadow. Each such
 * declaration is marked cx-colour-ok for the cx-csscheck colour rule. */
.cx-qr-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #fff; /* cx-colour-ok */
    padding: 0.5rem;
    border-radius: 4px;
    z-index: 100;
}
.cx-qr-tooltip img { display: block; width: 160px; height: 160px; }
.cx-qr-wrap:hover .cx-qr-tooltip { display: block; }

/* QR overlay */
.cx-qr-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
}
.cx-qr-overlay.active { display: flex; }

.cx-qr-box {
    background: #fff; /* cx-colour-ok */
    padding: 1.5rem;
    border-radius: 4px;
    text-align: center;
    max-width: 90vw;
}
.cx-qr-box img { display: block; width: 240px; height: 240px; }
.cx-qr-box-title {
    font-size: 0.85rem;
    color: #222; /* cx-colour-ok */
    margin-top: 0.75rem;
    font-family: sans-serif;
    text-shadow: none;
}
.cx-qr-box-url {
    font-size: 0.65rem;
    color: #666; /* cx-colour-ok */
    margin-top: 0.25rem;
    font-family: monospace;
    word-break: break-all;
    text-shadow: none;
}
.cx-qr-close {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #888; /* cx-colour-ok */
    cursor: pointer;
    font-family: sans-serif;
    text-shadow: none;
}

/* Screenshot thumbnail — same shape as the QR thumb/overlay above, for the
 * page-preview screenshot on each card. Hidden until the image is confirmed
 * to load (see cx-index.js) — no screenshot on disk means no thumb. */
.cx-shot-wrap { position: relative; flex-shrink: 0; }

.cx-shot-thumb {
    width: 36px;
    height: 36px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity var(--cx-transition-fast);
    border: 1px solid var(--cx-border-dim);
    display: block;
    object-fit: cover;
}
.cx-shot-wrap:hover .cx-shot-thumb { opacity: 0.9; }

.cx-shot-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
}
.cx-shot-overlay.active { display: flex; }

.cx-shot-box {
    background: #fff; /* cx-colour-ok */
    padding: 1.5rem;
    border-radius: 4px;
    text-align: center;
    max-width: 90vw;
}
.cx-shot-box img { display: block; max-width: 80vw; max-height: 70vh; }
.cx-shot-box-title {
    font-size: 0.85rem;
    color: #222; /* cx-colour-ok */
    margin-top: 0.75rem;
    font-family: sans-serif;
    text-shadow: none;
}
.cx-shot-close {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #888; /* cx-colour-ok */
    cursor: pointer;
    font-family: sans-serif;
    text-shadow: none;
}

/* ── cx-qr (scoped) ── */
/* The QR tool page: a URL textarea, a toolbar and a grid of generated codes. */

.cx-qr .url-input {
    width: 100%;
    min-height: 9rem;
    box-sizing: border-box;
    resize: vertical;
    padding: 0.75rem;
    background: var(--cx-bg-high);
    color: var(--cx-text);
    border: 1px solid var(--cx-border);
    font-family: var(--cx-font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
}

.cx-qr .qr-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--cx-text-dim);
}

/* Column width is set by the 200px preview plus its pad and border, so a
   code never has to shrink or wrap out of its card. */
.cx-qr .qr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 1.75rem;
}

.cx-qr .qr-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    min-width: 0;
}

/* Literal white, like the thumbnail and lightbox blocks above: a QR needs a
   white quiet zone to scan, which is a physical requirement and not a theme
   choice. cx-colour-ok. Shrink-to-fit so the pad hugs the code. */
.cx-qr .qr-preview {
    display: inline-block;
    background: #fff; /* cx-colour-ok */
    padding: 0.5rem;
    border: 1px solid var(--cx-border-dim);
    line-height: 0;
}

.cx-qr .qr-url {
    width: 100%;
    font-family: var(--cx-font-mono);
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--cx-text-dim);
    word-break: break-all;
}

.cx-qr .qr-name {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.5rem;
    background: var(--cx-bg-high);
    color: var(--cx-text);
    border: 1px solid var(--cx-border);
    font-family: var(--cx-font-mono);
    font-size: 0.75rem;
}

.cx-qr .qr-err {
    font-size: 0.75rem;
    color: var(--cx-warn);
}

/* A render failure shows in place of the code, on the white ground above,
   where the theme's own text colours cannot be relied on. cx-colour-ok. */
.cx-qr .qr-preview .qr-err {
    padding: 2rem 1rem;
    color: #a33; /* cx-colour-ok */
    font-family: sans-serif;
    line-height: 1.4;
    text-shadow: none;
}
