:root {
    color-scheme: light dark;

    /* Radius - static across themes */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* ===== LIGHT MODE ===== */
    /* Background */
    --bg-base: #f5f0e8;
    /* Text */
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #8a8aa8;
    /* Accent colors */
    --accent-coral: #ff6b6b;
    --accent-warm: #f59e0b;
    --accent-mint: #22c55e;
    --accent-blue: #3b82f6;
    /* Semantic */
    --error-color: #ef4444;
    --success-color: #22c55e;
    /* Cards & Inputs */
    --card-bg: #ffffff;
    --card-border: #e5e5e5;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-border-focus: var(--accent-blue);
    /* Shadows */
    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    /* Aliases */
    --shadow-soft: var(--shadow-sm);
    --shadow-elevated: var(--shadow-md);
    --ring-color: rgb(59 130 246 / 0.4);
    /* Decorative blobs */
    --blob-top-color: rgb(251 191 36 / 0.3);
    --blob-bottom-color: rgb(255 107 107 / 0.2);
    /* Secondary button */
    --secondary-bg: #f59e0b;
    --secondary-bg-hover: #d97706;
    --secondary-text: #1a1a2e;
    /* Select arrow (URL-encoded color) */
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a4a68' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    :root {
        /* ===== DARK MODE ===== */
        /* Background - neutral dark gray, not purple-tinted */
        --bg-base: #0f1115;
        /* Text - proper contrast */
        --text-primary: #e4e4e7;
        --text-secondary: #a1a1aa;
        --text-muted: #71717a;
        /* Accent colors - desaturated for dark mode */
        --accent-coral: #f87171;
        --accent-warm: #fbbf24;
        --accent-mint: #4ade80;
        --accent-blue: #60a5fa;
        /* Semantic */
        --error-color: #f87171;
        --success-color: #4ade80;
        /* Cards & Inputs - subtle elevation */
        --card-bg: #18181b;
        --card-border: #27272a;
        --input-bg: #18181b;
        --input-border: #3f3f46;
        --input-border-focus: var(--accent-blue);
        /* Shadows - more subtle in dark mode */
        --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.3);
        --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
        /* Ring */
        --ring-color: rgb(96 165 250 / 0.4);
        /* Decorative blobs - very muted in dark mode */
        --blob-top-color: rgb(96 165 250 / 0.08);
        --blob-bottom-color: rgb(248 113 113 / 0.06);
        /* Secondary button - teal/cyan works better in dark */
        --secondary-bg: #14b8a6;
        --secondary-bg-hover: #0d9488;
        --secondary-text: #0f1115;
        /* Select arrow - lighter for dark mode */
        --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    }
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    margin: 0;
    padding: 24px;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* Decorative background shapes */
body::before {
    content: '';
    position: fixed;
    top: -100px;
    right: -100px;
    width: 300px;
    height: 300px;
    background: var(--blob-top-color);
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -100px;
    left: -100px;
    width: 350px;
    height: 350px;
    background: var(--blob-bottom-color);
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
}

header {
    text-align: center;
    margin-bottom: 24px;
}

h1 {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-top: 6px;
}

/* Card/Pane styles */
.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.pane:focus-within {
    box-shadow: var(--shadow-md);
}

.pane-header {
    padding: 12px 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pane-header .label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pane-header .icon {
    width: 16px;
    height: 16px;
    color: var(--accent-coral);
}

/* Textarea styles */
textarea {
    flex: 1;
    border: none;
    padding: 16px;
    resize: none;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.8125rem;
    line-height: 1.7;
    outline: none;
    width: 100%;
    background: var(--card-bg);
    color: var(--text-primary);
}

textarea::placeholder {
    color: var(--text-muted);
}

textarea:focus {
    background: var(--card-bg);
}

textarea[readonly] {
    background: var(--card-bg);
}

/* Error message */
.error-message {
    color: white;
    padding: 10px 16px;
    font-size: 0.8125rem;
    background: var(--accent-coral);
    display: none;
    font-weight: 500;
}

/* Button styles */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    transition: all 0.15s ease;
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}

button:hover {
    background: var(--bg-base);
    border-color: var(--text-muted);
}

button:focus {
    outline: none;
    box-shadow: var(--shadow-xs), 0 0 0 3px var(--ring-color);
}

button:active {
    transform: translateY(1px);
}

button.secondary {
    background: var(--secondary-bg);
    border-color: var(--secondary-bg);
    color: var(--secondary-text);
}

button.secondary:hover {
    background: var(--secondary-bg-hover);
    border-color: var(--secondary-bg-hover);
}

.copy-btn {
    padding: 6px 12px;
    font-size: 0.8125rem;
    background: var(--accent-blue);
    color: white;
    border: none;
}

.copy-btn:hover {
    background: color-mix(in srgb, var(--accent-blue) 85%, white);
}

.copy-btn.copied {
    background: var(--accent-mint);
}

/* Form inputs */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.25;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-xs);
}

input[type="text"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="time"]:hover,
select:hover {
    border-color: var(--text-muted);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus {
    border-color: var(--input-border-focus);
    box-shadow: var(--shadow-xs), 0 0 0 3px var(--ring-color);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
}

/* Option groups (for controls) */
.option-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.option-group label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* Status indicator */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-left: 8px;
    transition: all 0.2s;
}

.status-indicator.valid {
    background: var(--accent-mint);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-mint) 25%, transparent);
}

.status-indicator.invalid {
    background: var(--accent-coral);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-coral) 25%, transparent);
}

/* Back link */
.back-link {
    position: absolute;
    top: 24px;
    left: 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    transition: all 0.15s;
}

.back-link:hover {
    color: var(--text-primary);
    background: var(--card-border);
}

.back-link svg {
    width: 16px;
    height: 16px;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    padding: 0 0 20px 0;
    gap: 10px;
    flex-wrap: wrap;
}

/* Container */
.container {
    display: flex;
    flex: 1;
    gap: 20px;
    min-height: 0;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Visually hidden (for screen readers) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile styles */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .container {
        flex-direction: column;
    }

    .pane {
        min-height: 260px;
    }

    .back-link {
        position: static;
        margin-bottom: 16px;
        justify-content: center;
    }
}
