:root {
    /* Font Families */
    --font-body: 'Poppins', Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
        Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

    /* Main Colors - Modern Blue-Grey Theme */
    --bg-main: #f0f4f8; /* Soft blue-grey background */
    --bg-main-dark: #111827; /* Deep navy for dark mode */

    /* Text Colors */
    --color-text: #1e293b; /* Slate-800 - readable without being harsh */
    --color-text-light: #64748b; /* Slate-500 - balanced secondary text */
    --color-text-dark: #e2e8f0; /* Slate-200 - comfortable on dark backgrounds */

    /* Background Colors - Clear visual hierarchy */
    --color-bg-0: #ffffff; /* Cards & surfaces - white pops against bg-main */
    --color-bg-1: #e2e8f0; /* Sidebar & secondary surfaces */
    --color-bg-2: #cbd5e1; /* Borders & accent areas */

    /* Theme Colors - Modern Blue */
    --color-theme-1: #3b82f6; /* Blue-500 - vibrant, modern */
    --color-theme-2: #2563eb; /* Blue-600 - hover state */

    /* Button Colors */
    --button-bg: #3b82f6;
    --button-bg-hover: #2563eb;
    --button-bg-disabled: #94a3b8;
    --button-border: #cbd5e1;
    --button-border-hover: #3b82f6;
    --button-text-color-common: #ffffff;

    /* Button Colors - Dark Theme */
    --button-bg-dark: #60a5fa;
    --button-bg-hover-dark: #3b82f6;
    --button-bg-disabled-dark: #475569;
    --button-border-dark: #334155;
    --button-border-hover-dark: #60a5fa;

    /* Radio Button Colors */
    --radio-button-active: #3b82f6;
    --radio-button-inactive: #94a3b8;
    --radio-button-active-dark: #60a5fa;
    --radio-button-inactive-dark: #475569;

    /* Input Colors */
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-border-focus: #3b82f6;

    /* Header Colors */
    --header-text-color: #1e40af;
    --subheader-text-color: #1e3a5f;
    --header-text-color-dark: #93c5fd;
    --subheader-text-color-dark: #60a5fa;

    /* Semantic Colors */
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #06b6d4;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px rgba(15, 23, 42, 0.1), 0 4px 6px rgba(15, 23, 42, 0.05);

    /* Layout Variables */
    --column-width: 42rem;
    --column-margin-top: 4rem;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
}

body {
    min-height: 100vh;
    margin: 0;
    font-family: var(--font-body);
    color: var(--color-text);
    background-attachment: fixed;
    background-color: var(--bg-main);
    background-size: 100vw 100vh;
    background-image: linear-gradient(160deg, #eef2f7 0%, var(--bg-main) 50%, #e8edf4 100%);
}

h1,
h2,
p {
    font-weight: 400;
}

p {
    line-height: 1.6;
}

a {
    color: var(--color-theme-1);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--color-theme-2);
    text-decoration: underline;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--header-text-color);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--subheader-text-color);
}

pre {
    font-size: 16px;
    font-family: var(--font-mono);
    background-color: #f1f5f9;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 1em;
    overflow-x: auto;
    color: var(--color-text);
}

.text-column {
    display: flex;
    max-width: 60rem;
    flex: 0.6;
    flex-direction: column;
    justify-content: center;
    margin: 0 auto;
}

/* Input and Button Base Styles */
input,
button,
textarea,
select {
    font-size: inherit;
    font-family: inherit;
}

/* Button Styles */
button {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    background-color: var(--button-bg);
    color: var(--button-text-color-common);
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

button:hover {
    background-color: var(--button-bg-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

button:disabled {
    background-color: var(--button-bg-disabled);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

button:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.4);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

/* Input Fields */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea,
select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-sm);
    background-color: var(--input-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
    border-color: var(--input-border-focus);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled,
input[type="number"]:disabled,
input[type="date"]:disabled,
input[type="time"]:disabled,
textarea:disabled,
select:disabled {
    background-color: var(--color-bg-1);
    cursor: not-allowed;
    opacity: 0.6;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

/* Radio Buttons */
.radio-button,
input[type="radio"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--radio-button-inactive);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    margin-right: 0.5rem;
    transition: border-color 0.3s ease;
    flex-shrink: 0;
}

.radio-button:checked,
input[type="radio"]:checked {
    border-color: var(--radio-button-active);
}

.radio-button:checked::after,
input[type="radio"]:checked::after {
    content: '';
    width: 10px;
    height: 10px;
    background-color: var(--radio-button-active);
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
}

.radio-button:focus-visible,
input[type="radio"]:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.4);
    outline-offset: 2px;
}

/* Checkboxes */
input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--radio-button-inactive);
    border-radius: var(--border-radius-sm);
    position: relative;
    cursor: pointer;
    margin-right: 0.5rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

input[type="checkbox"]:checked {
    background-color: var(--radio-button-active);
    border-color: var(--radio-button-active);
}

input[type="checkbox"]:checked::after {
    content: '\2713';
    color: white;
    font-size: 14px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.4);
    outline-offset: 2px;
}

/* Headers and Subheaders */
.header {
    color: var(--header-text-color);
}

.subheader {
    color: var(--subheader-text-color);
}

/* Legend Text for Charts */
.legend-text {
    fill: var(--color-text);
    font-size: 12px;
}

@media (min-width: 720px) {
    h1 {
        font-size: 2.4rem;
    }
}

.visually-hidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: auto;
    margin: 0;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    white-space: nowrap;
}

/* Dark Theme - Override all CSS variables so every component adapts automatically */
[data-theme="dark"] {
    /* Main Colors */
    --bg-main: #111827;

    /* Text Colors */
    --color-text: #e2e8f0;
    --color-text-light: #94a3b8;

    /* Background Colors */
    --color-bg-0: #1e293b; /* Cards & surfaces */
    --color-bg-1: #162032; /* Sidebar & secondary surfaces */
    --color-bg-2: #334155; /* Borders & accent areas */

    /* Theme Colors */
    --color-theme-1: #60a5fa;
    --color-theme-2: #3b82f6;

    /* Button Colors */
    --button-bg: #60a5fa;
    --button-bg-hover: #3b82f6;
    --button-bg-disabled: #475569;
    --button-border: #334155;
    --button-border-hover: #60a5fa;
    --button-text-color-common: #0f172a;

    /* Radio Button Colors */
    --radio-button-active: #60a5fa;
    --radio-button-inactive: #475569;

    /* Input Colors */
    --input-bg: #1e293b;
    --input-border: #334155;
    --input-border-focus: #60a5fa;

    /* Header Colors */
    --header-text-color: #93c5fd;
    --subheader-text-color: #60a5fa;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35), 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Dark Theme - Element-specific overrides for things not covered by variables */
[data-theme="dark"] body,
html[data-theme="dark"] body {
    background-image: linear-gradient(160deg, #0c1220 0%, #111827 50%, #0f172a 100%);
}

[data-theme="dark"] a {
    color: #93c5fd;
}

[data-theme="dark"] a:hover {
    color: #bfdbfe;
}

[data-theme="dark"] pre {
    background-color: #1e293b;
}

[data-theme="dark"] button:hover {
    color: #ffffff;
}

[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="email"]:focus,
[data-theme="dark"] input[type="password"]:focus,
[data-theme="dark"] input[type="number"]:focus,
[data-theme="dark"] input[type="date"]:focus,
[data-theme="dark"] input[type="time"]:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

[data-theme="dark"] button:disabled {
    color: #94a3b8;
}

[data-theme="dark"] button:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.4);
}

[data-theme="dark"] .radio-button:focus-visible,
[data-theme="dark"] input[type="radio"]:focus-visible,
[data-theme="dark"] input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.4);
}
