@font-face {
    font-family: "Minecraft";
    src: url("../minecraft-4-cdnfonts/Minecraft_font.ttf") format("truetype");
    font-display: swap;
}

:root {
    --nav-green: #5d8c3e;
    --nav-green-dark: #3f6828;
    --sand: #f5efdc;
    --oak: #3b2d1e;
    --sky: #6cb4e8;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(0, 0, 0, 0.08);
    --sidebar-bg: linear-gradient(180deg,
        #7cb04c 0,
        #588537 72px,
        #7a5f42 72px,
        #5c4834 100%);
    --danger: #a83232;
    --danger-hover: #872626;
    --text-muted: #555555;
    --text-subtle: #3a3026;
    --sidebar-fg: #ffffff;
    --text-on-accent: #ffffff;
    --btn-secondary-fg: #0a4a6e;
    --btn-secondary-border: #1e7aad;
    --chart-axis: #3b2d1e;
    --chart-grid: rgba(59, 45, 30, 0.12);
    --image-border-color: #d4d4d4;
    --image-border: 1px solid var(--image-border-color);
    --image-border-radius: 8px;
    --image-border-hover: var(--nav-green);
    --image-hover-shadow: 0 2px 8px rgba(93, 140, 62, 0.2);
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root.minecraft-theme {
    --font-body: "Minecraft", Arial, sans-serif;
    --card-bg: rgba(245, 239, 220, 0.92);
    --card-border: rgba(59, 45, 30, 0.25);
    --sidebar-bg: linear-gradient(180deg, var(--nav-green), var(--nav-green-dark));
    --image-border-radius: 0;
    --image-border-color: #5c4033;
    --image-border: 3px solid var(--image-border-color);
    --image-border-hover: #8b6914;
    --image-hover-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.15), 3px 3px 0 rgba(0, 0, 0, 0.2);
}

:root.dark-mode.minecraft-theme {
    --sidebar-bg: linear-gradient(180deg, var(--nav-green), var(--nav-green-dark));
    --image-border-color: #3d2817;
    --image-border-hover: #6b4f2a;
}

:root.dark-mode {
    --nav-green: #2b3f1e;
    --nav-green-dark: #569e28;
    --sand: #f5efdc;
    --oak: #caa884;
    --sky: #6cb4e8;
    --card-bg: rgba(20, 20, 20, 0.92);
    --card-border: rgba(255, 255, 255, 0.1);
    --sidebar-bg: linear-gradient(180deg,
        #4c7330 0,
        #36501f 72px,
        #423528 72px,
        #342820 100%);
    --danger: #a83232;
    --danger-hover: #872626;
    --text-muted: #c8d0d8;
    --text-subtle: #e6dac8;
    --sidebar-fg: #ffffff;
    --text-on-accent: #ffffff;
    --btn-secondary-fg: #7ec8eb;
    --btn-secondary-border: #5ba8d4;
    --chart-axis: #e6dac8;
    --chart-grid: rgba(230, 218, 200, 0.18);
    --image-border-color: rgba(255, 255, 255, 0.22);

    .stat-box {
        background: rgb(9, 20, 31);
    }

    .stat-number {
        color: #8fd86e;
    }

    .action-card {
        background: rgb(34, 43, 51);
    }

    .btn-primary,
    .search-btn {
        background-color: var(--nav-green);
    }

    .btn-primary:hover,
    .search-btn:hover {
        background-color: #1a2812;
    }

}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    background-color: #eef0ea;
    background-image: linear-gradient(160deg,
        #f1f3ec 0%,
        #e7ece1 55%,
        #dfe6d6 100%);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--oak);
}

/* ---- Professional (default) dark background ---- */
:root.dark-mode body {
    background-color: #181c17;
    background-image: linear-gradient(160deg,
        #1d231b 0%,
        #191e18 55%,
        #141813 100%);
}

/* ---- Minecraft theme backgrounds ---- */
:root.minecraft-theme body {
    background-image: none;
}

:root.minecraft-theme body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: linear-gradient(rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25)),
        url("../images/backgrounds/grass_block_background.jpg");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    image-rendering: pixelated;
    pointer-events: none;
}

:root.dark-mode.minecraft-theme body {
    background-image: none;
}

:root.dark-mode.minecraft-theme body::before {
    background-image: linear-gradient(rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25)),
        url("../images/backgrounds/17346505-stonebrickscomparison_xl.webp");
}

/* ---- Theme toggle button ---- */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1500;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    background-color: rgba(245, 239, 220, 0.9);
    background-image: url("../images/ui/grass_block_icon.jpg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 26px 26px;
    image-rendering: pixelated;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.12s, box-shadow 0.12s, background-image 0.12s;
}

:root.minecraft-theme .theme-toggle {
    background-image: url("../images/ui/paper_icon.webp");
    background-size: 34px 34px;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--nav-green);
    outline-offset: 2px;
}

/* ---- Skip link (a11y) ---- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 8px;
    z-index: 1000;
    padding: 8px 16px;
    background: var(--oak);
    color: var(--sand);
    border-radius: 0 0 6px 6px;
    text-decoration: none;
    font-size: 0.85rem;
}

.skip-link:focus {
    top: 0;
}

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

/* ---- Layout ---- */
.app-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px 1fr;
}

.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 2px solid rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
}

.logo {
    font-size: 1.5rem;
    letter-spacing: 1px;
    font-weight: bold;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    color: var(--sidebar-fg);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 6px;
    transition: background-color 0.15s;
}

.nav-link.active,
.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.nav-link:focus-visible {
    outline: 2px solid var(--sidebar-fg);
    outline-offset: 2px;
}

/* ---- Footer ---- */
.app-footer {
    background: var(--oak);
    color: var(--sand);
    text-align: center;
    padding: 12px 16px;
    font-size: 0.8rem;
}

.app-footer p {
    margin: 0;
}

/* ---- Main content ---- */
.main-content {
    padding: 24px;
    display: flex;
    align-items: flex-start;
}

/* ---- Shared page card ---- */
.page-card {
    width: min(900px, 100%);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 24px;
    backdrop-filter: blur(2px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 12px 32px rgba(0, 0, 0, 0.06);
}

:root.minecraft-theme .page-card {
    position: relative;
    border-radius: 0;
    background: var(--card-bg);
    border: none;
    backdrop-filter: blur(2px);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}

:root.minecraft-theme .page-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow:
        inset 0 0 0 5px #9a7b4f,
        inset 5px 5px 0 0 #d4bc72,
        inset -5px -5px 0 0 #5c4033,
        inset 0 0 0 8px #6b5034;
}

:root.dark-mode.minecraft-theme .page-card::before {
    box-shadow:
        inset 0 0 0 5px #6b5034,
        inset 5px 5px 0 0 #9a7b4f,
        inset -5px -5px 0 0 #3d2817,
        inset 0 0 0 8px #4a3828;
}

.page-card header {
    margin-bottom: 16px;
}

.page-card h1 {
    margin: 0 0 8px;
    font-size: 2rem;
}

.page-card h2 {
    margin: 24px 0 12px;
    font-size: 1.3rem;
}

.page-card ul {
    margin: 0;
    padding-left: 1.5rem;
}

.page-card li {
    margin: 0;
    line-height: 1.5;
}

.page-card li + li {
    margin-top: 0.5rem;
}

.subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-subtle);
    line-height: 1.5;
}

/* ---- Bottom page navigation ---- */
.page-bottom-nav {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--card-border);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.page-bottom-nav__group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.page-bottom-nav__group--end {
    margin-left: auto;
}

.page-bottom-nav__btn {
    font-family: var(--font-body);
    padding: 10px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 2px solid var(--nav-green-dark);
    border-radius: 6px;
    background-color: var(--nav-green);
    color: var(--text-on-accent);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.15s, border-color 0.15s;
}

.page-bottom-nav__btn:hover {
    background-color: var(--nav-green-dark);
    border-color: #2f521f;
}

.page-bottom-nav__btn:focus-visible {
    outline: 2px solid var(--oak);
    outline-offset: 2px;
}

:root.dark-mode .page-bottom-nav__btn {
    background-color: var(--nav-green-dark);
    border-color: var(--nav-green);
}

:root.dark-mode .page-bottom-nav__btn:hover {
    background-color: var(--nav-green);
    border-color: var(--nav-green-dark);
}

:root.minecraft-theme .page-bottom-nav {
    border-top-width: 2px;
    border-top-color: rgba(59, 45, 30, 0.3);
}

:root.minecraft-theme .page-bottom-nav__btn {
    border-radius: 4px;
    border-color: rgba(0, 0, 0, 0.35);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
    image-rendering: pixelated;
}

:root.minecraft-theme .page-bottom-nav__btn:hover {
    filter: brightness(0.92);
}

/* ---- Home stats ---- */
.stats-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.stat-box {
    flex: 1;
    min-width: 100px;
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--nav-green-dark);
}

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

/* ---- Action grid (home) ---- */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.action-card {
    display: block;
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    padding: 16px;
    text-decoration: none;
    color: var(--oak);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.action-card:hover,
.action-card:focus-visible {
    border-color: var(--nav-green);
    box-shadow: 0 2px 8px rgba(93, 140, 62, 0.25);
}

.action-card h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    color: var(--nav-green-dark);
}

.action-card p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ---- Forms ---- */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-stack label {
    font-size: 0.85rem;
    font-weight: bold;
    margin-top: 4px;
}

.form-input {
    font-family: var(--font-body);
    padding: 10px 12px;
    font-size: 0.85rem;
    border: 1px solid #8b6d4c;
    border-radius: 8px;
    background: #fffdf7;
    color: var(--oak);
    width: 100%;
}

.form-input:focus {
    outline: 2px solid var(--nav-green);
    outline-offset: 1px;
}

#profile-avatar-preview {
    max-width: 50%;
    height: auto;
    display: block;
}

.form-select {
    width: auto;
    min-width: 160px;
}

.form-msg {
    font-size: 0.8rem;
    color: var(--nav-green-dark);
    min-height: 1.2em;
    margin: 4px 0;
}

.tag-fieldset {
    border: 1px solid #8b6d4c;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0;
}

.tag-fieldset legend {
    font-size: 0.85rem;
    font-weight: bold;
    padding: 0 6px;
}

.tag-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.tag-checks label {
    font-weight: normal;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.sort-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.btn-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-file-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.btn-file-label:focus-within {
    outline: 2px solid var(--nav-green);
    outline-offset: 2px;
}

/* ---- Search (discover) ---- */
.search-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    font: inherit;
    border: 1px solid #8b6d4c;
    border-radius: 8px;
    background: #fffdf7;
    color: var(--oak);
}

.search-input:focus {
    outline: 2px solid var(--nav-green);
    outline-offset: 1px;
}

.search-btn {
    padding: 10px 16px;
    font: inherit;
    border: none;
    border-radius: 8px;
    background-color: var(--nav-green-dark);
    color: var(--text-on-accent);
    cursor: pointer;
    transition: background-color 0.15s;
}

.search-btn:hover {
    background-color: #2f521f;
}

.results-heading {
    margin: 24px 0 12px;
    font-size: 1.3rem;
    color: var(--oak);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    min-height: 60px;
}

.results-grid:empty {
    min-height: 0;
}

/* ---- Messages ---- */
.results-message {
    grid-column: 1 / -1;
    margin: 0;
    padding: 16px;
    background: rgba(255, 253, 247, 0.95);
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    color: var(--oak);
    font-size: 0.85rem;
    line-height: 1.5;
}

.results-message--error {
    background: #f8d7da;
    border-color: #8b2d37;
    color: #5c1f26;
}

.results-message--loading {
    color: var(--text-subtle);
}

.results-message--muted {
    color: var(--text-subtle);
}

/* ---- Player cards (discover) ---- */
.player-card {
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.player-card__skin-wrap {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: #e8e8e8;
    flex-shrink: 0;
}

.player-card__skin {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    display: block;
}

.player-card__skin-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3d3d3d;
    color: #e8e8e8;
    font-size: 2rem;
}

.player-card__name {
    margin: 0;
    font-size: 1rem;
    font-weight: bold;
}

.player-card__tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.65rem;
    background: #e8e8e8;
    color: #3d3d3d;
}

.player-card__desc {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.player-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

/* ---- Feed posts ---- */
.feed-post {
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.feed-post__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.feed-post__author {
    margin: 0;
    font-size: 1rem;
}

.feed-post__time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.feed-post__desc {
    margin: 0 0 8px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.feed-post__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.feed-post__interest {
    margin-bottom: 8px;
}

.feed-post__names {
    margin: 6px 0 0;
    font-size: 0.75rem;
    color: var(--text-subtle);
}

.feed-post__actions {
    display: flex;
    gap: 8px;
}

/* ---- Following list (profile) ---- */
.following-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    margin-bottom: 8px;
}

.following-card__skin {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    image-rendering: pixelated;
    background: #e8e8e8;
}

.following-card__name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: bold;
}

/* ---- Group cards ---- */
.group-card {
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.group-card__name {
    margin: 0 0 6px;
    font-size: 1.05rem;
}

.group-card__members {
    margin: 0 0 10px;
    font-size: 0.8rem;
    color: var(--text-subtle);
}

.group-card__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn-primary {
    font-family: var(--font-body);
    padding: 8px 14px;
    font-size: 0.75rem;
    border: none;
    border-radius: 6px;
    background-color: var(--nav-green-dark);
    color: var(--text-on-accent);
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn-primary:hover {
    background-color: #2f521f;
}

.btn-primary:focus-visible {
    outline: 2px solid var(--oak);
    outline-offset: 2px;
}

.btn-secondary {
    font-family: var(--font-body);
    padding: 8px 14px;
    font-size: 0.75rem;
    border: 2px solid var(--btn-secondary-border);
    border-radius: 6px;
    background: transparent;
    color: var(--btn-secondary-fg);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background-color 0.15s;
}

.btn-secondary:hover {
    background: rgba(108, 180, 232, 0.2);
}

.btn-secondary:focus-visible {
    outline: 2px solid var(--oak);
    outline-offset: 2px;
}

.btn-danger {
    font-family: var(--font-body);
    padding: 8px 14px;
    font-size: 0.75rem;
    border: none;
    border-radius: 6px;
    background-color: var(--danger);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-danger:focus-visible {
    outline: 2px solid var(--oak);
    outline-offset: 2px;
}

/* ---- Chart ---- */
.chart-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin-top: 8px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        height: auto;
        max-height: none;
        overflow-y: visible;
    }

    .nav-links {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .nav-link {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .main-content {
        padding: 16px;
    }

    .page-card {
        padding: 16px;
    }

    .page-bottom-nav {
        flex-direction: column;
        align-items: stretch;
    }

    .page-bottom-nav__group--end {
        margin-left: 0;
    }

    .page-bottom-nav__group {
        justify-content: center;
    }

    .page-card h1 {
        font-size: 1.5rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .action-grid {
        grid-template-columns: 1fr;
    }

    .stats-row {
        gap: 8px;
    }

    .stat-box {
        min-width: 80px;
        padding: 10px;
    }
}

@media (max-width: 400px) {
    .sidebar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .search-input {
        min-width: 0;
    }
}

/* ---- Print ---- */
@media print {
    body {
        background: #fff;
        background-image: none;
        color: #000;
        font-size: 11pt;
    }

    .skip-link,
    .sidebar,
    .page-bottom-nav,
    .app-footer,
    .theme-toggle,
    .btn-row,
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    .btn-file-label,
    .feed-post__actions,
    .player-card__actions,
    .group-card__actions,
    [aria-label="Data management"],
    [aria-label="Quick actions"] {
        display: none !important;
    }

    .app-layout {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 0;
    }

    .page-card {
        width: 100%;
        background: #fff;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
        padding: 0;
    }

    .page-card h1 {
        font-size: 18pt;
        border-bottom: 2pt solid #000;
        padding-bottom: 6pt;
        margin-bottom: 12pt;
    }

    .page-card h2 {
        font-size: 13pt;
        margin-top: 16pt;
    }

    .stat-box {
        background: #f5f5f5;
        border: 1pt solid #ccc;
        box-shadow: none;
    }

    .feed-post,
    .player-card,
    .group-card,
    .following-card {
        background: #fff;
        border: 1pt solid #ccc;
        box-shadow: none;
        break-inside: avoid;
    }

    .player-card__tag,
    .feed-post__tags span {
        border: 1pt solid #999;
        background: #eee;
        color: #000;
    }

    a {
        color: #000;
        text-decoration: none;
    }

    .chart-container {
        max-width: 100%;
    }
}

/* ---- Subnav ---- */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-group-toggle {
    font-family: var(--font-body);
    color: var(--sidebar-fg);
    background: none;
    border: none;
    padding: 10px 12px;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: inherit;
}

.nav-group-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.nav-group-toggle::after {
    content: " \25B8";
    font-size: 0.7em;
}

.nav-group.open .nav-group-toggle::after {
    content: " \25BE";
}

.nav-group-toggle:focus-visible {
    outline: 2px solid var(--sidebar-fg);
    outline-offset: 2px;
}

.nav-subnav {
    display: none;
    flex-direction: column;
    padding-left: 16px;
    gap: 2px;
}

.nav-group.open .nav-subnav {
    display: flex;
}

.nav-subnav .nav-link {
    font-size: 0.85em;
    padding: 6px 12px;
}

/* ---- Gallery grid (project / game pages) ---- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.gallery-placeholder {
    aspect-ratio: 1;
    background: #e8e8e8;
    border: 2px dashed #8b6d4c;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 12px;
}

/* ---- Content images (shared border) ---- */
.detail-section > img,
.gallery-grid > img,
.timeline-entry li img,
#profile-avatar-preview,
.minecraft-media-row img,
.photo-gallery__item,
.minecraft-build-gallery__frame {
    border: var(--image-border);
    border-radius: var(--image-border-radius);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.detail-section > img:hover,
.gallery-grid > img:hover,
.timeline-entry li img:hover,
#profile-avatar-preview:hover,
.minecraft-media-row img:hover,
.photo-gallery__item:hover,
.minecraft-build-gallery__frame:hover {
    border-color: var(--image-border-hover);
    box-shadow: var(--image-hover-shadow);
}

.minecraft-build-gallery__frame img {
    border: none;
    border-radius: 0;
}

/* ---- Minecraft theme: sharp corners on all media ---- */
:root.minecraft-theme img,
:root.minecraft-theme .photo-gallery__item,
:root.minecraft-theme .gallery-placeholder,
:root.minecraft-theme .detail-section iframe,
:root.minecraft-theme .timeline-entry iframe,
:root.minecraft-theme .timeline-entry li iframe,
:root.minecraft-theme .minecraft-media-row iframe,
:root.minecraft-theme .minecraft-media-row video,
:root.minecraft-theme .image-lightbox__img {
    border-radius: 0;
}

/* ---- Photo gallery page ---- */
.photo-gallery {
    --gallery-row: 10px;
    --gallery-gap: 16px;
    --gallery-col-min: 180px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--gallery-col-min), 1fr));
    grid-auto-rows: var(--gallery-row);
    grid-auto-flow: dense;
    gap: var(--gallery-gap);
    margin-top: 8px;
}

.photo-gallery__item {
    margin: 0;
    overflow: hidden;
    background: #e8e8e8;
    min-height: 0;
}

.photo-gallery__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 0;
}

/* ---- Timeline ---- */
.timeline {
    border-left: 3px solid var(--nav-green);
    padding-left: 20px;
    margin: 16px 0;
}

.timeline-entry {
    position: relative;
    margin-bottom: 24px;
}

.timeline-entry::before {
    content: "";
    position: absolute;
    left: -27px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--nav-green-dark);
    border: 2px solid var(--nav-green);
}

.timeline-entry h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0 0 6px;
    display: block;
}

.timeline-entry p {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.timeline-entry ul {
    margin: 0 0 12px;
    padding-left: 1.2rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.timeline-entry li + li {
    margin-top: 12px;
}

.timeline-entry iframe,
.timeline-entry li iframe {
    display: block;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 16 / 9;
    height: auto;
    margin: 8px 0 0;
    border: 0;
    border-radius: 8px;
}

.media-subheading {
    margin: 20px 0 12px;
    font-size: 0.95rem;
    color: var(--nav-green-dark);
}

.media-timeline {
    margin-top: 0;
}

.media-timeline .timeline-entry:last-child {
    margin-bottom: 0;
}

.media-details {
    margin-top: 10px;
}

.media-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--nav-green-dark);
    font-weight: 600;
}

.media-details summary:hover {
    text-decoration: underline;
}

.media-details p {
    margin: 8px 0 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.timeline-entry li img {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin-top: 8px;
    cursor: zoom-in;
}

/* ---- Project cards ---- */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.project-card {
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    padding: 16px;
    text-decoration: none;
    color: var(--oak);
    transition: box-shadow 0.15s, border-color 0.15s;
    display: block;
}

.project-card:hover,
.project-card:focus-visible {
    border-color: var(--nav-green);
    box-shadow: 0 2px 8px rgba(93, 140, 62, 0.25);
}

.project-card h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    color: var(--nav-green-dark);
}

.project-card p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ---- Placeholder box ---- */
.placeholder-box {
    background: #f0ebe0;
    border: 2px dashed #8b6d4c;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 12px 0;
}

/* ---- Certification / document cards ---- */
.cert-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cert-card {
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    padding: 16px;
}

.cert-card h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    color: var(--nav-green-dark);
}

.cert-card p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.cert-card p + p {
    margin-top: 6px;
}

.document-embed {
    width: 100%;
    height: min(80vh, 900px);
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    background: #fff;
}

/* ---- Detail section (individual project/game pages) ---- */
.detail-section {
    margin: 16px 0;
}

.detail-section h2 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.detail-section h3 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: var(--nav-green-dark);
}

.detail-section iframe,
.detail-section video {
    display: block;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 16 / 9;
    height: auto;
    margin: 0 0 12px;
    border: 0;
    border-radius: 8px;
}

.detail-section video {
    background: #000;
}

.detail-section > img,
.gallery-grid > img {
    display: block;
    width: 100%;
    height: auto;
}

.detail-section > img {
    margin: 0 0 12px;
}

.detail-section > img.is-square {
    width: auto;
    max-width: min(100%, 400px);
}

/* ---- Minecraft page media layouts ---- */
.minecraft-media-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
    align-items: start;
    margin-bottom: 12px;
}

.minecraft-media-row iframe,
.minecraft-media-row video {
    width: 100%;
    max-width: none;
    margin: 0;
}

.minecraft-media-row img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
}

.minecraft-media-row--stacked-images {
    align-items: stretch;
}

.minecraft-media-row__images {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    min-height: 0;
}

.minecraft-media-row--stacked-images .minecraft-media-row__images img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.minecraft-build-gallery {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
}

.minecraft-build-gallery__frame {
    min-height: 0;
    overflow: hidden;
}

.minecraft-build-gallery__frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

@media (max-width: 640px) {
    .minecraft-media-row {
        grid-template-columns: 1fr;
    }

    .minecraft-media-row--stacked-images .minecraft-media-row__images {
        grid-template-rows: auto auto;
    }

    .minecraft-media-row--stacked-images .minecraft-media-row__images img {
        height: auto;
        object-fit: contain;
    }

    .minecraft-build-gallery {
        grid-template-columns: 1fr;
    }

    .minecraft-build-gallery__frame img {
        height: auto;
        object-fit: contain;
    }
}

/* ---- Marvel Rivals page media layouts ---- */
.marvel-rivals-media-row {
    grid-template-columns: 2fr 1fr;
    align-items: start;
}

.marvel-rivals-media-row .marvel-rivals-landscape,
.marvel-rivals-media-row .marvel-rivals-square {
    width: 100%;
    height: auto;
}

@media (max-width: 640px) {
    .marvel-rivals-media-row {
        grid-template-columns: 1fr;
    }
}

.tech-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tech-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: #e8e8e8;
    color: #3d3d3d;
}

/* ---- Image lightbox ---- */
img {
    cursor: zoom-in;
}

body.image-lightbox-open {
    overflow: hidden;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.85);
}

.image-lightbox[hidden] {
    display: none;
}

.image-lightbox__img {
    max-width: min(95vw, 1200px);
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    cursor: default;
}

.image-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: rgba(245, 239, 220, 0.95);
    color: var(--oak);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.image-lightbox__close:hover {
    background: #fff;
}
