/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #4dabf7;
  --bg: #ffffff;
  --bg-alt: #f1f3f5;
  --bg-card: #ffffff;
  --text: #202124;
  --text-light: #5f6368;
  --text-muted: #9aa0a6;
  --border: #dadce0;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --header-height: 60px;
  --bottom-nav-height: 64px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-top: var(--header-height);
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}

body.dark {
  --bg: #0f0f0f;
  --bg-alt: #1a1a2e;
  --bg-card: #1e1e32;
  --text: #e8eaed;
  --text-light: #9aa0a6;
  --text-muted: #5f6368;
  --border: #2d2d2d;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.8);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-alt); }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  justify-content: center;
  white-space: nowrap;
}
.btn-sm { font-size: 0.75rem; padding: 4px 12px; }
.btn-lg { font-size: 1rem; padding: 10px 24px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(26,115,232,0.35); }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }
.btn-outline-light { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,0.4); }
.btn-outline-light:hover { background: #fff; color: var(--primary); border-color: #fff; }

/* ============================================================
   TOP HEADER
   ============================================================ */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255,255,255,0.94);
  transition: transform 0.3s ease, background 0.3s, border-color 0.3s;
  display: flex;
  align-items: center;
  padding: 0 16px;
}
.top-header.hidden { transform: translateY(-100%); }
.top-header .header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  transition: 0.3s;
}
.sidebar-toggle:hover { color: var(--primary); }
.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.2rem;
}
.logo-img { height: 30px; width: auto; }
.logo-text span { color: var(--primary); }
.header-right { display: flex; align-items: center; gap: 6px; }
.nav-user { position: relative; }
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  padding: 4px 8px 4px 4px;
  border-radius: 50px;
  transition: 0.3s;
}
.user-menu-btn:hover { background: var(--bg-alt); }
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-light);
}
.user-name { font-size: 0.8rem; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  min-width: 180px;
  padding: 6px 0;
  display: none;
  z-index: 100;
  overflow: hidden;
}
.user-dropdown.show { display: block; animation: dropdownIn 0.2s ease; }
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  color: var(--text);
  transition: 0.3s;
  font-size: 0.85rem;
}
.user-dropdown a:hover { background: var(--bg-alt); color: var(--primary); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.header-avatar-placeholder {
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: default;
  display: flex;
  align-items: center;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: -320px;
  width: 320px;
  height: 100%;
  background: var(--bg);
  z-index: 1100;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 40px rgba(0,0,0,0.1);
}
.sidebar.open { left: 0; }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1050;
  display: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.show { display: block; }
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.2rem;
}
.sidebar-body { padding: 8px 0 24px; }

/* ─── Sidebar User Info with Dropdown ─── */
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
  cursor: pointer;
}
.sidebar-user-info .sidebar-user-text {
  flex: 1;
  min-width: 0;
}
.sidebar-avatar-wrapper {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}
.sidebar-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-light);
  display: block;
}
.sidebar-avatar-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 2px solid var(--border);
}
.sidebar-name { font-weight: 600; font-size: 0.95rem; }
.sidebar-email { font-size: 0.75rem; color: var(--text-light); }
.sidebar-user-dropdown-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 4px;
  cursor: pointer;
  transition: 0.3s;
  flex-shrink: 0;
}
.sidebar-user-dropdown-toggle:hover { color: var(--text); }

.sidebar-user-dropdown {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: none;
  animation: dropdownIn 0.2s ease;
  background: var(--bg);
}
.sidebar-user-dropdown.open { display: block; }
.sidebar-user-dropdown .recent-account-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  cursor: pointer;
  transition: 0.2s;
}
.sidebar-user-dropdown .recent-account-item:hover { background: var(--bg-alt); }
.sidebar-user-dropdown .recent-account-item .ra-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user-dropdown .recent-account-item .ra-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-dropdown .recent-account-item .ra-name {
  font-weight: 500;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-dropdown .recent-account-item .ra-email {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-dropdown .recent-account-item .ra-check {
  color: var(--primary);
  font-size: 0.8rem;
}
.sidebar-user-dropdown .recent-account-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 16px;
}

.sidebar-section { padding: 8px 0; }
.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 20px 4px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 20px;
  color: var(--text);
  font-weight: 500;
  transition: 0.3s;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.sidebar-link:hover,
.sidebar-link.active { background: var(--bg-alt); color: var(--primary); }
.sidebar-link i { width: 20px; text-align: center; }

.sidebar-auth, .sidebar-user { padding: 12px 20px; }
.sidebar-user-name { font-weight: 600; margin-bottom: 8px; font-size: 0.95rem; }

/* Theme section (collapsible) */
.theme-section .theme-toggle { cursor: pointer; user-select: none; }
.theme-section .theme-toggle i { transition: transform 0.3s; }
.theme-section.collapsed .theme-toggle i { transform: rotate(-90deg); }
.theme-section.collapsed .theme-options-wrapper { display: none; }
.theme-options-wrapper { padding: 4px 20px 8px; }
.theme-inline { display: flex; gap: 8px; flex-wrap: wrap; }
.theme-option-inline {
  flex: 1;
  min-width: 60px;
  padding: 6px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  font-weight: 500;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  transition: 0.3s;
  cursor: pointer;
}
.theme-option-inline:hover { border-color: var(--primary-light); }
.theme-option-inline.active { border-color: var(--primary); background: var(--bg-alt); }
.theme-option-inline i { font-size: 0.9rem; }

/* ============================================================
   MAIN SHELL & TABS
   ============================================================ */
.main-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 0 16px;
}
.tab-page {
  display: none;
  animation: fadeIn 0.3s ease;
  padding: 0 0 20px;
}
.tab-page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.tab-loading { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 0.95rem; }

/* ============================================================
   HERO BANNER
   ============================================================ */
.hero-banner { padding: 8px 0 4px; }
.banner-slide {
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: linear-gradient(135deg, #1a73e8, #4dabf7);
  min-height: 100px;
  margin: 0 4px;
}
.banner-content { flex: 1; }
.banner-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 2px 12px;
  border-radius: 50px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.banner-content h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 2px; }
.banner-content p { opacity: 0.85; font-size: 0.85rem; margin-bottom: 8px; }
.banner-content .btn { font-size: 0.75rem; padding: 4px 16px; }
.banner-icon { font-size: 3rem; opacity: 0.3; margin-left: 12px; }

/* ============================================================
   HOME TABS (sticky)
   ============================================================ */
.home-tabs { margin-top: 8px; }
.home-tab-nav {
  display: flex;
  gap: 4px;
  padding: 0 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  scrollbar-width: none;
  position: sticky;
  top: var(--header-height);
  background: var(--bg);
  z-index: 50;
  padding-top: 4px;
  padding-bottom: 4px;
}
.home-tab-nav::-webkit-scrollbar { display: none; }
.home-tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-light);
  transition: 0.3s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.home-tab-btn:hover { color: var(--text); }
.home-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.home-tab-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}
.home-tab-panel.active { display: block; }

/* ============================================================
   SHELVES & CARDS – LARGER SIZES
   ============================================================ */
.section-shelf { padding: 12px 0 4px; }
.section-shelf:last-child { padding-bottom: 16px; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 4px;
}
.section-header>div { display: flex; flex-direction: column; gap: 0; }
.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--text-light);
  letter-spacing: 0.3px;
}
.section-tag.sponsored-tag { color: #e17055; }
.section-tag i { font-size: 0.65rem; }

.doc-shelf {
  display: flex;
  gap: 20px;
  padding: 4px 12px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.doc-shelf::-webkit-scrollbar { display: none; }

/* Larger cards */
.doc-item {
  flex: 0 0 180px;        /* wider */
  max-width: 220px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.doc-item:hover { transform: translateY(-4px); }
.doc-icon-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1.2;   /* slightly taller (like a book) */
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-alt);
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s ease;
}
.doc-item:hover .doc-icon-wrapper { box-shadow: var(--shadow-hover); }
.doc-icon-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.doc-icon-wrapper .doc-thumbnail-loading {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  font-size: 1.5rem;
  color: var(--text-muted);
}
.sponsored-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: #e17055;
  color: #fff;
  font-size: 0.5rem;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  z-index: 2;
}
.doc-meta {
  width: 100%;
  padding: 8px 2px 0;
  text-align: left;
}
.doc-meta h3 {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 2px;
}
.doc-meta .author {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-bottom: 2px;
}
.doc-meta .rating {
  font-size: 0.7rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 2px;
}
.doc-meta .rating i { color: #fdcb6e; font-size: 0.6rem; }

/* ============================================================
   ADS CAROUSEL
   ============================================================ */
.ad-shelf { padding: 4px 12px 8px; overflow: hidden; }
.ad-carousel { position: relative; }
.ad-carousel-track {
  display: flex;
  transition: transform 0.6s ease;
}
.ad-banner {
  flex: 0 0 100%;
  width: 100%;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: 0.3s;
  position: relative;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}
.ad-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ad-banner .ad-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}
.ad-banner .ad-placeholder i { font-size: 2.5rem; color: var(--primary); opacity: 0.4; margin-bottom: 8px; }
.ad-banner .ad-title { font-weight: 600; font-size: 1rem; }
.ad-banner .ad-desc { font-size: 0.8rem; color: var(--text-light); }
.ad-banner .ad-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 0.55rem;
  padding: 2px 10px;
  border-radius: 50px;
  font-weight: 600;
  z-index: 2;
}
.ad-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px 0 2px;
}
.ad-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: 0.3s;
}
.ad-dot.active { background: var(--primary); }

/* ============================================================
   CATEGORIES GRID
   ============================================================ */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 4px 12px 12px;
}
.category-card {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 16px 10px;
  text-align: center;
  transition: 0.3s;
  border: 2px solid transparent;
  cursor: pointer;
}
.category-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  background: var(--bg);
}
.category-card i { font-size: 1.8rem; color: var(--primary); margin-bottom: 4px; }
.category-card h4 { font-weight: 600; font-size: 0.85rem; }
.category-card p { font-size: 0.65rem; color: var(--text-light); }

/* ============================================================
   SHIMMER LOADING (works in dark mode)
   ============================================================ */
.shimmer-wrapper {
  display: flex;
  gap: 20px;
  padding: 4px 12px 12px;
  overflow: hidden;
}
.shimmer-item {
  flex: 0 0 180px;
  max-width: 220px;
}
.shimmer-icon {
  width: 100%;
  aspect-ratio: 1 / 1.2;
  border-radius: var(--radius);
  background: var(--bg-alt);
  position: relative;
  overflow: hidden;
}
.shimmer-icon::after,
.shimmer-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 150%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.08) 30%,
    rgba(255,255,255,0.15) 50%,
    rgba(255,255,255,0.08) 70%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmerMove 1.8s infinite;
  pointer-events: none;
}
body.dark .shimmer-icon::after,
body.dark .shimmer-line::after {
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.04) 30%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 70%,
    transparent 100%
  );
}
@keyframes shimmerMove {
  0% { left: -150%; }
  100% { left: 150%; }
}
.shimmer-text { margin-top: 6px; }
.shimmer-line {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-alt);
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
}
.shimmer-line.long { width: 100%; }
.shimmer-line.medium { width: 70%; }
.shimmer-line.short { width: 40%; }

/* ============================================================
   ERROR & LOADING
   ============================================================ */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
  gap: 10px;
  min-height: 150px;
}
.error-container i { font-size: 2.5rem; color: var(--text-muted); }
.error-container h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
.error-container p { color: var(--text-light); font-size: 0.85rem; max-width: 300px; }
.error-container .btn { margin-top: 4px; }
.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}
.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary);
  animation: spin 0.8s linear infinite;
  position: relative;
}
.spinner::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 4px solid transparent;
  border-bottom: 4px solid var(--primary-light);
  animation: spin 0.6s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   WELCOME POPUP
   ============================================================ */
.welcome-popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: none;
  pointer-events: none;
}
.welcome-popup.show { display: block; pointer-events: auto; }
.welcome-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.welcome-popup.show .welcome-backdrop { opacity: 1; }
.welcome-sheet {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px 30px;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}
.welcome-popup.show .welcome-sheet { transform: translateY(0); }
.welcome-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 12px; }
.welcome-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
}
.welcome-content { text-align: center; }
.welcome-content h3 { margin: 8px 0 4px; font-size: 1.2rem; }
.welcome-content p { color: var(--text-light); font-size: 0.9rem; margin-bottom: 8px; }

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1000;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255,255,255,0.94);
  transition: background 0.3s;
  padding: 0 4px;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 8px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.55rem;
  font-weight: 500;
  transition: 0.3s;
  cursor: pointer;
  text-decoration: none;
  min-width: 48px;
}
.nav-item i { font-size: 1.2rem; transition: 0.3s; }
.nav-item span { font-size: 0.5rem; letter-spacing: 0.3px; }
.nav-item:hover { color: var(--text-light); }
.nav-item.active { color: var(--primary); }
.nav-item.active i { transform: scale(1.05); }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: 20px;
}
.footer .container { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-links a { color: var(--text-light); font-size: 0.85rem; transition: 0.3s; text-decoration: none; }
.footer-links a:hover { color: var(--primary); }
.footer-copy { font-size: 0.75rem; color: var(--text-muted); }

/* ============================================================
   DARK MODE
   ============================================================ */
body.dark .top-header { background: rgba(15,15,15,0.94); border-color: var(--border); }
body.dark .bottom-nav { background: rgba(15,15,15,0.94); border-color: var(--border); }
body.dark .user-dropdown { background: var(--bg); border-color: var(--border); }
body.dark .banner-slide { background: linear-gradient(135deg, #0d47a1, #1a73e8) !important; }
body.dark .doc-icon-wrapper .doc-icon { opacity: 0.7; }
body.dark .category-card { background: var(--bg-alt); border-color: var(--border); }
body.dark .category-card:hover { background: var(--bg); border-color: var(--primary); }
body.dark .ad-banner { background: var(--bg-card); border-color: var(--border); }
body.dark .welcome-sheet { background: var(--bg); }
body.dark .welcome-backdrop { background: rgba(0,0,0,0.7); }
body.dark .sidebar { background: var(--bg); border-color: var(--border); }
body.dark .theme-option-inline.active { background: var(--bg-card); border-color: var(--primary); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --header-height: 54px; --bottom-nav-height: 58px; }
  .sidebar { width: 290px; left: -290px; }
  .banner-slide { padding: 16px 18px; min-height: 80px; border-radius: var(--radius-sm); }
  .banner-content h2 { font-size: 1rem; }
  .banner-content p { font-size: 0.75rem; margin-bottom: 6px; }
  .banner-icon { font-size: 2.2rem; }
  .doc-item { flex: 0 0 140px; max-width: 160px; }
  .doc-icon-wrapper { aspect-ratio: 1 / 1.1; }
  .doc-meta h3 { font-size: 0.75rem; }
  .doc-meta .author { font-size: 0.6rem; }
  .doc-meta .rating { font-size: 0.6rem; }
  .ad-banner { min-height: 100px; }
  .ad-banner .ad-placeholder i { font-size: 2rem; }
  .category-card { padding: 12px 8px; }
  .category-card i { font-size: 1.4rem; }
  .category-card h4 { font-size: 0.75rem; }
  .user-name { display: none; }
  .nav-item { min-width: 40px; padding: 2px 4px; }
  .nav-item i { font-size: 1rem; }
  .nav-item span { font-size: 0.45rem; }
  .shimmer-item { flex: 0 0 140px; max-width: 160px; }
  .shimmer-icon { aspect-ratio: 1 / 1.1; }
  .home-tab-btn { font-size: 0.75rem; padding: 6px 12px; }
  .home-tab-nav { top: var(--header-height); padding-top: 2px; }
  .categories-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .welcome-sheet { padding: 12px 16px 24px; max-width: 100%; border-radius: 16px 16px 0 0; }
  .theme-inline { flex-direction: column; }
  .theme-option-inline { flex: none; width: 100%; }
  .sidebar-user-info { flex-wrap: wrap; }
  .sidebar-user-dropdown-toggle { margin-left: auto; }
}

@media (max-width: 480px) {
  .banner-slide { padding: 12px 14px; min-height: 70px; }
  .banner-content h2 { font-size: 0.85rem; }
  .banner-content p { font-size: 0.65rem; margin-bottom: 4px; }
  .banner-icon { font-size: 1.8rem; }
  .doc-item { flex: 0 0 110px; max-width: 130px; }
  .doc-icon-wrapper { aspect-ratio: 1 / 1; }
  .doc-meta h3 { font-size: 0.65rem; }
  .doc-meta .author { font-size: 0.55rem; }
  .doc-meta .rating { font-size: 0.55rem; }
  .ad-banner { min-height: 80px; }
  .ad-banner .ad-placeholder i { font-size: 1.6rem; }
  .category-card { padding: 10px 6px; }
  .category-card i { font-size: 1.2rem; }
  .category-card h4 { font-size: 0.65rem; }
  .shimmer-item { flex: 0 0 110px; max-width: 130px; }
  .shimmer-icon { aspect-ratio: 1 / 1; }
  .home-tab-btn { font-size: 0.65rem; padding: 4px 8px; }
  .categories-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}