/* ==========================================
   1. RESETS, FONTS & THEMES
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Theme 1: Dark Neon (Default Logo Match) */
:root, [data-theme="dark-neon"] {
    --bg-gradient: radial-gradient(circle at 50% 20%, #0d284c 0%, #071126 70%, #0b2545 100%);
    --card-bg: rgba(13, 27, 42, 0.75);
    --card-border: rgba(0, 242, 254, 0.25);
    --card-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 242, 254, 0.1);
    
    --text-primary: #ffffff;
    --text-accent: #00f2fe;
    --text-label: #00f2fe;
    
    --input-bg: rgba(6, 16, 33, 0.7);
    --input-border: rgba(0, 242, 254, 0.3);
    --input-text: #ffffff;
    
    --btn-bg: rgba(11, 25, 44, 0.7);
    --btn-border: rgba(0, 242, 254, 0.4);
    --btn-color: #00f2fe;
    
    --menu-bg: rgba(7, 17, 38, 0.95);
    --arrow-color: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%3c00f2fe' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

/* Theme 2: Light Teal (Classic Look) */
[data-theme="light-teal"] {
    --bg-gradient: linear-gradient(to bottom right, rgba(50, 150, 150, 0.5), rgba(20, 120, 200, 0.5));
    --card-bg: linear-gradient(to bottom right, rgba(174, 253, 227, 0.85), rgba(168, 217, 255, 0.85));
    --card-border: rgba(255, 255, 255, 0.6);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    
    --text-primary: #1e293b;
    --text-accent: #0284c7;
    --text-label: #334155;
    
    --input-bg: rgba(255, 255, 255, 0.85);
    --input-border: rgba(0, 0, 0, 0.15);
    --input-text: #1e293b;
    
    --btn-bg: rgba(255, 255, 255, 0.75);
    --btn-border: rgba(255, 255, 255, 0.6);
    --btn-color: #2c3e50;
    
    --menu-bg: rgba(241, 245, 249, 0.95);
    --arrow-color: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%3c334155' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

body {
    min-height: 100dvh;
    background: var(--bg-gradient);
    background-repeat: no-repeat;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    margin: 0;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

ul {
    list-style: none;
}

li {
    padding: 0.5em;
}

input[type="checkbox"] {
    display: none;
}

/* ==========================================
   2. MAIN LAYOUT & CALCULATOR CARDS
   ========================================== */
.container {
    min-height: 80vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
    transition: opacity 0.5s ease;
}

.container, main {
    flex: 1;
}

.section {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    justify-content: center;
    flex-direction: column;
    row-gap: 1.2em;
    padding: 1.5em;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    height: auto;
    margin: 1em auto;
    width: 90%;
    max-width: 450px;
    position: relative;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.calc-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.35em;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-align: left;
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
    word-wrap: break-word;
    flex: 1;
}

.title {
    font-family: 'Inter', sans-serif;
    font-size: 2.8em;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    text-align: center;
    margin: 1.5rem 0;
    text-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

.title span, 
.calc-title span {
    color: var(--text-accent);
    font-style: italic;
}

.section .title-wrapper {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-bottom: 0.5em;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5em;
    width: 100%;
}

.title-wrapper .calc-title {
    margin-bottom: 0;
}

/* Frosted Glass Help Button */
.help-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--btn-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid var(--btn-border);
    color: var(--btn-color);
    font-weight: bold;
    font-size: 1.1rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
    transition: transform 0.2s ease, background 0.2s ease;
    animation: helpPulse 1.8s infinite;
}

.help-btn:hover {
    transform: scale(1.08);
}

@keyframes helpPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.5);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 242, 254, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 242, 254, 0);
    }
}

/* Formula Modal Bubble */
.formula-bubble {
    position: absolute;
    top: 3.5rem;
    right: 1.5rem;
    left: 1.5rem;
    z-index: 100;
    background: var(--menu-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
}

.formula-bubble.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.formula-bubble h4 {
    color: var(--text-accent);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.formula-bubble p {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.8rem;
}

.formula-bubble code {
    display: block;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 0.5rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-accent);
    margin-bottom: 0.2rem;
}

.section div:not(.title-wrapper) {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3em;
}

.section label {
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-label);
    text-transform: uppercase;
}

.section input,
.section select {
    font-size: 16px;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--input-text);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--arrow-color);
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.section input:focus,
.section select:focus {
    border-color: var(--text-accent);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

.section input {
    background-image: none;
    padding-right: 0.75rem;
}

footer {
    text-align: center;
    padding: 16px;
    margin-top: auto;
    color: var(--text-primary);
    opacity: 0.6;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
    user-select: none;
}

footer p {
    margin: auto;
    color: var(--text-accent);
}

/* ==========================================
   3. NAVIGATION & THEMED FAB MENU
   ========================================== */
.navbar {
    height: auto;
    padding: 0.3em 0.3em;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.fab-menu-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    bottom: auto;
    right: auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--btn-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--btn-border);
    color: var(--btn-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.fab-menu-btn:hover {
    border-color: var(--text-accent);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

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

.menu {
    width: 14em;
    position: fixed;
    top: 65px;
    left: 12px;
    bottom: auto;
    padding: 0.75em;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    background: var(--menu-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transform: translateX(-110%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Theme Picker Control Styling Inside Menu */
.theme-picker-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5em;
    margin-bottom: 0.5em;
    border-bottom: 1px solid var(--card-border);
}

.theme-picker-wrapper label {
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text-primary);
}

.theme-picker-wrapper select {
    font-size: 0.85rem;
    padding: 0.3em 1.8em 0.3em 0.5em;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background-color: var(--input-bg);
    color: var(--input-text);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--arrow-color);
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 0.8em;
    cursor: pointer;
}

.label {
    height: 2.2em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.items:hover {
    background-color: rgba(0, 242, 254, 0.15);
    color: var(--text-accent);
    border-radius: 6px;
    transition: background-color 0.2s ease-in-out;
}

.arrow {
    font-size: 1.4em;
    color: var(--text-accent);
    display: inline-block;
    transition: transform 0.3s ease;
    transform: rotate(0deg);
}

.subMenu {
    opacity: 0;
    height: 0;
    overflow: hidden;
    padding-left: 0.8em;
    transition: all 0.3s ease;
}

/* ==========================================
   4. TOGGLE STATES & ANIMATIONS
   ========================================== */
.menuOpen:checked ~ .menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.menuOpen:checked ~ #main,
.menuOpen:checked ~ .container {
    opacity: 0.3;
    filter: brightness(0.5) blur(3px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.menuInput:checked ~ .subMenu {
    height: auto;
    opacity: 1;
    padding-top: 0.4em;
    padding-bottom: 0.4em;
}

.menuInput:checked ~ span.arrow {
    transform: rotate(180deg);
}

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

.show {
    display: flex;
    animation: fadeIn 0.4s ease-out forwards;
}

.subMenu .subMenu {
    padding-left: 12px;
    border-left: 1px solid rgba(0, 242, 254, 0.25);
    margin-left: 6px;
}

@media (max-height: 650px) {
    .section {
        padding: 1em;
        row-gap: 0.8em;
    }
}