:root {
    --bg-dark: #000000;
    --bg-glass: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.12);
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --text-primary: #ffffff;
    --text-secondary: rgba(235, 235, 245, 0.6);
    --error: #FF453A;
    --success: #32D74B;
    --gradient-1: #FF2A6D;
    --gradient-2: #05D5FF;
    --gradient-3: #5E5CE6;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Background */
.background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -1;
    background-color: #030406;
}

.blob {
    position: absolute;
    /* Removed filter: blur to prevent artifacts */
    border-radius: 50%;
    transform-origin: center center;
    mix-blend-mode: screen;
}

.blob-1, .blob-2, .blob-3 {
    width: 600px;
    height: 600px;
    top: 0;
    left: 0;
}

.blob-1 {
    background: radial-gradient(circle, rgba(10, 132, 255, 0.6) 0%, transparent 70%); /* Голуба */
}

.blob-2 {
    background: radial-gradient(circle, rgba(255, 42, 109, 0.6) 0%, transparent 70%); /* Рожева */
}

.blob-3 {
    background: radial-gradient(circle, rgba(157, 78, 221, 0.6) 0%, transparent 70%); /* Фіолетова */
}

/* Top Controls */
.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 10px;
    align-items: center;
}

.exit-btn {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.3);
    color: var(--error);
    padding: 8px 10px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.exit-btn:hover {
    background: rgba(255, 77, 77, 0.25);
    color: white;
}

/* Lang Selector */
.lang-selector {
    position: relative;
}
.lang-btn {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}
.lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(15, 17, 21, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    list-style: none;
    width: 160px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}
.lang-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease;
}
.lang-dropdown li {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.lang-dropdown li:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Layout Wrapper */
.layout-wrapper {
    display: flex;
    flex-direction: row;
    gap: 40px;
    align-items: stretch;
    justify-content: center;
    width: 90%;
    max-width: 1100px;
    z-index: 10;
}

/* Glassmorphism App Container */
.app-container, .table-card {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.1) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 32px;
    padding: 40px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s ease;
}

.app-container {
    flex: 1;
    width: 100%;
    max-width: 420px;
    z-index: 10;
}

.table-card {
    flex: 1;
    width: 100%;
    max-width: 600px;
    padding: 30px;
    display: none;
    position: relative;
    flex-direction: column;
}

.table-card.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.app-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
    margin-bottom: 15px;
    box-shadow: 0 10px 20px rgba(255, 51, 102, 0.3);
}

.logo svg {
    color: white;
}

h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

p {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
}

/* Form Styles */
.calc-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.help-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: 8px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    transition: color 0.2s;
}

.help-btn:hover {
    color: var(--accent);
}

.input-wrapper, .select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="number"], select:not(.unit-select) {
    width: 100%;
    background: rgba(118, 118, 128, 0.24);
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 17px;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    outline: none;
    transition: all 0.2s ease;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"]:focus, select:not(.unit-select):focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
    background: rgba(118, 118, 128, 0.35);
}

.unit, .unit-toggle {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.unit {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    pointer-events: none;
}

.unit-toggle {
    background: rgba(10, 132, 255, 0.15);
    color: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    right: 12px;
}

.unit-toggle:hover {
    background: rgba(10, 132, 255, 0.25);
    transform: translateY(-50%) scale(1.05);
}

select {
    appearance: none;
    padding-right: 40px;
    cursor: pointer;
}

select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.select-icon {
    position: absolute;
    right: 16px;
    width: 16px;
    height: 16px;
    pointer-events: none;
    color: var(--text-secondary);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(0.98);
}

.calc-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Results */
.result-box {
    max-height: 0;
    margin-top: 0;
    padding: 0 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 16px;
    text-align: center;
    opacity: 0;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-box.show {
    max-height: 250px;
    margin-top: 20px;
    padding: 20px;
    opacity: 1;
    border-color: var(--border-glass);
}

.result-box h3 {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.result-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
}

#max-result {
    font-size: 48px;
    font-weight: 800;
    color: var(--text-primary);
}

.result-unit {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
}

.result-value-alt {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 8px;
    margin-top: 5px;
    opacity: 0.7;
}

#max-result-alt {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.error-box {
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.3);
    border-radius: 8px;
    color: var(--error);
    font-size: 14px;
    text-align: center;
    display: none;
}

.error-box.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Reference Table styles */
.table-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 10px;
    text-align: center;
    color: var(--text-primary);
}

.table-help {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
    text-align: center;
}

.close-btn {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

.close-btn:hover {
    color: var(--accent);
}

.modal-backdrop {
    display: none;
}

.glass-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    overflow: hidden;
    font-size: 13px;
    flex: 1;
}

.glass-table th, .glass-table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.glass-table th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-weight: 600;
}

.glass-table td {
    color: var(--text-secondary);
}

.glass-table th[colspan="3"] {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.glass-table th:first-child, .glass-table td:first-child {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-primary);
}

/* Highlights */
.highlight-header {
    background: rgba(10, 132, 255, 0.2) !important;
    color: #fff !important;
}

.highlight-cell {
    background: rgba(10, 132, 255, 0.3) !important;
    color: #fff !important;
    font-weight: 800 !important;
}



/* Responsive Design */
@media screen and (max-width: 900px) {
    .table-card {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) !important;
        width: 95%;
        max-width: 480px;
        z-index: 1000;
        padding: 30px 20px;
    }
    
    .table-card.show {
        display: flex;
        animation: fadeInMobile 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    @keyframes fadeInMobile {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .close-btn {
        display: block;
    }
    
    .modal-backdrop.show {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(5px);
        z-index: 999;
    }
    
    .app-container {
        padding: 24px 20px;
        width: 95%;
        border-radius: 16px;
    }
    
    .glass-table {
        font-size: 12px;
    }
    .glass-table th, .glass-table td {
        padding: 8px 5px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .logo {
        width: 48px;
        height: 48px;
    }
    
    .calc-form {
        gap: 16px;
    }
    
    input[type="number"], select {
        padding: 12px 14px;
        font-size: 15px;
    }
    
    .btn-primary {
        padding: 14px;
        font-size: 15px;
    }
    
    #max-result {
        font-size: 38px;
    }
}
