:root {
    --sidebar-width: 320px;
    --accent: #222;
    --bg: #111;
}
* {
    box-sizing: border-box;
}
/* bookmark indicator on chapter in sidebar */
.bookmark-indicator {
    color: #ffca28;
    font-weight: bold;
    margin-left: auto;
}

body {
    background: var(--bg);
    color: #ddd;
    margin: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}
/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    background: #1b1b1b;
    border-right: 1px solid #333;
    position: fixed;
    left: 0;
    top: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    transform: translateX(-100%);
    will-change: transform;
}

body.sidebar-active #sidebar {
    transform: translateX(0);
}

.sidebar-header {
    padding: 20px;
    background: #111;
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid #333;
}

.nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.home-btn-text {
    color: white;
    text-decoration: none;
    font-size: 0.85em;
    padding: 6px 14px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    transition: background-color 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.home-btn-text:hover {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.title-item {
    display: flex;
    align-items: center;
    background: #252525;
    padding: 12px;
    border-bottom: 1px solid #111;
    font-weight: bold;
    cursor: pointer;
}

.vol-item {
    padding: 8px 15px;
    background: #222;
    color: #aaa;
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
}

.children {
    display: none;
}

.children.active {
    display: block;
}

.chap-link {
    padding: 8px 30px;
    font-size: 0.9em;
    color: #888;
    text-decoration: none;
    display: block;
    transition: background-color 0.2s, color 0.2s;
}

.chap-link:hover {
    background: #252525;
}

.chap-link.active {
    color: var(--accent);
    font-weight: bold;
    background: #222;
    border-left: 3px solid var(--accent);
}

/* Content Area */
#content {
    flex: 1;
    margin-left: 0;
    min-width: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.sidebar-active #content {
    margin-left: var(--sidebar-width);
}

/* Manga Grid */
.manga-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 25px;
    padding: 40px;
    width: 100%;
    max-width: 1400px;
}

.manga-card {
    background: #222;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
    text-decoration: none;
    color: white;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
}

.manga-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.manga-card img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    background: #000;
    flex-shrink: 0;
}

.manga-card span {
    padding: 12px;
    font-size: 0.95em;
    text-align: center;
    font-weight: 500;
    display: block;
    width: 100%;
    word-wrap: break-word;
    background: #222;
    z-index: 3;
}

.manga-info {
    position: absolute;
    left: 10px;
    right: 10px;
    background: rgba(0,0,0,0.9);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 0.8em;
    padding: 8px;
    border-radius: 8px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    z-index: 2;
    /* Оптимизированный переход только по нужным свойствам */
    transition: opacity 0.2s, top 0.2s;
    top: 260px;
}

/* Объединенный и очищенный hover для плашки инфо */
.manga-card:hover .manga-info {
    opacity: 1;
    top: 220px;
}

/* Viewer */
#viewer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#viewer img {
    width: var(--img-width, 70%);
    height: auto;
    margin-bottom: var(--img-gap, 10px);
}

/* Floating UI */
.float-btn {
    position: fixed;
    bottom: 25px;
    z-index: 2000;
    background: var(--accent);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#toggle-menu { left: 20px; }
#toggle-settings { right: 20px; background: #444; }

#bookmark-btn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 2000;
    background: #2a2a2a;
    color: #888;
    border: 1px solid #333;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s, color 0.2s;
}

#bookmark-btn.active {
    background: var(--accent);
    color: white;
    opacity: 1;
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent);
}

/* Settings Overlay */
#settings-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 3000;
    align-items: center;
    justify-content: center;
}

#settings-overlay.active {
    display: flex;
}

.settings-card {
    background: #222;
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    border: 1px solid #333;
}

.control-group {
    margin: 15px 0;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
    margin-bottom: 8px;
    color: #bbb;
}

input[type="color"] {
    border: none;
    width: 40px;
    height: 25px;
    cursor: pointer;
    background: none;
}

.nav-footer {
    margin: 40px 0 80px 0;
    display: flex;
    gap: 15px;
    width: 90%;
    max-width: 800px;
}

.btn {
    background: #252525;
    color: white;
    padding: 15px;
    text-decoration: none;
    border-radius: 8px;
    flex: 1;
    border: 1px solid #333;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn:hover {
    border-color: var(--accent);
    background: #333;
}

/* Progress Bar */
#progress-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    z-index: 4000;
    background: rgba(0,0,0,0.3);
    display: none;
}

#progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.1s linear;
}
