/**
 * AI Studio V4 — Claude-Inspired Premium Design System
 * Calm, Editorial, Refined, Minimalist, Multimodal Architecture
 */

:root {
  /* -------------------------------------------------------------
     Light Mode — Warm Cream & Terracotta Palette
     ------------------------------------------------------------- */
  --bg-app: #faf9f6;
  --bg-sidebar: #f4f2eb;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1efea;
  --bg-surface-active: #e9e7e0;
  --bg-input: #ffffff;
  --bg-code: #201f1d;
  --bg-code-header: #181716;

  --text-primary: #232220;
  --text-secondary: #66645e;
  --text-muted: #918f88;
  --text-inverse: #faf9f6;

  --border-subtle: #e7e5dc;
  --border-medium: #d6d4ca;
  --border-focus: #c2410c;
  --border-highlight: rgba(194, 65, 12, 0.15);

  --accent-primary: #c2410c; /* Warm Terracotta */
  --accent-primary-hover: #9a3412;
  --accent-soft: rgba(194, 65, 12, 0.08);
  --accent-amber: #b45309;

  --reasoning-bg: #f8f6f0;
  --reasoning-border: #dedad0;
  --reasoning-text: #78756d;

  --user-bubble-bg: #f1efe8;
  --user-bubble-text: #232220;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-popover: 0 10px 30px rgba(0, 0, 0, 0.1);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Apple Garamond", "Baskerville", "Times New Roman", "Droid Serif", Times, Source Serif Pro, serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Monaco, Consolas, monospace;

  --transition-fast: 140ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 220ms cubic-bezier(0.16, 1, 0.3, 1);
  --max-content-width: 48rem;
}

[data-theme="dark"] {
  /* -------------------------------------------------------------
     Dark Mode — Deep Warm Charcoal & Terracotta Palette
     ------------------------------------------------------------- */
  --bg-app: #181716;
  --bg-sidebar: #1f1e1c;
  --bg-surface: #262522;
  --bg-surface-hover: #2f2d2a;
  --bg-surface-active: #383632;
  --bg-input: #232220;
  --bg-code: #141312;
  --bg-code-header: #0e0d0d;

  --text-primary: #ece9e2;
  --text-secondary: #9e9a91;
  --text-muted: #726f67;
  --text-inverse: #181716;

  --border-subtle: #2d2b27;
  --border-medium: #3d3b36;
  --border-focus: #ea580c;
  --border-highlight: rgba(234, 88, 12, 0.2);

  --accent-primary: #ea580c;
  --accent-primary-hover: #f97316;
  --accent-soft: rgba(234, 88, 12, 0.12);
  --accent-amber: #d97706;

  --reasoning-bg: #201f1c;
  --reasoning-border: #33312b;
  --reasoning-text: #969288;

  --user-bubble-bg: #2b2926;
  --user-bubble-text: #ece9e2;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.4);
  --shadow-popover: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* -------------------------------------------------------------
   Global Reset & Base Layout
   ------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  position: relative;
}

.hidden {
  display: none !important;
}

/* -------------------------------------------------------------
   Sidebar Component
   ------------------------------------------------------------- */
.sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal), min-width var(--transition-normal), transform var(--transition-normal);
  z-index: 40;
  height: 100%;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  transform: translateX(-100%);
  border-right: none;
  visibility: hidden;
}

.sidebar-header {
  padding: 1.1rem 1rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background-color: var(--text-primary);
  color: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-name {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--accent-soft);
  color: var(--accent-primary);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  margin-left: 0.2rem;
}

.new-chat-wrapper {
  padding: 0.5rem 1rem 0.6rem;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.new-chat-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-medium);
}

.new-chat-btn .btn-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.new-chat-shortcut {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background-color: var(--bg-sidebar);
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

/* Sidebar Search */
.sidebar-search-box {
  padding: 0 1rem 0.5rem;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 0.65rem;
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  padding: 0.4rem 0.6rem 0.4rem 2rem;
  font-size: 0.82rem;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.sidebar-search-input:focus {
  background-color: var(--bg-surface);
  border-color: var(--border-medium);
}

.sidebar-search-input::placeholder {
  color: var(--text-muted);
}

/* Conversation History Groups */
.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0.75rem 1rem;
}

.history-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.7rem 0.5rem 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
  margin-bottom: 2px;
}

.chat-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.chat-item.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.chat-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-item-actions {
  display: none;
  align-items: center;
  gap: 0.2rem;
  margin-left: 0.4rem;
}

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  display: flex;
}

.chat-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.chat-action-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-active);
}

/* Sidebar Footer & User Profile */
.sidebar-footer {
  padding: 0.6rem 0.8rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-md);
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.user-profile-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-subtle);
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-circle img, .avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.user-display-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-quick-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  padding-top: 0.2rem;
  border-top: 1px solid var(--border-subtle);
}

.footer-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.84rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.footer-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.account-profile-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem 0.8rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.3rem;
}

.avatar-large {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
}

.menu-user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.menu-user-email {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------
   Main Chat Workspace
   ------------------------------------------------------------- */
.main-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  background-color: var(--bg-app);
  overflow: hidden;
  min-width: 0;
}

/* Workspace Header */
.workspace-header {
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(1.25rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  background-color: var(--bg-app);
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.header-chat-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 380px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Standardized Header Action Buttons */
.header-action-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.header-action-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.header-action-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

.header-action-btn:active {
  background-color: var(--bg-surface-active);
}

.voice-header-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.voice-mic-btn.listening {
  color: #22c55e;
  background-color: rgba(34, 197, 94, 0.12);
  animation: pulse 1.2s infinite;
}

/* Green Live Audio Waveform Badge */
.voice-waveform-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background-color: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  height: 24px;
  box-sizing: border-box;
}

.voice-waveform-badge .pulse-dot {
  width: 6px;
  height: 6px;
  background-color: #22c55e;
  border-radius: 50%;
  animation: blink 0.8s infinite;
}

.voice-waveform-badge .wave-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 12px;
}

.voice-waveform-badge .wave-bars span {
  width: 2px;
  background-color: #22c55e;
  border-radius: 1px;
  animation: waveAnim 0.8s ease-in-out infinite alternate;
}

.voice-waveform-badge .wave-bars span:nth-child(1) { height: 4px; animation-delay: 0.1s; }
.voice-waveform-badge .wave-bars span:nth-child(2) { height: 10px; animation-delay: 0.2s; }
.voice-waveform-badge .wave-bars span:nth-child(3) { height: 7px; animation-delay: 0.3s; }
.voice-waveform-badge .wave-bars span:nth-child(4) { height: 11px; animation-delay: 0.4s; }

/* -------------------------------------------------------------
   Composer Interactive Control Pills (Model & Reasoning)
   ------------------------------------------------------------- */
.composer-control-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.32rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  max-width: 175px;
}

.composer-control-pill:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.composer-control-pill.active {
  background-color: var(--bg-surface-active);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.composer-control-pill .control-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-control-pill .chevron-icon {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.composer-control-pill.active .chevron-icon {
  transform: rotate(180deg);
  color: var(--accent-primary);
}

.composer-control-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.desktop-control {
  display: inline-flex;
}

.mobile-ai-btn {
  display: none;
}

.btn-label-desktop {
  display: inline;
}

/* -------------------------------------------------------------
   Direct Floating Composer Popovers (Model, Mode, Effort, Tools)
   ------------------------------------------------------------- */
.popover-backdrop {
  position: fixed;
  inset: 0;
  background-color: transparent;
  backdrop-filter: none;
  z-index: 140;
}

.composer-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 1.25rem;
  width: 300px;
  max-width: calc(100vw - 2rem);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  z-index: 160;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.4rem;
  pointer-events: auto;
  animation: slideUp 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.composer-popover.hidden {
  display: none !important;
}

#toolsPopover {
  left: 1.25rem;
  right: auto;
}

/* Mobile AI Settings Bottom Sheet Structure */
.mobile-sheet-popover {
  display: flex;
  flex-direction: column;
}

.popover-sheet-handle {
  width: 36px;
  height: 4px;
  background-color: var(--border-medium);
  border-radius: var(--radius-full);
  margin: 0.3rem auto 0.6rem;
  flex-shrink: 0;
}

.sheet-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-main-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sheet-close-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.sheet-close-icon-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sheet-scroll-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.8rem 0.5rem;
  max-height: 52vh;
}

.sheet-block {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sheet-block-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sheet-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sheet-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 36px;
  user-select: none;
}

.sheet-pill-btn:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-surface-active);
}

.sheet-pill-btn.active {
  background-color: var(--accent-soft);
  border-color: var(--border-highlight);
  color: var(--accent-primary);
  font-weight: 600;
}

.sheet-pill-btn .mode-badge-tag {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.sheet-pill-btn.active .mode-badge-tag {
  background-color: rgba(194, 65, 12, 0.2);
  color: var(--accent-primary);
}

.sheet-footer-action {
  padding: 0.6rem 0.5rem 0.2rem;
  border-top: 1px solid var(--border-subtle);
}

.sheet-done-btn {
  width: 100%;
  padding: 0.65rem;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.sheet-done-btn:hover {
  opacity: 0.92;
}

#languagePopover {
  left: 5.5rem;
  right: auto;
  width: 260px;
}

#composerModelPopover {
  right: 6.5rem;
}

#composerEffortPopover {
  right: 1.25rem;
  width: 240px;
}

/* Sidebar Account Dropdown Popover */
.account-popover {
  position: fixed;
  bottom: 74px;
  left: 12px;
  width: 245px;
  max-width: calc(100vw - 24px);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  z-index: 160;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.4rem;
  pointer-events: auto;
  animation: slideUp 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.account-popover.hidden {
  display: none;
}

.popover-header {
  padding: 0.4rem 0.65rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.popover-scroll-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
}

.popover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  width: 100%;
  transition: all var(--transition-fast);
  color: var(--text-primary);
}

.popover-item:hover {
  background-color: var(--bg-surface-hover);
}

.popover-item.active {
  background-color: var(--bg-surface-active);
  font-weight: 600;
}

.popover-item-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.item-title {
  font-size: 0.84rem;
  color: var(--text-primary);
  display: block;
}

.item-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

.popover-item .check-icon {
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0;
  flex-shrink: 0;
}

.popover-item.active .check-icon {
  opacity: 1;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* -------------------------------------------------------------
   Chat Scroll Area & Conversation Stream
   ------------------------------------------------------------- */
.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1.25rem 2rem;
}

.conversation-container {
  width: 100%;
  max-width: var(--max-content-width);
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

/* -------------------------------------------------------------
   Claude-Inspired Welcome Home State
   ------------------------------------------------------------- */
.welcome-screen {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 600px;
  padding: 2rem 1rem;
}

.welcome-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--text-primary);
  color: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow-md);
}

.welcome-greeting {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  font-family: var(--font-serif);
}

.welcome-subtext {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.welcome-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.shortcut-chip {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.shortcut-chip:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

/* -------------------------------------------------------------
   Message Row & Editorial Document Typography
   ------------------------------------------------------------- */
.message-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
}

.message-row.user {
  align-items: flex-end;
}

.message-row.assistant {
  align-items: flex-start;
}

.message-bubble {
  max-width: 100%;
  font-size: 0.95rem;
  line-height: 1.68;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background-color: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-xs);
  max-width: 85%;
}

.message-row.assistant .message-bubble {
  color: var(--text-primary);
  padding: 0.2rem 0;
  width: 100%;
}

/* Markdown Typography Inside Assistant Message */
.message-bubble p {
  margin-bottom: 0.9rem;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4 {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 1.4rem 0 0.6rem;
}

.message-bubble h1 { font-size: 1.4rem; }
.message-bubble h2 { font-size: 1.2rem; }
.message-bubble h3 { font-size: 1.05rem; }

.message-bubble ul, .message-bubble ol {
  margin: 0.6rem 0 0.9rem 1.4rem;
}

.message-bubble li {
  margin-bottom: 0.35rem;
}

.message-bubble blockquote {
  border-left: 3px solid var(--border-medium);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.88rem;
}

.message-bubble th, .message-bubble td {
  border: 1px solid var(--border-subtle);
  padding: 0.6rem 0.85rem;
  text-align: left;
}

.message-bubble th {
  background-color: var(--bg-surface-hover);
  font-weight: 600;
}

.message-bubble code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background-color: var(--bg-surface-hover);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}

/* Code Block Containers */
.code-block-container {
  margin: 1.1rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-code);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.9rem;
  background-color: var(--bg-code-header);
  color: #9e9a91;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.copy-code-btn {
  background: transparent;
  border: none;
  color: #9e9a91;
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.copy-code-btn:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
}

.code-block-container pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
}

.code-block-container pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #e5e2da;
}

/* Reasoning & Thought Process Accordion (Disabled to prevent internal thought exposure) */
.reasoning-box {
  display: none !important;
}

.reasoning-header {
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--reasoning-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.reasoning-header svg {
  transition: transform var(--transition-fast);
}

.reasoning-box.collapsed .reasoning-header svg {
  transform: rotate(-90deg);
}

.reasoning-box.collapsed .reasoning-content {
  display: none;
}

.reasoning-content {
  padding: 0.7rem 0.85rem 0.85rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--reasoning-border);
  white-space: pre-wrap;
  font-family: var(--font-mono);
  max-height: 240px;
  overflow-y: auto;
  line-height: 1.5;
}

/* Message Hover Actions */
.message-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.message-row:hover .message-actions {
  opacity: 1;
}

.msg-action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.msg-action-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
  border-color: var(--border-subtle);
}

/* -------------------------------------------------------------
   Claude-Inspired Floating Chat Composer
   ------------------------------------------------------------- */
.composer-container {
  width: 100%;
  max-width: var(--max-content-width);
  margin: 0 auto;
  padding: 0 1.25rem 1.25rem;
  position: relative;
  z-index: 150;
}

.composer-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 0.75rem 0.9rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.composer-box:focus-within {
  border-color: var(--border-medium);
  box-shadow: 0 0 0 1px var(--border-medium), var(--shadow-sm);
}

/* Active Tool Chip Bar */
.active-tool-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
  animation: oskaFadeIn 0.15s ease both;
}

.active-tool-bar.hidden {
  display: none;
}

.active-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--accent-soft);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--accent-primary);
}

.tool-chip-remove {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  opacity: 0.7;
  cursor: pointer;
  padding: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: opacity var(--transition-fast);
}

.tool-chip-remove:hover {
  opacity: 1;
}

/* Attachment Chips Bar */
.attachment-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}

.attachment-preview-bar.hidden {
  display: none;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-primary);
  max-width: 200px;
}

.attachment-chip .chip-thumb {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-xs);
  object-fit: cover;
}

.attachment-chip .chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.attachment-chip .chip-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.attachment-chip .chip-remove:hover {
  color: #ef4444;
}

/* Composer Textarea */
#chatInput {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.95rem;
  resize: none;
  max-height: 180px;
  line-height: 1.5;
  padding: 0.2rem 0;
}

#chatInput::placeholder {
  color: var(--text-muted);
}

/* Composer Toolbar */
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.2rem;
}

.composer-tools-left {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.composer-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.composer-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.composer-btn.active {
  background-color: var(--accent-soft);
  color: var(--accent-primary);
}

.composer-actions-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.send-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--text-primary);
  color: var(--bg-app);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.send-btn:hover {
  background-color: var(--accent-primary);
  transform: scale(1.04);
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  background-color: var(--text-muted);
}

.stop-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.composer-disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.4rem;
}

/* -------------------------------------------------------------
   Popovers & Dropdowns (Model, Tools, Personas)
   ------------------------------------------------------------- */
.popover-menu {
  position: absolute;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  z-index: 100;
  width: 260px;
  overflow: hidden;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.popover-menu.hidden {
  display: none;
}

.popover-header {
  padding: 0.4rem 0.6rem 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.popover-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}

.popover-item:hover {
  background-color: var(--bg-surface-hover);
}

.popover-item.active {
  background-color: var(--accent-soft);
  color: var(--accent-primary);
  font-weight: 600;
}

.popover-item-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.popover-item-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* -------------------------------------------------------------
   Media Cards (Image & Video Generation)
   ------------------------------------------------------------- */
.ai-media-card {
  margin: 1rem 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  max-width: 580px;
}

.ai-media-card img {
  width: 100%;
  height: auto;
  display: block;
}

.ai-media-footer {
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface-hover);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.media-action-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}

.media-action-btn:hover {
  background-color: var(--bg-surface-active);
}

/* -------------------------------------------------------------
   Settings Modal & Dialogs
   ------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.25);
  backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.hidden {
  display: none;
}

.settings-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  width: 90%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 310;
  animation: modalScaleUp 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.dialog-header {
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.dialog-body {
  padding: 1.4rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.setting-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.setting-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.setting-select, .setting-input {
  background-color: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.84rem;
  color: var(--text-primary);
  outline: none;
}

.setting-select:focus, .setting-input:focus {
  border-color: var(--border-focus);
}

.dialog-footer {
  padding: 0.9rem 1.4rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* -------------------------------------------------------------
   Clean Google-Only Auth Card
   ------------------------------------------------------------- */
.auth-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  width: 90%;
  max-width: 390px;
  padding: 2rem 1.8rem 1.6rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  z-index: 310;
  animation: modalScaleUp 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.auth-close-btn {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.auth-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.3rem;
}

.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 310px;
}

.auth-body {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.google-auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.google-auth-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--text-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.google-auth-btn:active {
  transform: translateY(0);
}

.google-auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-dismiss-link {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: color var(--transition-fast);
}

.auth-dismiss-link:hover {
  color: var(--text-primary);
}

.sidebar-auth-hint {
  padding: 1.5rem 0.75rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.sidebar-auth-hint:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* -------------------------------------------------------------
   Admin Console Dashboard
   ------------------------------------------------------------- */
.admin-dialog {
  max-width: 720px;
}

.admin-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-bottom: 1.2rem;
}

.metric-card {
  background-color: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: center;
}

.metric-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.admin-section-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}

.admin-provider-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.admin-provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.provider-status {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.provider-status.online {
  background-color: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

/* -------------------------------------------------------------
   Interactive Data Chart Card & Citations
   ------------------------------------------------------------- */
.ai-chart-card {
  margin: 1.2rem 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  max-width: 600px;
  box-shadow: var(--shadow-sm);
}

.ai-chart-header {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-canvas-wrapper {
  position: relative;
  height: 260px;
  width: 100%;
}

.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background-color: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  font-size: 0.72rem;
  color: var(--accent-primary);
  font-weight: 600;
  margin: 0 2px;
  text-decoration: none;
  cursor: pointer;
  vertical-align: baseline;
}

.citation-chip:hover {
  background-color: var(--accent-soft);
}

/* -------------------------------------------------------------
   Toast Notifications
   ------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 300;
  pointer-events: none;
}

.toast {
  background-color: var(--text-primary);
  color: var(--bg-app);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

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

/* -------------------------------------------------------------
   Responsive Architecture (Desktop, 1366x768 Laptop, Tablet, Mobile)
   ------------------------------------------------------------- */
.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  max-width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Laptop Vertical Optimization (1366x768, 1440x900) */
@media (max-height: 820px) {
  .welcome-screen {
    padding: 1rem 0.5rem;
  }
  .welcome-mark {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
  }
  .welcome-greeting {
    font-size: 1.5rem;
    margin-bottom: 0.2rem;
  }
  .welcome-subtext {
    font-size: 0.88rem;
    margin-bottom: 1.2rem;
  }
}

/* Tablet & Mobile Breakpoints */
@media (max-width: 768px) {
  .btn-label-desktop {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 82vw;
    z-index: 45;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-normal);
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
    visibility: visible !important;
    width: 280px !important;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 42;
    transition: opacity var(--transition-fast);
  }

  .workspace-header {
    padding: 0 max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
    height: 48px;
    min-height: 48px;
  }

  .header-chat-title {
    max-width: 160px;
    font-size: 0.84rem;
  }

  .header-right {
    gap: 6px;
  }

  .header-action-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  /* Desktop controls hidden on mobile; Unified AI Settings Pill shown */
  .desktop-control {
    display: none !important;
  }

  .mobile-ai-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.6rem;
    min-height: 36px;
    max-width: 155px;
    font-size: 0.76rem;
    font-weight: 550;
    border-radius: var(--radius-full);
    background-color: var(--bg-surface-hover);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
  }

  .btn-label-desktop {
    display: none !important;
  }

  /* Responsive Mobile Chat Area */
  .chat-scroll-area {
    padding: 0.75rem 0.5rem 5.5rem;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .conversation-container {
    padding: 0 0.35rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .message-row.user .message-bubble {
    max-width: 85%;
    font-size: 0.9rem;
    padding: 0.65rem 0.95rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .message-row.assistant .message-bubble {
    width: 100%;
    max-width: 100%;
    font-size: 0.92rem;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Responsive Mobile Composer */
  .composer-container {
    width: 100%;
    max-width: 100%;
    padding: 0 8px max(6px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    margin: 0 auto;
    position: relative;
    z-index: 150;
  }

  .composer-box {
    width: 100%;
    min-width: 0;
    border-radius: 20px;
    padding: 0.6rem 0.75rem 0.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  #chatInput {
    font-size: 0.92rem;
    padding: 0.15rem 0;
    min-height: 24px;
    max-height: 140px;
  }

  .composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    gap: 0.3rem;
    margin-top: 0.15rem;
    box-sizing: border-box;
  }

  .composer-tools-left {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    min-width: 0;
  }

  .composer-btn {
    padding: 0.35rem 0.5rem;
    min-height: 36px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .composer-actions-right {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
    min-width: 0;
    margin-left: auto;
  }

  .send-btn, .stop-btn {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    box-sizing: border-box !important;
    margin-left: 2px !important;
  }

  .composer-disclaimer {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.5rem;
    margin-bottom: max(0.4rem, env(safe-area-inset-bottom));
    padding: 0 0.5rem;
  }

  /* All Popovers as clean mobile bottom sheets */
  .composer-popover {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 20px 20px 0 0 !important;
    border: 1px solid var(--border-medium) !important;
    border-bottom: none !important;
    max-height: 75vh !important;
    z-index: 250 !important;
    padding: 0.6rem 0.8rem max(0.8rem, env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4) !important;
    box-sizing: border-box !important;
  }

  .settings-dialog {
    width: 95%;
    max-height: 90vh;
  }
}

/* Small Mobile Viewports (≤ 380px) */
@media (max-width: 380px) {
  .welcome-shortcuts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    width: 100%;
  }

  .shortcut-chip {
    padding: 0.4rem 0.5rem;
    font-size: 0.72rem;
    justify-content: center;
  }

  .mobile-ai-btn {
    max-width: 100px !important;
    font-size: 0.72rem !important;
    padding: 0.3rem 0.45rem !important;
  }

  .composer-btn {
    padding: 0.3rem 0.45rem !important;
  }
}

/* -------------------------------------------------------------
   oska.AI Premium Thinking Indicator
   ------------------------------------------------------------- */

/* Thinking container — occupies the same space as the response will */
.oska-thinking {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0;
  min-height: 2.2rem;
  animation: oskaFadeIn 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* The small oska logo mark */
.oska-thinking-mark {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 7px;
  background-color: var(--bg-surface-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-primary);
  animation: oskaPulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  will-change: transform, opacity;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Subtle light trail sweep across the mark */
.oska-thinking-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(194, 65, 12, 0.08) 48%,
    transparent 66%
  );
  animation: oskaShimmerSweep 2.4s ease-in-out infinite;
  will-change: transform;
  pointer-events: none;
}

[data-theme="dark"] .oska-thinking-mark {
  background-color: var(--bg-surface-hover);
  color: var(--accent-primary);
}

[data-theme="dark"] .oska-thinking-mark::after {
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(234, 88, 12, 0.1) 48%,
    transparent 66%
  );
}

/* Status text */
.oska-thinking-status {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 450;
  letter-spacing: 0.005em;
  line-height: 1.5;
  min-height: 24px;
  position: relative;
}

/* Animated dots */
.oska-thinking-dots {
  display: inline-flex;
  gap: 2.5px;
  margin-left: 1px;
  align-items: center;
  height: 24px;
}

.oska-thinking-dots span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background-color: var(--text-muted);
  opacity: 0.35;
  animation: oskaDotFade 1.4s ease-in-out infinite;
  will-change: opacity;
}

.oska-thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.oska-thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Status text transition for smooth label changes */
.oska-thinking-label {
  transition: opacity 180ms ease;
}

.oska-thinking-label.fading {
  opacity: 0;
}

/* Shimmer across the status text */
.oska-thinking-status.shimmer .oska-thinking-label {
  background: linear-gradient(
    90deg,
    var(--text-muted) 0%,
    var(--text-secondary) 40%,
    var(--text-muted) 80%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: oskaTextShimmer 2.8s ease-in-out infinite;
}

/* Transition from thinking to streaming — the indicator fades out */
.oska-thinking.dissolving {
  animation: oskaDissolve 250ms cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Error state inside thinking */
.oska-thinking-error {
  color: #ef4444;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.oska-thinking-error .oska-retry-btn {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.oska-thinking-error .oska-retry-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-focus);
  color: var(--accent-primary);
}

/* Small oska mark at the top of the streamed response */
.oska-response-mark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background-color: var(--bg-surface-active);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
  opacity: 0.7;
  flex-shrink: 0;
}

[data-theme="dark"] .oska-response-mark {
  background-color: var(--bg-surface-hover);
}

/* Streaming cursor */
.oska-stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background-color: var(--accent-primary);
  margin-left: 1px;
  vertical-align: text-bottom;
  animation: oskaCursorBlink 0.8s step-end infinite;
  will-change: opacity;
}

/* Smooth entry for streamed content */
.oska-stream-content {
  animation: oskaContentFadeIn 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Keyframe Animations (GPU-only: transform + opacity) --- */

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

@keyframes oskaPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.04); opacity: 0.85; }
}

@keyframes oskaDotFade {
  0%, 100% { opacity: 0.2; }
  50%      { opacity: 0.8; }
}

@keyframes oskaShimmerSweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

@keyframes oskaTextShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes oskaDissolve {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-3px); }
}

@keyframes oskaCursorBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

@keyframes oskaContentFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- Reduced Motion --- */

@media (prefers-reduced-motion: reduce) {
  .oska-thinking-mark {
    animation: none;
  }
  .oska-thinking-mark::after {
    animation: none;
    display: none;
  }
  .oska-thinking-dots span {
    animation: none;
    opacity: 0.5;
  }
  .oska-thinking-status.shimmer .oska-thinking-label {
    animation: none;
    -webkit-text-fill-color: var(--text-muted);
    background: none;
  }
  .oska-thinking {
    animation: none;
    opacity: 1;
  }
  .oska-thinking.dissolving {
    animation: none;
    display: none;
  }
  .oska-stream-cursor {
    animation: none;
    opacity: 1;
  }
  .oska-stream-content {
    animation: none;
    opacity: 1;
  }
}

/* -------------------------------------------------------------
   Verified Web Sources & Citations
   ------------------------------------------------------------- */
.sources-container {
  margin: 1rem 0 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  animation: oskaFadeIn 0.2s ease both;
}

.sources-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.5rem;
}

.source-card {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  min-height: 48px;
}

.source-card:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.source-card-badge {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: var(--radius-full);
  background-color: var(--accent-soft);
  color: var(--accent-primary);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.source-card-info {
  flex: 1;
  min-width: 0;
}

.source-card-title {
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.source-card-domain {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-card-ext {
  color: var(--text-muted);
  opacity: 0.6;
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   Interactive AI Chart & Data Table Card
   ------------------------------------------------------------- */
.ai-chart-card {
  margin: 1rem 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.ai-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.ai-chart-header-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ai-chart-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 3px 7px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all var(--transition-fast);
}

.chart-btn:hover, .chart-btn.active {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-medium);
  color: var(--accent-primary);
}

.chart-canvas-wrapper {
  position: relative;
  height: 260px;
  width: 100%;
}

/* Data Table in Analysis */
.data-table-wrapper {
  margin-top: 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.data-table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.data-table-wrapper th, .data-table-wrapper td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.data-table-wrapper th {
  background-color: var(--bg-surface-hover);
  font-weight: 600;
  color: var(--text-secondary);
}

/* -------------------------------------------------------------
   Mobile Bottom Sheet for Tools Menu (≤ 640px)
   ------------------------------------------------------------- */
@media (max-width: 640px) {
  #toolsPopover {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding: 0.75rem 1rem max(1rem, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
    z-index: 220;
    animation: slideUpSheet 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .popover-sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    background-color: var(--border-medium);
    border-radius: var(--radius-full);
    margin: 0 auto 0.6rem;
  }

  .popover-item {
    min-height: 48px;
    padding: 0.6rem 0.75rem;
  }

  .sources-grid {
    grid-template-columns: 1fr;
  }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* -------------------------------------------------------------
   Projects Sidebar & Project Item Styling
   ------------------------------------------------------------- */
.sidebar-section-container {
  padding: 0.5rem 0.5rem 0.2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0.35rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.sidebar-section-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.sidebar-section-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--accent-primary);
}

.sidebar-projects-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 140px;
  overflow-y: auto;
}

.sidebar-project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.sidebar-project-item:hover, .sidebar-project-item.active {
  background-color: var(--bg-surface-hover);
}

.project-item-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.project-color-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: var(--radius-full);
}

.project-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------------------------------------------------------------
   Behavior Mode Popover & Selector
   ------------------------------------------------------------- */
#composerModePopover {
  right: 12.5rem;
  width: 250px;
}

.mode-item-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  background-color: var(--accent-soft);
  color: var(--accent-primary);
  margin-left: 0.35rem;
}

/* -------------------------------------------------------------
   Universal File Preview Modal
   ------------------------------------------------------------- */
.file-preview-card {
  width: 92vw;
  max-width: 980px;
  height: 86vh;
  max-height: 860px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-hover);
}

.preview-header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.preview-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.preview-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preview-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preview-action-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background-color: var(--bg-base);
  position: relative;
}

/* PDF Previewer */
.pdf-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-surface);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-medium);
  font-size: 0.78rem;
  box-shadow: var(--shadow-sm);
}

.pdf-canvas-wrapper {
  max-width: 100%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-xs);
  overflow: hidden;
  background-color: #fff;
}

/* DOCX Preview */
.docx-preview-content {
  max-width: 800px;
  margin: 0 auto;
  background-color: var(--bg-surface);
  padding: 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  line-height: 1.65;
  color: var(--text-primary);
}

.docx-preview-content h1, .docx-preview-content h2, .docx-preview-content h3 {
  margin: 1.2rem 0 0.5rem;
  color: var(--text-primary);
}

.docx-preview-content p {
  margin-bottom: 0.8rem;
}

/* PPTX Slide Deck Preview */
.pptx-slide-deck {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.pptx-slide-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slide-counter {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
}

.slide-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.slide-body-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  flex: 1;
}

/* Spreadsheet Tabbed Table Preview */
.spreadsheet-preview-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
}

.sheet-tabs-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sheet-tab-btn {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.sheet-tab-btn.active {
  background-color: var(--accent-soft);
  border-color: var(--border-highlight);
  color: var(--accent-primary);
  font-weight: 600;
}

.spreadsheet-preview-table-wrapper {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
}

.spreadsheet-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.spreadsheet-preview-table th {
  position: sticky;
  top: 0;
  background-color: var(--bg-surface-hover);
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-medium);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-primary);
  white-space: nowrap;
}

.spreadsheet-preview-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* Code Preview */
.code-preview-block {
  max-width: 900px;
  margin: 0 auto;
  background-color: #1e1e1e;
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: #d4d4d4;
  line-height: 1.5;
}

/* Image Lightbox */
.image-lightbox-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.image-lightbox-wrapper img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* -------------------------------------------------------------
   Chat Message Attachment Chips (Interactive in History)
   ------------------------------------------------------------- */
.chat-attachments-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.chat-file-chip:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.chat-file-chip .chip-icon {
  color: var(--accent-primary);
}

.chat-file-chip .chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.chat-file-chip .chip-type-tag {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* -------------------------------------------------------------
   Project Workspace Screen Styling
   ------------------------------------------------------------- */
.project-screen {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: oskaFadeIn 0.2s ease both;
}

.project-header-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.project-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.project-icon-badge {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface-hover);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.project-name-heading {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

.project-meta-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-actions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.project-instructions-box {
  background-color: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.instructions-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.instructions-content {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.project-section-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.project-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.section-title-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-left h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.project-sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}

.project-source-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background-color: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.project-source-card:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-surface-hover);
}

.source-card-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.source-card-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.project-chats-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.project-chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background-color: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-chat-item:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-medium);
}

/* -------------------------------------------------------------
   File Library Modal (My Files) Styling
   ------------------------------------------------------------- */
.library-dialog {
  max-width: 760px;
  width: 90vw;
  max-height: 82vh;
}

.library-filter-tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.library-tab {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.library-tab.active, .library-tab:hover {
  background-color: var(--accent-soft);
  border-color: var(--border-highlight);
  color: var(--accent-primary);
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  max-height: 460px;
  overflow-y: auto;
}

.library-file-card {
  background-color: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.library-file-card:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.library-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.library-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.library-card-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.library-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.4rem;
  margin-top: 0.2rem;
}

/* Project Color Picker */
.project-color-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-dot {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.color-dot.active {
  transform: scale(1.15);
  border-color: var(--text-primary);
}

/* Mobile Responsive Adjustments */
@media (max-width: 640px) {
  #composerModePopover {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding: 0.75rem 1rem max(1rem, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2);
    z-index: 220;
    animation: slideUpSheet 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .file-preview-card {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .project-screen {
    padding: 1rem 0.75rem 4rem;
  }
}

/* -------------------------------------------------------------
   Platform Maintenance Mode Screen (Locked for visitors)
   ------------------------------------------------------------- */
.maintenance-screen-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(circle at 50% 35%, #201e1b 0%, #121110 100%);
  z-index: 99999999 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  pointer-events: auto;
  user-select: none;
  animation: fadeInModal 0.25s ease forwards;
}

.maintenance-card {
  background-color: var(--bg-surface);
  border: 1px solid rgba(234, 88, 12, 0.35);
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

.maintenance-icon-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--accent-soft);
  border: 1px solid rgba(234, 88, 12, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  animation: pulseWrench 3s infinite ease-in-out;
}

@keyframes pulseWrench {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.maintenance-brand {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.maintenance-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
  line-height: 1.3;
}

.maintenance-message {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 1.5rem;
}

.maintenance-timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--accent-primary);
  margin-bottom: 1.25rem;
}

.maintenance-footer-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.45;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.25rem;
}
