:root {
    --bg: #f4f5f7;
    --dots: #d8dce3;
    --surface: #fff;
    --field: #f3f4f6;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-text: #fff;
    --purple-soft: #f3e8ff;
    --purple: #9333ea;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --ok: #16a34a;
    --ok-soft: #ecfdf3;
    --warn: #d97706;
    --radius: 6px;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --dots: #22262e;
        --surface: #171a20;
        --field: #1f232b;
        --text: #e8eaee;
        --muted: #9aa1ad;
        --border: #2a2f39;
        --accent: #3b82f6;
        --purple-soft: #261a36;
        --purple: #c084fc;
        --danger: #f87171;
        --danger-soft: #2a1515;
        --ok: #4ade80;
        --ok-soft: #12261a;
        color-scheme: dark;
    }
}


/* Derived from --accent, so a user's accent colour (theme.css) recolours everything. */
:root {
    --accent-hover: color-mix(in srgb, var(--accent) 82%, #000);
    --accent-soft: color-mix(in srgb, var(--accent) 11%, var(--surface));
    --accent-ring: color-mix(in srgb, var(--accent) 25%, transparent);
}

* { box-sizing: border-box; }
body {
    margin: 0; color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg) radial-gradient(var(--dots) 1px, transparent 1px) 0 0 / 18px 18px;
    min-height: 100vh;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; }
code, .mono { font-family: var(--mono); font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.center { text-align: center; }
.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

/* Shell: sidebar + content */
.shell { display: grid; grid-template-columns: var(--sidebar-w, 264px) minmax(0, 1fr); min-height: 100vh; }
/* Full-bleed: screens fill the window edge to edge; sections are separated by lines, not gaps. */
.content { padding: 0; display: flex; flex-direction: column; gap: 0; min-width: 0; min-height: 100vh; }
.content > .card, .content .page-head { border-radius: 0; border-width: 0 0 1px; }
.content .card-head { border-radius: 0; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; color: var(--text); text-decoration: none; }
.logo-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-text); }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 14px 20px; border-bottom: 1px solid var(--border); }
.sidebar-toggle { width: 32px; height: 32px; color: var(--muted); }
.site-initial { display: none; }

/* Collapsed sidebar: icon rail, labels become tooltips (title="") */
.shell { transition: grid-template-columns .2s ease; }
.shell.collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.collapsed .sidebar .label, .collapsed .nav-filter, .collapsed .count { display: none; }
.collapsed .sidebar-head { flex-direction: column; padding: 14px 0; }
.collapsed .sidebar-nav { padding: 12px 8px; align-items: center; }
.collapsed .nav-label { height: 1px; margin: 10px 4px; background: var(--border); width: 32px; }
.collapsed .nav-label:first-child { display: none; }
.collapsed .nav-item, .collapsed .nav-site { justify-content: center; padding: 9px; width: 40px; }
.collapsed .site-list { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.collapsed .nav-site { display: grid; place-items: center; }
.collapsed .site-initial { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--field); font-weight: 700; font-size: .8rem; color: var(--muted); }
.collapsed .site-initial.on { color: var(--text); }
.collapsed .nav-site.open .site-initial { background: var(--accent); color: var(--accent-text); }
.collapsed .subnav { margin: 2px 0 6px; padding: 0; border-left: 0; align-items: center; }
.collapsed .sidebar-foot { flex-direction: column; padding: 12px 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 16px 8px 6px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.nav-label:first-child { margin-top: 4px; }
.nav-item, .nav-site { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 500; }
.nav-item .icon { color: var(--muted); }
.nav-item:hover, .nav-site:hover { background: var(--field); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.active .icon { color: var(--accent); }
.count { margin-left: auto; font-size: .75rem; color: var(--muted); }
.nav-filter { display: flex; align-items: center; gap: 8px; margin: 6px 0; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--field); color: var(--muted); }
.nav-filter input { border: 0; background: none; padding: 7px 0; box-shadow: none; }
.site-list { list-style: none; margin: 4px 0 0; padding: 0; }
.nav-site { font-size: .9rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }
.nav-site.open { font-weight: 700; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--border); margin-right: 10px; vertical-align: 1px; }
.status-dot.on { background: var(--ok); }
.subnav { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 8px 13px; padding-left: 10px; border-left: 1px solid var(--border); }
.subnav .nav-item { padding: 6px 10px; font-size: .9rem; }
.sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.sidebar-foot .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.sidebar-foot .icon-btn { width: 32px; height: 32px; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; }
.user-cell { display: inline-flex; align-items: center; gap: 10px; }
.field.inline { flex-direction: row; align-items: center; gap: 12px; }
.field.inline input { width: 240px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; gap: 16px; padding: 16px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.card-head.sticky { position: sticky; top: 0; z-index: 2; }
.card-title { flex: 1; min-width: 0; }
.card-title h1, .card-title h2 { font-size: .95rem; font-weight: 600; }
.card-title p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title p .icon { width: 13px; height: 13px; vertical-align: -2px; }
.card-head > .icon-btn:first-child { margin-right: 4px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px; border-top: 1px solid var(--border); }
.card > .card-foot:only-child { border-top: 0; }
.card-foot p { margin: 0; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.icon-tile { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); }

.columns { display: grid; grid-template-columns: 1fr 1fr; }
.column { padding: 20px 16px; }
.column + .column { border-left: 1px solid var(--border); }
.section { padding: 20px 16px; }
.section + .section { border-top: 1px solid var(--border); }
.step { display: flex; align-items: center; gap: 10px; font-size: .95rem; font-weight: 600; margin-bottom: 16px; }
.step > span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; }

/* Buttons */
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; padding: 9px 16px; border-radius: var(--radius); cursor: pointer; text-decoration: none;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover, .button:hover { border-color: #c7ccd4; }
button:disabled { opacity: .35; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.danger { color: var(--danger); }
.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.block-btn { width: 100%; padding: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.icon-btn:hover { border-color: #c7ccd4; }

/* Forms */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-weight: 600; font-size: .85rem; }
.field > span small { font-weight: 400; color: var(--muted); }
.field > small { color: var(--muted); font-size: .8rem; }
input, textarea, select {
    font: inherit; width: 100%; padding: 10px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--field); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-ring); }
textarea { resize: vertical; }
.switches { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 16px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin-top: 16px; }
.switches .switch { margin-top: 0; }
.switch input { appearance: none; width: 36px; height: 20px; padding: 0; border-radius: 99px; background: var(--border); border: 0; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }

/* Banners */
.banner { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.banner p { margin: 6px 0 0; }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.banner-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); }
.banner.error { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.banner.error .banner-icon { background: var(--danger-soft); color: var(--danger); }
.banner.error strong { display: block; margin-top: 6px; }
.banner.inset { margin: 16px 16px 0; background: var(--accent-soft); border-color: transparent; }
.banner.inset .banner-icon { background: var(--surface); color: var(--accent); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--accent); color: var(--accent-text); text-align: left; font-weight: 600; padding: 14px 16px; }
.table td { padding: 14px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tr:first-child td { border-top: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 50%, transparent); }
.table td small { display: block; color: var(--muted); }
.row-link { font-weight: 600; color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--accent); }
.legend { margin: 0; padding: 12px 16px; border-top: 1px solid var(--border); font-size: .8rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.legend .pill:not(:first-child) { margin-left: 12px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: .75rem; font-weight: 600; text-decoration: none; background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; }
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.missing { background: none; border: 1px dashed var(--border); color: var(--muted); }
.langs { display: flex; gap: 4px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.status.on { color: var(--ok); }
.status.on::before { background: var(--ok); }

.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 48px 16px; text-align: center; }
.empty .icon { width: 28px; height: 28px; color: var(--accent); margin-bottom: 8px; }
.empty p { margin: 0; }

/* Language tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--radius); font-weight: 600; font-size: .85rem; text-decoration: none; color: var(--text); border: 1px solid var(--border); }
.tab:hover { border-color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tab.missing:not(.active) { border-style: dashed; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .6; }
.dot.on { background: var(--ok); border-color: var(--ok); opacity: 1; }
.dot.draft { border-color: var(--warn); opacity: 1; }
.tab.active .dot.on { background: var(--accent-text); border-color: var(--accent-text); }

/* Blocks */
.block { border: 1px solid var(--border); border-radius: var(--radius); padding: 0 16px 16px; margin: 0 0 12px; scroll-margin-top: 90px; min-width: 0; }
.block-head { display: flex; align-items: center; gap: 10px; padding: 12px 0; margin-bottom: 4px; }
.block-head strong { flex: 1; }
.block-num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 5px; background: var(--purple-soft); color: var(--purple); font-size: .8rem; font-weight: 700; }
.block-actions { display: flex; gap: 6px; }
.block-actions .icon-btn { width: 32px; height: 32px; }
.add-block { display: flex; gap: 8px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius); }
.add-block select { width: auto; flex: 1; max-width: 320px; }

/* Page editor + preview */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.preview { position: sticky; top: 16px; overflow: hidden; }
.preview iframe { display: block; width: 100%; height: calc(100vh - 104px); border: 0; background: #fff; }

/* Sign in */
.auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-hero {
    display: flex; flex-direction: column; justify-content: space-between; padding: 56px; color: #fff;
    background-color: var(--accent);
    background-image: linear-gradient(rgb(255 255 255 / .06) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / .06) 1px, transparent 1px);
    background-size: 28px 28px;
}
.auth-hero .logo { color: #fff; }
.auth-hero .logo-mark { background: rgb(255 255 255 / .18); }
.auth-hero h1 { font-size: 2.2rem; line-height: 1.2; letter-spacing: -.02em; max-width: 480px; }
.auth-hero p { font-size: 1.05rem; max-width: 460px; opacity: .9; }
.auth-features { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.auth-features li { display: flex; align-items: center; gap: 10px; }
.auth-form { display: grid; place-items: center; padding: 32px 24px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.auth-form h2 { font-size: 1.6rem; }
.auth-form h2 + p { margin: -12px 0 8px; }

@media (max-width: 1100px) {
    .split, .columns { grid-template-columns: 1fr; }
    .column + .column { border-left: 0; border-top: 1px solid var(--border); }
    .preview { position: static; }
}
@media (max-width: 800px) {
    .auth { grid-template-columns: 1fr; }
    .auth-hero { padding: 32px 24px; gap: 32px; }
    .auth-hero h1 { font-size: 1.6rem; }
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar-nav { max-height: 40vh; }
    .sidebar-toggle { display: none; }
    .shell.collapsed { grid-template-columns: 1fr; }
    .collapsed .sidebar .label { display: revert; }
    .content { padding: 16px; }
    .card-head { flex-wrap: wrap; }
    .table th:nth-child(n+3), .table td:nth-child(n+3) { display: none; }
}

/* Settings pages: section intro on the left, fields card on the right */
.settings { display: contents; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.page-head h1 { font-size: 1.15rem; font-weight: 700; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.page-head.sticky { position: sticky; top: 0; z-index: 3; }
.settings-section { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 32px; padding: 24px; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: 0; }
.settings-intro h2 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.settings-intro p { margin: 0; color: var(--muted); font-size: .875rem; line-height: 1.55; }
.settings-card { padding: 20px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.settings-card > .switch { margin-top: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.settings-card > .setting-row:first-of-type { padding-top: 0; border-top: 0; } /* first div; ignores the hidden CSRF input */
.setting-row p { margin: 2px 0 0; font-size: .85rem; }
.setting-row .switch { margin: 0; }
.setting-row .field { flex: 1; max-width: 320px; }
.danger-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--surface); color: var(--muted); font-family: var(--mono); font-size: .8rem; }
.input-group input { border-radius: 0 var(--radius) var(--radius) 0; }
.lang-preview { display: flex; gap: 6px; flex-wrap: wrap; }

/* Table input for rows:N fields */
.grid-input { display: grid; gap: 4px; }
.grid-input.cols-1 { grid-template-columns: 1fr; }
.grid-input.cols-2 { grid-template-columns: 1fr 2fr; }
.grid-input.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-input.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-input.cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid-input.cols-6 { grid-template-columns: repeat(6, 1fr); }
.grid-input.cols-7 { grid-template-columns: repeat(7, 1fr); }
.grid-input.cols-8 { grid-template-columns: repeat(8, 1fr); }
.grid-input input { padding: 8px 10px; font-size: .9rem; min-width: 0; }

/* Roles and site access */
.role-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-option { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.role-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-option input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.role-option small { display: block; color: var(--muted); }
.site-checks { border: 0; padding: 0; margin: 0; display: grid; gap: 2px; }
.site-checks legend { font-weight: 600; font-size: .85rem; margin-bottom: 8px; padding: 0; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; }
.check-row:hover { background: var(--field); }
.check-row input { width: auto; accent-color: var(--accent); }

/* Colour picker */
.color-picker { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; }
.cp-main { display: flex; flex-direction: column; gap: 12px; }
.cp-sv { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); cursor: crosshair; touch-action: none;
    background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent); background-color: red; }
.cp-hue { position: relative; height: 14px; border-radius: 99px; cursor: pointer; touch-action: none;
    background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); }
.cp-thumb { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .25), 0 2px 6px rgb(0 0 0 / .3); transform: translate(-50%, -50%); pointer-events: none; }
.cp-hue .cp-thumb { top: 50%; }
.cp-sv:focus-visible, .cp-hue:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.cp-side { display: flex; flex-direction: column; gap: 14px; }
.cp-preview { display: flex; align-items: flex-end; gap: 14px; }
.cp-preview .field { margin: 0; }
.cp-chip { width: 64px; height: 64px; border-radius: 12px; background: var(--accent); flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1); }
.cp-preview .field { width: 140px; }
.cp-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.cp-swatch { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.cp-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.cp-label { margin: 0 0 8px; font-weight: 600; font-size: .85rem; }
.cp-contrast { margin: 0; }
.settings-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px -20px -20px; padding: 14px 20px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--field) 50%, var(--surface)); border-radius: 0 0 var(--radius) var(--radius); }
.settings-card-foot p { margin: 0; }

@media (max-width: 1000px) {
    .settings-section, .color-picker { grid-template-columns: 1fr; gap: 14px; }
    .role-options { grid-template-columns: 1fr; }
}

/* Page editor workspace: editor and preview side by side, full height, each scrolls on its own */
.workspace { display: grid; grid-template-columns: minmax(320px, var(--split, 50%)) minmax(320px, 1fr); height: 100vh; }
.workspace.no-preview { grid-template-columns: minmax(0, 1fr); }
.workspace.no-preview .ws-preview { display: none; }
.ws-edit { overflow-y: auto; background: var(--surface); min-width: 0; }
.workspace:not(.no-preview) .ws-edit { border-right: 1px solid var(--border); }
.ws-preview { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.ws-preview-bar { display: flex; align-items: center; gap: 10px; height: 57px; padding: 0 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.ws-preview-bar .icon-btn { margin-left: auto; width: 34px; height: 34px; }
.ws-preview iframe { flex: 1; width: 100%; border: 0; background: #fff; }

.ed-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; height: 57px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.ed-bar .icon-btn { width: 34px; height: 34px; }
.ed-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ed-bar .primary { padding: 8px 18px; }
.switch.compact { margin: 0; gap: 8px; font-weight: 500; font-size: .875rem; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--field); overflow-x: auto; max-width: 100%; }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 6px; font-size: .78rem; font-weight: 700; color: var(--muted); text-decoration: none; white-space: nowrap; }
.segmented a:hover { color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.segmented a.missing { opacity: .55; }

.ed-body { padding: 20px 24px 64px; display: flex; flex-direction: column; gap: 12px; }
.ed-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; border: 0; background: none; padding: 0; border-radius: 0; }
.ed-title:focus { background: none; box-shadow: none; }
.ed-url { display: flex; align-items: center; font-size: .85rem; color: var(--muted); margin-top: -6px; }
.ed-url .ed-slug { width: auto; flex: 0 1 260px; padding: 3px 6px; margin-left: 1px; font-size: .85rem; border-color: transparent; background: var(--field); }
.ed-meta-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: .875rem; font-weight: 500; }
.position-input { width: 70px; padding: 5px 8px; }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.ed-section { border: 1px solid var(--border); border-radius: var(--radius); }
.ed-section > summary { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; font-weight: 600; }
.ed-section > summary .small { font-weight: 400; }
.ed-section > summary .blk-chevron { margin-left: auto; }
.ed-section-body { display: grid; gap: 14px; padding: 2px 14px 14px; }
.serp { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--field); font-family: Arial, sans-serif; }
.serp-url { font-size: .8rem; color: var(--muted); }
.serp-title { font-size: 1.15rem; color: #1a0dab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serp-desc { font-size: .85rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (prefers-color-scheme: dark) { .serp-title { color: #8ab4f8; } }

.ed-blocks { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ed-blocks-head { display: flex; align-items: center; justify-content: space-between; }
.ed-blocks-head h2 { font-size: .95rem; margin: 0; }
.link-btn { border: 0; background: none; padding: 4px 6px; font-weight: 500; font-size: .85rem; color: var(--muted); }
.link-btn:hover { color: var(--accent); }
.blk { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); scroll-margin-top: 70px; transition: border-color .15s, box-shadow .15s; }
.blk[open] { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 4px 16px -10px rgb(0 0 0 / .3); }
.blk-head { display: flex; align-items: center; gap: 12px; padding: 9px 10px 9px 12px; cursor: pointer; }
.blk-head:hover { background: color-mix(in srgb, var(--field) 60%, transparent); }
.blk-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.blk-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.blk-title strong { font-size: .9rem; }
.blk-summary { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.blk-head:hover .blk-actions, .blk-head:focus-within .blk-actions, .blk[open] .blk-actions { opacity: 1; }
.blk-actions .icon-btn { width: 30px; height: 30px; border-color: transparent; background: none; }
.blk-actions .icon-btn:hover:not(:disabled) { background: var(--field); }
.blk-chevron { display: grid; color: var(--muted); transition: transform .15s; }
details[open] > summary .blk-chevron { transform: rotate(90deg); }
.blk-body { padding: 16px; border-top: 1px solid var(--border); }
.blk-body input, .blk-body textarea, .blk-body select { padding: 8px 10px; }

.block-picker > summary { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px; border: 1.5px dashed var(--border); border-radius: var(--radius); color: var(--muted); font-weight: 600; cursor: pointer; }
.block-picker > summary:hover, .block-picker[open] > summary { border-color: var(--accent); color: var(--accent); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; margin-top: 8px; }
.picker-item { justify-content: flex-start; padding: 10px 12px; font-weight: 500; text-align: left; }
.picker-item .icon { color: var(--accent); }
.picker-item:hover { border-color: var(--accent); background: var(--accent-soft); }

/* dropdown menu */
.menu { position: relative; }
.menu > summary { cursor: pointer; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 230px; display: flex; flex-direction: column; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 32px -12px rgb(0 0 0 / .35); }
.menu-list a, .menu-list button { display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; font-weight: 500; font-size: .875rem; text-decoration: none; color: var(--text); }
.menu-list a:hover, .menu-list button:hover { background: var(--field); }
.menu-list .danger { color: var(--danger); }

/* Flash message as a toast: never pushes the layout */
.content > .banner:first-child { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 420px; border-radius: 10px; box-shadow: 0 12px 32px -12px rgb(0 0 0 / .35); animation: toast 4s ease forwards; }
@keyframes toast { 0%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(8px); visibility: hidden; } }

/* Row actions in tables */
.row-actions { text-align: right; white-space: nowrap; width: 1%; }
.row-actions form { display: inline; }
.row-actions .icon-btn { width: 32px; height: 32px; border-color: transparent; background: none; color: var(--muted); }
.row-actions .icon-btn:hover { background: var(--field); color: var(--text); }

@media (max-width: 1100px) {
    .workspace { grid-template-columns: 1fr; height: auto; }
    .ws-edit { overflow: visible; }
    .ws-preview { height: 80vh; border-top: 1px solid var(--border); }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Drag handles: sidebar edge and editor/preview divider (admin.js; sizes saved in theme.css) */
.resizer { position: absolute; top: 0; bottom: 0; width: 9px; z-index: 6; cursor: col-resize; touch-action: none; }
.sidebar > .resizer { right: -5px; }
.ws-preview > .resizer { left: -5px; }
.resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px; background: transparent; transition: background .15s, width .15s, left .15s; }
.resizer:hover::after, .resizer:focus-visible::after, .resizing .resizer.active::after { left: 3px; width: 3px; background: var(--accent); }
.resizer:focus-visible { outline: none; }
.collapsed .sidebar > .resizer { display: none; }
.resizing, .resizing * { cursor: col-resize !important; user-select: none; }
.resizing iframe { pointer-events: none; }
.resizing .shell { transition: none; }
@media (max-width: 1100px) { .resizer { display: none; } }

/* One header height everywhere so the sidebar, page and editor/preview header lines align. */
:root { --bar-h: 64px; }
.sidebar-head, .content .page-head, .content > .card > .card-head:first-child, .ed-bar, .ws-preview-bar {
    height: var(--bar-h); min-height: var(--bar-h); padding-top: 0; padding-bottom: 0; box-sizing: border-box;
}
.content .page-head { flex-wrap: nowrap; }
.content .page-head p, .content .card-head .card-title p { margin-top: 1px; }
.collapsed .sidebar-head { flex-direction: row; justify-content: center; padding: 0; }
.collapsed .sidebar-head .logo { display: none; }

/* Row delete button (sites list) */
.row-actions { white-space: nowrap; }
.row-actions .inline-form { display: inline; margin: 0; }
.icon-btn.danger-icon:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* Inline editing: block flashes when its text is edited in the preview; Save pulses while unsaved */
.blk-flash { animation: blk-flash 1.2s ease; }
@keyframes blk-flash { from { box-shadow: 0 0 0 2px var(--accent); } to { box-shadow: 0 0 0 2px transparent; } }
button.primary.needs-save { box-shadow: 0 0 0 3px var(--accent-soft); }
