/* ==========================================================================
   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;
    overflow-y: auto;
}
.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 { 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-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 .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; }
.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; }

.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 ---------- */
.stat-tile { display: flex; flex-direction: column; gap: .15rem; height: 100%; padding: 1.1rem 1.15rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--ink-900); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d6d2fa; }
.stat-icon { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .65rem; background: var(--brand-50); color: var(--brand-600); margin-bottom: .5rem; }
.stat-value { font-size: 1.75rem; font-weight: 750; line-height: 1.1; }
.stat-label { color: var(--ink-500); font-size: .85rem; }
.stat-tile.is-warn { border-color: #f5c2bf; }
.stat-tile.is-warn .stat-icon { background: var(--danger-100); color: var(--danger-600); }
.stat-tile.is-warn .stat-value { color: var(--danger-600); }

/* ---------- 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-elevenlabs { background: linear-gradient(135deg, #111827, #6d28d9); }
.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 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); }
.job-error { min-width: 14rem; max-width: 28rem; }
.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; }
.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: .5rem; }
.audio-version { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .6rem .75rem; 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-meta { flex: 1 1 14rem; min-width: 0; font-size: .85rem; color: var(--ink-700); }
.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; gap: .35rem; }
.timing-table input { min-width: 5.5rem; max-width: 7rem; }
.timing-table td, .timing-table th { vertical-align: middle; }

/* 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; }
