/* ============================================================
   Awesome Gaussian Splatting ¡ª Stylesheet
   Light / Dark theme via CSS custom properties
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  /* Light theme (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fb;
  --bg-card: #ffffff;
  --bg-sidebar: #f1f3f7;
  --bg-modal: #ffffff;
  --bg-input: #f1f3f7;
  --bg-hover: #e8ecf1;
  --bg-tag: #e8ecf1;
  --bg-tag-active: #4f46e5;
  --bg-badge: #eef2ff;
  --bg-code: #f1f3f7;

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  --text-inverse: #ffffff;
  --text-tag-active: #ffffff;
  --text-link: #4f46e5;

  --border-color: #e5e7eb;
  --border-light: #f3f4f6;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --navbar-height: 64px;
  --sidebar-width: 280px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-card: #1a1d2e;
  --bg-sidebar: #141625;
  --bg-modal: #1a1d2e;
  --bg-input: #1e2135;
  --bg-hover: #252940;
  --bg-tag: #252940;
  --bg-tag-active: #6366f1;
  --bg-badge: #1e1b4b;
  --bg-code: #1e2135;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: #ffffff;
  --text-tag-active: #ffffff;
  --text-link: #818cf8;

  --border-color: #2a2d3e;
  --border-light: #1e2135;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.15);

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: #1e1b4b;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* ---------- Navbar ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.85);
  transition: background var(--transition), border-color var(--transition);
}

[data-theme="dark"] .navbar {
  background: rgba(15,17,23,0.85);
}

.navbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  text-decoration: none;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 8px;
  letter-spacing: -0.02em;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

#searchInput {
  width: 280px;
  padding: 8px 40px 8px 36px;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition);
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#searchInput::placeholder {
  color: var(--text-tertiary);
}

.search-kbd {
  position: absolute;
  right: 10px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--bg-primary);
  color: var(--text-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  pointer-events: none;
}

/* Icon buttons */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

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

.btn-icon svg {
  width: 20px;
  height: 20px;
}

/* Theme toggle icons */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ---------- Filter toggle (mobile) ---------- */
.filter-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 90;
  padding: 12px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
}

.filter-toggle:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* ---------- Layout ---------- */
.layout {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  padding-top: var(--navbar-height);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: var(--navbar-height);
  width: var(--sidebar-width);
  height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  padding: 24px 20px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-sidebar);
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-item {
  flex: 1;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  text-align: center;
  border: 1px solid var(--border-color);
}

.stat-item.stat-item-today {
  grid-column: 1 / -1;
  background: var(--accent-soft);
  border-color: var(--accent);
}

.stat-item.stat-item-today .stat-label {
  color: var(--text-secondary);
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* Filter select */
.filter-select {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8.825L.35 3.175l.7-.7L6 7.425l4.95-4.95.7.7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.filter-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Tag filter */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-tag);
  color: var(--text-secondary);
  border-radius: 50px;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
  transition: all var(--transition);
}

.tag-badge:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tag-badge.active {
  background: var(--bg-tag-active);
  color: var(--text-tag-active);
  border-color: transparent;
}

.tag-count {
  font-size: 0.65rem;
  opacity: 0.7;
}

.btn-link {
  font-size: 0.75rem;
  background: none;
  border: none;
  color: var(--text-link);
  cursor: pointer;
  font-family: var(--font-sans);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

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

/* ---------- Content / Paper Cards ---------- */
.content {
  flex: 1;
  padding: 24px;
  min-width: 0;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.paper-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.paper-card.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg-card) 45%);
}

.paper-card.is-today:hover {
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-lg);
}

.today-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-inverse);
  background: var(--accent);
  border-radius: 999px;
  padding: 4px 8px;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}

.paper-figure {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.paper-figure img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.paper-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-authors {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-date {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.paper-abstract-preview {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.paper-tag {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50px;
}

.paper-links {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.paper-link {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  transition: all var(--transition);
  text-decoration: none;
}

.paper-link:hover {
  background: var(--accent);
  color: white;
}

/* ---------- Load more / No results ---------- */
.load-more {
  text-align: center;
  padding: 32px 0;
}

.no-results {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-tertiary);
}

.no-results svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.no-results p {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: white;
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

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

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-modal);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  z-index: 1;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  padding-right: 40px;
  margin-bottom: 12px;
}

.modal-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal-meta strong {
  color: var(--text-primary);
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.modal-abstract {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.modal-figure img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
}

.modal-figure-caption {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-color);
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .paper-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (max-width: 768px) {
  .navbar-inner {
    padding: 0 16px;
  }

  #searchInput {
    width: 180px;
  }

  .logo-text {
    display: none;
  }

  .filter-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .layout {
    flex-direction: column;
  }

  .content {
    padding: 16px;
  }

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

  .modal-content {
    padding: 20px;
    max-height: 90vh;
  }
}

@media (max-width: 480px) {
  #searchInput {
    width: 140px;
  }

  .search-kbd {
    display: none;
  }

  .paper-card {
    padding: 16px;
  }
}
