/* Perpranov AI — Professional Theme & UI Styles */

:root,
[data-theme="dark"] {
  /* Typography */
  --font-ui: 'Inter', 'Noto Sans Tamil', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-brand: 'Outfit', sans-serif;

  /* Silver Christmas Season Palette Tokens */
  --xmas-primary: #C0C7D1;          /* Silver */
  --xmas-primary-hover: #E3E8EF;    /* Light Silver */
  --xmas-accent: #9AA4B2;           /* Deeper silver for borders */
  --xmas-text-on-primary: #0B1220;  /* Dark text on silver for contrast */
  --xmas-gold-highlight: #FFD700;   /* Use sparingly */
  --xmas-warm-white: #FFF8F0;       /* Warm White */

  /* Compatibility aliases */
  --xmas-primary-red: var(--xmas-primary);
  --xmas-primary-red-hover: var(--xmas-primary-hover);
  --xmas-santa-red: var(--xmas-accent);
  --xmas-gold: var(--xmas-gold-highlight);
  --xmas-dark-red: var(--xmas-accent);

  /* Night Theme (Default) */
  --bg-primary: #050816;          /* Deep navy dark base background */
  --bg-surface: #0f172a;          /* Surface / sidebar / cards */
  --bg-surface-elevated: #162036; /* Slightly elevated surfaces */
  --bg-input: #0b1426;            /* Unified search bar background */
  --border-color: #1e293b;        /* Subtle borders */
  --border-focus: var(--xmas-primary); /* Active focus border */
  --text-primary: #f8fafc;        /* Off-white text */
  --text-secondary: #94a3b8;      /* Muted text */
  --text-muted: #64748b;          /* Faint secondary text */

  /* Accent Family (Silver Christmas Palette) */
  --accent-color: var(--xmas-primary);
  --accent-secondary: var(--xmas-accent);
  --accent-warm-white: var(--xmas-warm-white);
  --accent-gold: var(--xmas-gold-highlight);
  --accent-glow: rgba(192, 199, 209, 0.25);
  --accent-gradient: linear-gradient(135deg, var(--xmas-primary) 0%, var(--xmas-accent) 100%);
  --accent-hover: var(--xmas-primary-hover);

  /* Watermark opacity */
  --watermark-opacity: 0.09;

  /* Name accent (welcome heading) — Silver */
  --name-accent: var(--xmas-primary);

  /* Icon tile (attachment menu) */
  --icon-tile-bg: rgba(192, 199, 209, 0.10);
  --icon-tile-border: rgba(154, 164, 178, 0.30);
  --icon-tile-color: var(--xmas-primary);

  /* Message Bubbles */
  --user-bubble-bg: linear-gradient(135deg, var(--xmas-primary) 0%, #7e8b9b 100%);
  --user-bubble-text: var(--xmas-text-on-primary);
  --ai-bubble-bg: #0f172a;
  --ai-bubble-border: #1e293b;
  --ai-bubble-text: #f1f5f9;

  /* Parent company logo */
  --parent-logo-url: url('/static/lawrence-joseph-techno-logo-dark.png');
}

body.light,
[data-theme="light"] {
  /* Day Theme (Light) */
  --bg-primary: #f8fafc;          /* Soft light grey */
  --bg-surface: #ffffff;          /* Pure white card surface */
  --bg-surface-elevated: #f1f5f9; /* Soft grey elevated surface */
  --bg-input: #ffffff;            /* Crisp white search bar */
  --border-color: #e2e8f0;        /* Subtle light grey border */
  --border-focus: var(--xmas-accent); /* Silver accent focus */
  --text-primary: #0f172a;        /* Near-black text */
  --text-secondary: #475569;      /* Slate grey text */
  --text-muted: #64748b;          /* Soft grey text */

  /* Accent Family (Silver Day Theme) */
  --accent-color: var(--xmas-accent);
  --accent-secondary: var(--xmas-primary);
  --accent-warm-white: var(--xmas-warm-white);
  --accent-gold: var(--xmas-gold-highlight);
  --accent-glow: rgba(154, 164, 178, 0.20);
  --accent-gradient: linear-gradient(135deg, var(--xmas-accent) 0%, var(--xmas-primary) 100%);
  --accent-hover: #7b8696;

  /* Watermark opacity (18-22%) — darker for readability on light bg */
  --watermark-opacity: 0.20;

  /* Name accent (welcome heading) */
  --name-accent: var(--xmas-accent);

  /* Icon tile (attachment menu) */
  --icon-tile-bg: rgba(154, 164, 178, 0.12);
  --icon-tile-border: rgba(154, 164, 178, 0.30);
  --icon-tile-color: var(--xmas-accent);

  /* Message Bubbles */
  --user-bubble-bg: linear-gradient(135deg, var(--xmas-primary) 0%, var(--xmas-accent) 100%);
  --user-bubble-text: var(--xmas-text-on-primary);
  --ai-bubble-bg: #ffffff;
  --ai-bubble-border: #e2e8f0;
  --ai-bubble-text: #0f172a;

  /* Parent company logo */
  --parent-logo-url: url('/static/lawrence-joseph-techno-logo.png');
}

/* Base resets & typography */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Main chat page fixed viewport shell (no outer page scroll, no duplicate scrollbars) */
html.chat-page,
body.chat-page {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.app-shell {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

#sidebar.chat-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#sidebar.chat-sidebar .sidebar-scroll-region {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
}

#sidebar.chat-sidebar #history-list {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
}

#sidebar.chat-sidebar .sidebar-user-section {
  flex-shrink: 0;
}

.main-chat-col {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  height: 100dvh;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.chat-area-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  height: 100%;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.chat-bg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  user-select: none;
  z-index: 0;
}

#chat-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Distinct Brand Name Styling */
.brand-name {
  font-family: var(--font-brand);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  line-height: 1.2;
}

body:not(.light) .brand-name {
  text-shadow: 0 0 20px rgba(192, 199, 209, 0.35);
}

body.light .brand-name {
  text-shadow: 0 1px 2px rgba(154, 164, 178, 0.25);
}

#sidebar .brand-name {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Welcome Header User Name Accent */
.welcome-user-name {
  color: var(--name-accent) !important;
  transition: color 0.25s ease;
}

/* Icon Tile for Attachment Menu SVGs */
.icon-tile-36 {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--icon-tile-bg);
  border: 1px solid var(--icon-tile-border);
  color: var(--icon-tile-color);
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* Chat Container Eagle Watermark */
.chat-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  max-width: 420px;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  z-index: 0;
  opacity: var(--watermark-opacity);
  transition: opacity 0.3s ease;
  user-select: none;
}

@media (max-width: 640px) {
  .chat-watermark {
    width: 70%;
  }
}

body > * {
  position: relative;
  z-index: 1;
}

/* Ensure welcome hero and chat messages sit cleanly */
#welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

#welcome-hero > * {
  max-width: 100%;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* Day (Light) Theme Overrides */
body.light .bg-slate-950 {
  background-color: var(--bg-primary) !important;
}

body.light .bg-slate-900,
body.light .bg-slate-900\/90,
body.light .bg-slate-900\/80,
body.light .bg-slate-900\/60 {
  background-color: var(--bg-surface) !important;
}

body.light .bg-slate-800,
body.light .bg-slate-800\/80,
body.light .bg-slate-800\/60,
body.light .bg-slate-800\/90 {
  background-color: var(--bg-surface-elevated) !important;
}

body.light .border-slate-800,
body.light .border-slate-700,
body.light .border-slate-700\/80,
body.light .border-slate-700\/60 {
  border-color: var(--border-color) !important;
}

body.light .text-slate-100,
body.light .text-slate-200 {
  color: var(--text-primary) !important;
}

body.light .text-slate-300,
body.light .text-slate-400 {
  color: var(--text-secondary) !important;
}

body.light .text-slate-500 {
  color: var(--text-muted) !important;
}

body.light input,
body.light select,
body.light textarea {
  background-color: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

body.light input::placeholder {
  color: var(--text-muted) !important;
}

/* Password visibility toggle button */
.password-toggle-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: color 0.15s ease;
}
.password-toggle-btn:hover {
  color: #e2e8f0;
}
body.light .password-toggle-btn {
  color: var(--text-muted) !important;
}
body.light .password-toggle-btn:hover {
  color: var(--text-primary) !important;
}

/* Unified Search Bar Box */
.search-bar-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  transition: all 0.2s ease;
}

body.light .search-bar-box {
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

.search-bar-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Restyled Compact Send Button: Fully transparent background with colored border */
.send-btn, #send-btn, #agent-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: transparent !important;
  border: 1.5px solid var(--theme-send-btn-border, var(--xmas-primary, #C0C7D1)) !important;
  color: var(--theme-send-btn-border, var(--xmas-primary, #C0C7D1)) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease, border-color 0.2s ease, color 0.2s ease;
  box-shadow: none !important;
}

.send-btn svg, #send-btn svg, #agent-send-btn svg {
  color: inherit !important;
  stroke: currentColor !important;
  opacity: 1 !important;
}

.send-btn:hover, #send-btn:hover, #agent-send-btn:hover {
  transform: scale(1.04);
  background: rgba(192, 199, 209, 0.12) !important;
}

.send-btn:active, #send-btn:active, #agent-send-btn:active {
  transform: scale(0.96);
}

.send-btn:disabled, #send-btn:disabled, #agent-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

body.light .send-btn, body.light #send-btn, body.light #agent-send-btn {
  border-color: var(--theme-send-btn-border, var(--xmas-accent, #9AA4B2)) !important;
  color: var(--theme-send-btn-border, var(--xmas-accent, #0B1220)) !important;
}

body.light .send-btn:hover, body.light #send-btn:hover, body.light #agent-send-btn:hover {
  background: rgba(154, 164, 178, 0.15) !important;
}

/* Search bar icon: Fully solid (opaque) with configured color */
.search-bar-icon, #chat-search-icon, .search-bar-box .search-bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-search-icon, var(--xmas-primary, #C0C7D1)) !important;
  opacity: 1 !important;
  fill: none;
  stroke: currentColor;
}

.search-bar-icon svg, #chat-search-icon svg {
  color: var(--theme-search-icon, var(--xmas-primary, #C0C7D1)) !important;
  stroke: currentColor !important;
  opacity: 1 !important;
}

body.light .search-bar-icon, body.light #chat-search-icon {
  color: var(--theme-search-icon, var(--xmas-accent, #64748B)) !important;
  opacity: 1 !important;
}

body.light .search-bar-icon svg, body.light #chat-search-icon svg {
  color: var(--theme-search-icon, var(--xmas-accent, #64748B)) !important;
  stroke: currentColor !important;
  opacity: 1 !important;
}

/* App Logo Circle Ring: uses configured ring color or none/transparent */
.app-logo-ring {
  background: var(--theme-logo-ring, var(--xmas-primary, #C0C7D1)) !important;
  padding: 2px !important;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: all 0.2s ease;
}

.app-logo-ring.ring-none,
.app-logo-ring[data-ring="none"],
.app-logo-ring[data-ring="transparent"] {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border: none !important;
}

/* New Conversation button */
#new-chat-btn {
  background: var(--theme-new-chat-btn, var(--xmas-primary, #C0C7D1)) !important;
  color: var(--theme-text-on-primary, #0B1220) !important;
}

/* Primary buttons (Upgrade, etc.) */
.primary-btn, #quick-settings-pro-btn, #dropdown-plan-pro-btn, .free-plan-upgrade-btn {
  background: var(--theme-primary-btn, var(--xmas-primary, #C0C7D1)) !important;
  color: var(--theme-text-on-primary, #0B1220) !important;
}

/* Other buttons */
.other-btn, .msg-action-btn, #free-plan-timer-badge {
  color: var(--theme-other-btn, var(--xmas-accent, #9AA4B2)) !important;
  border-color: var(--theme-other-btn, var(--xmas-accent, #9AA4B2)) !important;
}

/* Header & Sidebar background */
header.chat-header, #sidebar, .sidebar-footer {
  background-color: var(--theme-header-sidebar-bg, #0f172a) !important;
}

body.light header.chat-header, body.light #sidebar, body.light .sidebar-footer {
  background-color: var(--theme-header-sidebar-bg, #ffffff) !important;
}

/* Microphone Button Inside Search Bar */
.mic-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.mic-btn:hover {
  color: var(--accent-color);
  background: rgba(192, 199, 209, 0.12);
  border-color: rgba(154, 164, 178, 0.35);
}

body.light .mic-btn:hover {
  color: var(--accent-color);
  background: rgba(154, 164, 178, 0.15);
  border-color: rgba(154, 164, 178, 0.35);
}

.mic-btn.recording {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #ef4444 !important;
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Attachment Menu Popup */
#attachment-menu {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

body.light #attachment-menu {
  background-color: #ffffff;
  border-color: var(--border-color);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

body.light #attachment-menu button {
  color: var(--text-primary);
}

body.light #attachment-menu button:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--accent-color);
}

/* Message Bubble Styling */
.chat-bubble-user {
  background: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  border-radius: 20px 20px 4px 20px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.chat-bubble-ai {
  background: var(--ai-bubble-bg);
  border: 1px solid var(--ai-bubble-border);
  color: var(--ai-bubble-text);
  border-radius: 20px 20px 20px 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

body.light .chat-bubble-ai {
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}

/* Markdown Formatting Inside AI Bubbles */
.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4 {
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
}

.chat-markdown p {
  margin-bottom: 0.75rem;
  line-height: 1.65;
}

.chat-markdown p:last-child {
  margin-bottom: 0;
}

.chat-markdown ul,
.chat-markdown ol {
  margin-left: 1.25rem;
  margin-bottom: 0.75rem;
}

.chat-markdown li {
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.chat-markdown ul {
  list-style-type: disc;
}

.chat-markdown ol {
  list-style-type: decimal;
}

.chat-markdown blockquote {
  border-left: 3px solid var(--accent-color);
  padding-left: 0.85rem;
  margin: 0.75rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.chat-markdown pre {
  background: #030712;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  position: relative;
}

body.light .chat-markdown pre {
  background: #0f172a;
  color: #f8fafc;
}

.chat-markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875em;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.15);
  color: #38bdf8;
}

body.light .chat-markdown code {
  color: #0284c7;
}

.chat-markdown pre code {
  background: transparent;
  padding: 0;
  color: #e2e8f0;
}

/* Copy Code Button */
.copy-code-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.8);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
  cursor: pointer;
  transition: all 0.2s;
}

.copy-code-btn:hover {
  background: rgba(0, 245, 255, 0.2);
  color: var(--accent-color);
}

/* Loading Typing Dots */
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Founder Cards */
.founder-card {
  background: var(--bg-surface);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.founder-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

body.light .founder-card {
  background: #f8fafc;
  border-color: var(--accent-color);
}

/* Settings Panel (Desktop Popover & Mobile Bottom Sheet) */
.settings-panel {
  position: fixed;
  z-index: 75;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
  animation: settingsFadeIn 0.18s ease-out;
}

body.light .settings-panel {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

@keyframes settingsFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile: Bottom Sheet */
@media (max-width: 767px) {
  .settings-panel {
    inset-inline: 0;
    bottom: 0;
    width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    overflow-y: auto;
    padding: 18px 20px 28px;
    z-index: 100;
  }
}

/* Desktop: Popover anchored above sidebar profile card */
@media (min-width: 768px) {
  .settings-panel {
    border-radius: 16px;
    padding: 16px;
    min-width: 290px;
    max-width: 320px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
}

/* Star Rating Buttons */
.star-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.star-btn:hover {
  transform: scale(1.15);
}

.star-btn svg {
  fill: none;
  stroke: currentColor;
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.star-btn.active,
.star-btn.hovered {
  color: #f59e0b;
}

.star-btn.active svg,
.star-btn.hovered svg {
  fill: #f59e0b;
  stroke: #f59e0b;
}

body.light .star-btn.active,
body.light .star-btn.hovered {
  color: #d97706;
}

body.light .star-btn.active svg,
body.light .star-btn.hovered svg {
  fill: #d97706;
  stroke: #d97706;
}

/* Segmented Control for Theme */
.segmented-control {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.theme-choice-btn {
  padding: 3.5px 10px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-choice-btn:hover {
  color: var(--text-primary);
}

.theme-choice-btn.active {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

body:not(.light) .theme-choice-btn.active {
  color: #070d19;
}

/* Settings Toggle Buttons (Read Aloud, Save History) */
.settings-toggle-btn {
  padding: 3.5px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  min-width: 48px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-toggle-btn:hover {
  border-color: var(--border-focus);
}

/* Gear button active styling */
#settings-btn {
  transition: all 0.2s ease;
}

#settings-btn[aria-expanded="true"] {
  color: var(--accent-color);
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-color);
}

/* Contrast enhancement for active badges in light mode */
body.light .text-cyan-400 {
  color: var(--accent-color) !important;
}

/* ====================================================
   Image Edit Mode & Result Display Styles
   ==================================================== */
.edit-mode-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.edit-mode-title {
  color: var(--accent-color);
}

.edit-credits-badge {
  background: var(--icon-tile-bg);
  color: var(--accent-color);
  border: 1px solid var(--icon-tile-border);
  letter-spacing: 0.02em;
}

.edit-mode-cancel-btn {
  color: var(--text-muted);
}

.edit-mode-cancel-btn:hover {
  color: #ef4444;
}

#edit-mode-thumb {
  border-color: var(--icon-tile-border);
}

/* Image Action Buttons (Download & Edit Again) */
.image-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.image-action-btn:hover {
  border-color: var(--border-focus);
  color: var(--accent-color);
  transform: translateY(-1px);
}

.image-action-btn:active {
  transform: translateY(0);
}

.edited-image-card {
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-elevated);
  border-radius: 0.875rem;
  overflow: hidden;
  margin-top: 0.5rem;
}

.edited-image-card img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.2);
  display: block;
}

/* Sidebar Footer Brand */
.sidebar-footer {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.sidebar-parent-brand {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.02em;
  line-height: 1.3;
  text-align: center;
  max-width: 100%;
}

.parent-company-logo {
  height: 16px;
  width: auto;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.sidebar-parent-text {
  text-align: center;
  white-space: normal;
  word-break: normal;
}

@media (max-width: 480px) {
  .sidebar-parent-brand,
  .sidebar-parent-text {
    font-size: 10px;
  }
}

/* About Section in Settings */
#about-expanded-block {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
}

body.light #about-expanded-block {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-color);
}

#about-toggle-btn:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   Mobile Polish: Header Mode Title, Dropdown & Bottom Input Bar Safe Area
   ========================================================================== */

/* 1. Remove speaker button and voice style dropdown from top header */
header #tts-mute-btn,
header #tts-style-select {
  display: none !important;
}

/* 2. Header mode title fit on mobile screens below 640px */
@media (max-width: 639.98px) {
  header h1.brand-name {
    font-size: 0.8125rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  header .tour-nav-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* 3. Android bottom bar & safe area inset with dark background #050816 */
html,
body,
body:not(.light) {
  background-color: #050816;
}

.bottom-input-bar,
footer.bottom-input-bar,
footer {
  background-color: #050816;
  padding-bottom: env(safe-area-inset-bottom);
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

/* ==========================================================================
   Christmas Theme (December) & Festive Decorations
   ========================================================================== */

/* 1. Snowfall & Comet Effect over background section */
#snowfall-canvas,
.church-park-snowfall,
#comet-canvas,
.festive-comet-canvas {
  position: absolute !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
  z-index: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
  #snowfall-canvas,
  .church-park-snowfall,
  #comet-canvas,
  .festive-comet-canvas {
    display: none !important;
  }
}

/* 2. Santa Claus Thinking Indicator Icon */
.santa-thinking-icon {
  animation: santa-bob 1.8s ease-in-out infinite;
}

@keyframes santa-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .santa-thinking-icon {
    animation: none !important;
  }
}

/* 3. User Message Edit & Copy Controls */
.user-msg-group {
  position: relative;
}

.user-msg-actions {
  opacity: 0.9;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@media (min-width: 640px) {
  .user-msg-actions {
    opacity: 0;
  }
  .user-msg-group:hover .user-msg-actions,
  .user-msg-group:focus-within .user-msg-actions {
    opacity: 1;
  }
}

.user-edit-textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* 4. Upgrade button on timer bar */
#timer-upgrade-btn {
  letter-spacing: 0.02em;
}

/* 5. Responsive AI Markdown Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.75rem 0;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-table {
  width: 100%;
  min-width: 300px;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.35rem;
  color: #e2e8f0;
}

.ai-table th {
  background-color: rgba(30, 41, 59, 0.85);
  color: #f1f5f9;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.ai-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

.ai-table tr:last-child td {
  border-bottom: none;
}

.ai-table tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

.ai-table tr:hover {
  background-color: rgba(255, 255, 255, 0.05);
}
