:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --card-bg: #ffffff;
    --sidebar-bg: #343a40;
    --link-color: #e9ecef;
    --highlight: #4361ee;
    --highlight-hover: #3a56d4;
    --success: #4cc9f0;
    --danger: #f72585;
    --warning: #fca311;
    --info: #4895ef;
    --easy-color: #2ecc71;
    --medium-color: #f39c12;
    --hard-color: #e74c3c;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: all 0.3s ease;
    --sidebar-width: 280px;
}

.dark-theme {
    --bg-color: #121212;
    --text-color: #e9ecef;
    --card-bg: #1e1e1e;
    --sidebar-bg: #0d0d0d;
    --link-color: #ced4da;
    --highlight: #4cc9f0;
    --highlight-hover: #3a56d4;
    --easy-color: #27ae60;
    --medium-color: #d35400;
    --hard-color: #c0392b;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    min-height: 100vh;
    transition: var(--transition);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================ */
/* ===== SIDEBAR ===== */
/* ============================================ */
#sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--link-color);
    padding: 24px 20px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease, var(--transition);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Контейнер для логотипа в сайдбаре */
.sidebar-brand {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
}

.brand-logo {
    height: 48px;
    width: auto;
    display: block;
    user-select: none;
    pointer-events: none;
}

body.dark-theme .brand-logo {
    filter: brightness(1.08);
}

#sidebar a {
    color: var(--link-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 6px 0;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#sidebar a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
    color: var(--highlight);
}

#sidebar a span {
    margin-left: 12px;
}

/* ============================================ */
/* ===== MAIN CONTENT ===== */
/* ============================================ */
#mainContent {
    margin-left: var(--sidebar-width);
    padding: 30px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 60px;
    transition: var(--transition);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

/* ============================================ */
/* ===== BURGER MENU (для мобильных) ===== */
/* ============================================ */
.burger-menu {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: var(--highlight);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.burger-menu:hover {
    background: var(--highlight-hover);
    transform: scale(1.05);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================ */
/* ===== HEADINGS ===== */
/* ============================================ */
h1 {
    color: var(--text-color);
    margin-top: 0;
    margin-bottom: 24px;
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    word-break: break-word;
}

/* ============================================ */
/* ===== MODALS ===== */
/* ============================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    overflow-y: auto;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalFadeIn 0.3s;
}

.modal-content .close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 20px;
    transition: var(--transition);
}

.modal-content .close:hover {
    color: var(--text-color);
}

.language-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    margin-bottom: 6px;
}

.language-option:hover {
    border-color: var(--highlight);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.language-option.active {
    border-color: var(--highlight);
    background-color: rgba(67, 97, 238, 0.1);
}

.language-option .flag {
    font-size: 24px;
    width: 30px;
    text-align: center;
}

.language-option .language-name {
    flex: 1;
    font-size: 16px;
}

@keyframes modalFadeIn {
    from {opacity: 0; transform: translateY(-30px);}
    to {opacity: 1; transform: translateY(0);}
}

/* ============================================ */
/* ===== CONTROLS ===== */
/* ============================================ */
#controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    justify-content: center;
    width: 100%;
    max-width: 800px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.05);
    flex-wrap: wrap;
    justify-content: center;
}

.control-group:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.control-group label {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
}

select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,0.1);
    font-size: 14px;
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    min-width: 80px;
}

select:focus {
    outline: none;
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

/* ============================================ */
/* ===== TIMER ===== */
/* ============================================ */
#timer {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 24px;
    margin: 16px 0;
    font-weight: 700;
    text-align: center;
    padding: 12px 24px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    display: inline-block;
    min-width: 120px;
    box-shadow: var(--shadow-sm);
    color: var(--highlight);
}

/* ============================================ */
/* ===== QUOTE ===== */
/* ============================================ */
#quote-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 12px;
    transition: var(--transition);
}

#quote {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    line-height: 1.8;
    font-size: 18px;
    height: 180px;
    max-height: 250px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 16px;
    transition: opacity 0.25s ease, transform 0.25s ease, var(--transition);
    border: 1px solid rgba(0,0,0,0.05);
    scroll-behavior: smooth;
    position: relative;
    scrollbar-width: thin;
    scrollbar-color: rgba(67, 97, 238, 0.5) rgba(0,0,0,0.1);
}

#quote.fading {
    opacity: 0;
    transform: translateY(-8px);
}

#quote.appearing {
    animation: quoteAppear 0.3s ease forwards;
}

@keyframes quoteAppear {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

#quote::-webkit-scrollbar {
    width: 6px;
}

#quote::-webkit-scrollbar-track {
    background: transparent;
}

#quote::-webkit-scrollbar-thumb {
    background-color: rgba(67, 97, 238, 0.3);
    border-radius: 3px;
}

#quote::-webkit-scrollbar-thumb:hover {
    background-color: rgba(67, 97, 238, 0.5);
}

#quote span {
    white-space: pre-wrap;
    transition: all 0.1s ease;
    position: relative;
}

#quote span.correct {
    color: var(--easy-color);
}

#quote span.incorrect {
    color: var(--hard-color);
    text-decoration: underline;
    background-color: rgba(247, 37, 133, 0.1);
    border-radius: 2px;
}

#quote span.current {
    background-color: rgba(76, 201, 240, 0.3);
    border-radius: 2px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { background-color: rgba(76, 201, 240, 0.3); }
    50% { background-color: rgba(76, 201, 240, 0.5); }
    100% { background-color: rgba(76, 201, 240, 0.3); }
}

/* ============================================ */
/* ===== REFRESH BUTTON ===== */
/* ============================================ */
#refresh-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    margin: 0;
    background: var(--card-bg);
    color: var(--highlight);
    border: 2px solid var(--highlight);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    font-size: 22px;
    line-height: 1;
}

.refresh-btn:hover {
    background: var(--highlight);
    color: white;
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.refresh-btn:active,
.refresh-btn.active {
    transform: scale(0.94);
}

.refresh-btn .refresh-icon {
    display: inline-block;
    transition: transform 0.4s ease;
    font-weight: 700;
}

.refresh-btn .refresh-icon.spinning {
    animation: spinRefresh 0.5s ease;
}

@keyframes spinRefresh {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* ===== TEXTAREA ===== */
/* ============================================ */
#input-container {
    width: 100%;
    max-width: 800px;
    margin: 16px 0 24px;
    position: relative;
}

textarea {
    width: 100%;
    height: 160px;
    font-size: 20px;
    padding: 18px 20px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    color: var(--text-color);
    margin-top: 10px;
    transition: box-shadow 0.18s ease, transform 0.12s ease;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    box-shadow:
        0 8px 24px rgba(2,6,23,0.06),
        inset 0 1px 0 rgba(255,255,255,0.02),
        0 1px 0 rgba(255,255,255,0.02);
    resize: none;
    line-height: 1.6;
    outline: none;
    caret-color: var(--highlight);
    -webkit-font-smoothing: antialiased;
}

textarea:focus, textarea:active {
    transform: translateY(-2px);
    box-shadow:
        0 18px 36px rgba(67,97,238,0.08),
        inset 0 1px 0 rgba(255,255,255,0.02);
}

textarea::placeholder {
    color: rgba(33,37,41,0.45);
    font-weight: 500;
}

textarea[disabled] {
    opacity: 0.8;
    filter: grayscale(0.02);
}

/* ============================================ */
/* ===== PROGRESS BAR ===== */
/* ============================================ */
#progress-bar {
    height: 8px;
    background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.03));
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}

#progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--highlight), var(--success));
    transition: width 0.12s linear;
}

/* ============================================ */
/* ===== RESULTS ===== */
/* ============================================ */
#results {
    margin: 24px 0;
    text-align: center;
    width: 100%;
    max-width: 800px;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.result-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.result-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.result-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--highlight);
    margin-bottom: 8px;
}

.result-label {
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.8;
    font-weight: 500;
}

/* ============================================ */
/* ===== BUTTONS ===== */
/* ============================================ */
button {
    padding: 14px 28px;
    font-size: 16px;
    border: none;
    border-radius: var(--radius-md);
    background-color: var(--highlight);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    margin: 10px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    touch-action: manipulation;
}

button:hover {
    background-color: var(--highlight-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button:active {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.refresh-btn {
    padding: 0;
    margin: 0;
}

/* ============================================ */
/* ===== HISTORY ===== */
/* ============================================ */
#history {
    margin-top: 32px;
    max-width: 800px;
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-md);
    width: 100%;
    box-shadow: var(--shadow-sm);
}

#history h3 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    font-size: 20px;
    font-weight: 600;
}

.history-item {
    padding: 16px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background-color: rgba(0,0,0,0.02);
    border-radius: var(--radius-sm);
}

/* ============================================ */
/* ===== AUTH SECTION ===== */
/* ============================================ */
#auth-section {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

#auth-section button {
    width: 100%;
    margin: 8px 0;
    padding: 12px;
}

#auth-link button {
    width: 100%;
    margin: 8px 0;
    padding: 12px;
    background-color: var(--highlight);
    color: white;
}

#user-info p {
    color: white;
    margin-bottom: 16px;
    word-break: break-word;
}

/* ============================================ */
/* ===== NO COPY MESSAGE ===== */
/* ============================================ */
.no-copy-message {
    position: fixed;
    background: var(--danger);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    animation: fadeOut 2s forwards;
    pointer-events: none;
    box-shadow: var(--shadow-lg);
}

@keyframes fadeOut {
    0% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

/* =============================================== */
/* ===== АДАПТИВНЫЙ ДИЗАЙН ===== */
/* =============================================== */

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 250px;
    }
    
    #sidebar {
        width: var(--sidebar-width);
        padding: 20px 16px;
    }
    
    .brand-logo {
        height: 40px;
    }
    
    #sidebar a {
        font-size: 15px;
        padding: 10px 14px;
    }
    
    #mainContent {
        margin-left: var(--sidebar-width);
        padding: 24px;
    }
    
    h1 {
        font-size: 28px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
    
    .burger-menu {
        display: block !important;
    }
    
    #sidebar {
        width: 280px;
        transform: translateX(-100%);
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        padding: 20px 16px;
        box-shadow: var(--shadow-lg);
        transition: transform 0.3s ease;
    }
    
    #sidebar.open {
        transform: translateX(0);
    }
    
    #mainContent {
        margin-left: 0;
        padding: 16px 12px;
        padding-top: 70px;
        width: 100%;
    }
    
    h1 {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .brand-logo {
        height: 36px;
    }
    
    h1 {
        font-size: 20px;
    }
}