:root {
    --cream: #f4ede4;
    --terracotta: #c4704b;
    --terracotta-light: #d4886a;
    --warm-gray: #a09585;
    --bg: #1e1a16;
    --sidebar-bg: rgba(30, 26, 22, 0.92);
    --serif: 'Playfair Display', Georgia, serif;
    --sans: 'Libre Franklin', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--cream);
    font-family: var(--sans);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#canvas3d {
    position: fixed;
    inset: 0;
    z-index: 1;
}

.vignette {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(30, 26, 22, 0.4) 100%);
}

/* ===== BACK LINK (top right) ===== */
.back-link {
    position: fixed;
    top: 18px;
    right: 24px;
    z-index: 60;
    font-size: 0.52rem;
    font-weight: 300;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--cream);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(30, 26, 22, 0.7);
    border: 1px solid rgba(200, 165, 90, 0.15);
    border-radius: 20px;
    backdrop-filter: blur(8px);
    transition: all 0.3s;
}

.back-link:hover {
    background: rgba(196, 112, 75, 0.15);
    border-color: var(--terracotta);
}

.back-link svg {
    width: 13px;
    height: 13px;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    z-index: 50;
    background: rgba(30, 26, 22, 0.95);
    border-right: 1px solid rgba(200, 165, 90, 0.06);
    display: flex;
    flex-direction: column;
    padding: 32px 28px;
}

.logo {
    font-family: var(--serif);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--cream);
    text-decoration: none;
    margin-bottom: 40px;
    display: block;
}

.logo span {
    color: var(--terracotta-light);
}

/* Sidebar content (grows) */
.sidebar-content {
    flex: 1;
}

.tag {
    font-size: 0.42rem;
    font-weight: 300;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--terracotta-light);
    margin-bottom: 8px;
}

.sidebar h1 {
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 400;
    line-height: 1.15;
    margin-bottom: 8px;
}

.sidebar h1 em {
    font-style: italic;
    color: var(--terracotta-light);
}

.breadcrumb {
    font-size: 0.5rem;
    font-weight: 200;
    color: var(--warm-gray);
    margin-bottom: 24px;
}

.breadcrumb a {
    color: var(--terracotta-light);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--cream);
}

/* Tabs */
.tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.35s, max-height 0.35s;
}

.tabs.visible {
    opacity: 1;
    max-height: 200px;
}

.tab-btn {
    padding: 8px 14px;
    text-align: left;
    border: 1px solid rgba(200, 165, 90, 0.08);
    background: transparent;
    color: var(--warm-gray);
    font-family: var(--sans);
    font-size: 0.55rem;
    font-weight: 300;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn:hover {
    border-color: rgba(200, 165, 90, 0.2);
    color: var(--cream);
}

.tab-btn.active {
    border-color: var(--terracotta);
    color: var(--cream);
    background: rgba(196, 112, 75, 0.08);
}

/* Detail */
.detail {
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.detail.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.detail-line {
    width: 30px;
    height: 1px;
    background: var(--terracotta);
    margin-bottom: 14px;
}

.detail-sub {
    font-size: 0.42rem;
    font-weight: 400;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--terracotta);
    margin-bottom: 6px;
}

.detail h3 {
    font-family: var(--serif);
    font-size: 1.1rem;
    font-weight: 400;
    line-height: 1.3;
    margin-bottom: 6px;
}

.detail-desc {
    font-size: 0.65rem;
    font-weight: 200;
    color: rgba(244, 237, 228, 0.5);
    line-height: 1.7;
}

/* Page navigation — fixed right side */
.page-nav {
    position: fixed;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}

.page-nav.visible {
    opacity: 1;
    pointer-events: auto;
}

.page-arrow {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid rgba(200, 165, 90, 0.25);
    background: rgba(30, 26, 22, 0.85);
    color: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.page-arrow svg {
    width: 22px;
    height: 22px;
}

.page-arrow:hover {
    border-color: var(--terracotta);
    background: rgba(196, 112, 75, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 18px rgba(196, 112, 75, 0.15);
}

.page-arrow:active {
    transform: scale(0.92);
}

.page-arrow:disabled {
    opacity: 0.15;
    pointer-events: none;
}

.page-label {
    font-family: var(--sans);
    font-size: 0.5rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    color: var(--warm-gray);
    writing-mode: vertical-lr;
    text-orientation: mixed;
}

/* Sidebar bottom */
.sidebar-bottom {
    border-top: 1px solid rgba(200, 165, 90, 0.06);
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hint {
    font-size: 0.48rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--warm-gray);
    opacity: 0;
    transition: opacity 0.35s;
}

.hint.visible {
    opacity: 1;
}

.sidebar-controls {
    display: flex;
    gap: 8px;
}

.s-btn {
    padding: 12px 24px;
    border: 1px solid rgba(200, 165, 90, 0.25);
    border-radius: 3px;
    background: rgba(196, 112, 75, 0.08);
    color: var(--cream);
    font-family: var(--sans);
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s;
    opacity: 0;
    pointer-events: none;
}

.s-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.s-btn:hover {
    border-color: var(--terracotta);
    background: rgba(196, 112, 75, 0.18);
    color: var(--cream);
}

.counter {
    font-size: 0.48rem;
    font-weight: 200;
    color: var(--warm-gray);
    opacity: 0;
    transition: opacity 0.3s;
}

.counter.visible {
    opacity: 1;
}

.counter .cur {
    font-family: var(--serif);
    font-size: 0.9rem;
    color: var(--terracotta-light);
}

/* ===== LIGHTBOX ===== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(20, 18, 14, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.open {
    opacity: 1;
    visibility: visible;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: var(--warm-gray);
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 210;
}

.lightbox-close:hover {
    color: var(--cream);
}

.lightbox-img {
    max-width: 85vw;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transition: opacity 0.25s;
}

.lightbox-info {
    text-align: center;
    margin-top: 18px;
}

.lightbox-title {
    font-family: var(--serif);
    font-size: 1rem;
    font-weight: 400;
    color: var(--cream);
    margin-bottom: 4px;
}

.lightbox-desc {
    font-size: 0.6rem;
    font-weight: 200;
    color: var(--warm-gray);
}

.lightbox-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 18px;
}

.lightbox-arrow {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(200, 165, 90, 0.2);
    background: rgba(30, 26, 22, 0.6);
    color: var(--cream);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.lightbox-arrow svg {
    width: 18px;
    height: 18px;
}

.lightbox-arrow:hover {
    border-color: var(--terracotta);
    background: rgba(196, 112, 75, 0.15);
}

.lightbox-arrow:disabled {
    opacity: 0.15;
    pointer-events: none;
}

.lightbox-counter {
    font-size: 0.5rem;
    font-weight: 300;
    color: var(--warm-gray);
    letter-spacing: 0.1em;
}

/* ===== MOBILE 2D GRID ===== */
.mobile-grid {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 50px 12px 160px;
    background: rgba(30, 26, 22, 0.75);
    display: none;
}

.mobile-grid.centered {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.mobile-grid-inner {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

.mobile-card {
    background: rgba(30, 26, 22, 0.7);
    border: 1px solid rgba(200, 165, 90, 0.08);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.mobile-card:active {
    transform: scale(0.97);
}

.mobile-card:hover {
    border-color: rgba(200, 165, 90, 0.2);
}

.mobile-card img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
    background: rgba(200, 165, 90, 0.05);
}

.mobile-card-info {
    padding: 8px 10px;
}

.mobile-card-title {
    font-family: var(--sans);
    font-size: 0.55rem;
    font-weight: 400;
    color: var(--cream);
    line-height: 1.3;
}

.mobile-card-num {
    font-family: var(--serif);
    font-size: 0.65rem;
    color: var(--terracotta-light);
    opacity: 0.5;
    float: right;
    margin-top: -2px;
}

/* ===== RESPONSIVE ===== */

/* Tablet & mobile — sidebar becomes compact bottom drawer */
@media (max-width: 900px) {

    /* Show mobile 2D grid */
    .mobile-grid {
        display: block;
    }

    /* Make 3D just a background */
    #canvas3d {
        opacity: 0.3;
    }

    .sidebar {
        width: 100%;
        height: auto;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-right: none;
        border-top: 1px solid rgba(200, 165, 90, 0.06);
        max-height: 25vh;
        padding: 12px 16px;
        flex-direction: column;
        overflow-y: auto;
        z-index: 60;
    }

    .logo {
        margin-bottom: 4px;
        font-size: 0.85rem;
    }

    .sidebar h1 {
        font-size: 1rem;
        margin-bottom: 2px;
    }

    .tag {
        margin-bottom: 2px;
    }

    .breadcrumb {
        margin-bottom: 6px;
    }

    .sidebar-content {
        flex: 0;
    }

    .tabs {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        margin-bottom: 6px;
    }

    .tab-btn {
        padding: 5px 12px;
        font-size: 0.45rem;
    }

    .sidebar-bottom {
        padding-top: 6px;
    }

    .detail {
        margin-top: 4px;
    }

    .detail-line {
        margin-bottom: 6px;
    }

    .detail h3 {
        font-size: 0.85rem;
    }

    .detail-desc {
        font-size: 0.55rem;
    }

    .hint {
        font-size: 0.42rem;
    }

    .s-btn {
        font-size: 0.42rem;
        padding: 5px 10px;
    }

    .back-link {
        top: 10px;
        right: 12px;
        font-size: 0.45rem;
    }

    .back-link svg {
        width: 11px;
        height: 11px;
    }

    .page-nav {
        display: none;
    }

    .lightbox-img {
        max-width: 92vw;
        max-height: 60vh;
    }

    .lightbox-info {
        margin-top: 10px;
    }

    .lightbox-title {
        font-size: 0.8rem;
    }

    .lightbox-desc {
        font-size: 0.5rem;
    }

    .lightbox-nav {
        margin-top: 10px;
    }

    .lightbox-arrow {
        width: 36px;
        height: 36px;
    }

    .lightbox-close {
        top: 10px;
        right: 12px;
        font-size: 1.1rem;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .sidebar {
        padding: 8px 12px;
        max-height: 28vh;
    }

    .logo {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }

    .sidebar h1 {
        font-size: 0.9rem;
    }

    .tag {
        font-size: 0.36rem;
    }

    .breadcrumb {
        font-size: 0.42rem;
    }

    .tab-btn {
        font-size: 0.4rem;
        padding: 4px 8px;
    }

    .s-btn {
        font-size: 0.38rem;
        padding: 4px 8px;
    }

    .back-link {
        top: 6px;
        right: 8px;
        font-size: 0.4rem;
    }

    .page-nav {
        right: 6px;
    }

    .page-arrow {
        width: 34px;
        height: 34px;
    }

    .lightbox-img {
        max-width: 95vw;
        max-height: 55vh;
    }

    .lightbox-arrow {
        width: 32px;
        height: 32px;
    }

    .lightbox-arrow svg {
        width: 14px;
        height: 14px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
        height: 100%;
        top: 0;
        bottom: 0;
        left: 0;
        right: auto;
        max-height: none;
        border-right: 1px solid rgba(200, 165, 90, 0.06);
        border-top: none;
        padding: 14px 14px;
    }

    .logo {
        margin-bottom: 12px;
    }

    .sidebar h1 {
        font-size: 0.95rem;
    }

    .tabs {
        flex-direction: column;
    }

    .back-link {
        top: 10px;
        right: 10px;
    }

    .lightbox-img {
        max-width: 70vw;
        max-height: 80vh;
    }

    .lightbox-info {
        margin-top: 6px;
    }

    .lightbox-nav {
        margin-top: 6px;
    }
}