/* 
  Theme: Uchiyoso Hidden Hideout (Retro & Warm Dark Mode)
*/
@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@400;500;700&family=Yuji+Syuku&display=swap');

@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho&display=swap');

:root {
    --bg-color: #1a1917;
    --bg-secondary: #242220;
    --text-primary: #e6e2d6;
    --text-secondary: #a8a49c;
    --accent-gold: #cba052;
    --accent-red: #8a3b3b;
    --border-color: #3e3b36;
    --wood-brown: #5d4037;
    --wood-shelf: #4e342e;
    --lantern-glow: rgba(255, 167, 38, 0.4);
    --font-main: 'Shippori Mincho', serif;
    --font-accent: 'Yuji Syuku', serif;
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


header {
    padding: 16px 32px;
    background-color: rgba(26, 25, 23, 0.9);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 2px;
}

.logo img {
    /* Slight adjustment down */
    position: relative;
    top: 2px;
}

.logo a {
    text-decoration: none;
    color: inherit;
    font-family: var(--font-accent);
}

.nav-links {
    display: flex;
    gap: 16px;
    align-items: center;
}

.btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover,
.btn.active {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.btn-primary {
    background-color: var(--accent-gold);
    color: #000;
    font-weight: bold;
    border-color: var(--accent-gold);
}

/* SEARCH UI */
.search-wrapper {
    position: relative;
    margin: 0 20px;
    flex: 1;
    max-width: 300px;
}

#tag-search {
    width: 100%;
    padding: 8px 12px;
    background: rgba(20, 20, 20, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    transition: all 0.3s;
    outline: none;
}

#tag-search:focus {
    border-color: var(--accent-gold);
    background: rgba(40, 40, 40, 0.8);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: #2a2520;
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow: hidden;
}

/* Default (Desktop) State */
.mobile-search-btn {
    display: none;
    /* Hide on desktop */
}

/* Novel Bookshelf & Viewer Visibility */
#novel-bookshelf-area,
#novel-viewer-area {
    /* Ensure they are visible by default on desktop */
    display: flex;
    flex-direction: column;
}

#novel-viewer-area {
    display: none;
    /* Hidden initially, shown via JS */
}

/* Mobile Specific Overrides in Media Query */
/* Mobile Overrides - Add to existing Media Query or use specific block below */

.suggestion-item {
    padding: 10px 15px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--accent-gold);
    color: #1a1a1a;
}

/* HOME PAGE SPLIT LAYOUT */
.home-container {
    display: flex;
    flex: 1;
    width: 100%;
    height: calc(100vh - 70px);
}

.split-section {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: flex 0.5s ease;
    border-right: 1px solid var(--border-color);
    cursor: default;
}

.split-section:last-child {
    border-right: none;
}

.split-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: grayscale(80%) brightness(0.4);
    transition: all 0.5s ease;
    z-index: 1;
    background-image: var(--bg-image);
}

.split-section:hover::before {
    filter: grayscale(0%) brightness(0.75);
    transform: scale(1.02);
}

.split-section:hover {
    flex: 1.1;
}

/* 下部バー方式: キャラクター情報を下部に固定 */
.char-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    text-align: center;
    padding: 25px 20px;
    background: linear-gradient(to top,
            rgba(26, 25, 23, 0.95) 0%,
            rgba(26, 25, 23, 0.85) 60%,
            rgba(26, 25, 23, 0) 100%);
    backdrop-filter: blur(3px);
    transition: all 0.4s ease;
}

.split-section:hover .char-content {
    padding: 35px 20px;
    background: linear-gradient(to top,
            rgba(26, 25, 23, 0.98) 0%,
            rgba(26, 25, 23, 0.9) 70%,
            rgba(26, 25, 23, 0) 100%);
}

.char-name {
    font-size: 2rem;
    color: var(--accent-gold);
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    transition: all 0.4s ease;
    letter-spacing: 0.1em;
}

.split-section:hover .char-name {
    font-size: 2.2rem;
    text-shadow: 0 0 20px rgba(203, 160, 82, 0.5);
}

/* リンクは常に表示 */
.char-links {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 12px;
    opacity: 0.85;
    transition: all 0.4s ease;
}

.split-section:hover .char-links {
    opacity: 1;
    gap: 15px;
}

.char-links .btn {
    font-size: 0.85rem;
    padding: 8px 16px;
    background: rgba(36, 34, 32, 0.8);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.char-links .btn:hover {
    background: var(--accent-gold);
    color: #000;
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

/* Mobile: Home page bottom bar adjustments */
@media (max-width: 768px) {
    .home-container {
        flex-direction: column;
    }

    .split-section {
        min-height: 50vh;
    }

    .char-content {
        padding: 15px 10px;
    }

    .char-name {
        font-size: 1.5rem;
        margin-bottom: 10px;
    }

    .char-links {
        gap: 6px;
        justify-content: center;
    }

    .char-links .btn {
        font-size: 0.7rem;
        padding: 6px 10px;
        min-width: auto;
    }
}

/* BACKGROUND EDIT MODE (Logged In) */
body.logged-in .split-section {
    cursor: pointer;
}

body.logged-in .split-section::after {
    content: 'Click to change background';
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: var(--accent-gold);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    opacity: 0;
    transition: 0.3s;
    z-index: 20;
}

body.logged-in .split-section:hover::after {
    opacity: 1;
}

/* PROFILE PAGE (Character.html) - Dark Vintage Parchment Style */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&display=swap');

/* Profile page specific body styles */
.profile-page {
    background: #1a1510;
    background-image:
        radial-gradient(ellipse at center, rgba(60, 40, 20, 0.3) 0%, transparent 70%),
        url('https://www.transparenttextures.com/patterns/old-map.png');
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.profile-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

.flip-card {
    perspective: 2000px;
    width: 100%;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.flip-card-inner.flipped {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    width: 100%;
    backface-visibility: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.flip-card-front::before,
.flip-card-front::after,
.flip-card-back::before,
.flip-card-back::after {
    display: none;
}

.flip-card-back {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(180deg);
}

/* Main Layout - 50:50 Two Columns */
.char-layout {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: 60px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Left Side - Image Area with Wood Frame */
.char-visuals {
    width: 50%;
    max-width: 700px;
    background: linear-gradient(135deg, #3a2a1a 0%, #2a1a0a 100%);
    border: 12px solid;
    border-image: linear-gradient(135deg,
            #6b4c2e 0%,
            #8b6c4e 15%,
            #a5855a 30%,
            #c9a875 50%,
            #a5855a 70%,
            #8b6c4e 85%,
            #6b4c2e 100%) 1;
    border-radius: 0;
    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.8),
        inset 0 0 60px rgba(0, 0, 0, 0.5),
        0 0 0 4px #3a2a1a,
        0 0 0 6px #6b4c2e;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Main Character Image - Single Large Image */
.char-tachie {
    width: 100%;
    height: auto;
    min-height: 500px;
    max-height: 650px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 4px;
    border: 4px solid #c9a875;
    background-color: rgba(20, 15, 10, 0.9);
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.5),
        0 8px 25px rgba(0, 0, 0, 0.6);
}

/* Hide gallery - using single image only */
.char-gallery {
    display: none;
}

.gallery-thumb {
    display: none;
}

/* Right Side - Text & Status Area */
.char-info {
    width: 50%;
    padding: 40px 30px;
    background: rgba(40, 30, 20, 0.7);
    border-radius: 12px;
    border: 4px solid #5a4a3a;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 0 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 0;
}

.char-info h1.char-name {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #d4af37;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid #8b6f47;
    padding-bottom: 15px;
    margin: 0;
    letter-spacing: 2px;
}

.char-bio {
    font-family: 'Shippori Mincho', serif;
    font-size: 1.05rem;
    color: #e0d0b0;
    line-height: 1.9;
    text-align: left;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid #8b6f47;
}

/* Status Bars Container */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: rgba(0, 0, 0, 0.3);
    padding: 25px;
    border-radius: 10px;
    border: 2px solid #5a4a3a;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-label {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: #c9a875;
    width: 100px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Custom Slider Styling */
.stat-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 12px;
    background: linear-gradient(to right, #5a4a3a, #3a2a1a);
    border-radius: 6px;
    outline: none;
    position: relative;
    border: 1px solid #8b6f47;
}

.stat-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #d4af37 0%, #8b6f47 100%);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #e0d0b0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: all 0.2s;
}

.stat-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.stat-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #d4af37 0%, #8b6f47 100%);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #e0d0b0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Flip Trigger Button */
.flip-trigger {
    margin-top: auto;
    text-align: center;
    cursor: pointer;
    background: linear-gradient(135deg, #5a4a3a 0%, #3a2a1a 100%);
    color: #d4af37;
    border: 2px solid #8b6f47;
    padding: 15px 30px;
    border-radius: 30px;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.flip-trigger:hover {
    background: linear-gradient(135deg, #8b6f47 0%, #5a4a3a 100%);
    border-color: #d4af37;
    box-shadow:
        0 5px 20px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(212, 175, 55, 0.3);
    transform: translateY(-2px);
}

.flip-trigger i {
    margin-right: 8px;
}

/* Responsive Design */
@media (max-width: 900px) {
    .char-layout {
        flex-direction: column;
        gap: 30px;
        padding: 0 10px;
    }

    .calendar-container {
        padding: 0 10px;
    }

    .char-visuals,
    .char-info {
        width: 100%;
        max-width: none;
    }

    .char-info h1.char-name {
        font-size: 1.8rem;
    }

    .stat-label {
        width: 80px;
        font-size: 0.8rem;
    }

    .char-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}

.stat-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
}

.stat-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
}

/* UTILS */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 40px;
    border: 2px solid var(--accent-gold);
    border-radius: 8px;
    text-align: center;
}

.flip-trigger {
    margin-top: 30px;
    text-align: center;
    cursor: pointer;
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
    padding: 10px;
    transition: 0.3s;
}

.flip-trigger:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

/* PICTURE PAGE */
.picture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.film-card {
    background: #000;
    padding: 15px 10px 40px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.film-image {
    width: 100%;
    aspect-ratio: 1;
    background-size: cover;
    border: 2px solid #222;
}

/* CALENDAR PAGE STYLES */
.calendar-container {
    width: 95%;
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    background: var(--border-color);
    padding: 8px;
    border-radius: 8px;
    margin-top: 20px;
}

.cal-header {
    text-align: center;
    padding: 10px;
    background: var(--bg-secondary);
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 0.9rem;
    border-radius: 4px;
}

.cal-day {
    background: var(--bg-color);
    min-height: 120px;
    padding: 10px;
    border-radius: 4px;
    position: relative;
    transition: background 0.3s;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cal-day:hover {
    background: #242220;
}

.cal-date-num {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 5px;
}

.cal-entry {
    display: block;
    background: rgba(203, 160, 82, 0.1);
    border-left: 3px solid var(--accent-gold);
    padding: 6px 8px;
    font-size: 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: none;
    border-radius: 2px;
    transition: background 0.2s;
    line-height: 1.4;
}

.cal-entry:hover {
    background: rgba(203, 160, 82, 0.2);
}

.cal-entry .cal-tags {
    display: block;
    color: var(--accent-gold);
    font-size: 0.7rem;
    margin-top: 2px;
}

/* Image Modal (Calendar Specific) */
#img-modal.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

#img-modal.hidden {
    display: none !important;
}

.image-modal-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 80vh;
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

@media (max-width: 900px) {
    .home-container {
        flex-direction: column;
        height: auto;
    }

    .split-section {
        height: 50vh;
    }

    .char-layout {
        grid-template-columns: 1fr;
    }

    .char-visuals {
        grid-template-columns: 1fr 100px;
    }

    .calendar-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
        padding: 4px;
    }

    .cal-day {
        min-height: 60px;
        padding: 5px;
    }
}

/* NOVEL (PRIVATTER-STYLE) UI */
.novel-page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.novel-book-ui {
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    min-height: 80vh;
}

.novel-cover-area {
    width: 300px;
    background: #000;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--border-color);
}

.novel-cover-preview {
    width: 200px;
    aspect-ratio: 1 / 1.4;
    background-color: #222;
    background-size: cover;
    background-position: center;
    border: 1px solid #444;
    margin-bottom: 20px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.novel-main-area {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.naro-input,
.naro-textarea {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 4px;
    font-family: inherit;
    margin-bottom: 20px;
}

.naro-textarea.main-body {
    min-height: 400px;
}

.editor-field label {
    display: block;
    color: var(--accent-gold);
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
}

.formatting-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 4px;
}

.novel-controls {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
}

/* Viewer Styles */
.novel-content {
    background: #fdfdfd;
    /* Paper-like color */
    color: #333;
    padding: 60px;
    min-height: 100%;
    border-radius: 4px;
    line-height: 1.8;
}

.novel-content.vertical {
    writing-mode: vertical-rl;
    height: 600px;
    overflow-x: auto;
    overflow-y: hidden;
}

.novel-text-section {
    margin-bottom: 40px;
}

.novel-text-section.summary {
    font-style: italic;
    color: #666;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.novel-tags-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 30px;
}

.tag-pill {
    background: rgba(203, 160, 82, 0.1);
    color: var(--accent-gold);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    border: 1px solid rgba(203, 160, 82, 0.2);
}

.restriction-notice {
    color: var(--accent-red);
    font-weight: bold;
}

/* LIBRARY (BOOKSHELF) STYLES */
.library-page {
    background-color: #3e2723;
    /* Dark earthy brown */
    background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    /* Mock wood texture */
}

.library-container {
    flex: 1;
    padding: 40px 20px;
}

.bookshelf-wrapper {
    max-width: 1200px;
    margin: 0 auto;
}

.library-title {
    font-family: var(--font-accent);
    color: var(--accent-gold);
    text-align: center;
    font-size: 3rem;
    margin-bottom: 40px;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.bookshelf {
    display: flex;
    flex-direction: column;
    gap: 100px;
    margin-top: 200px;
    padding-bottom: 50px;
}

.shelf {
    background: var(--wood-shelf);
    height: 25px;
    border-radius: 5px;
    position: relative;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 40px;
    margin-bottom: 220px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    width: 95%;
}

.shelf::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.2);
    transform: skewX(-45deg);
    transform-origin: bottom left;
}

.book-item {
    width: 60px;
    height: 220px;
    background: var(--accent-gold);
    border-radius: 2px 5px 5px 2px;
    position: relative;
    bottom: 25px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -5px 0 10px rgba(0, 0, 0, 0.5);
    border-left: 3px solid rgba(0, 0, 0, 0.2);
    margin: 0 8px;
    /* Slightly wider spacing for better balance */
    flex-shrink: 0;
}

.book-item:hover {
    transform: translateY(-20px) rotate(-5deg);
    z-index: 10;
}

.book-item.placeholder {
    cursor: default;
    background: #3e2723 !important;
    border-color: #4e342e !important;
    opacity: 0.6;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.3);
}

.book-item.placeholder:hover {
    transform: none;
}

.book-spine {
    writing-mode: vertical-rl;
    color: #1a1917;
    font-weight: bold;
    font-size: 0.8rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    /* Opacity set to 20% (80% transparent) */
    width: 65%;
    /* Label width ratio to spine */
    height: 80%;
    /* Label height ratio to spine */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    padding: 10px 0;
}

.book-item.placeholder .book-spine {
    background: none;
    box-shadow: none;
}

/* Book Preview Tooltip */
.book-preview {
    position: absolute;
    top: 100%;
    margin-top: 25px;
    left: 0;
    width: 250px;
    background: #fff;
    color: #333;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 100;
}

.book-item:hover .book-preview {
    opacity: 1;
    transform: translateY(10px);
}

.preview-cover {
    width: 100%;
    height: 150px;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    margin-bottom: 10px;
}

.preview-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.preview-summary {
    font-size: 0.85rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    display: -webkit-box;
    overflow: hidden;
}

/* Lantern Animation */
.lantern-container {
    position: relative;
    width: 40px;
    height: 40px;
}

.lantern {
    width: 24px;
    height: 32px;
    background: var(--accent-gold);
    border-radius: 5px;
    position: relative;
    animation: sway 3s ease-in-out infinite alternate;
}

.lantern::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 15px;
    background: #fff;
    box-shadow: 0 0 20px 10px var(--lantern-glow);
    border-radius: 50%;
}

@keyframes sway {
    0% {
        transform: rotate(-5deg);
    }

    100% {
        transform: rotate(5deg);
    }
}

.wood-header {
    background: #4e342e;
    border-bottom: 4px solid #3e2723;
}

.wood-footer {
    background: #3e2723;
    color: var(--accent-gold);
    padding: 40px;
    text-align: center;
}

/* Mobile Search Elements - Hidden on Desktop by default */
#mobile-search-toggle,
#mobile-search-close {
    display: none;
}

/* --- MOBILE HEADER OPTIMIZATION --- */
@media (max-width: 768px) {
    header {
        padding: 10px 15px;
        height: 60px;
        position: relative;
    }

    .logo {
        font-size: 1.2rem;
        gap: 10px;
    }

    /* Hide default Search Input */
    .search-wrapper input {
        display: none;
    }

    .search-wrapper.mobile-active input {
        display: block;
        width: 100%;
        border-radius: 4px;
        /* Reset radius for bar */
    }

    /* Mobile Search Toggle Button (Magnifying Glass) */
    #mobile-search-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--accent-gold);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 5px;
    }

    /* Expanded Search State - Overlay */
    .search-wrapper {
        position: static;
        /* Default static to allow flex flow */
        margin: 0;
    }

    .search-wrapper.mobile-active {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(26, 25, 23, 0.98);
        padding: 10px;
        z-index: 200;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    /* Close Button for Search */
    #mobile-search-close {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 1.5rem;
        /* Icon size */
        cursor: pointer;
        display: none;
    }

    .search-wrapper.mobile-active #mobile-search-close {
        display: block;
    }

    .search-wrapper.mobile-active #mobile-search-toggle {
        display: none;
    }

    /* Ensure Nav buttons don't overlap when search is active */
    .nav-links {
        gap: 10px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    /* --- MOBILE NOVEL PAGE OPTIMIZATION --- */

    /* Reset Library Title Position */
    .simple-library-title {
        margin-left: 0 !important;
    }

    /* Bookshelf Scroll & Alignment */
    /* Bookshelf Scroll & Alignment REMOVED/STATIC for Mobile */

    /* Reduce Vertical Gap */
    .bookshelf {
        margin-top: 30px !important;
        gap: 20px !important;
        /* Reduce internal gap if needed */
    }

    .shelf {
        justify-content: center;
        /* Center items in the static grid */
        overflow: visible !important;
        /* Allow page scroll to handle content */
        /* Disable specific axises if needed, but visible is safest for flow */

        flex-wrap: wrap;
        /* Wrap items */
        padding: 20px 10px;
        height: auto !important;
        /* Auto height */
        background: none;
        /* Remove wood texture */
        align-items: flex-start;
        /* Align to top */
        gap: 20px;
        /* Space between books */
    }

    /* Disable Book Animations & Fixed Position */
    .book-item,
    .dummy-book {
        transform: none !important;
        transition: none !important;
        margin-bottom: 20px !important;
        /* Spacing for folded rows */
        /* Ensure no hover effects */
        pointer-events: auto;

        /* Stabilization Fixes */
        width: 60px !important;
        /* Override JS random width */
        height: 220px !important;
        /* Override JS random height */
        touch-action: pan-y;
        /* Disable horizontal swipe/drag interactions */
        user-select: none;
        /* Prevent selection */
        -webkit-user-select: none;
    }

    .book-item:active,
    .dummy-book:active {
        transform: none !important;
        /* Prevent click-down movement */
    }

    /* Fix for dummy book color on tap/hover - Restore original style */
    .book-item.placeholder:hover,
    .book-item.placeholder:active,
    .dummy-book:hover,
    .dummy-book:active {
        background: #3e2723 !important;
        /* Restore brown */
        box-shadow: -2px 0px 5px 0px rgba(0, 0, 0, 0.3) !important;
        /* Restore shadow */
        opacity: 0.6 !important;
        /* Keep original opacity */
    }

    /* Hide Preview Tooltip on Mobile (The "area like thing") */
    .book-preview {
        display: none !important;
    }

    .book-item:hover,
    .dummy-book:hover {
        transform: none !important;
        /* Prevent highlight if any */
        z-index: 1 !important;
        /* Prevent popping up */
    }

    /* Disable Spine Labels for Placeholders on Mobile (Reverted as requested) */
    .book-item.placeholder .book-spine {
        background: none !important;
        box-shadow: none !important;
    }
}

/* --- EDITOR PREVIEW & TOOLS --- */
.editor-preview-box {
    position: absolute;
    top: 20px;
    right: 40px;
    /* Increased margin to accommodate scaling */
    width: 300px;
    /* Internal resolution/width remains same */
    transform: scale(1.6);
    transform-origin: top right;
    height: 400px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 50;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    color: #333;
}

.preview-header {
    background: #eee;
    padding: 5px 10px;
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: bold;
    color: #333;
}

.preview-header button {
    font-size: 0.7rem;
    padding: 2px 8px;
    height: auto;
    line-height: 1.2;
    background: transparent;
    border: 1px solid #888;
    color: #555;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-header button:hover {
    background: #555;
    color: white;
    border-color: #555;
}

#editor-realtime-preview {
    flex: 1;
    overflow: auto;
    padding: 15px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    line-height: 1.8;
}

#editor-realtime-preview.vertical {
    writing-mode: vertical-rl;
}

#editor-realtime-preview.horizontal {
    writing-mode: horizontal-tb;
}

/* Cover Editing Overlay */
.cover-edit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.cover-edit-area {
    width: 300px;
    height: 400px;
    border: 2px solid white;
    background-color: #333;
    background-repeat: no-repeat;
    cursor: move;
    position: relative;
    overflow: hidden;
}

.cover-edit-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

/* Added for Layout Adjustment */
.novel-cover-area {
    display: flex;
    justify-content: space-evenly;
    /* Even spacing for button-less layout */
    gap: 0;
    margin-bottom: 20px;
    margin-top: 20px;
    /* Matched to preview box top offset */
    margin-left: 40px;
    /* Matched to preview right margin */
    /* Height Alignment */
    height: 690px;
    /* Matched to visual overflow of text preview */
    flex-direction: column;
    padding: 0;
    box-sizing: border-box;
}

.novel-cover-preview {
    width: 200px;
    height: 280px;
    /* Restored to original size */
    border: 1px solid #555;
    background-color: #222;
    background-size: cover;
    background-position: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    /* For icon containment */
}

.novel-cover-preview:hover {
    border-color: var(--accent-gold);
}

.cover-edit-icon {
    position: absolute;
    top: 10px;
    left: 10px;
    color: rgba(255, 255, 255, 0.7);
    width: 24px;
    height: 24px;
    pointer-events: none;
    /* Let clicks pass to the parent */
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
    transition: all 0.2s;
}

.novel-cover-area.viewer-cover {
    justify-content: flex-start;
    /* Start from top */
    gap: 0px !important;
    height: auto;
    /* Fit content */
    padding-top: 60px;
    /* Space for back link */
    padding-bottom: 40px;
    /* Bottom balance */
}

/* Edit Icon on Cover */
.novel-cover-preview:hover .cover-edit-icon {
    color: white;
    transform: scale(1.1);
}

/* --- CALENDAR GLOBAL FIXES (Desktop & Mobile Base) --- */
.calendar-cell {
    overflow: hidden;
    /* Prevent cell expansion */
}

.event-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
    /* Ensure it respects width */
}

/* Home Icon Visibility (Desktop: Hide) */
.btn .home-icon {
    display: none;
}

/* Mobile Devices (Max-width: 768px) */
@media (max-width: 768px) {

    /* Restore Home Icon on Mobile */
    .btn .home-icon {
        display: inline-block;
    }

    .library-page,
    .split-section,
    .shelf {
        background-attachment: scroll !important;
        background-position: center !important;
    }

    .book-item {
        /* Ensure books don't float away */
        transform: none !important;
        bottom: 0 !important;
        /* Reset relative float if causing issues */
        margin-bottom: 25px;
        /* Replace bottom offset with margin */
    }

    /* CALENDAR MOBILE FIX */
    .calendar-cell {
        min-height: 80px !important;
    }

    .cell-content {
        display: flex;
        flex-wrap: wrap;
        gap: 2px;
        justify-content: flex-end;
        /* Align icons to corner or center? Let's pile them. */
    }

    .event-item {
        font-size: 0 !important;
        /* Hide text */
        width: 16px;
        height: 16px;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        color: var(--accent-gold) !important;
        display: inline-flex !important;
        justify-content: center;
        align-items: center;
        border: 1px solid var(--accent-gold);
        border-radius: 50%;
        overflow: hidden;
    }

    .event-item::before {
        content: '✔';
        /* Checkmark */
        font-size: 10px;
        line-height: 1;
        display: block;
    }

    /* Hide internal icons/images on mobile events to keep it small */
    .event-item i,
    .event-item img,
    .event-item svg {
        display: none !important;
    }
}

/* Hide Scrollbar on Mobile */
@media (max-width: 768px) {

    /* Chrome, Safari, Opera */
    body::-webkit-scrollbar,
    .home-container::-webkit-scrollbar,
    .split-section::-webkit-scrollbar,
    .shelf::-webkit-scrollbar,
    .novel-container::-webkit-scrollbar,
    *::-webkit-scrollbar {
        display: none;
    }

    /* IE, Edge, Firefox */
    body,
    .home-container,
    .split-section,
    .shelf,
    .novel-container,
    * {
        -ms-overflow-style: none;
        /* IE and Edge */
        scrollbar-width: none;
        /* Firefox */
    }
}

/* Mobile Search Icon Centering */
/* Mobile Header Adjustments */
@media (max-width: 768px) {
    header {
        position: sticky;
        top: 0;
    }

    /* --- 1. Nav Buttons Layout (Search, Home, Login) --- */
    .nav-links {
        display: flex;
        gap: 8px;
        /* Space between buttons */
        align-items: center;
    }

    .nav-links .btn {
        padding: 0 !important;
        width: 44px !important;
        height: 44px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        min-width: 0 !important;
    }

    /* --- 2. Hide Text on Home & Login --- */
    .nav-links .btn span,
    .nav-links .btn .nav-text {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        opacity: 0 !important;
    }

    /* --- 3. Icon Sizing --- */
    .home-icon {
        display: block !important;
        width: 20px !important;
        height: 20px !important;
    }

    #login-btn svg {
        width: 20px !important;
        height: 20px !important;
        margin: 0 !important;
        display: block !important;
    }

    /* --- 4. Mobile Search Button --- */
    .mobile-search-btn {
        display: flex !important;
        /* Show on mobile */
        /* Inherits .btn styles above */
    }

    .mobile-search-btn svg {
        width: 20px !important;
        height: 20px !important;
    }

    /* --- 5. Search Wrapper (Toggleable) --- */
    .search-wrapper {
        display: none;
        /* Hidden by default */
        position: absolute;
        top: 100%;
        /* Below header */
        left: 0;
        width: 100%;
        background: rgba(26, 25, 23, 0.95);
        /* Match header bg */
        padding: 10px 20px;
        z-index: 98;
        border-bottom: 1px solid var(--border-color);
    }

    .search-wrapper.active {
        display: block !important;
    }

    /* Ensure input inside is visible */
    .search-wrapper.active input,
    .search-wrapper.active #tag-search {
        display: block !important;
        width: 100% !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Remove old absolute positioning if it exists */
    #mobile-search-toggle {
        position: static !important;
        transform: none !important;
        margin: 0 !important;
    }

    /* --- 6. Mobile Button Colors (Requested: White -> Gold on Press) --- */
    .nav-links .btn,
    .mobile-search-btn {
        color: #ffffff !important;
        border-color: #ffffff !important;
        background: transparent !important;
        /* Ensure no conflicting bg */
    }

    /* Target Icons specifically */
    .nav-links .btn svg,
    .mobile-search-btn svg,
    .home-icon {
        stroke: #ffffff !important;
        color: #ffffff !important;
    }

    /* Active State (Gold) */
    .nav-links .btn:active,
    .mobile-search-btn:active {
        color: var(--accent-gold) !important;
        border-color: var(--accent-gold) !important;
        transform: scale(0.95);
        /* Optional: slight press effect */
    }

    .nav-links .btn:active svg,
    .mobile-search-btn:active svg,
    .nav-links .btn:active .home-icon {
        stroke: var(--accent-gold) !important;
        color: var(--accent-gold) !important;
    }
}

/* Unified Login Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    background: #1a1917;
    border: 1px solid var(--accent-gold);
    padding: 40px 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
    text-align: center;
}

.modal-x-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: rgba(40, 30, 20, 0.9);
    border: 1.68539px solid var(--accent-gold);
    border-radius: 50%;
    color: var(--accent-gold);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

.modal-x-close:hover {
    background: var(--accent-gold);
    color: rgb(26, 26, 26);
    transform: rotate(90deg);
}

/* --- Edit Markers & Scrollbars (Ported) --- */
.img-edit-marker {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--accent-gold);
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--accent-gold);
    cursor: pointer;
    z-index: 10;
    opacity: 0.8;
    transition: 0.3s;
}

.img-edit-marker:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--accent-brown);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}