/**
 * Desmos & WolframAlpha Design Tokens: 100% Authentic Desmos Aesthetic
 */
:root, [data-theme="light"] {
    /* Desmos Header (Always Dark Charcoal) */
    --header-bg: #27282a;
    --header-border: #1e1f21;
    --header-text: #ffffff;
    --header-text-muted: #9aa0a6;

    /* Workspace & Surfaces (Desmos Classic Light) */
    --bg-base: #ffffff;
    --bg-surface: #ffffff;
    --bg-sidebar: #fcfcfc;
    --bg-elevated: #f1f3f5;
    --bg-hover: #e8ecf0;
    --bg-active: #dce1e7;

    --border-subtle: #edf0f2;
    --border-medium: #d9dee3;
    --border-strong: #bac2cb;

    --text-primary: #18191d;
    --text-secondary: #495057;
    --text-muted: #868e96;

    /* Desmos Authentic 6-Color Curve Palette */
    --curve-blue: #2d70b3;
    --curve-green: #388c46;
    --curve-amber: #fa7e19;
    --curve-purple: #6042a6;
    --curve-red: #c74440;
    --curve-teal: #008080;

    /* Keypad Colors */
    --keypad-bg: #eaecf0;
    --keypad-btn-bg: #ffffff;
    --keypad-btn-border: #d0d5dd;
    --keypad-btn-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
    --keypad-op-bg: #f2f4f7;
    --keypad-action-bg: #2d70b3;

    /* Radii & Fonts */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.18);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
}

[data-theme="dark"] {
    --header-bg: #141517;
    --header-border: #202226;
    --header-text: #ffffff;
    --header-text-muted: #80868b;

    --bg-base: #101114;
    --bg-surface: #16171b;
    --bg-sidebar: #131417;
    --bg-elevated: #1e2025;
    --bg-hover: #26282f;
    --bg-active: #2f323a;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.25);

    --text-primary: #f1f3f5;
    --text-secondary: #9aa0a6;
    --text-muted: #60646c;

    --curve-blue: #3b82f6;
    --curve-green: #22c55e;
    --curve-amber: #f59e0b;
    --curve-purple: #8b5cf6;
    --curve-red: #ef4444;
    --curve-teal: #14b8a6;

    --keypad-bg: #18191d;
    --keypad-btn-bg: #22242a;
    --keypad-btn-border: rgba(255, 255, 255, 0.1);
    --keypad-btn-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --keypad-op-bg: #1e2025;
    --keypad-action-bg: #3b82f6;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
}

/* Workstations Dark Mode Overrides */
[data-theme="dark"] .workstation-container {
    background: #090d16;
}

[data-theme="dark"] .tool-view-card {
    background: #111827;
    border-color: #1f2937;
    color: #f3f4f6;
}

[data-theme="dark"] .tool-view-header h2 {
    color: #f9fafb;
}

[data-theme="dark"] .btn-tool-back {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
}

[data-theme="dark"] .btn-tool-back:hover {
    background: #374151;
    color: #ffffff;
}

[data-theme="dark"] .custom-select-trigger {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

[data-theme="dark"] .custom-select-trigger:hover {
    background: #374151;
    border-color: #4b5563;
}

[data-theme="dark"] .custom-select-container.open .custom-select-trigger,
[data-theme="dark"] .custom-select-trigger:focus {
    border-color: #ec4899;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.25);
}

[data-theme="dark"] .custom-select-chevron {
    color: #9ca3af;
}

[data-theme="dark"] .custom-select-container.open .custom-select-chevron {
    color: #ec4899;
}

[data-theme="dark"] .custom-select-menu {
    background: #111827;
    border-color: #374151;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .custom-select-option {
    color: #d1d5db;
}

[data-theme="dark"] .custom-select-option:hover {
    background: #1f2937;
    color: #ffffff;
}

[data-theme="dark"] .custom-select-option.selected {
    background: #371b28;
    color: #f472b6;
}

[data-theme="dark"] .d3-custom-dropdown,
[data-theme="dark"] .geom-select-preset,
[data-theme="dark"] .nb-select-template {
    background-color: #1f2937;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    border-color: #374151;
    color: #f9fafb;
}

[data-theme="dark"] .d3-custom-dropdown option,
[data-theme="dark"] .geom-select-preset option,
[data-theme="dark"] .nb-select-template option {
    background: #111827;
    color: #f9fafb;
}

[data-theme="dark"] .d3-input {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

[data-theme="dark"] .d3-toolbar-row,
[data-theme="dark"] .geometry-pro-toolbar {
    background: #111827;
    border-color: #1f2937;
}

[data-theme="dark"] .d3-btn-action,
[data-theme="dark"] .geom-tool-btn,
[data-theme="dark"] .geom-action-btn,
[data-theme="dark"] .nb-action-btn {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
}

[data-theme="dark"] .d3-btn-action:hover,
[data-theme="dark"] .geom-tool-btn:hover,
[data-theme="dark"] .geom-action-btn:hover,
[data-theme="dark"] .nb-action-btn:hover {
    background: #374151;
    color: #ffffff;
}

[data-theme="dark"] .geometry-canvas-wrapper {
    background: #111827;
    border-color: #374151;
}

[data-theme="dark"] .notebook-doc-title {
    color: #f9fafb;
}

[data-theme="dark"] .notebook-cell {
    background: #111827;
    border-color: #1f2937;
}

[data-theme="dark"] .nb-text-editor {
    color: #e5e7eb;
}

[data-theme="dark"] .nb-text-editor:hover,
[data-theme="dark"] .nb-text-editor:focus {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .nb-math-input {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

[data-theme="dark"] .nb-math-output,
[data-theme="dark"] .nb-fit-info {
    background: #1f2937;
    border-color: #374151;
}

[data-theme="dark"] .nb-output-result,
[data-theme="dark"] .nb-fit-eq {
    color: #60a5fa;
}

[data-theme="dark"] .btn-nb-add {
    background: #1f2937;
    border-color: #374151;
    color: #d1d5db;
}

[data-theme="dark"] .btn-nb-add:hover {
    background: #374151;
    color: #ffffff;
}
