/* ==========================================================================
   AI Story Studio design system
   Tokens first, then layout (sidebar, top bar, content), then components.
   Bootstrap 5.3 supplies the grid and form controls; these rules restyle it.
   ========================================================================== */

:root {
    --brand-900: #1b1640;
    --brand-800: #251d5c;
    --brand-700: #3a2c8f;
    --brand-600: #5b45e0;
    --brand-500: #6e5af0;
    --brand-100: #ece9ff;
    --brand-50: #f6f4ff;
    --accent-500: #ff7a59;
    --accent-100: #ffe9e2;
    --ink-900: #17152b;
    --ink-700: #3d3a55;
    --ink-500: #6b6884;
    --ink-300: #b4b2c7;
    --line: #e6e5ef;
    --surface: #ffffff;
    --surface-muted: #f7f7fb;
    --page-bg: #f3f3f9;
    --ok-600: #138a5e;
    --ok-100: #dcf5ea;
    --warn-600: #a55a00;
    --warn-100: #fff1d6;
    --danger-600: #c0322b;
    --danger-100: #fde4e2;
    --info-600: #2464c7;
    --info-100: #e2edff;
    --radius-sm: .5rem;
    --radius: .875rem;
    --radius-lg: 1.25rem;
    --shadow-sm: 0 1px 2px rgba(23, 21, 43, .06);
    --shadow: 0 1px 3px rgba(23, 21, 43, .06), 0 8px 24px -12px rgba(23, 21, 43, .12);
    --sidebar-width: 264px;
    --topbar-height: 4rem;

    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
    --bs-body-color: var(--ink-900);
    --bs-body-bg: var(--page-bg);
    --bs-secondary-color: var(--ink-500);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-primary: var(--brand-600);
    --bs-primary-rgb: 91, 69, 224;
    --bs-link-color: var(--brand-600);
    --bs-link-color-rgb: 91, 69, 224;
    --bs-link-hover-color: var(--brand-700);
    --bs-link-hover-color-rgb: 58, 44, 143;
    --bs-focus-ring-color: rgba(91, 69, 224, .3);
}

html, body {
    font-family: var(--bs-body-font-family);
    background: var(--page-bg);
    color: var(--ink-900);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink-900); font-weight: 650; letter-spacing: -.01em; }
h1:focus { outline: none; }
code { color: var(--brand-700); background: var(--brand-50); padding: .1em .35em; border-radius: .3rem; font-size: .85em; }
a, .btn-link { color: var(--brand-600); }
.text-secondary { color: var(--ink-500) !important; }
.icon { flex: none; vertical-align: -.15em; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }
.nav-toggle-input { position: absolute; opacity: 0; pointer-events: none; }

.app-sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    width: var(--sidebar-width);
    display: flex; flex-direction: column;
    background: radial-gradient(120% 60% at 0% 0%, #3a2c8f 0%, transparent 60%), linear-gradient(180deg, var(--brand-900) 0%, #120f2e 100%);
    color: #e7e5ff;
    transform: translateX(-100%);
    transition: transform .22s ease, width .2s ease;
    overflow-y: auto;
    /* No scrollbar on the menu; it still scrolls with the wheel, touch and keyboard. */
    scrollbar-width: none;
}
.app-sidebar::-webkit-scrollbar { display: none; }
.nav-toggle-input:checked ~ .app-sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.35); }
.nav-backdrop { display: none; position: fixed; inset: 0; z-index: 1030; background: rgba(18, 15, 46, .45); cursor: pointer; }
.nav-toggle-input:checked ~ .nav-backdrop { display: block; }

.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.25rem 1rem; }
.sidebar-brand a { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.sidebar-brand strong { display: block; font-size: 1rem; line-height: 1.2; }
.sidebar-brand small { display: block; font-size: .75rem; color: rgba(231, 229, 255, .6); }
.sidebar-close { color: rgba(255,255,255,.7); cursor: pointer; padding: .4rem; border-radius: .5rem; }
.sidebar-close:hover { background: rgba(255,255,255,.08); color: #fff; }

/* The logo (wwwroot/logo.png) has a transparent background, so it sits on the dark sidebar and the light pages alike. */
.brand-mark { display: inline-block; flex: none; width: 2.25rem; height: 2.25rem; object-fit: contain; }
.brand-mark.lg { width: 3.25rem; height: 3.25rem; }
.brand-mark.sm { width: 1.75rem; height: 1.75rem; }

.sidebar-nav { flex: 1; padding: .25rem .75rem 1rem; }
.nav-section { padding: 1.1rem .75rem .4rem; font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: rgba(231, 229, 255, .45); }
.side-link {
    display: flex; align-items: center; gap: .75rem; width: 100%;
    padding: .6rem .75rem; margin-bottom: .15rem; border: 0; border-radius: .6rem;
    background: none; color: rgba(231, 229, 255, .78); font-size: .92rem; font-weight: 500; text-align: left; text-decoration: none;
    transition: background .15s, color .15s;
}
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-link.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--accent-500); }
.side-link .icon { opacity: .9; }
.sidebar-footer { padding: .75rem; border-top: 1px solid rgba(255,255,255,.08); }

.app-main { transition: margin-left .2s ease; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    height: var(--topbar-height); padding: 0 1rem;
    background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-menu-btn { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: .6rem; cursor: pointer; color: var(--ink-700); }
.topbar-menu-btn:hover { background: var(--surface-muted); }
.topbar-brand { white-space: nowrap; display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink-900); text-decoration: none; }
.topbar-tagline { display: none; color: var(--ink-500); font-size: .875rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.topbar-link { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .7rem; border-radius: .6rem; color: var(--ink-700); font-size: .9rem; font-weight: 500; text-decoration: none; }
.topbar-link:hover { background: var(--surface-muted); color: var(--ink-900); }
.env-badge { padding: .25rem .6rem; border-radius: 999px; background: var(--warn-100); color: var(--warn-600); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; padding: .25rem .5rem .25rem .25rem; border-radius: 999px; color: var(--ink-700); text-decoration: none; font-size: .875rem; }
.user-chip:hover { background: var(--surface-muted); }
.user-chip { cursor: pointer; list-style: none; }
.user-chip::-webkit-details-marker { display: none; }
.user-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); font-weight: 700; font-size: .85rem; }

@media (max-width: 575.98px) { .env-badge { display: none; } }
.app-content { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

@media (min-width: 992px) {
    .app-sidebar { transform: none; }
    .sidebar-close, .topbar-menu-btn, .topbar-brand, .nav-backdrop, .nav-toggle-input:checked ~ .nav-backdrop { display: none; }
    .nav-toggle-input:checked ~ .app-sidebar { box-shadow: none; }
    .app-main { margin-left: var(--sidebar-width); }
    .topbar-tagline { display: block; }
    .app-topbar { padding: 0 2rem; }
    .app-content { padding: 2rem 2rem 4rem; }
}

/* ---------- Sign-in and public pages ---------- */
.auth-shell {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 2rem 1rem;
    background: radial-gradient(80% 50% at 50% 0%, var(--brand-100) 0%, transparent 70%), var(--page-bg);
}
.auth-brand { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.75rem; color: var(--ink-900); font-weight: 750; font-size: 1.2rem; text-decoration: none; }
.auth-main { width: 100%; max-width: 30rem; flex: 1; }
.auth-main:has(.auth-wide) { max-width: 60rem; }
.auth-main > h1, .auth-main > h2 { text-align: center; }
.auth-footer { margin-top: 2rem; color: var(--ink-500); font-size: .85rem; text-align: center; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 2rem 1.5rem; }
.auth-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: .25rem; }
.auth-card .auth-lead { color: var(--ink-500); text-align: center; margin-bottom: 1.5rem; }
@media (min-width: 576px) { .auth-card { padding: 2.5rem; } }

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-600); margin-bottom: .25rem; }
.page-title { font-size: clamp(1.4rem, 2.5vw, 1.85rem); margin: 0; }
.page-subtitle { margin: .35rem 0 0; color: var(--ink-500); max-width: 48rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------- Cards, tables, forms ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; font-weight: 600; }
.card-body { padding: 1.25rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem; }
.panel-title { font-size: 1.05rem; font-weight: 650; margin: 0 0 .75rem; }
.panel-title:has(+ .panel-subtitle) { margin-bottom: .25rem; }
.panel-subtitle { color: var(--ink-500); font-size: .9rem; margin: 0 0 1rem; }

.table-responsive { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { background: var(--surface-muted); color: var(--ink-500); font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border-bottom-color: var(--line); padding: .75rem 1rem; white-space: nowrap; }
.table > tbody td { padding: .8rem 1rem; border-color: var(--line); }
.table > tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--brand-50); }

.form-label { font-weight: 600; font-size: .875rem; color: var(--ink-700); margin-bottom: .35rem; }
.form-text { color: var(--ink-500); font-size: .8rem; }
.form-control, .form-select { border-color: #d9d8e6; border-radius: .6rem; padding: .55rem .8rem; }
/* Keep room on the right for the select arrow; the padding above would otherwise draw the arrow over the text. */
.form-select { padding-right: 2.25rem; }
.form-select-sm { padding-top: .3rem; padding-bottom: .3rem; padding-right: 2rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 .2rem rgba(91, 69, 224, .18); }
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-section { padding: 1.25rem 0; border-top: 1px solid var(--line); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section-title { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-500); margin-bottom: .75rem; }

.btn { border-radius: .6rem; font-weight: 600; padding: .5rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-lg { padding: .75rem 1.25rem; }
.btn-primary {
    --bs-btn-bg: var(--brand-600); --bs-btn-border-color: var(--brand-600);
    --bs-btn-hover-bg: var(--brand-700); --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg: var(--brand-800); --bs-btn-active-border-color: var(--brand-800);
    --bs-btn-disabled-bg: var(--brand-500); --bs-btn-disabled-border-color: var(--brand-500);
    box-shadow: 0 6px 16px -8px rgba(91, 69, 224, .8);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-600); --bs-btn-border-color: #cfc8fb;
    --bs-btn-hover-bg: var(--brand-50); --bs-btn-hover-color: var(--brand-700); --bs-btn-hover-border-color: var(--brand-500);
    --bs-btn-active-bg: var(--brand-100); --bs-btn-active-color: var(--brand-700); --bs-btn-active-border-color: var(--brand-500);
}
.btn-outline-secondary {
    --bs-btn-color: var(--ink-700); --bs-btn-border-color: #d9d8e6;
    --bs-btn-hover-bg: var(--surface-muted); --bs-btn-hover-color: var(--ink-900); --bs-btn-hover-border-color: #c4c2d6;
    --bs-btn-active-bg: #ecebf4; --bs-btn-active-color: var(--ink-900); --bs-btn-active-border-color: #c4c2d6;
}
.btn:focus-visible, .btn-link.nav-link:focus { box-shadow: 0 0 0 .2rem rgba(91, 69, 224, .3); }

.badge { font-weight: 600; letter-spacing: .01em; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; background: var(--surface-muted); color: var(--ink-700); border: 1px solid var(--line); }
.chip-ok { background: var(--ok-100); color: var(--ok-600); border-color: transparent; }
.chip-warn { background: var(--warn-100); color: var(--warn-600); border-color: transparent; }
.chip-danger { background: var(--danger-100); color: var(--danger-600); border-color: transparent; }
.chip-brand { background: var(--brand-100); color: var(--brand-700); border-color: transparent; }
.chip-accent { background: var(--accent-100); color: #c2451f; border-color: transparent; }

.alert { border-radius: var(--radius); border: 0; }
.alert-danger { background: var(--danger-100); color: #8d1f19; }
.alert-success { background: var(--ok-100); color: #0c5e40; }
/* A notice that hides itself (see app.js) has a close button at its end. */
.alert[data-notice] { position: relative; padding-right: 3.2rem; }
.notice-x { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer; opacity: .65; }
.notice-x:hover, .notice-x:focus-visible { opacity: 1; background: rgba(0, 0, 0, .08); }
.notice-gone { display: none !important; }

.empty-state { text-align: center; padding: 2.5rem 1.5rem; color: var(--ink-500); }
.empty-state .empty-icon { display: inline-grid; place-items: center; width: 3.5rem; height: 3.5rem; border-radius: 1rem; background: var(--brand-50); color: var(--brand-600); margin-bottom: .75rem; }
.empty-state h2, .empty-state h3 { font-size: 1.1rem; color: var(--ink-900); }

/* ---------- Help callouts ---------- */
.help-callout { display: flex; gap: .75rem; padding: .9rem 1rem; border-radius: var(--radius); background: var(--info-100); color: #183f7d; margin-bottom: 1rem; font-size: .9rem; }
.help-callout .help-icon { flex: none; margin-top: .05rem; }
.help-callout .help-title { font-weight: 700; margin-bottom: .15rem; }
.help-callout p:last-child, .help-callout ul:last-child, .help-callout ol:last-child { margin-bottom: 0; }
.help-callout code { background: rgba(255,255,255,.6); color: inherit; }
.help-tip { background: var(--brand-50); color: var(--brand-800); }
.help-warning { background: var(--warn-100); color: #6b3b00; }
.help-success { background: var(--ok-100); color: #0c5e40; }

/* ---------- Stat tiles ---------- */

/* ---------- Dashboard ---------- */
.hero { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 1.75rem 1.5rem; margin-bottom: 1.5rem; color: #fff; background: radial-gradient(90% 120% at 100% 0%, rgba(255, 122, 89, .55) 0%, transparent 55%), linear-gradient(135deg, var(--brand-700), var(--brand-900)); box-shadow: var(--shadow); }
.hero h1 { color: #fff; font-size: clamp(1.4rem, 3vw, 2rem); margin-bottom: .35rem; }
.hero p { color: rgba(255,255,255,.82); max-width: 40rem; margin-bottom: 1.1rem; }
.hero .btn-light { color: var(--brand-800); }
.hero .btn-outline-light { --bs-btn-hover-color: var(--brand-800); }
@media (min-width: 768px) { .hero { padding: 2.25rem 2.5rem; } }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.step { position: relative; display: flex; gap: .9rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; padding-top: 0; }
.step-marker { flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; border: 2px solid var(--line); color: var(--ink-500); font-weight: 700; font-size: .85rem; background: var(--surface); }
.step.is-done .step-marker { border-color: transparent; background: var(--ok-100); color: var(--ok-600); }
.step.is-current .step-marker { border-color: var(--brand-500); color: var(--brand-600); box-shadow: 0 0 0 4px var(--brand-50); }
.step-body { flex: 1; min-width: 0; }
.step-title { font-weight: 650; margin: 0; }
.step-text { color: var(--ink-500); font-size: .88rem; margin: .1rem 0 .4rem; }

.quick-action { display: flex; align-items: center; gap: .85rem; padding: .9rem 1rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink-900); text-decoration: none; transition: border-color .15s, background .15s; }
.quick-action:hover { border-color: #cfc8fb; background: var(--brand-50); }
.quick-action .qa-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: .7rem; background: var(--brand-100); color: var(--brand-700); flex: none; }
.quick-action strong { display: block; font-size: .95rem; }
.quick-action small { color: var(--ink-500); }

/* ---------- AI providers ---------- */
.flow { display: grid; gap: .75rem; grid-template-columns: 1fr; margin-bottom: 1.5rem; }
@media (min-width: 768px) { .flow { grid-template-columns: repeat(3, 1fr); } }
.flow-step { display: flex; gap: .75rem; padding: 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.flow-num { flex: none; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--brand-600); color: #fff; font-weight: 700; font-size: .85rem; }
.flow-step strong { display: block; font-size: .95rem; }
.flow-step > div > span { color: var(--ink-500); font-size: .85rem; }

.catalog { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: 2rem; }
@media (min-width: 640px) { .catalog { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .catalog { grid-template-columns: repeat(4, 1fr); } }
.provider-card { display: flex; flex-direction: column; gap: .6rem; padding: 1.15rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.provider-card:hover { box-shadow: var(--shadow); }
.provider-card.is-selected { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.provider-card-head { display: flex; align-items: center; gap: .7rem; }
.provider-logo { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .75rem; font-weight: 800; color: #fff; flex: none; }
.logo-gemini { background: linear-gradient(135deg, #4285f4, #9b72cb 60%, #d96570); }
.logo-ollama { background: linear-gradient(135deg, #1f2937, #4b5563); }
.logo-anthropic { background: linear-gradient(135deg, #d97757, #b9583a); }
.logo-openai { background: linear-gradient(135deg, #10a37f, #0b7d61); }
.logo-canva { background: linear-gradient(135deg, #00c4cc, #7d2ae8); }
.logo-cartesia { background: linear-gradient(135deg, #111827, #ea580c); }
.logo-googletts { background: linear-gradient(135deg, #1a73e8, #34a853); }
.logo-fake { background: linear-gradient(135deg, #9ca3af, #6b7280); }
.provider-card h3 { font-size: 1rem; margin: 0; }
.provider-card .provider-sub { color: var(--ink-500); font-size: .8rem; }
.provider-card p { color: var(--ink-700); font-size: .88rem; margin: 0; flex: 1; }
.provider-tags { display: flex; flex-wrap: wrap; gap: .35rem; }

.guide { border: 1px solid #d6d2fa; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 2rem; overflow: hidden; }
.guide-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; background: var(--brand-50); border-bottom: 1px solid #e3defd; }
.guide-head h2 { font-size: 1.1rem; margin: 0; }
.guide-body { padding: 1.25rem; }
.guide-step { display: flex; gap: 1rem; padding-bottom: 1.25rem; }
.guide-step:last-child { padding-bottom: 0; }
.guide-step .flow-num { margin-top: .1rem; }
.guide-step h3 { font-size: 1rem; margin: 0 0 .35rem; }
.guide-step .step-content { flex: 1; min-width: 0; color: var(--ink-700); font-size: .92rem; }

.seg { display: inline-flex; flex-wrap: wrap; gap: .25rem; padding: .25rem; border-radius: .7rem; background: var(--surface-muted); border: 1px solid var(--line); margin-bottom: .6rem; }
.seg button { border: 0; background: none; padding: .35rem .75rem; border-radius: .5rem; font-size: .82rem; font-weight: 600; color: var(--ink-500); }
.seg.seg-sm { margin-bottom: 0; padding: .15rem; }
.seg.seg-sm button { padding: .2rem .55rem; font-size: .78rem; }
.seg button.active { background: var(--surface); color: var(--ink-900); box-shadow: var(--shadow-sm); }
.seg-count { display: inline-block; min-width: 1.5rem; margin-left: .3rem; padding: .05rem .4rem; border-radius: 999px; background: var(--line); color: var(--ink-500); font-size: .72rem; text-align: center; }
.seg button.active .seg-count { background: var(--brand-100); color: var(--brand-700); }

/* ---------- Admin list pages: status tabs, filter panel, summary line, table, pager ---------- */
.list-tabs { margin-bottom: .75rem; }
.list-filters { margin-bottom: 1rem; }
.list-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; color: var(--ink-500); font-size: .875rem; }
.list-summary label { font-size: .875rem; }
.list-pager { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1rem; color: var(--ink-500); font-size: .875rem; }
.list-section + .list-section { margin-top: 1.5rem; }
.list-row-editor > td { background: var(--surface-muted); }

.code-block { position: relative; margin: 0; padding: .9rem 1rem; border-radius: .7rem; background: #15132b; color: #e9e7ff; font-size: .82rem; line-height: 1.6; overflow-x: auto; white-space: pre; }
.code-block .c { color: #8f8bb3; }

.provider-row-name { font-weight: 650; }
.provider-row-meta { color: var(--ink-500); font-size: .8rem; }
.key-status { display: flex; flex-direction: column; gap: .2rem; }

/* ---------- Misc ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }
.darker-border-checkbox.form-check-input { border-color: #929292; }
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { color: var(--bs-secondary-color); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { text-align: start; }
.nav-tabs .nav-link.active { color: var(--brand-700); font-weight: 600; }
/* Page tabs as one segmented control: the open tab is filled, so it can be told apart at a glance. */
.seg-tabs { display: inline-flex; gap: 4px; margin: 0; padding: 5px; list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(23, 21, 43, .06); }
.seg-tabs button { padding: .6rem 1.25rem; border: 0; border-radius: 10px; background: none; color: var(--ink-700); font: inherit; font-weight: 600; }
.seg-tabs button:hover { background: var(--brand-100); }
.seg-tabs button.active { background: var(--brand-600); color: #fff; font-weight: 700; box-shadow: 0 3px 8px -2px rgba(91, 69, 224, .6); }
.seg-tabs button:focus-visible { outline: 3px solid rgba(91, 69, 224, .45); outline-offset: 2px; }
.list-group-item.active { background: var(--brand-600); border-color: var(--brand-600); }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}
/* Syllable colouring. Colours meet WCAG AA (4.5:1) on white. Every second syllable is also underlined, so it does not rely on colour alone. */
.syllable-text .syl-word { border-radius: .25rem; }
.syllable-text .syl-word.clickable { cursor: pointer; }
.syllable-text .syl-word.clickable:hover { background: #f1f3f5; }
.syllable-text .syl-word.needs-review { outline: 2px dashed #b45309; outline-offset: 1px; }
.syllable-text .syl-word.selected { background: #fff3bf; }
/* Inline-block keeps the second syllable's underline off the dot. */
.syllable-text.show-sep .syl + .syl::before { content: "\00B7"; display: inline-block; color: #6c757d; padding: 0 .05em; }
.palette-redblue .syl-c0 { color: #c62828; }
.palette-redblue .syl-c1 { color: #1565c0; text-decoration: underline; text-underline-offset: .2em; }
.palette-rainbow .syl-c0 { color: #c62828; }
.palette-rainbow .syl-c1 { color: #1565c0; }
.palette-rainbow .syl-c2 { color: #2e7d32; }
.palette-rainbow .syl-c3 { color: #6a1b9a; }
.palette-contrast .syl-c0 { color: #000; }
.palette-contrast .syl-c1 { color: #a0156b; text-decoration: underline; text-underline-offset: .2em; }
.palette-plain .syl, .syllable-text.no-color .syl { color: inherit; text-decoration: none; }

/* Book preview */
.reader-page { background: #fffdf7; border: 1px solid #e9e2cf; border-radius: 1rem; min-height: 22rem; }
.reader-illustration { background: repeating-linear-gradient(45deg, #f8f4e8, #f8f4e8 12px, #f3edd9 12px, #f3edd9 24px); border-radius: .75rem; min-height: 12rem; }
.reader-text { font-family: "Andika", "Comic Sans MS", "Trebuchet MS", sans-serif; font-size: clamp(1.6rem, 4vw, 2.6rem); line-height: 1.6; letter-spacing: .02em; }
.reader-focus { font-size: clamp(2rem, 6vw, 3.5rem); font-weight: 600; }
.reader-dots .btn { width: 2rem; height: 2rem; padding: 0; }
.syllable-chip { font-size: 1.1rem; }

/* Read-along: the sentence, word or syllable being read. */
.syllable-text .syl-word.ra-active { background: #ffe59a; box-shadow: 0 0 0 .12em #ffe59a; }
.syllable-text .syl.ra-active { background: #ffd24d; border-radius: .2rem; box-shadow: 0 0 0 .08em #ffd24d; }
.reader-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .6rem .75rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); margin-bottom: 1rem; }
.reader-controls .seg { margin-bottom: 0; }
.reader-controls .form-select { width: auto; }

/* Audio manager */
.audio-player { width: 100%; max-width: 22rem; height: 2.25rem; }
.audio-versions { display: grid; gap: .6rem; min-width: 0; }
/* One version = a small card stacked top to bottom (title, player, details, actions) so nothing can hang out of a narrow clip card. */
.audio-version { display: grid; gap: .6rem; min-width: 0; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-muted); }
.audio-version.is-selected { border-color: var(--brand-500); background: var(--brand-50); }
.audio-version.is-approved { border-color: var(--ok-600); background: var(--ok-100); }
.audio-version.is-review { border-color: #e0a526; background: var(--warn-100); }
.audio-version.is-failed { border-color: var(--danger-600); background: var(--danger-100); }
.audio-player-compact { width: 10.5rem; max-width: 100%; height: 2rem; flex: 0 0 auto; }
.audio-version-head { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }
.audio-version-head .av-toggle { padding: 0 .25rem; font-size: .8rem; text-decoration: none; }
.audio-version.is-approved .audio-version-actions { border-top-color: var(--ok-600); }
.audio-version.is-review .audio-version-actions { border-top-color: #e0a526; }
.audio-version.is-failed .audio-version-actions { border-top-color: var(--danger-600); }
.audio-version .audio-player { max-width: none; }
.audio-version-meta { min-width: 0; font-size: .85rem; color: var(--ink-700); overflow-wrap: anywhere; }
.audio-version-meta details { min-width: 0; }
.sent-request { max-height: 16rem; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: .75rem; background: var(--surface-muted); border: 1px solid var(--line); padding: .5rem; border-radius: .375rem; }
.audio-version-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.audio-version-actions:empty { display: none; }
.audio-version-actions .small { flex: 1 1 100%; }
.timing-table input { min-width: 5.5rem; max-width: 7rem; }
.timing-table td, .timing-table th { vertical-align: middle; }

/* Words and syllables: one card per item, listen / prompt / versions kept visibly apart */
.clip-grid { align-items: start; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: .85rem; }
.clip-card { min-width: 0; display: flex; flex-direction: column; gap: .65rem; padding: .9rem 1rem; border: 1px solid var(--line); border-left-width: .3rem; border-radius: var(--radius); background: var(--surface); }
.clip-card.is-ready { border-left-color: var(--ok-600); }
.clip-card.is-review { border-left-color: #e0a526; }
.clip-card.is-failed { border-left-color: var(--danger-600); }
.clip-card.is-empty { border-left-color: var(--line); background: var(--surface-muted); }
.clip-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .4rem .6rem; }
.clip-head > div { min-width: 0; flex: 1 1 6rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.panel-head > .panel-title { margin-bottom: 0; }
.panel-head .av-toggle { padding: 0 .25rem; font-size: .8rem; text-decoration: none; white-space: nowrap; }
.clip-suggest { display: grid; gap: .4rem; padding: .6rem .7rem; border: 1px dashed var(--ok-600); border-radius: var(--radius-sm); background: var(--ok-100); }
.clip-suggest-title { font-size: .8rem; font-weight: 700; color: var(--ok-600); }
.clip-suggest-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; font-size: .8rem; }
.clip-suggest-meta { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.clip-head-end { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.clip-head .av-toggle { padding: 0 .25rem; font-size: .8rem; text-decoration: none; }
.clip-word { font-size: 1.35rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.clip-meta { font-size: .78rem; color: var(--ink-500); }
.clip-listen { padding: .4rem .5rem; border-radius: var(--radius-sm); background: var(--surface-muted); min-height: 3rem; display: flex; align-items: center; }
.clip-listen .audio-player { max-width: none; }
.clip-prompt { font-size: .85rem; }
.clip-prompt-label { font-weight: 600; color: var(--ink-700); margin-right: .4rem; }
.clip-prompt-text { color: var(--ink-900); overflow-wrap: anywhere; }
.clip-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.clip-versions { padding-top: .5rem; border-top: 1px dashed var(--line); }

/* Illustrations */
.media-placeholder { background: repeating-linear-gradient(45deg, #f8f4e8, #f8f4e8 12px, #f3edd9 12px, #f3edd9 24px); aspect-ratio: 3 / 2; border-radius: .5rem; }
.media-version { flex: 0 0 13rem; }
.media-version .card-img-top { aspect-ratio: 3 / 2; height: auto; object-fit: cover; }
.media-prompt { white-space: pre-wrap; font-size: .75rem; max-height: 12rem; overflow: auto; background: #f6f6f6; padding: .5rem; border-radius: .25rem; }
.reader-illustration img { width: 100%; height: auto; border-radius: .75rem; display: block; }

/* Review and publish -------------------------------------------------------- */
.publish-steps { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.25rem; counter-reset: none; }
.publish-steps li { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .9rem .35rem .4rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-500); font-weight: 600; font-size: .9rem; }
.publish-step-dot { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--surface-muted); font-size: .8rem; }
.publish-steps li.done { color: var(--ok-600); }
.publish-steps li.done .publish-step-dot { background: var(--ok-100); }
.publish-steps li.current { color: var(--brand-700); border-color: var(--brand-500); background: var(--brand-50); }
.publish-steps li.current .publish-step-dot { background: var(--brand-600); color: #fff; }
.readiness-list { list-style: none; padding: 0; margin: 0; }
.readiness-list li { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem 0; border-top: 1px solid var(--line); }
.readiness-list li:first-child { border-top: 0; }
.readiness-list li > svg { flex: none; margin-top: .15rem; }
.readiness-ok > svg { color: var(--ok-600); }
.readiness-warning > svg { color: var(--warn-600); }
.readiness-blocker > svg { color: var(--danger-600); }
.readiness-title { font-weight: 600; }
.readiness-blocker .readiness-title { color: var(--danger-600); }
.readiness-detail { color: var(--ink-500); font-size: .9rem; }

.sample-books { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sample-books h2 { font-size: 1.05rem; margin: 0 0 .25rem; }
.sample-books p { margin: 0; color: var(--ink-500); max-width: 48rem; }
.sample-books > div { flex: 1 1 24rem; }
.access-choice { display: flex; gap: .75rem; flex-wrap: wrap; }
.access-choice label { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border: 2px solid var(--line); border-radius: .75rem; cursor: pointer; min-width: 12rem; background: var(--surface); }
.access-choice label.selected { border-color: var(--brand-500); background: var(--brand-50); }
.access-choice span { display: flex; flex-direction: column; }
.access-choice small { color: var(--ink-500); }
.gateway-ref { display: inline-block; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* Payment gateways page */
.gateway-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .75rem; }
.gateway-option { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border: 1px solid var(--bs-border-color); border-radius: .75rem; cursor: pointer; background: var(--bs-body-bg); }
.gateway-option.selected { border-color: var(--bs-primary); box-shadow: 0 0 0 1px var(--bs-primary) inset; }
.gateway-option.incomplete { cursor: not-allowed; opacity: .7; }
.gateway-option input { margin-top: .3rem; }
.gateway-option span { display: flex; flex-direction: column; }
.gateway-option small { color: var(--bs-secondary-color); }
.gateway-panel { margin-top: 1rem; }

/* ---------- Error log ---------- */
.error-log-filters { margin-bottom: 1rem; }
.error-log-row { cursor: pointer; }
.error-log-row.is-open > * { --bs-table-bg-state: var(--brand-50); }
.error-log-message { min-width: 16rem; }
.error-log-detail > td { background: var(--surface-muted); }
.error-log-facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; font-size: .875rem; }
.error-log-facts dt { color: var(--ink-500); font-weight: 600; }
.error-log-facts dd { margin: 0; }
.error-log-stack { max-height: 28rem; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 576px) { .error-log-facts { grid-template-columns: 1fr; } .error-log-facts dd { margin-bottom: .4rem; } }

/* Security audit log */
.audit-table tr.audit-flagged > td:first-child { box-shadow: inset 3px 0 0 var(--bs-danger); }
.audit-table tr.audit-detail > td { background: var(--surface-muted); }
.audit-table .btn-link { font-size: inherit; }
.btn-close-sm { width: .5em; height: .5em; padding: .15em; }

/* Payment gateways page: cards pick which gateway's settings are open */
.gw-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.gw-card { --gw: #5b45e0; text-align: left; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: .35rem; padding: 1.1rem 1.2rem; border-radius: 1.2rem; border: 1px solid #e0def0; background: linear-gradient(180deg, color-mix(in srgb, var(--gw) 12%, #fff), #fff 60%); box-shadow: 0 6px 16px -8px rgba(23, 21, 43, .25); transition: transform .15s, box-shadow .15s; }
.gw-card:hover { transform: translateY(-2px); }
.gw-card:nth-child(4n+1) { --gw: #3b6fe0; }
.gw-card:nth-child(4n+2) { --gw: #8a4fe0; }
.gw-card:nth-child(4n+3) { --gw: #1f9d8f; }
.gw-card strong { color: var(--gw); font-size: 1.15rem; font-weight: 800; }
.gw-card small { color: var(--ink-500); font-size: .85rem; }
.gw-card.selected { border: 2px solid var(--gw); box-shadow: 0 14px 28px -14px var(--gw); padding: calc(1.1rem - 1px) calc(1.2rem - 1px); }
.gw-card-off { --gw: #6b6884 !important; border-style: dashed; background: #fff; box-shadow: none; }
.gw-card-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.gw-options { border-top: 1px solid var(--bs-border-color); padding-top: 1rem; }
.gw-copy { display: flex; align-items: center; gap: .5rem; justify-content: space-between; background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: .6rem; padding: .5rem .5rem .5rem .9rem; }
.gw-help { border: 1px solid var(--bs-border-color); border-radius: .7rem; background: var(--bs-tertiary-bg); padding: .8rem 1rem; }
.gw-help summary { cursor: pointer; font-weight: 600; }
.gw-help ol { margin: .75rem 0 .5rem; padding-left: 1.25rem; }
.gw-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--bs-border-color); }

/* Payment and mail log pages */
.log-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.log-dl { display: grid; grid-template-columns: 8.5rem 1fr; gap: .4rem .75rem; font-size: .9rem; }
.log-dl dt { color: var(--bs-secondary-color); font-weight: 400; }
.log-dl dd { margin: 0; }
.log-detail { border-color: var(--bs-primary); }

/* Manual invoices: the running total beside the new-invoice form. */
.inv-summary { border-color: var(--bs-primary); }
.inv-summary dl { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0; }
.inv-summary dt { font-weight: 400; color: var(--bs-secondary-color); }
.inv-summary dd { margin: 0; text-align: right; }

/* New invoice toolbar: one line, 38px tall, never wraps. */
.inv-actions { align-items: flex-end; }
.inv-actions .btn { min-height: 38px; padding: 0 1rem; font-size: .9rem; white-space: nowrap; }
.inv-actions .btn .icon { flex: none; }

/* Gateway status pills: soft tints with a dot. Green only for Live, blue for Ready, grey when nothing is set up. */
.gw-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .65rem .2rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.gw-badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; box-sizing: border-box; }
.gw-badge.live { background: #e4f4ec; color: #145c3b; }
.gw-badge.live::before { background: #1f9d61; }
.gw-badge.ready { background: #e7edff; color: #2a3fa0; }
.gw-badge.ready::before { background: #4a63e0; }
.gw-badge.off { background: #efeef6; color: #4f4c70; }
.gw-badge.off::before { border: 2px solid #8d8aa8; }

/* Sales pages: summary tiles, plan cards, avatar rows. */
.sales-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin: 0 0 1rem; }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: 1rem; align-items: stretch; }
.plan-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: 1.4rem 1rem 1.1rem; text-align: center; border-radius: 1.4rem; border: 1px solid #e0def0; background: linear-gradient(180deg, color-mix(in srgb, var(--plan-color, #5b45e0) 12%, #fff), #fff 45%); box-shadow: 0 6px 16px -8px rgba(23, 21, 43, .25); }
.plan-card.recommended { border: 2px solid var(--plan-color, #5b45e0); box-shadow: 0 14px 28px -14px var(--plan-color, #5b45e0); }
.plan-card.off { opacity: .75; }
.plan-flag { position: absolute; top: -.7rem; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: .15rem .6rem; border-radius: 999px; background: #ffe9a8; color: #6a4000; font-size: .68rem; font-weight: 800; }
.plan-card h3 { margin: 0; font-size: 1.2rem; font-weight: 800; }
.plan-en { margin: 0; font-size: .85rem; color: var(--ink-500); }
.plan-price { display: flex; align-items: baseline; justify-content: center; gap: .1rem .5rem; margin-top: .5rem; white-space: nowrap; }
.plan-price strong { color: var(--plan-color, #5b45e0); font-size: 2.2rem; font-weight: 800; line-height: 1.15; }
.plan-was { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: .4rem; min-height: 1.5rem; white-space: nowrap; color: var(--ink-500); }
.plan-save { padding: .1rem .55rem; border-radius: 999px; background: #dff5f1; color: #14756b; font-size: .72rem; font-weight: 800; }
.plan-per { color: var(--ink-500); font-size: .85rem; white-space: nowrap; }
.plan-code { margin: .2rem 0 .8rem; background: none; color: #8a88a3; font-size: .75rem; }
.plan-switches { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; width: 100%; margin-top: auto; margin-bottom: .9rem; }
.plan-switches label { display: grid; justify-items: center; gap: .25rem; margin: 0; padding: .5rem .2rem; border: 1px solid #e0def0; border-radius: .9rem; background: #fff; color: var(--ink-500); font-size: .78rem; font-weight: 700; }
.plan-switches .form-check-input { width: 2.4rem; height: 1.3rem; margin: 0; cursor: pointer; }
.plan-edit { width: 100%; white-space: nowrap; border: 2px solid var(--plan-color, #5b45e0); border-radius: .8rem; background: #fff; color: var(--plan-color, #5b45e0); font-weight: 700; }
.plan-edit:hover { background: var(--plan-color, #5b45e0); color: #fff; }
/* Plan editor as a modal: the shade closes it on click, the panel keeps clicks to itself. */
.modal-shade { position: fixed; inset: 0; z-index: 1050; display: grid; place-items: start center; overflow-y: auto; padding: 4vh 1rem; background: rgba(23, 21, 43, .5); }
.plan-modal { width: min(46rem, 100%); margin: 0; box-shadow: 0 24px 60px -20px rgba(23, 21, 43, .6); }
.avatar-dot { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; margin-right: .5rem; border-radius: 50%; background: #e7e2ff; color: #3a2c8f; font-size: .8rem; font-weight: 800; }
.sales-table thead th { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--bs-secondary-color); background: var(--bs-tertiary-bg, #f7f7fb); }

/* Invoices table: a native <details> menu, so no extra script is needed. The wrapper keeps room below the last row,
   because .table-responsive clips anything that hangs out of it. */
.inv-wrap { min-height: 14rem; }
.inv-actions { position: relative; display: inline-block; }
.inv-actions > summary { list-style: none; cursor: pointer; }
.inv-actions > summary::-webkit-details-marker { display: none; }
.inv-menu { position: absolute; right: 0; top: calc(100% + .25rem); z-index: 5; min-width: 11rem; padding: .35rem; text-align: start; background: #fff; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .75rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.inv-menu a, .inv-menu button { display: block; width: 100%; padding: .45rem .75rem; border: 0; border-radius: .5rem; background: none; text-align: start; text-decoration: none; font-size: .9rem; color: inherit; }
.inv-menu a:hover, .inv-menu button:hover { background: #f1ecff; }

/* ---------- Summary tiles ----------
   One look for every row of numbers in the admin (dashboard, sales and log pages): a white card, a small label, a big number in
   the tile's colour, and a big icon in the corner, in the tile's pale colour. The colour cycles by position, in the plan card
   colours; warning tiles on the dashboard are red. */
.stat-tile, .sales-tile, .log-tile { --tile-a: #5b45e0; --tile-b: #ece9ff; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: center; column-gap: .75rem; row-gap: .1rem; height: 100%; min-height: 6.5rem; padding: 1rem 1.25rem; border-radius: 1.1rem; background: #fff; border: 1px solid #e0def0; box-shadow: 0 6px 16px -8px rgba(23, 21, 43, .25); color: var(--ink-900); text-decoration: none; transition: transform .15s, box-shadow .15s; }
a.stat-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -8px rgba(23, 21, 43, .3); color: var(--ink-900); }
.sales-tile:nth-child(4n+2), .log-tile:nth-child(4n+2), :nth-child(4n+2) > .stat-tile { --tile-a: #1f9d8f; --tile-b: #dff5f1; }
.sales-tile:nth-child(4n+3), .log-tile:nth-child(4n+3), :nth-child(4n+3) > .stat-tile { --tile-a: #d92d55; --tile-b: #fde6ec; }
.sales-tile:nth-child(4n), .log-tile:nth-child(4n), :nth-child(4n) > .stat-tile { --tile-a: #2c7be5; --tile-b: #e3f0ff; }
.stat-tile.is-warn { --tile-a: #b8323f !important; --tile-b: #fbe4e6 !important; }
.stat-tile > :not(.tile-icon), .sales-tile > :not(.tile-icon), .log-tile > :not(.tile-icon) { grid-column: 1; min-width: 0; position: relative; z-index: 1; }
.tile-icon { grid-column: 2; grid-row: 1 / span 3; align-self: center; display: block; line-height: 0; color: var(--tile-b); pointer-events: none; position: relative; z-index: 0; }
.tile-icon .icon { width: clamp(2.4rem, 18cqi, 3.5rem); height: clamp(2.4rem, 18cqi, 3.5rem); }
.stat-label, .sales-tile span, .log-tile span { color: var(--ink-500); font-size: clamp(.78rem, 4.2cqi, .88rem); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-tile, .sales-tile, .log-tile { container-type: inline-size; }
.stat-value, .sales-tile strong, .log-tile strong { color: var(--tile-a); font-size: clamp(1.9rem, 13cqi, 2.8rem); font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sales-tile small { color: var(--ink-500); font-size: .82rem; }

/* Sidebar: "New book" is under "Book library" in the URL, so only the more specific link stays highlighted. */
.sidebar-nav:has(a.side-link.active[href="admin/books/new"]) a.side-link[href="admin/books"] { background: none; color: rgba(231, 229, 255, .78); box-shadow: none; }

/* New book page */
.nb-grid { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1.25rem; align-items: start; max-width: 64rem; }
.nb-card { display: grid; gap: .5rem; padding: 1.5rem; border-radius: 1.2rem; background: #fff; border: 1px solid #e0def0; box-shadow: 0 6px 16px -8px rgba(23, 21, 43, .25); }
.nb-label { margin-top: .6rem; color: var(--ink-900); font-weight: 700; font-size: .92rem; }
.nb-label span { color: var(--ink-500); font-weight: 500; }
.nb-title { min-height: 3.2rem; font-size: 1.15rem; font-weight: 600; }
.nb-langs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.nb-lang { display: grid; gap: .1rem; padding: .75rem .9rem; text-align: left; border-radius: .9rem; border: 1px solid #e0def0; background: #fff; color: var(--ink-900); }
.nb-lang strong { font-size: .95rem; white-space: nowrap; }
.nb-lang small { color: var(--ink-500); font-size: .78rem; }
.nb-lang:hover { border-color: #b9b2f2; }
.nb-lang.active { border: 2px solid var(--brand-600, #5b45e0); background: #f3f1ff; padding: calc(.75rem - 1px) calc(.9rem - 1px); box-shadow: 0 8px 18px -10px #5b45e0; }
.nb-lang.active strong { color: #4a35c8; }
.nb-hint { margin: 0; color: var(--ink-500); font-size: .82rem; }
.nb-optional { display: grid; grid-template-columns: minmax(0, 1fr) 11rem; gap: 1rem; }
.nb-optional > div { display: grid; gap: .4rem; align-content: start; }
.nb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .9rem; padding-top: 1rem; border-top: 1px dashed #dcdaea; }
.nb-manual { margin-left: auto; font-size: .85rem; }
.nb-side { padding: 1.25rem; border-radius: 1.2rem; background: linear-gradient(180deg, #ece9ff, #fff 70%); border: 1px solid #e0def0; }
.nb-side h2 { margin: 0 0 .8rem; font-size: 1rem; font-weight: 800; color: #4a35c8; }
.nb-side ul { display: grid; gap: .6rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.nb-side li { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: .9rem; }
.nb-side li .icon { color: #5b45e0; }
.nb-side p { margin: 0; color: var(--ink-500); font-size: .82rem; }
@media (max-width: 900px) { .nb-grid { grid-template-columns: minmax(0, 1fr); } .nb-optional, .nb-langs { grid-template-columns: minmax(0, 1fr); } .nb-manual { margin-left: 0; } }

/* Generation jobs: status tiles that filter, and one card per job. */
.job-tiles { grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }
.job-tiles .log-tile { font: inherit; text-align: left; cursor: pointer; width: 100%; }
.job-tiles .log-tile:hover { transform: translateY(-2px); }
.job-tiles .log-tile.sel { border: 2px solid var(--tile-a); box-shadow: 0 12px 24px -14px var(--tile-a); padding: calc(1rem - 1px) calc(1.25rem - 1px); }
.job-list { display: grid; gap: .7rem; }
.job-card { --job: #8d8aa8; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; border-radius: 1rem; border: 1px solid #e0def0; border-left: 6px solid var(--job); background: #fff; box-shadow: 0 4px 12px -8px rgba(23, 21, 43, .3); }
.job-queued { --job: #d98a00; }
.job-processing { --job: #3b6fe0; }
.job-succeeded { --job: #1f9d8f; }
.job-failed { --job: #d92d55; }
.job-main { display: grid; gap: .45rem; min-width: 0; flex: 1; }
.job-top { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.job-top code { padding: .1rem .55rem; border-radius: .5rem; background: #f1f0f8; color: var(--ink-900); font-weight: 700; }
.job-id, .job-note { color: var(--ink-500); font-size: .8rem; }
.job-meta { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; color: var(--ink-500); font-size: .85rem; }
.job-meta span { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.job-meta .icon { opacity: .7; }
.job-error { display: flex; align-items: flex-start; gap: .5rem; margin: 0; padding: .55rem .75rem; border-radius: .7rem; background: #fde6ec; color: #8f1f3a; font-size: .84rem; overflow-wrap: anywhere; }
.job-error .icon { flex: none; margin-top: .15rem; }
.job-cancel { flex: none; }
@media (max-width: 640px) { .job-card { flex-direction: column; } }
.nb-section { margin: 1.1rem 0 .1rem; padding-top: 1rem; border-top: 1px dashed #dcdaea; color: #4a35c8; font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.nb-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem 1rem; }
.nb-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nb-row > div { display: grid; gap: .4rem; align-content: start; }
@media (max-width: 900px) { .nb-row, .nb-row-2 { grid-template-columns: minmax(0, 1fr); } }
.job-ok { --job: #1f9d8f; }
.job-bad { --job: #d92d55; }
.job-warn { --job: #d98a00; }
.job-info { --job: #3b6fe0; }
.job-card.is-click { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.job-card.is-click:hover { transform: translateY(-1px); }
.job-card.sel { box-shadow: 0 10px 22px -12px var(--job); outline: 2px solid var(--job); outline-offset: -2px; }
.job-title { font-size: 1rem; }
.job-subject { margin: 0; color: var(--ink-700, #3a3856); font-size: .88rem; overflow-wrap: anywhere; }
.log-tile small { color: var(--ink-500); font-size: .82rem; }
.job-amount { flex: none; align-self: center; color: var(--ink-900); font-size: 1.15rem; font-weight: 800; white-space: nowrap; }
.job-crit { --job: #8f1f3a; }
.job-card { flex-wrap: wrap; }
.job-detail { flex-basis: 100%; margin-top: .3rem; padding-top: .8rem; border-top: 1px dashed #dcdaea; cursor: auto; }
.job-actions { flex: none; align-self: center; display: flex; align-items: center; gap: .5rem; }
.job-toggle { white-space: nowrap; }
.job-toggle .icon { transform: rotate(90deg); transition: transform .15s; }
.job-toggle[aria-expanded="true"] .icon { transform: rotate(-90deg); }

/* Users and roles: one card per staff member, in the same style as the job and log cards (coloured edge, plain icon). */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.person-card { --job: #8d8aa8; margin: 0; padding: 1.1rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .15rem; border-radius: 1rem; border: 1px solid #e0def0; border-left: 6px solid var(--job); background: #fff; box-shadow: 0 4px 12px -8px rgba(23, 21, 43, .3); }
.person-card.job-ok { --job: #1f9d8f; }
.person-card.job-bad { --job: #d92d55; }
.person-card.job-warn { --job: #d98a00; }
.person-icon { display: block; line-height: 0; color: var(--job); grid-column: auto; }
.person-icon .icon { width: 2.6rem; height: 2.6rem; }
.person-name { margin-top: .5rem; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-mail { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; color: var(--bs-secondary-color); }
.person-roles { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem; margin: .5rem 0; min-height: 1.5rem; }
.person-state { justify-content: center; margin-bottom: .8rem; }
.person-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: auto; }
.role-pill { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .65rem .22rem .5rem; border-radius: .6rem; font-size: .78rem; font-weight: 700; line-height: 1.2; background: #eeedf5; color: #5b5873; }
.role-pill .icon { flex: none; }
.role-pill.r-admin { background: #ece8ff; color: #4a35c9; }
.role-pill.r-edit { background: #e1f1fd; color: #0b5f93; }
.role-pill.r-rev { background: #dff5ea; color: #12714a; }

/* Paste-a-key row: the box takes the free width, the button stays on one line beside it. */
.key-form { display: flex; align-items: stretch; gap: .5rem; max-width: 40rem; }
.key-form .form-control { flex: 1 1 auto; min-width: 0; }
.key-form .btn { flex: none; white-space: nowrap; padding-inline: 1.25rem; font-weight: 600; }

a.job-card { color: inherit; text-decoration: none; }
a.job-card:hover { color: inherit; }

.stat-note { color: var(--ink-500); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Getting started page: a quiet timeline, one accent colour. */
.help-page { max-width: 62rem; }
.help-promise { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.25rem; padding: .75rem 1rem; border-radius: 1rem; background: #ece9ff; color: #3d2fa8; font-weight: 600; }
.help-steps { list-style: none; margin: 0; padding: 0; }
.help-steps > li { position: relative; padding: 0 0 .75rem 3.1rem; }
.help-steps > li::before { content: ""; position: absolute; left: 1.05rem; top: 0; bottom: 0; width: 2px; background: #dcd8f0; }
.help-steps > li:first-child::before { top: 1.5rem; }
.help-steps > li:last-child { padding-bottom: 0; }
.help-steps > li:last-child::before { bottom: auto; height: 1.5rem; }
.help-steps > li > .step-marker { position: absolute; left: 0; top: .5rem; z-index: 1; width: 2.1rem; height: 2.1rem; background: #5b45e0; border-color: #5b45e0; color: #fff; }
.help-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; align-items: start; }
.help-card { background: #fff; border: 1px solid #e0def0; border-radius: 1rem; }
.help-card > summary { display: flex; align-items: center; gap: .9rem; padding: .85rem 1.1rem; cursor: pointer; list-style: none; }
.help-card > summary::-webkit-details-marker { display: none; }
.help-card > summary:hover { background: #faf9ff; border-radius: 1rem; }
.help-card[open] > summary { border-bottom: 1px solid #efedf8; border-radius: 1rem 1rem 0 0; }
.help-sum { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.help-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; color: var(--ink-900); }
.help-line { color: var(--ink-500); font-size: .9rem; }
.help-chev { color: var(--ink-500); line-height: 0; transition: transform .15s; }
.help-card[open] .help-chev { transform: rotate(90deg); }
.help-ico { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: #ece9ff; color: #5b45e0; flex: none; }
.help-more { padding: 1rem 1.1rem 1.1rem; font-size: .93rem; }
.help-more p:last-child, .help-more ul:last-child { margin-bottom: 0; }
@media (max-width: 767px) { .help-go { display: none; } .help-facts { grid-template-columns: 1fr; } }

/* Header: a taller welcome bar in the brand colours, a round guide button and an account pill that opens a menu. */
.app-topbar { background: radial-gradient(circle at 46% 0, rgba(255, 255, 255, .07) 3.7rem, transparent 3.75rem), radial-gradient(circle at 54% 100%, rgba(255, 255, 255, .07) 2.2rem, transparent 2.25rem), radial-gradient(60% 160% at 95% 0%, rgba(255, 122, 89, .55) 0%, transparent 65%), linear-gradient(100deg, var(--brand-900) 0%, #2b2170 38%, #5b45e0 100%); backdrop-filter: none; border-bottom: 0; color: #fff; box-shadow: 0 8px 22px -12px rgba(18, 15, 46, .65); }
.app-topbar .topbar-menu-btn, .app-topbar .topbar-brand { color: #fff; }
.app-topbar .topbar-menu-btn:hover { background: rgba(255, 255, 255, .15); }
.topbar-welcome { display: none; flex: 1 1 auto; max-width: 42rem; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.25; text-align: left; position: relative; z-index: 1; }
.topbar-hi { font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
.topbar-sub { max-width: 100%; color: rgba(255, 255, 255, .8); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { position: relative; z-index: 2; }
.app-topbar .env-badge { background: #fff1d6; color: #8a5a00; }
@media (min-width: 992px) { .app-topbar { --topbar-height: 5.5rem; } .topbar-welcome { display: flex; } }
.topbar-icon-btn { display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .18); color: #fff; text-decoration: none; }
.topbar-icon-btn:hover { background: rgba(255, 255, 255, .3); color: #fff; }
.user-menu { position: relative; }
.user-menu > .user-chip { padding: .25rem .65rem .25rem .25rem; border: 0; background: #fff; color: var(--brand-800); box-shadow: 0 6px 14px -6px rgba(0, 0, 0, .5); cursor: pointer; list-style: none; }
.user-menu > .user-chip::-webkit-details-marker { display: none; }
.user-menu > .user-chip:hover, .user-menu[open] > .user-chip { background: #f3f1ff; }
.user-chip .avatar { background: linear-gradient(135deg, #5b45e0, #8a5cf0); color: #fff; }
.user-caret { display: inline-grid; color: var(--ink-500); transform: rotate(90deg); transition: transform .15s; }
.user-menu[open] .user-caret { transform: rotate(-90deg); }
.user-panel { position: absolute; right: 0; top: calc(100% + .6rem); z-index: 1030; width: 19rem; max-width: calc(100vw - 2rem); overflow: hidden; background: #fff; color: var(--ink-900); border: 1px solid #e0def0; border-radius: 1.1rem; box-shadow: 0 20px 40px -14px rgba(18, 15, 46, .55); }
.user-panel-head { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.1rem; background: #f3f1ff; border-bottom: 1px solid #e6e2fb; }
.user-panel .avatar-lg { width: 2.8rem; height: 2.8rem; font-size: 1.1rem; flex: none; background: linear-gradient(135deg, #5b45e0, #8a5cf0); color: #fff; }
.user-panel-name { font-weight: 600; font-size: .92rem; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel-role { display: inline-block; margin-top: .15rem; padding: .05rem .55rem; border-radius: 999px; background: #ece9ff; color: #3d2fa8; font-size: .74rem; font-weight: 600; }
.user-panel-body { padding: .5rem; }
.user-item { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .5rem .6rem; border: 0; border-radius: .75rem; background: none; color: var(--ink-900); font-size: .9rem; font-weight: 500; text-decoration: none; text-align: left; cursor: pointer; }
.user-item:hover { background: #f3f1ff; color: var(--ink-900); }
.user-item-ico { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: #ece9ff; color: #5b45e0; flex: none; }
.user-panel-foot { padding: .5rem; border-top: 1px solid #efedf8; }
.user-signout { color: #b8323f; }
.user-signout .user-item-ico { background: #fbe4e6; color: #b8323f; }
.user-signout:hover { background: #fbe4e6; color: #b8323f; }
.min-w-0 { min-width: 0; }

/* Collapsible menu (desktop): an icon rail. app.js toggles html.sidebar-collapsed and remembers it. */
.topbar-collapse-btn { display: none; place-items: center; width: 2.4rem; height: 2.4rem; border: 0; border-radius: .7rem; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; position: relative; z-index: 1; }
.topbar-collapse-btn:hover { background: rgba(255, 255, 255, .28); }
@media (min-width: 992px) {
    .topbar-collapse-btn { display: inline-grid; }
    html.sidebar-collapsed { --sidebar-width: 4.75rem; }
    html.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 1.25rem .5rem 1rem; }
    html.sidebar-collapsed .sidebar-brand a span { display: none; }
    html.sidebar-collapsed .sidebar-nav { padding: .25rem .6rem 1rem; }
    html.sidebar-collapsed .nav-section { height: 0; margin: .7rem .6rem; padding: 0; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 0; }
    html.sidebar-collapsed .side-link { justify-content: center; gap: 0; padding: .7rem 0; font-size: 0; }
}

/* AI providers: what each job uses now, then the providers, then a filtered catalogue to add one. */
.section-title { margin: 1.75rem 0 .75rem; font-size: 1.1rem; font-weight: 700; }
.jobs { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: .5rem; }
@media (min-width: 900px) { .jobs { grid-template-columns: repeat(3, 1fr); } }
.job-box { display: flex; align-items: flex-start; gap: .85rem; padding: 1.1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-left-width: 5px; box-shadow: var(--shadow-sm); }
.job-box.ok { border-left-color: var(--ok-600); }
.job-box.warn { border-left-color: #d98a00; }
.job-box.none { border-left-color: var(--ink-300); }
.job-box-ico { flex: none; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .8rem; background: var(--brand-100); color: var(--brand-600); }
.job-box.ok .job-box-ico { background: var(--ok-100); color: var(--ok-600); }
.job-box.warn .job-box-ico { background: var(--warn-100); color: var(--warn-600); }
.job-box-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; }
.job-box-text h2 { margin: 0; font-size: 1.05rem; }
.job-box-hint { margin: 0; color: var(--ink-500); font-size: .85rem; }
.job-box-names { color: var(--ink-700); font-size: .85rem; overflow-wrap: anywhere; }
.job-box .btn { flex: none; align-self: center; }
.add-provider { margin-top: 2rem; padding-top: .5rem; scroll-margin-top: 5rem; }
.add-provider .flow { margin-bottom: 1.25rem; }
.start-here { margin-left: auto; align-self: flex-start; padding: .15rem .6rem; border-radius: 999px; background: #fff1d6; color: #a55a00; font-size: .72rem; font-weight: 700; white-space: nowrap; }

/* Tabs carry a small icon before the label; it follows the text colour and turns brand-coloured on the active tab. */
.seg button .icon, .seg-tabs button .icon { margin-right: .2rem; opacity: .85; }
.seg button.active .icon { color: var(--brand-600, var(--brand-700)); opacity: 1; }
.seg-tabs button.active .icon { opacity: 1; }

/* Centre a dialog in the window; auto margins (not align-items:center) so a tall dialog still scrolls from its top edge. */
.modal-shade.modal-center .plan-modal { margin-block: auto; }

/* Book library cards: a small cover tile in the status colour in front of the title. */
.book-ico { flex: none; align-self: center; display: grid; place-items: center; width: 3rem; height: 3.6rem; border-radius: .35rem .7rem .7rem .35rem; background: color-mix(in srgb, var(--job) 14%, #fff); color: var(--job); }
.job-card .job-title:is(a) { color: var(--ink-900); text-decoration: none; }
.job-card .job-title:is(a):hover { color: var(--brand-700); text-decoration: underline; }
.book-search { flex: 1 1 14rem; max-width: 22rem; margin-left: auto; }

/* Model picker strip: cost and list status on the left, sort on the right, then two links that open the long notes in a panel. */
.model-meta { margin-top: .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface-muted); display: grid; gap: .45rem; }
.model-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.model-meta-links { display: flex; gap: 1rem; }
.model-meta-links button { border: 0; background: none; padding: 0; color: var(--brand-700); font-size: .82rem; font-weight: 600; }
.model-meta-links button.on { text-decoration: underline; }
.model-meta-panel { padding-top: .45rem; border-top: 1px dashed #dcdaea; color: var(--ink-500); font-size: .84rem; }

/* New book, "Many books" tab */
.bk-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.bk-age { display: flex; align-items: center; gap: .5rem; }
.bk-age select { width: 6rem; }
.bk-steps { display: grid; gap: .6rem; }
.bk-step { display: grid; grid-template-columns: auto minmax(0, 1fr) 13rem; align-items: center; gap: .75rem; padding: .8rem 1rem; border: 1px solid #e0def0; border-radius: 1rem; background: #faf9ff; }
.bk-step.off { opacity: .6; }
.bk-step input[type="checkbox"] { width: 1.3rem; height: 1.3rem; }
.bk-step label { display: grid; margin: 0; }
.bk-step small { color: var(--ink-500); }
.bk-note { margin: .6rem 0 0; padding: .7rem 1rem; border-radius: .9rem; background: #fff6dc; border: 1px solid #f3dc9a; font-size: .9rem; }
@media (max-width: 900px) { .bk-row { grid-template-columns: minmax(0, 1fr); } .bk-step { grid-template-columns: auto minmax(0, 1fr); } .bk-step select { grid-column: 1 / -1; } }

/* Book library: the cover (the first page's picture) in the same slot as the book icon. */
.book-cover { flex: none; align-self: center; width: 3.4rem; height: 4.4rem; object-fit: cover; border-radius: .35rem .7rem .7rem .35rem; box-shadow: 0 4px 10px -4px rgba(23, 21, 43, .45); background: #d9d6ea; }

/* Subscriptions → Modules: one tile per reader module, grey with a lock when switched off. */
.module-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.module-tile { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: 1rem; text-align: center; border-radius: 1.2rem; background: #fff; border: 1px solid #e0def0; box-shadow: 0 6px 16px -10px rgba(23, 21, 43, .25); }
.module-art { display: grid; place-items: center; width: 100%; height: 5.5rem; margin-bottom: .4rem; border-radius: 1rem; font-size: 2.6rem; background: linear-gradient(160deg, #8a4fe0, #5b6cf0); }
.module-tile.off .module-art { background: linear-gradient(160deg, #d6d6dd, #a4a4b0); filter: grayscale(1); }
.module-tile.off .module-art::after { content: "🔒"; }
.module-tile.off .module-art { font-size: 0; }
.module-tile.off .module-art::after { font-size: 2.4rem; }
.module-tile .form-switch { display: flex; align-items: center; gap: .5rem; margin-top: .4rem; }

/* Audio version rows and cards: the review actions are always visible and big enough to tap; only the details fold. */
.audio-version-actions .btn { min-height: 2.25rem; padding-inline: .9rem; }
.audio-version-error { font-size: .8rem; color: var(--danger-600); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clip-review { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; padding: .5rem .6rem; border-radius: var(--radius-sm); background: var(--warn-100); border: 1px solid #e0a526; }
.clip-review-text { flex: 1 1 8rem; font-size: .82rem; font-weight: 600; color: var(--warn-600); }
.clip-review .btn { min-height: 2.25rem; padding-inline: 1rem; }

/* Syllable words: one card per word with a picture block and an audio block. */
.sw-activity { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; margin-bottom: 1rem; border-radius: var(--radius); background: var(--surface-2, #eef4ff); border: 1px solid var(--line); }
.sw-bulk { margin-bottom: 1rem; display: grid; gap: .6rem; }
.sw-bulk-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.sw-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .6rem .9rem; border-radius: var(--radius); background: #fff8e1; border: 1px solid #f0d77a; }
.sw-confirm > span { flex: 1 1 18rem; }

/* "Delete selected" on every admin list of audio and pictures (BulkDeleteBar, SelectTick). */
.bulk-bar { display: grid; gap: .5rem; margin-bottom: 1rem; padding: .55rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.bulk-bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem; }
.bulk-tick { flex: 0 0 auto; width: 1.15rem; height: 1.15rem; margin: 0; cursor: pointer; }
.sw-clip-label { display: inline-flex; align-items: center; gap: .3rem; }
.sw-clips.has-ticks .sw-clip { grid-template-columns: 4.6rem 6.5rem minmax(0, 1fr) 7rem; }
@media (max-width: 40rem) { .sw-clips.has-ticks .sw-clip { grid-template-columns: 4.6rem 6.5rem minmax(0, 1fr); } }
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); gap: .9rem; }
.sw-card { min-width: 0; display: flex; flex-direction: column; gap: .6rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.sw-card.is-review { border-color: #f0d77a; }
.sw-card.is-hidden { opacity: .65; }
.sw-head { display: flex; align-items: center; gap: .6rem; }
.sw-pic { width: 3.5rem; height: 3.5rem; flex: none; display: grid; place-items: center; font-size: 2.2rem; border-radius: .6rem; background: var(--surface-2, #f3f4f6); overflow: hidden; }
.sw-pic img { width: 100%; height: 100%; object-fit: cover; }
.sw-title { flex: 1; min-width: 0; }
.sw-word { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }
.sw-syl { color: var(--muted, #6b7280); }
.sw-badges { display: flex; gap: .25rem; flex-wrap: wrap; }
.sw-block { display: grid; gap: .45rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: .6rem; }
.sw-block.is-ok { background: #effaf1; border-color: #b7e2c0; }
.sw-block.is-review { background: #fff8e1; border-color: #f0d77a; }
.sw-block-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sw-line { display: flex; align-items: center; gap: .5rem; }
.sw-review { display: grid; gap: .5rem; }
.sw-review img { border-radius: .5rem; max-width: 100%; height: auto; }
.sw-review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.sw-review-actions .btn { padding: .6rem; font-weight: 600; }
.sw-gen { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.sw-edit, .sw-foot { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* Syllable words redesign: even spacing, one control size, tabs by status. */
.sw-stack { display: grid; gap: 1rem; }
.sw-stack > .panel, .sw-stack > .log-tiles { margin: 0; }
.sw-add > summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: .4rem; }
.sw-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .85rem 1rem; align-items: start; }
.sw-field { display: grid; gap: .3rem; min-width: 0; align-content: start; }
.sw-field .form-label { margin: 0; font-size: .85rem; font-weight: 600; }
.sw-field .form-control, .sw-field .form-select { height: 2.6rem; }
.sw-field-btn { align-self: end; }
.sw-field-btn .btn { height: 2.6rem; }
.sw-range { height: 2.6rem; margin: 0; }
/* Voice and Picture settings cards (SettingsPanel): same look on every page, side by side when there is room. */
.settings-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem; align-items: stretch; }
.settings-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.settings-icon { display: inline-flex; color: var(--brand-600); }
.settings-chip { font-size: .72rem; font-weight: 650; padding: .1rem .55rem; border-radius: 999px; background: color-mix(in srgb, var(--brand-600) 12%, transparent); color: var(--brand-700); }
.sw-half { grid-column: span 2; }
.sw-wide { grid-column: 1 / -1; }
@media (max-width: 40rem) { .sw-half { grid-column: auto; } }
.sw-filters { margin-bottom: .5rem; }
.sw-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; border-bottom: 1px solid var(--line); }
.sw-tab { border: 0; background: transparent; padding: .6rem 1rem; font-weight: 700; color: var(--ink-500); border-bottom: 3px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: .45rem; }
.sw-tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600, #5b45e0); }
.sw-count { background: var(--surface-2, #eef0f6); border-radius: 999px; padding: .05rem .55rem; font-size: .85rem; }
.sw-options { display: grid; gap: .65rem; padding: .7rem; border: 1px dashed var(--line); border-radius: .6rem; }
.dn-admin-qr { max-width: 14rem; width: 100%; height: auto; border: 1px solid var(--line); border-radius: .75rem; background: #fff; padding: .5rem; image-rendering: pixelated; }

/* Syllable words cards: a row of label, status, player and two buttons was wider than the card and the buttons and the
   "Approved" chip stuck out. Rows now wrap, the players can shrink, and nothing is wider than its box. */
.sw-block { min-width: 0; }
.sw-block-head { flex-wrap: wrap; }
.sw-line { flex-wrap: wrap; row-gap: .35rem; min-width: 0; }
.sw-line .audio-player-compact { flex: 1 1 8rem; width: auto; min-width: 8rem; max-width: 12rem; }
.sw-line .btn { flex: none; }

/* VoiceSelect: Model and Voice side by side, stacked on narrow screens. */
.vs-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem 1rem; }
.vs-item { min-width: 0; }
.ma-voices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; margin-top: .85rem; }
@media (max-width: 40rem) { .ma-voices { grid-template-columns: 1fr; } }
.settings-panel > .panel-head { margin-bottom: 1rem; }
/* Never let a label sit tight under a heading or above its field. */
.settings-panel .form-label, .sw-field .form-label { margin-bottom: .3rem; }
.ma-voices > :empty { display: none; }

/* Word card: status tag, header buttons and aligned clip rows. */
.sw-tag { font-size: .78rem; font-weight: 700; border-radius: 999px; padding: .2rem .65rem; white-space: nowrap; }
.sw-tag-ok { background: #d8f3e2; color: #17794a; }
.sw-tag-wait { background: #fff1d6; color: #8a5a00; }
.sw-tag-todo { background: #ece9fb; color: #4b3fb5; }
.sw-head-btn { margin-left: auto; }
.sw-clips { display: grid; gap: .4rem; }
.sw-clip { display: grid; grid-template-columns: 3rem 6.5rem minmax(0, 1fr) 7rem; align-items: center; gap: .5rem; min-height: 2.2rem; }
.sw-clip .chip { justify-self: start; }
.sw-clip .audio-player-compact { width: 100%; max-width: none; min-width: 0; flex: none; }
.sw-clip-actions { display: flex; gap: .35rem; justify-content: flex-end; min-width: 7rem; }
.sw-clip-actions .btn { min-width: 7rem; }
.sw-prompt-link { padding-left: 0; }
@media (max-width: 40rem) { .sw-clip { grid-template-columns: 3rem 6.5rem minmax(0, 1fr); } .sw-clip-actions { grid-column: 1 / -1; justify-content: flex-start; } }
/* Everything in a block header sits on the same vertical centre line. */
.sw-block-head { align-items: center; min-height: 2.1rem; }
.sw-block-head > strong, .sw-block-head > .chip { display: inline-flex; align-items: center; line-height: 1.2; margin: 0; }
.sw-block-head > .btn { display: inline-flex; align-items: center; gap: .35rem; margin-top: 0; margin-bottom: 0; }
.sw-clip > * { align-self: center; }

.sw-editform { display: grid; gap: .7rem; padding: .8rem; border: 1px solid #c9c2f5; background: #faf9ff; border-radius: .7rem; }
.sw-editrow { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; gap: .7rem; }
/* Text inside the Picture and Audio boxes sits on the vertical centre of its row. */
.sw-block { align-content: start; }
.sw-block .chip, .sw-block .btn, .sw-block strong, .sw-block .small { display: inline-flex; align-items: center; }
.sw-clip .chip, .sw-clip strong, .sw-clip .btn { display: inline-flex; align-items: center; justify-content: center; line-height: 1.2; }
.sw-clip strong { justify-content: flex-start; }
.sw-clip .chip { justify-self: start; }
.sw-foot .sw-confirm-text { flex-basis: 100%; }
.sw-card.is-hidden .sw-block { opacity: .6; }
.settings-pair > .settings-panel { height: 100%; }
/* Word card headers: title, status chip, then the Generate button on one line; the chip shrinks before anything wraps. */
.sw-block-head { flex-wrap: nowrap; justify-content: flex-start; gap: .6rem; }
.sw-block-head > .chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 1.6; }
.sw-block-head > .sw-head-btn { margin-left: auto; flex: none; white-space: nowrap; }
.sw-head { flex-wrap: nowrap; }

/* A box nobody has finished is purple (to do), like the Pending tag; green is approved and yellow is waiting for review. */
.sw-block.is-todo { background: #f4f3fc; border-color: #d9d4f6; }
.sw-iconbtn { min-width: 0 !important; width: 2.2rem; height: 2.2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.sw-clip-actions { min-width: 0; }
.sw-clip-actions { width: 7rem; justify-content: stretch; }
.sw-clip-actions .sw-iconbtn { flex: 1 1 0; width: auto; }
.sw-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin: .5rem 0; }
.sw-pages { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; }

/* Payment gateways: a saved secret shows only its masked ending, with Change joined to the box. */
.gw-secret .form-control { min-height: 44px; }
.gw-secret .btn { min-width: 6rem; min-height: 44px; font-weight: 600; }
.gw-secret-saved { font-family: var(--bs-font-monospace, ui-monospace, monospace); letter-spacing: .04em; color: var(--bs-secondary-color, #5c5f6a); background-color: var(--bs-tertiary-bg, #f6f6f9) !important; }
