:root {
    --bg: #1a1a2e;
    --paper: #f5f0e8;
    --text: #2c2c2c;
    --accent: #ff6b6b;
    --accent2: #4ecdc4;
    --border: #2d2d44;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: var(--bg);
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(78, 205, 196, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 107, 107, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(255, 230, 109, 0.05) 0%, transparent 50%);
    min-height: 100vh;
    padding: 40px 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    pointer-events: none;
    z-index: 0;
}

/* Звездочки */
.star {
    position: fixed;
    color: #ff6b6b;
    animation: twinkle 2s infinite;
    z-index: 1;
    pointer-events: none;
    font-size: 20px;
}

.star:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; }
.star:nth-child(2) { top: 20%; right: 10%; animation-delay: 0.5s; }
.star:nth-child(3) { bottom: 30%; left: 8%; animation-delay: 1s; }
.star:nth-child(4) { top: 40%; right: 5%; animation-delay: 1.5s; }
.star:nth-child(5) { bottom: 10%; right: 20%; animation-delay: 0.8s; }
.star:nth-child(6) { top: 60%; left: 15%; animation-delay: 0.3s; }
.star:nth-child(7) { bottom: 50%; right: 15%; animation-delay: 1.2s; }

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Обложка тетради */
.main-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.notebook-cover {
    background: var(--paper);
    border: 3px solid #2d2d44;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 4px #f5f0e8,
        0 0 0 8px #2d2d44;
    padding: 60px 40px;
    max-width: 600px;
    width: 90%;
    text-align: center;
    position: relative;
    z-index: 2;
}

.cover-title {
    font-size: 48px;
    font-weight: bold;
    color: #2d2d44;
    margin-bottom: 30px;
    letter-spacing: 5px;
    text-transform: uppercase;
}

.cover-description {
    font-size: 16px;
    color: #666;
    line-height: 1.8;
    margin-bottom: 40px;
    text-align: justify;
    word-wrap: break-word;
}

.cover-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.cover-btn {
    background: white;
    border: 3px solid #2d2d44;
    padding: 15px 30px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 4px 4px 0 #2d2d44;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cover-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #2d2d44;
}

.cover-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #2d2d44;
}

.diary-btn {
    background: #4ecdc4;
    color: #2d2d44;
}

.edit-btn-cover {
    background: #ff6b6b;
    color: white;
}

.btn-icon {
    font-size: 20px;
}

.edit-btn-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.cover-note {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* Верхнее меню */
.browser-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #2d2d44;
    z-index: 1000;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
}

.site-title {
    color: #f5f0e8;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 0 10px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.tabs-container {
    display: flex;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    padding: 3px 0;
    align-items: flex-end;
    min-height: 40px;
    flex-wrap: nowrap;
}

.tabs-container::-webkit-scrollbar {
    height: 6px;
}

.tabs-container::-webkit-scrollbar-track {
    background: #3d3d5c;
    border-radius: 3px;
}

.tabs-container::-webkit-scrollbar-thumb {
    background: #555577;
    border-radius: 3px;
}

.tab {
    background: #3d3d5c;
    border: 1px solid #555577;
    padding: 8px 12px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #cccccc;
    transition: all 0.15s ease;
    white-space: nowrap;
    position: relative;
    user-select: none;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    max-width: 150px;
    flex-shrink: 0;
}

.tab:hover {
    background: #4a4a6a;
    color: #ffffff;
}

.tab.active {
    background: #f5f0e8;
    color: #2d2d44;
    border-color: #f5f0e8;
}

.tab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
}

.tab-close {
    font-weight: bold;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    border-radius: 50%;
    transition: all 0.15s ease;
    display: none;
    flex-shrink: 0;
}

.tab:hover .tab-close,
.tab.active .tab-close {
    display: inline-block;
}

.tab-close:hover {
    background: #ff6b6b;
    color: white;
}

.add-tab-btn {
    background: transparent;
    border: 1px solid #555577;
    color: #cccccc;
    padding: 8px 12px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    transition: all 0.15s ease;
    border-radius: 8px 8px 0 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.add-tab-btn:hover {
    background: #4a4a6a;
    color: #ffffff;
}

.add-tab-btn.visible {
    display: flex;
}

/* Кнопки */
.font-btn, .search-btn, .color-btn, .backup-btn {
    background: transparent;
    border: 2px solid #555577;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #cccccc;
    transition: all 0.15s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.font-btn:hover, .search-btn:hover, .color-btn:hover, .backup-btn:hover {
    background: #4a4a6a;
    color: #ffffff;
}

.search-btn.visible {
    display: flex;
}

.search-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: relative;
}

.search-icon::after {
    content: '';
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 6px;
    height: 2px;
    background: currentColor;
    transform: rotate(45deg);
}

/* Кнопка редактирования */
.edit-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--accent);
    border: 3px solid #2d2d44;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 24px;
    font-weight: bold;
    color: white;
    box-shadow: 4px 4px 0 #2d2d44;
    transition: all 0.15s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edit-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #2d2d44;
    background: #ff5252;
}

.edit-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #2d2d44;
}

.edit-btn.active {
    background: #4ecdc4;
    color: #2d2d44;
}

/* Модальные окна */
.font-modal, .color-modal, .tab-edit-modal, .search-modal, .password-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 46, 0.8);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.font-modal.active, .color-modal.active, .tab-edit-modal.active, .search-modal.active, .password-modal.active {
    display: flex;
}

.font-box, .tab-edit-box, .search-box, .password-box {
    background: var(--paper);
    padding: 30px;
    border: 3px solid #2d2d44;
    box-shadow: 8px 8px 0 #2d2d44;
    max-width: 400px;
    width: 90%;
    position: relative;
}

.search-box {
    max-width: 500px;
}

.password-box {
    text-align: center;
}

.password-box::before {
    content: '🔐';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    background: var(--paper);
    padding: 0 10px;
}

.font-box h3, .tab-edit-box h3, .search-box h3, .password-box h3 {
    margin-bottom: 20px;
    color: #2d2d44;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.font-box label, .tab-edit-box label, .search-box label, .password-box label {
    display: block;
    margin-bottom: 8px;
    color: #2d2d44;
    font-size: 13px;
    font-weight: bold;
}

.font-box input, .tab-edit-box input, .search-box input, .password-box input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 2px solid #2d2d44;
    font-size: 14px;
    outline: none;
    font-family: 'Courier New', monospace;
    background: white;
    box-shadow: 3px 3px 0 #2d2d44;
}

.password-box input {
    font-size: 18px;
}

.font-box input:focus, .tab-edit-box input:focus, .search-box input:focus, .password-box input:focus {
    background: #f0f8ff;
}

.font-option {
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    border: 2px solid #2d2d44;
    transition: all 0.15s ease;
    background: white;
    box-shadow: 3px 3px 0 #2d2d44;
}

.font-option:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 #2d2d44;
    background: #f0f8ff;
}

.font-option.active {
    background: #4ecdc4;
    color: #2d2d44;
    border-color: #2d2d44;
}

.font-option .font-name {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
}

.font-option .font-preview {
    font-size: 16px;
}

.color-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.15s ease;
}

.color-option:hover {
    transform: scale(1.2);
    border-color: #2d2d44;
}

.color-option.active {
    border-color: #2d2d44;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.custom-color {
    margin-bottom: 20px;
}

.custom-color label {
    display: block;
    margin-bottom: 8px;
    color: #2d2d44;
    font-size: 13px;
    font-weight: bold;
}

.custom-color input[type="color"] {
    width: 100%;
    height: 40px;
    border: 2px solid #2d2d44;
    cursor: pointer;
    padding: 0;
}

.btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.btn-group button {
    background: white;
    border: 2px solid #2d2d44;
    padding: 8px 16px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: bold;
    transition: all 0.15s ease;
    box-shadow: 3px 3px 0 #2d2d44;
    text-transform: uppercase;
}

.btn-group button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 #2d2d44;
}

.btn-group button:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #2d2d44;
}

.error-message {
    color: #ff6b6b;
    font-size: 12px;
    margin-top: -15px;
    margin-bottom: 15px;
    display: none;
}

.error-message.show {
    display: block;
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.search-result-item {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    transition: all 0.15s ease;
}

.search-result-item:hover {
    background: #f0f4ff;
}

.search-result-item .result-title {
    font-weight: bold;
    color: #2d2d44;
    font-size: 13px;
}

.search-result-item .result-date {
    color: #888;
    font-size: 11px;
}

/* Бумага */
.paper-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 100px auto 40px;
    z-index: 2;
}

.paper-frame {
    background: var(--paper);
    padding: 20px;
    border: 3px solid #2d2d44;
    box-shadow: 
        var(--shadow),
        0 0 0 4px #f5f0e8,
        0 0 0 8px #2d2d44;
    position: relative;
}

.paper {
    background-color: #fffef8;
    width: 100%;
    min-height: 700px;
    padding: 60px 80px;
    position: relative;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 70px;
    right: 30px;
    bottom: 0;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 35px,
        #c8d8e8 35px,
        #c8d8e8 36px
    );
    pointer-events: none;
}

.paper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 64px;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #ff6b6b, #ff8e8e);
    border-radius: 3px;
    pointer-events: none;
}

.paper-content {
    position: relative;
    z-index: 1;
    min-height: 580px;
    line-height: 36px;
    font-size: 20px;
    color: var(--text);
    outline: none;
    word-wrap: break-word;
    font-family: 'Times New Roman', serif;
    padding-top: 17px;
}

.paper-content:empty::before {
    content: '~ начни писать здесь ~';
    color: #bbb;
    font-style: italic;
}

.paper-content.editing {
    background: #fffef8;
    color: #2c2c2c;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    line-height: 1.6;
    min-height: 580px;
    white-space: pre-wrap;
    border: 2px dashed #ff6b6b;
}

/* Название страницы */
.page-title {
    text-align: center;
    font-size: 52px;
    font-weight: bold;
    color: #f5f0e8;
    margin-bottom: 30px;
    letter-spacing: 8px;
    text-transform: uppercase;
    font-family: 'Times New Roman', serif;
    text-shadow: 
        3px 3px 0 #2d2d44,
        6px 6px 0 rgba(255, 107, 107, 0.5);
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
}

.page-title::after {
    content: '';
    display: block;
    width: 120px;
    height: 3px;
    background: #ff6b6b;
    margin: 15px auto 0;
    box-shadow: 0 0 15px #ff6b6b;
}

.holes {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 50px;
    z-index: 3;
}

.hole {
    width: 16px;
    height: 16px;
    background-color: #1a1a2e;
    border-radius: 50%;
    box-shadow: 
        inset 0 3px 5px rgba(0, 0, 0, 0.5),
        0 0 0 3px #f5f0e8;
}

.corner-decoration {
    position: absolute;
    width: 30px;
    height: 30px;
    z-index: 5;
}

.corner-tl { top: -15px; left: -15px; border-top: 3px solid #ff6b6b; border-left: 3px solid #ff6b6b; }
.corner-tr { top: -15px; right: -15px; border-top: 3px solid #4ecdc4; border-right: 3px solid #4ecdc4; }
.corner-bl { bottom: -15px; left: -15px; border-bottom: 3px solid #4ecdc4; border-left: 3px solid #4ecdc4; }
.corner-br { bottom: -15px; right: -15px; border-bottom: 3px solid #ff6b6b; border-right: 3px solid #ff6b6b; }

/* Перетаскивание вкладок */
.tab.dragging {
    opacity: 0.5;
}

.tab.drag-over {
    border-left: 3px solid #4ecdc4;
}

@media (max-width: 768px) {
    .paper {
        padding: 40px 50px;
        min-height: 500px;
    }
    
    .paper::before { left: 45px; right: 20px; }
    .paper::after { left: 40px; }
    .paper-content { font-size: 16px; line-height: 30px; padding-top: 10px; }
    .holes { left: 10px; }
    
    .edit-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 20px;
        right: 20px;
    }
    
    .tab {
        padding: 6px 8px;
        font-size: 10px;
        min-width: 60px;
        max-width: 100px;
    }
    
    .site-title {
        font-size: 12px;
    }
    
    .cover-title {
        font-size: 36px;
    }
}/* Стрелка следующей страницы */
.next-page-arrow {
    display: block;
    margin: 30px auto 0;
    background: transparent;
    border: 3px solid #f5f0e8;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    color: #f5f0e8;
    font-size: 24px;
    transition: all 0.15s ease;
    box-shadow: 3px 3px 0 #2d2d44;
    position: relative;
    z-index: 10;
}

.next-page-arrow:hover {
    transform: translateY(3px);
    background: rgba(245, 240, 232, 0.1);
    box-shadow: 5px 5px 0 #2d2d44;
    color: #ff6b6b;
    border-color: #ff6b6b;
}

.next-page-arrow:active {
    transform: translateY(5px);
    box-shadow: 1px 1px 0 #2d2d44;
}

.arrow-icon {
    display: inline-block;
    animation: bounce 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}