:root {
    --primary-blue: #3B5BDB;
    --primary-blue-light: #4C6EF5;
    --magic-purple: #845EF7;
    --magic-purple-light: #B197FC;
    --text-dark: #111827;
    --text-gray: #4B5563;
    --text-light: #9CA3AF;
    --bg-white: #FFFFFF;
    --bg-gray: #F8F9FA;
    --success-green: #10B981;
    --border-color: #E5E7EB;

    --gradient-magic: linear-gradient(135deg, var(--primary-blue) 0%, var(--magic-purple) 100%);
    --gradient-magic-hover: linear-gradient(135deg, var(--primary-blue-light) 0%, var(--magic-purple-light) 100%);

    --container-width: 1200px;
}

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

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-dark);
    background-color: var(--bg-gray);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Header */
header {
    background: white;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--primary-blue);
}

.logo-img {
    height: 32px;
    width: auto;
}

.logo span span {
    color: var(--magic-purple);
}

.back-link {
    color: var(--text-gray);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--primary-blue);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

/* Nav Dropdown */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.nav-dropbtn {
    background-color: transparent;
    color: var(--text-gray);
    padding: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s;
}

.nav-dropdown:hover .nav-dropbtn {
    color: var(--primary-blue);
}

.nav-dropdown-content {
    display: none;
    position: absolute;
    background-color: #ffffff;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.1);
    z-index: 1;
    border-radius: 8px;
    padding: 0.5rem 0;
    border: 1px solid var(--border-color);
    left: 50%;
    transform: translateX(-50%);
}

.nav-dropdown-content a {
    color: var(--text-dark);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s;
}

.nav-dropdown-content a:hover {
    background-color: var(--bg-gray);
    color: var(--primary-blue);
}

.nav-dropdown:hover .nav-dropdown-content {
    display: block;
}

/* Main Layout */
.calculator-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 3rem;
    padding-bottom: 4rem;
}

/* Inputs Section */
h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-gray);
    margin-bottom: 2.5rem;
}

.input-group {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.input-group h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--primary-blue);
}

.input-wrapper {
    margin-bottom: 1.75rem;
}

.input-wrapper:last-child {
    margin-bottom: 0;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.value-display {
    color: var(--primary-blue);
    font-weight: 700;
    font-family: monospace;
    font-size: 1.1rem;
}

.input-hint {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.range-hints {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.35rem;
}

/* Custom Slider */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #E5E7EB;
    border-radius: 99px;
}

input[type=range]::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #E5E7EB;
    border-radius: 99px;
}

input[type=range]::-webkit-slider-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-blue-light);
}

input[type=range]::-moz-range-thumb {
    height: 20px;
    width: 20px;
    border: none;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

input[type=range]::-moz-range-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-blue-light);
}

/* Weekend Toggle */
.toggle-wrapper {
    margin-top: 0.25rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.toggle-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-label {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-dark);
    display: block;
    margin-bottom: 0.25rem;
}

/* iOS-style toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #E5E7EB;
    transition: 0.3s;
    border-radius: 28px;
}

.slider-toggle:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

input:checked + .slider-toggle {
    background: var(--gradient-magic);
}

input:checked + .slider-toggle:before {
    transform: translateX(24px);
}

/* Results Section */
.sticky-results {
    position: sticky;
    top: 2rem;
    background: var(--text-dark);
    color: white;
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.sticky-results h2 {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Primary outputs — side by side */
.primary-outputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.result-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0;
}

.main-result {
    background: var(--gradient-magic);
    text-align: center;
    border: none;
    padding: 1.75rem 1rem;
    box-shadow: 0 10px 30px -5px rgba(132, 94, 247, 0.4);
}

.secondary-main {
    background: linear-gradient(135deg, #1e3a8a 0%, #5b21b6 100%);
    box-shadow: 0 10px 30px -5px rgba(91, 33, 182, 0.4);
}

.main-result .result-label {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.main-result .result-value {
    font-size: 2.75rem;
    font-weight: 800;
    display: block;
    line-height: 1;
}

.result-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 0.4rem;
}

/* Supporting math cards */
.results-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr;
    margin-top: 1rem;
}

.results-grid .result-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
}

.results-grid .result-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.65);
}

.results-grid .result-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.cta-box {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.cta-box p {
    margin-bottom: 1.25rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

.btn {
    display: inline-block;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    width: 100%;
    text-align: center;
}

.btn-primary {
    background: var(--gradient-magic);
    color: white !important;
}

.btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    z-index: 1002;
    position: relative;
    margin-left: auto;
}

.mobile-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background-color: var(--primary-blue);
    margin: 6px auto;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Responsive */
@media (max-width: 900px) {
    .calculator-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.75rem;
    }

    .sticky-results {
        padding: 1.5rem;
        position: static;
    }

    .main-result .result-value {
        font-size: 2.25rem;
    }

    .nav-links {
        display: block;
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: white;
        flex-direction: column;
        padding: 6rem 2rem 2rem;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
        text-align: left;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1001;
        overflow-y: auto;
    }

    .nav-links.active {
        right: 0;
        display: flex;
    }

    .mobile-toggle {
        display: block;
    }

    .nav-links a,
    .nav-dropbtn {
        display: block;
        font-size: 1.25rem;
        margin-bottom: 1.5rem;
        border-bottom: 1px solid #f3f4f6;
        padding-bottom: 0.5rem;
        width: 100%;
        text-align: left;
    }

    .nav-dropdown {
        display: block;
        width: 100%;
    }

    .nav-dropdown-content {
        position: static;
        box-shadow: none;
        border: none;
        padding-left: 1rem;
        transform: none;
        display: block;
        width: 100%;
    }

    .nav-dropdown-content a {
        font-size: 1rem;
        border-bottom: none;
        margin-bottom: 0.5rem;
        padding: 0.5rem 0;
    }

    .nav-container {
        flex-direction: row;
    }
}

@media (max-width: 480px) {
    .primary-outputs {
        grid-template-columns: 1fr;
    }
}
