/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    background: #fff;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: #888; }

/* ── Layout ── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: 320px;
    min-width: 320px;
    border-right: 1px solid #e8e8e8;
    padding: 40px 28px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    background: #fff;
    isolation: isolate;
}

.sidebar-header {
    margin-bottom: 32px;
}

.site-name {
    font-size: 0.85em;
    color: #333;
    text-decoration: none;
    letter-spacing: 0.3px;
}

.site-name:hover { color: #888; }

.sidebar-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.sidebar-index {
    flex: 1;
    position: relative;
    z-index: 1;
}

.sidebar-section {
    margin-bottom: 14px;
}

.sidebar-section-heading {
    font-size: 0.72em;
    font-weight: 700;
    color: #333;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.sidebar-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 4px;
    cursor: pointer;
    position: relative;
    border-radius: 3px;
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (hover: hover) {
    .sidebar-item:hover {
        background: rgba(120, 200, 150, 0.08);
        transform: translateX(2px);
    }
}

@media (hover: hover) {
    .sidebar-item:hover .sidebar-item-title { color: #000; }
    .sidebar-item:hover .sidebar-item-date { color: #888; }
}

.sidebar-item.active {
    background: rgba(120, 200, 150, 0.12);
}
.sidebar-item.active .sidebar-item-title { color: #000; font-weight: 600; }
.sidebar-item.active .sidebar-item-date { color: #666; }

.sidebar-item-title {
    font-size: 0.8em;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.1s;
}

.sidebar-item-dash {
    flex: 1;
    border-bottom: 1px solid #ddd;
    min-width: 16px;
    margin-bottom: 3px;
}

.sidebar-item-date {
    font-size: 0.75em;
    color: #bbb;
    white-space: nowrap;
}

.sidebar-footer {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid #e8e8e8;
}

.sidebar-meta {
    font-size: 0.75em;
    color: #bbb;
    text-decoration: none;
}

.sidebar-meta:hover { color: #888; }

/* ── Content ── */
.content {
    flex: 1;
    margin-left: 320px;
    padding: 40px 60px;
    max-width: 900px;
}

/* ── Sections ── */
.section { display: none; opacity: 0; }
.section.active { display: block; animation: fadeIn 0.2s ease forwards; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── About / Home ── */
.about-box {
    max-width: 640px;
}

.about-section-title {
    font-size: 0.8em;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    margin-top: 28px;
    letter-spacing: 0.3px;
}

.about-section-title:first-child { margin-top: 0; }

.about-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 0.8em;
    color: #555;
    line-height: 1.7;
}

.about-item a {
    color: #888;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.about-item a:hover { color: #333; }

.about-arrow {
    flex-shrink: 0;
    font-size: 0.55em;
    margin-top: 5px;
    color: #999;
}

.contact-box {
    margin-top: 28px;
    padding: 14px 18px;
    border: 1px solid #e8e8e8;
    font-size: 0.78em;
    color: #888;
}

/* ── Index Lists (essays, guides, projects) ── */
.index-list {
    max-width: 640px;
}

.section-title {
    font-size: 0.85em;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    letter-spacing: 0.3px;
    text-transform: lowercase;
}

.index-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    padding: 4px 0;
}

.index-item:hover .index-title { color: #000; }

.index-title {
    font-size: 0.82em;
    color: #444;
    white-space: nowrap;
    transition: color 0.1s;
}

.index-dash {
    flex: 1;
    border-bottom: 1px solid #ddd;
    min-width: 20px;
    margin-bottom: 3px;
}

.index-date {
    font-size: 0.75em;
    color: #bbb;
    white-space: nowrap;
}

/* ── Detail View (single essay / project) ── */
.detail-back {
    font-size: 0.78em;
    color: #bbb;
    cursor: pointer;
    margin-bottom: 24px;
    display: inline-block;
}

.detail-back:hover { color: #333; }

.detail-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.detail-date {
    font-size: 0.78em;
    color: #bbb;
    margin-bottom: 24px;
}

.detail-description {
    font-size: 0.85em;
    color: #555;
    line-height: 1.8;
    margin-bottom: 24px;
}

.detail-body {
    font-size: 0.85em;
    color: #444;
    line-height: 1.9;
    word-wrap: break-word;
    max-width: 640px;
}

.detail-body p {
    margin-bottom: 16px;
}

.detail-h2 {
    font-size: 1em;
    font-weight: 600;
    color: #333;
    margin-top: 32px;
    margin-bottom: 12px;
}

.detail-h3 {
    font-size: 0.9em;
    font-weight: 600;
    color: #444;
    margin-top: 24px;
    margin-bottom: 8px;
}

.detail-img {
    margin: 20px 0;
}

.detail-img img {
    max-width: 100%;
    height: auto;
    border: 1px solid #e8e8e8;
}

.detail-list {
    list-style: disc;
    padding-left: 20px;
    margin-bottom: 16px;
}

.detail-list li {
    margin-bottom: 6px;
}

.detail-body a, .detail-list a {
    color: #888;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.detail-body a:hover, .detail-list a:hover {
    color: #333;
}

.detail-link {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.8em;
    color: #888;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.detail-link:hover { color: #333; }

/* ── Embeds ── */
.detail-embed {
    margin: 16px 0;
    border: 1px solid #e8e8e8;
    border-radius: 3px;
    overflow: hidden;
}

.detail-embed iframe {
    width: 100%;
    height: 70vh;
    display: block;
}

/* ── Detail Images ── */
.detail-images {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.detail-images img {
    max-width: 100%;
    height: auto;
    border: 1px solid #e8e8e8;
}

.detail-images.gallery {
    display: block;
    columns: 2;
    column-gap: 10px;
}

.detail-images.gallery img {
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    break-inside: avoid;
    cursor: pointer;
}

.gallery-cols {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.gallery-col {
    flex: 1;
    min-width: 0;
}

.gallery-col img {
    width: 100%;
    height: auto;
    margin-bottom: 10px;
    cursor: pointer;
    border: 1px solid #e8e8e8;
}

/* ── Photo Grid ── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.photo-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.15s;
    border: 1px solid #f0f0f0;
}

.photo-grid img:hover { opacity: 0.85; }

/* ── Photo Lightbox ── */
.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox.active { display: flex; }

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* ── Shelf Section ── */
.shelf-tabs {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e8e8e8;
}

.shelf-tab {
    padding: 8px 0;
    font-size: 0.78em;
    color: #bbb;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    text-transform: lowercase;
    letter-spacing: 0.3px;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.shelf-tab:hover { color: #888; }
.shelf-tab.active { color: #333; border-bottom-color: #333; }

.shelf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 14px;
}

.shelf-item {
    cursor: pointer;
    transition: transform 0.15s;
}

.shelf-item:hover { transform: translateY(-3px); }

.shelf-cover {
    width: 100%;
    aspect-ratio: 2/3;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    overflow: hidden;
    position: relative;
}

.shelf-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shelf-item-title {
    font-size: 0.68em;
    color: #888;
    margin-top: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shelf-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 0.75em;
    background: #fff;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e8e8e8;
}

/* Shelf list (for essays/music) */
.shelf-list-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
    padding: 4px 0;
    cursor: pointer;
}

.shelf-list-item:hover .shelf-list-title { color: #000; }

.shelf-list-title {
    font-size: 0.82em;
    color: #444;
    transition: color 0.1s;
}

.shelf-list-author {
    font-size: 0.75em;
    color: #bbb;
}

/* Shelf detail modal */
.shelf-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.shelf-modal.active { display: flex; }

.shelf-modal-content {
    background: #fff;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid #e8e8e8;
}

.shelf-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 1.3em;
    cursor: pointer;
    color: #bbb;
    background: none;
    border: none;
    font-family: inherit;
}

.shelf-modal-close:hover { color: #333; }

.shelf-modal-title {
    font-size: 0.9em;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.shelf-modal-meta {
    font-size: 0.78em;
    color: #bbb;
    margin-bottom: 12px;
}

.shelf-modal-review {
    font-size: 0.8em;
    line-height: 1.8;
    color: #555;
    white-space: pre-wrap;
}

/* ── Sidebar Hover Preview ── */
.sidebar-hover {
    display: none;
    position: fixed;
    z-index: 200;
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 14px 16px;
    max-width: 300px;
    font-size: 0.78em;
    color: #555;
    line-height: 1.6;
    pointer-events: none;
}

.sidebar-hover.active { display: block; }

.sidebar-hover .hover-text {
    color: #555;
}

.sidebar-hover .hover-img {
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    margin-bottom: 8px;
    border: 1px solid #eee;
}

/* ── Loading ── */
.loading {
    font-size: 0.78em;
    color: #bbb;
    padding: 20px 0;
}

/* ── Toolbar (bottom center) ── */
.toolbar {
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0;
    background: #fff;
    padding: 5px 8px;
    border: 1px solid #e8e8e8;
    border-radius: 20px;
    user-select: none;
    box-shadow: 0 1px 8px rgba(0,0,0,0.04);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 7px;
}

.toolbar-sep {
    width: 1px;
    height: 16px;
    background: #e0e0e0;
    margin: 0 8px;
    flex-shrink: 0;
}

.toolbar-btn {
    background: none;
    border: none;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #bbb;
    padding: 0;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}

.toolbar-btn:hover {
    color: #333;
    background: #f5f5f5;
}

.toolbar-btn:active {
    background: #eee;
}

.toolbar-lucky {
    width: auto;
    font-size: 9px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    padding: 0 8px;
    height: 26px;
    letter-spacing: 0.2px;
    color: #bbb;
    white-space: nowrap;
    font-style: italic;
    display: flex;
}

/* ── Ideas Popup ── */
.ideas-popup {
    display: none;
    position: fixed;
    bottom: 60px;
    right: 20px;
    z-index: 9998;
    width: 340px;
    background: #fff;
    border: 1px solid #e8e8e8;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    padding: 16px 18px;
}

.ideas-popup.active {
    display: block;
}

.ideas-popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.1em;
    color: #bbb;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.ideas-popup-close:hover { color: #333; }

.ideas-popup-text {
    font-size: 0.8em;
    color: #444;
    line-height: 1.7;
    padding-right: 16px;
}

.ideas-popup-from {
    font-size: 0.68em;
    color: #bbb;
    margin-top: 10px;
    font-style: italic;
}

/* ── Mobile Nav Button ── */
.mobile-nav-btn {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .mobile-nav-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 300;
        width: 36px;
        height: 36px;
        background: #fff;
        border: 1px solid #e8e8e8;
        font-size: 18px;
        color: #555;
        cursor: pointer;
        font-family: inherit;
        padding: 0;
    }

    .mobile-nav-btn:active {
        background: #f5f5f5;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: transparent;
        z-index: 150;
    }

    .sidebar-backdrop.active {
        display: block;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        border-right: 1px solid #e8e8e8;
        border-bottom: none;
        padding: 20px;
        background: #fff;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        margin-bottom: 16px;
    }

    .sidebar-footer {
        margin-top: 12px;
    }

    .content {
        margin-left: 0;
        padding: 60px 20px 24px;
    }

    .ideas-popup {
        right: 3%;
        left: 3%;
        width: 94%;
        bottom: 64px;
    }

    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .shelf-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 10px;
    }

    .detail-images.gallery {
        columns: 2;
    }
}

/* ── Login modal (kept from original) ── */
.login-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.login-modal.active { display: flex; }

.login-modal-content {
    background-color: #fff;
    padding: 30px;
    max-width: 350px;
    width: 90%;
    position: relative;
    border: 1px solid #e8e8e8;
}

.login-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5em;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
    line-height: 1;
}

.login-modal-close:hover { color: #333; }

.login-modal h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 0.85em;
    font-weight: normal;
    text-transform: lowercase;
    color: #333;
    font-family: inherit;
}

.login-form-group {
    margin-bottom: 15px;
}

.login-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.8em;
    text-transform: lowercase;
    color: #333;
}

.login-form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e8e8e8;
    font-family: inherit;
    font-size: 0.85em;
    box-sizing: border-box;
}

.login-btn {
    background: none;
    color: #333;
    border: 1px solid #e8e8e8;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.8em;
    font-family: inherit;
    text-transform: lowercase;
    width: 100%;
}

.login-btn:hover { background: #f5f5f5; }

.login-error {
    color: #c33;
    font-size: 0.8em;
    margin-bottom: 15px;
}

/* ── Shelf Player ── */
.shelf-player {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 8000;
    width: 340px;
    max-height: 80vh;
    background: #fff;
    border: 1px solid #e8e8e8;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    overflow: hidden;
    flex-direction: column;
}

.shelf-player.active {
    display: flex;
}

.sp-video {
    width: 100%;
    position: relative;
    padding-bottom: 56.25%;
    background: #000;
    line-height: 0;
    flex-shrink: 0;
}

.sp-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    border: none;
}

.sp-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 6px 12px;
    border-top: 1px solid #e8e8e8;
    background: #fafafa;
    gap: 6px;
}

.sp-now {
    flex: 1;
    min-width: 0;
}

.sp-album {
    display: block;
    font-size: 0.65em;
    color: #bbb;
    font-family: 'SF Mono', 'Menlo', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
}

.sp-album:empty {
    display: none;
}

.sp-track {
    display: block;
    font-size: 0.78em;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.sp-buttons {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.sp-btn {
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
    padding: 0;
    border-radius: 4px;
    transition: color 0.12s, background 0.12s;
}

.sp-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.sp-btn:active {
    background: #e8e8e8;
}

.sp-list {
    height: 140px;
    overflow-y: auto;
    border-top: 1px solid #e8e8e8;
}

.mode-film .sp-list {
    height: 84px;
}

.mode-music .sp-list {
    height: 140px;
}

.sp-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 0.75em;
    color: #666;
    transition: background 0.1s;
}

.sp-list-item:hover {
    background: rgba(120, 200, 150, 0.08);
    color: #333;
}

.sp-list-item.active {
    background: rgba(120, 200, 150, 0.12);
    color: #000;
    font-weight: 600;
}

.sp-list-num {
    color: #ccc;
    font-size: 0.9em;
    width: 16px;
    text-align: right;
    flex-shrink: 0;
}

.sp-list-item.active .sp-list-num {
    color: #888;
}

.sp-list-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Music Player (Spotify) ── */
.music-player {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 8000;
    width: 300px;
    background: #fff;
    border: 1px solid #e8e8e8;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    overflow: hidden;
    flex-direction: column;
}

.music-player.active {
    display: flex;
}

.mp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.mp-title {
    font-size: 0.72em;
    color: #555;
    font-family: 'SF Mono', 'Menlo', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.mp-close {
    background: none;
    border: 1px solid #e0e0e0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9em;
    color: #bbb;
    font-family: inherit;
    padding: 0;
    flex-shrink: 0;
}

.mp-close:hover { color: #333; }

.mp-embed {
    line-height: 0;
}

.mp-embed iframe {
    display: block;
    border: none;
    width: 100%;
}

@media (max-width: 768px) {
    .shelf-player {
        top: 50%;
        left: 3%;
        right: 3%;
        bottom: auto;
        transform: translateY(-50%);
        width: 94%;
        max-height: 75vh;
    }
}
