/* ============================================
   ЛОКАЛЬНЫЕ ШРИФТЫ
============================================ */
@font-face {
    font-family: 'Caveat';
    src: url('../fonts/HQYSaversText.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Caveat';
    src: url('../fonts/HQYSaversText.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Special Elite';
    src: url('../fonts/HQYSaversText.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* ============================================
   ПЕРЕМЕННЫЕ — СВЕТЛАЯ ТЕМА
============================================ */
:root {
    /* Бумага */
    --paper-color: #f5f0e6;
    --paper-light: #faf8f3;
    --paper-lines: #c8d4e8;
    --margin-line: rgba(196, 69, 54, 0.35);

    /* Чернила */
    --ink-color: #35355e;
    --ink-light: #4a4a5a;

    /* Дерево / стол */
    --wood-dark: #3d3020;
    --wood-mid: #4a3d2a;
    --wood-light: #5c4a2a;

    /* Акценты */
    --accent-red: #c44536;
    --accent-gold: #d4a03c;

    /* Стикеры */
    --sticky-yellow: #fff9c4;

    /* Крем */
    --cream: #f5f0e6;
    --cream-dark: #e8e0d0;
    --cream-hover: #ebe5d8;

    /* Разметка листа */
    --line-height: 32px;
    --paper-padding-top: 80px;
    --paper-padding-left: 100px;
    --margin-position: 70px;
    --paper-padding-right: 50px;

    /* Фон */
    --bg-gradient-top: #5c4a2a;
    --bg-gradient-mid: #3d3020;
    --bg-gradient-bot: #2d2418;
    --bg-stripe-color: rgba(0, 0, 0, 0.02);
    --bg-texture-opacity: 0.25;

    /* Полупрозрачные для панелей */
    --panel-text: rgba(245, 240, 230, 1);
    --panel-text-dim: rgba(245, 240, 230, 0.5);
    --panel-text-faint: rgba(245, 240, 230, 0.35);
    --panel-border: rgba(245, 240, 230, 0.1);
    --panel-border-strong: rgba(245, 240, 230, 0.15);
    --panel-item-bg: rgba(245, 240, 230, 0.06);
    --panel-hover-bg: rgba(245, 240, 230, 0.1);
    --panel-btn-bg: rgba(245, 240, 230, 0.1);
    --panel-btn-hover: rgba(245, 240, 230, 0.2);
    --panel-scrollbar: rgba(245, 240, 230, 0.15);

    /* Модалки */
    --modal-overlay: rgba(45, 36, 24, 0.92);
}

/* ============================================
   ПЕРЕМЕННЫЕ — ТЁМНАЯ ТЕМА
============================================ */
[data-theme="dark"] {
    --paper-color: #2a2a3e;
    --paper-light: #32324a;
    --paper-lines: rgba(100, 149, 237, 0.08);
    --margin-line: rgba(220, 80, 80, 0.12);

    --ink-color: #e0d8cc;
    --ink-light: #8a8298;

    --wood-dark: #1a1a2e;
    --wood-mid: #22223a;
    --wood-light: #2a2a4a;

    --accent-red: #e07060;
    --accent-gold: #7c6fa0;

    --sticky-yellow: #3a3a55;

    --cream: #2a2a3e;
    --cream-dark: #3a3a55;
    --cream-hover: #32324a;

    --bg-gradient-top: #1a1a2e;
    --bg-gradient-mid: #16162a;
    --bg-gradient-bot: #101024;
    --bg-stripe-color: rgba(255, 255, 255, 0.01);
    --bg-texture-opacity: 0.06;

    --panel-text: rgba(224, 216, 204, 1);
    --panel-text-dim: rgba(224, 216, 204, 0.5);
    --panel-text-faint: rgba(224, 216, 204, 0.3);
    --panel-border: rgba(224, 216, 204, 0.08);
    --panel-border-strong: rgba(224, 216, 204, 0.12);
    --panel-item-bg: rgba(224, 216, 204, 0.05);
    --panel-hover-bg: rgba(224, 216, 204, 0.08);
    --panel-btn-bg: rgba(224, 216, 204, 0.08);
    --panel-btn-hover: rgba(224, 216, 204, 0.15);
    --panel-scrollbar: rgba(224, 216, 204, 0.1);

    --modal-overlay: rgba(10, 10, 20, 0.92);
}

/* ============================================
   СБРОС
============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   BODY И ФОН
============================================ */
body {
    min-height: 100vh;
    font-family: 'Special Elite', monospace;
    overflow-x: hidden;
    position: relative;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 80px,
            var(--bg-stripe-color) 80px,
            var(--bg-stripe-color) 81px
        ),
        linear-gradient(
            180deg,
            var(--bg-gradient-top) 0%,
            var(--bg-gradient-mid) 50%,
            var(--bg-gradient-bot) 100%
        );
}

/* Текстура фона — бесшовная шершавость */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: var(--bg-texture-opacity);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.5'/%3E%3Crect width='200' height='200' fill='%238B7355' opacity='0.15'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

/* ============================================
   ОСНОВНОЙ КОНТЕЙНЕР
============================================ */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding: 40px 40px 120px 40px;
    min-height: 100vh;
}

/* ============================================
   ЛИСТ БУМАГИ
============================================ */
.paper-sheet {
    position: relative;
    width: 100%;
    max-width: 750px;
    min-height: 900px;
    background-color: var(--paper-color);
    border-radius: 2px;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(0, 0, 0, 0.1),
        0 16px 32px rgba(0, 0, 0, 0.15),
        inset 0 0 80px rgba(139, 105, 20, 0.03);
    overflow: hidden;
    transition: min-height 0.4s ease;
}

/* Текстура бумаги — повторяющаяся */
.paper-texture {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../images/paper.jpg');
    background-repeat: repeat;
    background-size: 200px 200px;
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

[data-theme="dark"] .paper-texture {
    opacity: 0.08;
}

/* Линейки */
.paper-lines {
    position: absolute;
    top: var(--paper-padding-top);
    left: var(--paper-padding-left);
    right: 40px;
    bottom: 40px;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(var(--line-height) - 1.5px),
        var(--paper-lines) calc(var(--line-height) - 1.5px),
        var(--paper-lines) var(--line-height)
    );
    pointer-events: none;
    transition: all 0.4s ease;
    z-index: 1;
    filter: blur(0.5px);
}

/* Красная полоса */
.margin-line {
    position: absolute;
    top: 40px;
    bottom: 40px;
    left: var(--margin-position);
    width: 2.5px;
    background: var(--margin-line);
    pointer-events: none;
    transition: all 0.4s ease;
    z-index: 1;
    filter: blur(0.5px);
}

/* Дырки */
.paper-holes {
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 200px;
    pointer-events: none;
    transition: all 0.4s ease;
    z-index: 2;
}

.paper-hole {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--wood-dark);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
    transition: all 0.4s ease;
}

/* ============================================
   ЗОНЫ ДЛЯ ЗВЁЗДОЧЕК (ИЗБРАННОЕ)
============================================ */
.star-zone {
    position: absolute;
    width: 45px;
    height: 45px;
    cursor: pointer;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.star-zone:hover {
    transform: scale(1.1);
}

.star-zone.top-left {
    top: 45px;
    left: 15px;
}

.star-zone.bottom-left {
    bottom: 45px;
    left: 15px;
}

.star-zone.bottom-right {
    bottom: 45px;
    right: 15px;
}

.star-zone .star-icon {
    width: 28px;
    height: 28px;
    opacity: 0.15;
    transition: all 0.3s ease;
}

.star-zone:hover .star-icon {
    opacity: 0.4;
}

.star-zone .star-icon path {
    fill: none;
    stroke: var(--accent-gold);
    stroke-width: 1.5;
}

.star-zone.active .star-icon {
    opacity: 1;
}

.star-zone.active .star-icon path {
    fill: var(--accent-gold);
    stroke: var(--accent-gold);
    stroke-dasharray: 100;
    animation: drawStar 0.6s ease forwards;
}

@keyframes drawStar {
    0% {
        stroke-dashoffset: 100;
        fill: transparent;
    }
    60% {
        stroke-dashoffset: 0;
        fill: transparent;
    }
    100% {
        stroke-dashoffset: 0;
        fill: var(--accent-gold);
    }
}

/* ============================================
   КОНТЕНТ ЛИСТА
============================================ */
.paper-content-wrapper {
    position: relative;
    padding: var(--paper-padding-top) var(--paper-padding-right) 80px var(--paper-padding-left);
    min-height: 800px;
    z-index: 3;
}

.story-header {
    font-size: 18px;
    line-height: var(--line-height);
    color: var(--ink-light);
    opacity: 0.6;
    margin-bottom: 0;
    pointer-events: none;
    user-select: none;
}

.story-input {
    font-size: 18px;
    line-height: var(--line-height);
    color: var(--ink-color);
    white-space: pre-wrap;
    word-wrap: break-word;
    outline: none;
    min-height: calc(var(--line-height) * 3);
    cursor: text;
    font-family: 'Special Elite', monospace;
}

.story-input:focus {
    outline: none;
}

.story-input:empty::before {
    content: 'напишите тему или нажмите Enter...';
    color: var(--ink-light);
    opacity: 0.35;
    font-style: italic;
}

/* Кнопка «нет идей» */
.no-ideas-btn {
    display: block;
    margin-top: 12px;
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    color: var(--ink-light);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.2s;
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 3px;
}

.no-ideas-btn:hover {
    opacity: 0.7;
}

.no-ideas-btn.hidden {
    display: none;
}

/* Курсор печати */
.typing-cursor {
    display: inline;
    animation: cursorBlink 0.7s infinite;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ============================================
   ДАТА НА ЛИСТЕ
============================================ */
.paper-date {
    position: absolute;
    top: 45px;
    right: var(--paper-padding-right);
    font-family: 'Caveat', cursive;
    font-size: 14px;
    color: var(--ink-light);
    opacity: 0.5;
    z-index: 4;
}

/* ============================================
   КНОПКИ УПРАВЛЕНИЯ
============================================ */
.controls {
    position: fixed;
    bottom: 25px;
    right: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.control-btn {
    width: 46px;
    height: 46px;
    background: var(--cream);
    border: 2px solid var(--cream-dark);
    border-radius: 12px;
    cursor: pointer;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    transform: scale(1.08);
    background: var(--cream-hover);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--ink-light);
    stroke-width: 2;
    fill: none;
}

.control-btn.action-btn svg {
    fill: var(--ink-light);
    stroke: none;
}

.control-btn.share-btn svg {
    fill: none;
    stroke: var(--ink-light);
}

.control-btn.stop-btn {
    background: #f5e8e6;
    border-color: #e8d8d4;
}

[data-theme="dark"] .control-btn.stop-btn {
    background: #3e2a2a;
    border-color: #4a3535;
}

.control-btn.stop-btn svg {
    fill: var(--accent-red);
}

.control-btn:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

/* ============================================
   БОКОВАЯ ПАНЕЛЬ (SIDEBAR)
============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100%;
    background: linear-gradient(
        180deg,
        var(--wood-mid) 0%,
        var(--wood-dark) 50%,
        var(--bg-gradient-bot) 100%
    );
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.4s ease;
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(-100%);
}

.sidebar.open {
    transform: translateX(0);
}

/* На десктопе hover открывает */
@media (min-width: 769px) {
    .sidebar:hover {
        transform: translateX(0);
    }

    .sidebar:hover ~ .sidebar-arrow {
        opacity: 0;
        pointer-events: none;
    }
}

.sidebar.open ~ .sidebar-arrow {
    opacity: 0;
    pointer-events: none;
}

/* Стрелка-триггер */
.sidebar-arrow {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 65px;
    background: var(--panel-btn-bg);
    border-radius: 0 10px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 201;
    transition: all 0.3s ease;
}

.sidebar-arrow:hover {
    background: var(--panel-btn-hover);
    width: 26px;
}

.sidebar-arrow::after {
    content: '';
    border: solid var(--panel-text-dim);
    border-width: 0 2px 2px 0;
    padding: 5px;
    transform: rotate(-45deg);
    margin-left: -4px;
    transition: transform 0.3s ease;
}

/* Крестик закрытия */
.sidebar-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: var(--panel-btn-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.sidebar.open .sidebar-close {
    opacity: 0.6;
    pointer-events: all;
}

.sidebar-close:hover {
    opacity: 1 !important;
    background: var(--panel-btn-hover);
}

.sidebar-close svg {
    width: 18px;
    height: 18px;
    stroke: var(--panel-text);
    stroke-width: 2;
    fill: none;
}

/* Заголовок */
.sidebar-header {
    padding: 30px 20px 20px;
    border-bottom: 1px solid var(--panel-border);
}

.sidebar-title {
    font-family: 'Caveat', cursive;
    font-size: 1.6rem;
    color: var(--accent-gold);
}

/* Табы */
.sidebar-tabs {
    display: flex;
    padding: 15px 20px;
    gap: 10px;
}

.sidebar-tab {
    flex: 1;
    padding: 10px 12px;
    font-family: 'Special Elite', monospace;
    font-size: 0.75rem;
    color: var(--panel-text-dim);
    background: transparent;
    border: 1px solid var(--panel-border-strong);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-tab:hover {
    color: var(--panel-text);
    border-color: var(--panel-text-dim);
}

.sidebar-tab.active {
    color: var(--wood-dark);
    background: var(--accent-gold);
    border-color: var(--accent-gold);
}

[data-theme="dark"] .sidebar-tab.active {
    color: #e0d8cc;
}

/* Контент */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.sidebar-content::-webkit-scrollbar {
    width: 5px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--panel-scrollbar);
    border-radius: 3px;
}

/* ============================================
   КАРТОЧКИ АРХИВА
============================================ */
.archive-card {
    background: var(--cream);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--cream-dark);
}

.archive-card:hover {
    transform: translateX(5px);
    background: var(--paper-light);
}

.archive-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.archive-card-star {
    width: 14px;
    height: 14px;
    fill: var(--accent-gold);
    flex-shrink: 0;
}

.archive-card-title {
    font-family: 'Caveat', cursive;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ink-color);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.archive-card-preview {
    font-size: 0.8rem;
    color: var(--ink-light);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.archive-card-date {
    font-size: 0.65rem;
    color: var(--ink-light);
    opacity: 0.5;
    margin-top: 8px;
}

.archive-card-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    background: var(--cream-dark);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.archive-card:hover .archive-card-delete {
    opacity: 0.6;
}

.archive-card-delete:hover {
    opacity: 1 !important;
    background: #f0e0dc;
}

[data-theme="dark"] .archive-card-delete:hover {
    background: #4a3535;
}

.archive-card-delete svg {
    width: 12px;
    height: 12px;
    stroke: var(--accent-red);
    stroke-width: 2.5;
    fill: none;
}

.archive-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--panel-text-faint);
    font-family: 'Caveat', cursive;
    font-size: 1.15rem;
}

/* ============================================
   ПАНЕЛЬ НАСТРОЕК
============================================ */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    z-index: 299;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.settings-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: linear-gradient(
        180deg,
        var(--wood-mid) 0%,
        var(--wood-dark) 50%,
        var(--bg-gradient-bot) 100%
    );
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.35s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
}

.settings-panel.open {
    transform: translateX(0);
}

/* Шапка настроек */
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30px 24px 20px;
    border-bottom: 1px solid var(--panel-border);
}

.settings-title {
    font-family: 'Caveat', cursive;
    font-size: 1.6rem;
    font-weight: normal;
    color: var(--accent-gold);
}

.settings-close {
    width: 32px;
    height: 32px;
    background: var(--panel-btn-bg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: all 0.2s;
    border-radius: 8px;
}

.settings-close:hover {
    opacity: 1;
    background: var(--panel-btn-hover);
}

.settings-close svg {
    width: 18px;
    height: 18px;
    stroke: var(--panel-text);
    stroke-width: 2;
    fill: none;
}

/* Контент настроек */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 30px;
}

.settings-content::-webkit-scrollbar {
    width: 5px;
}

.settings-content::-webkit-scrollbar-thumb {
    background: var(--panel-scrollbar);
    border-radius: 3px;
}

/* Секции */
.settings-section {
    margin-bottom: 28px;
}

.settings-section-title {
    font-family: 'Special Elite', monospace;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--panel-text-dim);
    margin-bottom: 12px;
    opacity: 0.7;
}

/* Элемент настройки */
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: var(--panel-item-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    margin-bottom: 8px;
}

.settings-item-vertical {
    flex-direction: column;
    align-items: stretch;
}

.settings-item-info {
    flex: 1;
    min-width: 0;
}

.settings-label {
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    color: var(--panel-text);
    display: block;
    margin-bottom: 2px;
}

.settings-hint {
    font-family: 'Special Elite', monospace;
    font-size: 0.68rem;
    color: var(--panel-text-faint);
    line-height: 1.5;
}

/* Toggle переключатель */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--panel-border-strong);
    border-radius: 24px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--panel-text);
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-gold);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Слайдеры */
.settings-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.slider-label-left,
.slider-label-right {
    font-family: 'Caveat', cursive;
    font-size: 0.85rem;
    color: var(--panel-text-faint);
    white-space: nowrap;
    min-width: 60px;
}

.slider-label-left {
    text-align: right;
}

.slider-label-right {
    text-align: left;
}

.settings-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--panel-border-strong);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.settings-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-gold);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s;
}

.settings-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.settings-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-gold);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.settings-range-value {
    font-family: 'Special Elite', monospace;
    font-size: 0.78rem;
    color: var(--accent-gold);
    font-weight: bold;
    min-width: 34px;
    text-align: center;
}

/* Кнопка сброса */
.settings-reset-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px dashed var(--panel-text-faint);
    color: var(--panel-text-dim);
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s;
    margin-top: 8px;
}

.settings-reset-btn:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
}

/* ============================================
   КОНТЕКСТНОЕ МЕНЮ
============================================ */
.context-menu {
    position: fixed;
    z-index: 600;
    background: linear-gradient(
        180deg,
        var(--wood-mid) 0%,
        var(--wood-dark) 100%
    );
    border: 1px solid var(--panel-border-strong);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 6px 0;
    min-width: 200px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.15s, transform 0.15s;
    pointer-events: none;
}

.context-menu.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    font-family: 'Caveat', cursive;
    font-size: 1.05rem;
    color: var(--panel-text);
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.context-menu-item:hover {
    background: var(--panel-hover-bg);
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    stroke: var(--accent-gold);
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

.context-menu-divider {
    height: 1px;
    background: var(--panel-border);
    margin: 4px 0;
}

/* ============================================
   МОДАЛКИ
============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--paper-color);
    width: 90%;
    max-width: 460px;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--cream-dark);
}

.modal-title {
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    color: var(--ink-color);
}

.modal-body {
    padding: 20px 24px;
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    font-family: 'Special Elite', monospace;
    font-size: 0.95rem;
    color: var(--ink-color);
    background: var(--paper-light);
    border: 1px solid var(--cream-dark);
    border-radius: 6px;
    outline: none;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--accent-gold);
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px 24px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 24px;
    font-family: 'Caveat', cursive;
    font-size: 1.15rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.modal-btn-primary {
    background: var(--accent-gold);
    color: #fff;
}

.modal-btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.modal-btn-secondary {
    background: var(--cream-dark);
    color: var(--ink-color);
}

.modal-btn-secondary:hover {
    background: var(--cream-hover);
}

/* ============================================
   ПРЕВЬЮ ЦИТАТЫ / ЭКСПОРТА
============================================ */
.quote-preview-container {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.quote-canvas-wrap {
    border: 1px solid var(--cream-dark);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.quote-canvas-wrap canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.quote-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.quote-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cream-dark);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.quote-nav-btn:hover {
    background: var(--cream-hover);
    transform: scale(1.08);
}

.quote-nav-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--ink-color);
    stroke-width: 2;
    fill: none;
}

.quote-page-indicator {
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: var(--ink-light);
}

/* ============================================
   СТИКЕРЫ
============================================ */
.sticky-note {
    position: fixed;
    background: var(--sticky-yellow);
    padding: 18px 22px;
    box-shadow:
        3px 3px 12px rgba(0, 0, 0, 0.12),
        inset 0 -2px 4px rgba(0, 0, 0, 0.03);
    font-family: 'Caveat', cursive;
    font-size: 1.05rem;
    color: var(--ink-color);
    line-height: 1.5;
    max-width: 250px;
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    border-radius: 2px;
}

.sticky-note.visible {
    opacity: 1;
    pointer-events: auto;
}

.sticky-note::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 14px;
    background: rgba(180, 160, 100, 0.3);
    border-radius: 2px;
}

.sticky-note .close-sticky {
    position: absolute;
    top: 2px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--ink-light);
    cursor: pointer;
    opacity: 0.35;
    line-height: 1;
}

.sticky-note .close-sticky:hover {
    opacity: 0.7;
}

.sticky-arrow {
    display: inline-block;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.sticky-note.sticky-1 {
    top: 100px;
    left: 50px;
    transform: rotate(-2deg);
}

.sticky-note.sticky-2 {
    top: 100px;
    right: 120px;
    left: auto;
    transform: rotate(2deg);
}

.sticky-note.sticky-3 {
    bottom: 200px;
    left: 50px;
    transform: rotate(-1deg);
}

/* ============================================
   ПРИВЕТСТВЕННЫЙ ЭКРАН
============================================ */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-overlay);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.welcome-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-paper {
    background: var(--paper-color);
    width: 90%;
    max-width: 520px;
    padding: 42px;
    border-radius: 3px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    position: relative;
    transform: rotate(-1deg);
}

.welcome-title {
    font-family: 'Caveat', cursive;
    font-size: 2.2rem;
    color: var(--ink-color);
    margin-bottom: 22px;
    text-align: center;
}

.welcome-text {
    font-family: 'Caveat', cursive;
    font-size: 1.25rem;
    color: var(--ink-color);
    line-height: 1.7;
    margin-bottom: 12px;
}

.welcome-text span {
    color: var(--accent-gold);
    font-weight: 600;
}

.welcome-btn {
    display: block;
    margin: 32px auto 0;
    padding: 14px 50px;
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    color: var(--ink-color);
    background: var(--cream-dark);
    border: 2px solid var(--ink-light);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.welcome-btn:hover {
    background: var(--ink-color);
    color: var(--cream);
    border-color: var(--ink-color);
}

/* ============================================
   УВЕДОМЛЕНИЯ
============================================ */
.notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    padding: 12px 26px;
    background: var(--ink-color);
    color: var(--cream);
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    border-radius: 8px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
============================================ */
@media (max-width: 768px) {
    :root {
        --paper-padding-left: 75px;
        --margin-position: 55px;
        --paper-padding-right: 25px;
        --line-height: 28px;
    }

    .app-container {
        padding: 20px 15px 100px;
    }

    .story-header,
    .story-input {
        font-size: 16px;
    }

    .paper-holes {
        left: 15px;
        gap: 150px;
    }

    .paper-hole {
        width: 16px;
        height: 16px;
    }

    .paper-texture {
        background-size: 150px 150px;
    }

    .star-zone {
        width: 40px;
        height: 40px;
    }

    .star-zone .star-icon {
        width: 24px;
        height: 24px;
    }

    .star-zone.top-left {
        top: 35px;
        left: 10px;
    }

    .star-zone.bottom-left {
        bottom: 35px;
        left: 10px;
    }

    .star-zone.bottom-right {
        bottom: 35px;
        right: 10px;
    }

    .welcome-paper {
        padding: 28px 24px;
    }

    .welcome-title {
        font-size: 1.85rem;
    }

    .welcome-text {
        font-size: 1.12rem;
    }

    .sticky-note {
        font-size: 0.95rem;
        padding: 14px 16px;
        max-width: 200px;
    }

    .sticky-note.sticky-1 {
        top: 70px;
        left: 10px;
    }

    .sticky-note.sticky-2 {
        top: 200px;
        right: 10px;
        left: auto;
    }

    .sticky-note.sticky-3 {
        top: 330px;
        left: 10px;
    }

    .controls {
        bottom: 15px;
        right: 15px;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }

    .sidebar-arrow {
        width: 26px;
        height: 70px;
    }

    .sidebar {
        width: 85vw;
    }

    /* На мобильном hover не открывает сайдбар */
    .sidebar:hover {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open:hover {
        transform: translateX(0);
    }

    .settings-panel {
        width: 100vw;
    }

    .context-menu {
        min-width: 170px;
    }

    .modal-box {
        width: 95%;
    }
}