:root {
    --page-bg: #FFF9F3;
    --surface: #FFFFFF;
    --text: #29221D;
    --muted: #685B50;
    --orange: #C2410C;
    --orange-hover: #9A3412;
    --accent: #F97316;
    --pale: #FFF0DF;
    --divider: #E9D9C9;
    --success: #1F7A4D;
    --error: #B42318;
    --warning: #9A6700;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(41, 34, 29, 0.06), 0 8px 24px rgba(41, 34, 29, 0.05);
    --heading-font: Georgia, "Times New Roman", "Noto Serif", serif;
    --body-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --max-width: 1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--body-font);
    font-size: 16px;
    line-height: 1.6;
}

h1, h2, h3, h4 {
    font-family: var(--heading-font);
    line-height: 1.2;
    margin: 0 0 0.5em;
    font-weight: 700;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.85rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; }

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

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

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--orange);
    color: #fff;
    padding: 0.6rem 1rem;
    z-index: 100;
}
.skip-link:focus { left: 0; }

.container {
    width: min(100% - 2rem, var(--max-width));
    margin-inline: auto;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--divider);
}
.site-header__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    flex-wrap: wrap;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text);
    text-decoration: none;
}
.brand__mark { width: 30px; height: 30px; }
.site-nav { display: flex; gap: 1rem; margin-inline-start: auto; flex-wrap: wrap; }
.site-nav a { text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.95rem; }
.site-nav a:hover { color: var(--orange); }

main { padding: 2rem 0 3rem; }

.hero {
    background: linear-gradient(180deg, var(--pale), var(--page-bg));
    border-bottom: 1px solid var(--divider);
    padding: 2.5rem 0;
}
.hero h1 { max-width: 22ch; }
.hero p.lede { color: var(--muted); font-size: 1.1rem; max-width: 60ch; }

.search-form {
    display: flex;
    gap: 0.5rem;
    margin: 1.25rem 0 0;
    max-width: 640px;
    flex-wrap: wrap;
}
.search-form input[type="search"] {
    flex: 1 1 260px;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
}
.search-form button { flex: 0 0 auto; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--orange);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    min-height: 44px;
}
.btn:hover { background: var(--orange-hover); color: #fff; }
.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--divider);
}
.btn--secondary:hover { background: var(--pale); color: var(--text); }
.btn--danger { background: var(--error); }
.btn--danger:hover { background: #8f1c12; }
.btn--small { padding: 0.4rem 0.7rem; min-height: 36px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.grid { display: grid; gap: 1.25rem; }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid--categories { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.card__thumb {
    aspect-ratio: 16 / 9;
    background: var(--pale);
    width: 100%;
    object-fit: cover;
    display: block;
}
.card__body { padding: 1rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.card__title { font-size: 1.05rem; margin: 0; }
.card__title a { text-decoration: none; color: var(--text); }
.card__title a:hover { color: var(--orange); }
.card__meta { color: var(--muted); font-size: 0.85rem; margin: 0; }
.card__desc { color: var(--muted); font-size: 0.92rem; margin: 0; }

.category-card { padding: 1.1rem; text-decoration: none; color: var(--text); display: block; }
.category-card:hover { border-color: var(--accent); background: var(--pale); }
.category-card h3 { margin: 0 0 0.25rem; }
.category-card p { color: var(--muted); font-size: 0.9rem; margin: 0; }
.category-card .count { color: var(--orange); font-weight: 600; font-size: 0.85rem; }

.section { margin-top: 2.5rem; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

.breadcrumbs { font-size: 0.88rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--orange); }

.layout-split { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 900px) {
    .layout-split { grid-template-columns: 240px 1fr; }
    .layout-split--task { grid-template-columns: minmax(0, 1fr) 300px; }
}

.topic-rail { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 1rem; }
.topic-rail h2 { font-size: 1rem; font-family: var(--body-font); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.topic-rail ul { list-style: none; margin: 0 0 1rem; padding: 0; }
.topic-rail li { margin-bottom: 0.35rem; }
.topic-rail a { text-decoration: none; color: var(--text); display: block; padding: 0.25rem 0.4rem; border-radius: 6px; }
.topic-rail a:hover, .topic-rail a[aria-current="page"] { background: var(--pale); color: var(--orange-hover); }

.player { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-facade {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    padding: 0;
    cursor: pointer;
    background: #000;
    background-size: cover;
    background-position: center;
    border-radius: var(--radius);
    overflow: hidden;
    display: block;
}
.player-facade__play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}
.player-facade__play span {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: var(--orange);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    padding-left: 6px;
}

.video-caption { margin-top: 0.75rem; color: var(--muted); font-size: 0.9rem; }
.video-caption a { color: var(--muted); }

.prose { max-width: 68ch; }
.prose h2 { margin-top: 1.8rem; }

.fact-list { list-style: none; margin: 0; padding: 0; }
.fact-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--divider); font-size: 0.95rem; }
.fact-list li:last-child { border-bottom: 0; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--pale);
    color: var(--orange-hover);
}
.badge--muted { background: #f1ece6; color: var(--muted); }
.badge--ok { background: #e7f5ee; color: var(--success); }
.badge--warn { background: #fdf3e2; color: var(--warning); }
.badge--error { background: #fdecea; color: var(--error); }

.notice {
    border: 1px solid var(--divider);
    border-left: 4px solid var(--accent);
    background: var(--surface);
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}
.notice--error { border-left-color: var(--error); }
.notice--success { border-left-color: var(--success); }
.notice--warning { border-left-color: var(--warning); }

.empty-state {
    border: 1px dashed var(--divider);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
}

.pagination { display: flex; gap: 0.5rem; margin-top: 1.5rem; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    text-decoration: none;
    background: var(--surface);
    color: var(--text);
}
.pagination [aria-current="page"] { background: var(--orange); color: #fff; border-color: var(--orange); }

.site-footer {
    border-top: 1px solid var(--divider);
    background: var(--surface);
    padding: 2rem 0;
    color: var(--muted);
    font-size: 0.9rem;
}
.site-footer nav { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.site-footer a { color: var(--muted); }

/* Admin */
.admin-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 900px) { .admin-shell { grid-template-columns: 240px 1fr; } }
.admin-side { background: #2b211b; color: #f6ece2; padding: 1.25rem; }
.admin-side a { color: #f6ece2; text-decoration: none; display: block; padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); }
.admin-side a:hover, .admin-side a[aria-current="page"] { background: rgba(249, 115, 22, 0.22); }
.admin-side__brand { font-family: var(--heading-font); font-size: 1.1rem; margin-bottom: 1rem; display: block; color: #fff; }
.admin-side__state { font-size: 0.8rem; color: #f2c9a8; margin-top: 1rem; }
.admin-main { padding: 1.5rem; max-width: 1100px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 1rem; }
.stat__value { font-size: 1.6rem; font-family: var(--heading-font); }
.stat__label { color: var(--muted); font-size: 0.85rem; }

.panel { background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel h2 { font-size: 1.15rem; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--divider); vertical-align: top; }
table.data th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field .help { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="url"], .field input[type="number"], .field select, .field textarea {
    width: 100%;
    padding: 0.65rem 0.7rem;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    font: inherit;
    background: var(--surface);
    color: var(--text);
}
.field textarea { min-height: 120px; resize: vertical; }
.field-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.check { display: flex; align-items: center; gap: 0.5rem; }
.check input { width: 20px; height: 20px; }

.progress { background: #f1ece6; border-radius: 999px; height: 12px; overflow: hidden; }
.progress__bar { background: var(--orange); height: 100%; width: 0; transition: width 0.4s ease; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.4rem 0; border-bottom: 1px solid var(--divider); }
.checklist li:last-child { border-bottom: 0; }
.checklist .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 0.45rem; flex: 0 0 auto; background: var(--muted); }
.checklist .dot--pass { background: var(--success); }
.checklist .dot--warn { background: var(--warning); }
.checklist .dot--fail { background: var(--error); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: min(100%, 440px); background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius); padding: 2rem; }

.install-shell { padding: 2rem 0 4rem; }
.steps { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; color: var(--muted); font-size: 0.9rem; }
.steps li { list-style: none; }

.recovery-codes { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.recovery-codes code { background: var(--pale); padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); display: block; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 1rem; }
.inline-form { display: inline; }
.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;
}

/* --- CSP-safe utility classes (no inline styles anywhere) --- */
.list-reset { list-style: none; padding: 0; margin: 0; }
.list-reset--spaced { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.list-reset--flush { list-style: none; padding: 0; margin: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 0.6rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.25rem; }
.mt-5 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }
.panel--flush { padding: 1rem; }
.h-sm { font-size: 1rem; margin-bottom: 0.5em; }
.h-md { font-size: 1.2rem; }
.h-lg { font-size: 1.5rem; }
.w-100 { width: 100%; }
.brand--stack { margin-bottom: 1rem; }
.section-intro { margin-bottom: 1.5rem; }
.prose--mt { margin-top: 1.25rem; }
.code-block {
    background: var(--pale);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    overflow-wrap: anywhere;
}
.pre-block {
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    padding: 1rem;
    overflow: auto;
    max-height: 70vh;
}
.divider { margin: 1rem 0; border: 0; border-top: 1px solid var(--divider); }
.actions-row { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tag-list {
    list-style: none;
    padding: 0.75rem 0 0;
    margin: 0.75rem 0 0;
    border-top: 1px solid var(--divider);
}
.tag-list li { margin-bottom: 0.25rem; }
.card--padded { padding: 1rem; }
.category-card--flush { padding: 0; }

.player-facade__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.progress {
    appearance: none;
    border: 0;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: #f1ece6;
}
.progress::-webkit-progress-bar { background: #f1ece6; border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--orange); border-radius: 999px; }
.progress::-moz-progress-bar { background: var(--orange); }

.maintenance-body {
    font-family: var(--body-font);
    background: var(--page-bg);
    color: var(--text);
    margin: 0;
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}
.maintenance-card {
    max-width: 40rem;
    background: var(--surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 2rem;
}

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

