:root {
    --bg-dark: #0a0b10;
    --bg-panel: rgba(22, 24, 32, 0.6);
    --bg-panel-border: rgba(255, 255, 255, 0.05);
    
    --text-primary: #e6e8eb;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7280;
    
    --accent: #5e8bc4;
    --accent-hover: #7bade6;
    --accent-glow: rgba(94, 139, 196, 0.3);
    
    --success: #34d399;
    --warning: #fbbf24;
    
    --font-heading: 'Cinzel', serif;
    --font-ui: 'Inter', sans-serif;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    /* Subtle background image/gradient for fantasy feel */
    background-image: 
        radial-gradient(ellipse at top right, rgba(20, 30, 50, 0.8), transparent 50%),
        radial-gradient(ellipse at bottom left, rgba(20, 25, 40, 0.8), transparent 50%);
    background-attachment: fixed;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: rgba(10, 11, 16, 0.8);
    border-right: 1px solid var(--bg-panel-border);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    padding: 0 1.5rem 2rem;
    border-bottom: 1px solid var(--bg-panel-border);
    margin-bottom: 1.5rem;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    letter-spacing: 2px;
    background: linear-gradient(to right, #cfdbec, #5e8bc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.nav-item {
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.nav-item:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border-left: 3px solid var(--accent);
}

.nav-item.active {
    background: rgba(94, 139, 196, 0.1);
    color: var(--text-primary);
    border-left: 3px solid var(--accent);
}

.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-item small {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--bg-panel-border);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
}

.top-header {
    margin-bottom: 3rem;
}

.top-header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px var(--accent-glow);
}

.top-header .subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Calculator Grid */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--bg-panel-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.panel h3 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--accent);
}

.panel h4 {
    font-size: 1.1rem;
    margin: 1.5rem 0 1rem;
    color: var(--text-secondary);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tooltip {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 10px;
    cursor: help;
    margin-left: 4px;
}

input[type="number"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 1rem;
    transition: var(--transition);
}

/* Custom chevron + inset from right edge (native arrow often hugs the border) */
select {
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%239aa0a6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1.5 1.5L6 6l4.5-4.5'/%3E%3C/svg%3E");
    width: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    padding-right: 2.75rem;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 1rem;
    transition: var(--transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: rgba(0, 0, 0, 0.6);
    background-image: var(--select-chevron);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Slider Customization */
.slider-group {
    margin-bottom: 1.5rem;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.value-display {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.8rem;
    border-radius: var(--radius-md);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    margin-top: 1rem;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid var(--accent);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 0 10px var(--accent-glow);
}

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

/* Toggle Switches */
.toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.toggle input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

.toggle:focus-within .toggle-slider {
    box-shadow: 0 0 0 2px var(--bg-dark), 0 0 0 4px var(--accent);
}

.toggle-slider {
    position: relative;
    width: 40px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    margin-right: 12px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    background: white;
    transition: var(--transition);
}

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

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

.toggle-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.toggle input:checked ~ .toggle-label {
    color: var(--text-primary);
}

/* Checkbox (Standard) */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.unofficial-patch-group {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Result Panel */
.result-panel {
    background: linear-gradient(135deg, rgba(22, 24, 32, 0.8), rgba(15, 17, 24, 0.9));
    border: 1px solid rgba(94, 139, 196, 0.3);
    position: sticky;
    top: 3rem;
}

.result-display {
    text-align: center;
    padding: 3rem 0;
    margin-bottom: 2rem;
    background: radial-gradient(circle at center, rgba(94, 139, 196, 0.1), transparent 70%);
}

.result-value {
    font-family: var(--font-heading);
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(to bottom right, #ffffff, #cfdbec, #5e8bc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--accent-glow);
    margin-bottom: 0.5rem;
}

.result-label {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    font-weight: 600;
}

.result-fixed-wrap {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(94, 139, 196, 0.2);
}

.result-fixed-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.result-fixed-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.formula-breakdown {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breakdown-row {
    display: contents;
}

.breakdown-row.total {
    font-weight: 600;
    color: var(--text-primary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 0.5rem;
}

.breakdown-value {
    text-align: right;
    font-family: monospace;
    color: var(--accent);
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 1rem 2rem;
        position: relative;
    }

    .sidebar-header {
        margin: 0;
        padding: 0 2rem 0 0;
        border-bottom: none;
        border-right: 1px solid var(--bg-panel-border);
    }
    
    .sidebar-nav {
        flex-direction: row;
        gap: 1rem;
        margin-left: 2rem;
    }
    
    .nav-item {
        padding: 0.5rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .nav-item:hover:not(.disabled), .nav-item.active {
        border-left: none;
        border-bottom-color: var(--accent);
    }
    
    .sidebar-footer {
        display: none;
    }

    .main-content {
        padding: 2rem;
    }
}
