/* --- Jost Font Declarations --- */
/* Paths are relative to the location of style.css (which is in /static/) */

/* Jost Hairline (Weight 100) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-100-Hairline.ttf') format('truetype');
    font-weight: 100;
    font-style: normal;
    font-display: swap;
}

/* Jost Thin (Weight 200) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-200-Thin.ttf') format('truetype');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}

/* Jost Light (Weight 300) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-300-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

/* Jost Book (Weight 400 - often considered 'Regular') */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-400-Book.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Jost Medium (Weight 500) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-500-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

/* Jost SemiBold (Weight 600) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-600-Semi.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

/* Jost Bold (Weight 700) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-700-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Jost Heavy (Weight 800) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-800-Heavy.ttf') format('truetype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

/* Jost Black (Weight 900) */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-900-Black.ttf') format('truetype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

/* Jost Black Italic (Weight 900, Italic) - for .otf file */
@font-face {
    font-family: 'Jost';
    src: url('fonts/Jost-900-Blackitalic.otf') format('opentype');
    font-weight: 900;
    font-style: italic;
    font-display: swap;
}

/* --- END Jost Font Declarations --- */


:root {
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --accent-primary: #007bff;
    --accent-secondary: #28a745;
    --border-color: #dee2e6;
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);

    /* NEW: Variables for input background/border in settings */
    --input-bg: #f8f9fa;
    --input-border: #ced4da;
    --hover-bg: #e2e6ea; /* General hover background for buttons/icons */
}

/* Dark Mode Styles */
body.dark-mode {
    --background-color: #1a1a1a;
    --card-background: #2a2a2a;
    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --accent-primary: #6ab04c; /* A softer green for dark mode */
    --accent-secondary: #00bcd4; /* A teal for secondary accent */
    --border-color: #3a3a3a;
    --shadow: 0 4px 12px rgba(0,0,0,0.5);

    /* NEW: Dark mode specific input background/border in settings */
    --input-bg: #343a40;
    --input-border: #495057;
    --hover-bg: #3f444a;
}

body {
    margin: 0;
    font-family: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh; /* Make body fill the viewport height */
    background-color: var(--background-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition for dark mode */
}

/* NEW: Page Header */
.page-header {
    flex-shrink: 0; /* Prevent header from shrinking */
    padding: 20px 25px 15px 25px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-background);
}

.page-header h1 {
    font-size: 1.8em;
    font-weight: 700;
    margin: 0 0 5px 0;
}

/* VVV NEW: Header link style VVV */
.header-link {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}
.header-link:hover {
    color: var(--accent-primary);
}
/* --- ^^^ NEW --- */

.page-header .tagline {
    font-size: 1.1em;
    color: var(--text-secondary);
    margin: 0;
}


#main-container {
    display: flex;
    flex-grow: 1; /* Allow main container to fill remaining space */
    min-height: 0; /* Crucial for preventing flexbox overflow */
    width: 100%;
    padding: 25px;
    box-sizing: border-box;
    gap: 25px;
}

/* NEW: Wrapper for the map column */
#map-column {
    flex: 1; /* Occupy 1/3 of the space */
    display: flex;
    flex-direction: column;
    gap: 25px; /* Space between map and lower panel */
    min-width: 0;
}

#map {
    flex: 1; /* Occupy top half of the column */
    min-height: 0; /* Important for flex children */
    position: relative;
    transition: filter 0.3s ease, box-shadow 0.3s ease;

    /* Card-like styles */
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden; /* This is crucial to clip the map corners */
}

/* NEW: Style for the empty panel that will hold the 3D model */
#map-lower-panel {
    flex: 1; /* Occupy bottom half of the column */
    min-height: 0; /* Important for flex children */
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 25px;
    box-sizing: border-box;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    /* Flex column layout for title + canvas */
    display: flex;
    flex-direction: column;
}
#map-lower-panel h4 {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.canvas-container {
    flex-grow: 1;
    min-height: 0;
    position: relative; /* Needed for renderer to size correctly */
}

body.dark-mode #map {
    /* Simple filter to make satellite imagery appear darker/desaturated */
    filter: invert(0.9) hue-rotate(180deg) brightness(0.9);
}

#data-panel, #ai-panel {
    flex: 1; /* Occupy 1/3 of the space */
    min-width: 0;
    height: 100%;
    display: flex; /* Make panels flex columns to contain cards */
    flex-direction: column;
}

#ai-panel > .card,
#data-panel > #calculator-container {
    flex-grow: 1; /* Allow cards to fill the panel height */
    display: flex;
    flex-direction: column;
    margin-bottom: 0; /* Remove margin as it's the only element */
}

#data-panel > #calculator-container {
    gap: 25px; /* Add space between explorer and assumptions cards */
    overflow-y: auto; /* Allow calculator section itself to scroll if needed */
}

#calculator-container.hidden, .hidden {
    display: none;
}
.card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 25px;
    margin-bottom: 25px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Lucide icons are SVGs, so target the svg element */
h4 svg,
.control-group label svg,
.input-group-title svg,
.item-label svg,
#chat-send svg,
.global-control-button svg,
.tagline svg {
    stroke: currentColor;
    fill: none;
    width: 1em; /* Make them match font size */
    height: 1em;
    vertical-align: middle;
    margin-right: 5px;
}
.global-control-button svg{
    width: 18px;
    height: 18px;
    margin-right: 8px;
}


.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--accent-primary);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: none; /* Hidden by default */
}
.spinner.active {
    display: inline-block;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

h4 {
    font-size: 1.2em;
    font-weight: 600;
    margin: 0; /* Reset margin */
    padding: 0; /* Reset padding */
    border: none; /* Reset border */
    flex-shrink: 0;
}

#explorer-card > h4, .cost-group > h4 {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

#explorer-card .key-metrics {
    display: flex;
    justify-content: space-around;
    text-align: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
    background-color: var(--card-background);
    z-index: 100;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.metric .label {
    color: var(--text-secondary);
    font-size: 1em;
    margin-bottom: 5px;
    /* VVV MODIFICATIONS VVV */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px; /* Adds space between text and icon */
}
.metric .value {
    font-size: 2em;
    font-weight: 700;
}
.metric .value.profit { color: var(--accent-secondary); }
.metric .value.cost { color: var(--text-primary); }
.metric .value.payback { color: var(--accent-primary); }
#controls { padding: 15px 0; border-top: 1px solid var(--border-color); }
.control-group { margin-bottom: 20px; }
.control-group label {
    display: flex; /* Use flex to align icon */
    align-items: center;
    font-weight: 500;
    margin-bottom: 10px;
    gap: 8px; /* Space between icon and text */
}
.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative; /* For tooltip positioning */
}
.slider-container input[type="range"] { flex-grow: 1; cursor: grab; }
.slider-container input[type="range"]:active { cursor: grabbing; }
.slider-container .value-display {
    font-weight: 600;
    font-size: 1.1em;
    width: 100px;
    text-align: right;
}
/* Slider Tooltip */
.slider-tooltip {
    position: absolute;
    background-color: var(--accent-primary);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    bottom: 100%; /* Position above slider */
    left: var(--tooltip-left, 50%); /* Dynamic left position */
    transform: translateX(-50%) translateY(-5px); /* Center and push up */
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none; /* Allow clicks to pass through */
    z-index: 10;
}
.slider-container input[type="range"]:hover + .value-display + .slider-tooltip,
.slider-container input[type="range"]:active + .value-display + .slider-tooltip {
     opacity: 1;
     visibility: visible;
}


.button-group { display: inline-flex; }
.button-group button {
    padding: 8px 16px;
    font-size: 1em;
    border: 1px solid var(--border-color);
    background-color: transparent;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    color: var(--text-secondary); /* Default text color for non-selected buttons */
}
.button-group button:first-child { border-radius: 8px 0 0 8px; margin-right: -1px;}
.button-group button:last-child { border-radius: 0 8px 8px 0; }
.button-group button.selected {
    background-color: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    z-index: 1;
}
.button-group button:hover:not(.selected) {
    background-color: var(--background-color); /* Use background color for subtle hover */
}
.tab-nav {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.tab-link {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 1.1em;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
}
.tab-link.active {
    color: var(--text-primary);
    border-bottom: 3px solid var(--accent-primary);
}
.tab-link:hover:not(.active) {
    color: var(--accent-primary);
}
.tab-content {
    display: none;
    padding-top: 15px;
    overflow-y: auto; /* Allow individual tabs to scroll if content is long */
}
.tab-content.active {
    display: block;
}
.input-group-title {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    display: flex; /* Use flex to align icon */
    align-items: center;
    gap: 8px; /* Space between icon and text */
}

/* Cost Grouping */
.cost-group {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 20px;
    background-color: var(--background-color); /* Matches background, adjust if needed */
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
body.dark-mode .cost-group {
    background-color: #2e2e2e; /* Slightly different background for dark mode groups */
}
.cost-item {
    display: grid;
    grid-template-columns: 2fr 1.5fr auto;
    gap: 15px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color); /* Use var for border */
}
.cost-item:last-child {
    border-bottom: none;
}
.item-label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
}
.cost-item .sub-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-left: 8px;
}
.item-input {
    text-align: right;
    color: var(--text-secondary);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    white-space: nowrap; /* Prevent wrapping */
    gap: 4px;
}
.cost-item .item-total {
    text-align: right;
    font-weight: 600;
    font-size: 1.05em;
    min-width: 70px;
    color: var(--text-primary);
}
.editable-input {
    width: 70px;
    text-align: right;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 1em;
    background-color: var(--card-background); /* Ensure input background changes */
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.editable-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
.cost-total-summary {
    font-weight: 700;
    font-size: 1.1em;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}
.cost-total-summary span:last-child {
    color: var(--text-primary);
}

/* NEW: Consistent styling for Generation/Assumption Inputs */
.assumptions-grid {
    display: flex;
    flex-direction: column;
    margin-top: 15px;
}
.assumption-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr; /* Give more space to label */
    gap: 15px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.assumption-row:last-child {
    border-bottom: none;
}
.unit-prefix, .unit-suffix {
    font-size: 0.95em;
    color: var(--text-secondary);
}
#generation-inputs hr {
    margin: 25px 0 15px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

/* AI Panel Styles */
#ai-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}
#ai-chat-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow container to fill space in card */
    min-height: 0; /* Fix for flexbox scrolling bugs */
}

.chat-messages {
    flex-grow: 1; padding: 15px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--border-radius); margin-bottom: 15px; display: flex; flex-direction: column; gap: 12px;
    background-color: var(--background-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.chat-message {
    padding: 10px 15px; border-radius: 18px; max-width: 85%; line-height: 1.4;
    word-wrap: break-word; /* Ensure long words don't overflow */
}
.chat-message.user {
    background-color: var(--accent-primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px;
}
.chat-message.bot {
    background-color: var(--card-background); color: var(--text-primary); align-self: flex-start; border-bottom-left-radius: 4px;
    transition: background-color 0.3s ease, color 0.3s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
body.dark-mode .chat-message.bot {
    background-color: #3a3a3a;
    color: var(--text-primary);
}
.chat-message.thinking span.thinking-dots span { display: inline-block; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.chat-suggestions { padding-bottom: 15px; flex-shrink: 0; }
.chat-suggestions button {
    background: transparent; border: 1px solid var(--accent-primary); color: var(--accent-primary); padding: 5px 10px; margin: 0 5px 5px 0; border-radius: 15px; font-size: 0.9em; cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.chat-suggestions button:hover {
    background-color: var(--accent-primary);
    color: white;
}
.chat-input-form { display: flex; gap: 10px; flex-shrink: 0; }
#chat-input {
    flex-grow: 1; border: 1px solid var(--border-color); border-radius: 18px; padding: 10px 15px; font-size: 1em;
    background-color: var(--card-background);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
#chat-input:disabled {
    background-color: var(--background-color);
    cursor: not-allowed;
}
#chat-send {
    border: none; background: var(--accent-primary); color: white; border-radius: 50%; width: 44px; height: 44px; font-size: 18px; cursor: pointer; flex-shrink: 0;
}

#global-controls {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 900;
    display: flex;
    gap: 10px;
}

.global-control-button {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    color: var(--text-primary);
    font-size: 0.9em;
    font-weight: 500;
}

.global-control-button:hover {
    background-color: var(--hover-bg);
    transform: translateY(-1px);
    border-color: var(--accent-primary);
}

/* Add this to your style.css file */

.bmc-button svg {
    margin: 0; /* Remove the margin from the default icon style */
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.bmc-button:hover svg {
    transform: scale(1.1); /* Adds a nice little hover effect */
}




/* Settings Dropdown Menu */
#settings-dropdown {
    position: absolute;
    top: calc(100% + 10px); /* Position below the button */
    right: 0; /* Align to the right of the settings area */
    left: auto;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 15px;
    min-width: 220px; /* Adjust as needed */
    z-index: 950; /* Higher than icon area */
    opacity: 0;
    transform: translateY(-10px); /* Start slightly above and faded */
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.3s ease, border-color 0.3s ease;
    pointer-events: none; /* Allows clicks to pass through when hidden */
}

#settings-dropdown.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* Enable clicks when visible */
}

/* Re-using existing setting-item and switch styles */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--input-border); /* Use input-border for these internal lines */
    color: var(--text-primary);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item span {
    font-size: 0.95em;
    color: var(--text-primary); /* Ensure text color changes with theme */
}

/* Toggle Switch (for dark mode) */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input-border); /* Use border color for track */
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--card-background); /* Slider handle color */
    -webkit-transition: .4s;
    transition: .4s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2); /* Small shadow for the handle */
}

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

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-primary);
}

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

/* Rounded sliders */
.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Select Box Styling */
#currency-selector {
    padding: 5px 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9em;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

#currency-selector:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2); /* Assuming primary-rgb variable for accent */
}


/* Responsive adjustments */
@media (max-width: 1200px) { /* Changed breakpoint to 1200px for stacking */
    body {
        height: auto;
    }
    .page-header {
        padding: 15px;
    }
    #main-container {
        flex-direction: column;
        height: auto;
        padding: 15px;
        gap: 15px; /* Reduce gap for stacked layout */
    }
    #map-column, #data-panel, #ai-panel {
        width: 100%;
        height: auto; /* Let content dictate height */
        flex: none; /* Reset flex property for stacked layout */
    }
    #map-column {
        height: 60vh; /* Set a height for the map column */
        min-height: 400px;
    }
    #data-panel, #ai-panel {
        overflow-y: visible; /* Prevent double scrollbars */
    }
    #data-panel > #calculator-container {
        overflow-y: visible;
    }
    #ai-panel {
        max-height: 70vh; /* Give AI panel a max height on mobile */
    }
    .card {
        margin-bottom: 0;
    }
    #explorer-card .key-metrics {
        position: static;
        margin-left: -25px;
        margin-right: -25px;
    }

    #global-controls {
        top: 10px;
        right: 10px;
    }
    #settings-dropdown {
        top: calc(100% + 8px);
    }
}

@media (max-width: 576px) {
    .page-header h1 {
        font-size: 1.5em;
    }
    .page-header .tagline {
        font-size: 1em;
    }
    #main-container {
        padding: 10px;
        gap: 10px;
    }
    #map-column {
        height: 50vh; /* Make map column smaller on very small screens */
    }
    .card {
        padding: 15px;
    }
    .metric .value {
        font-size: 1.6em;
    }
    .button-group button {
        padding: 6px 10px;
        font-size: 0.9em;
    }
    .editable-input {
        width: 50px;
        padding: 4px;
    }
    .cost-item, .assumption-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .item-input {
        justify-content: flex-start;
        padding-left: 20px;
    }
    .cost-item .item-total {
       text-align: left;
       padding-left: 20px;
       font-size: 1em;
    }
    .cost-total-summary {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* --- VVVV ALL THIS CODE IS NEW VVVV --- */

/* --- Contextual Help Link Styles --- */
.help-link {
    font-size: 0.9em;
    font-weight: 500;
    margin-left: 10px;
    color: var(--accent-primary);
    text-decoration: none;
    display: inline-block; /* Ensures it flows with the label */
}
.help-link:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.help-link-icon {
    color: var(--accent-primary);
    display: inline-flex; /* Use inline-flex for perfect alignment */
    line-height: 1; /* Prevents it from adding extra line height */
    cursor: pointer;
}
.help-link-icon svg {
    width: 1.1em; /* Make it just a bit larger than text */
    height: 1.1em;
    stroke: currentColor;
}
.help-link-icon:hover {
    opacity: 0.7;
}

/* --- Article Page Layout --- */
.article-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    max-width: 1200px; /* Max width for readability */
    margin: 0 auto; /* Center the layout */
}

.article-sidebar {
    width: 280px; /* Fixed width for sidebar */
    flex-shrink: 0;
    padding-right: 25px;
    box-sizing: border-box;
    /* VVV NEW: Sticky sidebar VVV */
    position: sticky;
    top: 25px; /* Stick to top, with padding */
    height: calc(100vh - 50px); /* Full height minus padding */
    overflow-y: auto; /* Allow sidebar to scroll if content is tall */
}

.toc-nav h4 {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
}

/* Table of Contents List */
.toc-nav .toc {
    padding-left: 0;
    list-style-type: none;
    margin: 0;
}
.toc-nav .toc ul {
    padding-left: 15px; /* Indent sub-items */
    list-style-type: none;
    margin-top: 5px;
}
.toc-nav .toc li {
    margin-bottom: 8px;
}
.toc-nav .toc a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95em;
    transition: all 0.2s ease;
}
.toc-nav .toc a:hover {
    color: var(--accent-primary);
    transform: translateX(2px);
}
.toc-nav .toc a:active {
    color: var(--text-primary);
    font-weight: 600;
}


.article-content {
    flex-grow: 1; /* Take up remaining space */
    min-width: 0; /* Prevent flex overflow */
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 40px 50px;
    line-height: 1.7;
    font-size: 1.1em;
}

/* Article Typography */
.article-content h1:first-child {
    margin-top: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}
.article-content h2 {
    font-size: 1.8em;
    font-weight: 700;
    margin-top: 40px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.article-content h3 {
    font-size: 1.4em;
    font-weight: 600;
    margin-top: 30px;
    margin-bottom: 10px;
}
.article-content p {
    margin-bottom: 20px;
    color: var(--text-primary);
}
.article-content ul, .article-content ol {
    margin-bottom: 20px;
    padding-left: 25px;
}
.article-content li {
    margin-bottom: 10px;
}
.article-content a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}
.article-content a:hover {
    text-decoration: underline;
}
.article-content hr {
    border: none;
    border-top: 2px dashed var(--border-color);
    margin: 40px 0;
}
.article-content blockquote {
    border-left: 4px solid var(--accent-primary);
    padding-left: 20px;
    margin: 25px 0;
    font-size: 1.1em;
    font-style: italic;
    color: var(--text-secondary);
}
.article-content code {
    background: var(--background-color);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.9em;
}
.article-content pre {
    background: #1a1a1a; /* Always dark for code */
    color: #f0f0f0;
    padding: 20px;
    border-radius: var(--border-radius);
    overflow-x: auto; /* Allow code to scroll horizontally */
    font-size: 0.9em;
}
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
}
.article-content th, .article-content td {
    border: 1px solid var(--border-color);
    padding: 12px 15px;
    text-align: left;
}
.article-content th {
    background: var(--background-color);
    font-weight: 600;
}

/* Article layout responsive adjustments */
@media (max-width: 1000px) {
    .article-layout {
        flex-direction: column;
    }
    .article-sidebar {
        width: 100%;
        position: static; /* No sticky sidebar */
        height: auto;
        overflow-y: visible;
        margin-bottom: 25px;
        padding-right: 0;
        border-bottom: 2px solid var(--border-color);
    }
    .toc-nav {
        padding-bottom: 15px;
    }
    .article-content {
        padding: 25px;
    }
}
/* --- ^^^^ ALL THIS CODE IS NEW ^^^^ --- */


/* --- Global Header Buttons (Final Code) --- */

/* 1. Base style for all buttons (shape, size, animation) */
.global-control-button {
    /* Reset browser defaults */
    -webkit-appearance: none;
    appearance: none;

    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Box Model */
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);

    /* Style */
    color: var(--text-primary);
    background-color: var(--card-background); /* Default background (now white) */
    box-shadow: var(--shadow);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;

    /* Animation */
    transition: all 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
}

/* 2. Hover style for text expansion */
.global-control-button:hover {
    padding: 8px 18px; /* Expand padding on hover */
}

/* 3. Style for the text inside the buttons (hidden by default) */
.global-control-button .control-text {
    opacity: 0;
    width: 0;
    margin-left: 0;
    transition: opacity 0.2s ease, width 0.2s ease, margin-left 0.2s ease;
}

/* 4. Style for text on hover */
.global-control-button:hover .control-text {
    opacity: 1;
    width: auto;
    margin-left: 8px; /* Space between icon and text */
    transition-delay: 0.1s;
}

/* 5. Unified Yellow Color for all three buttons */
.btn-yellow {
    background-color: #FFDD00;
    border-color: #E0C000;
    color: #212529; /* Dark text/icon for yellow background */
}

.btn-yellow:hover {
    background-color: #F0D000;
    border-color: #D0B000;
}

