/* Theme tokens. Light is the default; [data-theme="dark"] overrides apply for dark mode. */

:root {
    --bg-base: #f5f6f8;
    --bg-surface: #ffffff;
    --bg-sunken: #eef0f4;
    --bg-deep: #f0f2f6;
    --bg-elevated: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.04);
    --bg-tap: #e8ebf0;

    --border-subtle: #e5e7eb;
    --border-default: #d1d5db;
    --border-strong: #9ca3af;
    --border-focus: #2563eb;

    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-disabled: #9ca3af;
    --text-inverse: #ffffff;
    --text-on-accent: #ffffff;

    --accent: #e94560;
    --accent-hover: #c73852;
    --accent-soft: rgba(233, 69, 96, 0.10);

    --action: #2563eb;
    --action-hover: #1d4ed8;
    --action-soft: rgba(37, 99, 235, 0.10);

    --success: #059669;
    --success-bg: #d1fae5;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;

    --link: #2563eb;
    --link-hover: #1d4ed8;

    --code-bg: #f4f4f5;
    --code-text: #1f2937;

    --hold-color: #FFD700;
    --hold-stroke: #d97706;
    --badge-gold-bg: #FFD700;
    --badge-gold-text: #1a1a2e;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.4rem;
    --text-2xl: 1.8rem;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
}

[data-theme="dark"] {
    --bg-base: #1a1a2e;
    --bg-surface: #16213e;
    --bg-sunken: #0f1d3a;
    --bg-deep: #0a0e21;
    --bg-elevated: #1a2952;
    --bg-overlay: rgba(15, 21, 35, 0.6);
    --bg-tap: #1f2a4d;

    --border-subtle: #1a2952;
    --border-default: #0f3460;
    --border-strong: #1a4a8a;
    --border-focus: #e94560;

    --text-primary: #eeeeee;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --text-disabled: #555555;
    --text-inverse: #16213e;

    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-soft: rgba(233, 69, 96, 0.18);

    --action: #1a4a8a;
    --action-hover: #245fb0;
    --action-soft: rgba(26, 74, 138, 0.30);

    --success: #34D399;
    --success-bg: rgba(52, 211, 153, 0.16);
    --warning: #ffa657;
    --warning-bg: rgba(255, 166, 87, 0.16);
    --danger: #ff6b81;
    --danger-bg: #4a1a26;
    --danger-text: #ff8a9c;

    --link: #60A5FA;
    --link-hover: #93c5fd;

    --code-bg: #0a0e21;
    --code-text: #b8c5d6;

    --hold-stroke: #FFD700;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);
}

/* Common base */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    height: 100%;
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Utility classes used inside JS template literals (replaces inline style="color:#xxx") */
.u-text-primary   { color: var(--text-primary); }
.u-text-secondary { color: var(--text-secondary); }
.u-text-muted     { color: var(--text-muted); }
.u-text-disabled  { color: var(--text-disabled); }
.u-text-danger    { color: var(--danger-text); }
.u-text-success   { color: var(--success); }
.u-text-warning   { color: var(--warning); }
.u-text-accent    { color: var(--accent); }
.u-text-link      { color: var(--link); }
.u-badge-gold     { background: var(--badge-gold-bg); color: var(--badge-gold-text); }

/* Theme toggle button (shared across pages) */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}
.theme-toggle:hover {
    background: var(--bg-overlay);
    border-color: var(--border-strong);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
