/* DocMX Help. Design tokens are DocMX Extract's (src/docmxExtract.Web/wwwroot/app.css) so the help
   centre reads as part of the same family. Do not invent new brand colours here. */

:root {
    /* Fonts */
    --font-title: 'Roboto', system-ui, sans-serif;
    --font-subtitle: 'Hind', system-ui, sans-serif;
    --font-body: 'Open Sans', system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Primary brand */
    --color-brand: #074684;
    --color-brand-dark: #053562;
    --color-brand-teal: #0ea5c6;
    --color-brand-accent: #a0edf7;

    /* Surfaces */
    --color-surface: #ffffff;
    --color-surface-raised: #f8fafc;
    --color-border: #e2e8f0;

    /* Text */
    --color-text-primary: #0f172a;
    --color-text-secondary: #64748b;
    --color-link: #075a9e;

    /* Callouts (semantic, never replace with brand) */
    --color-info-bg: #eff6ff;
    --color-info-border: #93c5fd;
    --color-warning-bg: #fffbeb;
    --color-warning-border: #fbbf24;
    --color-tip-bg: #ecfdf5;
    --color-tip-border: #34d399;

    --app-header-height: 56px;
    --radius: 0.5rem;
    --radius-lg: 12px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-raised: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    --focus-ring: 0 0 0 3px rgba(14, 165, 198, 0.45);
    --page-width: 1200px;
}

/* ── Base ── */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-padding-top: calc(var(--app-header-height) + 1rem);
}

body {
    background: var(--color-surface-raised);
    margin: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    outline: none;
}

h1, h2, h3, h4 {
    font-family: var(--font-title);
    line-height: 1.25;
    color: var(--color-text-primary);
    margin: 0 0 0.5em;
}

h1 { font-size: clamp(1.75rem, 2.5vw + 1rem, 2.25rem); font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

a {
    color: var(--color-link);
    text-underline-offset: 0.15em;
}

a:hover {
    color: var(--color-brand);
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: 4px;
}

/* Headings receive programmatic focus after navigation (FocusOnNavigate); no ring for that. */
h1:focus, main:focus {
    box-shadow: none;
}

img {
    max-width: 100%;
    height: auto;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 200;
    background: var(--color-surface);
    color: var(--color-brand);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    box-shadow: var(--shadow-raised);
}

.skip-link:focus {
    top: 0.5rem;
}

.muted { color: var(--color-text-secondary); }

.meta {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.lead {
    font-family: var(--font-subtitle);
    font-size: 1.125rem;
    color: var(--color-text-secondary);
    margin: 0 0 0.75rem;
}

.lead p { margin: 0 0 0.5rem; }

.eyebrow {
    font-family: var(--font-subtitle);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    /* Darker than the brand teal so small text meets WCAG AA contrast (5.4:1 on white). */
    color: #0e7490;
    margin: 0 0 0.25rem;
}

/* ── Top bar (as DocMX Extract) ── */

.top-bar {
    background-color: var(--color-brand);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(7, 70, 132, 0.15);
}

.top-bar-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    min-height: var(--app-header-height);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}

.brand:hover { color: #fff; }

.brand-logo { display: block; }

.brand-product {
    font-family: var(--font-subtitle);
    font-weight: 600;
    font-size: 1.125rem;
    padding-left: 0.625rem;
    border-left: 1px solid rgba(255, 255, 255, 0.35);
    line-height: 1.2;
}

.top-nav {
    display: flex;
    gap: 0.25rem;
}

.top-nav a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
}

.top-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.top-bar-search {
    margin-left: auto;
    width: min(320px, 40vw);
}

/* ── Search box ── */

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--color-text-secondary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    font-family: var(--font-body);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text-primary);
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-brand-teal);
    box-shadow: var(--focus-ring);
}

.search-box-compact input {
    padding: 0.4rem 0.75rem 0.4rem 2.25rem;
    font-size: 0.875rem;
    border-color: transparent;
}

.search-box-hero {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    padding: 0.375rem;
    max-width: 640px;
}

.search-box-hero .search-icon { left: 1.125rem; }

.search-box-hero input {
    border: none;
    padding: 0.75rem 0.75rem 0.75rem 2.75rem;
    font-size: 1.0625rem;
}

.search-box-hero input:focus { box-shadow: none; }

.search-box-hero:focus-within { box-shadow: var(--shadow-raised), var(--focus-ring); }

.search-box button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    background: var(--color-brand);
    border: 1px solid var(--color-brand);
    border-radius: var(--radius);
    padding: 0.6rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.search-box button:hover, .button:hover {
    background: var(--color-brand-dark);
    border-color: var(--color-brand-dark);
    color: #fff;
}

.button-secondary {
    background: var(--color-surface);
    color: var(--color-brand);
    border-color: #cbd5e1;
}

.button-secondary:hover {
    background: var(--color-surface-raised);
    color: var(--color-brand);
    border-color: #94a3b8;
}

/* ── Hero ── */

.hero {
    background: linear-gradient(135deg, var(--color-brand) 0%, #0a5aa5 55%, var(--color-brand-teal) 140%);
    color: #fff;
    padding: 3.5rem 0 4rem;
}

.hero-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.hero h1 {
    color: #fff;
    font-size: clamp(2rem, 3vw + 1rem, 2.75rem);
}

.hero-lead {
    font-family: var(--font-subtitle);
    font-size: 1.1875rem;
    color: rgba(255, 255, 255, 0.92);
    margin: 0 0 1.5rem;
    max-width: 40rem;
}

/* ── Page shell ── */

.page {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.page.narrow { max-width: 760px; }

.page-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin: 0.5rem 0 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    margin: 0 0 1rem;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
}

.card + .card { margin-top: 1.25rem; }

.category-grid > .card, .course-grid > .card { margin-top: 0; }

.card h2 { font-size: 1.125rem; }

.link-arrow {
    font-weight: 600;
    text-decoration: none;
}

.link-arrow::after { content: " \2192"; }

/* A card whose title link covers the whole card. */
.stretched::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
}

/* ── Breadcrumbs ── */

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.breadcrumbs li + li::before {
    content: "/";
    margin-right: 0.25rem;
    color: #cbd5e1;
}

.breadcrumbs a {
    color: var(--color-text-secondary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--color-brand);
    text-decoration: underline;
}

/* ── Home ── */

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.category-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

.category-card:hover, .course-card:hover {
    border-color: #bae6fd;
    box-shadow: var(--shadow-raised);
}

.category-card h3 { margin: 0.5rem 0 0.25rem; }

.category-card h3 a {
    color: var(--color-text-primary);
    text-decoration: none;
}

.category-card p { margin: 0; }

.category-card .meta { margin-top: auto; padding-top: 0.75rem; }

.category-children {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.category-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #e0f2fe;
    color: var(--color-brand);
    flex-shrink: 0;
}

.home-columns {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

/* ── Article lists ── */

.article-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.article-list li + li { border-top: 1px solid var(--color-border); }

.article-list a {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.75rem 0.5rem;
    text-decoration: none;
    border-radius: var(--radius);
}

.article-list a:hover { background: var(--color-surface-raised); }

.article-list-title {
    font-weight: 600;
    color: var(--color-link);
}

.article-list-summary {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
}

.category-section h2 { margin-bottom: 0.25rem; }

.category-section h2 a { text-decoration: none; color: var(--color-text-primary); }

/* ── Article ── */

.article-layout, .lesson-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 2rem;
    align-items: start;
}

.article-header {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.article-aside, .lesson-aside {
    position: sticky;
    top: calc(var(--app-header-height) + 1.5rem);
}

.toc ol, .chapters ol {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9375rem;
}

.toc li { margin: 0.125rem 0; }

.toc a {
    display: block;
    padding: 0.25rem 0.5rem;
    border-left: 2px solid var(--color-border);
    color: var(--color-text-secondary);
    text-decoration: none;
}

.toc a:hover {
    border-left-color: var(--color-brand-teal);
    color: var(--color-brand);
}

.toc .toc-level-3 a { padding-left: 1.25rem; }

.related .article-list a { padding: 0.5rem 0.25rem; }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 1.25rem 0 0;
    margin: 1.5rem 0 0;
    border-top: 1px solid var(--color-border);
}

.tag-list a {
    display: inline-block;
    font-size: 0.8125rem;
    padding: 0.125rem 0.625rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    text-decoration: none;
}

.tag-list a:hover { background: #e0f2fe; color: var(--color-brand); }

.feedback form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.feedback h2 { margin: 0; }

.feedback-buttons { display: flex; gap: 0.5rem; }

.feedback-thanks {
    font-weight: 600;
    color: var(--color-brand);
    margin: 0 0 0.25rem;
}

/* ── Prose (rendered TipTap content) ── */

.prose {
    font-size: 1rem;
    line-height: 1.7;
}

.prose > :first-child { margin-top: 0; }

.prose h2, .card .prose h2 { font-size: 1.375rem; margin-top: 2rem; padding-top: 0.25rem; }

.prose h3 { margin-top: 1.5rem; }

.prose h4 { margin-top: 1.25rem; }

.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose figure, .prose .table-wrap, .prose details, .prose .callout {
    margin: 0 0 1rem;
}

.prose li > p { margin: 0 0 0.375rem; }

.prose ul, .prose ol { padding-left: 1.5rem; }

.prose figure.image {
    margin: 1.25rem 0;
}

.prose figure.image img {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.prose figcaption {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-top: 0.375rem;
}

.prose blockquote {
    border-left: 3px solid var(--color-brand-teal);
    padding: 0.25rem 1rem;
    color: var(--color-text-secondary);
}

.prose code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: #f1f5f9;
    border-radius: 4px;
    padding: 0.1em 0.35em;
}

.prose pre {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
}

.prose pre code { background: none; padding: 0; color: inherit; }

.prose hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

.prose .table-wrap { overflow-x: auto; }

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.prose th, .prose td {
    border: 1px solid var(--color-border);
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: top;
}

.prose th { background: var(--color-surface-raised); font-weight: 600; }

.prose th p, .prose td p { margin: 0; }

.callout {
    border: 1px solid;
    border-left-width: 4px;
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
}

.callout > :last-child { margin-bottom: 0; }

.callout-info { background: var(--color-info-bg); border-color: var(--color-info-border); }

.callout-warning { background: var(--color-warning-bg); border-color: var(--color-warning-border); }

.callout-tip { background: var(--color-tip-bg); border-color: var(--color-tip-border); }

.prose details {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-raised);
}

.prose summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.75rem 1rem;
}

.prose .details-content { padding: 0 1rem 0.5rem; }

.prose .video, .prose .video-embed, .player {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 0 0 1.25rem;
}

.prose video, .prose iframe, .player video, .player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.player .muted {
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
}

/* ── Courses and lessons ── */

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.course-card {
    position: relative;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.course-card + .course-card { margin-top: 0; }

.course-card-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--color-surface-raised);
}

.course-card-body { padding: 1.25rem 1.5rem 1.5rem; }

.course-card h2 a { color: var(--color-text-primary); text-decoration: none; }

.course-card-description { color: var(--color-text-secondary); font-size: 0.9375rem; }

.course-card-description p { margin: 0 0 0.5rem; }

.course-header {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.course-header-image {
    width: 240px;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.course-mini-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.course-mini-list a {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem;
    border-radius: var(--radius);
    text-decoration: none;
}

.course-mini-list a:hover { background: var(--color-surface); }

.course-mini-list img { border-radius: 6px; object-fit: cover; }

.course-mini-list span { display: flex; flex-direction: column; }

.lesson-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lesson-list li + li { border-top: 1px solid var(--color-border); }

.lesson-list a {
    display: flex;
    gap: 0.875rem;
    align-items: center;
    padding: 0.75rem 0.5rem;
    text-decoration: none;
    border-radius: var(--radius);
}

.lesson-list a:hover { background: var(--color-surface-raised); }

.lesson-list a > span:last-child { display: flex; flex-direction: column; }

.lesson-list a[aria-current="page"] {
    background: #e0f2fe;
    font-weight: 600;
    color: var(--color-brand);
}

.lesson-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #e0f2fe;
    color: var(--color-brand);
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.lesson-list-compact a { padding: 0.5rem 0.25rem; font-size: 0.9375rem; }

.lesson-list-compact .lesson-number { width: 1.625rem; height: 1.625rem; font-size: 0.75rem; }

.chapters a {
    display: flex;
    gap: 0.75rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius);
    text-decoration: none;
}

.chapters a:hover { background: var(--color-surface-raised); }

.chapter-time {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--color-text-secondary);
    min-width: 3rem;
    padding-top: 0.15rem;
}

.lesson-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-border);
}

.lesson-nav .spacer { flex: 1; }

/* ── Not found ── */

.not-found .search-box-hero {
    margin: 1rem 0 1.5rem;
    box-shadow: none;
    border: 1px solid var(--color-border);
}

/* ── Footer ── */

.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

.footer-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    align-items: center;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.footer-brand { display: flex; flex-direction: column; }

.footer-brand strong { color: var(--color-text-primary); font-family: var(--font-title); }

.footer-links { display: flex; flex-wrap: wrap; gap: 1.25rem; }

.footer-links a { color: var(--color-text-secondary); text-decoration: none; }

.footer-links a:hover { color: var(--color-brand); text-decoration: underline; }

.footer-copy { margin: 0 0 0 auto; }

/* ── Blazor error UI ── */

#blazor-error-ui {
    background: #fef2f2;
    color: #991b1b;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.4rem;
    background: none;
    border: 0;
    font-size: 1.25rem;
}

/* ── Responsive ── */

@media (max-width: 960px) {
    .article-layout, .lesson-layout, .home-columns {
        grid-template-columns: minmax(0, 1fr);
    }

    .article-aside, .lesson-aside { position: static; }

    .course-header { flex-direction: column; align-items: flex-start; }

    .course-header-image { width: 100%; max-width: 360px; }
}

@media (max-width: 720px) {
    .top-bar-inner {
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
        padding: 0.5rem 1rem;
    }

    .top-bar-search {
        width: 100%;
        margin: 0 0 0.25rem;
        order: 3;
    }

    .top-nav { margin-left: auto; }

    .top-nav a { padding: 0.375rem 0.5rem; font-size: 0.875rem; }

    .hero { padding: 2.5rem 0 3rem; }

    .hero-inner { padding: 0 1rem; }

    .page { padding: 1.25rem 1rem 2rem; }

    .card { padding: 1.125rem; }

    .search-box-hero button { padding: 0.6rem 0.875rem; }

    .footer-copy { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}

/* ── Search ── */

.page.narrow-wide { max-width: 880px; }

.search-header-body { flex: 1; }

.search-header .search-box-hero { max-width: none; }

.search-summary {
    color: var(--color-text-secondary);
    margin: 0 0 1rem;
}

.search-results {
    list-style: none;
    padding: 0;
    margin: 0;
}

.search-result + .search-result { margin-top: 1rem; }

.search-result h2 { margin: 0 0 0.25rem; font-size: 1.1875rem; }

.search-result h2 a { text-decoration: none; }

.search-result h2 a:hover { text-decoration: underline; }

.search-snippet {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
}

.search-snippet mark {
    background: #fef08a;
    color: var(--color-text-primary);
    border-radius: 2px;
    padding: 0 0.1em;
}

.search-empty ul { padding-left: 1.25rem; }

/* ── Sign in (as DocMX Extract) ── */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e9f0 100%);
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    padding: 2.5rem 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}

.login-header { text-align: center; margin-bottom: 1.75rem; }

.login-logo {
    display: inline-flex;
    background: var(--color-brand);
    border-radius: 10px;
    padding: 0.5rem 0.875rem;
    margin-bottom: 1rem;
}

.login-title {
    font-size: 1.5rem;
    color: var(--color-brand);
    margin: 0 0 0.25rem;
}

.login-subtitle { font-size: 0.875rem; color: #6b7280; margin: 0; }

.login-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.8125rem;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.login-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
    margin: 0.875rem 0 0.375rem;
}

.login-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
    font-family: var(--font-body);
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

.login-input:focus { outline: none; border-color: var(--color-brand-teal); box-shadow: var(--focus-ring); }

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.7rem 1rem;
    margin-top: 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: #fff;
    background: var(--color-brand);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}

.login-btn:hover { background: var(--color-brand-dark); color: #fff; }

.login-hint { font-size: 0.8125rem; color: #6b7280; margin: 0.75rem 0 0; text-align: center; }

.login-admin { margin-top: 1.25rem; border-top: 1px solid #e5e7eb; padding-top: 0.75rem; }

.login-admin summary { cursor: pointer; font-size: 0.8125rem; color: #6b7280; text-align: center; }

.login-back { text-align: center; font-size: 0.8125rem; margin: 1.25rem 0 0; }

/* ── Admin ── */

.top-nav a.active { background: rgba(255, 255, 255, 0.16); color: #fff; }

.auth-pill {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius);
    padding: 0.25rem 0.375rem 0.25rem 0.625rem;
    font-size: 0.8125rem;
}

.auth-pill form { margin: 0; }

.auth-name { font-weight: 600; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.signout-btn {
    color: rgba(255, 255, 255, 0.9);
    background: none;
    border: 0;
    font: inherit;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
}

.signout-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-grid > .card { margin-top: 0; }

.stat { display: flex; flex-direction: column; }

.stat-value { font-family: var(--font-title); font-size: 2rem; font-weight: 700; color: var(--color-brand); }

.stat-label { color: var(--color-text-secondary); font-size: 0.875rem; }

.inline-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }

.field { display: flex; flex-direction: column; gap: 0.25rem; }

.field label:not(.radio) { font-size: 0.8125rem; font-weight: 600; color: #374151; }

.field input:not([type=radio]):not([type=checkbox]), .field select, .data-table select {
    font: inherit;
    font-size: 0.9375rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
    min-width: 12rem;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }

.data-table th, .data-table td { text-align: left; padding: 0.625rem 0.5rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }

.data-table th { font-size: 0.8125rem; color: var(--color-text-secondary); font-weight: 600; }

.data-table select { min-width: 8rem; }

.button-small { padding: 0.35rem 0.75rem; font-size: 0.8125rem; }

.form-error { color: #991b1b; margin: 0.75rem 0 0; }

.form-status { color: #166534; margin: 0.75rem 0 0; }

/* ── Admin and editor ── */

.admin-header { justify-content: space-between; align-items: center; }

.admin-filters { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }

.admin-filters input, .admin-filters select, #redirect-filter {
    font: inherit;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
}

.small { font-size: 0.8125rem; }

.banner { padding: 0.625rem 0.875rem; border-radius: var(--radius); margin: 0 0 1rem; }

.form-error.banner { background: #fef2f2; border: 1px solid #fecaca; }

.form-status.banner { background: #f0fdf4; border: 1px solid #bbf7d0; }

.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    margin-right: 0.25rem;
    white-space: nowrap;
}

.badge-live { background: #dcfce7; color: #166534; }

.badge-draft { background: #f1f5f9; color: #475569; }

.badge-changes { background: #fef3c7; color: #92400e; }

.badge-internal { background: #ede9fe; color: #5b21b6; }

.editor-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    position: sticky;
    top: var(--app-header-height);
    z-index: 20;
    background: var(--color-surface-raised);
    padding: 0.5rem 0;
}

.editor-status { display: flex; align-items: center; gap: 0.5rem; }

.editor-actions, .form-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.form-actions { margin-top: 1rem; }

.form-actions .spacer, .dialog-actions .spacer { flex: 1; }

.editor-layout, .admin-two-column, .revisions-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.25rem;
    align-items: start;
    margin-bottom: 1.25rem;
}

.admin-two-column { grid-template-columns: minmax(0, 1fr) 380px; }

.revisions-layout { grid-template-columns: 320px minmax(0, 1fr); }

.editor-side .card + .card { margin-top: 1rem; }

.editor-side h2 { font-size: 1rem; }

.title-input {
    width: 100%;
    border: none;
    font-family: var(--font-title);
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text-primary);
    padding: 0.25rem 0;
    margin-bottom: 0.25rem;
}

.summary-input {
    width: 100%;
    border: none;
    resize: vertical;
    font-family: var(--font-subtitle);
    font-size: 1.0625rem;
    color: var(--color-text-secondary);
    padding: 0.25rem 0;
}

.title-input:focus, .summary-input:focus { outline: none; box-shadow: inset 0 -2px 0 var(--color-brand-teal); }

.char-count { text-align: right; margin: 0 0 0.75rem; }

.field { margin-bottom: 0.875rem; }

.field input:not([type=radio]):not([type=checkbox]), .field select, .field textarea {
    width: 100%;
    min-width: 0;
    font: inherit;
    font-size: 0.9375rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
}

.field-label, fieldset.field legend { font-size: 0.8125rem; font-weight: 600; color: #374151; margin-bottom: 0.25rem; display: block; }

fieldset.field { border: none; padding: 0; margin: 0 0 0.875rem; }

.radio { display: flex; gap: 0.5rem; align-items: center; font-size: 0.9375rem; margin: 0.25rem 0; }

.slug-input { display: flex; align-items: center; gap: 0.25rem; }

.slug-input span { font-size: 0.875rem; white-space: nowrap; }

.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--color-link);
    cursor: pointer;
    text-align: left;
}

.link-button:hover { text-decoration: underline; }

/* Rich text editor */

/* TipTap's base editor rules. TipTap would inject these as an inline style element, which the
   Content Security Policy blocks, so the editor runs with injectCSS off and they live here. */
.ProseMirror {
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
    white-space: break-spaces;
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0;
}
.ProseMirror [contenteditable="false"] { white-space: normal; }
.ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; }
.ProseMirror pre { white-space: pre-wrap; }
img.ProseMirror-separator {
    display: inline !important;
    border: none !important;
    margin: 0 !important;
    width: 0 !important;
    height: 0 !important;
}
.ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; }
.ProseMirror-gapcursor::after {
    content: "";
    display: block;
    position: absolute;
    top: -2px;
    width: 20px;
    border-top: 1px solid black;
    animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink { to { visibility: hidden; } }
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection * { caret-color: transparent; }
.ProseMirror-focused .ProseMirror-gapcursor { display: block; }

.rte {
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
}

.rte:focus-within { border-color: var(--color-brand-teal); box-shadow: var(--focus-ring); }

.rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    padding: 0.375rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-raised);
    border-radius: var(--radius) var(--radius) 0 0;
    position: sticky;
    top: calc(var(--app-header-height) + 3.25rem);
    z-index: 10;
}

.rte-group { display: flex; gap: 0.125rem; align-items: center; padding-right: 0.5rem; border-right: 1px solid var(--color-border); }

.rte-group:last-child, .rte-group-end { border-right: 0; }

.rte-group-end { margin-left: auto; }

.rte-button, .rte-select {
    font: inherit;
    font-size: 0.8125rem;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-primary);
    cursor: pointer;
}

.rte-select { border-color: #d1d5db; background: #fff; }

.rte-button:hover:not(:disabled) { background: #e2e8f0; }

.rte-button[aria-pressed="true"] { background: #dbeafe; border-color: #93c5fd; color: var(--color-brand); }

.rte-button:disabled { opacity: 0.4; cursor: default; }

.rte-bold { font-weight: 700; }

.rte-italic { font-style: italic; }

.rte-underline { text-decoration: underline; }

.rte-strike { text-decoration: line-through; }

.rte-status { margin: 0; padding: 0.375rem 0.75rem; font-size: 0.8125rem; background: #eff6ff; color: var(--color-brand); }

.rte-surface .ProseMirror {
    min-height: 420px;
    padding: 1rem 1.25rem;
    outline: none;
}

.rte-surface .ProseMirror p.is-editor-empty:first-child::before {
    content: attr(data-placeholder);
    color: #94a3b8;
    float: left;
    height: 0;
    pointer-events: none;
}

.rte-surface .ProseMirror img { max-width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius); }

.rte-surface .ProseMirror img[data-missing-alt] { outline: 3px dashed #f59e0b; outline-offset: 2px; }

.rte-surface .ProseMirror .ProseMirror-selectednode { outline: 3px solid var(--color-brand-teal); outline-offset: 2px; }

.rte-surface .ProseMirror table { border-collapse: collapse; width: 100%; }

.rte-surface .ProseMirror th, .rte-surface .ProseMirror td { border: 1px solid var(--color-border); padding: 0.375rem 0.5rem; position: relative; }

.rte-surface .ProseMirror .selectedCell::after { content: ""; position: absolute; inset: 0; background: rgba(14, 165, 198, 0.15); pointer-events: none; }

.rte-surface .ProseMirror [data-type="details"] { display: flex; gap: 0.25rem; border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.5rem; margin: 0 0 1rem; }

.rte-surface .ProseMirror [data-type="details"] > button { background: none; border: 0; cursor: pointer; }

.rte-surface .ProseMirror [data-type="details"] > div { flex: 1; }

.rte-surface .ProseMirror summary { font-weight: 600; }

.rte-surface .ProseMirror .video, .rte-surface .ProseMirror .video-embed { pointer-events: none; }

/* Dialogs */

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 1rem;
}

.dialog {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    width: min(560px, 100%);
    max-height: 88vh;
    overflow: auto;
    padding: 1.5rem;
}

.dialog h2 { font-size: 1.25rem; }

.dialog-image { max-height: 180px; border-radius: var(--radius); border: 1px solid var(--color-border); margin-bottom: 0.75rem; }

.picker-list { list-style: none; padding: 0; margin: 0 0 1rem; max-height: 240px; overflow: auto; }

.picker-list button {
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-radius: 6px;
    padding: 0.5rem;
    font: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.picker-list button:hover { background: var(--color-surface-raised); }

/* Reorder lists */

.reorder-list { list-style: none; padding: 0; margin: 0; }

.reorder-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    background: #fff;
}

.reorder-item.dragging { opacity: 0.5; background: #e0f2fe; }

.drag-handle { cursor: grab; color: #94a3b8; font-size: 1.125rem; user-select: none; }

.reorder-body { flex: 1; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.reorder-buttons { display: flex; gap: 0.25rem; }

/* Revisions */

.revision-list { list-style: none; padding: 0; margin: 0; }

.revision {
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-left: 3px solid transparent;
    padding: 0.5rem 0.75rem;
    font: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.revision:hover { background: var(--color-surface-raised); }

.revision.selected { border-left-color: var(--color-brand-teal); background: #e0f2fe; }

.revision-when { font-weight: 600; }

.diff-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }

.diff { list-style: none; padding: 0; margin: 0; font-size: 0.9375rem; }

.diff li { padding: 0.25rem 0.5rem; border-left: 3px solid transparent; }

.diff-added { background: #ecfdf5; border-left-color: #10b981 !important; }

.diff-removed { background: #fef2f2; border-left-color: #ef4444 !important; text-decoration: line-through; color: #7f1d1d; }

.diff-legend { padding: 0 0.375rem; border-radius: 4px; margin-left: 0.5rem; text-decoration: none; }

/* Preview, courses, lessons */

.preview-banner {
    background: #fef3c7;
    color: #78350f;
    text-align: center;
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.preview-banner a { margin-left: 0.75rem; }

.course-edit-image { width: 100%; border-radius: var(--radius); margin-bottom: 0.5rem; }

.lesson-edit-video { width: 100%; border-radius: var(--radius); margin-top: 0.5rem; background: #0f172a; }

.chapter-row { display: grid; grid-template-columns: 6rem minmax(0, 1fr) auto; gap: 0.5rem; margin-bottom: 0.5rem; }

.chapter-row input { font: inherit; padding: 0.4rem 0.5rem; border: 1px solid #d1d5db; border-radius: var(--radius); }

@media (max-width: 960px) {
    .editor-layout, .admin-two-column, .revisions-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ── Lesson transcript and chapter highlighting ── */

.transcript {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin: 0 0 1.25rem;
}

.transcript summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.75rem 1rem;
}

.transcript-lines {
    list-style: none;
    margin: 0;
    padding: 0 0.5rem 0.75rem;
    max-height: 420px;
    overflow-y: auto;
}

.transcript-lines a {
    display: flex;
    gap: 0.75rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius);
    color: var(--color-text-primary);
    text-decoration: none;
    line-height: 1.5;
}

.transcript-lines a:hover { background: var(--color-surface-raised); }

.transcript-lines a[data-active] { background: #e0f2fe; }

.chapters a[aria-current="true"] { background: #e0f2fe; font-weight: 600; }

/* ── Ask DocMX ── */

.ask { display: flex; flex-direction: column; gap: 0.75rem; }

.ask-messages {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
}

.ask-full .ask-messages { min-height: 320px; max-height: 60vh; }

.ask-compact .ask-messages { height: min(420px, 55vh); padding-right: 0.25rem; }

.ask-message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    max-width: 92%;
    line-height: 1.55;
    font-size: 0.9375rem;
}

.ask-message p { margin: 0 0 0.5rem; }

.ask-message p:last-child { margin-bottom: 0; }

.ask-message ol, .ask-message ul { margin: 0 0 0.5rem; padding-left: 1.25rem; }

.ask-user {
    align-self: flex-end;
    background: var(--color-brand);
    color: #fff;
    white-space: pre-wrap;
}

.ask-assistant { align-self: flex-start; background: var(--color-surface-raised); border: 1px solid var(--color-border); }

.ask-typing { color: var(--color-text-secondary); font-style: italic; }

.ask-error { color: #991b1b; }

.ask-cite {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.25rem;
    margin: 0 0.1rem;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 999px;
    background: #dbeafe;
    color: var(--color-brand);
    text-decoration: none;
    vertical-align: super;
}

.ask-cite:hover { background: var(--color-brand); color: #fff; }

.ask-sources {
    margin: 0.75rem 0 0;
    padding: 0.5rem 0 0 1.5rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.8125rem;
}

.ask-support { font-size: 0.875rem; margin: 0.5rem 0 0; }

.ask-feedback { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.625rem; }

.ask-suggestions { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }

.ask-suggestions button {
    font: inherit;
    font-size: 0.875rem;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    color: var(--color-brand);
}

.ask-suggestions button:hover { border-color: var(--color-brand-teal); }

.ask-form { display: flex; gap: 0.5rem; align-items: flex-end; }

.ask-form textarea {
    flex: 1;
    font: inherit;
    resize: none;
    padding: 0.625rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
}

.ask-form textarea:focus { outline: none; border-color: var(--color-brand-teal); box-shadow: var(--focus-ring); }

.ask-disclaimer { margin: 0; }

.ask-widget { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 150; }

.ask-launcher {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--color-brand);
    border: none;
    border-radius: 999px;
    padding: 0.75rem 1.125rem;
    box-shadow: var(--shadow-raised);
    cursor: pointer;
}

.ask-launcher:hover { background: var(--color-brand-dark); }

.ask-panel {
    position: absolute;
    right: 0;
    bottom: 3.75rem;
    width: min(420px, calc(100vw - 2rem));
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-raised);
    padding: 1rem;
}

.ask-panel-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }

.ask-panel-header h2 { margin: 0; font-size: 1.0625rem; flex: 1; }

.ask-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--color-text-secondary); }

@media (max-width: 720px) {
    .ask-widget { right: 0.75rem; bottom: 0.75rem; }

    .ask-launcher span { display: none; }
}

.nowrap { white-space: nowrap; }

.log-answer { font-size: 0.8125rem; color: var(--color-text-secondary); max-width: 40rem; }

/* ── Editor AI helpers ── */

.ai-helper-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.dialog-wide { width: min(860px, 100%); }

.ai-preview {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 50vh;
    overflow: auto;
    margin-bottom: 1rem;
}

.ai-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

.ai-compare h3 { font-size: 0.875rem; color: var(--color-text-secondary); }

.ai-text { white-space: pre-wrap; background: var(--color-surface-raised); border-radius: var(--radius); padding: 0.75rem; margin: 0; }

.ai-suggestion-list dt { font-weight: 600; font-size: 0.875rem; color: var(--color-text-secondary); margin-top: 0.75rem; }

.ai-suggestion-list dd { margin: 0.25rem 0 0; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.tag-button {
    font: inherit;
    font-size: 0.8125rem;
    padding: 0.125rem 0.75rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #fff;
    cursor: pointer;
}

.tag-button[aria-pressed="true"] { background: #dcfce7; border-color: #86efac; }

@media (max-width: 720px) {
    .ai-compare { grid-template-columns: 1fr; }
}
