:root {
    /* Color Palette */
    --bg-primary: #191919;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --bg-active: #404040;
    --bg-hover: #505050;

    /* Apple HIG Semantic Borders & Vibrancy Strokes */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.12);
    --border-color-hover: rgba(255, 255, 255, 0.24);
    --border-focus: rgba(139, 92, 246, 0.5);

    /* Text Hierarchy System */
    --text-emphasis: #ffffff;   /* 강조 (Titles, Headers, Highlight) */
    --text-primary: #e0e0e0;    /* 주요 텍스트 (Labels, Inputs, Names, Titles) */
    --text-secondary: #a0a0a0;  /* 보조 설명 (Descriptions, Sub-info, Role desc) */
    --text-muted: #707070;      /* 흐린 안내 텍스트 (Placeholders, Captions, Muted icons) */

    --accent-color: #8B5CF6; /* Violet (Point Color) */
    --accent-hover: #7c3aed;

    --danger-color: #ff6b6b;
    --danger-bg: rgba(255, 107, 107, 0.1);
    --danger-border: rgba(255, 107, 107, 0.3);

    /* Spacing Grid (4px Multiples) */
    --spacing-xs: calc(4 * var(--ws-unit, 1px));
    --spacing-sm: calc(8 * var(--ws-unit, 1px));
    --spacing-md: calc(12 * var(--ws-unit, 1px));
    --spacing-lg: calc(16 * var(--ws-unit, 1px));
    --spacing-xl: calc(20 * var(--ws-unit, 1px));
    --spacing-xxl: calc(24 * var(--ws-unit, 1px));

    /* Apple Hierarchical Corner Radii (Concentric Curvature) */
    --radius-2xs: calc(2 * var(--ws-unit, 1px));
    --radius-xs: calc(4 * var(--ws-unit, 1px));
    --radius-sm: calc(6 * var(--ws-unit, 1px));
    --radius-md: calc(10 * var(--ws-unit, 1px));
    --radius-lg: calc(14 * var(--ws-unit, 1px));
    --radius-xl: calc(18 * var(--ws-unit, 1px));
    --radius-full: calc(9999 * var(--ws-unit, 1px));

    /* Font Sizes (Standard System) */
    --font-size-sm: calc(12 * var(--ws-unit, 1px));     /* 작은 크기 (Small) */
    --font-size-base: calc(14 * var(--ws-unit, 1px));   /* 기본 크기 (Base) - Standard UI */
    --font-size-md: calc(16 * var(--ws-unit, 1px));     /* 중간 크기 (Medium) - 16px */
    --font-size-lg: calc(18 * var(--ws-unit, 1px));     /* 큰 크기 (Large) */
    --font-size-xl: calc(26 * var(--ws-unit, 1px));     /* 매우 큰 크기 (Extra Large) - 26px */

    /* Sub-Aliases for Compatibility */
    --font-size-2xs: calc(12 * var(--ws-unit, 1px));
    --font-size-xs: calc(12 * var(--ws-unit, 1px));
    --font-size-2xl: calc(26 * var(--ws-unit, 1px));

    /* Font Weights */
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Animation Easing Curves (Apple & Emil Fluid Motion Standards) */
    --ease-apple-fluid: cubic-bezier(0.16, 1, 0.3, 1);     /* Standard Fluid Spring (Damping 1.0, Response 0.35s) */
    --ease-apple-drawer: cubic-bezier(0.32, 0.72, 0, 1);    /* Dynamic Sheet / Drawer Spring (Damping 0.8, Response 0.35s) */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

    /* Animation Durations */
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-slow: 300ms;
    --duration-apple: 350ms;  /* Apple Default Fluid Spring Response Time */
}

/* 색상만 전환한다. 크기·간격·높이 비율 토큰은 두 모드가 공유한다. */
html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #f5f5f5;
    /* 메인 배경의 245/255 비율을 나머지 중립 배경에도 적용한다. */
    --bg-secondary: #e9e9e9;
    --bg-tertiary: #ededed;
    --bg-active: #dedede;
    --bg-hover: #e3e3e3;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-color: rgba(0, 0, 0, 0.12);
    --border-color-hover: rgba(0, 0, 0, 0.22);
    --text-emphasis: #191919;
    --text-primary: #303030;
    --text-secondary: #626262;
    --text-muted: var(--text-secondary);
    --danger-color: #c93636;
    --danger-bg: rgba(201, 54, 54, 0.08);
    --danger-border: rgba(201, 54, 54, 0.3);

    /* 기존 고정 색상은 다크 값을 fallback으로 보존하고 역할별로 연결한다. */
    --theme-surface-main: #f5f5f5;
    --theme-surface-panel: var(--bg-secondary);
    --theme-surface-input: var(--bg-tertiary);
    --theme-surface-hover: var(--bg-hover);
    --theme-surface-active: var(--bg-active);
    --theme-text-emphasis: var(--text-emphasis);
    --theme-text-primary: var(--text-primary);
    --theme-text-secondary: var(--text-secondary);
    --theme-text-muted: var(--text-secondary);
    --theme-accent-text: #6d28d9;
    --theme-danger-text: #c93636;
    --theme-danger-bg: rgba(201, 54, 54, 0.08);
    --theme-danger-bg-hover: rgba(201, 54, 54, 0.12);
    --theme-danger-border: rgba(201, 54, 54, 0.3);
    --theme-info-text: #1d5fbc;
    --theme-success-text: #087b55;
    --theme-warning-text: #926000;
    --theme-border: rgba(0, 0, 0, 0.12);
    --theme-foreground-rgb: 0, 0, 0;
    --theme-surface-rgb: 245, 245, 245;
    --theme-panel-rgb: 233, 233, 233;
    --theme-overlay: rgba(0, 0, 0, 0.25);
    --theme-shadow: rgba(0, 0, 0, 0.12);
    --theme-scrollbar: rgba(0, 0, 0, 0.2);
    --theme-scrollbar-hover: rgba(0, 0, 0, 0.32);
    --theme-icon-filter: brightness(0) saturate(100%) opacity(0.75);
}
