:root {
    --bg: #111111;
    --surface: #1a1a1a;
    --surface-soft: #242424;
    --card: #202020;
    --paper: #f7f4ed;
    --paper-soft: #ebe5d8;
    --text: #f3f3f0;
    --text-secondary: #c9c9c4;
    --text-muted: #8e8e88;
    --border: #343434;
    --border-dark: #4a4a4a;
    --heading: #ffffff;
    --gold: #d6a94a;
    --forest: #4d6816;
    --forest-dark: #4d6816;
    --ink: #111111;
    --parchment: #f7f4ed;
    --accent: #4d6816;
    --accent-strong: #4d6816;
    --accent-mid: #4d6816;
    --accent-soft: rgba(77, 104, 22, 0.22);
    --accent-quiet: rgba(77, 104, 22, 0.14);
    --warm-accent: #a64747;
    --danger: #d56a5f;
    --surface-lift: #2a2a2a;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 18px 42px rgba(0, 0, 0, 0.26);
    --shadow-gold: 0 14px 30px rgba(214, 169, 74, 0.12);
    --space-section: clamp(3rem, 7vw, 5rem);
    --carousel-gap: 1.25rem;
}

body.light-mode {
    --bg: #f5f7f4;
    --surface: #ffffff;
    --surface-soft: #eef2ed;
    --card: #ffffff;
    --paper: #f7f4ed;
    --paper-soft: #e7eadf;
    --text: #172018;
    --text-secondary: #516052;
    --text-muted: #758073;
    --border: #d9dfd5;
    --border-dark: #b8c3b6;
    --heading: #0f1911;
    --gold: #b9851d;
    --forest: #4d6816;
    --forest-dark: #4d6816;
    --ink: #0f1911;
    --parchment: #f7f4ed;
    --accent: #4d6816;
    --accent-strong: #4d6816;
    --accent-mid: #4d6816;
    --accent-soft: rgba(77, 104, 22, 0.12);
    --accent-quiet: rgba(77, 104, 22, 0.08);
    --warm-accent: #9f4f38;
    --danger: #b94e43;
    --surface-lift: #ffffff;
    --shadow-card: 0 16px 38px rgba(28, 45, 34, 0.09);
    --shadow-gold: 0 14px 30px rgba(77, 104, 22, 0.14);
}

html {
    scroll-behavior: smooth;
}

body {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.035), transparent 340px),
        var(--bg);
    color: var(--text);
    font-family: 'Inter', Arial, sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: color 0.25s ease;
    position: relative;
}

body:not(.light-mode) {
    background: var(--bg);
}

.brand-font { font-family: 'Inter', Arial, sans-serif; }
.parchment-text { color: var(--heading); }
.gold-accent { color: var(--gold); }

body.light-mode .text-zinc-500,
body.light-mode .text-zinc-600,
body.light-mode .text-zinc-700 {
    color: var(--text-muted);
}

body.light-mode .hover\:text-\[var\(--accent\)\]:hover {
    color: var(--accent);
}

.site-layer {
    position: relative;
    z-index: 2;
    min-height: 100vh;
}

.hero-title {
    letter-spacing: 0.16em;
    line-height: 1.15;
}

.site-header {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1.25rem;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-bottom: 2.9rem;
    padding: 1.05rem max(1.25rem, calc((100vw - 72rem) / 2 + 1.25rem));
    text-align: left;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}

body.light-mode .site-header {
    background: transparent;
}

.site-header .parchment-text {
    color: var(--ink);
}

.site-header::before {
    content: "";
    position: absolute;
    right: max(1.5rem, calc((100vw - 72rem) / 2));
    bottom: 6px;
    width: 150px;
    height: 42px;
    background-image: none;
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.65;
}

.site-header::after {
    display: none;
}

.brand-block {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.brand-mark {
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
    border-radius: 13px;
    box-shadow: 0 14px 30px rgba(0,0,0,0.28);
}

.brand-copy {
    min-width: 0;
}

.brand-title {
    margin: 0;
    font-family: 'Inter', Arial, sans-serif;
    font-size: clamp(1.6rem, 3.2vw, 2.35rem);
    font-style: italic;
    font-weight: 600;
    letter-spacing: 0.035em;
    line-height: 1;
}

.brand-subtitle {
    color: var(--text-muted);
    font-size: 9px;
    letter-spacing: 0.16em;
    margin-top: 0.35rem;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.55rem;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.65rem;
}

.section-kicker,
.section-meta,
.filter-label {
    font-family: 'Inter', Arial, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    line-height: 1.2;
}

.section-kicker {
    color: var(--paper-soft);
    font-size: 10px;
    font-weight: 700;
}

.section-meta {
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
}

.filter-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: clamp(1rem, 3vw, 1.4rem);
    box-shadow: var(--shadow-card);
}

.filter-panel,
.search-shell,
.chess-card,
.featured-shell,
.author-profile-shell,
.no-results,
.archive-pagination .page-chip.active {
    background-image: url("data:image/svg+xml,%3Csvg width='140' height='140' viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 .16'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23p)' opacity='.34'/%3E%3C/svg%3E");
}

.filter-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    width: 100%;
    height: 1px;
    pointer-events: none;
    background: var(--accent);
    opacity: 0.35;
}

.filter-panel > * {
    position: relative;
    z-index: 1;
}

.filter-row {
    display: grid;
    gap: 0.65rem;
    text-align: left;
}

.filter-label {
    color: var(--text-secondary);
    font-size: 9px;
    font-weight: 700;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.library-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.library-filter-field {
    display: grid;
    gap: 0.45rem;
    text-align: left;
}

.library-filter-field.hidden {
    display: none;
}

.library-select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    color: var(--heading);
    padding: 0.65rem 0.8rem;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.library-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(183, 154, 85, 0.14);
    outline: none;
}

.active-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: left;
}

.active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--border-dark);
    border-radius: 999px;
    padding: 0.45rem 0.65rem;
    background: var(--accent-soft);
    color: var(--heading);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.active-filter-chip button {
    color: var(--accent);
    font-size: 13px;
    line-height: 1;
}

@media (max-width: 700px) {
    .library-filter-grid {
        grid-template-columns: 1fr;
    }
}

.search-container input {
    background-color: var(--surface);
    border: 1px solid var(--border);
    color: var(--heading);
    box-shadow: var(--shadow-card);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.search-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(183, 154, 85, 0.14), var(--shadow-card);
    outline: none;
}

#searchSuggestions {
    box-shadow: 0 12px 28px rgba(32, 37, 26, 0.08);
}

.suggestion-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary);
    transition: background 0.15s ease;
}

.suggestion-row:hover {
    background: var(--accent-soft);
    color: var(--heading);
}

.suggestion-row .suggestion-kind {
    font-size: 8px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    font-style: normal;
    font-family: 'Inter', Arial, sans-serif;
}

.carousel-viewport {
    position: relative;
    overflow: hidden;
    width: calc(100% + 24px);
    margin-left: -12px;
    padding: 12px;
    margin-top: -12px;
    margin-bottom: -12px;
}

.carousel-viewport::before,
.carousel-viewport::after {
    content: "";
    position: absolute;
    top: 0;
    width: 80px;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

#latestGrid {
    display: flex;
    gap: var(--carousel-gap);
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

#recentlyViewedGrid {
    display: flex;
    gap: var(--carousel-gap);
}

.carousel-item { width: calc((100% - (var(--carousel-gap) * 2)) / 3); flex: 0 0 auto; }
@media (max-width: 1024px) { .carousel-item { width: calc((100% - var(--carousel-gap)) / 2); } }
@media (max-width: 640px) { .carousel-item { width: 100%; } }

.header-btn {
    transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    background-color: transparent;
    border-color: var(--border-dark);
    color: var(--paper-soft);
    letter-spacing: 0.18em;
    position: relative;
    overflow: hidden;
    min-height: 38px;
    align-items: center;
    border-radius: 6px;
}

.header-btn:hover {
    background: rgba(183,154,85,0.08);
    box-shadow: none;
    color: var(--paper);
    border-color: var(--border-dark);
}

.primary-action {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--ink);
}

.primary-action:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: var(--ink);
}

.header-btn:active,
#toTopBtn:active,
#themeToggle:active,
#surpriseBtn:active,
.filter-chip:active,
.featured-btn:active {
    transform: scale(0.96);
}

.featured-shell {
    position: relative;
    border: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
    transition: box-shadow 0.25s ease, border-color 0.25s ease, background 0.25s ease;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius);
}

.featured-shell:hover {
    border-color: var(--border-dark);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
    background: var(--surface);
}

.featured-layout {
    min-height: 300px;
}

.featured-image {
    position: relative;
    overflow: hidden;
    min-height: 300px;
    height: 100%;
    background: color-mix(in srgb, var(--surface-soft) 84%, var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 2.2vw, 1.35rem);
}

.featured-image img {
    width: min(100%, 285px);
    height: min(100%, 285px);
    object-fit: contain;
    object-position: center;
    opacity: 0.96;
    filter: saturate(0.82) contrast(1.03);
    transform: none;
    transition: opacity 0.35s ease, filter 0.35s ease, transform 0.35s ease;
}

.featured-shell:hover .featured-image img {
    opacity: 1;
    filter: saturate(0.95) contrast(1.05);
    transform: scale(1.01);
}

.featured-image::after {
    display: none;
}

.featured-badge {
    border: 1px solid var(--border);
    color: var(--paper);
    background: rgba(22,21,17,0.76);
    backdrop-filter: blur(4px);
    letter-spacing: 0.22em;
    box-shadow: 0 6px 16px rgba(32, 37, 26, 0.06);
}

.featured-badge,
.forest-tag,
.skill-tag,
.new-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-height: 22px;
}

.featured-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}

.featured-btn {
    transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    border: 1px solid var(--gold);
    border-radius: 6px;
}

.featured-btn:hover {
    box-shadow: 0 10px 22px rgba(0,0,0,0.12);
}

.featured-copy-panel {
    border-color: var(--border);
    background: var(--surface);
    padding: clamp(1.35rem, 3vw, 2.1rem);
}

.featured-copy-panel .gold-accent {
    color: var(--gold);
}

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

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

.chess-card {
    background: var(--surface);
    border: 1px solid var(--border);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    height: 100%;
    min-height: 0;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(18px);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.chess-card.reveal {
    opacity: 1;
    transform: translateY(0);
}

.chess-card:hover {
    border-color: var(--border-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(32, 37, 26, 0.07);
}

.card-media {
    aspect-ratio: 16 / 10;
    min-height: 0;
    flex: 0 0 auto;
}

.card-image-wrap {
    position: relative;
    overflow: hidden;
    height: 100%;
    width: 100%;
    background: var(--ink);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    opacity: 0.86;
    transform: none;
    transition: opacity 0.45s ease, filter 0.45s ease, transform 0.45s ease;
    filter: grayscale(1) sepia(0.18) saturate(0.38) contrast(1.04) brightness(0.84);
}

.chess-card:hover .card-image,
.chess-card:focus-within .card-image {
    opacity: 1;
    filter: grayscale(0.1) sepia(0.08) saturate(0.9) contrast(1.08) brightness(0.98);
    transform: scale(1.01);
}

.image-vignette {
    display: none;
}

.note-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(17,16,13,0.94);
    color: var(--paper);
    padding: 1.5rem;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50;
    font-size: 11px;
    font-style: italic;
    line-height: 1.4;
}

.chess-card:hover .note-overlay {
    transform: translateY(0);
    opacity: 1;
}

.filter-chip {
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 9999px;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.12em;
    position: relative;
    overflow: hidden;
    background: transparent;
    line-height: 1.1;
}

.filter-chip:hover {
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 8px 18px -18px color-mix(in srgb, var(--accent) 48%, transparent);
}

.filter-chip.active {
    border-color: var(--accent);
    color: var(--ink);
    background: var(--accent);
    box-shadow: 0 8px 18px rgba(32, 37, 26, 0.05);
}

.fav-btn {
    transition: color 0.25s ease, background 0.25s ease;
}

.fav-btn:hover {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.fav-btn.active {
    color: var(--gold);
}

.fav-btn.active svg {
    fill: var(--gold);
}

.forest-tag {
    background-color: var(--accent);
    color: #ffffff;
    padding: 2px 8px;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 999px;
    backdrop-filter: blur(4px);
}

.skill-tag {
    background-color: color-mix(in srgb, var(--warm-accent) 12%, var(--card));
    border: 1px solid color-mix(in srgb, var(--warm-accent) 34%, var(--border));
    color: color-mix(in srgb, var(--warm-accent) 72%, var(--heading));
    padding: 2px 8px;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    backdrop-filter: blur(4px);
    border-radius: 999px;
}

.new-tag {
    background-color: var(--warm-accent);
    color: var(--paper);
    padding: 2px 8px;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 999px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.05em;
}

.modal-overlay {
    backdrop-filter: blur(12px);
    transition: opacity 0.25s ease;
    z-index: 2000;
    background-color: rgba(17, 16, 13, 0.82);
    opacity: 1;
}

.modal-overlay .parchment-text {
    color: var(--paper);
}

.modal-overlay .text-zinc-400 {
    color: rgba(233, 223, 200, 0.78);
}

.modal-overlay .hover\:text-\[var\(--heading\)\]:hover {
    color: var(--accent-strong);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

body.light-mode .modal-overlay {
    background-color: rgba(17, 16, 13, 0.82);
}

.contribute-panel {
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
    background: var(--surface-soft);
}

#toTopBtn, #themeToggle, #surpriseBtn {
    position: fixed;
    bottom: 40px;
    width: 45px;
    height: 45px;
    background: rgba(17,16,13,0.88);
    border: 1px solid var(--border-dark);
    color: var(--paper-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(8px);
}

#toTopBtn {
    right: 40px;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

#toTopBtn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#themeToggle { right: 95px; }
#surpriseBtn { right: 150px; }

#toTopBtn:hover, #themeToggle:hover, #surpriseBtn:hover {
    border-color: var(--accent);
    box-shadow: 0 12px 28px rgba(0,0,0,0.26);
    color: var(--paper);
}

#toTopBtn svg, #themeToggle svg, #surpriseBtn svg {
    transition: transform 0.5s;
    transform: rotate(0deg);
}

#toTopBtn:hover svg, #themeToggle:hover svg, #surpriseBtn:hover svg {
    transform: none;
    color: var(--accent);
}

#liveCounter {
    font-size: 10px;
    letter-spacing: 0.3em;
    transition: all 0.3s ease;
}

.copy-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--paper);
    padding: 8px 16px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 2px;
    z-index: 5000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.author-profile-shell {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto 3rem auto;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
    background: var(--card);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border-radius: var(--radius);
}

.author-profile-header {
    position: relative;
    padding: 1.6rem 1.25rem 1.4rem;
    border-bottom: 1px solid color-mix(in srgb, var(--accent) 14%, var(--border));
    background: var(--accent-quiet);
}

.author-profile-header-inner {
    max-width: 1100px;
    margin: 0 auto;
}

.author-profile-top-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
    margin-bottom: 0.9rem;
}

.author-profile-name {
    font-family: 'Inter', Arial, sans-serif;
    color: var(--heading);
    font-size: clamp(1.45rem, 3vw, 2.35rem);
    line-height: 1.08;
    letter-spacing: 0.02em;
    text-transform: none;
    margin: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.author-profile-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
    background: var(--card);
    color: var(--heading);
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
    white-space: nowrap;
}

.author-profile-badge .flag {
    font-size: 1rem;
    line-height: 1;
}

.author-profile-subtitle {
    margin-top: 0.2rem;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--accent) 88%, var(--heading));
    font-family: 'Inter', Arial, sans-serif;
}

.author-profile-body {
    padding: 1.15rem;
}

.author-profile-grid {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.author-profile-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.author-profile-card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
    box-shadow: 0 14px 28px -22px color-mix(in srgb, var(--accent) 28%, transparent);
}

.author-card-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 9px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.9rem;
    font-family: 'Inter', Arial, sans-serif;
}

.author-card-label .dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--gold);
    opacity: 0.9;
    flex: 0 0 auto;
}

.author-card-text {
    color: var(--text);
    line-height: 1.65;
    font-style: italic;
    font-size: 14px;
    white-space: pre-line;
}

.author-bio-card {
    grid-column: 1 / -1;
}

.author-country-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.author-country-flag {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--accent) 12%, var(--card));
    border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
    font-size: 1.3rem;
    flex: 0 0 auto;
}

.author-country-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.author-country-name {
    color: var(--heading);
    font-style: normal;
    font-size: 14px;
    line-height: 1.35;
}

.author-country-sub {
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--accent) 88%, var(--heading));
    font-family: 'Inter', Arial, sans-serif;
}

.author-links-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.author-link-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 100%;
    padding: 0.62rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--heading);
    text-decoration: none;
    word-break: break-word;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
    font-style: normal;
    font-size: 12px;
    line-height: 1.2;
}

.author-link-chip:hover {
    transform: translateY(-2px);
    border-color: var(--gold);
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    color: var(--gold);
}

.author-link-chip svg {
    flex: 0 0 auto;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 1.15rem;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
    transition: color 0.25s ease, transform 0.25s ease;
    font-family: 'Inter', Arial, sans-serif;
}

.back-btn:hover {
    color: var(--heading);
    transform: translateX(-2px);
}

.author-profile-footer {
    max-width: 1100px;
    margin: 1rem auto 0 auto;
    padding: 0 1.25rem 1.25rem 1.25rem;
    color: color-mix(in srgb, var(--accent) 70%, transparent);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-family: 'Inter', Arial, sans-serif;
}

.author-link {
    color: var(--gold);
    text-decoration: underline;
    word-break: break-word;
}

.preview-title {
    font-family: 'Inter', Arial, sans-serif;
    color: var(--heading);
    font-size: clamp(1.15rem, 2.4vw, 1.75rem);
    line-height: 1.3;
    letter-spacing: 0.01em;
    text-transform: none;
    margin: 0;
    font-style: italic;
}

.study-card-body {
    padding: 1rem 1.05rem 1.1rem;
    min-height: 168px;
    display: grid;
    grid-template-rows: auto minmax(2.8rem, auto) auto auto;
    gap: 0.5rem;
}

.card-category {
    display: block;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

.card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8rem;
    font-family: 'Inter', Arial, sans-serif;
    font-size: 1.12rem;
    font-weight: 600;
    line-height: 1.28;
}

.featured-copy-panel h2 {
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.015em;
}

.card-author {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.22rem;
    max-width: 100%;
    overflow: hidden;
    font-size: 12px;
    color: var(--text-secondary);
}

.card-author-link {
    display: inline;
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: left;
    cursor: pointer;
}

.card-author-link:hover {
    color: var(--heading);
    text-decoration: underline;
}

.card-author-separator {
    color: var(--gold);
    opacity: 0.55;
}

.featured-author-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    color: var(--gold);
}

.card-note {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 0;
}

.card-open-link {
    align-self: end;
    width: fit-content;
    color: var(--accent);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: none;
}

.card-open-link:hover {
    color: var(--heading);
}

.empty-state {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
    padding: 2rem;
    text-align: center;
}

.archive-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
    margin-bottom: clamp(2.25rem, 5vw, 3.5rem);
}

.archive-pagination .page-chip {
    appearance: none;
    background: transparent;
}

.archive-pagination .page-chip[disabled] {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.archive-pagination .page-chip.active {
    border-color: var(--gold);
    color: var(--heading);
    background: var(--card);
    box-shadow: 0 8px 18px -18px color-mix(in srgb, var(--accent) 48%, transparent);
}

.staff-pick-ribbon {
    background: var(--warm-accent);
    color: var(--paper);
}

.site-footer {
    position: relative;
    width: 100vw;
    margin: 6rem 0 0 calc(50% - 50vw);
    padding: 0;
    border: 0;
    border-top: 1px solid var(--border-dark);
    border-radius: 0;
    background: var(--paper-deep);
    overflow: hidden;
    box-shadow: 0 -10px 30px rgba(32, 37, 26, 0.08);
}

.site-footer::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 1px;
    pointer-events: none;
    background: var(--accent);
    opacity: 0.42;
}

.footer-inner {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    max-width: 72rem;
    margin: 0 auto;
    padding: 2.5rem max(1.25rem, calc((100vw - 72rem) / 2 + 1.25rem)) 2.1rem;
}

.footer-brand {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
    max-width: 760px;
}

.footer-mark {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid rgba(233,223,200,0.28);
}

.footer-title {
    margin: 0;
    color: var(--paper);
    font-family: 'Inter', Arial, sans-serif;
    font-size: 1.45rem;
    font-style: italic;
    font-weight: 600;
    line-height: 1.1;
}

.footer-description {
    margin: 0.35rem 0 0;
    max-width: 54rem;
    color: rgba(233,223,200,0.78);
    font-size: 0.95rem;
    line-height: 1.65;
    font-style: italic;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    margin-top: 1.8rem;
    padding-top: 1.15rem;
    border-top: 1px solid rgba(233,223,200,0.16);
}

.footer-nav a,
.footer-nav button {
    color: rgba(233,223,200,0.78);
    font-size: 0.68rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.footer-nav a:hover,
.footer-nav button:hover {
    color: var(--accent-strong);
}

.footer-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    margin-top: 1.4rem;
    color: rgba(233,223,200,0.6);
    font-size: 0.72rem;
    line-height: 1.6;
}

.site-footer p {
    margin: 0;
}

@media (min-width: 768px) {
    .author-profile-header {
        padding: 2rem 2rem 1.7rem;
    }

    .author-profile-top-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1.25rem;
    }

    .author-profile-badge {
        margin-left: auto;
    }

    .author-profile-body {
        padding: 1.4rem 2rem 1.8rem 2rem;
    }

    .author-profile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.15rem;
    }

    .author-bio-card {
        grid-column: 1 / -1;
    }
}

@media (min-width: 1024px) {
    .author-profile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .author-bio-card {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {

    #toTopBtn, #themeToggle, #surpriseBtn {
        bottom: 20px;
    }

    #toTopBtn { right: 20px; }
    #themeToggle { right: 75px; }
    #surpriseBtn { right: 130px; }

    .featured-shell {
        max-width: 100%;
    }

    .featured-image {
        min-height: 190px;
        height: 190px;
    }

    .featured-image img {
        width: min(100%, 240px);
        height: min(100%, 240px);
    }

    .site-footer {
        margin-top: 4rem;
    }

    .footer-inner {
        padding: 1.6rem 1.25rem 1.55rem;
    }

    .footer-brand {
        grid-template-columns: 1fr;
    }

    .footer-meta {
        display: block;
    }

    .footer-meta p + p {
        margin-top: 0.65rem;
    }

    .author-profile-body {
        padding: 1rem;
    }

    .author-profile-header {
        padding: 1.5rem 1rem;
    }
}

@media (max-width: 820px) {
    .site-header {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .brand-block {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
    }

    .header-actions {
        justify-content: center;
    }
}

/* Modern chess-learning platform cleanup */
html,
body {
    min-height: 100%;
}

body {
    min-height: 100vh;
}

body::before,
body::after,
.site-layer::before,
.site-layer::after,
.filter-panel::before,
.filter-panel::after,
#liveCounter::after {
    display: none !important;
    content: none !important;
}

body > .site-layer {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none !important;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

body > .site-layer > :not(.site-header):not(.site-footer) {
    width: min(100% - 2rem, 1180px);
    margin-left: auto;
    margin-right: auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 90;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    width: 100%;
    margin: 0 0 2.25rem;
    padding: 0.9rem max(1rem, calc((100vw - 1180px) / 2 + 1rem));
    border: 0;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(16px);
    overflow: visible;
}

.site-header .parchment-text,
body.light-mode .site-header .parchment-text {
    color: var(--heading);
}

.brand-block {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.brand-mark {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    box-shadow: none;
}

.brand-title {
    margin: 0;
    color: var(--heading);
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(1.45rem, 2.6vw, 2rem);
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.05;
}

.brand-subtitle {
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.55rem;
}

.header-btn,
.primary-action {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    box-shadow: none;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.header-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--heading);
}

.primary-action {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--parchment);
}

.primary-action:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: var(--parchment);
}

#themeToggle {
    display: flex;
}

#libraryControls {
    margin-bottom: 3rem !important;
}

.community-library-note {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.35fr);
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.35rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    text-align: left;
}

.community-library-note h2 {
    margin: 0;
    color: var(--heading);
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(1.35rem, 2vw, 1.85rem);
    font-weight: 700;
    line-height: 1.08;
}

.community-library-note p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.65;
}

.community-eyebrow {
    margin-bottom: 0.45rem !important;
    color: var(--accent) !important;
    font-size: 0.72rem !important;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.search-container input {
    min-height: 58px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--heading);
    box-shadow: var(--shadow-card);
    font-family: 'Inter', Arial, sans-serif;
    font-size: 0.98rem;
    font-style: normal;
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-card);
}

.filter-panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    padding: clamp(1rem, 3vw, 1.35rem);
    box-shadow: var(--shadow-card);
}

.library-filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
}

.filter-label {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.library-select {
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--heading);
    padding: 0.65rem 0.75rem;
    font-family: 'Inter', Arial, sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.library-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-chip,
.active-filter-chip,
.archive-pagination .page-chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-family: 'Inter', Arial, sans-serif;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
}

.filter-chip:hover,
.filter-chip.active,
.active-filter-chip,
.archive-pagination .page-chip.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--heading);
}

#liveCounter {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.section-heading {
    border-bottom: 1px solid var(--border);
}

.section-kicker {
    color: var(--heading);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.section-meta {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.carousel-viewport {
    width: calc(100% + 32px);
    margin-left: -16px;
    padding: 16px;
}

#resultsGrid {
    gap: 1.65rem !important;
}

#archiveHeader,
#authorProfileSection {
    scroll-margin-top: 7rem;
}

.carousel-item {
    width: calc((100% - (var(--carousel-gap) * 2)) / 3);
}

.chess-card {
    min-height: 430px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow-card);
}

.chess-card:hover {
    border-color: var(--accent);
    box-shadow: 0 20px 46px rgba(0, 0, 0, 0.16);
    transform: translateY(-3px);
}

.card-media {
    aspect-ratio: 16 / 11;
}

.card-image-wrap {
    background: var(--surface-soft);
}

.card-image-wrap.thumbnail-generated,
.card-image-wrap.thumbnail-study-generated,
.card-image-wrap.thumbnail-screenshot-generated {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-image {
    opacity: 0.95;
    filter: none;
}

.thumbnail-generated .card-image,
.thumbnail-study-generated .card-image,
.thumbnail-screenshot-generated .card-image {
    object-fit: contain;
}

.thumbnail-manual .card-image,
.thumbnail-fallback .card-image {
    object-fit: contain;
}

.chess-card:hover .card-image,
.chess-card:focus-within .card-image {
    opacity: 1;
    filter: none;
    transform: scale(1.015);
}

.study-card-body {
    min-height: 190px;
    padding: 1.2rem 1.25rem 1.3rem;
    gap: 0.68rem;
}

.card-category {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.card-title {
    min-height: 3.25rem;
    color: var(--heading);
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(1.25rem, 1.6vw, 1.52rem);
    font-style: normal;
    font-weight: 700;
    line-height: 1.18;
}

.card-author,
.card-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.card-author-link,
.author-link,
.author-link-chip {
    color: var(--gold);
}

.card-open-link {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    opacity: 0.88;
}

.card-open-link:hover {
    color: var(--accent);
    opacity: 1;
}

.side-badge,
.new-tag,
.staff-pick-ribbon,
.featured-badge {
    background: var(--accent);
    color: #ffffff;
}

.featured-shell {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow-card);
}

.featured-shell:hover {
    border-color: var(--accent);
    box-shadow: 0 20px 46px rgba(0, 0, 0, 0.16);
}

.featured-image {
    background: color-mix(in srgb, var(--surface-soft) 84%, var(--accent));
}

.featured-image img {
    opacity: 0.96;
    filter: saturate(0.82) contrast(1.03);
}

.featured-copy-panel {
    background: var(--card);
    padding: clamp(1.35rem, 3vw, 2.1rem);
}

.featured-copy-panel h2,
.preview-title,
.author-profile-name {
    color: var(--heading);
    font-family: 'Fraunces', Georgia, serif;
    font-style: normal;
}

.featured-spotlight-text,
.featured-taxonomy-text,
.featured-author-line,
.author-profile-subtitle {
    color: var(--text-secondary);
}

.featured-btn {
    border-color: var(--border);
    background: var(--surface-soft);
    color: var(--heading);
}

.featured-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--heading);
}

.modal-overlay,
body.light-mode .modal-overlay {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
}

.modal-overlay .parchment-text,
.modal-overlay .text-zinc-400 {
    color: var(--text);
}

.contribute-panel,
.author-profile-shell,
.author-profile-header,
.author-profile-card,
.empty-state,
.no-results {
    border-color: var(--border);
    background: var(--surface);
}

#surpriseBtn,
#themeToggle,
#toTopBtn {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text-secondary);
    backdrop-filter: blur(12px);
    transition: border-color 0.22s ease, box-shadow 0.22s ease, color 0.22s ease, background 0.22s ease, transform 0.22s ease, filter 0.22s ease;
}

#surpriseBtn:hover,
#themeToggle:hover,
#toTopBtn:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-card);
    filter: brightness(1.04);
    transform: translateY(-3px) scale(1.035);
}

#themeToggle:hover svg,
#surpriseBtn:hover svg,
#toTopBtn:hover svg {
    color: var(--accent);
    transform: scale(1.08);
}

.site-footer {
    width: 100%;
    margin: auto 0 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow: none;
}

.site-footer::before {
    display: none;
}

.footer-inner {
    max-width: 1180px;
    padding: 2rem 1rem;
}

.footer-mark {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.footer-title {
    color: var(--heading);
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.35rem;
    font-style: normal;
    font-weight: 700;
}

.footer-description,
.footer-nav a,
.footer-nav button,
.footer-meta {
    color: var(--text-secondary);
}

.footer-nav {
    border-top-color: var(--border);
}

.footer-nav a:hover,
.footer-nav button:hover {
    color: var(--accent);
}

@media (min-width: 1180px) {
    #resultsGrid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 1024px) {
    .library-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .carousel-item {
        width: calc((100% - var(--carousel-gap)) / 2);
    }
}

@media (max-width: 760px) {
    body > .site-layer > :not(.site-header):not(.site-footer) {
        width: min(100% - 1rem, 1180px);
    }

    .site-header {
        grid-template-columns: 1fr;
        padding: 0.8rem 1rem;
    }

    .brand-block {
        grid-template-columns: auto minmax(0, 1fr);
        justify-self: stretch;
        text-align: left;
    }

    .header-actions {
        justify-content: flex-start;
        gap: 0.45rem;
    }

    .header-btn,
    .primary-action {
        min-height: 36px;
        padding: 0.55rem 0.75rem !important;
        font-size: 0.62rem !important;
    }

    .library-filter-grid {
        grid-template-columns: 1fr;
    }

    .community-library-note {
        grid-template-columns: 1fr;
        gap: 0.85rem;
        padding: 1rem;
    }

    #resultsGrid {
        gap: 1rem !important;
    }

    .carousel-item {
        width: 100%;
    }

    .chess-card {
        min-height: 400px;
        border-radius: 16px;
    }
}

.endgame-trainer-section {
    margin-bottom: 4rem;
}

.trainer-hero,
.trainer-sidebar,
.trainer-board-panel,
.trainer-task-card,
.trainer-progress-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.trainer-hero {
    margin-bottom: 1.5rem;
    padding: clamp(1.25rem, 3vw, 2rem);
}

.trainer-hero h2 {
    margin: 0.35rem 0 0.75rem;
    color: var(--heading);
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1;
}

.trainer-hero p:last-child {
    max-width: 760px;
    color: var(--text-secondary);
    line-height: 1.65;
}

.trainer-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 1.25rem;
}

.trainer-sidebar {
    padding: 1rem;
    align-self: start;
}

.trainer-category {
    display: grid;
    gap: 0.18rem;
    width: 100%;
    margin-top: 0.7rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--heading);
    text-align: left;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.trainer-category:hover,
.trainer-category.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.trainer-category span {
    font-weight: 800;
}

.trainer-category small,
.trainer-progress-card small {
    color: var(--text-muted);
}

.trainer-progress-card {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface-soft);
}

.trainer-progress-card strong {
    display: block;
    color: var(--accent);
    font-family: 'Fraunces', Georgia, serif;
    font-size: 2rem;
    line-height: 1;
}

.trainer-progress-card span {
    display: block;
    margin: 0.25rem 0;
    color: var(--heading);
    font-weight: 800;
}

.trainer-board-panel {
    padding: clamp(1rem, 2.4vw, 1.4rem);
}

.trainer-board-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
    gap: 1rem;
    align-items: end;
    margin-bottom: 1rem;
}

.trainer-board-header h3 {
    margin: 0.3rem 0 0.35rem;
    color: var(--heading);
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(1.45rem, 3vw, 2.1rem);
}

.trainer-board-header p {
    margin: 0;
    color: var(--text-secondary);
}

.trainer-practice {
    display: grid;
    grid-template-columns: minmax(320px, 520px) minmax(240px, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.trainer-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    width: min(100%, 520px);
    aspect-ratio: 1;
    overflow: hidden;
    border: 1px solid var(--border-dark);
    border-radius: 14px;
    background: var(--ink);
}

.trainer-square {
    position: relative;
    display: grid;
    place-items: center;
    border: 0;
    color: var(--ink);
    cursor: pointer;
    transition: box-shadow 0.16s ease, filter 0.16s ease;
}

.trainer-square.is-light {
    background: #d8c6a3;
}

.trainer-square.is-dark {
    background: #7e694d;
}

.trainer-square:hover,
.trainer-square.selected {
    box-shadow: inset 0 0 0 4px var(--accent);
    filter: brightness(1.06);
}

.trainer-piece {
    color: #111827;
    font-size: clamp(2rem, 6vw, 3.7rem);
    line-height: 1;
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}

.trainer-coord {
    position: absolute;
    right: 5px;
    bottom: 4px;
    color: rgba(17, 24, 39, 0.52);
    font-size: 0.58rem;
    font-weight: 800;
}

.trainer-task-card {
    padding: 1.1rem;
    background: var(--surface-soft);
}

.trainer-task-card h4 {
    margin: 0.35rem 0 0.6rem;
    color: var(--heading);
    font-size: 1.25rem;
    font-weight: 800;
}

.trainer-task-card p {
    color: var(--text-secondary);
    line-height: 1.55;
}

.trainer-task-card dl {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
    margin: 1rem 0;
}

.trainer-task-card dt {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.trainer-task-card dd {
    margin: 0.15rem 0 0;
    color: var(--heading);
    font-weight: 800;
}

.trainer-status {
    margin: 1rem 0;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--text-secondary);
    font-weight: 700;
}

.trainer-status.complete {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--heading);
}

.trainer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.trainer-fen {
    margin-top: 1rem !important;
    color: var(--text-muted) !important;
    font-size: 0.72rem;
    overflow-wrap: anywhere;
}

body.training-view .site-footer {
    margin-top: auto;
}

@media (max-width: 980px) {
    .trainer-layout,
    .trainer-practice,
    .trainer-board-header {
        grid-template-columns: 1fr;
    }

    .trainer-sidebar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .trainer-sidebar .section-kicker,
    .trainer-progress-card {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .trainer-sidebar {
        grid-template-columns: 1fr;
    }

    .trainer-practice {
        gap: 1rem;
    }

    .trainer-board {
        width: 100%;
    }

    .trainer-task-card dl {
        grid-template-columns: 1fr;
    }
}

/* Final visual tone pass: black library, green controls, gold accents. */
:root {
    --bg: #070806;
    --surface: #0d0f0b;
    --surface-soft: #12150f;
    --card: #0d0e0c;
    --text: #f2efe5;
    --text-secondary: #c8bea4;
    --text-muted: #7f7a70;
    --border: #20231d;
    --border-dark: #303529;
    --heading: #fff9e8;
    --gold: #d5aa44;
    --forest: #0f5d39;
    --forest-dark: #0a432b;
    --ink: #fff9e8;
    --accent: #0f5d39;
    --accent-strong: #157346;
    --accent-mid: #0f5d39;
    --accent-soft: rgba(15, 93, 57, 0.24);
    --accent-quiet: rgba(15, 93, 57, 0.13);
    --surface-lift: #151710;
    --shadow-card: 0 18px 42px rgba(0, 0, 0, 0.34);
    --shadow-gold: 0 14px 30px rgba(213, 170, 68, 0.13);
}

body.light-mode {
    --bg: #f4f0e6;
    --surface: #fffaf0;
    --surface-soft: #ebe5d6;
    --card: #fffdf5;
    --text: #171713;
    --text-secondary: #514937;
    --text-muted: #817762;
    --border: #d7cdb8;
    --border-dark: #b9aa8d;
    --heading: #080907;
    --gold: #a9791d;
    --forest: #0f5d39;
    --forest-dark: #0a432b;
    --ink: #080907;
    --accent: #0f5d39;
    --accent-strong: #157346;
    --accent-mid: #0f5d39;
    --accent-soft: rgba(15, 93, 57, 0.14);
    --accent-quiet: rgba(15, 93, 57, 0.08);
    --surface-lift: #ffffff;
    --shadow-card: 0 18px 42px rgba(25, 23, 17, 0.12);
    --shadow-gold: 0 14px 30px rgba(169, 121, 29, 0.12);
}

body,
body:not(.light-mode) {
    background:
        radial-gradient(circle at 50% -12%, rgba(213, 170, 68, 0.055), transparent 28rem),
        #070806;
    color: var(--text);
}

body.light-mode {
    background:
        radial-gradient(circle at 50% -12%, rgba(15, 93, 57, 0.07), transparent 30rem),
        #f4f0e6;
}

.brand-title,
.card-title,
.featured-copy-panel h2,
.author-profile-name,
.footer-title {
    font-family: 'Fraunces', Georgia, serif;
    color: var(--heading);
}

.brand-subtitle,
.section-kicker,
.community-eyebrow,
.filter-label,
.card-category,
.featured-badge,
.forest-tag,
.skill-tag,
.staff-pick-ribbon,
.header-btn,
.primary-action,
.filter-chip,
.library-select {
    font-family: 'Inter', Arial, sans-serif;
    letter-spacing: 0.13em;
}

.site-header,
body.light-mode .site-header {
    background: #11120e;
    border-bottom-color: color-mix(in srgb, var(--gold) 24%, transparent);
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.36);
}

body.light-mode .site-header {
    background: #fffaf0;
    border-bottom-color: color-mix(in srgb, var(--gold) 30%, var(--border));
    box-shadow: 0 12px 34px rgba(32, 27, 17, 0.12);
}

.site-header .parchment-text,
body.light-mode .site-header .parchment-text {
    color: var(--heading);
}

.community-library-note,
.library-control-panel,
.search-container input,
.featured-shell,
.chess-card,
.site-footer,
.modal-card,
.author-profile-shell,
.author-profile-card,
.trainer-shell {
    background: var(--card);
    border-color: var(--border);
}

.search-container input,
.library-select {
    color: var(--heading);
}

.search-container input::placeholder {
    color: color-mix(in srgb, var(--text-muted) 78%, transparent);
}

.header-btn,
.filter-chip,
.featured-btn {
    border-color: color-mix(in srgb, var(--gold) 28%, var(--border));
    color: var(--text-secondary);
}

.header-btn:hover,
.filter-chip:hover,
.featured-btn:hover {
    border-color: var(--accent);
    color: var(--heading);
    background: var(--accent-soft);
}

.primary-action,
.forest-tag,
.active-filter-chip {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff9e8;
}

.primary-action:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.gold-accent,
.card-author,
.card-author-link,
.open-link,
.footer-nav a:hover,
.section-kicker:last-child {
    color: var(--gold) !important;
}

.staff-pick-ribbon {
    background: var(--gold);
    color: #17130a;
}

.card-image,
.featured-image img {
    opacity: 1;
    filter: grayscale(1) saturate(0) contrast(1.04);
    transition: filter 0.8s ease-in-out, opacity 0.28s ease, transform 0.28s ease;
}

.chess-card:hover .card-image,
.chess-card:focus-within .card-image,
.featured-shell:hover .featured-image img,
.featured-shell:focus-within .featured-image img {
    filter: grayscale(0) saturate(1) contrast(1.02);
}

.card-image-wrap {
    background: #070806;
}

body.light-mode .card-image-wrap {
    background: var(--surface-soft);
}

/* Small typography polish: modern-classy spacing and softer title forms. */
.brand-title {
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 220;
    text-transform: uppercase;
    letter-spacing: clamp(0.18em, 0.64vw, 0.46em);
    line-height: 1.05;
}

.brand-subtitle,
.section-kicker,
.featured-copy-panel .gold-accent,
.card-category {
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 620;
    letter-spacing: 0.18em;
}

.card-title,
.featured-copy-panel h2,
.author-profile-name {
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 360;
    letter-spacing: 0.01em;
}

.card-title {
    font-size: clamp(1.05rem, 1.28vw, 1.26rem);
    font-weight: 360;
    line-height: 1.2;
}

.card-author {
    color: color-mix(in srgb, var(--gold) 78%, var(--text-muted)) !important;
    font-size: 0.78rem;
}

.card-author-link {
    color: color-mix(in srgb, var(--gold) 82%, var(--text-muted)) !important;
}

.card-author-separator {
    color: color-mix(in srgb, var(--gold) 55%, var(--text-muted));
}

.card-open-link {
    color: color-mix(in srgb, var(--text-muted) 86%, var(--gold)) !important;
    font-size: 0.66rem;
    font-weight: 560;
    letter-spacing: 0.1em;
    opacity: 0.76;
}

.card-open-link:hover {
    color: var(--gold) !important;
    opacity: 0.95;
}

/* Header-only typography refinement. */
.brand-title {
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Inter, Arial, sans-serif;
    font-size: clamp(1.45rem, 2.15vw, 2.28rem);
    font-weight: 300;
    letter-spacing: clamp(0.12em, 0.42vw, 0.28em);
    line-height: 1.08;
}

.brand-subtitle {
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Inter, Arial, sans-serif;
    font-size: clamp(0.58rem, 0.72vw, 0.68rem);
    font-weight: 500;
    letter-spacing: 0.16em;
}

/* Small label and featured-board tone refinement. */
.section-kicker:last-child,
#featuredSection .section-kicker:last-child,
#featuredSection .section-heading .section-meta,
#liveCounter {
    color: var(--gold) !important;
}

.filter-label,
.library-select,
#liveCounter,
.section-kicker,
#featuredSection .section-heading .section-meta {
    font-weight: 520;
}

.featured-image {
    background: #070806;
    border-right: 1px solid var(--border);
}

body.light-mode .featured-image {
    background: var(--surface-soft);
}

.featured-shell:hover {
    border-color: var(--border-dark);
}

/* Curated collections share the library's cards and theme tokens. */
.library-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 1.5rem 0 2rem;
    border-bottom: 1px solid var(--border);
}
.library-tabs a {
    white-space: nowrap;
    padding: 0.7rem 0;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
}
.library-tabs a[aria-current="page"],
.library-tabs a:hover { color: var(--gold); border-bottom-color: var(--gold); }
.collection-intro { max-width: 850px; margin: 0 0 2.5rem; }
.collection-intro h1 { font-size: 2rem; font-weight: 400; line-height: 1.2; margin: 1rem 0; }
.collection-intro p { line-height: 1.7; margin: 0.8rem 0; color: var(--text-secondary); }
.collection-intro .collection-guidance { font-size: 0.9rem; }
.collection-level { color: var(--gold); font-size: 0.85rem; line-height: 1.5; }
.collection-jump-links { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; margin-top: 1.4rem; }
.collection-jump-links a { text-decoration: underline; text-underline-offset: 4px; font-size: 0.9rem; }
.collection-group { margin: 0 0 3rem; scroll-margin-top: 150px; }
.collection-group > h2 { font-size: 1.35rem; font-weight: 400; padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.collection-study-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem 1.5rem; }
.collection-entry { min-width: 0; display: grid; grid-template-rows: subgrid; grid-row: span 2; row-gap: 1rem; }
.collection-curator-note { line-height: 1.65; font-size: 0.95rem; color: var(--text-secondary); }
.collection-curator-note h3 { color: var(--heading); font-size: 1.1rem; font-weight: 500; margin-bottom: 0.4rem; }
.collection-curator-note .collection-level { margin-bottom: 0.4rem; }
.collection-entry .chess-card { height: auto; opacity: 1; transform: none; }
.collection-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; margin-bottom: 3rem; }
.collection-summary { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--card); }
.collection-summary > img { aspect-ratio: 16 / 9; height: auto; width: 100%; object-fit: contain; background: var(--surface-soft); filter: grayscale(1); transition: filter 0.8s ease-in-out; }
.collection-summary:hover > img, .collection-summary:focus-visible > img { filter: none; }

@media (prefers-reduced-motion: reduce) {
    .card-image,
    .featured-image img,
    .collection-summary > img { transition: none; }
}
.collection-summary > div { padding: 1.5rem; }
.collection-summary h2 { font-size: 1.4rem; line-height: 1.35; font-weight: 400; margin: 0.75rem 0; }
.collection-summary p { line-height: 1.65; margin-bottom: 1rem; }
.collection-missing { padding: 1.5rem; border: 1px solid var(--border); }
.scf-discovery-links { display: flex; flex-wrap: wrap; gap: 0.6rem 1.3rem; margin-top: 1rem; font-size: 0.85rem; }
.scf-discovery-links a, .study-details-link { color: var(--gold); text-decoration: underline; text-underline-offset: 4px; }
.study-details-link { display: inline-block; margin-top: 0.8rem; font-size: 0.8rem; }
.scf-page { padding-bottom: 3rem; }
.scf-page h2 { font-size: 1.35rem; font-weight: 500; margin: 2rem 0 0.8rem; }
.scf-page p, .scf-page li { line-height: 1.75; color: var(--text-secondary); }
.scf-page p { margin-bottom: 1rem; }
.scf-page ul, .scf-page ol { padding-left: 1.4rem; list-style: revert; }
.scf-page a:not(.card-media):not(.card-title):not(.fav-btn) { text-underline-offset: 4px; }
.scf-page > section { max-width: 850px; margin-bottom: 2rem; }
.scf-schedule { width: 100%; border-collapse: collapse; margin: 1.5rem 0; }
.scf-schedule th, .scf-schedule td { text-align: left; padding: 1rem 0.75rem; border-bottom: 1px solid var(--border); }
.scf-schedule th { font-weight: 500; color: var(--gold); }
.scf-schedule caption { text-align: left; margin-bottom: 1rem; color: var(--text-secondary); }
.scf-detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
.scf-detail-layout .chess-card { opacity: 1; transform: none; }
.scf-page a:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
@media (max-width: 640px) {
    .scf-detail-layout { grid-template-columns: minmax(0, 1fr); }
    .library-tabs { gap: 0.5rem 1rem; font-size: 0.9rem; }
    .scf-schedule th, .scf-schedule td { padding: 0.8rem 0.35rem; font-size: 0.85rem; }
}
.collections-view .collection-entry a:focus-visible,
.library-tabs a:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
@media (max-width: 1000px) {
    .collection-study-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .collection-study-grid, .collection-overview { grid-template-columns: minmax(0, 1fr); }
    .collection-intro h1 { font-size: 1.6rem; overflow-wrap: anywhere; }
    .collection-group { scroll-margin-top: 220px; }
}
