/* --- CSS Variables для темы и лёгкого управления --- */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #7d8590;
    --accent-primary: #ff7b25;
    --accent-primary-hover: #ff8e43;
    --accent-secondary: #2eaadc;
    --success: #3fb950;
    --error: #f85149;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* --- Base Styles --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto Flex', 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-primary);
}

/* --- Header --- */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 200;
    /* Увеличиваем z-index шапки */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    height: 70px;
}

.logo a,
.logo {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.5rem;
    font-family: 'Montserrat', sans-serif;
}

/* --- Burger Menu --- */
.burger {
    cursor: pointer;
    width: 28px;
    height: 22px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* z-index: 1000; */
    /* Бургер должен быть выше всего */
}

.burger span {
    display: block;
    height: 3px;
    background: var(--accent-primary);
    border-radius: 3px;
    transition: var(--transition);
    transform-origin: center;
}

.burger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.burger.active span:nth-child(2) {
    opacity: 0;
    width: 0;
}

.burger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* --- Side Menu --- */
.side-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background: var(--bg-secondary);
    padding: 5rem 1.5rem 2rem 1.5rem;
    transform: translateX(100%);
    transition: transform 0.4s ease-in-out;
    z-index: 3;
    /* Меню ниже бургера, но выше основного контента */
    overflow-y: auto;
}

.side-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.side-menu ul li {
    margin-bottom: 0.75rem;
}

.side-menu ul li a {
    display: block;
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    border: 1px solid transparent;
}

.side-menu ul li a:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    border-color: rgba(255, 123, 37, 0.2);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    /* z-index: 800; */
    /* Оверлей ниже меню */
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

.side-menu.show {
    transform: translateX(0);
}

/* --- Main Page Tiles --- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.tile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.tile:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: 0 10px 30px rgba(255, 123, 37, 0.15);
}

.tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 123, 37, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: var(--transition);
}

.tile:hover::before {
    opacity: 1;
}

/* --- Sub Header & Tabs --- */
.sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    /* Такой же как у основной шапки */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    height: 70px;
    /* Фиксированная высота */
}

.tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    padding: 0.25rem;
    border-radius: var(--border-radius);
}

.tab {
    cursor: pointer;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    transition: var(--transition);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.tab.active {
    background: var(--accent-primary);
    color: #000;
    box-shadow: 0 0 10px rgba(255, 123, 37, 0.4);
}

.tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* --- Cipher Title --- */
.cipher-title {
    text-align: center;
    margin: 2rem 1rem;
    font-size: 2.2rem;
    color: var(--accent-primary);
    font-weight: 700;
    text-shadow: 0 2px 8px rgba(255, 123, 37, 0.3);
}

/* --- Tab Content --- */
.tab-content {
    padding: 1rem 1.5rem 3rem 1.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.tab-pane {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.tab-pane.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* --- Inputs & Buttons --- */
textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    resize: vertical;
    margin-bottom: 1.2rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(255, 123, 37, 0.2);
}

button {
    padding: 0.8rem 1.8rem;
    border: none;
    border-radius: var(--border-radius);
    background: var(--accent-primary);
    color: #000;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    display: inline-block;
    margin-bottom: 1.5rem;
}

button:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 123, 37, 0.3);
}

button:active {
    transform: translateY(0);
}

/* --- Result Box --- */
.result-box {
    margin-top: 1.5rem;
}

.result-box label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.result {
    padding: 1.2rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    min-height: 60px;
    border-left: 4px solid var(--success);
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.result.show {
    opacity: 1;
    transform: translateY(0);
}

.result.error {
    border-left-color: var(--error);
    background: rgba(248, 81, 73, 0.1);
}

/* Стили для переключателя */
.switch-container {
    margin-bottom: 1rem;
}

.switch {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 0.25rem;
}

.switch input[type="radio"] {
    display: none;
}

.switch label {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: var(--transition);
    flex: 1;
}

.switch input[type="radio"]:checked+label {
    background: var(--accent-primary);
    color: #000;
    box-shadow: 0 0 10px rgba(255, 123, 37, 0.4);
}

.switch label:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* --- Info Sections --- */
.info-section {
    margin-bottom: 2.5rem;
}

.info-section h2 {
    color: var(--accent-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(255, 123, 37, 0.3);
}

/* Steps */
.steps {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    color: #000;
    border-radius: 50%;
    font-weight: bold;
    flex-shrink: 0;
}

.step-content h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

/* Interactive Demo */
.interactive-demo {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.input-group input[readonly] {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

/* --- Adaptive / Mobile First --- */
@media (max-width: 768px) {
    .sub-header {
        flex-wrap: wrap;
        justify-content: space-between;
        height: auto;
        min-height: 70px;
        padding: 0.8rem 1rem;
    }

    .tabs {
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding: 0.5rem;
        -ms-overflow-style: none;
        scrollbar-width: none;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Улучшаем отступы */
    .tab-content {
        padding: 1rem;
    }

    /* Улучшаем кнопки */
    button {
        width: 100%;
        padding: 1rem;
    }

    /* Улучшаем шаги в описании */
    .step {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .step-number {
        margin-bottom: 0.5rem;
    }

    .cipher-title {
        font-size: 1.8rem;
        margin: 1.5rem 0.5rem;
    }
}

@media (max-width: 480px) {

    header,
    .sub-header {
        padding: 0.8rem 1rem;
    }

    .logo {
        font-size: 1.3rem;
    }

    .tiles {
        grid-template-columns: 1fr;
        padding: 1.5rem;
    }

    .tile {
        padding: 2rem 1rem;
        font-size: 1rem;
    }

    .info-section h2 {
        font-size: 1.3rem;
    }

    .interactive-demo {
        padding: 1rem;
    }
}