@import url("https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@900&family=Cinzel:wght@400;600;700&family=Source+Sans+3:wght@300;600&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
    color-scheme: dark;
    --gold: #c9922b;
    --gold-light: #e8dfc8;
    --gold-dark: #8b6914;
    --ember: #c4541a;
    --rune-violet: #7b4ea6;
    --steel: #8a9bad;
    --parchment: #e8dfc8;
    --ash: #4a4050;
    --sidebar-w: 220px;
    --sidebar-w-collapsed: 64px;
    --bg-deep: #0d0b0f; /* Obsidian page background */
    --bg-card: #1c1820; /* Iron surface */
    --bg-panel: #1c1820; /* Iron surface */
    --bg-hover: #2d2733;
    --text-primary: #e8dfc8; /* Parchment text */
    --text-secondary: #8a9bad; /* Steel text */
    --text-muted: #8e7f96; /* Ash text */
    --border: #4a4050; /* Ash border */
    --border-gold: rgba(201, 146, 43, 0.35);
    --mana-white: #f9faf4;
    --mana-blue: #0e68ab;
    --mana-black: #150b00;
    --mana-red: #d3202a;
    --mana-green: #00733e;
    --danger: #c4541a; /* Use Ember for danger state base */
    --danger-hover: #e35e1c;
    --success: #2d6b3f;

    /* Semantic surfaces */
    --glass-bg: rgba(28, 24, 32, 0.85);
    --glass-bg-soft: rgba(28, 24, 32, 0.8);
    --glass-bg-strong: rgba(28, 24, 32, 0.92);
    --glass-bg-xstrong: rgba(28, 24, 32, 0.95);
    --header-bg: linear-gradient(
        180deg,
        rgba(13, 11, 15, 0.95) 0%,
        rgba(13, 11, 15, 0.88) 100%
    );
    --body-veil:
        radial-gradient(
            ellipse at 20% 0%,
            rgba(196, 84, 26, 0.08) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse at 80% 100%,
            rgba(201, 146, 43, 0.05) 0%,
            transparent 50%
        ),
        rgba(13, 11, 15, 0.78);
    --overlay-bg: rgba(13, 11, 15, 0.85);
    --lightbox-bg: rgba(13, 11, 15, 0.95);
    --bg-grid-opacity: 0.12;
    --bg-grid-filter: saturate(0.35) brightness(0.3);
}

html[data-theme="light"] {
    color-scheme: light;
    --gold: #a37f1f;
    --gold-light: #c9a84c;
    --gold-dark: #6b4d0e;
    --bg-deep: #f4ebd9;
    --bg-card: #faf3e0;
    --bg-panel: #f1e4c6;
    --bg-hover: #e9dab8;
    --text-primary: #2a241a;
    --text-secondary: #5c5238;
    --text-muted: #8a7f62;
    --border: #d4c29a;
    --border-gold: rgba(139, 105, 20, 0.35);

    --glass-bg: rgba(250, 243, 224, 0.82);
    --glass-bg-soft: rgba(250, 243, 224, 0.78);
    --glass-bg-strong: rgba(250, 243, 224, 0.9);
    --glass-bg-xstrong: rgba(250, 243, 224, 0.94);
    --header-bg: linear-gradient(
        180deg,
        rgba(244, 235, 217, 0.94) 0%,
        rgba(244, 235, 217, 0.86) 100%
    );
    --body-veil:
        radial-gradient(
            ellipse at 20% 0%,
            rgba(201, 168, 76, 0.12) 0%,
            transparent 50%
        ),
        radial-gradient(
            ellipse at 80% 100%,
            rgba(139, 105, 20, 0.08) 0%,
            transparent 50%
        ),
        rgba(244, 235, 217, 0.6);
    --overlay-bg: rgba(60, 45, 20, 0.55);
    --lightbox-bg: rgba(40, 30, 15, 0.85);
    --bg-grid-opacity: 0.35;
    --bg-grid-filter: saturate(1) brightness(1.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* overflow-x on html (not body) clips viewport scroll without affecting position:fixed elements,
           which is required for iOS Safari compatibility. */
html {
    overflow-x: hidden;
}

body {
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 14pt;
    font-weight: 300;
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
}

/* Global card-art background (shown behind both login and main app) */
#app-bg-cards {
    position: fixed;
    inset: -40px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    transform: rotate(-4deg) scale(1.15);
    opacity: var(--bg-grid-opacity);
    filter: var(--bg-grid-filter);
    z-index: -1;
    animation: bgPulse 8s ease-in-out infinite alternate;
    pointer-events: none;
}

#app-bg-cards img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* Theme-aware veil + subtle gold atmosphere overlay over card background */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--body-veil);
    pointer-events: none;
    z-index: 0;
}

/* ===== HEADER — Castle Gate Bar ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-gold);
    padding: 0 2rem;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
}

/* Castle battlement decoration under header */
.app-header::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        rgba(201, 168, 76, 0.15) 0px,
        rgba(201, 168, 76, 0.15) 12px,
        transparent 12px,
        transparent 18px
    );
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-dragon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--gold);
    box-shadow: 0 0 5px rgba(201, 168, 76, 0.1);
}

.logo-dragon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.logo-text {
    font-family: "Cinzel Decorative", serif;
    font-weight: 900;
    font-size: 1.5rem;
    background: linear-gradient(
        135deg,
        var(--gold-light),
        var(--gold),
        var(--gold-dark)
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.1em;
    text-shadow: none;
    filter: drop-shadow(0 0 8px rgba(201, 168, 76, 0.4));
}

.logo-subtitle {
    font-family: "Cinzel", serif;
    font-size: 0.82rem;
    color: var(--text-secondary);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin-top: 2px;
}

.nav-tabs {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.nav-tab {
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: "Cinzel", serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    padding: 0.45rem 0.85rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.nav-tab .nav-icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.nav-tab:hover {
    color: var(--gold-light);
    background: rgba(201, 168, 76, 0.08);
}

.nav-tab.active {
    color: var(--gold);
    background: rgba(201, 168, 76, 0.12);
}

.nav-tab.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0.6rem;
    right: 0.6rem;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    border-radius: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* User preferences dropdown */
.user-info:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: 8px;
}
.user-dropdown-chevron {
    font-size: 0.55rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    margin-left: 0.4rem;
    flex-shrink: 0;
}
.user-info.open .user-dropdown-chevron {
    transform: rotate(180deg);
}
.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    background: var(--glass-bg-strong);
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    z-index: 300;
    overflow: hidden;
    display: none;
}
.user-dropdown.open {
    display: block;
}
.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: "Cinzel", serif;
    transition:
        background 0.15s,
        color 0.15s;
    letter-spacing: 0.04em;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    white-space: nowrap;
}
.user-dropdown-item:hover {
    background: rgba(201, 168, 76, 0.12);
    color: var(--gold);
}
.user-dropdown-item .item-icon {
    font-size: 1rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 1rem;
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    background: rgba(201, 168, 76, 0.05);
    cursor: pointer;
    position: relative;
    user-select: none;
}

.user-info-name {
    font-family: "Cinzel", serif;
    font-size: 0.8rem;
    color: var(--gold);
    letter-spacing: 0.05em;
}

.user-info-role {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: "Cinzel", serif;
    font-size: 0.7rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.05em;
}

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

/* ===== SIDE NAV ===== */
.side-nav {
    position: fixed;
    top: 121px;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--glass-bg-strong);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-right: 1px solid var(--border-gold);
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease;
}

.side-nav.collapsed {
    width: var(--sidebar-w-collapsed);
}

.side-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.6rem 0.85rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    min-height: 44px;
    width: 100%;
    transition:
        color 0.2s,
        background 0.2s;
}

.side-nav-toggle:hover {
    color: var(--gold);
    background: rgba(201, 168, 76, 0.08);
}

.side-nav-toggle svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.side-nav.collapsed .side-nav-toggle {
    justify-content: center;
}

.side-nav.collapsed .side-nav-toggle svg {
    transform: rotate(180deg);
}

.side-nav-items {
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.4rem;
    gap: 0.2rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}

/* Override nav-tab styles inside the sidebar */
.side-nav .nav-tab {
    flex-direction: row;
    justify-content: flex-start;
    min-width: unset;
    width: 100%;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    gap: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
}

.side-nav .nav-tab .nav-label {
    font-size: 0.9rem;
    font-family: "Cinzel", serif;
    font-weight: 700;
    letter-spacing: 0.08em;
    transition: opacity 0.15s ease;
    overflow: hidden;
    flex-shrink: 0;
}

.side-nav.collapsed .nav-tab {
    justify-content: center;
    padding: 0.65rem;
    gap: 0;
}

.side-nav.collapsed .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.side-nav.collapsed .nav-tab.active::after {
    left: 4px;
    right: 4px;
}

/* Mobile icon-only nav strip (inside header, visible on mobile only) */
.mobile-nav-strip {
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-top: 1px solid var(--border);
    gap: 0.25rem;
}

@media (max-width: 900px) {
    .mobile-nav-strip {
        display: flex;
    }
}

.mobile-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.45rem 0.75rem;
    flex: 1;
    transition: all 0.2s ease;
}

.mobile-nav-btn:hover {
    color: var(--gold-light);
    background: rgba(201, 168, 76, 0.1);
}

.mobile-nav-btn.active {
    color: var(--gold);
    background: rgba(201, 168, 76, 0.15);
    border-color: rgba(201, 168, 76, 0.35);
    box-shadow: 0 0 12px rgba(201, 168, 76, 0.15);
}

.mobile-nav-btn svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
}

/* Tactile press feedback on touch — transition on base so release also animates */
button,
[role="button"] {
    transition: transform 0.08s ease;
}
button:active,
[role="button"]:active {
    transform: scale(0.96);
}

/* User dropdown logout item — danger tint */
.user-dropdown-item.logout-item:hover {
    background: rgba(139, 32, 32, 0.15);
    color: var(--danger-hover);
}

/* ===== LOGIN VIEW ===== */
.login-backdrop {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    background: transparent;
}

.login-bg-grid {
    position: absolute;
    inset: -40px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 6px;
    transform: rotate(-4deg) scale(1.15);
    opacity: 0.6;
    filter: saturate(0.9) brightness(0.85);
    z-index: 0;
    animation: bgPulse 8s ease-in-out infinite alternate;
}

.login-bg-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

@keyframes bgPulse {
    0% {
        opacity: 0.55;
        filter: saturate(0.9) brightness(0.85);
    }
    100% {
        opacity: 0.7;
        filter: saturate(1) brightness(0.95);
    }
}

.login-backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(10, 10, 15, 0.1) 0%,
        rgba(10, 10, 15, 0.6) 70%,
        rgba(10, 10, 15, 0.9) 100%
    );
    z-index: 1;
    pointer-events: none;
}

.login-panel {
    background: linear-gradient(145deg, #2a2d33 0%, #1e2024 40%, #252830 100%);
    border: 4px solid #5a5e66;
    border-radius: 4px;
    padding: 3rem 2.5rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 2;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.5),
        0 0 0 6px #3a3d44,
        0 0 0 7px rgba(0, 0, 0, 0.4),
        0 0 0 12px #2f3238,
        0 0 0 13px rgba(0, 0, 0, 0.3),
        0 12px 40px rgba(0, 0, 0, 0.6);
}

/* Steel plate texture overlay */
.login-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 3px,
            rgba(255, 255, 255, 0.01) 3px,
            rgba(255, 255, 255, 0.01) 4px
        ),
        repeating-linear-gradient(
            0deg,
            transparent 0px,
            transparent 3px,
            rgba(255, 255, 255, 0.008) 3px,
            rgba(255, 255, 255, 0.008) 4px
        );
    pointer-events: none;
    z-index: 0;
}

/* Corner rivets */
.steel-rivet {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(
        circle at 40% 35%,
        #8a8e96 0%,
        #5a5e66 50%,
        #3a3d44 100%
    );
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.2),
        inset 0 -1px 2px rgba(0, 0, 0, 0.4),
        0 1px 3px rgba(0, 0, 0, 0.5);
    z-index: 5;
}
.steel-rivet::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 5px;
    width: 4px;
    height: 1.5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: rotate(-30deg);
}
.rivet-tl {
    top: 12px;
    left: 12px;
}
.rivet-tr {
    top: 12px;
    right: 12px;
}
.rivet-bl {
    bottom: 12px;
    left: 12px;
}
.rivet-br {
    bottom: 12px;
    right: 12px;
}

/* Steel border plate edges */
.steel-edge {
    position: absolute;
    background: linear-gradient(180deg, #5a5e66 0%, #4a4e55 50%, #3a3d44 100%);
    z-index: 1;
}
.steel-edge-top {
    top: 0;
    left: 30px;
    right: 30px;
    height: 3px;
    background: linear-gradient(90deg, #4a4e55, #6a6e76, #4a4e55);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.steel-edge-bottom {
    bottom: 0;
    left: 30px;
    right: 30px;
    height: 3px;
    background: linear-gradient(90deg, #4a4e55, #6a6e76, #4a4e55);
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.3);
}

.login-panel .logo-text {
    font-size: 1.6rem;
    margin-bottom: 0.25rem;
}

.login-panel .logo-subtitle {
    margin-bottom: 2rem;
}

.login-field {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

.login-field:focus {
    outline: none;
    border-color: var(--gold);
}

.login-field::placeholder {
    color: var(--text-muted);
}

.btn-login {
    width: 100%;
    padding: 0.85rem;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    border: none;
    border-radius: 8px;
    color: #1a1a1a;
    font-family: "Cinzel", serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 0.5rem;
}

.btn-login:hover {
    filter: brightness(1.15);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    color: var(--danger-hover);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    min-height: 1.2em;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0 0.5rem;
    color: rgba(180, 160, 100, 0.5);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
}
.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(180, 160, 100, 0.25);
}

.btn-oauth {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.7rem;
    border: 1px solid rgba(180, 160, 100, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #c8c4bc;
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.25s;
    margin-top: 0.5rem;
    text-decoration: none;
}
.btn-oauth:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(180, 160, 100, 0.6);
}
.btn-oauth svg {
    flex-shrink: 0;
}

/* ===== ADMIN VIEW ===== */
.admin-section {
    margin-bottom: 2rem;
}

.admin-section-title {
    font-family: "Cinzel", serif;
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-gold);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    font-family: "Cinzel", serif;
    font-size: 0.8rem;
    color: var(--gold-dark);
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.admin-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.admin-form .login-field {
    margin-bottom: 0;
}

.admin-form-full {
    grid-column: 1 / -1;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: "Cinzel", serif;
    letter-spacing: 0.05em;
}

.badge-admin {
    background: rgba(201, 168, 76, 0.2);
    color: var(--gold);
    border: 1px solid var(--border-gold);
}

.badge-user {
    background: rgba(45, 107, 63, 0.2);
    color: #6dbb82;
    border: 1px solid rgba(45, 107, 63, 0.3);
}

/* ===== MAIN LAYOUT ===== */
.app-container {
    max-width: 1600px;
    margin-left: var(--sidebar-w);
    margin-right: auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
    transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .app-container {
    margin-left: var(--sidebar-w-collapsed);
}

.view {
    display: none;
}
.view.active {
    display: block;
}

/* ===== FORGE VIEW (Generator) ===== */
.forge-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

.panel {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
}

/* Subtle stone arch top border on panels */
.panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(201, 168, 76, 0.15) 20%,
        rgba(201, 168, 76, 0.25) 50%,
        rgba(201, 168, 76, 0.15) 80%,
        transparent
    );
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(
        180deg,
        rgba(201, 168, 76, 0.03) 0%,
        transparent 100%
    );
}

.panel-header h2 {
    font-family: "Cinzel", serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.05em;
}

.panel-header .icon {
    width: 20px;
    height: 20px;
    color: var(--gold-dark);
}

.panel-body {
    padding: 1.5rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-family: "Cinzel", serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

/* Color selector - the mana symbols */
.color-selector {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.color-option {
    position: relative;
}

.color-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.color-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    font-family: "MedievalSharp", cursive;
    font-size: 1.3rem;
    font-weight: bold;
}

.color-option.white label {
    background: radial-gradient(circle at 35% 35%, #fffef5, #f0e6c8);
    color: #6b5b3e;
    border: 2px solid #d4c5a0;
    box-shadow:
        0 0 0 3px transparent,
        inset 0 1px 3px rgba(255, 255, 255, 0.5);
}
.color-option.blue label {
    background: radial-gradient(circle at 35% 35%, #1b8fd4, #0a4f7a);
    color: #c4e4ff;
    border: 2px solid #2196c8;
    box-shadow: 0 0 0 3px transparent;
}
.color-option.black label {
    background: radial-gradient(circle at 35% 35%, #3a3035, #100b0e);
    color: #a8959c;
    border: 2px solid #4a3f44;
    box-shadow: 0 0 0 3px transparent;
}
.color-option.red label {
    background: radial-gradient(circle at 35% 35%, #e8482a, #8b1a1a);
    color: #ffcfb8;
    border: 2px solid #c43a2a;
    box-shadow: 0 0 0 3px transparent;
}
.color-option.green label {
    background: radial-gradient(circle at 35% 35%, #1da050, #0a5028);
    color: #b8f0c8;
    border: 2px solid #1b8545;
    box-shadow: 0 0 0 3px transparent;
}

.color-option input:checked + label {
    box-shadow:
        0 0 0 3px var(--gold),
        0 0 20px rgba(201, 168, 76, 0.3);
    transform: scale(1.1);
}

.color-option label:hover {
    transform: scale(1.08);
}

.color-option input:checked + label:hover {
    transform: scale(1.12);
}

/* Select / Input styling */
.form-select,
.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s;
    appearance: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239A9488' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--gold-dark);
    box-shadow: 0 0 0 2px rgba(201, 168, 76, 0.1);
}

/* iOS Safari applies its own pale autofill background when the device is
           in light mode; pin it to the dark theme so the look stays consistent. */
.form-select:-webkit-autofill,
.form-input:-webkit-autofill,
.form-textarea:-webkit-autofill,
.form-select:-webkit-autofill:focus,
.form-input:-webkit-autofill:focus,
.form-textarea:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-card) inset;
    box-shadow: 0 0 0 1000px var(--bg-card) inset;
    caret-color: var(--text-primary);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

option {
    background: var(--bg-panel);
}

/* Radio group styled as segmented control */
.radio-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.radio-option {
    flex: 1;
    position: relative;
}

.radio-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.radio-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.5rem;
    cursor: pointer;
    font-family: "Cinzel", serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    transition: all 0.3s;
    text-align: center;
}

.radio-option:last-child label {
    border-right: none;
}

.radio-option input:checked + label {
    background: rgba(201, 168, 76, 0.12);
    color: var(--gold);
}

.radio-option label:hover {
    background: var(--bg-hover);
}

/* Generate Button */
.btn-forge {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--ember), var(--gold));
    border: none;
    border-radius: 8px;
    color: #0d0b0f;
    font-family: "Cinzel", serif;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn-forge:hover {
    background-position: right center;
    box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
    transform: translateY(-1px);
    animation: forgePulse 2s ease-in-out infinite;
}

.btn-forge:active {
    transform: translateY(0);
}

.btn-forge:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-forge.loading {
    color: transparent;
}

.btn-forge.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid rgba(10, 10, 15, 0.3);
    border-top-color: #0a0a0f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Preview panel */
.preview-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.preview-empty .sigil {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    opacity: 0.3;
}

.preview-empty p {
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

/* ===== LIBRARY VIEW ===== */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.library-title {
    font-family: "Cinzel", serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.05em;
}

.library-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

.deck-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
}

/* Stone arch top accent */
.deck-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(201, 168, 76, 0.2) 30%,
        rgba(201, 168, 76, 0.3) 50%,
        rgba(201, 168, 76, 0.2) 70%,
        transparent
    );
    opacity: 0;
    transition: opacity 0.3s;
}

.deck-card:hover::before {
    opacity: 1;
}

.deck-card:hover {
    border-color: var(--border-gold);
    transform: translateY(-4px);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px var(--border-gold);
}

.deck-card-top {
    padding: 1.25rem 1.5rem;
    position: relative;
}

.deck-card-colors {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.mana-pip {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "MedievalSharp", cursive;
    font-size: 0.75rem;
    font-weight: bold;
}

.mana-pip.mana-pip-large {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15); /* Sleek highlight ring */
}

.mana-pip.W {
    background: linear-gradient(135deg, #fffef5, #e8d8b8);
    color: #6b5b3e;
}
.mana-pip.U {
    background: linear-gradient(135deg, #1b8fd4, #0a4f7a);
    color: #c4e4ff;
}
.mana-pip.B {
    background: linear-gradient(135deg, #3a3035, #100b0e);
    color: #a8959c;
    border: 1px solid #4a3f44;
}
.mana-pip.R {
    background: linear-gradient(135deg, #e8482a, #8b1a1a);
    color: #ffcfb8;
}
.mana-pip.G {
    background: linear-gradient(135deg, #1da050, #0a5028);
    color: #b8f0c8;
}

.deck-card .mana-pip {
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
}

.deck-card-name {
    font-family: "Cinzel", serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.deck-card-commander {
    font-size: 0.9rem;
    color: var(--gold);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.deck-card-format {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: "Source Sans 3", system-ui, sans-serif;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.deck-card-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.deck-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.5rem;
}

.deck-tag {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    color: var(--gold);
    font-family: "Cinzel", serif;
    letter-spacing: 0.03em;
}

.deck-card-footer {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.deck-card-meta {
    display: flex;
    gap: 1.25rem;
}

.deck-card-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-fav-card {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s;
    line-height: 1;
}

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

.btn-filter-fav {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    font-family: "Cinzel", serif;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-filter-fav:hover,
.btn-filter-fav.active {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(212, 175, 55, 0.08);
}

.btn-delete-card {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn-delete-card:hover {
    background: var(--danger);
    color: var(--text-primary);
}

.library-empty {
    text-align: center;
    padding: 6rem 2rem;
    color: var(--text-muted);
}

.library-empty .sigil {
    width: 100px;
    height: 100px;
    margin: 0 auto 2rem;
    opacity: 0.2;
}

.library-empty h3 {
    font-family: "Cinzel", serif;
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ===== DECK DETAIL VIEW ===== */
.detail-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: "Cinzel", serif;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    transition: color 0.3s;
}

.detail-back:hover {
    color: var(--gold);
}

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-header h1 {
    font-family: "Cinzel", serif;
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.detail-commander {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.detail-strategy {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 960px;
}

.detail-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
    flex-shrink: 0;
}

.detail-commander-image {
    width: 220px;
    border-radius: 12px;
    flex-shrink: 0;
    align-self: flex-start;
    filter: drop-shadow(0 8px 28px rgba(0, 0, 0, 0.65));
    transition:
        transform 0.25s ease,
        filter 0.25s ease;
    cursor: zoom-in;
}

.detail-commander-image:hover {
    transform: scale(1.75);
    filter: drop-shadow(0 16px 48px rgba(0, 0, 0, 0.85));
    position: relative;
    z-index: 10;
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    min-width: 90px;
}

.stat-value {
    font-family: "Cinzel", serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.25rem;
}

.detail-stats .stat-box {
    padding: 0.6rem 0.8rem;
    min-width: 70px;
}

.detail-stats .stat-value {
    font-size: 1.1rem;
}

.detail-stats .stat-label {
    font-size: 0.75rem;
}

.stat-box-mini {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    min-width: 64px;
    text-align: center;
}

.stat-box-mini.invalid-count {
    border-color: rgba(196, 84, 26, 0.6) !important;
    background: rgba(196, 84, 26, 0.08) !important;
}

.stat-box-mini.invalid-count .stat-value-mini {
    color: var(--ember) !important;
}

.stat-value-mini {
    font-family: "JetBrains Mono", monospace !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: var(--gold);
}

.stat-label-mini {
    font-family: "Cinzel", serif;
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.15rem;
}

/* Card list by category */
.category-section {
    background: var(
        --bg-card
    ); /* Solid Iron backplate to block out background art */
    border: 1px solid var(--border); /* Metallic frame border */
    border-radius: 8px; /* Brand md radius */
    padding: 0.5rem 1.25rem; /* Clean internal breathing room */
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35); /* Floating depth shadow */
}

.category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    cursor: pointer;
}

.category-name {
    font-family: "Cinzel", serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.05em;
}

.category-count {
    font-size: 1rem;
    color: var(--text-muted);
}

.category-toggle {
    margin-left: auto;
    color: var(--gold);
    font-size: 1rem;
    flex-shrink: 0;
    user-select: none;
    font-weight: bold;
}

.category-body {
    display: none;
}

.category-body.expanded {
    display: block;
    border-top: 1px solid var(--border); /* Thin divider when expanded */
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.card-row {
    display: grid;
    grid-template-columns: 2.5rem 1fr auto auto;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    align-items: center;
    transition: background 0.2s;
    font-size: 0.95rem;
}

.card-row:hover {
    background: var(--bg-hover);
}

.card-qty {
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
}

.card-name-col {
    display: flex;
    flex-direction: column;
}

.card-name-text {
    color: var(--text-primary);
    font-weight: 600;
}

.card-role-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.card-type-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.card-price {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.875rem;
}

/* Btn general */
.btn-outline {
    background: none;
    border: 1px solid rgba(201, 146, 43, 0.5);
    color: var(--parchment);
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    font-family: "Cinzel", serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-outline:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.btn-danger {
    background: rgba(196, 84, 26, 0.15);
    border: 1px solid rgba(196, 84, 26, 0.4);
    color: var(--ember);
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    font-family: "Cinzel", serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-danger:hover {
    background: rgba(196, 84, 26, 0.25);
    border-color: var(--ember);
}

/* Export dropdown */
.export-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.export-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    background: var(--bg-panel);
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    padding: 0.4rem 0;
    min-width: 160px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.export-dropdown.hidden {
    display: none;
}

.export-dropdown button {
    display: block;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 0.5rem 1rem;
    font-family: "Cinzel", serif;
    font-size: 0.78rem;
    color: var(--text-primary);
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}

.export-dropdown button:hover {
    background: var(--bg-hover);
    color: var(--gold);
}

.export-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.3rem 0;
}

.export-dropdown .export-section-label {
    display: block;
    padding: 0.3rem 1rem 0.1rem;
    font-family: "Cinzel", serif;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: default;
}

/* Toast notifications */
.bulk-delete-bar {
    position: fixed;
    bottom: 2rem;
    bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bulk-delete-bar.hidden {
    display: none;
}

.deck-card.selected {
    outline: 2px solid var(--gold);
    outline-offset: -2px;
}

.deck-card-checkbox {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 18px;
    height: 18px;
    accent-color: var(--gold);
    cursor: pointer;
}

.deck-card {
    position: relative;
}

.toast-container {
    position: fixed;
    bottom: 2rem;
    bottom: max(2rem, env(safe-area-inset-bottom, 0px));
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--glass-bg-strong);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
}

.toast.error {
    border-color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Delete confirmation modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--glass-bg-xstrong);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-gold);
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    text-align: center;
}

.modal h3 {
    font-family: "Cinzel", serif;
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 0.75rem;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Library filter bar */
.library-filters {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--glass-bg-soft);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.filter-input {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 0.95rem;
    padding: 0.45rem 0.85rem;
    flex: 1;
    min-width: 160px;
    transition: border-color 0.2s;
}
.filter-input:focus {
    outline: none;
    border-color: var(--gold-dark);
}
.filter-input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: "Cinzel", serif;
    font-size: 0.75rem;
    padding: 0.45rem 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s;
}
.filter-select:focus {
    outline: none;
    border-color: var(--gold-dark);
}

.filter-color-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.filter-pip {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    font-family: "MedievalSharp", cursive;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.45;
    transition: all 0.2s;
}
.filter-pip.active {
    opacity: 1;
    border-color: var(--gold);
    box-shadow: 0 0 6px rgba(201, 168, 76, 0.5);
}
.filter-pip.W {
    background: radial-gradient(circle at 35% 35%, #fffef5, #f0e6c8);
    color: #6b5b3e;
}
.filter-pip.U {
    background: radial-gradient(circle at 35% 35%, #1b8fd4, #0a4f7a);
    color: #c4e4ff;
}
.filter-pip.B {
    background: radial-gradient(circle at 35% 35%, #3a3035, #100b0e);
    color: #a8959c;
}
.filter-pip.R {
    background: radial-gradient(circle at 35% 35%, #e8482a, #8b1a1a);
    color: #ffcfb8;
}
.filter-pip.G {
    background: radial-gradient(circle at 35% 35%, #1da050, #0a5028);
    color: #b8f0c8;
}

.btn-filter-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: "Cinzel", serif;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    transition: color 0.2s;
}
.btn-filter-clear:hover {
    color: var(--gold);
}

/* Load more button */
.load-more-wrap {
    text-align: center;
    margin-top: 2rem;
}

/* Edit modal */
.edit-modal-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 70vh;
    overflow-y: auto;
    text-align: left;
}
.edit-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.edit-label {
    font-family: "Cinzel", serif;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.edit-input,
.edit-textarea,
.edit-select {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.2s;
}
.edit-input:focus,
.edit-textarea:focus,
.edit-select:focus {
    outline: none;
    border-color: var(--gold-dark);
}
.edit-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Responsive — tablet */
@media (max-width: 900px) {
    .forge-layout {
        grid-template-columns: 1fr;
    }
    .header-inner {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 0;
        gap: 0.5rem;
    }
    .nav-tabs {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    .nav-tab {
        padding: 0.4rem 0.7rem;
        font-size: 0.65rem;
    }
    .nav-tab .nav-icon {
        width: 14px;
        height: 14px;
    }
    .detail-header {
        flex-direction: column;
        gap: 1.5rem;
    }
    .detail-stats {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    .library-filters {
        gap: 0.5rem;
    }

    /* Hide sidebar entirely on mobile */
    .side-nav {
        display: none !important;
    }
    /* Content not shifted on mobile */
    .app-container,
    body.sidebar-collapsed .app-container {
        margin-left: 0;
    }
}

/* Responsive — tablet/large phone */
@media (max-width: 768px) {
    /* Segmented controls wrap on narrow tablets */
    .radio-group {
        flex-wrap: wrap;
    }
    .radio-option {
        min-width: 45%;
    }

    /* Collapse card-editor modal to single column at ≤768px */
    .card-editor-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Responsive — iPhone / small mobile */
@media (max-width: 480px) {
    .app-container {
        padding: 1rem;
    }

    .logo-text {
        font-size: 1.3rem;
    }
    .logo-subtitle {
        display: none;
    }
    .logo-dragon {
        width: 72px;
        height: 72px;
    }
    .header-inner {
        padding: 0.75rem 0;
        gap: 0.5rem;
    }

    .user-info-role {
        display: none;
    }
    .user-info {
        padding: 0.3rem 0.6rem;
    }
    .user-info-name {
        font-size: 0.7rem;
    }

    .staging-banner-text {
        font-size: 0.6rem;
        letter-spacing: 0.05em;
    }
    .staging-full {
        display: none !important;
    }
    .staging-short {
        display: inline !important;
    }

    /* Forge view */
    .panel-body {
        padding: 1rem;
    }
    .color-option label {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    .btn-forge {
        font-size: 0.85rem;
        padding: 0.9rem 1rem;
    }

    /* Library */
    .library-title {
        font-size: 1.3rem;
    }
    .deck-grid {
        grid-template-columns: 1fr;
    }
    .library-filters {
        padding: 0.75rem;
        gap: 0.4rem;
    }
    .filter-input {
        min-width: 100%;
    }
    .filter-color-row {
        flex-wrap: wrap;
    }

    /* Detail */
    .detail-header h1 {
        font-size: 1.4rem;
    }
    .card-row {
        grid-template-columns: 2rem 1fr auto;
        font-size: 1.1rem;
        gap: 0.5rem;
    }
    .card-type-text {
        display: none;
    }
    .card-role-text {
        font-size: 0.7rem;
    }
    .card-price {
        font-size: 0.75rem;
    }
    .detail-stats {
        flex-direction: row;
        gap: 0.75rem;
    }
    .stat-box {
        padding: 0.75rem;
        min-width: 70px;
    }
    .stat-value {
        font-size: 1.1rem;
    }

    /* Modal */
    .modal {
        padding: 1.5rem 1rem;
    }
    .modal-actions {
        flex-direction: column;
    }
    .modal-actions button {
        width: 100%;
    }

    /* Buttons row in detail */
    #detailContent .detail-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    #detailContent .detail-actions button {
        font-size: 0.7rem;
        padding: 0.5rem 0.75rem;
    }

    /* Hide card image tooltip on touch devices */
    .card-img-tooltip {
        display: none !important;
    }

    /* Analysis panel */
    .analysis-body {
        padding: 0.75rem;
    }

    /* Login background — 2 columns on mobile */
    #app-bg-cards,
    .login-bg-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(6, 1fr);
        inset: -20px;
        transform: rotate(-4deg) scale(1.05);
    }
    .login-panel {
        padding: 2rem 1.5rem;
    }

    /* Price lookup — stack layout on mobile */
    #view-prices .panel > div:nth-child(3) {
        flex-direction: column !important;
    }
    #priceCardHeader {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    #priceCardImage img {
        width: 140px !important;
    }

    /* Larger touch targets */
    .btn-delete-card {
        padding: 0.4rem 0.65rem;
        min-height: 44px;
    }
    .filter-pip {
        width: 36px;
        height: 36px;
    }

    /* Category tree — tap-friendly header */
    .category-header {
        min-height: 44px;
        padding: 0.6rem 0;
    }

    /* Hand simulator — smaller cards on narrow screens, keep action buttons horizontal */
    #handSimCards > div {
        width: 80px !important;
    }
    #handSimCards > div img {
        width: 80px !important;
        min-height: 112px !important;
    }
    #handSimModal .modal-actions {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    #handSimModal .modal-actions button {
        width: auto !important;
        flex: 1;
        min-width: 80px;
    }

    /* Deck compare — stack columns vertically, each half takes equal scroll height */
    #compareBody {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr 1fr !important;
    }
    /* Placeholder/loading div should fill the full grid when it's the only child */
    #compareBody > div:only-child {
        grid-column: 1 / -1 !important;
        grid-row: 1 / -1 !important;
    }

    /* Admin — scrollable tables */
    .admin-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-table {
        min-width: 420px;
    }

    /* Admin — stack form fields */
    .admin-form {
        grid-template-columns: 1fr !important;
    }
    .admin-form-full {
        grid-column: 1 !important;
    }

    /* Minimum 44px touch targets on outline/filter buttons */
    .btn-outline {
        padding: 0.65rem 1rem;
        min-height: 44px;
    }
    .btn-filter-fav {
        min-height: 44px;
        min-width: 44px;
    }
    .library-filter-btn {
        min-height: 44px;
        padding: 0.5rem 0.75rem;
    }

    /* Legible secondary text in card detail rows */
    .card-role-text {
        font-size: 0.85rem;
    }
    .card-price {
        font-size: 0.85rem;
    }

    /* Segmented control wraps on small phones */
    .radio-group {
        flex-wrap: wrap;
        border-radius: 8px;
    }
    .radio-option {
        min-width: 45%;
    }
    .radio-option label {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .radio-option:nth-last-child(-n + 2) label {
        border-bottom: none;
    }

    /* Mobile nav strip — larger tap area */
    .mobile-nav-btn {
        padding: 0.6rem 0.75rem;
        min-height: 44px;
    }
}

/* Responsive — desktop upscale */
/* Boost rem base on non-mobile viewports so all rem-sized elements scale up proportionally. */
@media (min-width: 901px) {
    html {
        font-size: 112.5%;
    } /* 1rem = 18px */
}

@media (min-width: 1800px) {
    html {
        font-size: 118.75%;
    } /* 1rem = 19px */
    .app-container {
        max-width: 1800px;
    }
    .header-inner {
        max-width: 1800px;
    }
    .deck-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
}

/* Loading shimmer for generation */
.generating-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--glass-bg-xstrong);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10;
}

.generating-overlay.hidden {
    display: none;
}

.arcane-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.generating-text {
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    color: var(--gold);
    letter-spacing: 0.1em;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Deck detail color bar */
.detail-colors {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

/* Description paragraph */
.deck-description-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold-dark);
    border-radius: 0 8px 8px 0;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
    font-style: italic;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ===== DRAGON THEME ===== */

/* Subtle dragon-scale background texture */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(
            ellipse 24px 15px at 50% 0%,
            rgba(201, 168, 76, 0.038) 0%,
            transparent 100%
        ),
        radial-gradient(
            ellipse 24px 15px at 0% 50%,
            rgba(201, 168, 76, 0.028) 0%,
            transparent 100%
        );
    background-size:
        32px 24px,
        32px 24px;
    background-position:
        0 0,
        16px 12px;
    pointer-events: none;
    z-index: 0;
}

/* Dragon watermark */
.dragon-watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(75vw, 680px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.038;
    color: var(--gold);
}

/* Floating ember particles */
.ember {
    position: fixed;
    bottom: -6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(0.8px);
    animation: emberRise linear infinite;
}
@keyframes emberRise {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    8% {
        opacity: 0.7;
    }
    75% {
        opacity: 0.25;
    }
    100% {
        transform: translateY(-102vh) translateX(var(--drift, 0px));
        opacity: 0;
    }
}

/* Forge button fire pulse */
@keyframes forgePulse {
    0%,
    100% {
        box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
    }
    50% {
        box-shadow:
            0 4px 28px rgba(201, 168, 76, 0.5),
            0 0 55px rgba(220, 70, 5, 0.14);
    }
}

/* ===== END DRAGON THEME ===== */

/* Card image tooltip */
.card-img-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.75);
    border: 1px solid var(--border-gold);
    overflow: hidden;
    width: min(92vw, 476px);
}
.card-img-tooltip.visible {
    opacity: 1;
}
.card-img-tooltip img {
    display: block;
    width: min(92vw, 476px);
    height: auto;
}

/* Card image lightbox (touch/mobile fullscreen) */
.card-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--lightbox-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.card-lightbox.visible {
    opacity: 1;
}
.card-lightbox.hidden {
    display: none;
}
.card-lightbox img {
    max-width: 90vw;
    max-height: 90dvh;
    border-radius: 12px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9);
    border: 1px solid var(--border-gold);
    display: block;
}
.card-name-text {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}
.card-name-text:hover {
    color: var(--gold-light) !important;
}

/* Analysis panel */
.analysis-panel {
    margin-top: 2rem;
    border: 1px solid var(--border-gold);
    border-radius: 8px;
    overflow: hidden;
}
.analysis-panel-header {
    background: linear-gradient(
        90deg,
        rgba(201, 168, 76, 0.12) 0%,
        transparent 100%
    );
    padding: 0.75rem 1.25rem;
    font-family: "Cinzel", serif;
    font-size: 1rem;
    color: var(--gold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-gold);
}
.analysis-body {
    padding: 1.25rem;
    font-size: 1.1rem;
}
.analysis-rating {
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 4px;
    padding: 0.25rem 0.75rem;
    font-family: "Cinzel", serif;
    font-size: 1.05rem;
    color: var(--gold-light);
    margin-bottom: 1rem;
}
.analysis-synergy {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}
.analysis-section-title {
    font-family: "Cinzel", serif;
    font-size: 0.95rem;
    color: var(--gold-dark);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}
.analysis-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem 0;
}
.analysis-list li {
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 0.3rem 0 0.3rem 1rem;
    position: relative;
    line-height: 1.5;
}
.analysis-list li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--gold-dark);
}
.upgrade-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}
.upgrade-swap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}
.upgrade-remove {
    color: #c0392b;
    text-decoration: line-through;
    opacity: 0.8;
}
.upgrade-arrow {
    color: var(--text-muted);
}
.upgrade-add {
    color: #27ae60;
    font-weight: 600;
}
.upgrade-reason {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-style: italic;
}
.upgrade-apply-btn {
    margin-top: 0.4rem;
    padding: 0.2rem 0.65rem;
    font-size: 0.8rem;
    background: var(--gold-dark);
    color: #1a1209;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.15s;
}
.upgrade-apply-btn:hover {
    opacity: 0.85;
}
.upgrade-apply-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.upgrade-apply-btn.applied {
    background: #7a5c1e;
    color: #f0e6c8;
}
.analysis-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Disable hover-only effects on touch devices — prevents states from sticking after tap */
@media (hover: none) {
    .card-row:hover {
        background: none;
    }
    .deck-card:hover {
        transform: none;
        box-shadow: none;
    }
    .nav-tab:hover,
    .mobile-nav-btn:hover {
        background: none;
        color: inherit;
    }
    .btn-outline:hover {
        background: none;
    }
}

/* ── Salt Badges ── */
.salt-badge {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
    flex-shrink: 0;
}
.salt-0 {
    background: var(--text-muted);
    opacity: 0.4;
}
.salt-1 {
    background: #4caf50;
}
.salt-2 {
    background: #ffc107;
}
.salt-3 {
    background: #ff5722;
}
.salt-4 {
    background: #9c27b0;
}
.salt-total {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: "Cinzel", serif;
    font-size: 0.75rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

/* ── Ownership Bar ── */
.ownership-bar {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.ownership-progress {
    flex: 1;
    min-width: 120px;
    height: 8px;
    background: var(--bg-deep);
    border-radius: 4px;
    overflow: hidden;
}
.ownership-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold));
    border-radius: 4px;
    transition: width 0.4s;
}

/* ── Primer Section ── */
.primer-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin: 1.5rem 0;
}
.primer-section h4 {
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--gold);
    margin: 0 0 0.75rem;
    text-transform: uppercase;
}
.primer-section .primer-body {
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text-primary);
}
.primer-section .primer-body h1,
.primer-section .primer-body h2,
.primer-section .primer-body h3 {
    font-family: "Cinzel", serif;
    color: var(--gold-light);
    margin: 1rem 0 0.5rem;
}
.primer-section .primer-body a {
    color: var(--gold-light);
}
.primer-section .primer-body ul,
.primer-section .primer-body ol {
    padding-left: 1.5rem;
}
.primer-textarea {
    width: 100%;
    min-height: 220px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 1rem;
    padding: 0.75rem;
    resize: vertical;
    box-sizing: border-box;
}

/* ── Collection View ── */
.collection-table {
    width: 100%;
    border-collapse: collapse;
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 1.1rem;
}
.collection-table th {
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.collection-table td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}
.collection-table tr:hover td {
    background: var(--bg-panel);
}
.collection-search {
    width: 100%;
    max-width: 360px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}
.buildable-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    transition: box-shadow 0.2s;
}
.buildable-card:hover {
    box-shadow: 0 4px 16px rgba(201, 168, 76, 0.15);
}
.buildable-pct {
    font-family: "Cinzel", serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold);
}
.completion-bar {
    height: 6px;
    background: var(--bg-deep);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.4rem 0;
}
.completion-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold));
    border-radius: 3px;
}
.col-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.col-tab {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    color: var(--text-secondary);
    font-family: "Cinzel", serif;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s;
}
.col-tab.active {
    background: var(--gold-dark);
    color: #1a1208;
    border-color: var(--gold-dark);
}

/* ── History Timeline ── */
.history-entry {
    display: flex;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}
.history-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold);
    margin-top: 5px;
    flex-shrink: 0;
}
.history-meta {
    font-family: "Cinzel", serif;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}
.history-summary {
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 0.95rem;
    color: var(--text-primary);
}
.history-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}
.history-chip {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: "Cinzel", serif;
}
.history-chip.added {
    background: rgba(76, 175, 80, 0.15);
    color: #81c784;
    border: 1px solid rgba(76, 175, 80, 0.3);
}
.history-chip.removed {
    background: rgba(244, 67, 54, 0.12);
    color: #ef9a9a;
    border: 1px solid rgba(244, 67, 54, 0.25);
}

/* ── Recommendations Panel ── */
.rec-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    margin-bottom: 0.5rem;
}
.rec-card .rec-name {
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    color: var(--gold-light);
}
.rec-card .rec-reason {
    font-family: "Source Sans 3", system-ui, sans-serif;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}
.rec-thumb {
    width: 44px;
    min-width: 44px;
    height: 62px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    display: block;
}
.rec-add-btn {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-family: "Cinzel", serif;
    letter-spacing: 0.04em;
    border: 1px solid var(--border-gold);
    background: transparent;
    color: var(--gold);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.rec-add-btn:hover:not(:disabled) {
    background: rgba(201, 168, 76, 0.15);
}
.rec-add-btn:disabled {
    opacity: 0.5;
    cursor: default;
}
.rec-add-btn.added {
    border-color: rgba(76, 175, 80, 0.4);
    color: #81c784;
}
.budget-chip {
    font-size: 0.85rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-family: "Cinzel", serif;
    letter-spacing: 0.04em;
}
.budget-chip.budget {
    background: rgba(76, 175, 80, 0.18);
    color: #81c784;
}
.budget-chip.mid {
    background: rgba(255, 193, 7, 0.15);
    color: #ffd54f;
}
.budget-chip.expensive {
    background: rgba(244, 67, 54, 0.12);
    color: #ef9a9a;
}
.owned-chip {
    font-size: 0.85rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-family: "Cinzel", serif;
    letter-spacing: 0.04em;
}
.owned-chip.owned {
    background: rgba(76, 175, 80, 0.18);
    color: #81c784;
}
.owned-chip.unowned {
    background: rgba(244, 67, 54, 0.12);
    color: #ef9a9a;
}

/* --- JetBrains Mono mappings for Data & System Markers --- */
.admin-table,
.collection-table,
.stat-value,
.badge,
.budget-chip,
.owned-chip,
.history-chip,
.rec-add-btn,
.history-meta,
.synergy-chip {
    font-family: "JetBrains Mono", monospace !important;
    font-weight: 500 !important;
}
