/* === Admin Panel === */
:root {
    --brand-red: #8B5CF6;
    --dark-red: #7C3AED;
    --bg-dark: #12121f;
    --bg-sidebar: #1a1a2e;
    --bg-card: #1e1e32;
    --bg-input: #252540;
    --text-light: #e2e2ef;
    --text-muted: #8888a0;
    --white: #FFFFFF;
    --border-color: #2d2d44;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;

    /* --- Shell metrics & surface tokens ---------------------------------
       Everything below is additive: no existing variable changed meaning,
       so the ~47 views that hard-code `var(--bg-card)` etc. are untouched.
       New rules prefer these so spacing/radii stay consistent across the
       panel instead of being re-guessed per view. */
    --sidebar-w: 248px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-1: 0 1px 2px rgba(0,0,0,0.25);
    --shadow-2: 0 6px 22px -8px rgba(0,0,0,0.55);
    --bg-hover: rgba(255,255,255,0.045);
    --bg-subtle: rgba(255,255,255,0.02);
    --border-soft: rgba(255,255,255,0.07);
    --ring: 0 0 0 3px color-mix(in srgb, var(--brand-red) 30%, transparent);
    --content-max: 1440px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.admin-body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Keyboard users get a visible ring everywhere; mouse users never see it. */
.admin-body :focus-visible {
    outline: 2px solid var(--brand-red);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.admin-sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.admin-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 18px;
    height: 60px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border-color);
}

.admin-logo a {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text-light);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    text-decoration: none;
}

/* Home shortcut beside the wordmark — opens the live site. `a.` because
   .admin-logo a above is the wordmark's own styling. */
.admin-logo a.admin-logo-site {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.admin-logo a.admin-logo-site:hover,
.admin-logo a.admin-logo-site:focus-visible {
    color: #fff;
    background: var(--brand-red);
    border-color: var(--brand-red);
}
.admin-logo-site svg { width: 15px; height: 15px; }

/* Small brand tile so the wordmark has an anchor instead of floating. */
.admin-logo-mark {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--brand-red), var(--brand-secondary, var(--dark-red)));
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

/* --- Nav filter: type to narrow 35+ links down to the one you want. --- */
.admin-nav-search {
    position: relative;
    padding: 12px 14px 8px;
    flex: 0 0 auto;
}
.admin-nav-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.admin-nav-search input::placeholder { color: #5c5c78; }
.admin-nav-search input:focus {
    border-color: var(--brand-red);
    box-shadow: var(--ring);
}
.admin-nav-search svg {
    position: absolute;
    left: 24px;
    top: 50%;
    /* The wrapper's padding is asymmetric (12 top / 8 bottom), so centring
       on the wrapper lands 2px high relative to the input itself. */
    transform: translateY(-50%);
    margin-top: 2px;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    padding: 4px 10px 16px;
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}
.admin-nav::-webkit-scrollbar { width: 6px; }
.admin-nav::-webkit-scrollbar-track { background: transparent; }
.admin-nav::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.admin-nav::-webkit-scrollbar-thumb:hover { background: #3d3d5c; }

.admin-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.3;
    transition: background 0.15s, color 0.15s;
}

.admin-nav a svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.admin-nav a:hover {
    background: var(--bg-hover);
    color: var(--text-light);
}
.admin-nav a:hover svg { opacity: 1; }

.admin-nav a.active {
    /* Fallback first — without it, a browser lacking color-mix() leaves the
       active item with no highlight at all. */
    background: var(--bg-card);
    background: color-mix(in srgb, var(--brand-red) 16%, transparent);
    color: var(--white);
    font-weight: 600;
}
.admin-nav a.active svg { opacity: 1; color: var(--brand-red); }

/* Left accent marker on the active item — replaces the old full-height
   border so it reads as a pill rather than a table row. */
.admin-nav a.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-red);
}

.admin-nav-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 10px 2px;
}

/* --- Collapsible groups ------------------------------------------------
   The group header is a real <button> so it is keyboard reachable; the
   open/closed state is persisted in localStorage by admin-chrome.js. */
.admin-nav-group { margin-top: 10px; }
.admin-nav-group:first-of-type { margin-top: 2px; }

.admin-nav-label,
button.admin-nav-label {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px 5px;
    background: none;
    border: 0;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}
button.admin-nav-label:hover { color: var(--text-light); background: var(--bg-hover); }

.admin-nav-label .chev {
    display: inline-flex;
    margin-left: auto;
    opacity: 0.6;
    transition: transform 0.18s ease;
}
.admin-nav-group.is-collapsed .admin-nav-label .chev { transform: rotate(-90deg); }
.admin-nav-group.is-collapsed .admin-nav-group-items { display: none; }

/* A collapsed group that still holds the current page gets a dot, so the
   panel never hides where you actually are. */
.admin-nav-group.is-collapsed.has-active .admin-nav-label::after {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-red);
}

/* Filter mode: groups are force-opened and non-matches hidden. */
.admin-nav.is-filtering .admin-nav-group.is-collapsed .admin-nav-group-items { display: block; }
.admin-nav.is-filtering .admin-nav-divider { display: none; }
.admin-nav a.is-hidden,
.admin-nav-group.is-hidden { display: none; }

.admin-nav-empty {
    display: none;
    padding: 14px 10px;
    color: var(--text-muted);
    font-size: 12.5px;
    text-align: center;
}
.admin-nav.is-empty .admin-nav-empty { display: block; }

/* Count/notification pill inside a nav item. */
.admin-nav-badge {
    flex: 0 0 auto;
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}
.admin-nav-badge.is-quiet {
    background: rgba(148,163,184,0.22);
    color: var(--text-muted);
    font-weight: 600;
}

/* ============================================================
   MAIN COLUMN
   ============================================================ */
.admin-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

/* Sticky so the page title and its actions stay reachable on long lists. */
.admin-header {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 30px;
    min-height: 60px;
    border-bottom: 1px solid var(--border-color);
    /* Opaque first. A browser without color-mix() drops the second
       declaration, and a sticky header with no background would let the page
       scroll visibly through it. */
    background: var(--bg-sidebar);
    background: color-mix(in srgb, var(--bg-sidebar) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.admin-header-titles { min-width: 0; flex: 1; }

.admin-header h1 {
    font-size: 19px;
    font-weight: 650;
    letter-spacing: -0.3px;
    color: var(--white);
    line-height: 1.25;
}

/* Breadcrumb — shows where a nested screen sits without a back-button hunt. */
.admin-crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 2px;
    font-size: 11.5px;
    color: var(--text-muted);
}
.admin-crumbs a { color: var(--text-muted); text-decoration: none; transition: color 0.15s; }
.admin-crumbs a:hover { color: var(--brand-red); }
.admin-crumbs .sep { opacity: 0.45; }

.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

/* "View site" — pinned to the far end of the header on every admin screen. */
.admin-header-site {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    margin-left: auto;
}
/* A pill in the brand colour rather than the quiet ghost button it was:
   as a ghost it read as part of the page's own actions and was missed.
   Scoped under .admin-header-site because .btn-admin is declared further
   down this file and would otherwise win on order alone. */
.admin-header-site .admin-site-btn {
    border-radius: 999px;
    padding: 7px 14px;
    color: var(--text-light);
    border-color: var(--brand-red);
    /* Opaque first; a browser without color-mix() keeps this one. */
    background: var(--bg-input);
    background: color-mix(in srgb, var(--brand-red) 16%, var(--bg-input));
}
.admin-header-site .admin-site-btn:hover,
.admin-header-site .admin-site-btn:focus-visible { background: var(--brand-red); color: #fff; }
.admin-header-site .btn-admin svg:last-child { width: 12px; height: 12px; opacity: 0.6; }
.admin-header-site .btn-admin:hover svg:last-child { opacity: 1; }
@media (max-width: 640px) {
    /* Icon only on phones; the title attribute still names it. */
    .admin-header-site-label,
    .admin-header-site .btn-admin svg:last-child { display: none; }
}

.admin-content {
    width: 100%;
    max-width: var(--content-max);
    padding: 24px 30px 60px;
    flex: 1;
}

/* Section heading used between blocks on a page. */
.admin-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 26px 0 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}
.admin-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* ============================================================
   CARDS
   ============================================================ */
.admin-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-1);
}

.admin-card > h3 {
    font-size: 14.5px;
    font-weight: 650;
    color: var(--white);
    letter-spacing: -0.1px;
}

/* Optional header strip for cards that need a title + action row. */
.admin-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -20px -20px 16px;
    padding: 13px 20px;
    border-bottom: 1px solid var(--border-color);
}
.admin-card-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; color: var(--white); }

/* ============================================================
   DASHBOARD STATS
   ============================================================ */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 20px;
    text-align: left;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-1);
    transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
/* Only the clickable variants lift, so hover means "this does something". */
a.stat-card, .stat-card[onclick] { cursor: pointer; text-decoration: none; display: block; }
a.stat-card:hover, .stat-card[onclick]:hover {
    border-color: color-mix(in srgb, var(--brand-red) 55%, var(--border-color));
    transform: translateY(-2px);
    box-shadow: var(--shadow-2);
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -1px;
    color: var(--white);
}

.stat-card .stat-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    margin-top: 6px;
}
.stat-card .stat-label svg { width: 14px; height: 14px; color: var(--brand-red); }

/* ============================================================
   TABLES
   ============================================================ */
/* NOTE: no `overflow: hidden` here — it would make the table its own scroll
   container and silently break the sticky `th` below. The corners are
   rounded on the edge cells instead. */
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}

.admin-table th,
.admin-table td {
    padding: 11px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.admin-table th {
    position: sticky;
    /* --header-h is measured and set by admin-chrome.js so the column
       headers park directly under the sticky page header whatever its
       height (a breadcrumb line makes it taller). */
    top: var(--header-h, 60px);
    z-index: 5;
    background: #21213a;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    white-space: nowrap;
}

.admin-table thead tr:first-child th:first-child { border-top-left-radius: var(--radius); }
.admin-table thead tr:first-child th:last-child { border-top-right-radius: var(--radius); }
.admin-table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.admin-table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }

.admin-table td {
    font-size: 13.5px;
}

.admin-table tbody tr:last-child td { border-bottom: 0; }

.admin-table tbody tr { transition: background 0.12s; }
.admin-table tbody tr:hover td { background: var(--bg-subtle); }

/* Row actions stay out of the way until the row is hovered or focused,
   which cuts most of the visual noise from a dense list. */
.admin-table .actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    opacity: 0.55;
    transition: opacity 0.15s;
}
/* On a <td> the flex above turned the cell into a flex box, so it stopped
   sizing with its row: on any row taller than one line (a name with a second
   line under it) the actions cell, its border and its hover background sat
   out of line with the rest of the row. Keep the cell a table cell and space
   the buttons with margins instead. */
.admin-table td.actions { display: table-cell; text-align: right; white-space: nowrap; vertical-align: middle; }
.admin-table td.actions > * { vertical-align: middle; }
.admin-table td.actions > * + * { margin-left: 6px; }
.admin-table tbody tr:hover .actions,
.admin-table tbody tr:focus-within .actions { opacity: 1; }
@media (hover: none) {
    .admin-table .actions { opacity: 1; }
}

/* Wrap a wide table in this so it scrolls itself instead of the page. */
.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
}

/* Friendly zero-state for lists. */
.admin-empty {
    padding: 46px 20px;
    text-align: center;
    color: var(--text-muted);
}
.admin-empty svg { width: 30px; height: 30px; opacity: 0.35; margin-bottom: 10px; }
.admin-empty h4 { font-size: 14px; font-weight: 600; color: var(--text-light); margin-bottom: 4px; }
.admin-empty p { font-size: 13px; margin-bottom: 14px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-admin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 550;
    line-height: 1.3;
    cursor: pointer;
    border: 1px solid transparent;
    color: var(--white);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, filter 0.15s, transform 0.05s;
}
.btn-admin svg { width: 15px; height: 15px; }
.btn-admin:active { transform: translateY(1px); }
.btn-admin:disabled, .btn-admin.is-disabled { opacity: 0.5; pointer-events: none; }

.btn-admin-primary {
    background: var(--brand-red);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.btn-admin-primary:hover {
    background: var(--dark-red);
}

.btn-admin-secondary {
    background: var(--bg-input);
    color: var(--text-light);
    border-color: var(--border-color);
}

.btn-admin-secondary:hover {
    background: #2f2f52;
    border-color: #3d3d5c;
}

/* Quiet variant for low-stakes actions in dense rows. */
.btn-admin-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-color);
}
.btn-admin-ghost:hover { background: var(--bg-hover); color: var(--text-light); }

.btn-admin-danger {
    background: var(--danger);
}

.btn-admin-danger:hover {
    background: #c82333;
}

.btn-admin-success {
    background: var(--success);
}
.btn-admin-success:hover { background: #218838; }

.btn-admin-builder {
    background: #6366f1;
}

.btn-admin-builder:hover {
    background: #4f46e5;
}

.btn-sm,
.btn-admin-sm {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: 5px;
}
.btn-sm svg,
.btn-admin-sm svg { width: 13px; height: 13px; }

/* A button given no colour variant used to render as bare text: .btn-admin
   alone has no background and a transparent border. Give it the secondary
   look. :where() keeps this at the specificity of .btn-admin itself, so any
   page's own styling of its buttons still wins. */
.btn-admin:where(:not(.btn-admin-primary, .btn-admin-secondary, .btn-admin-ghost,
                      .btn-admin-danger, .btn-admin-success, .btn-admin-builder)) {
    background: var(--bg-input);
    color: var(--text-light);
    border-color: var(--border-color);
}
.btn-admin:where(:not(.btn-admin-primary, .btn-admin-secondary, .btn-admin-ghost,
                      .btn-admin-danger, .btn-admin-success, .btn-admin-builder)):hover {
    background: #2f2f52;
    border-color: #3d3d5c;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-light);
    font-size: 13px;
    font-weight: 550;
}

/* Hint text under a label or field — saves a tooltip hunt. */
.form-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group input[type="datetime-local"],
.form-group input[type="search"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: #5c5c78; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--brand-red);
    box-shadow: var(--ring);
}
/* The generic ring above already marks focus; suppress the doubled outline. */
.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible { outline: none; }

.form-group textarea {
    min-height: 200px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 15px;
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Sticky save bar so long edit forms never need a scroll-to-bottom. */
.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

/* Filter chips (All / Published / Drafts …) on list screens. */
.admin-filters {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 3px;
    margin-bottom: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: fit-content;
}
.admin-filters a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 550;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.admin-filters a:hover { background: var(--bg-hover); color: var(--text-light); }
/* Fallback first: with no background, the selected filter would be
   indistinguishable from the others and you couldn't tell what you're viewing. */
.admin-filters a.is-active { background: var(--bg-input); background: color-mix(in srgb, var(--brand-red) 20%, transparent); color: var(--white); }
.admin-filters a .count { opacity: 0.6; font-variant-numeric: tabular-nums; }

/* Shared list-screen toolbar (search + count + New). Its layout used to be
   inline styles inside the partial; the search box now has an icon and an
   inline clear affordance instead of a stray “×” button floating after it. */
.admin-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.admin-list-search { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.admin-list-search-field { position: relative; flex: 1; display: flex; align-items: center; }
.admin-list-search-field > svg {
    position: absolute;
    left: 11px;
    color: var(--text-muted);
    pointer-events: none;
}
.admin-list-search-field input {
    width: 100%;
    padding: 8px 32px 8px 34px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.admin-list-search-field input::placeholder { color: #5c5c78; }
/* type="search" draws its own clear button, which appears exactly when the
   custom one does and lands on top of it. */
.admin-list-search-field input::-webkit-search-cancel-button { display: none; }
.admin-list-search-field input:focus { border-color: var(--brand-red); box-shadow: var(--ring); }
.admin-list-search-field input:focus-visible { outline: none; }
.admin-list-search-clear {
    position: absolute;
    right: 8px;
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    line-height: 1;
}
.admin-list-search-clear:hover { background: var(--bg-hover); color: var(--text-light); }

.admin-list-count {
    color: var(--text-muted);
    font-size: 12.5px;
    white-space: nowrap;
}
.admin-list-count strong { color: var(--text-light); font-variant-numeric: tabular-nums; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1.5;
    border: 1px solid transparent;
}

/* A badge with no colour of its own (28 places) used to be bare text. */
.badge:where(:not([class*="badge-"])) { background: rgba(148,163,184,0.15); color: var(--text-light); border-color: var(--border-color); }
.badge-publish,
.badge-success { background: rgba(40,167,69,0.16); color: #4ade80; border-color: rgba(40,167,69,0.3); }
.badge-draft { background: rgba(255,193,7,0.14); color: #fcd34d; border-color: rgba(255,193,7,0.28); }
.badge-neutral { background: rgba(148,163,184,0.15); color: var(--text-muted); border-color: var(--border-color); }

/* ============================================================
   AUTH PAGES — sign in, 2FA, forgot password, reset password.

   All four used to carry their own markup and their own styling: login had
   an inline <style> block, forgot/reset shared a bare centred card, and the
   2FA page was a standalone slab of hard-coded hex that never loaded this
   stylesheet at all (and shipped without a doctype, so it rendered in quirks
   mode with no mobile viewport). One shell now serves all of them —
   views/admin/partials/auth-head.php + auth-foot.php.

   --auth-brand / --auth-brand-2 are written inline by auth-head.php from the
   site's configured brand colours, so this file never has to know them.
   ============================================================ */
.auth-body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    -webkit-font-smoothing: antialiased;
}

.auth-shell {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    min-height: 100vh;
}
.auth-shell.is-solo { grid-template-columns: 1fr; }

/* ---- Brand panel ---- */
.auth-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    overflow: hidden;
    background: var(--bg-sidebar);
}
.auth-shell.is-solo .auth-hero { display: none; }

/* Default (no image): a soft two-tone wash off the brand colours, with a
   grid overlay so a flat gradient doesn't read as an unstyled page. */
.auth-hero-art {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(80% 60% at 15% 15%, var(--auth-brand) 0%, transparent 60%),
        radial-gradient(70% 70% at 85% 80%, var(--auth-brand-2) 0%, transparent 55%),
        var(--bg-sidebar);
    opacity: 0.9;
}
.auth-hero-art::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(70% 70% at 50% 40%, #000 30%, transparent 100%);
    -webkit-mask-image: radial-gradient(70% 70% at 50% 40%, #000 30%, transparent 100%);
}
/* Image variant — the art layer becomes the photo plus a scrim so white
   text stays legible whatever was uploaded. */
.auth-hero-art.has-image {
    background-size: cover;
    background-position: center;
    opacity: 1;
}
.auth-hero-art.has-image::after {
    background-image: none;
    background: linear-gradient(180deg, rgba(10,10,20,0.35) 0%, rgba(10,10,20,0.85) 100%);
    mask-image: none;
    -webkit-mask-image: none;
}

.auth-hero-top,
.auth-hero-bottom { position: relative; z-index: 1; }

.auth-hero-mark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.2px;
    text-decoration: none;
}
.auth-hero-mark img { max-height: 34px; max-width: 160px; display: block; }

.auth-hero-bottom h2 {
    margin: 0 0 10px;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 700;
    color: #fff;
    max-width: 15ch;
}
.auth-hero-bottom p {
    margin: 0;
    max-width: 46ch;
    font-size: 14px;
    line-height: 1.65;
    color: rgba(255,255,255,0.82);
}

/* ---- Form side ---- */
.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 28px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
}
.auth-card-logo {
    margin-bottom: 22px;
    text-align: center;
}
.auth-card-logo img { max-height: 42px; max-width: 190px; }

.auth-card h1 {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text-light);
}
.auth-card .auth-sub {
    margin: 0 0 26px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-muted);
}

.auth-field { margin-bottom: 16px; }
.auth-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}
.auth-field input,
.auth-field textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-light);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-field input::placeholder,
.auth-field textarea::placeholder { color: #5c5c78; }
.auth-field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.auth-field input:focus,
.auth-field textarea:focus {
    border-color: var(--auth-brand);
    /* colour-mix keeps the ring tied to the brand colour without needing a
       second variable; browsers without it just get the border change. */
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-brand) 28%, transparent);
}

/* Password field with a reveal toggle. */
.auth-field-pw { position: relative; }
.auth-field-pw input { padding-right: 46px; }
.auth-pw-toggle {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}
.auth-pw-toggle:hover { color: var(--text-light); background: rgba(255,255,255,0.05); }
.auth-pw-toggle svg { width: 17px; height: 17px; }
.auth-pw-toggle .icon-off { display: none; }
.auth-pw-toggle.is-on .icon-on { display: none; }
.auth-pw-toggle.is-on .icon-off { display: block; }

.auth-submit {
    width: 100%;
    padding: 12px 16px;
    margin-top: 4px;
    border: 0;
    border-radius: 8px;
    background: var(--auth-brand);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s, transform 0.05s;
}
.auth-submit:hover { filter: brightness(1.12); }
.auth-submit:active { transform: translateY(1px); }
.auth-submit:focus-visible {
    outline: 2px solid var(--auth-brand);
    outline-offset: 2px;
}

/* ---- Messages ---- */
.auth-note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 13px;
    margin-bottom: 18px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid transparent;
}
.auth-note svg { flex: 0 0 auto; width: 16px; height: 16px; margin-top: 1px; }
.auth-note-error   { background: rgba(220,53,69,0.12);  border-color: rgba(220,53,69,0.35);  color: #f2909b; }
.auth-note-success { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.35); color: #6ee7b7; }
.auth-note-warn    { background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.35); color: #fcd34d; word-break: break-word; }

.auth-caps {
    display: none;
    margin: 8px 0 0;
    font-size: 12px;
    color: #fcd34d;
}
.auth-caps.is-on { display: block; }

/* ---- Single sign-on: Discord button, divider, hint ---- */
/* Discord's own blurple rather than the site brand colour: people scan for
   the colour they know before they read the label, and a button that says
   Discord in someone else's purple reads as a phishing page. */
.auth-discord {
    display: block;
    background: #5865F2;
    text-align: center;
    text-decoration: none;
    margin-bottom: 4px;
}
.auth-discord:hover { filter: brightness(1.12); }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-hint {
    margin: 16px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
}
.auth-hint a { color: inherit; text-decoration: underline; }

/* ---- Account page: several forms stacked in the same card ---- */
.auth-section {
    margin: 32px 0 6px;
    padding-top: 22px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.auth-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 8px; }

.auth-sessions {
    list-style: none;
    margin: 12px 0 16px;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}
.auth-sessions li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.auth-sessions li:last-child { border-bottom: 0; }
.auth-sessions em { font-style: normal; color: #6ee7b7; }
.auth-dim { color: var(--text-muted); font-size: 12px; }

/* ---- Footer links ---- */
.auth-links {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}
.auth-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.auth-links a:hover { color: var(--auth-brand); text-decoration: underline; }

/* ---- One-time code (2FA) ---- */
.auth-code {
    width: 100%;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-light);
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 24px;
    letter-spacing: 10px;
    text-indent: 10px;   /* re-centres text that letter-spacing pushes left */
    text-align: center;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-code:focus {
    border-color: var(--auth-brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-brand) 28%, transparent);
}

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}
/* Phones. 16px fields, because iOS zooms the whole page into any field smaller
   than that the moment it is tapped, and leaves it zoomed after. And the links
   under the form become thumb-sized: "Forgot your password?" was an 18px-tall
   strip of text, which is exactly the link somebody locked out is trying to hit. */
@media (max-width: 768px) {
    .auth-field input,
    .auth-field textarea,
    .auth-field select { font-size: 16px; }
    .auth-links a { display: inline-block; padding: 12px 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .auth-submit, .auth-field input, .auth-links a { transition: none; }
}

/* Legacy aliases — pages or add-ons still using the old class names get the
   new look rather than an unstyled box. */
.login-page { background: var(--bg-dark); }
.login-box  { width: 100%; max-width: 400px; margin: 0 auto; }

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.media-item {
    background: var(--bg-card);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s;
}

.media-item:hover {
    border-color: var(--brand-red);
}

.media-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.media-item-info {
    padding: 8px;
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
}

.media-item .actions {
    padding: 5px 8px 8px;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.upload-area:hover {
    border-color: var(--brand-red);
}

.upload-area p {
    color: var(--text-muted);
}

/* ======================= */
/* TinyMCE Dark Theme      */
/* ======================= */
.tox-tinymce { border: 1px solid var(--border-color) !important; border-radius: 5px !important; }
.tox .tox-toolbar__primary { background: var(--bg-sidebar) !important; }
.tox .tox-statusbar { background: var(--bg-sidebar) !important; border-top-color: var(--border-color) !important; }
.tox .tox-statusbar__text-container { color: var(--text-muted) !important; }

/* ======================= */
/* Settings Tabs           */
/* ======================= */
.settings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 25px;
}

.settings-tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    font-family: inherit;
}

.settings-tab-btn:hover {
    color: var(--text-light);
    background: var(--bg-card);
}

.settings-tab-btn.active {
    color: var(--brand-red);
    border-bottom-color: var(--brand-red);
}

.settings-tab-panel {
    display: none;
}

#tab-general {
    display: block;
}

/* ======================= */
/* Color Picker            */
/* ======================= */
.color-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input-group input[type="color"] {
    width: 42px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--bg-input);
    cursor: pointer;
}

.color-input-group input[type="text"] {
    flex: 1;
}

/* ======================= */
/* Hero Image Manager      */
/* ======================= */
.hero-images-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    min-height: 80px;
    padding: 10px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
}

.hero-img-item {
    position: relative;
    width: 120px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    cursor: grab;
    transition: border-color 0.2s;
}

.hero-img-item:hover {
    border-color: var(--brand-red);
}

.hero-img-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-img-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ======================= */
/* Media Modal             */
/* ======================= */
.media-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-modal {
    background: var(--bg-card);
    border-radius: 10px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.media-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.media-modal-header h3 {
    color: var(--white);
    margin: 0;
    font-size: 18px;
}

.media-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
}

.media-modal-close:hover {
    color: var(--white);
}

.media-modal-upload-bar {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.media-modal-upload-bar input[type="file"] {
    display: none;
}

.media-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

.media-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.media-modal-item {
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s;
}

.media-modal-item:hover {
    border-color: var(--text-muted);
}

.media-modal-item.selected {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 1px var(--brand-red);
}

.media-modal-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}

.media-modal-file {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    word-break: break-all;
}

.media-modal-name {
    padding: 5px 8px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}

/* ======================= */
/* Image Picker Preview    */
/* ======================= */
.image-picker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.image-picker-preview {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
}

/* ======================= */
/* Admin Flash Messages    */
/* ======================= */
.admin-flash {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    transition: opacity 0.3s;
}

.admin-flash-success {
    background: rgba(40,167,69,0.15);
    color: var(--success);
    border: 1px solid rgba(40,167,69,0.3);
}

.admin-flash-error {
    background: rgba(220,53,69,0.15);
    color: var(--danger);
    border: 1px solid rgba(220,53,69,0.3);
}

/* The layout's own flash strip. Previously each one carried a block of
   inline styles built in PHP; these classes replace that so the colours
   live in one place and the dismiss button has something to hook onto. */
.pcms-flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    margin-bottom: 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    line-height: 1.5;
    animation: pcms-flash-in 0.25s ease both;
}
@keyframes pcms-flash-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
}
.pcms-flash svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.pcms-flash-text { flex: 1; min-width: 0; }
.pcms-flash-close {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: none;
    color: inherit;
    opacity: 0.6;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
}
.pcms-flash-close:hover { opacity: 1; background: rgba(255,255,255,0.08); }

.pcms-flash-success { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.35); color: #6ee7b7; }
.pcms-flash-error   { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.35);  color: #f2909b; }
.pcms-flash-info    { background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.35); color: #a5b4fc; }
.pcms-flash.is-leaving { opacity: 0; transition: opacity 0.25s, transform 0.25s; transform: translateY(-4px); }

/* ============================================================
   SETTINGS SHELL — Settings, and any other long configuration screen.

   The problem this solves: Settings is 26 cards across 4 tabs, every one of
   them expanded, so finding "Discord OAuth" meant picking the right tab and
   then scrolling past eleven unrelated panels. The tabs are still the top-level
   grouping, but they now feed a rail: one click to any section, one section on
   screen at a time, and a filter box for when you don't know which tab it's under.

   Visual language is lifted from the auth screens (auth-head.php + the AUTH
   block above) — same brand wash, same 13px/600 labels, same focus ring — so
   the panel stops looking like a different product from its own login page.

   The markup is assembled at runtime by assets/js/admin-settings.js from the
   cards the view already renders, so a new <div class="admin-card"><h3> in
   settings.php joins the rail with no wiring.
   ============================================================ */
.set-shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

/* ---- Sticky command bar: filter + save, always reachable ----
   --set-top is measured from the real header height by admin-settings.js;
   the fallback keeps the bar sane if the script hasn't run yet. */
.set-topbar {
    position: sticky;
    top: var(--header-h, 60px);
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--bg-card) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
}
.set-search {
    position: relative;
    flex: 1;
    min-width: 0;
}
.set-search svg {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    pointer-events: none;
}
.set-search input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.set-search input::placeholder { color: #5c5c78; }
.set-search input:focus {
    border-color: var(--brand-red);
    box-shadow: var(--ring);
}
.set-topbar .btn-admin { flex: 0 0 auto; }
/* Nothing matched the filter — said once, in the bar, instead of leaving a
   blank stage with no explanation. */
.set-empty {
    display: none;
    padding: 26px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* ---- Section rail ---- */
.set-rail {
    position: sticky;
    top: calc(var(--header-h, 60px) + 74px);
    align-self: start;
    max-height: calc(100vh - var(--header-h, 60px) - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}
.set-rail-group {
    margin: 12px 0 5px;
    padding: 0 9px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.set-rail-group:first-child { margin-top: 3px; }

.set-rail-item {
    position: relative;
    display: block;
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 1px;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.set-rail-item:hover { background: var(--bg-hover); color: var(--text-light); }
.set-rail-item.is-active {
    background: color-mix(in srgb, var(--brand-red) 16%, transparent);
    color: var(--white);
    font-weight: 600;
}
/* The same 2px brand marker the main nav uses for its active row. */
.set-rail-item.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 2px;
    border-radius: 0 2px 2px 0;
    background: var(--brand-red);
}
.set-rail-item[hidden] { display: none; }

/* ---- Stage ---- */
.set-stage { min-width: 0; }
.set-sec { display: none; }
.set-sec.is-active { display: block; }

/* The card keeps its own chrome; what changes is the head, which now runs edge
   to edge and carries the section title instead of a bare red <h3>. The card
   gives up its padding to .set-body, which admin-settings.js wraps around
   everything below the heading. */
.set-sec .admin-card { padding: 0; }

/* …except the "these settings are not being used" banner, which is an
   .admin-card only so it inherits the card's border and radius. It has no
   heading and so no head band to give its padding to; stripping it would
   leave the text pressed against the amber rule. */
.set-sec .admin-card.cp-overridden { padding: 12px 16px; }

.set-sec .admin-card > h3 {
    position: relative;
    margin: 0;
    padding: 16px 22px 14px;
    /* A whisper of the auth hero's brand wash, so the panel reads as the same
       product as the sign-in screen without shouting. Rounded to match the
       card rather than clipped with overflow:hidden, which would cut off a
       focus ring on the first field. */
    background:
        radial-gradient(120% 180% at 0% 0%, color-mix(in srgb, var(--brand-red) 13%, transparent) 0%, transparent 70%),
        var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.25px;
    color: var(--white);
}
/* The same head band when the title arrives with an action beside it — the
   "View page ↗" links on Design > Blog & Docs Pages. Painted identically to
   the bare <h3> above; what differs is that the band, not the heading, owns
   the padding, so the button can sit flush against its right edge. */
.set-sec .admin-card > .cp-card-head {
    margin: 0;
    padding: 11px 16px 10px 22px;
    background:
        radial-gradient(120% 180% at 0% 0%, color-mix(in srgb, var(--brand-red) 13%, transparent) 0%, transparent 70%),
        var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius) var(--radius) 0 0;
}

.set-sec .admin-card > .cp-card-head h3 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.25px;
    color: var(--white);
}

.set-sec .set-body { padding: 18px 22px 20px; }

/* A card's own intro paragraph becomes the section's subtitle. Both selectors
   earn their keep: .set-intro is what settings.php now marks up, and the
   positional one catches any card that grows an intro without the class. */
.set-intro,
.set-sec .set-body > p:first-child {
    margin-top: 0 !important;
    margin-bottom: 16px !important;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
}
.set-intro code {
    padding: 1px 5px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
}
.set-sec .set-body > *:last-child { margin-bottom: 0 !important; }

/* Denser field rhythm than the old page: the two-column rows stay, but the
   gutters and the label-to-input gap come down, which is most of what made
   26 panels feel like a mile of scrolling. */
.set-sec .form-row { gap: 16px; }
.set-sec .form-group { margin-bottom: 15px; }
.set-sec .form-group label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}
.set-sec .form-group input[type="text"],
.set-sec .form-group input[type="email"],
.set-sec .form-group input[type="password"],
.set-sec .form-group input[type="number"],
.set-sec .form-group input[type="url"],
.set-sec .form-group select,
.set-sec .form-group textarea { padding: 10px 13px; }
.set-sec .form-group textarea { min-height: 120px; }
/* Code-ish fields still want the room. */
.set-sec .form-group textarea[name="custom_css"],
.set-sec .form-group textarea[name="custom_head_code"],
.set-sec .form-group textarea[name="custom_footer_code"] { min-height: 220px; font-family: Consolas, Menlo, monospace; font-size: 12.5px; }

/* The old inline `style="color:var(--text-muted);font-size:11px"` hints are
   now class-driven and one step larger, because 11px grey on dark was the
   least readable text on the page. */
.set-sec small,
.set-sec .form-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

/* Sub-headings inside a section (Typography Scale, Button Preset, Role Sync…). */
.set-sec h4 {
    margin: 22px 0 12px !important;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
}
.set-sec .form-row + h4 { margin-top: 18px !important; }

/* A filtered-out field dims rather than vanishes, so the row it lived in
   doesn't reflow and lose your place. */
.set-sec .form-group.is-dim { opacity: 0.28; }
.set-sec .form-group.is-hit label { color: var(--brand-red); }

@media (max-width: 980px) {
    .set-shell { grid-template-columns: 1fr; }
    .set-rail {
        position: static;
        max-height: none;
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 7px;
    }
    .set-rail-group { display: none; }
    .set-rail-item { width: auto; white-space: nowrap; flex: 0 0 auto; }
    .set-rail-item.is-active::before { display: none; }
}

/* Mobile nav toggle (hidden on desktop) */
.admin-mobile-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 1100; width: 40px; height: 40px; background: var(--bg-card, #1e1e32); border: 1px solid var(--border-color, #2d2d44); border-radius: var(--radius-sm); padding: 0; cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.admin-mobile-toggle span { display: block; width: 20px; height: 2px; background: var(--text-light, #e0e0e0); border-radius: 2px; transition: transform 0.25s, opacity 0.25s; }
.admin-nav-backdrop { display: none; }

/* Responsive */
@media (max-width: 1100px) {
    .admin-header,
    .admin-content { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 768px) {
    .admin-mobile-toggle { display: flex; }
    .admin-sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 260px; z-index: 1050;
        transform: translateX(-100%); transition: transform 0.3s ease; box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    }
    .admin-nav-open .admin-sidebar { transform: translateX(0); }
    .admin-nav-open .admin-nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1040; }
    .admin-nav-open .admin-mobile-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .admin-nav-open .admin-mobile-toggle span:nth-child(2) { opacity: 0; }
    .admin-nav-open .admin-mobile-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
    /* (The old `.admin-nav a span { display: inline }` override lived here to
       un-hide labels from a collapsed-icon mode that no longer exists. It now
       only broke the flex layout and the label ellipsis, so it's gone.) */
    .admin-main { margin-left: 0; padding-top: 0; }
    .admin-header { padding-left: 62px; position: sticky; }
    .admin-table th { top: 0; }
    .form-row { grid-template-columns: 1fr; }
    .admin-toolbar { flex-wrap: wrap; gap: 8px; }
    .admin-stats { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    /* Row actions can't rely on hover on touch, and a 4-button row would
       overflow — let the table scroll itself instead. */
    .admin-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
    .admin-nav a, .btn-admin, .stat-card, .admin-nav-label .chev, .pcms-flash { transition: none; animation: none; }
}

/* =========================================================
   Post editor â€” action bar, content card, featured image,
   gallery picker, taxonomy boxes, save bar.
   ========================================================= */

.pcms-post-actionbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.pcms-post-actionbar-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pcms-post-permalink {
    font-family: Consolas, Menlo, monospace;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-dark);
    padding: 3px 8px;
    border-radius: 4px;
}

.pcms-post-actionbar-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pcms-post-draft-note {
    margin: -6px 0 16px;
    padding: 10px 14px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 6px;
    color: #fbbf24;
    font-size: 13px;
    line-height: 1.6;
}

.pcms-field-hint {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 12px;
}

/* ---- slug field with its /post/ prefix inline ---- */
.pcms-slug-field {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.pcms-slug-field > span {
    padding: 0 2px 0 10px;
    color: var(--text-muted);
    font-family: Consolas, Menlo, monospace;
    font-size: 13px;
    white-space: nowrap;
}

.pcms-slug-field input {
    border: none !important;
    background: transparent !important;
    flex: 1;
    min-width: 0;
}

/* ---- content card ---- */
.pcms-content-head,
.pcms-gallery-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.pcms-format-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px;
    flex-shrink: 0;
}

.pcms-format-toggle label {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    margin: 0;
    user-select: none;
}

.pcms-format-toggle label.is-active {
    background: var(--brand-color, #8B5CF6);
    color: #fff;
}

.pcms-format-toggle input {
    display: none;
}

.pcms-content-inserts {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.pcms-content-inserts-hint {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: auto;
}

/* ---- featured image ---- */
.pcms-featured-picker {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.pcms-featured-preview img {
    max-height: 110px;
    max-width: 200px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: block;
    background: var(--bg-dark);
}

.pcms-featured-placeholder {
    width: 180px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12px;
    background: var(--bg-dark);
}

.pcms-featured-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- gallery picker ---- */
.pcms-gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 20px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    background: var(--bg-dark);
}

.pcms-gallery-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.pcms-gallery-tile {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    cursor: grab;
    transition: border-color 0.15s, opacity 0.15s;
}

.pcms-gallery-tile.is-dragging {
    opacity: 0.4;
}

.pcms-gallery-tile.is-drop-target {
    border-color: var(--brand-color, #8B5CF6);
    box-shadow: 0 0 0 1px var(--brand-color, #8B5CF6);
}

.pcms-gallery-thumb {
    position: relative;
    border-radius: 5px;
    overflow: hidden;
    background: var(--bg-darker, #12121f);
}

.pcms-gallery-thumb img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.pcms-gallery-pos {
    position: absolute;
    top: 6px;
    left: 6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcms-gallery-caption-input {
    width: 100%;
    margin-top: 8px;
    padding: 6px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-light);
    font-size: 12px;
}

.pcms-gallery-tile-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.pcms-gallery-tile-actions button {
    flex: 1;
    padding: 4px 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.pcms-gallery-tile-actions button:hover {
    color: var(--text-light);
    border-color: var(--brand-color, #8B5CF6);
}

.pcms-gallery-tile-actions .pcms-gallery-remove:hover {
    color: #f87171;
    border-color: #f87171;
}

.pcms-gallery-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.pcms-gallery-foot label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12px;
    margin: 0;
}

.pcms-gallery-foot select {
    width: auto;
    padding: 5px 8px;
    font-size: 12px;
}

.pcms-gallery-count {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: auto;
}

/* ---- taxonomy boxes ---- */
.pcms-tax-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.pcms-tax-box {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
}

.pcms-tax-box h4 {
    margin: 0 0 10px;
    color: var(--text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pcms-tax-list {
    max-height: 190px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.pcms-tax-empty {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    padding: 6px 0;
}

/* Checkbox rendered as a togglable chip â€” reads faster than a column
   of checkboxes when a site has a dozen categories. */
.pcms-tax-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    margin: 0;
    user-select: none;
}

.pcms-tax-item:hover {
    border-color: var(--brand-color, #8B5CF6);
}

.pcms-tax-item:has(input:checked) {
    background: color-mix(in srgb, var(--brand-color, #8B5CF6) 18%, transparent);
    border-color: var(--brand-color, #8B5CF6);
    color: var(--text-light);
}

.pcms-tax-add {
    display: flex;
    gap: 6px;
}

.pcms-tax-add input {
    flex: 1;
    min-width: 0;
    padding: 6px 9px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    border-radius: 4px;
    font-size: 12px;
}

/* ---- sticky save bar ---- */
.pcms-save-bar {
    position: sticky;
    bottom: 0;
    margin-top: 18px;
    padding: 12px 0;
    background: linear-gradient(to top, var(--bg-dark) 70%, transparent);
    z-index: 20;
}

.pcms-save-bar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.pcms-save-bar-hint {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: auto;
}

/* ---- media modal multi-select ---- */
.media-modal-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.media-modal-count {
    color: var(--text-muted);
    font-size: 12px;
    margin-right: auto;
    align-self: center;
}

.media-modal-item {
    position: relative;
}

.media-modal-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(0, 0, 0, 0.45);
    display: none;
}

.media-modal.is-multiple .media-modal-check {
    display: block;
}

.media-modal-item.selected .media-modal-check {
    background: var(--brand-color, #8B5CF6);
    border-color: #fff;
}

/* Checkmark glyph, drawn rather than shipped as an icon font. */
.media-modal-item.selected .media-modal-check::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

@media (max-width: 640px) {
    .pcms-save-bar-hint,
    .pcms-content-inserts-hint {
        display: none;
    }
}

/* =========================================================
   "Add a block" bar on the post editor
   ========================================================= */

.pcms-content-inserts {
    display: block;
}

.pcms-inserts-label {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.pcms-inserts-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pcms-insert-btn {
    padding: 6px 11px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-light);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.pcms-insert-btn:hover {
    border-color: var(--brand-color, #8B5CF6);
    background: color-mix(in srgb, var(--brand-color, #8B5CF6) 14%, var(--bg-input));
}

.pcms-insert-sep {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    margin: 0 3px;
}

.pcms-inserts-hint {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.65;
}

.pcms-inserts-hint strong {
    color: var(--text-light);
    font-weight: 600;
}

/* =========================================================
   Blog & Docs Pages screen
   ========================================================= */

.cp-intro {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.7;
    max-width: 760px;
}

.cp-intro code,
.cp-hint code {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: Consolas, Menlo, monospace;
    font-size: 11.5px;
    color: var(--text-light);
}

.cp-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.cp-card-head h3 {
    margin: 0;
}

.cp-hint {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.6;
}

.cp-note {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.65;
}

/* Same voice, but introducing a card rather than closing one — so no rule
   above it and no top gap. */
.admin-card > h3 + .cp-note {
    margin: 0 0 16px;
    padding-top: 0;
    border-top: none;
}

/* Delete affordance on a media picker tile. Hidden until the tile is
   hovered or something inside it is focused, so the grid still reads as a
   grid of images rather than a grid of controls — but reachable by keyboard,
   which a hover-only control would not be. */
.media-modal-item { position: relative; }

.media-modal-del {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 2;
    width: 22px;
    height: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 18, 0.82);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 6px;
    color: #e2e2ef;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .14s, background .14s, border-color .14s;
}

.media-modal-item:hover .media-modal-del,
.media-modal-del:focus-visible { opacity: 1; }

.media-modal-del:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.media-modal-del:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--brand-color);
}

/* No hover on touch, so the control would never appear. */
@media (hover: none) {
    .media-modal-del { opacity: 1; }
}

/* "These settings are not being used." Amber rather than red: nothing is
   broken and nothing was lost — the page is just being rendered by something
   else, which is a choice the admin made and can unmake. */
.cp-overridden {
    border-left: 3px solid #F59E0B;
    background: color-mix(in srgb, #F59E0B 9%, transparent);
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 18px;
}

.cp-overridden strong { color: #FCD34D; }
.cp-overridden a { color: var(--brand-color); font-weight: 600; white-space: nowrap; }

/* ---- Ready-made colour sets ----
   A row of buttons, each showing the palette it applies rather than naming
   it and hoping. The swatches overlap slightly so four of them read as one
   object at this size instead of four unrelated squares. */
.cp-palettes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 0;
}

.cp-palette {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 7px 13px 7px 9px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.cp-palette:hover {
    border-color: var(--brand-color, #8B5CF6);
    color: var(--text-light);
}

.cp-palette.is-applied {
    color: var(--text-light);
    border-color: color-mix(in srgb, var(--brand-color, #8B5CF6) 60%, transparent);
    background: color-mix(in srgb, var(--brand-color, #8B5CF6) 12%, var(--bg-dark));
}

.cp-palette-swatches { display: inline-flex; }

.cp-palette-swatches i {
    display: block;
    width: 15px;
    height: 15px;
    border-radius: 4px;
    /* A ring rather than a border: on the near-black swatches a border would
       be the only thing visible, and on the near-white ones nothing at all. */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.cp-palette-swatches i + i { margin-left: -5px; }

.cp-palette-clear { padding-left: 13px; }

@media (prefers-reduced-motion: reduce) {
    .cp-palette { transition: none; }
}

/* Divider inside a long settings card. The docs palette is twelve pickers;
   flat, it reads as a wall, and these are the four things it is actually
   about. */
.cp-subhead {
    margin: 22px 0 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.9px;
    text-transform: uppercase;
}

.admin-card > .cp-subhead:first-of-type { margin-top: 4px; }

.cp-subhead + .cp-hint code,
.cp-note code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--bg-input);
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.92em;
}

.cp-toggles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 8px;
}

.cp-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    margin: 0;
    user-select: none;
    transition: border-color 0.15s, color 0.15s;
}

.cp-toggle:hover {
    border-color: var(--brand-color, #8B5CF6);
}

.cp-toggle:has(input:checked) {
    color: var(--text-light);
    border-color: color-mix(in srgb, var(--brand-color, #8B5CF6) 55%, transparent);
    background: color-mix(in srgb, var(--brand-color, #8B5CF6) 10%, var(--bg-dark));
}

.cp-toggle input {
    flex-shrink: 0;
    margin: 0;
}

/* =========================================================
   Per-doc layout panel (views/admin/partials/doc-layout-panel)
   ========================================================= */

.dl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.dl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.dl-row-label {
    color: var(--text-light);
    font-size: 13px;
    min-width: 0;
}

/* Three-way control: Default / Show / Hide. Default carries a small note
   saying what the site setting currently is, so choosing it is informed. */
.dl-tri {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.dl-tri label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
    user-select: none;
    white-space: nowrap;
}

.dl-tri label.is-active {
    background: var(--brand-color, #8B5CF6);
    color: #fff;
}

.dl-tri input {
    display: none;
}

.dl-tri-hint {
    opacity: 0.65;
    font-size: 10px;
    font-weight: 400;
}

.dl-extras {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 700px) {
    .dl-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Doc badge in the admin docs list. The class is shared with the public
   docs template, but the admin layout only loads admin.css — so without
   this the badge rendered as unstyled inline text. */
.admin-table .doc-title-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--brand-color, #8B5CF6);
    color: #fff;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    vertical-align: middle;
}

/* =========================================================
   Progressive disclosure — settings that stay available but
   out of the way. Used by the Blog & Docs Pages screen and
   the per-document layout panel.
   ========================================================= */

.cp-advanced {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.cp-advanced > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    user-select: none;
}

.cp-advanced > summary::-webkit-details-marker { display: none; }

/* Border-drawn chevron: rotates when the section opens. */
.cp-advanced > summary::before {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.18s ease;
}

.cp-advanced[open] > summary::before { transform: rotate(45deg); }
.cp-advanced > summary:hover { color: var(--text-light); }
.cp-advanced-body { padding-top: 14px; }

/* ---- per-document panel header ---- */
.dl-panel > summary {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.dl-panel > summary::-webkit-details-marker { display: none; }

.dl-summary-title {
    color: var(--brand-red);
    font-size: 15px;
    font-weight: 600;
}

.dl-summary-state {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11.5px;
}

/* A document that differs from the site defaults says so at a glance,
   without needing the panel open. */
.dl-summary-state.is-custom {
    background: color-mix(in srgb, var(--brand-color, #8B5CF6) 16%, transparent);
    border-color: color-mix(in srgb, var(--brand-color, #8B5CF6) 45%, transparent);
    color: var(--text-light);
}

@media (prefers-reduced-motion: reduce) {
    .cp-advanced > summary::before { transition: none; }
}

/* Colour row on the Blog & Docs Pages screen: swatch, hex, and a Clear that
   returns the setting to "inherit". */
.color-input-group .cp-color-clear {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Live preview on the Blog & Docs Pages screen: the real /updates or /docs
   in a frame, laid out at desktop width and scaled down to fit (the script
   in content-pages.php sets the scale). Sticky while small, so it stays in
   view as you work down twenty colour fields; the card background behind it
   keeps the fields from showing through as they scroll under. */
.cp-preview {
    position: sticky;
    top: calc(var(--header-h, 60px) + 74px);
    z-index: 6;
    margin: 0 0 18px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.6);
}
.cp-preview.is-big,
.cp-preview.is-collapsed { position: static; }

.cp-preview-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    font-size: 12px;
}
/* Buttons on the first line, the note on its own line under them: in a
   ~540px column the note beside the buttons pushed Hide onto a line alone. */
.cp-preview-bar small {
    order: 5;
    flex-basis: 100%;
    color: var(--text-muted);
    font-size: 11.5px;
}
.cp-preview-size { margin-left: auto; }
.cp-preview-bar > button,
.cp-preview-seg button {
    flex-shrink: 0;
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-light);
    font-size: 11.5px;
    cursor: pointer;
}
.cp-preview-seg { display: inline-flex; }
.cp-preview-seg button { border-radius: 0; }
.cp-preview-seg button:first-child { border-radius: 6px 0 0 6px; }
.cp-preview-seg button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.cp-preview-seg button.is-on {
    background: color-mix(in srgb, var(--brand-color, #8B5CF6) 22%, var(--bg-input));
    border-color: color-mix(in srgb, var(--brand-color, #8B5CF6) 55%, var(--border-color));
}
.cp-preview-seg button:disabled { opacity: .45; cursor: default; }

.cp-preview-stage {
    position: relative;
    height: 280px;
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
}
.cp-preview.is-big .cp-preview-stage { height: 560px; }
.cp-preview.is-collapsed .cp-preview-stage { display: none; }
.cp-preview.is-collapsed .cp-preview-seg,
.cp-preview.is-collapsed .cp-preview-size { display: none; }

/* 1200px wide to match the script's VIRTUAL_W; the script sets the
   transform and the matching height. */
.cp-preview-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 1200px;
    height: 100%;
    border: 0;
    transform-origin: 0 0;
    background: transparent;
}
.cp-preview-msg {
    position: absolute;
    inset: auto 8px 8px 8px;
    z-index: 1;
    margin: 0;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 11.5px;
}

@media (max-width: 560px) {
    .cp-preview { position: static; }
    .cp-preview-bar small { display: none; }
    .cp-preview-stage { height: 220px; }
}

/* =========================================================
   Design > Blog & Docs Pages > Theme
   ========================================================= */
.cp-legacy-only[hidden],
.cp-theme-only[hidden] { display: none !important; }

.cp-head-links { display: inline-flex; gap: 6px; }

.cp-theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    margin: 4px 0 22px;
}

.cp-theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.cp-theme-card:hover { border-color: color-mix(in srgb, var(--brand-red) 50%, var(--border-color)); transform: translateY(-1px); }
.cp-theme-card.is-on,
.cp-theme-card:has(input:checked) {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-red) 28%, transparent);
}
.cp-theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.cp-theme-card:focus-within { outline: 2px solid var(--brand-red); outline-offset: 2px; }
.cp-theme-card strong { margin-top: 6px; color: var(--text-light); font-size: 13.5px; }
.cp-theme-card small { color: var(--text-muted); font-size: 11.5px; line-height: 1.4; }

/* A tiny drawing of each theme: header bar, rule, three cards. */
.cp-theme-thumb {
    display: flex;
    flex-direction: column;
    gap: 6px;
    height: 92px;
    padding: 12px;
    border-radius: 10px;
    background: radial-gradient(70% 60% at 50% 0%, color-mix(in srgb, var(--brand-red) 22%, transparent), transparent 70%), #12141b;
    overflow: hidden;
}
.cp-theme-thumb .t-head { width: 58%; height: 9px; margin: 4px auto 0; border-radius: 3px; background: #e9eaf0; }
.cp-theme-thumb .t-line { width: 38%; height: 4px; margin: 0 auto 4px; border-radius: 2px; background: #6b7080; }
.cp-theme-thumb .t-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; flex: 1; }
.cp-theme-thumb .t-cards i { border-radius: 6px; background: #1d2029; border: 1px solid #2c303c; }

.cp-theme-thumb[data-t="soft"] .t-cards i { border-color: transparent; background: #232733; border-radius: 9px; box-shadow: 0 4px 10px -4px #000; }
.cp-theme-thumb[data-t="outline"] { background: #12141b; }
.cp-theme-thumb[data-t="outline"] .t-cards i { background: transparent; border-color: #3a3f4d; border-radius: 3px; }
.cp-theme-thumb[data-t="bold"] { background: radial-gradient(60% 70% at 20% 0%, color-mix(in srgb, var(--brand-red) 45%, transparent), transparent 70%), radial-gradient(50% 70% at 90% 0%, #3b82f655, transparent 70%), #12141b; }
.cp-theme-thumb[data-t="bold"] .t-head { width: 74%; height: 13px; background: linear-gradient(90deg, #fff, color-mix(in srgb, var(--brand-red) 60%, #fff)); }
.cp-theme-thumb[data-t="legacy"] { background: repeating-linear-gradient(135deg, #171925 0 8px, #1b1d2a 8px 16px); }
.cp-theme-thumb[data-t="legacy"] .t-cards i { opacity: 0.55; }

.cp-theme-opts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 4px 22px;
    align-items: start;
}

.cp-seg {
    display: inline-flex;
    flex-wrap: wrap;
    padding: 3px;
    gap: 2px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 9px;
}
.cp-seg label { margin: 0; cursor: pointer; }
.cp-seg input { position: absolute; opacity: 0; pointer-events: none; }
.cp-seg span {
    display: block;
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}
.cp-seg label:hover span { color: var(--text-light); }
.cp-seg input:checked + span { background: var(--brand-red); color: #fff; }
.cp-seg input:focus-visible + span { outline: 2px solid var(--brand-red); outline-offset: 1px; }

.cp-theme-previews {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 14px;
    margin-top: 16px;
}
.cp-theme-previews .cp-preview { margin: 0; }

@media (prefers-reduced-motion: reduce) {
    .cp-theme-card, .cp-seg span { transition: none; }
    .cp-theme-card:hover { transform: none; }
}

/* ---- Syndication: receive from other sites ---- */
.syn-receive { padding: 18px 20px; margin-bottom: 24px; }
.syn-receive-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.syn-receive-head h2 { margin: 0; font-size: 16px; }
.syn-receive-intro { color: var(--text-muted); margin: 0 0 14px; line-height: 1.5; font-size: 13px; }
.syn-receive-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 18px; }
.syn-copy { display: flex; gap: 6px; }
.syn-copy input { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.syn-receive-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin-top: 6px; }
.syn-receive-actions { margin-left: auto; display: inline-flex; gap: 8px; }
.syn-receive-log { margin-top: 14px; }
.syn-receive-log summary { cursor: pointer; color: var(--text-muted); font-size: 13px; }
.syn-receive-log .admin-table { margin: 10px 0 0; }

.cp-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.cp-swatch {
    width: 24px; height: 24px; padding: 0;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    background: var(--sw, var(--bg-dark));
    box-shadow: 0 0 0 1px var(--border-color);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}
.cp-swatch:hover { transform: scale(1.12); }
.cp-swatch.is-on { box-shadow: 0 0 0 2px var(--text-light); }
.cp-swatch.is-brand {
    width: auto; padding: 0 9px; border-radius: 999px;
    color: var(--text-muted); font: inherit; font-size: 11px; font-weight: 600;
}
/* Keep each option row on one line: a wrapped segmented control reads as two. */
.cp-theme-opts { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.cp-seg { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; }
.cp-seg span { padding: 6px 10px; white-space: nowrap; }
