/* ======================================================================
   RPG Maker Forums Archive — CSS
   Light & Dark themes. Dark is XenForo-inspired teal; Light matches the
   original RPGMakerWeb forum light theme colors from LightModeExample.
   ====================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- Dark Theme (default for prefers-color-scheme:dark) -------------- */
:root, [data-theme="dark"] {
    --bg-body:         #111722;
    --bg-threadlist:   #141b28;
    --bg-surface:      #182230;
    --bg-card:         #1c2738;
    --bg-card-hover:   #233146;
    --bg-input:        #151e2b;
    --bg-header:       #0d141e;
    --bg-accent:       #0a3d5c;
    --bg-post:         #1c2738;
    --bg-post-sidebar: #17202e;
    --bg-post-header:  #192332;

    --text-primary:  #e0e6ed;
    --text-secondary:#8899a6;
    --text-muted:    #556677;
    --text-link:     #4fc3f7;
    --text-link-hover:#81d4fa;

    --accent:        #00acc1;
    --accent-bright: #26c6da;
    --accent-dim:    #00838f;
    --accent-glow:   rgba(0,172,193,0.15);

    --border:        #26354a;
    --border-light:  #2d3f56;

    --badge-sticky:  #e65100;
    --badge-event:   #2e7d32;
    --badge-rules:   #c62828;

    --success:       #4caf50;
    --warning:       #ff9800;
    --danger:        #f44336;

    --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:     0 8px 24px rgba(0,0,0,0.3);
    --shadow-lg:     0 16px 48px rgba(0,0,0,0.5);
    --overlay-bg:    rgba(0,0,0,0.7);
    --logo-badge-bg: var(--accent);
    --logo-badge-fg: #fff;
    --search-bg:     var(--bg-input);

    --code-bg:            #141d27;
    --code-border-accent: #38bdf8;
    --code-title:         #7dd3fc;
}

/* ---- Light Theme ----------------------------------------------------- */
[data-theme="light"] {
    --bg-body:         #dde5ed;
    --bg-threadlist:   #e6ecf2;
    --bg-surface:      #ebf3fa;
    --bg-card:         #ffffff;
    --bg-card-hover:   #f1f6fc;
    --bg-input:        #ffffff;
    --bg-header:       #e3effa;
    --bg-accent:       #e8f4fd;
    --bg-post:         #ffffff;
    --bg-post-sidebar: #f4f8fc;
    --bg-post-header:  #f8fafc;

    --text-primary:  #1c1e21;
    --text-secondary:#4b5563;
    --text-muted:    #8899a6;
    --text-link:     #0088bb;
    --text-link-hover:#176093;

    --accent:        #0088bb;
    --accent-bright: #176093;
    --accent-dim:    #0077a3;
    --accent-glow:   rgba(0,136,187,0.1);

    --border:        #d1d5db;
    --border-light:  #e5e7eb;

    --badge-sticky:  #e65100;
    --badge-event:   #2e7d32;
    --badge-rules:   #c62828;

    --success:       #16a34a;
    --warning:       #d97706;
    --danger:        #dc2626;

    --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:     0 8px 24px rgba(0,0,0,0.12);
    --overlay-bg:    rgba(0,0,0,0.4);
    --logo-badge-bg: var(--accent);
    --logo-badge-fg: #fff;
    --search-bg:     #f0f7fc;

    --code-bg:            #f4f8fb;
    --code-border-accent: #6b21a8;
    --code-title:         #0088bb;
}

/* ---- Spacing & Typography Tokens ------------------------------------- */
:root {
    --gap-xs: 4px;  --gap-sm: 8px;  --gap-md: 16px;
    --gap-lg: 24px; --gap-xl: 32px;
    --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px;
    --transition-fast: 150ms ease; --transition: 250ms ease;
    --max-content: 1200px;
    --avatar-sm: 36px; --avatar-md: 48px; --avatar-lg: 96px;
}

html { font-size: 15px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a { color: var(--text-link); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--text-link-hover); }
img { max-width: 100%; height: auto; }

/* ---- Scrollbar ------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ---- Top Bar --------------------------------------------------------- */
#top-bar {
    background: var(--bg-header);
    border-bottom: 2px solid var(--accent-dim);
    position: sticky; top: 0; z-index: 100;
    transition: background-color 0.3s ease;
}
.top-bar-inner {
    max-width: var(--max-content); margin: 0 auto;
    display: flex; align-items: center;
    padding: var(--gap-sm) var(--gap-md); gap: var(--gap-md);
}

.logo {
    display: flex; align-items: center; gap: var(--gap-sm);
    color: var(--text-primary); font-weight: 700; font-size: 1.1rem;
    white-space: nowrap; text-decoration: none; flex-shrink: 0;
}
.logo:hover { color: var(--accent-bright); }
.logo-icon { font-size: 1.4rem; }
.logo-badge {
    font-size: 0.6rem; font-weight: 600; letter-spacing: 0.08em;
    background: var(--logo-badge-bg); color: var(--logo-badge-fg);
    padding: 2px 6px; border-radius: 3px; vertical-align: super; margin-left: 2px;
}

/* Search */
.search-area { flex: 1; max-width: 460px; }
.search-box {
    display: flex; align-items: center;
    background: var(--search-bg); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 0 var(--gap-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.search-icon { color: var(--text-muted); flex-shrink: 0; }
#search-input {
    flex: 1; background: none; border: none; color: var(--text-primary);
    padding: var(--gap-sm); font-size: 0.9rem; outline: none; font-family: inherit;
}
#search-input::placeholder { color: var(--text-muted); }
.search-submit {
    background: var(--accent-dim); color: #fff; border: none;
    padding: 4px 12px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.8rem; font-weight: 600;
    transition: background var(--transition-fast);
}
.search-submit:hover { background: var(--accent); }

/* Theme Toggle */
.theme-toggle {
    background: none; border: 1px solid var(--border);
    border-radius: 50%; width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary);
    transition: all var(--transition-fast); flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

[data-theme="dark"] .theme-icon--dark { display: none; }
[data-theme="dark"] .theme-icon--light { display: block; }
[data-theme="light"] .theme-icon--light { display: none; }
[data-theme="light"] .theme-icon--dark { display: block; }

.top-bar-right { display: flex; align-items: center; gap: var(--gap-sm); }

.cache-indicator {
    display: flex; align-items: center; gap: 4px;
    color: var(--text-muted); font-size: 0.8rem; white-space: nowrap;
}
.cache-indicator svg { opacity: 0.6; }

/* ---- Progress Bar ---------------------------------------------------- */
.progress-bar-container { position: relative; height: 3px; background: var(--bg-surface); overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent-bright)); width: 0%; transition: width 0.4s ease; }
.progress-label { position: absolute; right: var(--gap-md); top: 4px; font-size: 0.7rem; color: var(--text-muted); }

/* ---- Breadcrumbs ----------------------------------------------------- */
.breadcrumbs { background: var(--bg-surface); border-bottom: 1px solid var(--border); }
.breadcrumbs-inner {
    max-width: var(--max-content); margin: 0 auto;
    padding: var(--gap-sm) var(--gap-md); font-size: 0.85rem;
    display: flex; align-items: center; gap: var(--gap-xs); flex-wrap: wrap;
}
.crumb { color: var(--text-secondary); }
a.crumb:hover { color: var(--text-link-hover); }
.crumb-sep { color: var(--text-muted); font-size: 0.75rem; }

/* ---- Main Content ---------------------------------------------------- */
#content { max-width: var(--max-content); margin: 0 auto; padding: var(--gap-lg) var(--gap-md); min-height: 60vh; }

/* ---- Home Page: Categorized Section Groups --------------------------- */
.category-group { margin-bottom: var(--gap-xl); }
.category-group-header {
    margin-bottom: var(--gap-md);
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.category-group-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
[data-theme="light"] .category-group-title {
    color: #1a365d;
}

.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--gap-md); }

.section-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: var(--gap-md);
    display: flex; align-items: flex-start; gap: var(--gap-md);
    cursor: pointer; transition: all var(--transition);
    text-decoration: none; color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}
.section-card:hover {
    background: var(--bg-card-hover); border-color: var(--accent-dim);
    transform: translateY(-2px); box-shadow: var(--shadow-md);
}

.section-icon {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, var(--accent-dim), var(--accent));
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,172,193,0.2);
}
[data-theme="light"] .section-icon {
    background: linear-gradient(135deg, #0088bb, #176093);
}

.section-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.section-info p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.35; }
.section-stat {
    display: inline-block; background: var(--bg-accent);
    padding: 2px 8px; border-radius: 10px;
    font-size: 0.72rem; color: var(--accent-bright);
    margin-top: var(--gap-sm); font-weight: 500;
}
[data-theme="light"] .section-stat { color: var(--accent); }

.home-hero { text-align: center; margin-bottom: var(--gap-xl); padding: var(--gap-xl) 0; }
.home-hero h1 {
    font-size: 2rem; font-weight: 700;
    background: linear-gradient(90deg, var(--accent-bright), #81d4fa);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: var(--gap-sm);
}
[data-theme="light"] .home-hero h1 {
    background: linear-gradient(90deg, #0088bb, #176093);
    -webkit-background-clip: text; background-clip: text;
}
.home-hero p { color: var(--text-secondary); font-size: 1rem; max-width: 600px; margin: 0 auto; }

/* ---- Thread List ----------------------------------------------------- */
.threadlist-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--gap-md); }
.threadlist-header h2 { font-size: 1.3rem; font-weight: 600; }
.thread-count { font-size: 0.85rem; color: var(--text-muted); }

.thread-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-threadlist);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
[data-theme="light"] .thread-table thead th {
    background: #e3effa;
}
.thread-table thead th {
    text-align: left; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); padding: var(--gap-sm) var(--gap-md);
    border-bottom: 1px solid var(--border); background: var(--bg-surface);
}
.thread-table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.thread-table thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

.thread-row { cursor: pointer; transition: background var(--transition-fast); }
.thread-row:hover { background: var(--bg-card-hover); }
.thread-row td { padding: var(--gap-sm) var(--gap-md); border-bottom: 1px solid var(--border); vertical-align: middle; }

.thread-title-cell { display: flex; align-items: center; gap: var(--gap-sm); }
.thread-avatar { width: var(--avatar-sm); height: var(--avatar-sm); border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg-accent); }
.thread-title-info { min-width: 0; }
.thread-title-text { font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 500px; display: block; }
.thread-row:hover .thread-title-text { color: var(--text-link); }
.thread-meta-line { font-size: 0.78rem; color: var(--text-muted); }
.thread-meta-line a { color: var(--text-secondary); }

.thread-badge { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.thread-badge--sticky { background: var(--badge-sticky); color: #fff; }
.thread-badge--tag { background: var(--bg-accent); color: var(--accent-bright); }

.td-replies, .td-date { font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; }
.td-replies { text-align: center; }

/* ---- Thread View ----------------------------------------------------- */
.thread-header { margin-bottom: var(--gap-lg); }
.thread-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: var(--gap-xs); }
.thread-header-meta { font-size: 0.85rem; color: var(--text-secondary); display: flex; gap: var(--gap-md); flex-wrap: wrap; }
.thread-tags { display: flex; gap: 4px; margin-top: var(--gap-sm); flex-wrap: wrap; }
.thread-tag { font-size: 0.72rem; background: var(--bg-accent); color: var(--accent-bright); padding: 2px 8px; border-radius: 10px; font-weight: 500; }
[data-theme="light"] .thread-tag { color: var(--accent); }

/* Thread Attached Downloads */
.thread-downloads {
    margin-top: var(--gap-md);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--gap-sm) var(--gap-md);
}
.thread-downloads-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-bright);
    margin-bottom: var(--gap-xs);
}
[data-theme="light"] .thread-downloads-title { color: var(--accent); }
.thread-downloads-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-sm);
}
.download-link {
    font-size: 0.8rem;
    color: var(--text-link);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 8px;
    text-decoration: none;
    transition: all var(--transition-fast);
}
.download-link:hover {
    border-color: var(--accent-dim);
    color: var(--text-link-hover);
    transform: translateY(-1px);
}

/* ---- Post Card & Thread Posts ---------------------------------------- */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: var(--gap-md);
}

.post, .post-card {
    background: var(--bg-post);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--gap-md);
    display: grid;
    grid-template-columns: 160px 1fr;
    overflow: hidden;
    scroll-margin-top: 70px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-sm);
}
.post:hover, .post-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}
.post.post-highlight, .post-card.post-highlight {
    outline: 2px solid var(--accent-bright);
    box-shadow: 0 0 16px var(--accent-glow);
    animation: postPulse 2.5s ease-out;
}
@keyframes postPulse {
    0% {
        box-shadow: 0 0 24px rgba(38, 198, 218, 0.6);
        border-color: var(--accent-bright);
    }
    70% {
        box-shadow: 0 0 12px rgba(38, 198, 218, 0.3);
    }
    100% {
        box-shadow: var(--shadow-sm);
    }
}

.post-user, .post-sidebar {
    background: var(--bg-post-sidebar);
    padding: var(--gap-md);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}
.post-avatar {
    width: var(--avatar-lg);
    height: var(--avatar-lg);
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 2px solid var(--border-light);
    background: var(--bg-accent);
}
.post-username, .post-author-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-link);
    word-break: break-word;
}
.post-user-title, .post-author-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}
.post-user-stats, .post-author-stat {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
    width: 100%;
}
.post-user-stats dt { color: var(--text-secondary); display: inline; }
.post-user-stats dd { display: inline; margin-left: 2px; }
.post-user-stats dl { margin-bottom: 2px; }

.post-main {
    display: flex;
    flex-direction: column;
    background: var(--bg-post);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px var(--gap-md);
    background: var(--bg-post-header);
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}
.post-number {
    color: var(--text-muted);
    font-weight: 600;
}
.post-body, .post-content {
    padding: var(--gap-md);
    flex: 1;
    font-size: 0.9375rem;
    line-height: 1.45;
    overflow-wrap: break-word;
    word-wrap: break-word;
    background: var(--bg-post);
}

/* bbcode content */
.post-body .bbWrapper { all: unset; display: block; }
.post-body p { margin-bottom: 0.5em; }
.post-body img.bbImage { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: var(--gap-sm) 0; }
.post-body .bbCodeSpoiler { margin: var(--gap-sm) 0; }
.post-body .bbCodeSpoiler-button {
    background: var(--bg-accent); color: var(--accent-bright); border: 1px solid var(--accent-dim);
    padding: 4px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem; font-family: inherit;
}
[data-theme="light"] .post-body .bbCodeSpoiler-button { color: var(--accent); }
.post-body .bbCodeSpoiler-button:hover { background: var(--accent-dim); color: #fff; }
.post-body .bbCodeSpoiler-content { display: none; margin-top: var(--gap-sm); }
.post-body .bbCodeSpoiler-content.is-active { display: block; }
.post-body .bbCodeBlock { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--gap-sm) var(--gap-md); }

/* Quotes */
.post-body blockquote, .post-body .bbCodeBlock--quote {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-dim);
    padding: var(--gap-sm) var(--gap-md);
    margin: var(--gap-sm) 0;
    background: var(--bg-surface);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.post-body .bbCodeBlock-title { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.post-body .bbCodeBlock--expandable .bbCodeBlock-expandContent {
    max-height: 160px;
    overflow: hidden;
    position: relative;
}
.post-body .bbCodeBlock--expandable.is-expanded .bbCodeBlock-expandContent {
    max-height: none;
    overflow: visible;
}
.post-body .bbCodeBlock-expandLink {
    display: none;
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px dashed var(--border);
    text-align: center;
}
.post-body .bbCodeBlock--expandable.is-truncated .bbCodeBlock-expandLink {
    display: block;
}
.post-body .bbCodeBlock--expandable.is-expanded .bbCodeBlock-expandLink {
    display: none !important;
}
.post-body .bbCodeBlock-expandLink a {
    color: var(--text-link);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}
.post-body .bbCodeBlock-expandLink a:hover {
    text-decoration: underline;
}

/* Code Blocks */
.post-body .bbCodeBlock--code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--code-border-accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: var(--gap-sm) 0;
    padding: 6px 12px 8px 12px;
    white-space: normal;
}
.post-body .bbCodeBlock--code .bbCodeBlock-title {
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--code-title);
    margin: 0 0 2px 0;
    padding: 0;
    white-space: normal;
}
.post-body .bbCodeBlock--code .bbCodeBlock-content {
    margin: 0;
    padding: 0;
    overflow-x: auto;
}
.post-body .bbCodeBlock--code pre,
.post-body .bbCodeBlock--code code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    white-space: pre;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    tab-size: 4;
}

/* Media Embeds (YouTube, Vimeo, Twitch, Steam, etc.) */
.post-body [data-s9e-mediaembed] {
    display: block;
    margin: var(--gap-md) 0;
    max-width: 100%;
}
.post-body [data-s9e-mediaembed="youtube"],
.post-body [data-s9e-mediaembed="vimeo"],
.post-body [data-s9e-mediaembed="twitch"],
.post-body [data-s9e-mediaembed="streamable"],
.post-body [data-s9e-mediaembed="facebook"] {
    width: 640px;
    max-width: 100%;
    aspect-ratio: 16 / 9;
}
.post-body [data-s9e-mediaembed] iframe,
.post-body iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--radius-sm);
}
.post-body [data-s9e-mediaembed="steamstore"] {
    width: 650px;
    max-width: 100%;
    height: 195px;
}
.post-body [data-s9e-mediaembed="soundcloud"] {
    width: 100%;
    max-width: 700px;
    height: 166px;
}
.post-body [data-s9e-mediaembed="pastebin"] {
    width: 100%;
    max-width: 800px;
    height: 300px;
}
.post-body ul, .post-body ol { padding-left: 1.5em; margin: var(--gap-sm) 0; }
.post-body a { color: var(--text-link); }
.post-body a:hover { color: var(--text-link-hover); text-decoration: underline; }
.post-edited { font-size: 0.75rem; color: var(--text-muted); font-style: italic; padding: var(--gap-sm) var(--gap-md); border-top: 1px solid var(--border); }

.chunk-loading { text-align: center; padding: var(--gap-lg); color: var(--text-muted); font-size: 0.9rem; }

/* ---- Sponsor Banners ------------------------------------------------- */
.sponsor-banners { border-top: 1px solid var(--border); padding: var(--gap-lg) var(--gap-md); margin-top: var(--gap-xl); }
.sponsor-banners-inner { max-width: var(--max-content); margin: 0 auto; display: flex; gap: var(--gap-md); justify-content: center; flex-wrap: wrap; }
.sponsor-banner {
    display: block; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: var(--gap-md) var(--gap-xl);
    text-align: center; text-decoration: none; transition: all var(--transition); min-width: 220px;
}
.sponsor-banner:hover { border-color: var(--accent-dim); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.sponsor-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }
.sponsor-name { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

/* ---- Footer ---------------------------------------------------------- */
#footer { background: var(--bg-header); border-top: 1px solid var(--border); padding: var(--gap-lg) var(--gap-md); text-align: center; }
.footer-inner { max-width: var(--max-content); margin: 0 auto; }
#footer p { font-size: 0.85rem; color: var(--text-secondary); }
.footer-sub { font-size: 0.75rem !important; color: var(--text-muted) !important; margin-top: var(--gap-xs); }

/* ---- Search Overlay -------------------------------------------------- */
.search-overlay { position: fixed; inset: 0; background: var(--overlay-bg); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 60px; backdrop-filter: blur(4px); }
.search-overlay-inner { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); max-width: 700px; width: 95%; max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.search-overlay-header { display: flex; justify-content: space-between; align-items: center; padding: var(--gap-md); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card); z-index: 1; }
.search-overlay-header h2 { font-size: 1.1rem; font-weight: 600; }
.search-close-btn { background: none; border: none; color: var(--text-secondary); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.search-close-btn:hover { color: var(--text-primary); }
.search-results { padding: var(--gap-md); }
.search-result-item { padding: var(--gap-sm) 0; border-bottom: 1px solid var(--border); }
.search-result-item:last-child { border-bottom: none; }
.search-result-title { font-weight: 600; color: var(--text-link); cursor: pointer; }
.search-result-title:hover { color: var(--text-link-hover); }
.search-result-snippet { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.search-result-snippet mark { background: var(--accent-glow); color: var(--accent-bright); padding: 1px 2px; border-radius: 2px; }
[data-theme="light"] .search-result-snippet mark { color: var(--accent); }
.search-no-results { text-align: center; color: var(--text-muted); padding: var(--gap-xl); }

/* ---- Spinner --------------------------------------------------------- */
.spinner { display: flex; align-items: center; justify-content: center; padding: var(--gap-xl); gap: var(--gap-sm); color: var(--text-muted); font-size: 0.9rem; }
.spinner::before { content: ''; width: 20px; height: 20px; border: 2px solid var(--border-light); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 768px) {
    .top-bar-inner { flex-wrap: wrap; }
    .search-area { order: 3; flex-basis: 100%; max-width: none; }
    .section-grid { grid-template-columns: 1fr; }
    .post, .post-card { grid-template-columns: 1fr; }
    .post-user, .post-sidebar { flex-direction: row; border-right: none; border-bottom: 1px solid var(--border); padding: var(--gap-sm) var(--gap-md); }
    .post-avatar { width: var(--avatar-md); height: var(--avatar-md); }
    .post-user-stats, .post-author-stat { display: none; }
    .thread-table thead { display: none; }
    .thread-row { display: block; padding: var(--gap-sm); }
    .thread-row td { display: block; padding: var(--gap-xs) 0; border: none; }
    .td-replies, .td-date { font-size: 0.78rem; }
    .home-hero h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .logo-text { display: none; }
}


/* ======================================================================
   v1 Optimization Additions: Loader, Search Filters, 2-Layer Sorting
   ====================================================================== */

/* ---- Center Screen Section Loading Overlay --------------------------- */
.section-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.25s ease;
}
.section-loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 22, 0.78);
    transition: background-color 0.25s ease;
}
[data-theme="light"] .section-loader-backdrop {
    background: rgba(230, 238, 248, 0.82);
}
.section-loader-card {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: loaderCardPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes loaderCardPop {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
.section-loader-icon {
    font-size: 2.75rem;
    margin-bottom: 12px;
    line-height: 1;
}
.section-loader-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 18px;
}
.section-loader-bar-wrap {
    width: 100%;
    height: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 14px;
}
.section-loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-dim), var(--accent-bright));
    border-radius: 6px;
    transition: width 0.15s ease;
}
.section-loader-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
#section-loader-pct {
    font-weight: 600;
    color: var(--accent-bright);
}

/* ---- Expandable Search Filter Options -------------------------------- */
.search-area {
    position: relative;
}
.search-filter-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    border-left: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 0 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: color var(--transition-fast);
}
.search-filter-btn:hover, .search-filter-btn.active {
    color: var(--accent-bright);
}
.search-options-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    min-width: 480px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: filterSlideDown 0.2s ease;
}
@keyframes filterSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.search-opt-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.search-opt-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.search-opt-label {
    width: 110px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.search-select, .search-input-sub {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-fast);
}
.search-select:focus, .search-input-sub:focus {
    border-color: var(--accent);
}
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}
.author-filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}
.highlight-checkbox {
    color: var(--accent-bright);
}
.search-opt-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-accent {
    background: var(--accent);
    border: 1px solid var(--accent-bright);
    color: #fff;
}
.btn-accent:hover {
    background: var(--accent-bright);
}
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.search-default-msg {
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
}

/* ---- In-Depth Search Download Progress -------------------------------- */
.search-download-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.search-progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.search-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-bright);
    border-radius: 3px;
    transition: width 0.15s ease;
}
.search-progress-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---- Two-Layer Thread Table Sorting ---------------------------------- */
.thread-table th.thread-col-sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    padding: 10px 12px;
    position: relative;
}

/* Default hover when inactive */
.thread-table th.thread-col-sortable:hover {
    background-color: var(--bg-card-hover);
}

/* Single heading locked-in sort (Title, Created, Replies, Last Post) */
.thread-table th.thread-col-sortable.sort-active-primary {
    background-color: #24354b;
    color: var(--text-primary);
}
[data-theme="light"] .thread-table th.thread-col-sortable.sort-active-primary {
    background-color: #dbe8f5;
    color: var(--text-primary);
}

/* Author locked-in: A notch lighter than normal primary */
.thread-table th.thread-col-sortable.sort-active-author {
    background-color: #354d6e;
    color: #ffffff;
}
[data-theme="light"] .thread-table th.thread-col-sortable.sort-active-author {
    background-color: #c0ddf7;
    color: #0e1726;
}

/* Secondary sort locked-in (in-between color) */
.thread-table th.thread-col-sortable.sort-active-secondary {
    background-color: #2b3e57;
    color: var(--text-primary);
}
[data-theme="light"] .thread-table th.thread-col-sortable.sort-active-secondary {
    background-color: #cee2f6;
    color: var(--text-primary);
}

/* When Author is primary, hovering over eligible secondary headings */
.thread-table.author-primary-active th.thread-col-sortable:not(.th-author):not(.sort-active-secondary):hover {
    background-color: #2b3e57;
}
[data-theme="light"] .thread-table.author-primary-active th.thread-col-sortable:not(.th-author):not(.sort-active-secondary):hover {
    background-color: #cee2f6;
}

/* Hover preview of (2) badge when Author is primary */
.thread-table.author-primary-active th.thread-col-sortable:not(.th-author):not(.sort-active-secondary):hover .sort-layer-badge-preview {
    display: inline-block !important;
}

/* Sort Header Inner Layout */
.sort-header-inner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

/* (1) Badge beside Author: Bright Aqua text, no circle background */
.sort-layer-num-author {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #00bcd4;
    letter-spacing: -0.5px;
    margin-right: 2px;
}
[data-theme="light"] .sort-layer-num-author {
    color: #0088bb;
}

/* (2) Badge beside Secondary Heading: Aqua text, no circle background */
.sort-layer-num-secondary {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #26c6da;
    letter-spacing: -0.5px;
    margin-right: 2px;
}
[data-theme="light"] .sort-layer-num-secondary {
    color: #0097a7;
}

/* Arrow button: hidden when inactive, visible when active */
.sort-arrow-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--accent-bright);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
    transition: all var(--transition-fast);
}
.sort-arrow-btn.is-active {
    display: inline-flex;
}
.sort-arrow-btn:hover {
    background: var(--accent-glow);
    border-color: var(--accent-bright);
}

.td-author {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.td-created {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}


/* When hovering over the active Author header, hide (1) to show clicking will remove it */
.th-author.sort-active-author:hover .sort-layer-num-author {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Visual cue on the previous sort heading showing you will flip back */
.thread-table th.thread-col-sortable.sort-revert-preview {
    background-color: #24354b !important;
    color: var(--accent-bright) !important;
    box-shadow: inset 0 0 0 1px var(--accent-dim);
}
[data-theme="light"] .thread-table th.thread-col-sortable.sort-revert-preview {
    background-color: #c7e1f5 !important;
    color: #0e1726 !important;
    box-shadow: inset 0 0 0 1px #8abde6;
}

/* ==========================================================================
   PasteBin Embedded Script Box Styles
   ========================================================================== */

.pastebin-embed {
    margin: 14px 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    font-family: inherit;
}

.pastebin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.04);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}

[data-theme="dark"] .pastebin-header {
    background: rgba(255, 255, 255, 0.04);
}

.pastebin-title-area {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.pastebin-icon {
    font-size: 15px;
}

.pastebin-title {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.pastebin-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pastebin-badge-live {
    background: #dcfce7;
    color: #15803d;
}
[data-theme="dark"] .pastebin-badge-live {
    background: #064e3b;
    color: #6ee7b7;
}

.pastebin-badge-wayback {
    background: #fef3c7;
    color: #b45309;
}
[data-theme="dark"] .pastebin-badge-wayback {
    background: #78350f;
    color: #fde68a;
}

.pastebin-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pastebin-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: var(--accent-dim);
    color: var(--text-primary);
    transition: background 0.15s ease, color 0.15s ease;
}

.pastebin-btn:hover {
    background: var(--accent-bright);
    color: #0b1118;
}

.pastebin-copy-btn.copied {
    background: #16a34a !important;
    color: #ffffff !important;
}

.pastebin-body {
    padding: 0;
    margin: 0;
    max-height: 480px;
    overflow: auto;
    background: #0f172a;
}

.pastebin-body pre {
    margin: 0;
    padding: 14px;
}

.pastebin-body code.pastebin-code {
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #e2e8f0;
    white-space: pre;
    tab-size: 4;
}

.pastebin-dead-badge {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    margin-left: 4px;
}

