/* =====================================================================
   theme.css — cfchat 디자인 토큰 (단일 출처)
   다크: 블루-차콜 + 바이올렛 액센트 (애플/리니어 풍). 라이트도 동일 액센트.
   모든 컴포넌트는 raw 헥스 대신 토큰만 사용 → 통일성 + 라이트/다크 + 팔레트 일괄 변경.
   ===================================================================== */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  /* ===== Surfaces ===== */
  --bg: #0c0d12;
  --sidebar-bg: #0e0f15;
  --surface-1: #16181f;
  --surface-2: #1e212a;
  --surface-3: #282c37;
  --surface-sunken: #101218;
  --panel-grad: linear-gradient(180deg, #1a1d25, #15171e);
  --hero-grad: linear-gradient(135deg, #232636, #15161d);
  --overlay: rgba(6, 7, 11, .66);
  --topbar-bg: rgba(13, 14, 20, .72);
  --bottombar-bg: rgba(13, 14, 20, .82);
  --compose-fade: linear-gradient(180deg, transparent, #0c0d12 22%);

  --panel: var(--surface-1);
  --panel-2: #1e212a;
  --card-bg: var(--surface-2);
  --input-bg: var(--surface-sunken);
  --border: var(--line);

  /* ===== Borders ===== */
  --line: #262a34;
  --border-strong: #3a3f4d;

  /* ===== Text ===== */
  --text: #f2f3f7;
  --soft: #c3c7d3;
  --muted: #878d9c;
  --faint: #5b6070;
  --label: #aab2ff;

  /* ===== Brand / accent (바이올렛-인디고) ===== */
  --accent: #7c6cff;
  --accent-2: #9a8dff;
  --accent-press: #6a58f0;
  --on-accent: #ffffff;
  --accent-soft: rgba(124, 108, 255, .18);

  /* ===== Semantic ===== */
  --blue: #4aa3ff;
  --success: #54d3a0;
  --tag-bg: #242838;
  --tag-text: #c5cdf0;
  --info-bg: #122031; --info-border: #2c4a6b; --info-text: #84c2ff;
  --warn-bg: #2e2510; --warn-border: #524320; --warn-text: #f3cf73;

  --danger: #ff8a90;
  --danger-bg: #2a1820;
  --danger-border: #5d2c39;
  --danger-strong-bg: #2e1620;
  --danger-strong-border: #6e3040;
  --danger-icon: #ff9ca6;

  --notice-bg: #271521;
  --notice-border: #5a2b3c;
  --notice-text: #ffd3da;

  --toast-bg: #241a31;          --toast-border: #4a3a6e;            --toast-text: #e7defb;
  --toast-info-bg: #122031;     --toast-info-border: #2c4a6b;       --toast-info-text: #cfe8ff;
  --toast-success-bg: #102a22;  --toast-success-border: rgba(84, 211, 160, .4); --toast-success-text: #d4ffee;

  /* ===== Accents (components) ===== */
  --chat-user-bg: #2a2e3b;
  --chat-user-text: #ffffff;
  --thumb-bg: #232733;
  --avatar-color: #b3a6ff;
  --avatar-grad: linear-gradient(150deg, #7c6cff, #b06cff);
  --secondary-bg: #eef0f6;
  --secondary-text: #181a22;

  /* ===== Effects ===== */
  --focus-ring: 0 0 0 3px rgba(124, 108, 255, .32);
  --shadow-1: 0 8px 24px rgba(0, 0, 0, .38);
  --shadow-2: 0 18px 50px rgba(0, 0, 0, .52);
  --shadow-3: 0 28px 80px rgba(0, 0, 0, .62);

  /* ===== Geometry (애플식 soft corners) ===== */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --sidebar: 264px;
  --topbar: 60px;
}

:root[data-theme="light"] {
  /* only light: UA 자동 다크가 라이트 화면을 어둡게 덮어쓰지 못하게 하는 강한 opt-out */
  color-scheme: only light;

  --bg: #ffffff;
  --sidebar-bg: #ffffff;
  --surface-1: #ffffff;
  --surface-2: #f4f5fa;
  --surface-3: #e9ebf3;
  --surface-sunken: #eef0f6;
  --panel-grad: linear-gradient(180deg, #ffffff, #f8f9fc);
  --hero-grad: linear-gradient(135deg, #efecff, #eef1f8);
  --overlay: rgba(24, 26, 38, .42);
  --topbar-bg: rgba(255, 255, 255, .82);
  --bottombar-bg: rgba(255, 255, 255, .88);
  --compose-fade: linear-gradient(180deg, transparent, #f5f6fa 22%);

  --panel: var(--surface-1);
  --panel-2: #eef0f6;
  --card-bg: var(--surface-1);
  --input-bg: var(--surface-sunken);
  --border: var(--line);

  --line: #e3e5ef;
  --border-strong: #c7cad8;

  --text: #191b24;
  --soft: #434a5c;
  --muted: #6b7183;
  --faint: #9aa0b2;
  --label: #5b54d6;

  --accent: #6a59f0;
  --accent-2: #8b7cff;
  --accent-press: #5a48e0;
  --on-accent: #ffffff;
  --accent-soft: rgba(106, 89, 240, .12);

  --blue: #2f7ff0;
  --success: #16a06a;
  --tag-bg: #ebedf8;
  --tag-text: #46506e;
  --info-bg: #e9f1ff; --info-border: #bcd6f5; --info-text: #1f548f;
  --warn-bg: #fff6e1; --warn-border: #f0d89c; --warn-text: #8a6a18;

  --danger: #c93b48;
  --danger-bg: #fdecee;
  --danger-border: #f1c3ca;
  --danger-strong-bg: #fdecee;
  --danger-strong-border: #eebbc2;
  --danger-icon: #c93b48;

  --notice-bg: #fdecf0;
  --notice-border: #f2c4cf;
  --notice-text: #93233a;

  --toast-bg: #efeaff;          --toast-border: #cdc2f3;            --toast-text: #483a8a;
  --toast-info-bg: #e9f1ff;     --toast-info-border: #bcd6f5;       --toast-info-text: #1f548f;
  --toast-success-bg: #e6f7ef;  --toast-success-border: #b1e3cc;    --toast-success-text: #156b46;

  --chat-user-bg: #e9e6fb;
  --chat-user-text: #191b24;
  --thumb-bg: #e6e8f2;
  --avatar-color: #6a59f0;
  --avatar-grad: linear-gradient(150deg, #8b7cff, #c79bff);
  --secondary-bg: #1d1f2a;
  --secondary-text: #ffffff;

  --focus-ring: 0 0 0 3px rgba(106, 89, 240, .24);
  --shadow-1: 0 8px 24px rgba(20, 22, 50, .08);
  --shadow-2: 0 18px 50px rgba(20, 22, 50, .12);
  --shadow-3: 0 28px 80px rgba(20, 22, 50, .16);
}

/* 부드러운 테마 전환 */
.theme-anim,
.theme-anim * {
  transition: background-color .25s ease, border-color .25s ease, color .2s ease;
}

/* ===== 테마 토글 버튼 ===== */
.theme-toggle {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--soft);
  display: inline-grid;
  place-items: center;
  padding: 0;
  transition: background-color .16s ease, color .16s ease, transform .08s ease;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text); }
.theme-toggle:active { transform: scale(.93); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
