/*
 * Celestia. Every color, size, radius and spacing value lives here as a
 * custom property; change the brand here, never in templates.
 */

/* ---------- Fonts (self-hosted, SIL Open Font License) ---------- */
@font-face { font-family: "Alegreya"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/alegreya-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Alegreya"; font-weight: 800; font-style: normal; font-display: swap; src: url("../fonts/alegreya-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/alegreya-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/alegreya-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/alegreya-sans-latin-700-normal.woff2") format("woff2"); }

/* ---------- Tokens ---------- */
:root {
    color-scheme: dark;

    --bg: #1E1B17;            /* Loam: page background */
    --surface: #27231E;       /* Hearth: cards, panels, inputs */
    --surface-2: #312B25;     /* Kiln: raised and selected surfaces, tags */
    --line: #3D362E;          /* Seam: dividers, card borders */
    --line-strong: #544A3F;   /* Seam strong: hover borders, secondary buttons */
    --text: #EBE3D3;          /* Parchment */
    --muted: #A59A88;         /* Ash */
    --accent: #7CB59B;        /* Verdigris: act or verified */
    --accent-hover: #93C8B0;
    --accent-ink: #10251C;    /* Deep moss: text on Verdigris */
    --brass: #D9AB4F;         /* Tested seal only */
    --brass-dim: #8A6A2C;
    --danger: #E07A66;        /* Rust */
    --pending: #9DB1D1;       /* Dusk */
    --starlight: #F0DFAE;     /* Logo and sky art only */

    --font-serif: "Alegreya", Georgia, serif;
    --font-sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;

    --fs-hero: clamp(42px, 6vw, 70px);
    --fs-h1: 38px;
    --fs-h2: 25px;
    --fs-h3: 19px;
    --fs-body: 17px;
    --fs-label: 16px;
    --fs-small: 14.5px;
    --fs-pill: 13px;

    --r-sm: 4px;
    --r-md: 8px;
    --r-icon: 14px;
    --r-icon-lg: 20px;
    --r-round: 999px;

    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;
    --s-12: 48px;
    --section-gap: 44px;
    --panel-pad: 21px;

    --content-width: 1180px;
    --header-height: 64px;
    --sidebar-width: 300px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1 0 auto; }
img, svg { max-width: 100%; }
img { display: block; }
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 700; line-height: 1.15; margin: 0 0 var(--s-3); }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-label); }
p { margin: 0 0 var(--s-4); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
strong, b { font-weight: 700; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.86em; }
code { background: var(--surface-2); border-radius: var(--r-sm); padding: 0.1em 0.35em; }
pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); overflow-x: auto; }
pre code { background: none; padding: 0; font-size: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-6) 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.wrap { max-width: var(--content-width); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-small); line-height: 1.5; }
.num { font-variant-numeric: tabular-nums; }
.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: var(--s-4); top: -100px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: var(--s-2) var(--s-4); border-radius: var(--r-sm); font-weight: 700; }
.skip-link:focus { top: var(--s-2); }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}
.site-header .wrap { height: var(--header-height); display: flex; align-items: center; gap: var(--s-6); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; flex-shrink: 0; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand .logo-mark { filter: drop-shadow(0 0 6px rgb(240 223 174 / 0.25)); }
.brand-name { font-family: var(--font-serif); font-weight: 800; font-size: 23px; line-height: 1; }
.main-nav { display: flex; gap: var(--s-5); }
.main-nav a { color: var(--muted); font-size: var(--fs-label); font-weight: 500; }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.header-search { margin-left: auto; width: min(380px, 32vw); }
.header-search input { width: 100%; }
.header-actions { display: flex; align-items: center; gap: var(--s-4); }
.header-actions .quiet-link { color: var(--muted); font-size: var(--fs-small); }
.header-actions .quiet-link:hover { color: var(--text); text-decoration: none; }
.header-actions form { margin: 0; }
.icon-link { color: var(--muted); display: inline-flex; position: relative; }
.icon-link:hover { color: var(--text); }
.count-badge {
    position: absolute; top: -6px; right: -8px; min-width: 17px; height: 17px; padding: 0 4px;
    background: var(--brass); color: var(--bg); border-radius: var(--r-round);
    font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: var(--s-12); padding: var(--s-8) 0; color: var(--muted); font-size: var(--fs-small); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.site-footer nav { display: flex; gap: var(--s-5); flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- Buttons ---------- */
.btn, .btn-primary, .btn-danger, .btn-quiet {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    min-height: 38px; padding: 0 var(--s-4);
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: transparent; color: var(--text);
    font: 700 var(--fs-small) / 1.2 var(--font-sans);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--muted); color: var(--text); text-decoration: none; background: var(--surface); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); text-decoration: none; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--bg); text-decoration: none; }
.btn-quiet { border-color: transparent; color: var(--muted); padding: 0 var(--s-2); font-weight: 500; }
.btn-quiet:hover { color: var(--text); text-decoration: none; }
.btn-lg { min-height: 46px; padding: 0 var(--s-6); font-size: var(--fs-label); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
    width: 100%; min-height: 44px; padding: var(--s-2) var(--s-3);
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    font: 400 var(--fs-label) / 1.4 var(--font-sans);
}
select { min-height: 38px; }
textarea { min-height: 120px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.form-field { margin-bottom: var(--s-5); }
.form-field > label, .form-label { display: block; font-weight: 700; font-size: var(--fs-label); margin-bottom: var(--s-2); }
.hint { display: block; color: var(--muted); font-size: var(--fs-small); margin-top: var(--s-1); }
.field-error { display: block; color: var(--danger); font-size: var(--fs-small); margin-top: var(--s-1); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: var(--s-2); color: var(--text); font-size: var(--fs-label); padding: var(--s-1) 0; cursor: pointer; }
.narrow-form { max-width: 430px; margin: 0 auto; padding-top: var(--s-12); }
.narrow-form h1 { margin-bottom: var(--s-5); }
.narrow-form .flash { margin: 0 0 var(--s-5); }
.form-foot { margin-top: var(--s-5); color: var(--muted); }

/* ---------- Flash ---------- */
.flash { margin: var(--s-5) auto 0; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.flash-ok { border-color: var(--accent); }
.flash-error { border-color: var(--danger); }

/* ---------- Panels, tags, pills ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--panel-pad); }
.panel + .panel { margin-top: var(--s-4); }
.panel h2, .panel h3 { margin-bottom: var(--s-3); }
.panel-title { font-family: var(--font-sans); font-weight: 700; font-size: var(--fs-label); margin: 0 0 var(--s-3); }
.panel-tested {
    border-color: var(--brass-dim);
    background: linear-gradient(135deg, rgb(217 171 79 / 0.08), rgb(217 171 79 / 0.02) 60%), var(--surface);
}
.panel-tested .mark-title { color: var(--brass); }
.panel-source { border-color: var(--accent); }
.panel-source .mark-title { color: var(--accent); }
.panel-mismatch { border-color: var(--danger); }
.panel-mismatch .mark-title { color: var(--danger); }
.mark-panel { display: flex; gap: var(--s-4); align-items: flex-start; }
.mark-panel .mark { flex-shrink: 0; }
.mark-title { font-family: var(--font-serif); font-weight: 700; font-size: var(--fs-h3); margin: 0 0 var(--s-1); }
.mark-title-sm { display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-sans); font-size: var(--fs-label); font-weight: 700; }
.panel p:last-child { margin-bottom: 0; }

.tags { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; padding: 0; margin: 0; }
.tag {
    display: inline-block; padding: 2px var(--s-2);
    background: var(--surface-2); color: var(--muted);
    border-radius: var(--r-sm); font-size: 13.5px; line-height: 1.6;
}
a.tag:hover { color: var(--text); text-decoration: none; }
.pill {
    display: inline-block; padding: 1px 9px;
    border: 1px solid var(--line-strong); border-radius: var(--r-round);
    font-size: var(--fs-pill); font-weight: 700; line-height: 1.5; color: var(--muted);
    vertical-align: middle;
}
.pill-ok { color: var(--accent); border-color: rgb(124 181 155 / 0.55); }
.pill-pending { color: var(--pending); border-color: rgb(157 177 209 / 0.55); }
.pill-danger { color: var(--danger); border-color: rgb(224 122 102 / 0.55); }
.pill-brass { color: var(--brass); border-color: var(--brass-dim); }
.mark { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.marks { display: inline-flex; gap: 6px; align-items: center; vertical-align: middle; }
.stars { color: var(--brass); letter-spacing: 1px; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: var(--r-round);
    background: var(--surface-2); color: var(--text);
    font-family: var(--font-serif); font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; border-radius: var(--r-round); object-fit: cover; }
.avatar-lg { width: 96px; height: 96px; font-size: 36px; }
.avatar-sm { width: 24px; height: 24px; font-size: 12px; }

/* ---------- Facts (label/value rows) ---------- */
.facts { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-4); margin: 0; font-size: var(--fs-small); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.facts-left dd { text-align: left; }
.facts-stack { display: block; }
.facts-stack dt { margin-top: var(--s-3); }
.facts-stack dt:first-child { margin-top: 0; }
.facts-stack dd { text-align: left; margin-top: var(--s-1); }

/* ---------- Tables ---------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
table.data th { text-align: left; font-weight: 500; color: var(--muted); background: var(--surface); padding: var(--s-3) var(--s-4); }
table.data td { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); vertical-align: middle; }
table.data .num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Page structure ---------- */
.page { padding-top: var(--s-8); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.section { margin-top: var(--section-gap); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s-4); }
.section-head h2 { margin: 0; }
.prose { max-width: 76ch; }
.prose h1 { font-size: var(--fs-h1); margin-top: var(--s-8); }
.prose h2 { margin-top: var(--s-8); }
.prose h3 { margin-top: var(--s-6); }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 var(--s-4); }
.prose li { margin-bottom: var(--s-1); }
.prose table { border-collapse: collapse; margin-bottom: var(--s-4); }
.prose th, .prose td { border: 1px solid var(--line); padding: var(--s-2) var(--s-3); }
.prose img { border-radius: var(--r-md); }
.prose blockquote { margin: 0 0 var(--s-4); padding-left: var(--s-4); border-left: 3px solid var(--line-strong); color: var(--muted); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) var(--sidebar-width); gap: var(--s-8); align-items: start; }
.sidebar > * + * { margin-top: var(--s-4); }
.error-page { max-width: 620px; margin: 0 auto; padding-top: var(--s-12); }

/* ---------- Hero and night sky ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); padding: var(--s-12) 0; }
.hero .wrap { position: relative; }
.hero-copy { position: relative; z-index: 1; max-width: 640px; }
.hero h1 { font-size: var(--fs-hero); font-weight: 800; line-height: 1.02; margin-bottom: var(--s-6); max-width: 7em; }
.hero-lede { color: var(--muted); font-size: 18px; max-width: 30em; margin-bottom: var(--s-6); }
.hero-search { display: flex; gap: var(--s-3); max-width: 620px; margin-bottom: var(--s-4); }
.hero-search input { min-height: 54px; }
.hero-search .btn-primary { min-height: 54px; padding: 0 var(--s-6); font-size: var(--fs-label); }
.hero-tags { max-width: 1040px; margin-bottom: var(--s-8); }
.site-stats { display: flex; gap: var(--s-8); }
.site-stats div { display: flex; flex-direction: column; }
.site-stats strong { font-family: var(--font-serif); font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.site-stats span { color: var(--muted); font-size: var(--fs-small); }
.site-stats .stat-brass strong { color: var(--brass); }
.sky { position: absolute; top: 0; right: 0; width: min(620px, 50vw); pointer-events: none; }
.sky svg { width: 100%; height: auto; display: block; }

/* ---------- Mod rows ---------- */
.mod-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-3); }
.mod-row {
    display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: var(--s-4); align-items: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4);
}
.mod-row:hover { border-color: var(--line-strong); }
.mod-icon { width: 76px; height: 76px; border-radius: var(--r-icon); background: var(--surface-2); object-fit: cover; }
.mod-icon-empty { display: block; }
.h3 { font-size: var(--fs-h3); }
.filters legend label { font-weight: 700; }
.mod-icon-lg { width: 112px; height: 112px; border-radius: var(--r-icon-lg); }
.mod-icon-sm { width: 44px; height: 44px; border-radius: 10px; }
.mod-row-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 var(--s-2); margin-bottom: 2px; }
.mod-row-title h3 { margin: 0; font-size: 21px; }
.mod-row-title h3 a { color: var(--text); }
.mod-row-title h3 a:hover { color: var(--text); text-decoration: underline; }
.byline { font-size: var(--fs-small); color: var(--muted); }
.byline a { color: var(--text); }
.mod-summary { color: var(--muted); margin: 0 0 var(--s-2); }
.mod-stats { text-align: right; font-size: var(--fs-small); color: var(--muted); display: grid; gap: 2px; white-space: nowrap; }
.mod-stats b { color: var(--text); font-variant-numeric: tabular-nums; }

.compact-list { list-style: none; padding: 0; margin: 0; }
.compact-list li { display: flex; gap: var(--s-3); align-items: center; padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.compact-list li:first-child { padding-top: 0; }
.compact-list a { color: var(--text); font-weight: 700; }
.compact-list .small { display: block; }

/* ---------- Home layout ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--s-12); }
.publish-cta { margin-top: var(--s-8); }

/* ---------- Browse ---------- */
.browse { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.filters fieldset { border: 0; padding: 0; margin: 0 0 var(--s-6); }
.filters legend { font-weight: 700; padding: 0; margin-bottom: var(--s-2); font-size: var(--fs-label); }
.filters .check { color: var(--muted); }
.filters .check:hover { color: var(--text); }
.search-bar { display: flex; gap: var(--s-3); margin-bottom: var(--s-3); }
.search-bar input { flex: 1; }
.search-bar select { width: auto; min-width: 150px; min-height: 44px; }
.result-count { color: var(--muted); font-size: var(--fs-small); margin-bottom: var(--s-4); display: flex; justify-content: space-between; }
.filter-jump { display: none; }
.pager { display: flex; justify-content: space-between; margin-top: var(--s-5); }
.empty { padding: var(--s-8) var(--s-5); text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-md); }

/* ---------- Mod page ---------- */
.mod-head { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: var(--s-6); align-items: start; }
.mod-head h1 { margin: var(--s-1) 0 var(--s-2); }
.mod-head .mod-summary { font-size: 18px; margin-bottom: var(--s-3); }
.mod-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); font-size: var(--fs-small); color: var(--muted); }
.mod-meta b { color: var(--text); }
.mod-actions { display: grid; gap: var(--s-2); min-width: 145px; }
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); margin: var(--s-8) 0 var(--s-6); overflow-x: auto; }
.tabs a { padding: var(--s-3) var(--s-4); color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 700; }
.featured-shot { margin: 0 0 var(--s-8); }
.featured-shot img, .gallery img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--line); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); list-style: none; padding: 0; margin: 0; }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.gallery figure img { border: 0; border-radius: 0; }
.gallery figcaption { padding: var(--s-3); font-size: var(--fs-small); font-weight: 700; }
.gallery figcaption span { display: block; font-weight: 400; color: var(--muted); }
.version-filter { display: flex; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.version-filter select { width: auto; }
.comment { padding: var(--s-4) 0; border-bottom: 1px solid var(--line); }
.comment-head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); font-size: var(--fs-small); }
.comment-head b { font-size: var(--fs-label); }
.comment-body { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.team-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.team-list li { display: flex; align-items: center; gap: var(--s-2); }
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-1); }

/* ---------- Version page ---------- */
.breadcrumb { font-size: var(--fs-label); margin-bottom: var(--s-4); color: var(--muted); }
.hash { font-family: var(--font-mono); font-size: 0.86em; overflow-wrap: anywhere; word-break: break-all; }

/* ---------- Profile ---------- */
.profile-head { display: flex; gap: var(--s-6); align-items: center; margin-bottom: var(--s-8); }
.profile-head h1 { margin-bottom: var(--s-1); }

/* ---------- Author tools ---------- */
.form-page { max-width: 760px; margin: 0 auto; }
.form-page > .muted { margin-bottom: var(--s-6); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--s-4); }
.form-label-sm { font-size: var(--fs-small); color: var(--muted); padding: 0; margin-bottom: var(--s-2); }
fieldset.form-field, fieldset.pill-checks { border: 0; padding: 0; margin: 0 0 var(--s-5); min-width: 0; }
.mono-input { font-family: var(--font-mono); font-size: 14px; line-height: 1.6; }
.pill-checks { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.pill-check {
    display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer;
    padding: 5px var(--s-3); border: 1px solid var(--line-strong); border-radius: var(--r-round);
    font-size: var(--fs-small); color: var(--text);
}
.pill-check:hover { border-color: var(--muted); }
.pill-check:has(input:checked) { border-color: var(--accent); background: rgb(124 181 155 / 0.08); }
.pill-check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-4); margin-bottom: var(--s-5); }
.stat-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-5); display: flex; flex-direction: column; }
.stat-card strong { font-family: var(--font-serif); font-size: 26px; line-height: 1.2; }
.stat-card span { color: var(--muted); font-size: var(--fs-small); }
.table-mod { display: inline-flex; align-items: center; gap: var(--s-3); color: var(--text); }
.manage { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.manage-main > .panel + .panel, .manage-main > form + form, .manage-main > .panel + form, .manage-main > form + .panel { margin-top: var(--s-5); }
.manage-mod { display: flex; gap: var(--s-3); align-items: center; margin-bottom: var(--s-4); }
.manage-nav nav { display: grid; gap: 2px; }
.manage-nav nav a { display: flex; justify-content: space-between; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); color: var(--muted); }
.manage-nav nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.manage-nav nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.manage-nav .count { font-size: var(--fs-small); }
.manage-nav hr { margin: var(--s-3) 0; }
.panel-danger { border-color: var(--danger); }
.panel-note { border-color: var(--pending); }
.icon-form { display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; }
.icon-form .form-field { margin: 0; }
.inline-form { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.inline-form input { max-width: 300px; }
input[type="file"] { color: var(--muted); font: inherit; font-size: var(--fs-small); }
input[type="file"]::file-selector-button {
    font: 700 var(--fs-small) var(--font-sans); color: var(--text); background: var(--surface-2);
    border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 6px var(--s-3); margin-right: var(--s-3); cursor: pointer;
}

.drop-zone {
    display: grid; gap: var(--s-1); justify-items: center; text-align: center; cursor: pointer;
    padding: var(--s-8) var(--s-5); margin-bottom: var(--s-5);
    border: 1px dashed var(--line-strong); border-radius: var(--r-md);
}
.drop-zone b { font-family: var(--font-serif); font-size: var(--fs-h3); }
.drop-zone:hover, .drop-zone:focus-within { border-color: var(--accent); }
.shot-grid { list-style: none; padding: 0; margin: var(--s-5) 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); }
.shot-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.shot-card img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }
.shot-card form { display: grid; gap: var(--s-2); padding: var(--s-3); }
.shot-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.text-danger, .btn-quiet.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.text-danger .mark, .text-accent .mark { margin-right: 4px; }
.form-error { margin: 0 0 var(--s-5); }
.source-box { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4) var(--s-5) 0; margin: 0 0 var(--s-5); }
.source-box legend { display: inline-flex; gap: var(--s-2); align-items: center; padding: 0 var(--s-2); color: var(--accent); font-weight: 700; }
.source-box .pill-check { margin-bottom: var(--s-4); }
.version-card { padding-bottom: var(--s-4); }
.version-head { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-bottom: var(--s-1); }
.tested-inline { color: var(--brass); font-size: var(--fs-small); font-weight: 700; display: inline-flex; gap: 4px; align-items: center; }
.version-card details summary { cursor: pointer; color: var(--text); }
.version-edit { margin-top: var(--s-4); }
.manage-main > p.small { margin-top: var(--s-3); }
.avatar-form { margin-bottom: var(--s-5); }
.new-token { border: 1px solid var(--accent); border-radius: var(--r-md); padding: var(--s-4); margin-bottom: var(--s-5); }
.section-sm { margin-top: var(--s-5); }
.invite-panel { display: flex; gap: var(--s-4); align-items: flex-start; margin-bottom: var(--s-6); }
.invite-panel .panel-title { margin-bottom: var(--s-1); }
.note-list { list-style: none; padding: 0; margin: 0; }
.note-list li { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.note-list a { color: var(--text); }
.note-list .read a { color: var(--muted); }
.note-list .small { white-space: nowrap; }
.comment-form { margin-bottom: var(--s-6); }
.comment-form-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-top: var(--s-3); }
.rating-input { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.rating-input legend { float: left; margin: 0 var(--s-2) 0 0; }
.rating-input label { display: inline-flex; gap: 4px; align-items: center; color: var(--brass); cursor: pointer; }
.comment-actions { display: flex; gap: var(--s-2); margin-top: var(--s-2); }
.comment-actions .btn-quiet { min-height: 28px; font-size: 13.5px; padding: 0; }
.chart-figure { margin: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--muted); font: 15px var(--font-sans); }
.chart .bar { fill: var(--accent); }
.chart .bar-now { stroke: var(--text); stroke-width: 2; }
.chart .bar-empty { stroke: var(--line-strong); stroke-width: 2; fill: none; }
.chart .hit { fill: transparent; }
.chart g:hover .bar { fill: var(--accent-hover); }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: var(--fs-small); margin-top: var(--s-2); padding-left: 4.4%; }
.share-cell { width: 40%; }
.share { width: 100%; height: 8px; display: block; }
.share-track { fill: var(--surface-2); }
.share-fill { fill: var(--accent); }
.team-name { display: inline-flex; align-items: center; gap: var(--s-2); }
.inline-form input[type="text"] { min-height: 38px; width: auto; }

/* ---------- Moderation ---------- */
.stat-cards-6 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
a.stat-card { color: var(--text); }
a.stat-card span { color: var(--accent); }
a.stat-card:hover { border-color: var(--muted); text-decoration: none; }
.manage-main > .panel, .manage-main > form.panel { margin-bottom: var(--s-5); }
.review-head { display: flex; gap: var(--s-4); align-items: center; margin-bottom: var(--s-5); }
.review-head h1 { margin: 0; }
.review-head p { margin: var(--s-1) 0 0; }
.facts-wide { grid-template-columns: minmax(120px, 180px) minmax(0, 1fr); }
.hash-inline { font-size: 0.92em; background: none; padding: 0; overflow-wrap: anywhere; }
.moderation .panel-title { font-family: var(--font-serif); font-size: 21px; font-weight: 700; margin-bottom: var(--s-4); }
.scan-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.source-status { display: inline-flex; align-items: center; gap: var(--s-1); font-weight: 700; }
.source-status.muted { font-weight: 400; }
.review-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-4); }
.review-gallery figure { margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); }
.review-gallery img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.review-gallery figcaption { padding: var(--s-2) var(--s-3); }
.version-card .facts { margin-top: var(--s-4); }
.moderation .tested-title { display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-sans); font-size: var(--fs-label); color: var(--brass); margin-bottom: var(--s-2); }
.tested-form .btn-quiet { padding: 0; }
.check-inline { margin-top: var(--s-2); display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.check-inline input[type="text"] { width: 220px; max-width: 100%; }
.source-page .lede { max-width: 640px; }
.source-page .mark-body { flex: 1; min-width: 0; }
.source-page .mark-body .facts { margin-top: var(--s-4); }
.check-row { display: flex; gap: var(--s-4); align-items: flex-start; flex-wrap: wrap; }
.check-row .form-field { flex: 1 1 320px; margin: 0; }
.check-row .btn-primary { margin-top: 28px; }
.build-log { max-height: 420px; overflow: auto; margin: var(--s-4) 0 0; padding: var(--s-4); background: var(--bg); border-radius: var(--r-sm); font-size: var(--fs-small); }
details.panel > summary { cursor: pointer; font-weight: 500; }
.report-head { display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; align-items: baseline; }
.report-head p { margin: 0; }
.report-details { margin: var(--s-3) 0 var(--s-4); }
.user-search { max-width: 420px; margin-bottom: var(--s-3); }
.users-table select { min-height: 38px; width: auto; min-width: 140px; }
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); align-items: start; }
.catalog-grid > .panel { margin: 0; }
.catalog-add { display: flex; gap: var(--s-3); margin-bottom: var(--s-4); }
.catalog-add input[type="text"] { flex: 1; min-width: 0; }
.catalog-list { list-style: none; margin: 0; padding: 0; }
.catalog-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.catalog-list code { background: none; color: var(--muted); }
@media (max-width: 960px) { .catalog-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
    .facts-wide { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .facts-wide dt { margin-top: var(--s-3); }
    .facts-wide dt:first-child { margin-top: 0; }
    .facts-wide dd { margin-top: var(--s-1); }
    .moderation .manage-nav nav { display: flex; flex-wrap: wrap; gap: var(--s-1); }
    .moderation .manage-nav nav a { padding: var(--s-1) var(--s-3); font-size: var(--fs-small); border: 1px solid var(--line); }
}
.failure-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); }
.failure-list li { display: flex; justify-content: space-between; gap: var(--s-4); align-items: flex-start; flex-wrap: wrap; }
.failure-list p { margin: var(--s-1) 0 0; }
.moderation .lede { max-width: 760px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); font-size: var(--fs-small); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .two-col, .browse, .home-grid, .manage { grid-template-columns: minmax(0, 1fr); }
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
    .browse .filters { order: 2; border-top: 1px solid var(--line); padding-top: var(--s-6); }
    .filter-jump { display: inline; }
    .header-search { display: none; }
    .sky { width: 70vw; }
}
@media (max-width: 600px) {
    :root { --fs-h1: 30px; --fs-body: 16px; }
    .site-header .wrap { gap: var(--s-4); }
    .main-nav a:not(.nav-browse), .header-actions .hide-sm { display: none; }
    .header-actions { margin-left: auto; }
    .hero { padding: var(--s-8) 0; }
    .hero-search { flex-direction: column; }
    .site-stats { gap: var(--s-6); }
    .sky { width: 44vw; top: 4px; }
    .sky .hills, .sky .minor { display: none; }
    .form-row, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .search-bar input { flex-basis: 100%; }
    .search-bar select { flex: 1; }
    .mod-row { grid-template-columns: 64px minmax(0, 1fr); align-items: start; }
    .mod-row .mod-icon { width: 64px; height: 64px; }
    .mod-stats { grid-column: 2; text-align: left; display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); white-space: normal; }
    .mod-head { grid-template-columns: 80px minmax(0, 1fr); gap: var(--s-4); }
    .mod-head .mod-icon-lg { width: 80px; height: 80px; }
    .mod-actions { grid-column: 1 / -1; grid-template-columns: 1fr auto; }
    .search-bar { flex-wrap: wrap; }
    .site-stats strong { font-size: 22px; }
}

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

/* ---------- Legal pages ---------- */
.legal-page { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.legal-nav nav { display: grid; gap: 2px; }
.legal-nav nav a { padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); color: var(--muted); }
.legal-nav nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.legal-nav nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.legal-toc { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.legal-toc p { margin: 0 0 var(--s-1); padding: 0 var(--s-3); font-size: var(--fs-small); color: var(--muted); }
.legal-nav .legal-toc a { font-size: var(--fs-small); padding: var(--s-1) var(--s-3); }
.legal-body h1 { margin-bottom: var(--s-2); }
.legal-body section { scroll-margin-top: var(--s-6); }
.table-scroll { overflow-x: auto; margin-bottom: var(--s-4); }
.table-scroll table { margin: 0; min-width: 520px; }

.legal-list { list-style: none; padding: 0; margin: var(--s-6) 0 0; }
.legal-list li { padding: var(--s-4) 0; border-bottom: 1px solid var(--line); }
.legal-list li:last-child { border-bottom: 0; }
.legal-list a { color: var(--text); font-weight: 700; }
.legal-list p { margin: var(--s-1) 0 0; }
@media (max-width: 960px) {
    .legal-page { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }
    .legal-toc { display: none; }
}
.legal-form-page, .legal-index { max-width: calc(780px + 2 * var(--s-6)); }
.legal-form-page textarea { width: 100%; }
.checks { display: grid; gap: var(--s-3); margin: var(--s-2) 0 var(--s-5); }
.checks .check { align-items: flex-start; }
.checks .check input { margin-top: 0.3em; flex-shrink: 0; }
.notice-urls { list-style: none; margin: var(--s-3) 0 0; padding: 0; overflow-wrap: anywhere; }
.site-banner { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-banner .wrap { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; padding-top: var(--s-2); padding-bottom: var(--s-2); }
.site-banner p { margin: 0; font-size: var(--fs-small); }
.narrow-form .checks .check { font-size: var(--fs-label); }

/* Email confirmation status under the settings email field */
.confirm-row { margin: calc(-1 * var(--s-2)) 0 var(--s-3); }
.confirm-row .btn-quiet { padding: 0; min-height: 28px; font-size: 13.5px; }

/* API tokens: each token is a data row plus a full-width "Change" row */
.token-form .hint { margin: calc(-1 * var(--s-2)) 0 var(--s-4); }
table.tokens tr.token-edit td { border-top: 0; padding-top: 0; }
table.tokens .token-edit summary { cursor: pointer; color: var(--muted); font-size: var(--fs-small); width: max-content; }
table.tokens .token-edit summary:hover { color: var(--text); }
table.tokens .token-edit form { padding: var(--s-4) 0 var(--s-2); max-width: 560px; }
.token-limits select { width: 100%; }
table.tokens th { white-space: nowrap; }

/* System and alerts */
.admin-banner { border-bottom-color: var(--brass-dim); }
.system-page > .panel p:last-child { margin-bottom: 0; }
table.problems summary { cursor: pointer; }
table.problems details p { margin: var(--s-2) 0 0; }
.token-search { margin: var(--s-4) 0; max-width: 480px; }
.token-admin { border-top: 1px solid var(--line); padding-top: var(--s-4); }
.raised-list { margin: 0; padding-left: var(--s-5); font-size: var(--fs-small); }

/* API docs */
.api-docs .code-block { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); font-family: var(--font-mono); font-size: 13.5px; line-height: 1.55; }
.api-ops { padding-left: var(--s-5); }
.api-ops li { margin-bottom: var(--s-2); }
