:root {
    --bg-gradient: linear-gradient(135deg, #1e1e2e 0%, #2d2d44 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --accent-color: #4b5efc;
    --accent-hover: #3b4cca;
    --btn-bg: rgba(255, 255, 255, 0.08);
    --btn-hover: rgba(255, 255, 255, 0.15);
    --sidebar-width: 70px;
    --history-width: 280px;
}

[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.4);
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --accent-color: #0984e3;
    --btn-bg: rgba(255, 255, 255, 0.5);
    --btn-hover: rgba(255, 255, 255, 0.8);
}

[data-theme="neon"] {
    --bg-gradient: linear-gradient(135deg, #09090b 0%, #1a1a2e 100%);
    --glass-bg: rgba(16, 16, 32, 0.8);
    --glass-border: rgba(0, 243, 255, 0.3);
    --text-primary: #00f3ff;
    --text-secondary: #bc92ff;
    --accent-color: #d600ff;
    --btn-bg: rgba(20, 20, 40, 0.6);
    --btn-hover: rgba(50, 50, 80, 0.8);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
}

[data-theme="pastel"] {
    --bg-gradient: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-primary: #5c4b51;
    --text-secondary: #8c7b81;
    --accent-color: #ff6b6b;
    --btn-bg: rgba(255, 255, 255, 0.6);
}

body {
    margin: 0;
    height: 100vh;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    display: flex;
    width: 95vw;
    height: 90vh;
    max-width: 1200px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    overflow: hidden;
    position: relative;
    transition: all 0.5s ease;
}

.sidebar {
    width: var(--sidebar-width);
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    border-right: 1px solid var(--glass-border);
    z-index: 10;
}

.nav-item {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: 0.3s;
    font-size: 1.2rem;
}

.nav-item:hover,
.nav-item.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.nav-item.bottom {
    margin-top: auto;
    margin-bottom: 20px;
}

.notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: #ff4757;
    border-radius: 50%;
}

.content-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-content {
    display: none;
    height: 100%;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

#programmer-tab,
#converter-tab {
    align-items: center;
    justify-content: center;
    width: 100%;
}

.tab-content.active {
    display: flex;
    animation: fadeIn 0.4s ease;
}

.display-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 20px;
    text-align: right;
    word-break: break-all;
}

.voice-indicator {
    align-self: flex-start;
    font-size: 0.9rem;
    color: var(--accent-color);
    margin-bottom: auto;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 12px;
    border-radius: 12px;
}

.voice-indicator.hidden {
    display: none;
}

.expression {
    font-size: 1.5rem;
    color: var(--text-secondary);
    min-height: 30px;
    margin-bottom: 5px;
}

.result {
    font-size: 4rem;
    font-weight: 300;
    line-height: 1.1;
}

.keyboard {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    gap: 15px;
    height: 60%;
}

.keys-scientific {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.keys-standard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.btn {
    border: none;
    outline: none;
    background: var(--btn-bg);
    color: var(--text-primary);
    font-size: 1.3rem;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.btn:hover {
    background: var(--btn-hover);
    transform: translateY(-2px);
}

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

.btn.operator {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.5rem;
}

.btn.special {
    background: var(--accent-color);
    color: white;
}

.btn.special:hover {
    filter: brightness(1.2);
}

.btn.action.red {
    color: #ff4757;
}

.btn.func {
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.05);
}

.section-title {
    text-align: center;
    font-weight: 300;
    margin-bottom: 30px;
}

.converter-types {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 40px;
}

.type-btn {
    padding: 10px 20px;
    border: none;
    background: var(--btn-bg);
    color: var(--text-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.type-btn.active {
    background: var(--accent-color);
    color: white;
}

.converter-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 95%;
}

.input-group {
    display: flex;
    width: 100%;
    gap: 10px;
}

.input-group input {
    flex: 2;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.2rem;
    outline: none;
}

.input-group select {
    flex: 1;
    padding: 10px;
    background: var(--btn-bg);
    border: none;
    color: var(--text-primary);
    border-radius: 12px;
    outline: none;
}

.input-group select option {
    background: #2d3436;
    color: white;
}

.icon-exchange {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.history-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: var(--history-width);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    display: flex;
    flex-direction: column;
}

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

.history-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    margin-left: 10px;
}

.history-actions button:hover {
    color: var(--text-primary);
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
}

.history-item {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.history-expression {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.history-result {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-gradient);
    padding: 30px;
    border-radius: 20px;
    width: 300px;
    text-align: center;
    border: 1px solid var(--glass-border);
}

.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 20px 0;
}

.theme-option {
    padding: 15px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

.theme-option:hover {
    transform: scale(1.05);
}

.btn-close {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
}

.mode-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 0.9rem;
    color: var(--accent-color);
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    border: 1px solid transparent;
    transition: 0.3s;
}

.mode-toggle:hover {
    background: var(--accent-hover);
    color: white;
    border-color: var(--glass-border);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    .sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        justify-content: space-around;
        padding: 0;
        order: 2;
        border-right: none;
        border-top: 1px solid var(--glass-border);
    }

    .nav-item {
        margin: 0;
    }

    .nav-item.bottom {
        margin: 0;
    }

    .keyboard {
        display: flex;
        flex-direction: column;
    }

    .keys-scientific {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        order: -1;
    }

    .keys-scientific .btn {
        padding: 10px 0;
        font-size: 0.8rem;
    }
}

.graph-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.graph-controls .input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-prefix {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
}

#graph-func {
    flex: 1;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: monospace;
}

#btn-plot {
    padding: 12px 24px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

#btn-plot:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.zoom-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.zoom-controls button {
    background: var(--btn-bg);
    color: var(--text-secondary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
}

.zoom-controls button:hover {
    background: var(--btn-hover);
    color: var(--text-primary);
}

.canvas-container {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    min-height: 400px;
}

#graph-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.prog-screen {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 5px;
    text-align: right;
    font-size: 2rem;
    font-family: monospace;
    color: var(--accent-color);
    min-height: 45px;
    overflow-x: auto;
    white-space: nowrap;
    width: 95%;
    max-width: 1000px;
    margin: 0 auto 5px auto;
}

.prog-display {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 95%;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.base-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid transparent;
}

.base-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.base-row.active {
    background: rgba(75, 94, 252, 0.2);
    border-color: var(--accent-color);
}

.base-label {
    font-weight: bold;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.base-value {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.base-row.active .base-label,
.base-row.active .base-value {
    color: var(--accent-color);
}

.prog-keyboard {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    height: auto;
    width: 95%;
    max-width: 1000px;
    margin: 0 auto;
}

.prog-keyboard .btn {
    font-size: 1rem;
    height: 45px;
    border-radius: 10px;
}

.btn.hex-btn {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.btn-disabled {
    opacity: 0.3;
    pointer-events: none;
}