:root {
    --bg-dark: #1a0a14;
    --bg-content: #220d1b;
    --accent: #ff4d8d;
    --accent-light: #ff80b3;
    --accent-dark: #d93672;
    --text: #ffe6f2;
    --text-secondary: #e6b3cc;
    --book-width: 1000px;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    line-height: 1.8;
    padding: 20px;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 77, 141, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(217, 54, 114, 0.1) 0%, transparent 20%);
    background-size: 40px 40px;
}

.book-container {
    max-width: var(--book-width);
    margin: 0 auto;
    background: linear-gradient(145deg, var(--bg-content), #1c0917);
    border-radius: var(--border-radius);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 77, 141, 0.1);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.book-header {
    padding: 50px 50px 30px;
    border-bottom: 1px solid rgba(255, 77, 141, 0.3);
    text-align: center;
    position: relative;
    background: linear-gradient(to bottom, rgba(34, 13, 27, 0.9), rgba(26, 10, 20, 0.7));
}

.book-header h1 {
    color: var(--accent-light);
    font-size: 2.8rem;
    letter-spacing: 1px;
    margin-bottom: 15px;
    font-weight: 700;
    position: relative;
    display: inline-block;
}

.book-header h1::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    opacity: 0.7;
}

.decoration {
    height: 4px;
    width: 80px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
    margin: 15px auto;
    border-radius: 2px;
}

.book-content {
    padding: 40px 60px 60px;
    min-height: 80vh;
    position: relative;
}

.book-footer {
    padding: 25px 50px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.3), transparent);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 77, 141, 0.2);
    position: relative;
}

.book-footer::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--accent), transparent);
}

h1, h2, h3, h4 {
    color: var(--accent-light);
    margin: 2rem 0 1.2rem;
    font-weight: 600;
    position: relative;
}

h1 {
    font-size: 2.4rem;
    border-bottom: 2px solid rgba(255, 77, 141, 0.3);
    padding-bottom: 12px;
    margin-top: 0;
}

h2 {
    font-size: 1.9rem;
    margin-top: 2.8rem;
    padding-left: 15px;
}

h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 70%;
    width: 4px;
    background: linear-gradient(to bottom, var(--accent), var(--accent-dark));
    border-radius: 2px;
}

p {
    margin: 1.5rem 0;
    text-align: justify;
    font-size: 1.05rem;
}

a {
    color: var(--accent-light);
    text-decoration: none;
    background: linear-gradient(to right, transparent 50%, rgba(255, 128, 179, 0.2) 50%);
    background-size: 200% 100%;
    background-position: right bottom;
    transition: var(--transition);
    padding: 0 2px;
    border-radius: 2px;
}

a:hover {
    background-position: left bottom;
    color: white;
}

pre {
    background: linear-gradient(to right, rgba(0, 0, 0, 0.4), rgba(34, 13, 27, 0.8));
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 30px 0;
    overflow-x: auto;
    border-left: 4px solid var(--accent);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5), 0 5px 20px rgba(0, 0, 0, 0.3);
    position: relative;
}

pre::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, var(--accent-dark), var(--accent));
}

pre code {
    font-family: 'Fira Code', monospace;
    font-size: 15px;
    line-height: 1.5;
    display: block;
    position: relative;
    padding-left: 3.5em !important; /* Отступ для номеров строк */
    counter-reset: line;
}

pre code .line {
    display: block;
    position: relative;
}

pre code .line::before {
    content: counter(line);
    counter-increment: line;
    position: absolute;
    left: -3.5em;
    width: 2.5em;
    text-align: right;
    color: var(--text-secondary);
    opacity: 0.6;
    user-select: none;
}

blockquote {
    border-left: 4px solid var(--accent);
    padding: 20px 25px;
    margin: 25px 0;
    background: linear-gradient(to right, rgba(255, 77, 141, 0.05), transparent);
    color: var(--text);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    position: relative;
    overflow: hidden;
}

blockquote::before {
    content: """";
    position: absolute;
    top: -20px;
    left: 10px;
    font-size: 5rem;
    color: rgba(255, 77, 141, 0.1);
    font-family: Georgia, serif;
    z-index: 0;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 30px 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

th, td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 77, 141, 0.1);
}

th {
    background: linear-gradient(to bottom, var(--accent-dark), var(--accent));
    color: white;
    font-weight: 600;
}

tr:nth-child(even) {
    background-color: rgba(255, 77, 141, 0.05);
}

tr:hover {
    background-color: rgba(255, 77, 141, 0.1);
}

/* Исправленный стиль скроллбара */
pre::-webkit-scrollbar {
    height: 10px;
}

pre::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    margin: 0 10px;
}

pre::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 5px;
    border: 2px solid rgba(0, 0, 0, 0.3);
}

pre::-webkit-scrollbar-thumb:hover {
    background: var(--accent-light);
}

/* Для Firefox */
pre {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .book-container {
        border-radius: 0;
    }
    
    .book-header,
    .book-content,
    .book-footer {
        padding: 25px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.6rem;
    }
    
    pre {
        padding: 15px;
    }
    
    pre code {
        padding-left: 2.5em !important;
    }
    
    pre code .line::before {
        left: -2.5em;
        width: 2em;
    }
}