/* Explicit appearance mode.
 * The app used to follow prefers-color-scheme with hardcoded surfaces in three
 * stylesheets. This layer is loaded last and gives the user a real Light / Dark
 * switch without changing the default palette or any layout. */

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #14151a;
  --ink-soft: #6c7280;
  --line: #e8eaf0;
  --header-bg: rgba(255, 255, 255, .92);
  --side-bg: #ffffff;
  --side-ink: #14151a;
  --chat-bg: #efe9e2;
  --accent: #0aa7ad;
  --accent-dark: #087f92;
  --accent-soft: #e9fbf9;
  --bubble-out: #dff7d7;
  --bubble-in: #ffffff;
  --st-surface: #f6f7fb;
  --st-surface-lowest: #ffffff;
  --st-surface-low: #ffffff;
  --st-surface-container: #ffffff;
  --st-surface-high: #f0f2f5;
  --st-surface-highest: #e8ebf0;
  --st-on-surface: #14151a;
  --st-on-surface-variant: #4b5563;
  --st-outline: #6c7280;
  --st-outline-variant: #dfe3ea;
  --st-primary: #087f92;
  --st-primary-container: #0aa7ad;
  --st-on-primary-container: #ffffff;
  --st-secondary: #0e7c66;
  --st-tertiary: #056f8d;
  --st-error: #b42318;
}

html[data-theme="light"] .main,
html[data-theme="light"] .mobile-content { background: #f6f7fb; }
html[data-theme="light"] .sidebar,
html[data-theme="light"] .chat-list,
html[data-theme="light"] .side-foot,
html[data-theme="light"] .cat-pills { background: #ffffff; }
html[data-theme="light"] .chat-item { background: #ffffff !important; }
html[data-theme="light"] .chat-item:nth-child(even) { background: #fafbfc !important; }
html[data-theme="light"] .ci-name { color: #14151a !important; }
html[data-theme="light"] .ci-preview { color: #6c7280 !important; }
html[data-theme="light"] .ci-time { color: #6c7280 !important; }
html[data-theme="light"] .chat-item:hover { background: #f2f4f8 !important; }
html[data-theme="light"] .chat-item.active { background: #e9fbf9 !important; }
html[data-theme="light"] .search { background: #eef0f4 !important; color: #14151a !important; }
html[data-theme="light"] .search:focus { background: #ffffff !important; }
html[data-theme="light"] .cat-pill { background: #eef0f4 !important; color: #4b5563 !important; border-color: transparent !important; }
html[data-theme="light"] .cat-pill.active { background: #e9fbf9 !important; color: #087f92 !important; border-color: #b8e3da !important; }
html[data-theme="light"] .chat-pane { background: #efe9e2; }
html[data-theme="light"] .composer { background: rgba(255, 255, 255, .95); }
html[data-theme="light"] .composer textarea { background: #ffffff; color: #14151a; }
html[data-theme="light"] .mobile-head,
html[data-theme="light"] .side-head,
html[data-theme="light"] .chat-head { background: rgba(255, 255, 255, .94); border-bottom-color: #e8eaf0; color: #14151a; }
html[data-theme="light"] .ch-name { color: #14151a; }
html[data-theme="light"] .ch-sub { color: #6c7280; }
html[data-theme="light"] .me-chip:hover { background: #f2f4f8; }
html[data-theme="light"] .day-sep { background: rgba(255, 255, 255, .94); color: #14151a; }
html[data-theme="light"] .empty-state { background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(246, 247, 251, .92)); }
html[data-theme="light"] .empty-state p { color: #6c7280; }
html[data-theme="light"] .cat-pill { background: #eef0f4; color: #4b5563; border-color: transparent; }
html[data-theme="light"] .cat-pill.active { background: #e9fbf9; color: #087f92; border-color: #b8e3da; }
html[data-theme="light"] .ci-time { color: #6c7280; }
html[data-theme="light"] .tab-nav { background: rgba(255, 255, 255, .96); }
html[data-theme="light"] .auth-wrap { background: #f6f7fb; }
html[data-theme="light"] .auth-card { background: #ffffff; border-color: #e8eaf0; }
html[data-theme="light"] .auth-card input,
html[data-theme="light"] .auth-card textarea { background: #ffffff; border-color: #dfe3ea; color: #14151a; }
html[data-theme="light"] .auth-card input:focus,
html[data-theme="light"] .auth-card textarea:focus { background: #ffffff; }
html[data-theme="light"] .tabs { background: #f2f3f7; border-color: #e5e7ee; }
html[data-theme="light"] .tab.active { background: #ffffff; }
html[data-theme="light"] .launch-note,
html[data-theme="light"] .encrypt-banner,
html[data-theme="light"] .info-banner { background: #f5f2ff; border-color: #ddd7ff; color: #454058; }
html[data-theme="light"] .settings-card { background: #ffffff; border-color: #e8eaf0; }
html[data-theme="light"] .modal { background: #ffffff; color: #14151a; }
html[data-theme="light"] .chat-head-main:hover { background: #f2f4f8; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0f14;
  --panel: #12161c;
  --ink: #eef0f4;
  --ink-soft: #99a1ad;
  --line: #252b33;
  --header-bg: rgba(24, 29, 36, .94);
  --side-bg: #12161c;
  --side-ink: #eef0f4;
  --chat-bg: #0f1519;
  --accent: #0aa7ad;
  --accent-dark: #087f92;
  --accent-soft: #27233f;
  --bubble-out: #174f46;
  --bubble-in: #20262d;
}

html[data-theme="dark"] .main,
html[data-theme="dark"] .mobile-content { background: #0c0f14; }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .chat-list,
html[data-theme="dark"] .side-foot,
html[data-theme="dark"] .cat-pills { background: #12161c; }
html[data-theme="dark"] .chat-item:hover { background: #171c23; }
html[data-theme="dark"] .chat-item.active { background: #25213c; }
html[data-theme="dark"] .search { background: #1c2229; }
html[data-theme="dark"] .chat-pane { background: #0f1519; }
html[data-theme="dark"] .composer { background: rgba(25, 30, 36, .95); }
html[data-theme="dark"] .composer textarea { background: #20262d; color: #eef0f4; }
html[data-theme="dark"] .mobile-head,
html[data-theme="dark"] .side-head,
html[data-theme="dark"] .chat-head { background: rgba(24, 29, 36, .94); border-bottom-color: #252b33; color: #eef0f4; }
html[data-theme="dark"] .ch-name { color: #eef0f4; }
html[data-theme="dark"] .ch-sub { color: #99a1ad; }
html[data-theme="dark"] .me-chip:hover { background: #20262d; }
html[data-theme="dark"] .day-sep { background: rgba(32, 38, 45, .92); color: #eef0f4; }
html[data-theme="dark"] .empty-state { background: linear-gradient(180deg, rgba(18, 22, 28, .55), rgba(12, 15, 20, .92)); }
html[data-theme="dark"] .empty-state p { color: #99a1ad; }
html[data-theme="dark"] .cat-pill { background: #1c2229; color: #c7ccd4; border-color: transparent; }
html[data-theme="dark"] .cat-pill.active { background: #27233f; color: #b9b0ff; border-color: #3a3357; }
html[data-theme="dark"] .ci-time { color: #99a1ad; }
html[data-theme="dark"] .tab-nav { background: rgba(18, 22, 28, .96); }
html[data-theme="dark"] .auth-wrap { background: #0d1015; }
html[data-theme="dark"] .auth-card { background: #151920; border-color: #272d36; }
html[data-theme="dark"] .auth-card input,
html[data-theme="dark"] .auth-card textarea { background: #10141a; border-color: #2b313a; color: #eef0f4; }
html[data-theme="dark"] .auth-card input:focus,
html[data-theme="dark"] .auth-card textarea:focus { background: #12171e; }
html[data-theme="dark"] .tabs { background: #10141a; border-color: #292e37; }
html[data-theme="dark"] .tab.active { background: #222833; }
html[data-theme="dark"] .launch-note,
html[data-theme="dark"] .encrypt-banner,
html[data-theme="dark"] .info-banner { background: #211d31; border-color: #342e4e; color: #d7d0f6; }
html[data-theme="dark"] .settings-card { background: #151a21; border-color: #282e36; }
html[data-theme="dark"] .modal { background: #151a20; color: #eef0f4; }
html[data-theme="dark"] .chat-head-main:hover { background: #20262d; }

/* Inside a conversation the tab bar belongs to the inbox, not the chat. */
@media (max-width: 768px) {
  body.chat-open .tab-nav { display: none !important; }
  body.chat-open .chat-pane { bottom: 0; max-height: 100%; }
  body.chat-open .fab { display: none !important; }
}
