:root {
    --bg-color: #f4f1ea;
    --wood-color: #5c4033;
    --wood-dark: #3e2723;
    --wood-light: #8d6e63;
    --text-color: #333;
    --font-elegant: 'Shippori Mincho', serif;
    --font-gothic: 'Kiwi Maru', serif;
}

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

/* Window Log Cabin Background */
body {
    font-family: var(--font-elegant);
    background-color: #8B5A2B;
    background-image: url('window_bg.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-color);
    overflow-x: hidden;
    transition: background-image 0.5s ease-in-out;
}

/* Deformed Decorations Image */
.decorations-image {
    position: absolute;
    top: -50px;
    right: 0;
    width: 450px;
    height: 350px;
    background-image: url('cute_decor.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: top right;
    pointer-events: none;
    z-index: 5;
    mix-blend-mode: multiply;
    opacity: 0.95;
}

/* UI Elements */
.btn {
    background-color: var(--wood-color);
    color: #fff;
    border: none;
    padding: 10px 20px;
    font-size: 1.1rem;
    font-family: var(--font-elegant);
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    position: relative;
    z-index: 10;
}

.btn:hover {
    background-color: var(--wood-light);
    transform: translateY(-2px);
}

.hidden {
    display: none !important;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
}

/* Start Screen */
.start-content {
    text-align: center;
    animation: fadeIn 2s ease;
}

.start-content h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    font-weight: normal;
    letter-spacing: 5px;
}

.start-content p {
    font-size: 1.2rem;
    margin-bottom: 40px;
    opacity: 0.8;
}

/* Main Layout */
header {
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 10;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 30px;
}

.search-sort {
    display: flex;
    gap: 10px;
}

.search-bar, .sort-select {
    padding: 8px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(25, 15, 10, 0.7);
    color: #f4f1ea;
    font-family: var(--font-elegant);
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
    transition: border-color 0.3s;
}

.search-bar:focus, .sort-select:focus {
    border-color: #d4af37;
}

.site-title {
    color: #fff;
    font-size: 2.5rem;
    letter-spacing: 5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    margin: 0;
}

/* Gorgeous Multi-shelf Bookshelf Wrapper */
.bookshelf-wrapper {
    width: 85%;
    max-width: 1000px;
    margin: 40px auto;
    background-color: #3b2f2f; /* Dark wood back panel */
    background-image: 
        linear-gradient(90deg, rgba(0,0,0,0.3) 0px, transparent 2px, transparent 100px, rgba(0,0,0,0.3) 102px), /* Wood slats */
        linear-gradient(rgba(0,0,0,0.4) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.4) 100%),
        url('data:image/svg+xml,%3Csvg width="100" height="100" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="w"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.01" numOctaves="3" /%3E%3CfeColorMatrix type="saturate" values="0.1" /%3E%3C/filter%3E%3Crect width="100" height="100" filter="url(%23w)" opacity="0.1" /%3E%3C/svg%3E');
    background-size: 100px 100%, 100% 100%, 100% 100%;
    border-left: 45px solid #2e1a1a;
    border-right: 45px solid #2e1a1a;
    border-top: 60px solid #2e1a1a;
    border-bottom: 80px solid #2e1a1a;
    padding: 0;
    box-shadow: 
        inset 0 0 80px rgba(0,0,0,0.9),
        25px 25px 50px rgba(0,0,0,0.8),
        inset -5px 0 10px rgba(255,255,255,0.05),
        inset 5px 0 10px rgba(255,255,255,0.05);
    position: relative;
    z-index: 10;
}

/* Side Panel Highlights */
.bookshelf-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -45px;
    width: 10px;
    background: rgba(255,255,255,0.05);
    z-index: 11;
}


/* Crown decoration */
.bookshelf-wrapper::before {
    content: 'じゃれ書庫';
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: #d4af37;
    font-family: var(--font-elegant);
    font-size: 1.8rem;
    letter-spacing: 12px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8), 0 0 10px rgba(212,175,55,0.4);
    opacity: 0.9;
}

.bookshelf-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: flex-start;
    min-height: 280px;
    gap: 0;
    padding: 0 40px;
    margin-bottom: 0; /* No margin, use board for spacing */
    position: relative;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 15%, transparent 85%, rgba(0,0,0,0.5) 100%);
    padding-bottom: 60px; /* Space for the shelf board */
}

/* Bookshelf Wrapper should grow with content */
.bookshelf-wrapper {
    min-height: 600px;
    height: auto;
    overflow: visible;
}

/* The actual shelf board (top surface where books sit) */
.bookshelf-row::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #4a2c14; /* Deep wood */
    background-image: linear-gradient(to bottom, #5c3d1e 0%, #2e1809 100%);
    transform: perspective(1000px) rotateX(45deg);
    transform-origin: bottom;
    z-index: 1;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* The front edge of the shelf board */
.bookshelf-row::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: -45px;
    right: -45px;
    height: 40px;
    background: #2e1a1a;
    background-image: linear-gradient(180deg, #3d2b1f 0%, #1a0f0f 100%);
    z-index: 5;
    box-shadow: 
        0 10px 20px rgba(0,0,0,0.6),
        inset 0 1px 3px rgba(255,255,255,0.2);
    border-bottom: 2px solid #d4af37; /* Gold accent on shelf edge */
}

/* Books on Shelf */
.book-spine {
    width: 55px;
    height: 250px;
    margin: 0 10px;
    border-radius: 3px 6px 6px 3px;
    box-shadow: 
        inset 3px 0 8px rgba(255,255,255,0.15),
        inset -4px 0 10px rgba(0,0,0,0.4),
        4px 0 12px rgba(0,0,0,0.7),
        0 5px 10px rgba(0,0,0,0.5); /* Base shadow */
    cursor: pointer;
    position: relative;
    z-index: 10;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    border-left: 3px solid rgba(255,255,255,0.25);
    border-right: 2px solid rgba(0,0,0,0.3);
}

.book-spine:hover {
    transform: translateY(-25px) scale(1.08) rotateY(-5deg);
    z-index: 50;
    box-shadow: 
        0 25px 40px rgba(0,0,0,0.8),
        inset 3px 0 8px rgba(255,255,255,0.2);
}

/* Patterns */
.book-spine.pattern-leather {
    background-image: radial-gradient(circle at 50% 50%, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.4) 100%), url('data:image/svg+xml,%3Csvg width="10" height="10" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="n"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="1.5" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="10" height="10" filter="url(%23n)" opacity="0.3"/%3E%3C/svg%3E');
}
.book-spine.pattern-fabric {
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.1) 0px, rgba(255,255,255,0.1) 2px, transparent 2px, transparent 4px), repeating-linear-gradient(-45deg, rgba(0,0,0,0.1) 0px, rgba(0,0,0,0.1) 2px, transparent 2px, transparent 4px);
}
.book-spine.pattern-antique {
    background-image: linear-gradient(0deg, rgba(0,0,0,0.3) 0%, transparent 20%, transparent 80%, rgba(0,0,0,0.3) 100%), repeating-linear-gradient(to right, transparent, transparent 10px, rgba(212, 175, 55, 0.3) 10px, rgba(212, 175, 55, 0.3) 12px);
}

.book-spine::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 4px;
    right: 4px;
    height: 10px;
    background: linear-gradient(to right, #b8860b, #ffd700, #daa520, #ffd700, #b8860b);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    z-index: 1;
    border-radius: 1px;
}

.book-spine::after {
    content: '';
    position: absolute;
    bottom: 20px;
    left: 4px;
    right: 4px;
    height: 10px;
    background: linear-gradient(to right, #b8860b, #ffd700, #daa520, #ffd700, #b8860b);
    box-shadow: 0 -1px 3px rgba(0,0,0,0.5);
    z-index: 1;
    border-radius: 1px;
}



/* Bookmark Ribbon */
.bookmark-ribbon {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 15px;
    height: 30px;
    background-color: #8c2020;
    z-index: 0;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}
.bookmark-ribbon::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    border-width: 5px 7.5px;
    border-style: solid;
    border-color: #8c2020 #8c2020 transparent #8c2020;
}

/* Tooltip (Speech Bubble) */
.book-spine-tooltip {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(40, 30, 20, 0.95);
    color: #f4f1ea;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: var(--font-elegant);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 5px 15px rgba(0,0,0,0.6);
    z-index: 100;
    pointer-events: none;
    border: 1px solid #d4af37;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
}
.book-spine-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: rgba(40, 30, 20, 0.95) transparent transparent transparent;
}
.book-spine:hover .book-spine-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.spine-text {
    writing-mode: vertical-rl;
    text-orientation: upright;
    color: #fff;
    font-size: 1.2rem;
    padding: 45px 5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    pointer-events: none;
    max-height: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 2;
}

/* Shelf Decorative Items */
.cute-item-vase, .cute-item-vase-2, .cute-item-vase-3,
.cute-item-frame, .cute-item-frame-2, .cute-item-frame-3 {
    width: 80px;
    height: 110px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    margin: 0 10px;
    flex-shrink: 0;
    align-self: flex-end;
    cursor: grab;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s;
    filter: drop-shadow(0 8px 8px rgba(0,0,0,0.7)); /* Realistic shadow on shelf */
    z-index: 12;
}

.cute-item-vase:hover, .cute-item-frame:hover {
    transform: translateY(-8px) scale(1.05);
    filter: drop-shadow(0 15px 12px rgba(0,0,0,0.6));
}

.cute-item-vase:active, .cute-item-frame:active { cursor: grabbing; }

.cute-item-vase { background-image: url('flower_vase.png'); }
.cute-item-vase-2 { background-image: url('flower_vase_2.png'); }
.cute-item-vase-3 { background-image: url('flower_vase_3.png'); }

.cute-item-frame { background-image: url('picture_frame.png'); width: 100px; }
.cute-item-frame-2 { background-image: url('picture_frame_2.png'); width: 100px; }
.cute-item-frame-3 { background-image: url('picture_frame_3.png'); width: 100px; }

/* Drag & Drop Visuals */
.dragging {
    opacity: 0.5;
    transform: scale(0.9);
    filter: grayscale(0.5);
}

.drag-over {
    border-left: 4px solid #d4af37 !important;
    padding-left: 4px !important;
}

/* Modal Shared */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.2rem;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    transition: color 0.3s;
    z-index: 3000;
}

/* Close button inside light modal-content needs dark color */
.modal-content .close-btn {
    color: #5c4033;
    font-size: 2rem;
}

.modal-content .close-btn:hover {
    color: #000;
}

#ctx-remove-bookmark-btn i {
    color: #8B0000;
}
.modal-content {
    background-color: var(--bg-color);
    padding: 40px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--wood-dark);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--wood-dark);
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-family: var(--font-elegant);
    font-size: 1rem;
    background-color: rgba(255,255,255,0.8);
}

/* File Upload Styles */
.file-upload-group input[type="file"] {
    display: none;
}
.file-label {
    display: inline-block;
    background-color: #6d4c41;
    color: #fff !important;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    margin-bottom: 10px !important;
}
.file-label:hover {
    background-color: #8d6e63;
}

.color-picker, .pattern-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-picker input[type="radio"], .pattern-picker input[type="radio"] {
    display: none;
}

.color-picker label {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.pattern-picker label {
    padding: 5px 10px;
    border: 2px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: #fff;
}

.color-picker input[type="radio"]:checked + label {
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--wood-dark);
    transform: scale(1.2);
}

.pattern-picker input[type="radio"]:checked + label {
    border-color: var(--wood-dark);
    background-color: #eaeaea;
}

/* 3D Book Reading Modal */
.perspective-container {
    perspective: 1500px;
}

.book-3d {
    width: 90vw;
    max-width: 800px;
    height: 80vh;
    max-height: 600px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.book-3d.closed {
    /* Start visually centered, slightly shrunk, with a hint of 3D tilt */
    transform: rotateY(-5deg) scale(0.85);
    filter: drop-shadow(20px 20px 30px rgba(0,0,0,0.8));
}

.book-3d.open {
    transform: rotateY(0deg) scale(1) translateZ(50px);
    filter: drop-shadow(40px 40px 60px rgba(0,0,0,0.8));
}

.book-cover {
    position: absolute;
    width: 50%;
    height: 100%;
    left: 0;
    top: 0;
    transform-origin: left center;
    transition: transform 1.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    background-color: #8B0000;
    box-shadow: inset -10px 0 30px rgba(0,0,0,0.6), 10px 10px 30px rgba(0,0,0,0.5);
    border-radius: 5px 12px 12px 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 15;
    backface-visibility: hidden;
    overflow: hidden;
}

.book-cover::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 3px solid rgba(212,175,55,0.8); /* Thicker gold border */
    border-radius: 4px;
    z-index: 1;
    pointer-events: none;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
}

/* Inner double border and corner accents */
.book-cover::after {
    content: '';
    position: absolute;
    inset: 16px;
    border: 1px solid rgba(212,175,55,0.5);
    border-radius: 2px;
    z-index: 1;
    pointer-events: none;
}

.book-cover-inner::before, .book-cover-inner::after {
    content: '✧';
    position: absolute;
    color: #d4af37;
    font-size: 1.2rem;
    z-index: 3;
}
.book-cover-inner::before { top: 10px; left: 10px; }
.book-cover-inner::after { top: 10px; right: 10px; }


.book-3d.open .book-cover {
    transform: rotateY(-180deg);
    box-shadow: inset 5px 0 20px rgba(0,0,0,0.5), -10px 10px 20px rgba(0,0,0,0.3);
}

.book-cover-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 2;
    padding: 20px;
    width: 100%;
    height: 100%;
}

.book-cover-ornament {
    color: rgba(212,175,55,0.9);
    font-size: 1.6rem;
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(212,175,55,0.5);
}

.book-cover-ornament-bottom {
    transform: rotate(180deg);
}

.book-cover h1 {
    color: rgba(255,255,255,0.95);
    writing-mode: vertical-rl;
    font-size: 2rem;
    letter-spacing: 6px;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.9), 0 0 15px rgba(0,0,0,0.5);
    z-index: 2;
    font-weight: normal;
    max-height: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Book Inner Pages (Pagination) */
.book-pages {
    position: absolute;
    width: 100%;
    height: 96%;
    top: 2%;
    left: 0;
    background-color: #fcfbfa; /* Elegant warm paper */
    box-shadow: inset 0 0 40px rgba(139, 69, 19, 0.08), 0 0 20px rgba(0,0,0,0.5);
    border-radius: 5px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    padding: 2% 4%;
    background-image: 
        linear-gradient(to right, transparent 48%, rgba(0,0,0,0.15) 50%, transparent 52%), /* Central spine shadow */
        linear-gradient(to right, rgba(0,0,0,0.02) 0%, transparent 5%, transparent 95%, rgba(0,0,0,0.02) 100%),
        url('data:image/svg+xml,%3Csvg width="100" height="100" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noise"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100" height="100" filter="url(%23noise)" opacity="0.04"/%3E%3C/svg%3E');
}

.book-3d.closed .book-pages {
    opacity: 0;
    transform: rotateY(10deg);
    pointer-events: none;
}

.book-3d.open .book-pages {
    opacity: 1;
    transform: rotateY(0deg);
    transition: opacity 0.3s 1.0s, transform 1.5s 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.book-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px dashed #ccc;
    padding-bottom: 10px;
    margin-bottom: 20px;
    height: 40px;
}

.book-header h2 {
    font-size: 1.5rem;
    color: #4a4a4a;
    letter-spacing: 2px;
    text-align: center;
    flex-grow: 1;
}

.font-controls {
    display: flex;
    gap: 5px;
}

.page-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #666;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s;
    padding: 5px 10px;
}
.page-btn:hover {
    color: #000;
}
.page-btn:disabled {
    color: #ccc;
    cursor: not-allowed;
}

.book-viewport {
    width: 100%;
    height: calc(100% - 60px);
    overflow: hidden; /* Hide scrollbars, scrolled via JS */
    position: relative;
    scroll-behavior: smooth;
}

.book-text.vertical-text {
    height: 100%;
    writing-mode: vertical-rl;
    text-orientation: upright;
    column-width: calc((100% - 100px) / 2); 
    column-gap: 100px;
    column-fill: auto;
    line-height: 2.2;
    font-size: 1.05rem;
    color: #2c2c2c;
    padding: 20px 0;
    box-sizing: border-box;
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    position: absolute;
    right: 0;
    transform-origin: right top; /* Ensure it scales/moves relative to right */
}

.font-gothic {
    font-family: var(--font-gothic) !important;
}

.book-text p {
    margin-bottom: 1em;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: rgba(40, 30, 20, 0.95);
    border: 1px solid #d4af37;
    border-radius: 5px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.6);
    z-index: 5000;
    padding: 5px 0;
    min-width: 120px;
    font-family: var(--font-elegant);
}
.context-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #f4f1ea;
    padding: 10px 20px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}
.context-menu button:hover {
    background: rgba(212, 175, 55, 0.3);
}

/* Dark Mode Global Styles */
body.dark-theme {
    background-image: url('window_bg_dark.png');
}
body.dark-theme .book-pages {
    background-color: #2b2b2b;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.02) 49%, rgba(0,0,0,0.3) 50%, rgba(255,255,255,0.02) 51%),
        url('data:image/svg+xml,%3Csvg width="100" height="100" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noise"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100" height="100" filter="url(%23noise)" opacity="0.02"/%3E%3C/svg%3E');
    box-shadow: inset 0 0 40px rgba(0,0,0,0.5), 0 0 20px rgba(0,0,0,0.8);
    border: 1px solid #444;
}
body.dark-theme .book-text.vertical-text,
body.dark-theme .book-header h2 {
    color: #dcdcdc;
}
body.dark-theme .page-btn {
    color: #aaa;
}
body.dark-theme .page-btn:hover {
    color: #fff;
}
body.dark-theme .book-header {
    border-bottom: 2px dashed #555;
}

/* Dark Mode: darken the bookshelf */
body.dark-theme .bookshelf-wrapper {
    background-color: #7A5D42;
    box-shadow:
        inset 0 0 80px rgba(0,0,0,0.7),
        inset 0 0 30px rgba(0,0,0,0.5),
        18px 18px 50px rgba(0,0,0,0.95),
        0 0 0 6px #7a6030,
        0 0 0 10px #1a0e05;
}
body.dark-theme .bookshelf-row {
    background: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.4) 100%);
}

/* Download Modal */
.download-content {
    max-width: 600px;
}
.download-hint {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.95rem;
}
.download-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
.btn-outline {
    padding: 7px 14px;
    border: 2px solid var(--wood-color);
    background: transparent;
    color: var(--wood-dark);
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-elegant);
    font-size: 0.95rem;
    transition: all 0.2s;
}
.btn-outline:hover {
    background: var(--wood-color);
    color: #fff;
}
.download-book-list {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 5px;
}
.download-book-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}
.download-book-item:hover {
    background: #f0e8d8;
}
.download-book-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--wood-color);
    cursor: pointer;
    flex-shrink: 0;
}
.download-book-item label {
    cursor: pointer;
    flex-grow: 1;
    font-size: 1rem;
}
.download-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.2);
}

/* --- Stylish Delete & Conflict Modal Styles --- */
#delete-modal .modal-content, #import-conflict-modal .modal-content {
    background-image: 
        linear-gradient(rgba(244, 241, 234, 0.9), rgba(244, 241, 234, 0.9)),
        url('https://www.transparenttextures.com/patterns/old-map.png'); /* Antique paper texture */
    border: 3px double var(--wood-color);
    box-shadow: 0 0 40px rgba(0,0,0,0.8), inset 0 0 20px rgba(92, 64, 51, 0.2);
    max-width: 700px;
}

#delete-book-list, #conflict-book-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px;
    background: rgba(0,0,0,0.03);
    border: 1px inset rgba(0,0,0,0.1);
    border-radius: 10px;
    max-height: 50vh;
}

.delete-book-card, .conflict-book-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.delete-book-card:hover, .conflict-book-card:hover {
    transform: translateY(-3px);
    box-shadow: 4px 4px 10px rgba(0,0,0,0.15);
    border-color: var(--wood-light);
}

.delete-book-card.selected, .conflict-book-card.selected {
    background: #fff9e6;
    border-color: #d4af37;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.delete-book-card input[type="checkbox"], .conflict-book-card input[type="checkbox"] {
    display: none; /* Hide default checkbox */
}

.delete-book-card .card-spine, .conflict-book-card .card-spine {
    width: 12px;
    height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
}

.delete-book-card .card-title, .conflict-book-card .card-title {
    font-family: var(--font-elegant);
    font-size: 0.95rem;
    color: var(--wood-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

/* Custom checkbox indicator */
.delete-book-card::before, .conflict-book-card::before {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    transition: all 0.2s;
}

.delete-book-card.selected::before, .conflict-book-card.selected::before {
    background: #d4af37;
    border-color: #d4af37;
    content: '✓';
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* --- Bookshelf Tabs (v28) --- */
.bookshelf-tabs-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    padding: 0 20px;
    position: relative;
    z-index: 5;
}

.bookshelf-tabs {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.bookshelf-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.bookshelf-tab {
    background: rgba(139, 69, 19, 0.2);
    border: 1px solid rgba(139, 69, 19, 0.3);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 8px 20px;
    font-family: var(--font-elegant);
    font-size: 0.9rem;
    color: var(--wood-dark);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bookshelf-tab:hover {
    background: rgba(139, 69, 19, 0.3);
}

.bookshelf-tab.active {
    background: rgba(244, 241, 234, 0.95);
    border-color: var(--wood-color);
    color: var(--wood-dark);
    font-weight: bold;
    padding-bottom: 10px;
    margin-bottom: -1px;
    box-shadow: 0 -3px 10px rgba(0,0,0,0.1);
}

.btn-add-shelf {
    background: var(--wood-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.btn-add-shelf:hover {
    transform: scale(1.1) rotate(90deg);
}

.btn-icon {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.shelf-badge {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 0.7rem;
    background: rgba(139, 69, 19, 0.1);
    color: #8b4513;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

.tab-rename-icon {
    font-size: 0.7rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.bookshelf-tab:hover .tab-rename-icon {
    opacity: 1;
}

/* --- V29 UI Refinements --- */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    gap: 20px;
    flex-wrap: nowrap; /* Force 1 row */
}

.header-right-area {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
}

.search-box-v29 {
    position: relative;
    max-width: 250px; /* Reduced to fit in one row */
    width: 100%;
}

.search-box-v29 input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    background: #fcfbfa; /* Opaque */
    border: 2px solid var(--wood-color);
    border-radius: 25px;
    font-family: var(--font-elegant);
    font-size: 0.9rem;
    color: var(--wood-dark);
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.1), 2px 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

.search-box-v29 input:focus {
    outline: none;
    background: #fff;
    box-shadow: 0 0 10px rgba(139, 69, 19, 0.3), inset 2px 2px 5px rgba(0,0,0,0.05);
}

.search-box-v29 i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wood-color);
}

.sort-select-v29 {
    background: #f4f1ea;
    border: 2px solid var(--wood-color);
    border-radius: 15px;
    padding: 5px 10px;
    font-family: var(--font-elegant);
    font-size: 0.8rem;
    color: var(--wood-dark);
    cursor: pointer;
    outline: none;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
}

.header-btns-v29 {
    display: flex;
    gap: 8px;
    align-items: center;
    white-space: nowrap;
}

.btn-text {
    background: #f4f1ea; /* Opaque Parchment */
    border: 2px solid var(--wood-color);
    color: var(--wood-dark);
    padding: 6px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    font-family: var(--font-elegant);
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

.btn-text:hover {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 4px 4px 12px rgba(0,0,0,0.4);
    border-color: var(--wood-light);
}

.btn-text i {
    color: var(--wood-color);
}

.btn-primary-v29 {
    background: var(--wood-color);
    border: 1px solid var(--wood-light);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-family: var(--font-elegant);
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-primary-v29:hover {
    background: var(--wood-light);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Bookshelf Container & Arrows */
.bookshelf-container-v29 {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
}

.shelf-nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: var(--wood-dark);
    color: #f4f1ea;
    border: 2px solid #d4af37;
    width: 50px;
    height: 120px;
    border-radius: 8px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 4px 4px 15px rgba(0,0,0,0.5);
}

.shelf-nav-btn:hover {
    background: var(--wood-color);
    width: 60px;
}

.shelf-nav-btn.left { left: 20px; }
.shelf-nav-btn.right { right: 20px; }

/* Random Book Ornament */
.random-book-ornament {
    position: fixed;
    right: 30px;
    top: 120px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #f7d774, #a0522d);
    border: 5px double #f4f1ea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6), inset 0 0 15px rgba(255,255,255,0.3);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1001;
    color: white;
    text-align: center;
}

.random-book-ornament:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
}

.dice-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.dice-box i {
    font-size: 2rem;
    animation: dice-pulse 2s infinite;
}

.dice-box span {
    font-size: 0.7rem;
    font-family: var(--font-elegant);
    font-weight: bold;
    display: block;
    line-height: 1;
}

@keyframes dice-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@media (max-width: 1300px) {
    .random-book-ornament {
        right: 20px;
        width: 80px;
        height: 80px;
    }
    .random-book-ornament:hover { transform: scale(1.1); }
    .dice-box i { font-size: 1.5rem; }
    .dice-box span { font-size: 0.6rem; }
}

/* Forest Toast Decoration */
.toast-forest {
    border-left: 5px solid #2e7d32 !important;
}
.toast-forest i {
    color: #4caf50 !important;
}

/* Toast Notification */
#toast-container {
    position: fixed;
    top: 40px;
    right: 40px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.toast {
    background: rgba(62, 39, 35, 0.95);
    color: #f4f1ea;
    padding: 15px 25px;
    border-radius: 8px;
    border-left: 5px solid #d4af37;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    font-family: var(--font-elegant);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideInRight 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(5px);
}
.toast i { color: #d4af37; font-size: 1.5rem; }
.toast.fade-out {
    animation: fadeOutDown 0.5s forwards;
}

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

#drag-overlay {
    background: rgba(46, 26, 26, 0.9);
    border: 5px dashed #d4af37;
    margin: 20px;
    width: calc(100% - 40px);
    height: calc(100% - 40px);
    border-radius: 15px;
    pointer-events: none;
    transition: opacity 0.3s;
}
#drag-overlay h2 {
    color: #d4af37;
    letter-spacing: 5px;
}

/* Bookshelf Switch Animation */
.shelf-transition-out {
    animation: shelfSlideOut 0.4s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.shelf-transition-in {
    animation: shelfSlideIn 0.4s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes shelfSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(-50px); }
}

@keyframes shelfSlideIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============================== */
/* v40: プログレスバー（背表紙）   */
/* ============================== */
.spine-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0,0,0,0.3);
    z-index: 20;
    border-radius: 0 0 3px 3px;
    overflow: hidden;
}
.spine-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4af37, #ffd700);
    transition: width 0.3s ease;
    border-radius: 0 0 3px 3px;
    box-shadow: 0 0 6px rgba(212,175,55,0.6);
}

/* ============================== */
/* v40: 読了バッジ（背表紙）       */
/* ============================== */
.completion-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #ffd700, #daa520);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    z-index: 30;
    box-shadow: 0 2px 8px rgba(212,175,55,0.7);
    animation: badgePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes badgePop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* ============================== */
/* v40: 読書プログレスバー（モーダル内） */
/* ============================== */
.reading-progress-bar {
    height: 4px;
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.reading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4af37, #ffd700);
    transition: width 0.4s ease;
    width: 0%;
}
.page-info {
    font-size: 0.85rem;
    color: #888;
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
}

/* ============================== */
/* v40: 季節テーマ                 */
/* ============================== */
.season-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9998;
    overflow: hidden;
}
.particle {
    position: absolute;
    pointer-events: none;
    opacity: 0.8;
}
/* 春：桜の花びら */
.particle-spring {
    width: 12px;
    height: 12px;
    background: radial-gradient(ellipse, #ffb7c5, #ff9baf);
    border-radius: 50% 0 50% 50%;
    animation: fallSpring linear infinite;
}
@keyframes fallSpring {
    0% { transform: translateY(-20px) rotate(0deg) translateX(0); opacity: 0.9; }
    50% { transform: translateY(50vh) rotate(180deg) translateX(40px); opacity: 0.7; }
    100% { transform: translateY(105vh) rotate(360deg) translateX(-20px); opacity: 0; }
}
/* 夏：蛍 */
.particle-summer {
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, #ffffaa, transparent);
    border-radius: 50%;
    box-shadow: 0 0 8px #ffffaa, 0 0 15px #ffffaa;
    animation: floatSummer ease-in-out infinite;
}
@keyframes floatSummer {
    0% { transform: translate(0, 0); opacity: 0; }
    25% { opacity: 1; }
    50% { transform: translate(30px, -40px); opacity: 0.7; }
    75% { opacity: 1; }
    100% { transform: translate(-20px, -80px); opacity: 0; }
}
/* 秋：紅葉 */
.particle-autumn {
    width: 14px;
    height: 14px;
    background: radial-gradient(ellipse, #c0392b, #e67e22);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    animation: fallAutumn linear infinite;
}
@keyframes fallAutumn {
    0% { transform: translateY(-20px) rotate(0deg) translateX(0); opacity: 0.85; }
    50% { transform: translateY(50vh) rotate(200deg) translateX(-50px); opacity: 0.6; }
    100% { transform: translateY(105vh) rotate(400deg) translateX(30px); opacity: 0; }
}
/* 冬：雪 */
.particle-winter {
    width: 8px;
    height: 8px;
    background: radial-gradient(circle, #fff, #e0e0e0);
    border-radius: 50%;
    animation: fallWinter linear infinite;
}
@keyframes fallWinter {
    0% { transform: translateY(-10px) translateX(0); opacity: 0.9; }
    50% { transform: translateY(50vh) translateX(25px); opacity: 0.7; }
    100% { transform: translateY(105vh) translateX(-15px); opacity: 0.3; }
}

/* ============================== */
/* v40: 暖炉エフェクト             */
/* ============================== */
.fireplace {
    position: fixed;
    bottom: 0;
    left: 30px;
    width: 120px;
    height: 100px;
    z-index: 999;
    pointer-events: none;
}
.fire-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
}
.flame {
    position: absolute;
    bottom: 0;
    border-radius: 50% 50% 30% 30%;
    filter: blur(2px);
}
.flame-1 {
    left: 15px;
    width: 30px;
    height: 50px;
    background: linear-gradient(to top, #ff6600, #ffcc00, transparent);
    animation: flicker1 0.8s ease-in-out infinite alternate;
}
.flame-2 {
    left: 5px;
    width: 22px;
    height: 35px;
    background: linear-gradient(to top, #ff4400, #ff8800, transparent);
    animation: flicker2 1.2s ease-in-out infinite alternate;
}
.flame-3 {
    left: 28px;
    width: 20px;
    height: 38px;
    background: linear-gradient(to top, #ff5500, #ffaa00, transparent);
    animation: flicker3 1s ease-in-out infinite alternate;
}
.flame-4 {
    left: 18px;
    width: 25px;
    height: 55px;
    background: linear-gradient(to top, #ff3300, #ffdd00, transparent);
    animation: flicker1 0.6s ease-in-out infinite alternate;
    opacity: 0.7;
}
.ember {
    position: absolute;
    bottom: 5px;
    width: 4px;
    height: 4px;
    background: #ff6600;
    border-radius: 50%;
    animation: emberFloat 2s ease-in-out infinite;
}
.ember-1 { left: 20px; animation-delay: 0s; }
.ember-2 { left: 30px; animation-delay: 0.7s; }
.ember-3 { left: 40px; animation-delay: 1.4s; }
@keyframes emberFloat {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-40px) translateX(10px); opacity: 0; }
}
.fire-log, .fire-log-2 {
    position: absolute;
    bottom: 5px;
    left: 15px;
    width: 50px;
    height: 10px;
    background: linear-gradient(to right, #3e1a00, #5c2e00, #3e1a00);
    border-radius: 5px;
    transform: rotate(-5deg);
}
.fire-log-2 {
    left: 25px;
    bottom: 12px;
    transform: rotate(8deg);
    width: 45px;
}
.fireplace-glow {
    position: absolute;
    bottom: -10px;
    left: -20px;
    width: 160px;
    height: 80px;
    background: radial-gradient(ellipse, rgba(255,120,0,0.15), transparent 70%);
    pointer-events: none;
}
@keyframes flicker1 {
    0% { height: 50px; opacity: 1; }
    100% { height: 42px; opacity: 0.85; }
}
@keyframes flicker2 {
    0% { height: 35px; opacity: 0.9; }
    100% { height: 28px; opacity: 0.7; }
}
@keyframes flicker3 {
    0% { height: 38px; opacity: 0.95; }
    100% { height: 30px; opacity: 0.75; }
}

/* ============================== */
/* v40: 読書統計ダッシュボード     */
/* ============================== */
.stats-content {
    max-width: 700px;
}
.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}
.stat-card {
    background: linear-gradient(135deg, #f8f4ed, #ece4d4);
    border: 2px solid var(--wood-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.1);
}
.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--wood-dark);
    font-family: var(--font-gothic);
    line-height: 1.2;
}
.stat-label {
    font-size: 0.85rem;
    color: #888;
    margin-top: 5px;
}
.heatmap-container {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 3px;
    padding: 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    border: 1px solid #eee;
}
.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: #ebedf0;
    transition: all 0.2s;
    cursor: default;
    position: relative;
}
.heatmap-cell[title]:hover {
    outline: 2px solid var(--wood-color);
}
.heatmap-level-1 { background: #c6e48b; }
.heatmap-level-2 { background: #7bc96f; }
.heatmap-level-3 { background: #239a3b; }
.heatmap-level-4 { background: #196127; }
.completed-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0,0,0,0.02);
    border-radius: 8px;
    border: 1px solid #eee;
}
.completed-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid #eee;
}
.completed-item:last-child { border-bottom: none; }
.completed-item i { color: #d4af37; }
.completed-date { font-size: 0.8rem; color: #999; margin-left: auto; }

/* ============================== */
/* v40: タグ管理                   */
/* ============================== */
.tag-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}
.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-family: var(--font-elegant);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid;
}
.tag-badge:hover { transform: translateY(-1px); }
.spine-tags {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 20;
}
.spine-tag-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(0,0,0,0.3);
}

/* ============================== */
/* v40: 本の引き抜き演出           */
/* ============================== */
.book-spine.neighbor-tilt-left {
    transform: rotate(3deg) translateY(-2px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.book-spine.neighbor-tilt-right {
    transform: rotate(-3deg) translateY(-2px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ============================== */
/* v40: キーボードショートカット   */
/* ============================== */
.shortcut-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(62, 39, 35, 0.8);
    color: #f4f1ea;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-family: var(--font-elegant);
    z-index: 100;
    backdrop-filter: blur(5px);
    opacity: 0.6;
    transition: opacity 0.3s;
}
.shortcut-hint:hover { opacity: 1; }
kbd {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
    margin: 0 2px;
}
.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}
.shortcut-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
}
.shortcut-item kbd {
    background: var(--wood-color);
    color: #fff;
    border: none;
    min-width: 30px;
    text-align: center;
}
.shortcut-item span { flex: 1; }

/* ============================== */
/* v40: 本棚移動サブメニュー       */
/* ============================== */
#move-shelf-menu {
    min-width: 160px;
}
#move-shelf-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #f4f1ea;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-family: var(--font-elegant);
    cursor: pointer;
    transition: background 0.2s;
}
#move-shelf-menu button:hover {
    background: rgba(212, 175, 55, 0.3);
}

/* ============================== */
/* v40: ヘッダーレスポンシブ対応   */
/* ============================== */
@media (max-width: 1100px) {
    .header-top { flex-wrap: wrap; }
    .header-right-area { flex-wrap: wrap; justify-content: flex-start; }
    .header-btns-v29 { flex-wrap: wrap; }
}
