:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-primary: #00b894;
    --accent-secondary: #00cec9;
    --danger: #ff7675;
    --chart-grid: #333;
    --input-bg: #2d2d2d;
    --border-color: #404040;
}

@keyframes backgroundPulse {
    0% {
        transform: scale(2);
        opacity: 0;
    }
    20% {
        transform: scale(2.5);
        opacity: 0.5;
    }
    60% {
        transform: scale(4);
        opacity: 0.5;
    }
    70% {
        transform: scale(4);
        opacity: 0;
    }
    /* The 70% to 99.99% segment is a hold, so no additional keyframes needed there for smoothness of change */
    100% {
        transform: scale(1);
        opacity: 0;
    }

}

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

/* Hide main browser scrollbar */
html::-webkit-scrollbar {
    display: none; /* For WebKit browsers (Chrome, Safari, Edge, etc.) */
}
html {
    overflow-y: scroll; /* Ensure scrolling is possible even if bar hidden */
    -ms-overflow-style: none;  /* For Internet Explorer and Edge */
    scrollbar-width: none;  /* For Firefox */
}

/* Override styles to show scrollbar when class is present */
html.show-scrollbar::-webkit-scrollbar {
    display: block; /* Or initial/auto */
}
html.show-scrollbar {
    -ms-overflow-style: scrollbar; /* Or auto */
    scrollbar-width: auto;  /* Or thin/auto */
}

html.no-scroll {
    overflow-y: hidden; /* Hide vertical scrollbar on html when class is present */
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Remove existing body::before and body::after if they exist */
/* body::before { ... } */
/* body::after { ... } */

/* Ensure these are fully removed if they were present from previous attempts */

#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* Use viewport units to ensure full coverage */
    height: 100vh;
    pointer-events: none; /* Allows clicks to pass through to elements behind it */
    z-index: 0; /* Position it behind most content but above default body background. Adjust if needed. */
    display: block; /* Avoids potential inline spacing issues */
}

@keyframes backgroundPulse {
    0% {
        transform: scale(2);
        opacity: 0;
    }
    20% {
        transform: scale(2.5);
        opacity: 0.5;
    }
    60% {
        transform: scale(4);
        opacity: 0.5;
    }
    70% {
        transform: scale(4);
        opacity: 0;
    }
    /* The 70% to 99.99% segment is a hold, so no additional keyframes needed there for smoothness of change */
    100% {
        transform: scale(1);
        opacity: 0;
    }

}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-primary); /* Changed from transparent */
    padding: 1rem 2rem;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    /* backdrop-filter: blur(5px); Removed */
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.header.scrolled {
    padding: 0.5rem 2rem;
}

.header.scrolled h1 {
    font-size: 2.4rem;
}

.container {
    /* max-width: 1400px; REMOVED */
    /* margin: 2rem auto; REMOVED auto margin */
    margin-top: 5rem; /* RESTORED top margin */
    padding: 3rem 2rem 0.5rem 2rem; /* Keep padding */
    background-color: var(--bg-primary); /* Ensure container bg matches body */
    /* border-radius: 8px; Optional: Remove radius if it looks odd full-width */
    /* Removed box-shadow as header has one */
}

.container.has-content {
    min-height: calc(100vh - 7rem);
}

/* Styles for the fullscreen toggle - NOW INDEPENDENTLY FIXED */
.fullscreen-toggle {
    position: fixed; /* Added back */
    top: 0.5rem; /* Position near top */
    right: 2rem; /* Position near right */
    z-index: 1001; /* Ensure it's on top */
    /* background-color, color, padding etc. remain */
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 2px 2px;
    margin-right: 1.6rem;
    margin-bottom: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.2s ease, transform 0.1s ease; /* Removed top/right transition */
    margin-bottom: 2px; /* Added small gap below button */
}

.fullscreen-toggle:hover {
    background-color: var(--button-hover-bg);
}

.fullscreen-toggle:active {
    transform: scale(0.98);
}

/* Styles for the tier logo GIF - NOW INSIDE A FIXED CONTAINER */
#tier-logo {
    /* position: fixed; REMOVED */
    /* top: 1rem; REMOVED */
    /* right: 1rem; REMOVED */
    margin-top: 2px;
    width: 52px; /* 20% larger than 36px */
    height: auto; /* Maintain aspect ratio */
    /* z-index: 1001; REMOVED - Handled by parent */
}

/* Styles for the container holding fixed elements THAT FADE */
#tier-info-container {
    position: fixed;
    top: calc(2.5rem - 10px); /* Adjust top slightly */
    /* margin-top: 1rem; */ /* Corrected comment */
    right: 2rem;
    z-index: 1001;
    display: flex;
    flex-direction: column; /* Stack Subscription and the row below */
    align-items: flex-end;   /* Align items to the right */
    gap: 0px; /* Adjust gap */
    opacity: 1;
    transition: opacity 0.15s ease-out;
}

#tier-info-container.faded-out {
    opacity: 0;
    pointer-events: none;
}

/* NEW: Styles for the horizontal row */
.credit-logo-tier-row {
    display: flex;
    align-items: center; /* Vertically align credit, logo, text */
    gap: 8px; /* Space between credit, logo, text */
}

/* Existing Subscription label styles */
#subscription-label {
    display: block; /* Ensure it takes full width */
    text-align: right; /* Align text right */
    margin-bottom: 2px; /* Small space below */
    margin-right: 3rem;
}


/* Credit display styles */
#credit-display {
    /* Ensure correct color and size */
    color: var(--accent-primary);
    font-size: 0.82rem;
    line-height: 1.1;
    /* Remove specific positioning */
    position: static;
    margin-top: 0;
    margin-right: 0;
}

/* Logo row within the new horizontal row */
.logo-text-row {
    /* Keep its internal flex display */
    display: flex;
    align-items: center;
    gap: 0px;
    /* Remove positioning relative to parent */
    position: static;
    top: auto;
    align-self: auto;
}

#tier-logo {
     width: 52px;
     height: auto;
}

.text-column {
    /* Keep internal flex */
    display: flex;
    flex-direction: column;
    position: static;
    top: auto;
}

#tier-info-container .tier-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.1;
}


/* --- Scrolled State Controls --- */
#scrolled-controls-container {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 1rem;
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    z-index: 1002;
}

.header.scrolled #scrolled-controls-container {
    display: flex !important; /* Show when scrolled (Forced) */
}

#scrolled-controls-container .fullscreen-toggle {
    position: static;
    margin: 0;
    padding: 2px 4px;
    font-size: 0.75rem;
}

#scrolled-credit-display {
    font-size: 0.75rem;
    text-align: right;
    color: var(--accent-primary);
    display: block !important; /* Ensure it's always visible in scrolled state */
    opacity: 1 !important;
    visibility: visible !important;
    margin-right: 3rem;
    margin-top: 0.5rem;
}

/* Remove fixed positioning from original fullscreen toggle if still present */
.fullscreen-toggle {
   /* Base styles */
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 2px 2px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.2s ease, transform 0.1s ease;
    /* Removed fixed positioning properties */
}

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400&display=swap');

h1 {
    font-size: 3.4rem;
    font-weight: 300;
    font-family: 'Quicksand', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: block;
    background-image: linear-gradient(135deg, 
        #00cec9 0%,
        #00b894 5%,
        #00b894 10%,
        #ff8866 30%,
        #ff4444 35%, 
        #ff4444 40%,
        #ff8866 45%,
        #00b894 60%,
        #00b894 75%,
        #00cec9 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    margin: 0;
    letter-spacing: -0.01em;
    position: relative;
    text-shadow: 0 0 30px rgba(0, 184, 148, 0.1);
    animation: titleGlow 10s ease-in-out infinite alternate;
    transition: font-size 0.3s ease;
    line-height: 1;
    margin-bottom: -0.2rem;
}

.subtitle {
    display: block;
    font-size: 0.8rem;
    color: rgba(160, 160, 160, 0.7);
    font-weight: 300;
    margin-top: 0.15rem;
    margin-left: 0.2rem;
    font-family: 'Quicksand', sans-serif;
    transition: all 0.3s ease, opacity 0.5s ease-in-out;
    line-height: 1;
    opacity: 1;
}

.header.scrolled .subtitle {
    font-size: 0.7rem;
}

.header-description {
    display: inline-block;
    margin-left: 2rem;
    padding-left: 0;
    font-size: 0.78rem;
    color: rgb(158, 158, 158);
    font-weight: 300;
    vertical-align: middle;
    opacity: 1;
    transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
    user-select: none;
    white-space: nowrap;
    line-height: 1;
    visibility: visible;
}

.header.scrolled .header-description {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
    pointer-events: none;
}

@keyframes titleGlow {
    0% {
        text-shadow: 0 0 30px rgba(0, 184, 148, 0.1);
    }
    100% {
        text-shadow: 0 0 50px rgba(0, 184, 148, 0.2);
    }
}

/* Ensure the gradient animation works smoothly */
@media (prefers-reduced-motion: no-preference) {
    h1 {
        background-size: 200% auto;
        animation: titleGlow 5s ease-in-out infinite alternate,
                   gradientFlow 20s ease infinite;
    }
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

h2, h3 {
    color: var(--text-primary);
    font-weight: 400;
    margin: 1.5rem 0;
}

.stock-input-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0;
    flex-wrap: wrap;
    min-height: fit-content;
}

.stock-input-group.has-price {
    margin-bottom: 2rem;
}

.mini-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.input-label {
    color: var(--text-secondary);
    font-weight: 500;
}

#stockTicker {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-size: 1rem;
    width: 120px;
}

.price-isin-display {
    font-size: 1.1rem;
    color: var(--accent-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
    line-height: 1.4;
}

.price-isin-display.visible {
    opacity: 1;
}

.price-isin-display .display-row-1,
.price-isin-display .display-row-2 {
    display: block;
    margin-bottom: 0.2rem;
}

.price-isin-display .display-row-2 {
    font-size: 1.0rem;
}

.ticker-error {
    color: #ffd700;
    font-size: 0.9rem;
    margin-top: 0.3rem;
    padding: 0.2rem 0.5rem;
    background-color: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 4px;
    display: none;
    line-height: 1.2;
    min-height: unset;
}

button {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

button:hover:not(:disabled) {
    background-color: var(--accent-secondary);
    transform: translateY(-1px);
}

button:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.7;
}

.stop-btn {
    background-color: var(--danger);
}

.stop-btn:hover {
    background-color: #ff8b8b;
}

.analysis-section {
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.analysis-section.visible {
    opacity: 1;
    display: block;
}

#probabilityGraphContainer, #riskToleranceSection, #searchParametersSection, #availableOptionsContainer {
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

#probabilityGraphContainer.visible, #riskToleranceSection.visible, #searchParametersSection.visible, #availableOptionsContainer.visible {
    opacity: 1;
    pointer-events: auto;
}

select, input[type="number"], input[type="text"] {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 200px;
}

select:disabled, input:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.graph-container {
    background-color: transparent;
    border: none;
    padding: 1.5rem;
    margin: 2rem 0;
    /* height: 450px; */ /* REMOVED height */
    position: relative;
    clear: both;
}

/* Hide the default graph info text */
.graph-info {
    /*
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
    */
    display: none; /* Ensure this is hidden */
}

.parameter-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
}

.parameter-group label {
    min-width: 100px;
}

#stepsContainer, #customWeightsContainer {
    display: none;
    margin-left: -0.5rem;
    align-items: center;
}

#stepsContainer.visible, #customWeightsContainer.visible {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.weight-selection-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.weight-label {
    display: inline-block;
    white-space: nowrap;
}

.console-window {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: #00ff00;
    font-family: 'Consolas', monospace;
    padding: 1rem;
    height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: all 0.3s ease;
    margin: 1rem 0;
    /* Webkit scrollbar styling */
    &::-webkit-scrollbar {
        width: 12px;
        background-color: var(--bg-primary);
    }
    &::-webkit-scrollbar-thumb {
        background-color: var(--border-color);
        border-radius: 6px;
        border: 2px solid var(--bg-primary);
    }
    &::-webkit-scrollbar-track {
        background-color: var(--bg-primary);
    }
    /* Firefox scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-primary);
}

.console-window.expanded {
    height: 80vh;
    width: 95vw;
    position: fixed;
    top: 10vh;
    left: 2.5vw;
    z-index: 1000;
    background-color: rgba(36, 36, 36, 0.95);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.console-toggle {
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 0.9rem;
}

.console-close-btn {
    background-color: var(--danger);
    color: var(--text-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: fixed;
    top: 12vh;
    right: 4vw;
    z-index: 1010;
    font-size: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.console-window.expanded + .console-close-btn {
    display: flex;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-container {
    background-color: var(--bg-secondary);
    border-radius: 4px;
    height: 8px;
    margin: 1.5rem 0;
    overflow: hidden;
}

.progress-bar {
    background-color: var(--accent-primary);
    height: 100%;
    transition: width 0.3s ease;
}

.warning-message {
    background-color: rgba(255, 118, 117, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.chart-container {
    background-color: transparent;
    border: none;
    padding: 1.5rem;
    margin: 1.5rem 0;
    min-height: 600px;
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
}

#resultChart {
    flex: 1;
    width: 100%;
    height: 100%;
    /* min-height: 550px; REMOVED min-height */
}

#bsChartContainer {
    background-color: transparent;
    border: none;
    padding: 1.5rem;
    margin: 1.5rem 0;
    margin-bottom: 100px;
}

.risk-tolerance-section {
    margin-top: 6rem;
    position: relative;
    clear: both;
}

#riskToleranceSection {
    margin-top: 6rem;
}

#probabilityGraphContainer, #riskToleranceSection {
    margin: 2rem 0;
}

/* Chart.js customization */
canvas {
    filter: none;
}

.date-select-container {
    /* Styles for being inside stock-input-group */
    margin-top: 0; 
    margin-bottom: 0; 
    padding: 0; 
    width: auto; 
    min-width: 250px; 
    /* flex-shrink: 0; */ /* Not needed inside default flex */
    /* margin-left: 2rem; is set inline for now */
}

.date-select-title {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 1rem;
    text-align: center;
    position: relative;
}

.date-select-title .info-icon {
    position: relative;
    display: inline-block;
    margin-left: 4px;
}

.date-select-title .info-icon .tooltip {
    left: auto;
    right: -10px;
    top: 100%;
    margin-top: 8px;
    transform: none;
    width: 300px;
    max-width: 300px;
    white-space: normal;
    line-height: 1.4;
    font-size: 0.9rem;
    z-index: 1000;
}

.date-select-title .info-icon .tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 10px;
    width: 12px;
    height: 12px;
    background-color: var(--bg-secondary);
    transform: rotate(45deg);
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

.years-horizontal-container {
    display: flex; /* Ensure flex display */
    /* justify-content: space-around; */ /* Remove justification */
    gap: 10px; /* Use same gap as vertical container */
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.year-header {
    font-size: 1.1em; 
    color: var(--accent-primary); 
    font-weight: 500;
    text-align: center;
    cursor: default;
    flex: 1; /* Make headers share space equally, replacing grow/basis */
    min-width: 70px; /* Match min-width of dates-container */
}

.dates-vertical-container {
    display: flex;
    /* justify-content: space-around; */ /* Remove justification */
    gap: 10px; /* Ensure gap is consistent */
}

.dates-container {
    display: flex;
    flex-direction: column;
    gap: 8px; 
    align-items: center;
    min-width: 70px;
    flex: 1; /* Make columns share space equally */
}

.date-option,
.date-option-basic { /* Apply to both */
    padding: 8px 12px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 2px; /* Less round */
    transition: all 0.25s ease-in-out;
    text-align: center;
    user-select: none;
    width: 100%; /* Ensure full box is clickable */
    font-size: 0.9em;
}

.date-option:hover,
.date-option-basic:hover { /* Apply to both */
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-secondary);
    transform: scale(1.05); /* Subtle scale on hover */
}

.date-option.active,
.date-option-basic.active { /* Apply to both */
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    border-color: var(--accent-secondary);
    font-weight: 500;
    box-shadow: 0 0 8px var(--accent-primary);
}

.warning-message {
    display: none !important;
}

.export-button {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    transition: all 0.2s ease;
}

.export-button:hover {
    background-color: var(--accent-secondary);
    transform: translateY(-1px);
}

.title-container {
    position: relative;
    display: block;
}

.title-container h2, .title-container h3 {
    display: inline-block;
    margin-right: 4px;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-secondary);
    color: var(--bg-primary);
    font-size: 12px;
    margin-left: 8px;
    cursor: help;
    font-family: serif;
    font-style: italic;
}

.tooltip {
    /* Keep basic styling */
    visibility: hidden; /* Initially hidden */
    position: fixed; /* Use fixed positioning for placement relative to viewport */
    z-index: 1001; /* Ensure it's above most other content */
    min-width: 200px;
    max-width: 400px;
    width: max-content;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    text-align: left;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.2s ease-in-out; /* Faster transition */
    word-wrap: break-word;
    white-space: normal;
    pointer-events: none; /* Prevent tooltip from interfering with mouse events */
}

.spread-results {
    font-family: 'Consolas', monospace;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    white-space: pre; /* Keep pre to respect newlines */
    line-height: 1.5;
    border: 1px solid var(--border-color);
    display: inline-block; /* Revert to inline-block */
    max-width: 100%; /* Prevent overflow if content is very wide */
    min-width: 350px; /* Keep the minimum width */
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    cursor: not-allowed;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: not-allowed;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-secondary);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
    border-radius: 50%;
}

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

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
    background-color: white;
}

.toggle-switch.disabled {
    opacity: 0.5; /* Keep general dimming */
    cursor: not-allowed;
}

.toggle-switch.disabled .toggle-slider {
    cursor: not-allowed;
    background-color: #444; /* Darker grey for disabled slider background */
}

.toggle-switch.disabled .toggle-slider:before {
    background-color: #777; /* Darker grey for disabled slider knob */
}

.toggle-label {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative; /* Needed for tooltip positioning on hover */
    cursor: not-allowed; /* Apply not-allowed cursor to the whole label when disabled */
}

.toggle-container.disabled-mode .toggle-label {
    cursor: not-allowed; /* Ensure label gets the cursor */
    /* pointer-events: none; REMOVE this - it prevents hover */
}

/* Ensure the tooltip shows on hover of the CONTAINER (label wrapper) */
.toggle-container.disabled-mode:hover .disabled-tooltip {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

/* Position the tooltip relative to the toggle container */
.disabled-tooltip {
    visibility: hidden; /* Use visibility + opacity for transition */
    opacity: 0;
    position: absolute;
    bottom: 110%; /* Position above the toggle label */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(45, 45, 45, 0.9); /* Dark semi-transparent background */
    color: #ffd700; /* Yellow text */
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 10; /* Ensure tooltip is above button */
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
    pointer-events: none; /* Prevent tooltip from stealing hover */
}

#stopBtn {
    display: none; /* Hide by default */
}

.manual-entry-container {
    margin-top: 0.5rem;
    margin-bottom: 1rem; /* Reduced bottom margin slightly */
    display: none; /* Hide container by default */
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
    min-height: min-content;
    overflow: visible;
}

.manual-entry-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px;
    margin: 0;
    transition: opacity 0.2s;
    width: fit-content;
}

.manual-entry-toggle:hover {
    opacity: 0.8;
}

.manual-entry-row {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    width: 100%;
    margin-bottom: 1rem;
    min-height: min-content;
    overflow: visible;
}

.manual-entry-input-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    width: 100%;
    min-height: 24px; /* Minimum height */
    margin-bottom: 0.5rem; /* Space below input row */
}

#manualEntryField {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 0.8rem;
    min-height: 24px;
    padding: 4px 8px;
    resize: none;
    width: calc(100% - 100px);
    overflow: hidden;
    max-height: 400px;
}

.manual-update-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 12px;
    font-size: 0.8rem;
    transition: all 0.2s;
    height: 24px;
    width: 80px;
    white-space: nowrap;
    align-self: flex-start;
}

.manual-entry-error {
    display: none;
    color: #ffd700;
    font-size: 0.8rem;
    margin-top: 4px;
    margin-bottom: 0.5rem; /* Space below error message */
}

/* Add spacing for content below manual entry */
.graph-container {
    position: relative;
    margin-top: 1rem;
    padding-top: 1rem;
    clear: both;
}

/* Ensure proper spacing when manual entry is expanded */
.manual-entry-row[style*="display: flex"] + .graph-container {
    margin-top: 2rem;
}

.search-parameters-section {
    margin-top: 200px;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Add new styles for the donation section */
.donation-section {
    margin-top: 3rem;
    margin-bottom: 8rem; /* Add bottom margin to ensure it's not at the very bottom edge */
    text-align: center;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.03);
    width: 100%;
}

.donation-text {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

.donate-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #0070ba;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: background-color 0.2s;
}

.donate-button:hover {
    background-color: #005ea6;
}

.paypal-logo {
    height: 0.8rem;
    width: auto;
}

#availableOptionsContainer {
    /* Let it flow naturally */
    width: 100%; /* Take full width below date selector */
    max-width: none; /* Remove max-width */
    height: 420px; 
    margin-top: 2rem; /* Add margin */
    /* flex-grow: 1; */ /* Not needed */
}

#availableOptionsContainer .graph-container {
     height: 100%; /* Make inner container fill height */
     padding: 1rem; /* Reduce padding */
     margin: 0; /* Remove margin */
}

#availableOptionsContainer h3 {
    margin-top: 0; /* Remove margin from title */
    font-size: 1.1rem; /* Smaller title */
}

#optionsOverviewChart {
    height: calc(100% - 40px) !important; /* Adjust canvas height within container */
    width: 100% !important;
}

/* NEW styles for the top layout container */
.top-layout-container {
    display: flex;
    /* justify-content: space-between; */ /* Change justification */
    justify-content: flex-start; /* Align items to start */
    align-items: flex-start; /* Align to top */
    gap: 2rem; /* Add gap between items */
    margin-bottom: 3rem; /* Space below this section */
}

/* Spacer element for positioning */
.layout-spacer {
    flex-basis: 25%; /* Occupy roughly 33% of the space */
    flex-shrink: 0;
}

/* --- New Top Layout Styles --- */
.top-section-wrapper {
    display: flex;
    align-items: flex-start; /* Align items to the top */
    gap: 2rem; /* Gap between left and right columns */
    margin-bottom: 2rem; /* Space below this whole section */
}

.left-column {
    display: flex;
    flex-direction: column; /* Stack stock input and price/isin */
    flex-basis: 30%; /* Reduced from 40% to shift right column left */
    flex-shrink: 0;
}

.right-column {
    display: flex;
    align-items: flex-start; /* Align date selector and chart */
    gap: 1.5rem; /* Gap between date selector and chart */
    flex-grow: 1; /* Take remaining space */
}
/* --- End New Top Layout Styles --- */

.date-select-container {
    /* Styles for being in right column */
    margin-top: 0; 
    margin-bottom: 0; 
    padding: 0; 
    width: auto; 
    min-width: 250px; 
    flex-shrink: 0; /* Prevent shrinking */
}

#availableOptionsContainer {
     /* Styles for being in right column */
     width: auto; /* Let flexbox decide */
     max-width: none; 
     height: 420px; /* Increased height by 40% (from 300px) */
     margin-top: 0; /* Reset margin */
     flex-grow: 1; /* Take available space */
     position: relative; /* Needed for internal chart elements */
}

#availableOptionsContainer .graph-container {
    height: 100%;
    padding: 1rem;
    margin: 0;
}

.header .subtitle {
    font-size: 0.9rem; 
    color: var(--text-secondary);
    margin-top: 2px;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

/* Style for the controls container */
/* REMOVED .header-controls rule */

/* Styles for the moved fullscreen toggle */
/* REMOVED old .fullscreen-toggle rule */

/* Styles for the tier logo GIF */
/* REMOVED old #tier-logo rule */

/* Style for fading out the container on scroll */
#tier-info-container.faded-out {
    opacity: 0;
    pointer-events: none; /* Prevent interaction when invisible */
    transition: opacity 0.15s ease-out; /* FASTER transition */
}

/* --- Styles for Tiers Page (tiers.html) --- */

/* Style for the back link */
#back-link {
    display: inline-block; /* Allow margin */
    margin-bottom: 1.5rem; /* Space below link */
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s ease;
}

#back-link:hover {
    color: var(--text-primary);
}

.tier-list {
    margin-top: 2rem;
}

.tier-item {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Space between image and text block */
    padding: 1.5rem 0;
    /* border-bottom: 1px solid var(--border-color); REMOVED */
}

/* .tier-item:last-child { 
    border-bottom: none; REMOVED as border is gone 
} */

.tier-item img {
    width: 80px; /* Increased size */
    height: auto;
    flex-shrink: 0; /* Prevent image from shrinking */
}

.tier-details {
    display: flex;
    align-items: center; /* Align text items horizontally */
    gap: 1.5rem; /* Space between name/api block and description */
    flex-grow: 1;
}

.tier-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    min-width: 100px; /* Ensure some width for name */
}

.tier-api {
    font-size: 1rem;
    color: var(--accent-primary); /* Use accent color */
    font-family: monospace;
    min-width: 100px; /* Ensure some width for api level */
}

.tier-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.4;
    flex-grow: 1; /* Allow description to take remaining space */
}

/* Style for the link wrapping the subscription label */
.tier-link {
    text-decoration: none; /* Remove underline */
    color: inherit; /* Inherit color from span */
}

/* Style for the notice box on tiers page */
.notice-box {
    background-color: rgba(255, 215, 0, 0.1); /* Light yellow/gold background */
    border: 1px solid rgba(255, 215, 0, 0.4); /* Yellow/gold border */
    color: #ffd700; /* Yellow/gold text */
    padding: 1rem 1.5rem;
    margin: 1rem 0 2rem 0; /* Add some vertical margin */
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.notice-box strong {
    color: #fff; /* Make "Please Note:" stand out more */
}

.title-block {
    /* Takes available space pushing logo container right because of justify-content: space-between on parent */
    flex-grow: 1;
}

/* Style for the small logo image itself */
#header-tier-logo-container {
    opacity: 0; /* Hidden by default */
    pointer-events: none;
    transition: opacity 0.15s ease-out; /* Match fade speed */
    position: absolute; /* Position relative to header */
    right: 1rem; 
    top: 50%; /* Use 50% for better vertical centering */
    transform: translateY(-50%); /* Adjust for exact centering */
}

/* Hide the original fullscreen toggle when header is scrolled */
.header.scrolled + .fullscreen-toggle#fullscreenToggle {
    display: none;
}

/* Ensure the scrolled controls fullscreen toggle is only visible when header is scrolled */
#scrolled-controls-container .fullscreen-toggle {
    /* existing styles */
    display: none; /* Hidden by default */
}

.header.scrolled #scrolled-controls-container .fullscreen-toggle {
    display: block; /* Or inline-flex, or flex, depending on desired layout */
    position: static; /* Reset position if it was fixed/absolute */
    margin: 0;
    padding: 2px 4px;
    font-size: 0.75rem;
}

/* Style for the controls container */
/* REMOVED .header-controls rule */

/* Styles for the moved fullscreen toggle */
/* REMOVED old .fullscreen-toggle rule */

/* Styles for the tier logo GIF */
/* REMOVED old #tier-logo rule */

/* Style for fading out the container on scroll */
#tier-info-container.faded-out {
    opacity: 0;
    pointer-events: none; /* Prevent interaction when invisible */
    transition: opacity 0.15s ease-out; /* FASTER transition */
}

/* --- Styles for Tiers Page (tiers.html) --- */

/* Style for the back link */
#back-link {
    display: inline-block; /* Allow margin */
    margin-bottom: 1.5rem; /* Space below link */
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s ease;
}

#back-link:hover {
    color: var(--text-primary);
}

.tier-list {
    margin-top: 2rem;
}

.tier-item {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Space between image and text block */
    padding: 1.5rem 0;
    /* border-bottom: 1px solid var(--border-color); REMOVED */
}

/* .tier-item:last-child { 
    border-bottom: none; REMOVED as border is gone 
} */

.tier-item img {
    width: 80px; /* Increased size */
    height: auto;
    flex-shrink: 0; /* Prevent image from shrinking */
}

.tier-details {
    display: flex;
    align-items: center; /* Align text items horizontally */
    gap: 1.5rem; /* Space between name/api block and description */
    flex-grow: 1;
}

.tier-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    min-width: 100px; /* Ensure some width for name */
}

.tier-api {
    font-size: 1rem;
    color: var(--accent-primary); /* Use accent color */
    font-family: monospace;
    min-width: 100px; /* Ensure some width for api level */
}

.tier-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.4;
    flex-grow: 1; /* Allow description to take remaining space */
}

/* Style for the link wrapping the subscription label */
.tier-link {
    text-decoration: none; /* Remove underline */
    color: inherit; /* Inherit color from span */
}

/* Style for the notice box on tiers page */
.notice-box {
    background-color: rgba(255, 215, 0, 0.1); /* Light yellow/gold background */
    border: 1px solid rgba(255, 215, 0, 0.4); /* Yellow/gold border */
    color: #ffd700; /* Yellow/gold text */
    padding: 1rem 1.5rem;
    margin: 1rem 0 2rem 0; /* Add some vertical margin */
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.notice-box strong {
    color: #fff; /* Make "Please Note:" stand out more */
}

.title-block {
    /* Takes available space pushing logo container right because of justify-content: space-between on parent */
    flex-grow: 1;
}

/* Style for the small logo image itself */
#header-tier-logo {
    width: 33px; /* Increased size by ~30% */
    height: auto;
    display: block; /* Prevents extra space below */
}

/* Show the small logo when header is scrolled */
.header.scrolled #header-tier-logo-container {
    opacity: 1;
    pointer-events: auto;
    margin-top: 1rem;
}
/* From backup/2025-04-30-0328/style.css */

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@media (prefers-reduced-motion: no-preference) {
    h1 {
        background-size: 200% auto;
        animation: titleGlow 5s ease-in-out infinite alternate,
                   gradientFlow 20s ease infinite;
    }
}

/* Hide specific UI elements */
#estimatedTime,
#loadingIndicator .eta-display,
#consoleToggle {
    display: none !important; /* Hide estimate, ETA, and console toggle */
}

#resultGraphContainer {
    margin-top: 2rem;
    padding: 0; 
    border: none; 
    box-shadow: none; 
    height: auto; /* <<< Ensure height is auto to allow expansion */
}

.spread-results {
    font-family: 'Consolas', monospace;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    white-space: pre; /* Keep pre to respect newlines */
    line-height: 1.5;
    border: 1px solid var(--border-color);
    display: inline-block; /* Revert to inline-block */
    max-width: 100%; /* Prevent overflow if content is very wide */
    min-width: 350px; /* Keep the minimum width */
}

/* Specific graph container heights */
#probabilityGraphContainer .graph-container {
    height: 600px; /* Adjusted height */
}
#riskToleranceSection .graph-container {
    height: 450px; /* Reduced height */
}

#availableOptionsContainer .graph-container {
    height: 500px; /* Keep this taller */
}

/* Add this class dynamically */
.container.has-content {
    min-height: calc(100vh - 7rem);
}

#resultGraphContainer .chart-container {
    height: 80vh; /* Set height relative to viewport height */
    /* aspect-ratio: 1 / 1; Removed fixed aspect ratio */
    background-color: transparent; /* Explicitly set to transparent */
    max-height: none; /* REMOVED max-height constraint */
    padding: 0rem;
    border-radius: 8px;
}

/* NEW rule for BS Table container */
.bs-table-container {
    background-color: transparent !important; /* Make background transparent */
    padding: 0.5rem;
    border-radius: 8px;
    margin: 1.5rem 0 100px 0;
    overflow: auto;
    height: auto;
    max-height: none;
}

/* Ensure the table itself can cause overflow */
#bsChartContainer table,
#bsChartContainerBasic table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent !important;
}

/* Styles for value glow effect */
.value-glow {
    /* Base styles if needed, e.g., display: inline-block; */
    /* but text-shadow should work on inline spans */
    position: relative; /* Helps some browsers render shadow consistently */
}

.value-glow.positive {
    /* Cyan glow - using accent-secondary */
    /* text-shadow: 0 0 8px rgba(0, 206, 201, 0.6); */
    text-shadow: 0 0 20px rgba(0, 206, 201, 1); /* Increased blur radius */
}

.value-glow.negative {
    /* Red glow - using danger color */
    /* text-shadow: 0 0 8px rgba(255, 118, 117, 0.7); */
    text-shadow: 0 0 20px rgba(255, 118, 117, 1); /* Increased blur radius */
}

.value-glow.zero {
    /* White/grey glow */
    /* text-shadow: 0 0 7px rgba(224, 224, 224, 0.5); */
    text-shadow: 0 0 20px rgba(224, 224, 224, 1); /* Increased blur radius */
}

/* Mode Selector Styles */
.mode-selector-container {
    display: flex;
    justify-content: space-between; /* SPREAD OUT buttons */
    padding: 1rem 20%; /* Space above/below AND 10% left/right padding */
    margin-top: 7rem; /* Push below fixed header */
    position: relative; /* Keep in flow but allow z-index if needed */
    z-index: 5; /* Ensure it's above the background pulse */
}

/* NEW: Mode Description Area Styles */
#mode-description-area {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.5rem 10%; /* Padding for horizontal centering and some vertical space */
    margin-top: 1.5rem; /* Increased to move it down */
    margin-bottom: -50px; /* Negative margin to pull subsequent content up */
    min-height: 2.5em; /* Reserve space to prevent layout shifts, allows for ~2 lines of text */
    line-height: 1.4;
    font-style: italic;
}

/* Wrapper for each mode button */
.mode-button-wrapper {
    position: relative; /* For tooltip positioning */
}

.mode-button {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: var(--input-bg); /* Whitish-grey */
    color: var(--text-secondary); /* Grey text */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    box-shadow: none; /* Default no glow */
}

/* Visual styling for disabled mode buttons */
.mode-button-wrapper.disabled-mode .mode-button {
    opacity: 0.6;
    cursor: not-allowed;
    /* No pointer-events: none needed here, hover is on wrapper */
}

/* Don't apply hover effect to the button itself if disabled */
.mode-button-wrapper.disabled-mode .mode-button:hover {
    background-color: var(--input-bg); /* Keep original background */
    color: var(--text-secondary); /* Keep original text color */
    /* Prevent transform */
    transform: none; 
}

.mode-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 0 12px 1px rgba(224, 224, 224, 0.4); 
}

/* Styles for the disabled tooltip */
.disabled-tooltip {
    visibility: hidden; /* Use visibility + opacity for transition */
    opacity: 0;
    position: absolute;
    bottom: 110%; /* Position above the button */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(45, 45, 45, 0.9); /* Dark semi-transparent background */
    color: #ffd700; /* Yellow text */
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 10; /* Ensure tooltip is above button */
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
    pointer-events: none; /* Prevent tooltip from stealing hover */
}

/* Show tooltip on wrapper hover */
.mode-button-wrapper.disabled-mode:hover .disabled-tooltip {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

/* Re-add the active button style with glow */
.mode-button.active {
    background-color: var(--bg-secondary); /* Slightly different active background */
    color: var(--text-primary);
    border-color: var(--text-secondary); 
    /* Whitish-grey glow */
    box-shadow: 0 0 12px 1px rgba(224, 224, 224, 0.4); 
}

/* Style for preset risk section */
.preset-section {
    margin-top: 0.5rem; /* Small gap below canvas */
    /*margin-bottom: 50rem;*/ /* INCREASED Space below presets before search params */
    text-align: left; /* Align label and buttons left */
}

.preset-label {
    display: block; /* Label on its own line */
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Style for preset risk buttons container */
.preset-risk-buttons {
    display: flex;
    justify-content: flex-start; 
    gap: 0.5rem; /* REDUCED gap */
    /*margin-bottom: 500px;*/ /* INCREASED Space below presets before search params */
}

.preset-button {
    padding: 0.3rem 0.6rem; /* Reduced padding */
    font-size: 0.8rem; /* Reduced font size */
    /* background-color: var(--input-bg); REMOVED solid background */
    background-color: rgba(45, 45, 45, 0.6); /* Use rgba for transparency (from #2d2d2d) */
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    background-image: none; /* <<< Explicitly no background image by default */
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; /* Specify transitions */
}

/* Remove generic hover background change */
/*
.preset-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}
*/

/* Specific hover gradients */
#preset-high-risk:hover {
    /* Red to Yellow (less saturated) */
    background-image: linear-gradient(to top right, #d84444, #d4b000);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #d8444400;
}
#preset-medium-risk:hover {
    /* Orange to Light Grey (less saturated) */
    background-image: linear-gradient(to top right, #cc8400, #cccccc);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #cc850000;
}
#preset-low-risk:hover {
    /* Yellow to Light Green (less saturated) */
    background-image: linear-gradient(to top right, #d4b000, #7fbc7f);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #d4b10000;
}
#preset-insurance:hover, 
#preset-no-loss:hover { 
    /* Light Yellow - White - Light Green */
    background-image: linear-gradient(to top right, #ffffcc, #ffffff, #ccffcc);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: #333; /* Darker text for light gradient */
    border-color: #cccccc00;
}
#preset-no-brainer:hover {
    /* Light Green to Dark Green (less saturated) */
    background-image: linear-gradient(to top right, #7fbc7f, #004d00);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #7fbc7f00;
}

/* NEW: Mirror styles for Basic Calc mode chart */
#availableOptionsContainerBasic {
    width: auto;
    max-width: none;
    height: 500px; /* Match original */
    margin-top: 0;
    flex-grow: 1;
    position: relative;
    /* Ensure visibility/opacity transitions if needed, mirroring original */
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}
#availableOptionsContainerBasic.visible {
    opacity: 1;
    pointer-events: auto;
}
/* END NEW Basic Calc styles */

#availableOptionsContainer .graph-container {
    height: 100%;
    padding: 1rem;
    margin: 0;
}

/* NEW: Mirror styles for Basic Calc mode */
#availableOptionsContainerBasic .graph-container {
    height: 100%;
    padding: 1rem;
    margin: 0;
}
/* END NEW Basic Calc styles */

#availableOptionsContainer h3 {
    margin-top: 0; /* Remove margin from title */
    font-size: 1.1rem; /* Smaller title */
}

/* NEW: Mirror styles for Basic Calc mode */
#availableOptionsContainerBasic h3 {
    margin-top: 0;
    font-size: 1.1rem;
}
/* END NEW Basic Calc styles */

#optionsOverviewChart {
    height: calc(100% - 40px) !important; /* Adjust canvas height within container */
    width: 100% !important;
}

/* NEW: Mirror styles for Basic Calc mode */
#optionsOverviewChartBasic {
    height: calc(100% - 40px) !important; /* Match original */
    width: 100% !important;
}
/* END NEW Basic Calc styles */

/* New styles for the top layout container */
.top-layout-container {
    display: flex;
    /* justify-content: space-between; */ /* Change justification */
    justify-content: flex-start; /* Align items to start */
    align-items: flex-start; /* Align to top */
    gap: 2rem; /* Add gap between items */
    margin-bottom: 3rem; /* Space below this section */
}

/* Spacer element for positioning */
.layout-spacer {
    flex-basis: 25%; /* Occupy roughly 33% of the space */
    flex-shrink: 0;
}

/* --- New Top Layout Styles --- */
.top-section-wrapper {
    display: flex;
    align-items: flex-start; /* Align items to the top */
    gap: 2rem; /* Gap between left and right columns */
    margin-bottom: 2rem; /* Space below this whole section */
}

.left-column {
    display: flex;
    flex-direction: column; /* Stack stock input and price/isin */
    flex-basis: 30%; /* Reduced from 40% to shift right column left */
    flex-shrink: 0;
}

.right-column {
    display: flex;
    align-items: flex-start; /* Align date selector and chart */
    gap: 1.5rem; /* Gap between date selector and chart */
    flex-grow: 1; /* Take remaining space */
}
/* --- End New Top Layout Styles --- */

.date-select-container {
    /* Styles for being in right column */
    margin-top: 0; 
    margin-bottom: 0; 
    padding: 0; 
    width: auto; 
    min-width: 250px; 
    flex-shrink: 0; /* Prevent shrinking */
}

#availableOptionsContainer {
     /* Styles for being in right column */
     width: auto; /* Let flexbox decide */
     max-width: none; 
     height: 420px; /* Increased height by 40% (from 300px) */
     margin-top: 0; /* Reset margin */
     flex-grow: 1; /* Take available space */
     position: relative; /* Needed for internal chart elements */
}

#availableOptionsContainer .graph-container {
    height: 100%;
    padding: 1rem;
    margin: 0;
}

.header .subtitle {
    font-size: 0.9rem; 
    color: var(--text-secondary);
    margin-top: 2px;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

/* Style for the controls container */
/* REMOVED .header-controls rule */

/* Styles for the moved fullscreen toggle */
/* REMOVED old .fullscreen-toggle rule */

/* Styles for the tier logo GIF */
/* REMOVED old #tier-logo rule */

/* Style for fading out the container on scroll */
#tier-info-container.faded-out {
    opacity: 0;
    pointer-events: none; /* Prevent interaction when invisible */
    transition: opacity 0.15s ease-out; /* FASTER transition */
}

/* --- Styles for Tiers Page (tiers.html) --- */

/* Style for the back link */
#back-link {
    display: inline-block; /* Allow margin */
    margin-bottom: 1.5rem; /* Space below link */
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s ease;
}

#back-link:hover {
    color: var(--text-primary);
}

.tier-list {
    margin-top: 2rem;
}

.tier-item {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Space between image and text block */
    padding: 1.5rem 0;
    /* border-bottom: 1px solid var(--border-color); REMOVED */
}

/* .tier-item:last-child { 
    border-bottom: none; REMOVED as border is gone 
} */

.tier-item img {
    width: 80px; /* Increased size */
    height: auto;
    flex-shrink: 0; /* Prevent image from shrinking */
}

.tier-details {
    display: flex;
    align-items: center; /* Align text items horizontally */
    gap: 1.5rem; /* Space between name/api block and description */
    flex-grow: 1;
}

.tier-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    min-width: 100px; /* Ensure some width for name */
}

.tier-api {
    font-size: 1rem;
    color: var(--accent-primary); /* Use accent color */
    font-family: monospace;
    min-width: 100px; /* Ensure some width for api level */
}

.tier-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.4;
    flex-grow: 1; /* Allow description to take remaining space */
}

/* Style for the link wrapping the subscription label */
.tier-link {
    text-decoration: none; /* Remove underline */
    color: inherit; /* Inherit color from span */
}

/* Style for the notice box on tiers page */
.notice-box {
    background-color: rgba(255, 215, 0, 0.1); /* Light yellow/gold background */
    border: 1px solid rgba(255, 215, 0, 0.4); /* Yellow/gold border */
    color: #ffd700; /* Yellow/gold text */
    padding: 1rem 1.5rem;
    margin: 1rem 0 2rem 0; /* Add some vertical margin */
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.notice-box strong {
    color: #fff; /* Make "Please Note:" stand out more */
}

.title-block {
    /* Takes available space pushing logo container right because of justify-content: space-between on parent */
    flex-grow: 1;
}

/* Style for the small logo image itself */
#header-tier-logo {
    width: 33px; /* Increased size by ~30% */
    height: auto;
    display: block; /* Prevents extra space below */
}

/* Show the small logo when header is scrolled */
.header.scrolled #header-tier-logo-container {
    opacity: 1;
    pointer-events: auto;
    margin-top: 1rem;
}
/* From backup/2025-04-30-0328/style.css */

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@media (prefers-reduced-motion: no-preference) {
    h1 {
        background-size: 200% auto;
        animation: titleGlow 5s ease-in-out infinite alternate,
                   gradientFlow 20s ease infinite;
    }
}

/* Hide specific UI elements */
#estimatedTime,
#loadingIndicator .eta-display,
#consoleToggle {
    display: none !important; /* Hide estimate, ETA, and console toggle */
}

#resultGraphContainer {
    margin-top: 2rem;
    padding: 0; 
    border: none; 
    box-shadow: none; 
    height: auto; /* <<< Ensure height is auto to allow expansion */
}

.spread-results {
    font-family: 'Consolas', monospace;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    white-space: pre; /* Keep pre to respect newlines */
    line-height: 1.5;
    border: 1px solid var(--border-color);
    display: inline-block; /* Revert to inline-block */
    max-width: 100%; /* Prevent overflow if content is very wide */
    min-width: 350px; /* Keep the minimum width */
}

/* Specific graph container heights */
#probabilityGraphContainer .graph-container {
    height: 600px; /* Adjusted height */
}
#riskToleranceSection .graph-container {
    height: 450px; /* Reduced height */
}

#availableOptionsContainer .graph-container {
    height: 500px; /* Keep this taller */
}

/* Add this class dynamically */
.container.has-content {
    min-height: calc(100vh - 7rem);
}

#resultGraphContainer .chart-container {
    height: 80vh; /* Set height relative to viewport height */
    /* aspect-ratio: 1 / 1; Removed fixed aspect ratio */
    background-color: transparent; /* Explicitly set to transparent */
    max-height: none; /* REMOVED max-height constraint */
    padding: 0rem;
    border-radius: 8px;
}

/* NEW rule for BS Table container */
.bs-table-container {
    background-color: transparent !important; /* Make background transparent */
    padding: 0.5rem;
    border-radius: 8px;
    margin: 1.5rem 0 100px 0;
    overflow: auto;
    height: auto;
    max-height: none;
}

/* Ensure the table itself can cause overflow */
#bsChartContainer table,
#bsChartContainerBasic table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent !important;
}

/* Styles for value glow effect */
.value-glow {
    /* Base styles if needed, e.g., display: inline-block; */
    /* but text-shadow should work on inline spans */
    position: relative; /* Helps some browsers render shadow consistently */
}

.value-glow.positive {
    /* Cyan glow - using accent-secondary */
    /* text-shadow: 0 0 8px rgba(0, 206, 201, 0.6); */
    text-shadow: 0 0 20px rgba(0, 206, 201, 1); /* Increased blur radius */
}

.value-glow.negative {
    /* Red glow - using danger color */
    /* text-shadow: 0 0 8px rgba(255, 118, 117, 0.7); */
    text-shadow: 0 0 20px rgba(255, 118, 117, 1); /* Increased blur radius */
}

.value-glow.zero {
    /* White/grey glow */
    /* text-shadow: 0 0 7px rgba(224, 224, 224, 0.5); */
    text-shadow: 0 0 20px rgba(224, 224, 224, 1); /* Increased blur radius */
}

/* Mode Selector Styles */
.mode-selector-container {
    display: flex;
    justify-content: space-between; /* SPREAD OUT buttons */
    padding: 1rem 20%; /* Space above/below AND 10% left/right padding */
    margin-top: 7rem; /* Push below fixed header */
    position: relative; /* Keep in flow but allow z-index if needed */
    z-index: 5; /* Ensure it's above the background pulse */
}

/* Wrapper for each mode button */
.mode-button-wrapper {
    position: relative; /* For tooltip positioning */
}

.mode-button {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    background-color: var(--input-bg); /* Whitish-grey */
    color: var(--text-secondary); /* Grey text */
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-top: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    box-shadow: none; /* Default no glow */
}

/* Visual styling for disabled mode buttons */
.mode-button-wrapper.disabled-mode .mode-button {
    opacity: 0.6;
    cursor: not-allowed;
    /* No pointer-events: none needed here, hover is on wrapper */
}

/* Don't apply hover effect to the button itself if disabled */
.mode-button-wrapper.disabled-mode .mode-button:hover {
    background-color: var(--input-bg); /* Keep original background */
    color: var(--text-secondary); /* Keep original text color */
    /* Prevent transform */
    transform: none; 
}

.mode-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 0 12px 1px rgba(224, 224, 224, 0.4); 
}

/* Styles for the disabled tooltip */
.disabled-tooltip {
    visibility: hidden; /* Use visibility + opacity for transition */
    opacity: 0;
    position: absolute;
    bottom: 110%; /* Position above the button */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(45, 45, 45, 0.9); /* Dark semi-transparent background */
    color: #ffd700; /* Yellow text */
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 10; /* Ensure tooltip is above button */
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
    pointer-events: none; /* Prevent tooltip from stealing hover */
}

/* Show tooltip on wrapper hover */
.mode-button-wrapper.disabled-mode:hover .disabled-tooltip {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

/* Re-add the active button style with glow */
.mode-button.active {
    background-color: var(--bg-secondary); /* Slightly different active background */
    color: var(--text-primary);
    border-color: var(--text-secondary); 
    /* Whitish-grey glow */
    box-shadow: 0 0 12px 1px rgba(224, 224, 224, 0.4); 
}

/* Style for preset risk section */
.preset-section {
    margin-top: 0.5rem; /* Small gap below canvas */
    /*margin-bottom: 50rem;*/ /* INCREASED Space below presets before search params */
    text-align: left; /* Align label and buttons left */
}

.preset-label {
    display: block; /* Label on its own line */
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Style for preset risk buttons container */
.preset-risk-buttons {
    display: flex;
    justify-content: flex-start; 
    gap: 0.5rem; /* REDUCED gap */
    /*margin-bottom: 500px;*/ /* INCREASED Space below presets before search params */
}

.preset-button {
    padding: 0.3rem 0.6rem; /* Reduced padding */
    font-size: 0.8rem; /* Reduced font size */
    /* background-color: var(--input-bg); REMOVED solid background */
    background-color: rgba(45, 45, 45, 0.6); /* Use rgba for transparency (from #2d2d2d) */
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    background-image: none; /* <<< Explicitly no background image by default */
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; /* Specify transitions */
}

/* Remove generic hover background change */
/*
.preset-button:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}
*/

/* Specific hover gradients */
#preset-high-risk:hover {
    /* Red to Yellow (less saturated) */
    background-image: linear-gradient(to top right, #d84444, #d4b000);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #d8444400;
}
#preset-medium-risk:hover {
    /* Orange to Light Grey (less saturated) */
    background-image: linear-gradient(to top right, #cc8400, #cccccc);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #cc850000;
}
#preset-low-risk:hover {
    /* Yellow to Light Green (less saturated) */
    background-image: linear-gradient(to top right, #d4b000, #7fbc7f);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #d4b10000;
}
#preset-insurance:hover, 
#preset-no-loss:hover { 
    /* Light Yellow - White - Light Green */
    background-image: linear-gradient(to top right, #ffffcc, #ffffff, #ccffcc);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: #333; /* Darker text for light gradient */
    border-color: #cccccc00;
}
#preset-no-brainer:hover {
    /* Light Green to Dark Green (less saturated) */
    background-image: linear-gradient(to top right, #7fbc7f, #004d00);
    background-color: transparent; /* <<< Ensure solid color is removed */
    color: var(--text-primary); /* Standard hover text color */
    border-color: #7fbc7f00;
}

/* Spread Section Styles REMOVED */

/* ... rest of css ... */

/* NEW Spread Selector Grid Styles */
#spreadSectionBasic {
    margin-top: 2rem;
    margin-bottom: 3rem;
    padding: 0 2rem; /* Horizontal padding */
}

#spreadGridBasic {
    background-color: transparent; /* Transparent background */
    width: 100%;
    margin-top: 1rem;
}

.spread-grid-row {
    display: flex;
    gap: 1rem; /* Gap between columns */
    align-items: center; /* Vertically center items in the row */
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.5rem; /* Space between rows */
}

.spread-grid-header {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem; /* More space below header */
}

.grid-col {
    box-sizing: border-box;
    display: flex;
    align-items: center; /* Center content vertically */
}

/* Column Widths (adjust as needed) */
.grid-col-longshort { width: 15%; } /* New column */
.grid-col-alloc  { width: 15%; /* text-align: right; REMOVED */ } /* Wider Allocation */
.grid-col-type   { width: 20%; } /* Wider Type */
.grid-col-strike { width: 20%; } /* Wider Strike */
.grid-col-price  { width: 15%; } /* Wider Price */
.grid-col-action { width: 10%; justify-content: center; } /* Center action items */

/* Style for the calculate button section */
.spread-calculate-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column; /* Stack button and message */
    align-items: flex-start; /* Align items left */
    gap: 0.5rem; /* Space between button and message */
}

/* Style for the validation message */
.spread-validation-message {
    color: #ffd700; /* Yellow */
    font-size: 0.9rem;
    /* display: none; /* Controlled by JS */
}

/* Style for disabled short option (title attribute handles tooltip) */
select.long-short-select option[value="short"]:disabled {
    color: #888; /* Grey out text */
    cursor: not-allowed;
    /* Background changes might not work consistently across browsers for disabled options */
}

.spread-grid-header .header-label {
    width: 100%;
    text-align: left; /* Ensure all headers are left-aligned */
    white-space: nowrap;
}

/* REMOVED specific alignment for allocation header */

/* Add button specific row styling */
.spread-add-row {
    justify-content: flex-start; /* Align button to the left */
    margin-top: 0.5rem;
}

.add-spread-leg-btn {
    background-color: rgba(0, 184, 148, 0.15); /* Transparent greenish */
    color: var(--accent-primary);
    border: 1px dashed var(--accent-primary); /* Dashed border */
    border-radius: 50%; /* Make it round */
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 1.2rem; /* Larger plus sign */
    line-height: 28px; /* Center plus sign vertically */
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.add-spread-leg-btn:hover {
    background-color: rgba(0, 184, 148, 0.3); /* More opaque green */
    color: #aaffec;
    border-color: var(--accent-secondary);
    transform: scale(1.05);
}

.add-spread-leg-btn:active {
    transform: scale(0.98);
}

/* NEW Style for Remove Button */
.remove-spread-leg-btn {
    background-color: rgba(255, 118, 117, 0.15); /* Transparent reddish */
    color: var(--danger);
    border: 1px dashed var(--danger);
    border-radius: 50%; /* Make it round */
    width: 26px; /* Slightly smaller than add */
    height: 26px;
    padding: 0;
    font-size: 1rem; /* Slightly smaller minus */
    line-height: 24px; /* Adjust line height */
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.remove-spread-leg-btn:hover {
    background-color: rgba(255, 118, 117, 0.3);
    color: #ffcccc;
    border-color: #ff4d4d;
    transform: scale(1.05);
}

.remove-spread-leg-btn:active {
    transform: scale(0.98);
}

/* Container for dynamically added legs */
#spread-legs-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Consistent gap with rows */
}

/* Input styling within the grid */
.spread-leg-input {
    width: 100%;
    height: 36px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-sizing: border-box;
}

.spread-leg-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #333; /* Darker disabled background */
}

/* Remove spinner buttons for number inputs */
.percentage-input::-webkit-outer-spin-button,
.percentage-input::-webkit-inner-spin-button,
.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.percentage-input[type=number],
.price-input[type=number] {
  -moz-appearance: textfield;
}

/* Style for price reset button */
.price-reset-btn {
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 5px; /* Space it from input */
    font-size: 12px;
    line-height: 18px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    display: none; /* Hidden by default */
    transition: background-color 0.2s, color 0.2s;
}

.price-reset-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

/* --- End NEW Spread Selector Grid Styles --- */

/* Add padding to body bottom */
body {
    /* ... existing body styles ... */
    padding-bottom: 30vh; /* Add significant padding to the bottom */
}

/* NEW: Container for price input + reset button */
.price-input-container {
    position: relative; /* Allows absolute positioning for button */
    display: flex; /* Aligns items */
    align-items: center; /* Vertical alignment */
    width: 100%;
}

.price-input {
    /* Price input takes most space, but leaves room for button */
    flex-grow: 1;
    padding-right: 25px !important; /* Ensure space for button */
    /* Inherit other styles from .spread-leg-input */
}

.spread-leg-input:disabled {
    opacity: 0.5;
}

/* Style for the new status message */
.calculation-status {
    display: none; /* Hidden by default */
    color: #ffd700; /* Yellow text */
    font-size: 0.9rem;
    margin-left: 1rem; /* Space between button and message */
    font-style: italic;
}

/* NEW: Container for price input + reset button */
.price-input-container {
    position: relative; /* Allows absolute positioning for button */
}

/* Ensure the tooltip shows on hover of the CONTAINER (label wrapper) */
.toggle-container.disabled-mode:hover .disabled-tooltip {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

/* <<< Add pointer-events: none to label when disabled >>> */
.toggle-container.disabled-mode .toggle-label {
    pointer-events: none;
}

/* Position the tooltip relative to the toggle container */

#bsChartContainerBasic table {
    width: 100%;
    border-collapse: collapse;
}

#bsChartContainerBasic td {
    border: 1px solid var(--border-color);
}

/* === Basic Calculation: Performance chart height === */
#resultChartBasicContainer.chart-container,
#resultChartBasicContainer {
    min-height: 1200px !important; /* 300% of 600px = 1800px */
}

/* Adjust inner canvas to take full height */
#resultChartBasic {
    height: 100% !important;
}

/* Ensure donation sections are at the bottom of results */
#resultGraphContainer .donation-section, 
#resultContainerBasic .donation-section {
    margin-top: 4rem;
    margin-bottom: 0;
    padding-bottom: 4rem;
    position: relative;
    z-index: 2;
}

/* Force result containers to be at bottom of page */
#resultContainerBasic,
#resultGraphContainer {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Fix container padding to ensure no extra space */
.container {
    padding-bottom: 0;
}

/* Force donation sections to be at the very bottom of the page */
.donation-section {
    position: relative;
    margin-top: 4rem;
    margin-bottom: 0;
    padding-bottom: 2rem;
    clear: both;
    background-color: transparent !important;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

/* Ensure content containers have no margin/padding at bottom */
#resultContainerBasic,
#resultGraphContainer,
.container,
body,
#mainContainer,
#mainContainerBasic {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Add space at bottom of main section to ensure donation button is visible */
.donation-section:after {
    content: '';
    display: block;
    height: 10px;
    width: 100%;
    clear: both;
}

/* Clear all floats */
.donation-section {
    clear: both;
}

/* Hide any content that might appear after donation section */
.donation-section ~ *:not(script):not(style) {
    display: none !important;
}

/* === ADDED: Bottom Spacing for Search Parameters === */
#searchParametersSection.needs-bottom-space {
    margin-bottom: 50vh; /* Add significant space below */
    transition: margin-bottom 0.5s ease-in-out; /* Smooth transition */
}
#searchParametersSection {
     transition: margin-bottom 0.5s ease-in-out; /* Ensure transition applies when class is removed */
}

/* === Improvement: keep loading indicator just below Calculate button === */
#searchParametersSection #loadingIndicator {
    margin-top: 1rem;
}

/* --- Credit Display Adjustments (Corrected) --- */

/* Ensure the main container stacks Subscription link and the row below */
#tier-info-container {
    /* position, top, right, z-index, opacity, transition remain */
    display: flex;
    flex-direction: column; /* STACK subscription + row */
    align-items: flex-end;  /* Align content to the right */
    gap: 2px; /* Small gap between subscription and row */
}

/* Style the new row holding credit, logo, tier text */
.credit-logo-tier-row {
    display: flex;
    align-items: center; /* Vertically align items in the row */
    gap: 8px; /* Space between credit and logo-row */
    width: 100%; /* Allow it to take width needed */
    justify-content: flex-end; /* Align content right */
}

/* Adjust subscription label display */
#subscription-label {
    display: block;
    text-align: right;
    margin-bottom: 2px;
}

/* Credit display within the horizontal row */
#credit-display {
    /* Styles inherited from .tier-text */
    color: var(--accent-primary); /* Specific color */
    /* Ensure no conflicting positioning */
    position: static;
    margin: 0; /* Reset margins */
    margin-top: 0.5rem;
}

/* Original logo-text row */
.logo-text-row {
    /* Keep internal flex */
    display: flex;
    align-items: center;
    gap: 0px;
    /* Remove any conflicting positioning */
    position: static;
    top: auto;
    align-self: auto;
}

/* --- Scrolled State Controls (Keep as previously added) --- */
#scrolled-controls-container {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 1rem;
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    z-index: 1002;
}

.header.scrolled #scrolled-controls-container {
    display: flex !important; /* Show when scrolled (Forced) */
}

#scrolled-controls-container .fullscreen-toggle {
    position: static;
    margin: 0;
    padding: 2px 4px;
    font-size: 0.75rem;
}

#scrolled-credit-display {
    font-size: 0.75rem;
    text-align: right;
    color: var(--accent-primary);
    display: block; /* Ensure it's visible */
}

/* --- Ensure tier info container fades out properly when scrolled --- */
.header.scrolled #tier-info-container {
    opacity: 0;
    pointer-events: none;
}

/* --- Fullscreen Toggle Positioning --- */
/* REMOVE any 'position: fixed', 'top', 'right' from the main .fullscreen-toggle rule */
/* It should only define background, padding, font-size etc. */
/* The positioning is now handled by #scrolled-controls-container */
/* or its default placement if the header isn't scrolled */

/* Gemini Chat Styles */
#gemini-logo-container {
    position: fixed;
    top: 15%; /* Changed from 25% */
    right: 2rem;
    z-index: 1005; /* Ensure it's above most content */
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
}

#gemini-logo-container:hover {
    transform: scale(1.1);
}

#gemini-logo-icon {
    width: 50px; /* Adjust size as needed */
    height: 50px;
    border-radius: 50%; /* Make it circular */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background-color: var(--bg-secondary); /* Optional: background for the logo */
    padding: 5px; /* Optional: padding around the logo image */
    object-fit: contain; /* Ensure image aspect ratio is maintained */
    box-sizing: border-box; /* Explicitly set box-sizing */
}

#gemini-chat-window {
    position: fixed;
    /* Adjusted to be right under the logo container, now at 10% */
    top: calc(15% + 60px); /* 10% from top (logo's top) + logo height (50px) + some spacing (10px) */
    right: 2rem;
    width: 320px;
    height: 450px;
    background-color: rgba(26, 26, 26, 0.9); /* var(--bg-primary) with transparency */
    border: 1px solid var(--border-color);
    border-radius: 16px; /* More rounded corners */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    z-index: 1004;
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    transform-origin: bottom right;
}

#gemini-chat-window.visible {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

#gemini-chat-window:not(.visible) {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

#gemini-chat-header {
    background-color: transparent; /* Make header transparent */
    padding: 0; /* Remove padding */
    display: flex;
    justify-content: flex-end;
    align-items: flex-start; /* Align close button to the top */
    border-bottom: none; /* Remove border */
    color: var(--text-primary);
    min-height: auto;
    height: 20px; /* Minimal height, adjust as needed or make 0 if button is fully absolute */
    position: relative; /* Needed for absolute positioning of the child button */
}

#gemini-chat-close-btn {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    position: absolute; /* Position absolutely within the chat window */
    top: 0.5rem;        /* Adjust as needed */
    right: 0.75rem;       /* Adjust as needed */
    z-index: 10;       /* Ensure it's above messages */
}

#gemini-chat-close-btn:hover {
    color: var(--text-primary);
}

#gemini-chat-messages {
    flex-grow: 1;
    padding: 1rem;
    /* Add padding to the top to prevent messages from going under the absolute positioned close button */
    padding-top: 2.5rem; 
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    /* Custom scrollbar for chat messages */
    scrollbar-width: thin;
    scrollbar-color: #5470ca var(--bg-secondary); /* Updated thumb color */
}

#gemini-chat-messages::-webkit-scrollbar {
    width: 8px;
}

#gemini-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

#gemini-chat-messages::-webkit-scrollbar-thumb {
    background-color: #5470ca; /* Updated thumb color */
    border-radius: 4px;
    border: 2px solid var(--bg-secondary);
}

.gemini-message {
    align-self: flex-end; /* Gemini messages on the right */
    background-image: linear-gradient(to right, #8A2BE2, #4169E1); /* Purple to Blue gradient */
    color: var(--text-primary);
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 90%;
    word-wrap: break-word;
}

.user-message {
    align-self: flex-start; /* User messages on the left */
    background-color: #5470ca; /* Greyish blue */
    color: var(--text-primary); /* Adjusted for better contrast if needed */
    border-radius: 6px; /* Standard border-radius */
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 90%;
    word-wrap: break-word;
}

#gemini-chat-input-container {
    display: flex;
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-primary); /* Match window background */
}

#gemini-chat-input {
    flex-grow: 1;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 0.9rem;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

#gemini-chat-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 184, 148, 0.2);
}

#gemini-chat-send-btn {
    background-color: #5470ca; /* Greyish blue */
    color: var(--text-primary); /* Adjusted for better contrast */
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

#gemini-chat-send-btn:hover {
    background-color: #546E7A; /* Darker greyish blue for hover */
}
