/* Modern CSS with 2025 best practices - Enhanced UI */
:root {
  /* Color system */
  --bg: #0b0d10;
  --bg-secondary: #12161b;
  --fg: #e7eaee;
  --fg-secondary: #cbd5e0;
  --muted: #97a0ad;
  --card: #12161b;
  --card-hover: #1a1e25;
  --border: #222831;
  --border-light: #2d3748;
  --brand: #69c;
  --brand-hover: #7dd3fc;
  --accent: #65d;
  --accent-hover: #818cf8;
  --warn: #f4a261;
  --warn-bg: #382d16;
  --warn-border: #6d5526;
  --success: #10b981;
  --error: #ef4444;
  --error-bg: #3d1f1f;
  --error-border: #7f2d2d;
  
  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Archive Archive Source Code Pro", Menlo, monospace;
  
  /* Borders */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.15);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.2);
}

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  overflow-x: hidden;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.75rem;
  background: rgba(12, 16, 22, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.3s ease, padding 0.3s ease, box-shadow 0.3s ease;
}

.app-header.scrolled {
  padding: 0.5rem 1.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.app-header.collapsed {
  transform: translateY(-100%);
}

.app-header__title {
  display: flex;
  align-items: center;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.app-header__title:empty {
  display: none;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.app-header__actions-primary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-header__actions-overflow {
  position: relative;
}

.header-button--overflow {
  min-width: 36px;
  padding: 0.4rem;
  justify-content: center;
}

.overflow-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 1000;
}

.overflow-menu[hidden] {
  display: none;
}

.overflow-menu .header-button {
  width: 100%;
  justify-content: flex-start;
  border: none;
  background: transparent;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
}

.overflow-menu .header-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.app-header__brand .brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg);
  font-size: 1.125rem;
  font-weight: 600;
  text-decoration: none;
}

.brand-link:hover {
  color: var(--accent);
}

.app-header__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-item {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-item:hover,
.nav-item:focus {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.nav-location {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--accent);
  background: rgba(102, 126, 234, 0.12);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
}

body:not(.location-active) .nav-item.nav-location {
  display: none;
}

.app-header__tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Legacy support - map to new structure */
.app-header__tools {
  display: contents;
}

.header-search {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 0.25rem 0.5rem 0.25rem 0.85rem;
  min-width: 220px;
}

.header-search input {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 0.95rem;
  width: 100%;
  outline: none;
}

.header-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.header-search button {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.header-search button:hover {
  background: var(--accent-hover);
}

.header-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition-fast), border var(--transition-fast);
}

.header-button:hover,
.header-button:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.header-button.status-link {
  background: rgba(102, 126, 234, 0.12);
  border-color: rgba(102, 126, 234, 0.35);
  color: #a9c1ff;
}

.header-button.status-link:hover {
  background: rgba(102, 126, 234, 0.2);
}

.header-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--fg);
  font-size: 1.4rem;
  cursor: pointer;
}

@media (max-width: 980px) {
  .app-header {
    grid-template-columns: auto auto 1fr auto;
    gap: 1rem;
  }

  /* Mobile navigation backdrop overlay */
  body.nav-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
    animation: fadeIn 0.2s ease;
  }

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

  .app-header__nav {
    position: fixed;
    inset: 56px 0 auto 0;
    background: rgba(8, 11, 16, 0.98);
    backdrop-filter: blur(18px);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: none;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 100;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }

  body.nav-open .app-header__nav {
    display: flex;
    transform: translateY(0);
  }
  
  /* Enhanced nav items for mobile */
  .app-header__nav .nav-item {
    padding: 0.875rem 1rem;
    min-height: 44px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: background var(--transition-base), transform var(--transition-fast);
  }
  
  .app-header__nav .nav-item:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.1);
  }

  .app-header__tools {
    display: none;
  }

  body.nav-open .app-header__tools {
    position: fixed;
    inset: auto 0 0 0;
    display: flex;
    padding: 0.75rem 1.5rem;
    background: rgba(8, 11, 16, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 100;
    backdrop-filter: blur(18px);
  }

  .app-header__brand {
    z-index: 101;
  }

  .header-mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.08);
    transition: background var(--transition-base), transform var(--transition-fast);
    z-index: 101;
  }
  
  .header-mobile-toggle:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
  }
  
  body.nav-open .header-mobile-toggle {
    background: rgba(255, 255, 255, 0.15);
  }
}

/* Global image fixes - ensure all images display properly */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

img[src=""],
img:not([src]) {
  display: none;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Touch-friendly on mobile - Enhanced for better mobile UX */
/* Small mobile devices (480px and below) */
@media (max-width: 480px) {
  * {
    -webkit-tap-highlight-color: rgba(102, 85, 221, 0.2);
  }
  
  .container {
    padding: var(--space-md) var(--space-sm);
  }
  
  .app-header {
    padding: 0.5rem var(--space-sm);
    gap: 0.75rem;
  }
  
  .brand-text {
    font-size: 1rem;
  }
  
  .header-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .header-search {
    min-width: 140px;
  }
  
  .dashboard-page {
    padding: var(--space-md) var(--space-sm);
  }
  
  .dashboard-hero {
    padding: var(--space-md);
  }
  
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
  
  .dashboard-panels {
    grid-template-columns: 1fr;
  }
}

/* Standard mobile devices (768px and below) */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: rgba(102, 85, 221, 0.2);
  }
  
  /* Enhanced touch targets - minimum 44x44px */
  button,
  a,
  [role="button"],
  .nav-item,
  .header-button,
  .btn-listen,
  .btn-control,
  .app-button,
  .hero-button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.625rem 1rem;
  }
  
  /* Form inputs also need good touch targets */
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    min-height: 44px;
    padding: 0.625rem 0.875rem;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Improve spacing between interactive elements */
  button + button,
  .nav-item + .nav-item,
  .header-button + .header-button {
    margin-left: var(--space-sm);
  }

  .header-content {
    gap: var(--space-md);
  }

  .header-nav {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  
  /* Mobile nav improvements */
  .mobile-nav-link {
    min-height: 48px;
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
  }
  
  .mobile-nav-close {
    min-width: 44px;
    min-height: 44px;
  }

  .toggle-filters-btn {
    width: 100%;
    justify-content: center;
    font-size: 1rem;
    padding: var(--space-md);
    min-height: 44px;
  }

  .filters-container.is-open {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    background: var(--card);
  }

  .toast-container {
    left: calc(var(--space-lg) + env(safe-area-inset-left, 0));
    right: calc(var(--space-lg) + env(safe-area-inset-right, 0));
    width: auto;
  }

  .toast-container .toast {
    width: 100%;
  }
  
  /* Prevent horizontal scrolling */
  body {
    overflow-x: hidden;
    width: 100%;
  }
  
  /* Stack layouts on mobile */
  .search-layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .reader-main {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .desk-main {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .dashboard-hero {
    grid-template-columns: 1fr;
  }
  
  .studio-main {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .studio-main .outline-panel,
  .studio-main .sources-panel {
    order: 2;
    max-height: 300px;
  }
  
  .studio-main .editor-panel {
    order: 1;
  }
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-lg);
}

/* Header & Navigation */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(18, 22, 27, 0.95);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
}

.brand {
  margin: 0;
  font-size: 1.5rem;
}

.brand a {
  color: var(--fg);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  transition: color var(--transition-fast);
}

.brand a:hover {
  color: var(--brand);
}

.header-nav {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--fg-secondary);
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-size: 0.9375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  gap: var(--space-xs);
}

.nav-link:hover {
  color: var(--fg);
  background: var(--bg-secondary);
}

.nav-link-button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-secondary);
  color: inherit;
  cursor: pointer;
  gap: 6px;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  border-color: var(--brand);
  background: var(--card-hover);
}

.nav-toggle:active {
  transform: scale(0.96);
}

.nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 998;
}

.mobile-nav-backdrop[hidden] {
  display: none;
}

.mobile-nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.3);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-base);
}

.mobile-nav[hidden] {
  display: flex;
  visibility: hidden;
  pointer-events: none;
}

.mobile-nav[data-open="true"] {
  transform: translateX(0);
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border);
}

.mobile-nav-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--fg);
}

.mobile-nav-close {
  background: none;
  border: none;
  color: var(--fg-secondary);
  font-size: 2rem;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.mobile-nav-close:hover,
.mobile-nav-close:focus-visible {
  color: var(--fg);
  background: var(--bg-secondary);
}

.mobile-nav-body {
  display: flex;
  flex-direction: column;
  padding: var(--space-md) var(--space-lg);
  gap: var(--space-xs);
  overflow-y: auto;
}

.mobile-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--fg);
  font-size: 1rem;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  min-height: 48px;
}

.mobile-nav-link:hover,
.mobile-nav-link:focus-visible {
  background: var(--bg-secondary);
  border-color: var(--border);
}

.mobile-nav-button {
  width: 100%;
  text-align: left;
}

.mobile-nav-link.location-mobile {
  justify-content: center;
  background: rgba(102, 126, 234, 0.12);
  color: #cbd7ff;
}

body.mobile-nav-open {
  overflow: hidden;
}

body.preview-open {
  overflow: hidden;
}

/* Main Content */
.main-content {
  min-height: calc(100vh - 200px);
  padding: var(--space-lg) 0;
}

.toggle-filters-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--fg);
  cursor: pointer;
  font-weight: 500;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.toggle-filters-btn .toggle-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.toggle-filters-btn:hover,
.toggle-filters-btn:focus-visible {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

.filters-container {
  display: none;
  margin-top: var(--space-md);
}

.filters-container.is-open {
  display: block;
}

/* Footer */
.footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: var(--space-xl) 0;
  margin-top: var(--space-2xl);
  text-align: center;
}

.footer p {
  margin: var(--space-xs) 0;
  color: var(--fg-secondary);
  font-size: 0.875rem;
}

.footer a {
  color: var(--brand);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.footer-meta {
  margin-top: var(--space-md);
  color: var(--muted);
}

/* Dashboard */
.dashboard-page {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1.75rem;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.75rem;
  background: rgba(18, 24, 32, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: 0 24px 48px rgba(9, 13, 20, 0.35);
}

.hero-intro h1 {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
}

.hero-intro p {
  margin: 0;
  color: var(--muted);
  max-width: 32rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.hero-button {
  border-radius: 999px;
  padding: 0.65rem 1.35rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.06);
}

.hero-button.primary {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  border: none;
  color: #fff;
  font-weight: 600;
}

.hero-button.subtle {
  background: rgba(255, 255, 255, 0.04);
}

.hero-button:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.hero-button.primary:hover {
  filter: brightness(1.1);
}

.hero-session {
  background: rgba(5, 8, 13, 0.65);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-session h2 {
  margin: 0;
  font-size: 1.1rem;
}

.hero-session dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
}

.hero-session dt {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero-session dd {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-chip {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem 1.2rem;
  background: rgba(18, 24, 32, 0.75);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-chip .icon {
  font-size: 1.4rem;
}

.stat-chip .label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-chip .value {
  margin: 0.1rem 0 0 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.stat-chip .hint {
  margin: 0.15rem 0 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-chip.location.active {
  border-color: rgba(102, 126, 234, 0.35);
  background: rgba(102, 126, 234, 0.12);
}

.dashboard-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.dashboard-card {
  background: rgba(18, 24, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 16px 40px rgba(8, 12, 20, 0.3);
}

.dashboard-card h2 {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
}

.steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--fg-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.recent-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.recent-item.pinned {
  border-color: rgba(102, 126, 234, 0.35);
  background: rgba(102, 126, 234, 0.12);
}

.recent-item .title {
  margin: 0 0 0.25rem 0;
  font-weight: 600;
}

.recent-item .meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.recent-item .pin {
  font-size: 1.2rem;
}

.card-hint {
  margin: 1rem 0 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 14px;
}

.empty-state .hint {
  margin: 0.35rem 0 0 0;
  color: var(--muted);
}

.dashboard-apps .apps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.dashboard-apps h2 {
  margin: 0;
  font-size: 1.3rem;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.app-card {
  background: rgba(18, 24, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.app-card__header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.app-card__header .icon {
  font-size: 1.4rem;
}

.app-card__header h3 {
  margin: 0;
}

.app-card__header p {
  margin: 0.2rem 0 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.app-card__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.app-button {
  border-radius: 999px;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
}

.app-button.primary {
  background: rgba(102, 126, 234, 0.18);
  border-color: rgba(102, 126, 234, 0.35);
  color: #b8cbff;
}

.app-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.app-button.primary:hover {
  background: rgba(102, 126, 234, 0.3);
}

.app-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.app-tags span {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .hero-session {
    order: -1;
  }
}

@media (max-width: 768px) {
  .dashboard-page {
    padding: 1.2rem 1.25rem 2rem;
  }

  .dashboard-hero {
    padding: 1.5rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-stats {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

/* Reader Layout - Enhanced UX */
.reader-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  min-height: calc(100vh - 200px);
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.citation-bar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding: var(--space-xl) var(--space-lg);
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  gap: var(--space-xl);
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  background: rgba(18, 22, 27, 0.95);
}

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

.article-title {
  margin: 0 0 var(--space-md) 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.citation-meta {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--fg-secondary);
  margin-top: var(--space-sm);
}

.citation-meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.citation-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.citation-link:hover {
  color: var(--brand-hover);
  text-decoration: underline;
  transform: translateX(2px);
}

.citation-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}

.btn-citation {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-citation:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-citation.pinned {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: white;
  border-color: var(--brand);
}

.reader-main {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: var(--space-xl);
  flex: 1;
  min-height: 0;
}

.reader-text {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-xl);
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
  min-height: 600px;
}

.reader-controls {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  border: 1px solid var(--border);
}

.btn-listen {
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
  font-size: 0.9375rem;
}

.btn-listen:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-listen.playing {
  background: linear-gradient(135deg, var(--error), #ff6b6b);
  animation: pulse 2s ease-in-out infinite;
}

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

.speed-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--fg-secondary);
  font-size: 0.875rem;
  padding: var(--space-sm) var(--space-md);
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.speed-controls label {
  font-weight: 500;
  color: var(--fg);
}

.speed-controls input[type="range"] {
  width: 100px;
}

.btn-control {
  padding: var(--space-sm) var(--space-md);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-control:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.text-content {
  line-height: 2;
  color: var(--fg);
  font-size: 1.0625rem;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  white-space: pre-wrap; /* Preserve line breaks and wrap text */
  word-wrap: break-word; /* Break long words if needed */
}

.text-content p {
  margin: var(--space-lg) 0;
  text-align: justify;
}

.text-content p:first-child {
  margin-top: 0;
}

.text-content p:last-child {
  margin-bottom: 0;
}

.reader-scan {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-lg);
  overflow-y: auto;
  position: sticky;
  top: calc(var(--space-lg) + 80px);
  max-height: calc(100vh - 120px);
  box-shadow: var(--shadow-sm);
}

.scan-container {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 1px solid var(--border);
}

.scan-image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-base);
}

.scan-image:hover {
  transform: scale(1.02);
}

.scan-controls {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.btn-scan {
  padding: var(--space-sm) var(--space-md);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-scan:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.reader-footer {
  text-align: center;
  padding: var(--space-lg);
}

.btn-discuss {
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(135deg, var(--accent), var(--brand));
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-lg);
}

.btn-discuss:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(102, 85, 221, 0.3);
}

/* Research Desk */
.research-desk {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  padding: 1.75rem;
  align-items: start;
}

.research-desk__sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: calc(72px + 1.25rem);
  max-height: calc(100vh - 84px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.desk-card {
  background: rgba(18, 24, 32, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: 0 12px 32px rgba(8, 12, 18, 0.35);
}

.desk-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.desk-card__header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.desk-session {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 0.75rem;
}

.metric-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.desk-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.desk-action {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), border var(--transition-fast);
}

.desk-action:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}

.desk-action.link {
  background: rgba(102, 126, 234, 0.12);
  border-color: rgba(102, 126, 234, 0.35);
  color: #a9c1ff;
}

.desk-sources-list,
.desk-citations-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.desk-sources-list .empty-state,
.desk-citations-list .citations-empty,
.desk-sources-list .loading,
.desk-sources-list .error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.pinned-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.9rem;
  background: rgba(14, 19, 26, 0.9);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.pinned-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.pinned-card h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.3;
}

.pinned-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.pinned-summary {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--fg-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pinned-summary-text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fg-secondary);
}

.pinned-card footer {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mini-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}

.mini-link:hover {
  text-decoration: underline;
}

.icon-button {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.citation-item {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.citation-link {
  color: var(--accent);
  text-decoration: none;
  display: block;
  margin-bottom: 0.35rem;
}

.citation-link:hover {
  text-decoration: underline;
}

.citation-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.research-desk__main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.desk-main__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: rgba(18, 24, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
}

.desk-main__header h1 {
  margin: 0 0 0.35rem 0;
  font-size: 1.5rem;
}

.desk-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.desk-shortcuts {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.shortcut {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.shortcut:hover {
  background: rgba(255, 255, 255, 0.16);
}

.desk-chat-surface {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(18, 24, 32, 0.9);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  min-height: 65vh;
}

.chat-messages {
  background: rgba(5, 8, 12, 0.65);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: 60vh;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message.user {
  align-self: flex-end;
  max-width: 75%;
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
}

.message.assistant .message-content,
.message.system .message-content {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.message.system .message-content {
  border-color: rgba(244, 162, 97, 0.4);
  color: #f4d2a6;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
}

.message-citations {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.chat-composer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1rem;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-form textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: var(--fg);
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.composer-hints {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.composer-hints button {
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: var(--fg);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.composer-hints button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-send {
  padding: 0.6rem 1.3rem;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: white;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: transform var(--transition-fast);
}

.btn-send:hover {
  transform: translateY(-1px);
}

.btn-send .send-icon {
  font-size: 0.9rem;
}

@media (max-width: 1100px) {
  .research-desk {
    grid-template-columns: 1fr;
  }

  .research-desk__sidebar {
    position: relative;
    top: 0;
    max-height: none;
    padding-right: 0;
    order: 2;
  }

  .research-desk__main {
    order: 1;
  }
}

@media (max-width: 768px) {
  .research-desk {
    padding: 1rem 1.25rem 2rem;
  }

  .desk-main__header {
    flex-direction: column;
  }

  .desk-shortcuts {
    width: 100%;
  }

  .desk-chat-surface {
    padding: 1.1rem;
  }

  .chat-messages {
    max-height: 50vh;
  }

  .composer-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-hints {
    justify-content: flex-start;
  }

  .btn-send {
    justify-content: center;
  }
}

/* My My Collections Styles */
.collections-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.collections-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.header-actions {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.collections-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.collection-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-base);
}

.collection-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: var(--space-md);
}

.card-header h3 {
  margin: 0;
  font-size: 1.125rem;
}

.card-actions {
  display: flex;
  gap: var(--space-xs);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--fg-secondary);
  cursor: pointer;
  padding: var(--space-xs);
  font-size: 1rem;
  transition: color var(--transition-fast);
}

.btn-icon:hover {
  color: var(--fg);
}

.card-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.tag {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--fg-secondary);
}

.card-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--fg-secondary);
}

.empty-collections {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-2xl);
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.btn-close {
  background: none;
  border: none;
  color: var(--fg-secondary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.modal-body {
  padding: var(--space-lg);
  flex: 1;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
}

.detail-section {
  margin-bottom: var(--space-lg);
}

.detail-section label {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--fg-secondary);
  font-size: 0.875rem;
}

.detail-section input,
.detail-section textarea {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-family: inherit;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.item-card {
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.empty-items {
  text-align: center;
  color: var(--fg-secondary);
  padding: var(--space-xl);
}

/* Hotkeys Help */
.hotkeys-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.hotkeys-overlay.show {
  display: flex;
}

.hotkeys-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.hotkey-item {
  display: flex;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.hotkey-key {
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

/* Mobile Responsive - Comprehensive mobile improvements */
@media (max-width: 768px) {
  .container {
    padding: var(--space-md);
  }
  
  .desk-main {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .citations-panel {
    position: fixed;
    right: -100%;
    top: 0;
    bottom: 0;
    width: 90%;
    max-width: 300px;
    z-index: 100;
    transition: right var(--transition-base);
  }
  
  .citations-panel.open {
    right: 0;
  }
  
  .collections-board {
    grid-template-columns: 1fr;
  }
  
  /* Research desk mobile improvements */
  .research-desk {
    grid-template-columns: 1fr;
    padding: var(--space-md);
  }
  
  .research-desk__sidebar {
    position: relative;
    top: 0;
    max-height: none;
    order: 2;
  }
  
  .research-desk__main {
    order: 1;
  }
  
  /* Reader mobile improvements */
  .reader-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .reader-controls > * {
    width: 100%;
  }
  
  /* Search layout mobile - ensure proper stacking */
  .search-layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
    padding: var(--space-md);
  }
  
  .filters-panel {
    order: 1;
    margin-bottom: var(--space-md);
    position: relative;
    top: 0;
    max-height: none;
    overflow-y: visible;
    padding: var(--space-md);
  }
  
  .search-results {
    order: 2;
  }
  
  .preview-panel {
    order: 3;
    position: relative;
    max-height: none;
  }
  
  /* Improve filter section spacing on mobile */
  .filter-section {
    padding: var(--space-md) 0;
  }
  
  .filter-section-header .filter-label {
    font-size: 0.875rem;
  }
  
  /* Category pills - better touch targets */
  .category-pill-compact,
  .category-pill {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9375rem;
  }
  
  /* Quick chips - better spacing */
  .quick-chip {
    min-height: 44px;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9375rem;
  }
  
  /* Filter inputs - better touch targets */
  .filter-input,
  .year-input {
    min-height: 44px;
    padding: var(--space-md);
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Search input improvements */
  .search-input-main {
    min-height: 48px;
    padding: var(--space-md) var(--space-lg);
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Results - better spacing */
  .results-main {
    padding: var(--space-md) 0;
  }
  
  .result-card {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }
  
  /* Action buttons - ensure touch-friendly */
  .btn-action,
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-md) var(--space-lg);
  }
  
  /* Dashboard mobile improvements */
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
  
  @media (max-width: 480px) {
    .dashboard-stats {
      grid-template-columns: 1fr;
    }
    
    /* Small phone specific improvements */
    .container {
      padding: var(--space-sm);
    }
    
    .search-layout {
      padding: var(--space-sm);
      gap: var(--space-sm);
    }
    
    .filters-panel {
      padding: var(--space-sm);
    }
    
    .filters-header h2 {
      font-size: 1.125rem;
    }
    
    .result-card {
      padding: var(--space-sm);
    }
    
    /* Smaller text on very small screens */
    .result-title {
      font-size: 1rem;
    }
    
    .result-snippet {
      font-size: 0.875rem;
    }
    
    /* Stack button groups */
    .result-actions {
      flex-direction: column;
      width: 100%;
    }
    
    .result-actions .btn-action {
      width: 100%;
    }
  }
  
  .dashboard-panels {
    grid-template-columns: 1fr;
  }
  
  /* Collections mobile */
  .collections-grid {
    grid-template-columns: 1fr;
  }
  
  /* Timeline mobile */
  .timeline-container {
    padding: var(--space-md);
  }
  
  /* Status page mobile */
  .status-grid {
    grid-template-columns: 1fr;
  }
  
  /* Ensure all images are responsive on mobile */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Fix floating button on mobile */
  .floating-chat-btn {
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
    right: calc(1.5rem + env(safe-area-inset-right, 0));
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
  }
  
  .floating-chat-btn svg {
    width: 24px;
    height: 24px;
  }
  
  .floating-chat-btn:hover,
  .floating-chat-btn:active {
    transform: scale(1.05) translateY(-2px);
  }
  
  /* Form improvements for mobile */
  .form-group {
    margin-bottom: var(--space-lg);
  }
  
  .form-row {
    flex-direction: column;
    gap: var(--space-md);
  }
  
  /* Button groups stack on mobile */
  .button-group {
    flex-direction: column;
    width: 100%;
  }
  
  .button-group > * {
    width: 100%;
  }
  
  /* Prevent text overflow */
  .result-title,
  .card-title,
  h1, h2, h3 {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}

/* Report Studio Styles */
.studio-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  gap: var(--space-lg);
}

.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.studio-main {
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  gap: var(--space-lg);
  flex: 1;
  min-height: 0;
}

/* Mobile responsive for studio */
@media (max-width: 968px) {
  .studio-main {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .outline-panel,
  .sources-panel {
    order: 2;
    max-height: 300px;
  }
  
  .editor-panel {
    order: 1;
  }
}

.outline-panel,
.editor-panel,
.sources-panel {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.editor-toolbar {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.btn-tool {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.875rem;
}

.btn-tool:hover {
  background: var(--card);
}

.toolbar-separator {
  width: 1px;
  background: var(--border);
  margin: 0 var(--space-xs);
}

.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.report-editor {
  min-height: 100%;
  outline: none;
  line-height: 1.8;
}

.report-editor h1,
.report-editor h2,
.report-editor h3 {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn.active {
  background: var(--card);
  color: var(--fg);
  border-bottom-color: var(--brand);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
}

.sources-list,
.quotes-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.source-item,
.quote-item {
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.empty-state {
  text-align: center;
  color: var(--fg-secondary);
  padding: var(--space-xl);
}

.outline-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-md);
}

.outline-item {
  padding: var(--space-sm);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.outline-item:hover {
  background: var(--bg-secondary);
}

.outline-item.active {
  background: var(--brand);
  color: white;
}

/* Story Story Timeline Styles */
.timeline-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  height: calc(100vh - 200px);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.timeline-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-height: 0;
}

.timeline-controls {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
  padding: var(--space-md);
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.timeline-container {
  position: relative;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: var(--space-xl);
}

.timeline-ribbon {
  position: relative;
  height: 200px;
  min-width: 100%;
}

.timeline-event {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  cursor: pointer;
}

.event-marker {
  width: 12px;
  height: 12px;
  background: var(--brand);
  border-radius: 50%;
  border: 3px solid var(--bg);
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.event-label {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.875rem;
  color: var(--fg);
  background: var(--card);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.event-popup {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 250px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: none;
  z-index: 10;
}

.timeline-event:hover .event-popup {
  display: block;
}

.timeline-years {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  border-top: 1px solid var(--border);
}

.year-marker {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: var(--space-xs);
}

/* Explore Archives Page Layout Styles */
.search-layout {
  display: grid;
  grid-template-columns: 280px 1fr 400px;
  gap: var(--space-lg);
  min-height: calc(100vh - 200px);
}

/* Refine Results Panel (Left) */
.filters-panel {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: var(--space-md);
  height: fit-content;
  position: sticky;
  top: var(--space-lg);
  max-height: calc(100vh - 250px);
  overflow-y: auto;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.filters-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--fg);
}

.btn-clear-all {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.btn-clear-all:hover {
  background: var(--card-hover);
  color: var(--fg);
}

.filters-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.filter-section {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.filter-section:last-child {
  border-bottom: none;
}

.filter-section-header {
  margin-bottom: var(--space-xs);
}

.filter-section-header .filter-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-section-collapsible {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.filter-section-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  padding: var(--space-xs) 0;
  cursor: pointer;
  color: var(--fg-secondary);
  transition: color var(--transition-fast);
}

.filter-section-toggle:hover {
  color: var(--fg);
}

.filter-section-toggle .filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toggle-icon {
  font-size: 0.7rem;
  transition: transform var(--transition-fast);
}

.filter-section-content {
  padding-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.category-pills-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.category-pill-compact {
  padding: 0.35rem 0.7rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.category-pill-compact:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--fg);
}

.category-pill-compact.is-active {
  background: rgba(102, 85, 221, 0.25);
  border-color: rgba(102, 85, 221, 0.45);
  color: #fff;
}

.quick-chip-container {
  margin-top: var(--space-xs);
  animation: fadeIn 0.2s ease;
}

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

.quick-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.quick-chip {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.quick-chip:hover,
.quick-chip:focus {
  background: rgba(102, 85, 221, 0.18);
  border-color: rgba(102, 85, 221, 0.42);
  color: #fff;
  transform: translateY(-1px);
}

.quick-chip-more {
  background: rgba(102, 85, 221, 0.1);
  border-color: rgba(102, 85, 221, 0.3);
  color: var(--brand);
  font-weight: 500;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.filter-label {
  font-size: 0.875rem;
  color: var(--fg-secondary);
  font-weight: 500;
}

.filter-input,
.filter-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102, 136, 204, 0.1);
}

.year-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.year-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-family: inherit;
}

.year-separator {
  color: var(--muted);
  font-size: 1.125rem;
}

/* Apply button removed - filters auto-submit */

/* Results Main (Center) */
.results-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-height: 0;
}

.search-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.search-form-main {
  display: flex;
  gap: var(--space-sm);
}

.search-input-main {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-size: 1rem;
  font-family: inherit;
  transition: all var(--transition-base);
}

.search-input-main:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102, 136, 204, 0.1);
}

.btn-search-main {
  padding: var(--space-md) var(--space-xl);
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-search-main:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
}

.btn-research-link {
  padding: var(--space-md) var(--space-lg);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: all var(--transition-base);
}

.btn-research-link:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.search-info {
  display: flex;
  gap: var(--space-lg);
  color: var(--fg-secondary);
  font-size: 0.875rem;
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-pill {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background var(--transition-fast), border var(--transition-fast), color var(--transition-fast);
}

.category-pill.is-active {
  background: rgba(102, 85, 221, 0.25);
  border-color: rgba(102, 85, 221, 0.45);
  color: #fff;
}

.category-pill:hover,
.category-pill:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.active-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--space-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
}

.active-filters__label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

.active-filter-chip {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background var(--transition-fast), border var(--transition-fast);
}

.active-filter-chip:hover,
.active-filter-chip:focus {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
}

.active-filter-reset {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color var(--transition-fast);
}

.active-filter-reset:hover,
.active-filter-reset:focus {
  color: var(--fg);
}

.result-count {
  color: var(--brand);
  font-weight: 600;
}

.results-stream {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  flex: 1;
  overflow-y: auto;
}

.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  gap: var(--space-md);
}

.result-card:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.result-thumbnail {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  position: relative;
}

.result-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-base);
}

.result-thumbnail:hover img {
  transform: scale(1.05);
}

/* Image error handling - show placeholder if image fails */
.result-thumbnail img[src=""],
.result-thumbnail img:not([src]) {
  display: none;
}

/* Thumbnail placeholder styling */
.result-thumbnail .thumbnail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 2em;
  color: #999;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

/* Loading state for thumbnails */
.result-thumbnail img {
  background: var(--bg-secondary);
}

.result-thumbnail img[data-loading="true"] {
  opacity: 0.5;
}

/* Ensure images are responsive */
img {
  max-width: 100%;
  height: auto;
}

/* Preview Document Document images */
.preview-image img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
}

.result-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0;
}

.result-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
}

.result-meta {
  display: flex;
  gap: var(--space-md);
  font-size: 0.875rem;
  color: var(--fg-secondary);
  flex-wrap: wrap;
}

.result-snippet {
  color: var(--fg-secondary);
  line-height: 1.6;
  font-size: 0.9375rem;
  margin: var(--space-xs) 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-actions {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.btn-action {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-action:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

/* Preview Document Document Drawer (Right) */
.preview-drawer {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: fit-content;
  position: sticky;
  top: var(--space-lg);
  max-height: calc(100vh - 250px);
  overflow: hidden;
  transition: all var(--transition-base);
  z-index: 10;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--fg);
}

.btn-drawer-close {
  background: none;
  border: none;
  color: var(--fg-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-drawer-close:hover {
  color: var(--fg);
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.drawer-placeholder {
  text-align: center;
  color: var(--fg-secondary);
  padding: var(--space-xl);
}

.preview-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.preview-item h4 {
  margin: 0;
  font-size: 1.125rem;
  color: var(--fg);
}

.preview-snippet {
  color: var(--fg-secondary);
  line-height: 1.6;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.preview-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.preview-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--fg);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.preview-toggle:hover,
.preview-toggle:focus-visible {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

.preview-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 998;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.preview-backdrop.show {
  display: block;
  opacity: 1;
}

.btn-preview-action {
  padding: var(--space-sm) var(--space-md);
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-preview-action:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
}

/* Empty States */
.search-prompt,
.no-results {
  text-align: center;
  padding: var(--space-2xl);
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.search-prompt h2,
.no-results h2 {
  margin: 0 0 var(--space-md) 0;
  color: var(--fg);
}

.no-results-hint {
  color: var(--fg-secondary);
  margin-top: var(--space-sm);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) 0;
  margin-top: var(--space-lg);
}

.btn-pagination {
  padding: var(--space-sm) var(--space-lg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  text-decoration: none;
  transition: all var(--transition-base);
}

.btn-pagination:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

/* Mobile Responsive for Explore Archives */
@media (max-width: 1200px) {
  .search-layout {
    grid-template-columns: 250px 1fr 350px;
  }
}

@media (max-width: 968px) {
  .search-layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .filters-panel {
    position: relative;
    top: 0;
    max-height: none;
  }
  
  .preview-toggle {
    display: inline-flex;
    width: 100%;
    margin-bottom: var(--space-sm);
  }
  
  .preview-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 60px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.45);
    transform: translateY(105%);
    transition: transform var(--transition-base);
    z-index: 1000;
    display: flex !important; /* Always visible for transform to work */
  }
  
  .preview-drawer.open {
    transform: translateY(0);
  }
  
  .preview-drawer .drawer-content {
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0));
  }
  
  /* Ensure backdrop works on mobile */
  .preview-backdrop {
    display: block;
    opacity: 0;
    pointer-events: none;
  }
  
  .preview-backdrop.show {
    opacity: 1;
    pointer-events: all;
  }
  
  .result-card {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .result-thumbnail {
    width: 100%;
    height: 200px;
    min-height: 150px;
    order: -1;
  }
  
  .result-thumbnail img {
    object-fit: cover;
    width: 100%;
    height: 100%;
  }
  
  .result-content {
    width: 100%;
  }
  
  .result-actions {
    flex-wrap: wrap;
    gap: var(--space-xs);
    justify-content: center;
  }
  
  .btn-action {
    min-width: 44px;
    min-height: 44px;
  }
  
  .filters-panel {
    margin-bottom: var(--space-md);
  }
}

/* Common Button Styles */
.btn-primary {
  padding: var(--space-md) var(--space-lg);
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-primary:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

.btn-ghost {
  padding: var(--space-md) var(--space-lg);
  background: transparent;
  color: var(--fg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-ghost:hover {
  color: var(--fg);
  background: var(--bg-secondary);
}

/* Alert & Notification Styles */
.alert {
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid;
  margin: var(--space-lg) 0;
  display: flex;
  align-items: start;
  gap: var(--space-md);
}

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error);
}

.alert-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.alert-info {
  background: rgba(102, 136, 204, 0.1);
  border-color: var(--brand);
  color: var(--brand);
}

.alert-content {
  flex: 1;
}

.alert-tip {
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Loading States */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Inline Explanations (Reader) */
.inline-explanations {
  margin-top: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.inline-explanation {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border-left: 4px solid var(--brand);
}

.inline-explanation.explain {
  border-left-color: var(--brand);
}

.inline-explanation.define {
  border-left-color: var(--accent);
}

.inline-explanation.translate {
  border-left-color: var(--warn);
}

.explanation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.explanation-header strong {
  color: var(--fg);
  font-size: 1rem;
}

.explanation-header button {
  background: none;
  border: none;
  color: var(--fg-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explanation-header button:hover {
  color: var(--fg);
}

.explanation-content {
  color: var(--fg-secondary);
  line-height: 1.6;
}

.explanation-content p {
  margin: var(--space-sm) 0;
}

.btn-add-note {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-add-note:hover {
  background: var(--brand-hover);
}

/* Status Page Styles */
.status-section {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: var(--space-xl);
}

.status-header {
  margin-bottom: var(--space-xl);
}

.status-header h2 {
  margin: 0 0 var(--space-sm) 0;
  color: var(--fg);
}

.status-subtitle {
  color: var(--fg-secondary);
  margin: 0 0 var(--space-lg) 0;
}

.status-totals {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.total-item {
  color: var(--fg-secondary);
  font-size: 0.875rem;
}

.total-item strong {
  color: var(--brand);
  font-size: 1.125rem;
}

.status-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.status-table-container {
  overflow-x: auto;
  margin-top: var(--space-lg);
}

.status-table {
  width: 100%;
  border-collapse: collapse;
}

.status-table th {
  text-align: left;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border);
  color: var(--fg);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--fg-secondary);
  font-size: 0.875rem;
}

.status-table tr:hover {
  background: var(--bg-secondary);
}

.category-badge {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.btn-link {
  color: var(--brand);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color var(--transition-fast);
}

.btn-link:hover {
  color: var(--brand-hover);
  text-decoration: underline;
}

/* Tooltips */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-xs) var(--space-sm);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: var(--space-xs);
  box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% - 5px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--border);
  z-index: 1000;
}

/* Mobile Card Stack UI - Enhanced */
@media (max-width: 768px) {
  .reader-layout {
    padding: 0 var(--space-md);
    gap: var(--space-lg);
  }
  
  .citation-bar {
    padding: var(--space-lg) var(--space-md);
    gap: var(--space-md);
    border-radius: var(--radius-md);
  }
  
  .article-title {
    font-size: 1.5rem;
  }
  
  .citation-meta {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .citation-actions {
    width: 100%;
    justify-content: flex-start;
  }
  
  .btn-citation {
    flex: 1;
    min-width: 0;
    justify-content: center;
  }
  
  .reader-main {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
  }
  
  .reader-scan {
    order: -1;
    position: relative;
    top: 0;
    max-height: 400px;
    overflow: hidden;
    border-radius: var(--radius-md);
  }
  
  .reader-text {
    padding: var(--space-lg) var(--space-md);
    border-radius: var(--radius-md);
    min-height: auto;
  }
  
  .reader-controls {
    position: sticky;
    top: 80px;
    background: var(--card);
    z-index: 10;
    padding: var(--space-md);
    margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-md)) var(--space-lg);
    border-bottom: 2px solid var(--border);
    border-radius: var(--radius-md);
    flex-direction: column;
    align-items: stretch;
  }
  
  .btn-listen {
    width: 100%;
    justify-content: center;
    padding: var(--space-lg);
    font-size: 1rem;
  }
  
  .speed-controls {
    width: 100%;
    justify-content: space-between;
    margin-top: var(--space-sm);
  }
  
  .btn-control {
    flex: 1;
    text-align: center;
    justify-content: center;
  }
  
  .text-content {
    font-size: 1rem;
    line-height: 1.8;
  }
  
  .text-content p {
    margin: var(--space-md) 0;
  }
  
  .result-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }
  
  .result-thumbnail {
    width: 100%;
    height: 200px;
    order: -1;
  }
  
  .result-actions {
    justify-content: center;
  }
  
  .btn-action {
    flex: 1;
    justify-content: center;
    padding: var(--space-md);
    font-size: 1rem;
  }
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Focus Management */
*:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Selection Colors */
::selection {
  background: var(--brand);
  color: white;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Dashboard Quick Actions */
.quick-actions {
  margin-top: var(--space-xl);
}

.section-title {
  margin: 0 0 var(--space-lg) 0;
  font-size: 1.25rem;
  color: var(--fg);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.action-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  text-align: center;
}

.action-card:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.action-icon {
  font-size: 2rem;
  margin-bottom: var(--space-xs);
}

.action-label {
  font-size: 0.9375rem;
  color: var(--fg);
  font-weight: 500;
}

/* Help Modal Styles */
.hotkey-list {
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0;
}

.hotkey-list li {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
}

.hotkey-list kbd {
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.875rem;
  min-width: 30px;
  text-align: center;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-secondary);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--fg);
  background: var(--bg-secondary);
}

/* Image URL Fix for Reader */
.reader-scan .scan-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

.scan-placeholder {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--fg-secondary);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

/* Archive Archive Source Display in Reader */
.article-source {
  color: var(--fg-secondary);
  font-size: 0.875rem;
  font-style: italic;
}

/* Loading States for Buttons */
button.loading,
.btn-primary.loading,
.btn-secondary.loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

button.loading::after,
.btn-primary.loading::after,
.btn-secondary.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Notification Toast */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-width: 400px;
  animation: slideInUp 0.3s ease;
}

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

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.info {
  border-left: 4px solid var(--brand);
}

/* Form Improvements */
input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

input[type="range"]::-webkit-slider-thumb {
  background: var(--brand);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  background: var(--brand);
  cursor: pointer;
  border: none;
}

/* Better focus states */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102, 136, 204, 0.1);
}

/* Disabled states */
button:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0));
  right: calc(var(--space-lg) + env(safe-area-inset-right, 0));
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  width: min(420px, calc(100vw - (var(--space-lg) + env(safe-area-inset-right, 0)) - (var(--space-lg) + env(safe-area-inset-left, 0))));
}

.toast-container .toast {
  pointer-events: auto;
}

/* Archive Archive Source URL in Reader */
.article-source {
  display: inline-block;
  margin-left: var(--space-sm);
}

/* Image URL Display */
.article-image-url {
  max-width: 100%;
  margin: var(--space-md) 0;
}

/* Reader Image Display */
.reader-scan img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* Better Empty States */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
  color: var(--fg-secondary);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.empty-state h2 {
  margin: 0 0 var(--space-md) 0;
  color: var(--fg);
}

.empty-state p {
  margin: var(--space-sm) 0;
}

/* Print Styles */
@media print {
  .topbar,
  .footer,
  .sidebar,
  .filters-panel,
  .preview-drawer,
  .reader-controls,
  .btn-action,
  .btn-primary,
  .btn-secondary {
    display: none !important;
  }
  
  .reader-main {
    grid-template-columns: 1fr;
  }
  
  .text-content {
    font-size: 12pt;
    line-height: 1.6;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Read Aloud Button Styles */
.btn-read-aloud {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.btn-read-aloud:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

.btn-read-aloud.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.btn-read-aloud.active:hover {
  background: var(--brand-hover);
}

.btn-read-aloud-message {
  background: transparent;
  border: none;
  padding: var(--space-xs);
  opacity: 0.7;
}

.btn-read-aloud-message:hover {
  opacity: 1;
  background: var(--bg-secondary);
}

.read-icon {
  font-size: 1rem;
  line-height: 1;
}

.read-text {
  font-size: 0.875rem;
}

/* Message Actions */
.message-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--border);
}

.message.user .message-actions {
  display: none;
}

/* Chat Overlay Styles - Modern Design */
.chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
    align-items: flex-end;
    justify-content: flex-end;
    pointer-events: none;
}

.chat-overlay.open {
    display: flex;
}

.chat-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    pointer-events: auto;
    animation: fadeIn 0.2s ease;
}

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

.chat-overlay-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    background: var(--card, #12161b);
    border-radius: 20px 20px 0 0;
    border: 1px solid var(--border, #222831);
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    animation: slideUpModern 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

/* Mobile optimizations for chat overlay */
@media (max-width: 768px) {
  .chat-overlay-content {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 20px 20px 0 0;
  }
  
  .chat-overlay-body {
    padding: var(--space-md);
  }
  
  .chat-overlay-header {
    padding: var(--space-md) var(--space-lg);
  }
  
  .chat-overlay-body .chat-messages {
    padding: var(--space-lg) var(--space-md);
    gap: var(--space-sm);
  }
  
  .chat-overlay-body .chat-message {
    max-width: 85%;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9375rem;
  }
  
  .chat-quick-actions {
    flex-direction: row;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .chat-quick-actions .quick-action-btn {
    white-space: nowrap;
    font-size: 0.8125rem;
    padding: var(--space-xs) var(--space-sm);
  }
  
  .chat-input-wrapper {
    padding: var(--space-md);
    gap: var(--space-xs);
  }
  
  .chat-overlay-input {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--space-sm) var(--space-md);
  }
  
  .chat-send-btn {
    min-width: 60px;
    padding: var(--space-sm) var(--space-md);
  }
}

@keyframes slideUpModern {
    from {
        transform: translateY(100%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.chat-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border, #222831);
    background: var(--card, #12161b);
    backdrop-filter: blur(20px);
    position: relative;
}

.chat-overlay-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border, #222831), transparent);
}

.chat-overlay-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--fg, #e7eaee);
    letter-spacing: -0.01em;
}

.chat-context-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent, #6655dd), var(--brand, #6699cc));
    color: white;
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(102, 85, 221, 0.3);
}

.chat-overlay-close {
    background: var(--bg-secondary, #12161b);
    border: 1px solid var(--border, #222831);
    color: var(--fg-secondary, #cbd5e0);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.chat-overlay-close:hover {
    background: var(--card-hover, #1a1e25);
    border-color: var(--brand, #6699cc);
    color: var(--fg, #e7eaee);
    transform: rotate(90deg);
}

.chat-overlay-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg, #0b0d10);
}

.chat-overlay-body .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl) var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    scroll-behavior: smooth;
}

.chat-overlay-body .chat-message {
    padding: var(--space-md) var(--space-lg);
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease;
    position: relative;
    line-height: 1.5;
}

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

.chat-overlay-body .chat-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent, #6655dd), var(--accent-hover, #818cf8));
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(102, 85, 221, 0.3);
}

.chat-overlay-body .chat-message.assistant,
.chat-overlay-body .chat-message.system {
    align-self: flex-start;
    background: var(--card, #12161b);
    color: var(--fg, #e7eaee);
    border: 1px solid var(--border, #222831);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-overlay-body .chat-message .message-content {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.chat-overlay-body .chat-message.user .message-content {
    color: white;
}

.chat-quick-actions {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border, #222831);
    flex-wrap: wrap;
    background: var(--card, #12161b);
    backdrop-filter: blur(20px);
}

.chat-quick-actions .quick-action-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary, #12161b);
    border: 1px solid var(--border, #222831);
    border-radius: var(--radius-md);
    color: var(--fg-secondary, #cbd5e0);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.chat-quick-actions .quick-action-btn:hover {
    background: var(--card-hover, #1a1e25);
    border-color: var(--brand, #6699cc);
    color: var(--fg, #e7eaee);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.chat-input-wrapper {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--border, #222831);
    background: var(--card, #12161b);
    backdrop-filter: blur(20px);
    position: relative;
}

.chat-input-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border, #222831), transparent);
}

.chat-overlay-input {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary, #12161b);
    border: 2px solid var(--border, #222831);
    border-radius: 24px;
    color: var(--fg, #e7eaee);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all var(--transition-base);
    resize: none;
    min-height: 48px;
    max-height: 120px;
}

.chat-overlay-input:focus {
    outline: none;
    border-color: var(--accent, #6655dd);
    box-shadow: 0 0 0 4px rgba(102, 85, 221, 0.1);
    background: var(--card, #12161b);
}

.chat-overlay-input::placeholder {
    color: var(--muted, #97a0ad);
}

.chat-send-btn {
    padding: var(--space-md) var(--space-xl);
    background: linear-gradient(135deg, var(--accent, #6655dd), var(--accent-hover, #818cf8));
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: all var(--transition-base);
    box-shadow: 0 2px 8px rgba(102, 85, 221, 0.3);
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 85, 221, 0.4);
}

.chat-send-btn:active {
    transform: translateY(0);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-loader {
    padding: var(--space-md) var(--space-lg);
    color: var(--fg-secondary, #cbd5e0);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chat-loader::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border, #222831);
    border-top-color: var(--brand, #6699cc);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Context Panel Overlay */
#context-panel-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-secondary, #1e1e1e);
    border-left: 1px solid var(--border-color, #3a3a3a);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#context-panel-overlay.open {
    display: flex;
}


/* Floating Chat Button - Modern Design */
.floating-chat-btn {
    position: fixed;
    bottom: calc(2rem + env(safe-area-inset-bottom, 0));
    right: calc(2rem + env(safe-area-inset-right, 0));
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent, #6655dd) 0%, var(--accent-hover, #818cf8) 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(102, 85, 221, 0.4), 
                0 0 0 0 rgba(102, 85, 221, 0.5),
                0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.floating-chat-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.floating-chat-btn:hover::before {
    width: 300px;
    height: 300px;
}

.floating-chat-btn svg {
    width: 28px;
    height: 28px;
    stroke: white;
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.floating-chat-btn:hover {
    transform: scale(1.1) translateY(-4px) rotate(5deg);
    box-shadow: 0 12px 32px rgba(102, 85, 221, 0.5), 
                0 0 0 8px rgba(102, 85, 221, 0.1),
                0 4px 12px rgba(0, 0, 0, 0.3);
}

.floating-chat-btn:hover svg {
    transform: scale(1.1);
}

.floating-chat-btn:active {
    transform: scale(0.95) translateY(-1px) rotate(0deg);
    box-shadow: 0 4px 12px rgba(102, 85, 221, 0.4),
                0 0 0 4px rgba(102, 85, 221, 0.1);
}

.floating-chat-btn:active svg {
    transform: scale(0.95);
}

/* Pulse animation when chat overlay is open */
.floating-chat-btn.active {
    animation: chatPulse 2s ease-in-out infinite;
}

body.chat-overlay-open .floating-chat-btn {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

@keyframes chatPulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(102, 85, 221, 0.4), 
                    0 0 0 0 rgba(102, 85, 221, 0.5);
    }
    50% {
        box-shadow: 0 8px 24px rgba(102, 85, 221, 0.4), 
                    0 0 0 8px rgba(102, 85, 221, 0);
    }
}


/* Dashboard Redesign - Apple-inspired */
.dashboard-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0 0 0.5rem 0;
}

.dashboard-subtitle {
    color: var(--text-secondary, #888);
    font-size: 1rem;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary, #1e1e1e);
    border: 1px solid var(--border-color, #3a3a3a);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--border-hover, #4a4a4a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-card.highlighted {
    border-color: var(--accent-color, #007aff);
    background: linear-gradient(135deg, var(--bg-secondary, #1e1e1e) 0%, rgba(0, 122, 255, 0.05) 100%);
}

.stat-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stat-icon {
    font-size: 1.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary, #888);
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin-bottom: 0.25rem;
}

.stat-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary, #666);
}

.quick-actions-section {
    margin-bottom: 2rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-primary-action,
.btn-secondary-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary-action {
    background: var(--accent-color, #007aff);
    color: white;
}

.btn-primary-action:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-secondary-action {
    background: var(--bg-tertiary, #2a2a2a);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-color, #3a3a3a);
}

.btn-secondary-action:hover {
    background: var(--bg-hover, #3a3a3a);
    border-color: var(--border-hover, #4a4a4a);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.dashboard-card {
    background: var(--bg-secondary, #1e1e1e);
    border: 1px solid var(--border-color, #3a3a3a);
    border-radius: 12px;
    padding: 1.5rem;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0 0 1rem 0;
}

.card-content {
    color: var(--text-secondary, #888);
}

.getting-started-list {
    list-style: decimal;
    padding-left: 1.5rem;
    margin: 0 0 1rem 0;
}

.getting-started-list li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.card-hint {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-tertiary, #2a2a2a);
    border-radius: 8px;
    font-size: 0.875rem;
}

.card-hint kbd {
    background: var(--bg-primary, #252525);
    border: 1px solid var(--border-color, #3a3a3a);
    border-radius: 4px;
    padding: 0.125rem 0.375rem;
    font-family: monospace;
    font-size: 0.8125rem;
}

.recent-articles-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-article-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-tertiary, #2a2a2a);
    border-radius: 8px;
    border-left: 3px solid transparent;
}

.recent-article-item.pinned {
    border-left-color: var(--accent-color, #007aff);
}

.article-title {
    font-size: 0.9375rem;
    color: var(--text-primary, #fff);
    margin-bottom: 0.25rem;
}

.article-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary, #888);
}

.pin-badge {
    font-size: 1rem;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary, #888);
}

.empty-state p {
    margin: 0.5rem 0;
}

.empty-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary, #666);
}

/* Apps Section */
.apps-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0 0 1.5rem 0;
}

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.app-card {
    background: var(--bg-secondary, #1e1e1e);
    border: 1px solid var(--border-color, #3a3a3a);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.2s;
}

.app-card:hover {
    border-color: var(--accent-color, #007aff);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

.app-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.app-icon {
    font-size: 2rem;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin: 0;
}

.app-description {
    color: var(--text-secondary, #888);
    font-size: 0.9375rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.app-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.app-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.app-link-btn.primary {
    background: var(--accent-color, #007aff);
    color: white;
}

.app-link-btn.primary:hover {
    background: var(--accent-hover, #0051d5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.app-link-btn.secondary {
    background: var(--bg-tertiary, #2a2a2a);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-color, #3a3a3a);
}

.app-link-btn.secondary:hover {
    background: var(--bg-hover, #3a3a3a);
    border-color: var(--border-hover, #4a4a4a);
}

.app-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.feature-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary, #2a2a2a);
    border: 1px solid var(--border-color, #3a3a3a);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    font-weight: 500;
}

@media (max-width: 768px) {
    .dashboard-content {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn-primary-action,
    .btn-secondary-action {
        width: 100%;
        justify-content: center;
    }
    
    .apps-grid {
        grid-template-columns: 1fr;
    }
    
    .app-actions {
        flex-direction: column;
    }
    
    .app-link-btn {
        width: 100%;
    }
}


/* Context Panel Overlay (Side Drawer) */
.context-panel-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-secondary, #1e1e1e);
    border-left: 1px solid var(--border-color, #3a3a3a);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.context-panel-overlay.open {
    display: flex;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.context-panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #3a3a3a);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.context-panel-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
}

.context-panel-close {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
}

.context-panel-close:hover {
    background: var(--bg-hover, #3a3a3a);
    color: var(--text-primary, #fff);
}

.context-panel-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.context-panel-container .context-panel-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.context-panel-container .context-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #888);
    margin: 0 0 0.75rem 0;
}

.context-panel-container .context-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.context-panel-container .context-item {
    padding: 0.75rem;
    background: var(--bg-tertiary, #2a2a2a);
    border: 1px solid var(--border-color, #3a3a3a);
    border-radius: 8px;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    transition: all 0.2s;
}

.context-panel-container .context-item:hover {
    border-color: var(--border-hover, #4a4a4a);
    background: var(--bg-hover, #3a3a3a);
}

.context-panel-container .context-item.pinned {
    border-left: 3px solid var(--accent-color, #007aff);
}

.context-panel-container .context-item-content {
    flex: 1;
    cursor: pointer;
}

.context-panel-container .context-item-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary, #fff);
    margin-bottom: 0.25rem;
}

.context-panel-container .context-item-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary, #888);
    display: flex;
    gap: 0.5rem;
}

.context-panel-container .context-item-snippet {
    font-size: 0.8125rem;
    color: var(--text-tertiary, #666);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.context-panel-container .context-item-controls {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-end;
}

.context-panel-container .context-order-controls {
    display: flex;
    gap: 0.25rem;
}

.context-panel-container .context-item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.context-panel-container .context-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.context-panel-container .context-action-btn:hover {
    background: var(--bg-primary, #252525);
    color: var(--text-primary, #fff);
}

.context-panel-container .context-action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.context-panel-container .context-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary, #888);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .context-panel-overlay {
        width: 100vw;
        max-width: 100vw;
    }
}

/* Research Notes Page */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.page-header h1 {
    margin: 0;
    font-size: 2rem;
}

.page-subtitle {
    margin: 0.5rem 0 0 0;
    color: var(--text-secondary, #9ba5b7);
    font-size: 0.95rem;
    max-width: 48rem;
}

.page-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.notebook-status {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    background: rgba(28, 37, 49, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary, #9ba5b7);
    font-size: 0.95rem;
}

.notebook-status.error {
    color: #ffb4b4;
    border-color: rgba(255, 107, 107, 0.3);
    background: rgba(86, 25, 25, 0.4);
}

.notebook-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.notebook-card {
    background: rgba(26, 34, 46, 0.95);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 12px 32px rgba(12, 20, 31, 0.4);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.notebook-card.flash {
    animation: notebookFlash 1.2s ease;
}

.notebook-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 38px rgba(20, 28, 40, 0.55);
}

.notebook-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.notebook-card-header h2 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.35;
}

.notebook-meta {
    margin: 0;
    color: var(--text-secondary, #9ba5b7);
    font-size: 0.9rem;
}

.notebook-summary-text {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.6;
    white-space: pre-line;
}

.notebook-summary-text.muted {
    color: var(--text-secondary, #7a8493);
    font-style: italic;
}

.notebook-bullets {
    margin: 0;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.notebook-bullets li {
    font-size: 0.97rem;
    line-height: 1.5;
}

.notebook-snippet {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary, #8893a5);
    line-height: 1.5;
}

.notebook-card-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-tertiary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(153, 164, 186, 0.3);
    background: transparent;
    color: #d0d8e6;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

.btn-tertiary:hover {
    background: rgba(153, 164, 186, 0.1);
    border-color: rgba(153, 164, 186, 0.5);
    transform: translateY(-1px);
}

.notebook-empty {
    text-align: center;
}

.notebook-empty h2 {
    margin: 0 0 0.75rem;
}

.notebook-empty p {
    margin: 0 auto 1.5rem;
    max-width: 32rem;
    color: var(--text-secondary, #9ba5b7);
}

.notebook-empty-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

@keyframes notebookFlash {
    0% {
        box-shadow: 0 0 0 rgba(102, 126, 234, 0);
        transform: scale(1);
    }
    40% {
        box-shadow: 0 0 0 12px rgba(102, 126, 234, 0.2);
        transform: scale(1.01);
    }
    100% {
        box-shadow: 0 12px 32px rgba(12, 20, 31, 0.4);
        transform: scale(1);
    }
}

@keyframes contextBadgePulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(102, 126, 234, 0.4);
    }
    60% {
        transform: scale(1.15);
        box-shadow: 0 0 0 6px rgba(102, 126, 234, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: none;
    }
}

[data-context-badge].badge-pulse,
[data-context-badge-mobile].badge-pulse {
    animation: contextBadgePulse 0.6s ease;
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions {
        justify-content: flex-start;
    }
}

.summary-panel {
  margin-top: var(--space-xl);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  box-shadow: var(--shadow-sm);
  display: none;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.summary-body {
  color: var(--fg-secondary);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.summary-body ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.btn-inline {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.btn-inline:hover {
  background: var(--bg-secondary);
}

/* Research Jobs Section */
.recent-research {
  margin-top: var(--space-xl);
}

.research-jobs-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.research-job-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.research-job-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}

.job-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.job-status {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.job-status-queued {
  background: var(--bg-secondary);
  color: var(--muted);
}

.job-status-running {
  background: var(--warn-bg);
  color: var(--warn);
}

.job-status-done {
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.job-status-error {
  background: var(--error-bg);
  color: var(--error);
}

.job-date {
  color: var(--muted);
  font-size: 0.875rem;
}

.job-question {
  color: var(--fg);
  margin-bottom: var(--space-md);
  font-weight: 500;
}

.job-progress {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.progress-bar-small {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill-small {
  height: 100%;
  background: var(--brand);
  transition: width 0.3s ease;
}

.progress-text-small {
  font-size: 0.875rem;
  color: var(--muted);
  min-width: 40px;
  text-align: right;
}

.job-actions {
  display: flex;
  gap: var(--space-sm);
}

.btn-job-action {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  color: var(--fg);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  border: 1px solid var(--border);
}

.btn-job-action:hover {
  background: var(--card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

.section-footer {
  margin-top: var(--space-lg);
  text-align: center;
}

.btn-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-fast);
}

.btn-link:hover {
  color: var(--brand-hover);
}

