/* ============================================
   AIHub - AI Tools Aggregation Platform
   Professional Design System
   ============================================ */

/* ===== CSS Variables ===== */
:root {
  /* Colors - Light Theme */
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f3f9;
  --bg-hover: #eef1f7;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border-color: #e5e7eb;
  --border-light: #f0f1f5;

  /* Brand */
  --brand-primary: #6366f1;
  --brand-secondary: #8b5cf6;
  --brand-accent: #ec4899;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --brand-gradient-soft: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-xl: 0 16px 50px rgba(0,0,0,0.12);
  --shadow-brand: 0 8px 30px rgba(99,102,241,0.25);

  /* Layout */
  --container-max: 1200px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #22223a;
  --bg-hover: #2a2a44;
  --text-primary: #f1f3f9;
  --text-secondary: #a1a8b8;
  --text-tertiary: #6b7280;
  --border-color: #2d2d44;
  --border-light: #22223a;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --shadow-xl: 0 16px 50px rgba(0,0,0,0.5);
  --shadow-brand: 0 8px 30px rgba(99,102,241,0.35);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { max-width: 100%; display: block; }

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

.hide-mobile { display: inline; }

/* ===== Navbar ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

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

.navbar.scrolled {
  border-bottom-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 24px;
  filter: drop-shadow(0 2px 8px rgba(99,102,241,0.4));
}

.logo-accent {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  gap: 8px;
  margin-left: auto;
  margin-right: 24px;
}

.nav-link {
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--brand-gradient-soft);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 35px rgba(99,102,241,0.35);
}

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

.nav-cta {
  padding: 9px 18px;
  font-size: 14px;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  padding: 140px 24px 80px;
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}

.glow-1 {
  width: 500px; height: 500px;
  background: #6366f1;
  top: -100px; left: -100px;
  animation: float1 12s ease-in-out infinite;
}

.glow-2 {
  width: 400px; height: 400px;
  background: #ec4899;
  top: 50px; right: -80px;
  animation: float2 15s ease-in-out infinite;
}

.glow-3 {
  width: 350px; height: 350px;
  background: #8b5cf6;
  bottom: -50px; left: 40%;
  animation: float3 18s ease-in-out infinite;
}

@keyframes float1 {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(40px,30px); }
}
@keyframes float2 {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(-30px,40px); }
}
@keyframes float3 {
  0%,100% { transform: translate(0,0); }
  50% { transform: translate(20px,-30px); }
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand-primary);
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 100px;
  margin-bottom: 24px;
}

[data-theme="dark"] .hero-badge {
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
}

.badge-dot {
  width: 8px; height: 8px;
  background: var(--brand-primary);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.hero-title {
  font-size: 52px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -2px;
  margin-bottom: 20px;
}

.gradient-text {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 40px;
}

/* ===== Search ===== */
.search-wrapper {
  max-width: 560px;
  margin: 0 auto;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-md);
}

.search-box:focus-within {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-brand);
}

.search-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  padding: 14px 12px;
  font-size: 16px;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.search-clear {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: var(--transition-fast);
}

.search-clear.visible {
  opacity: 1;
}

.search-clear:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.hint-tag {
  padding: 4px 12px;
  font-size: 13px;
  color: var(--brand-primary);
  background: rgba(99,102,241,0.08);
  border-radius: 100px;
  transition: var(--transition-fast);
}

.hint-tag:hover {
  background: rgba(99,102,241,0.15);
}

/* ===== Stats Bar ===== */
.stats-bar {
  padding: 40px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.stats-container {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-number {
  font-size: 36px;
  font-weight: 800;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}

.stat-suffix {
  font-size: 20px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border-color);
}

/* ===== Section Headers ===== */
.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-tag {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--brand-primary);
  margin-bottom: 12px;
}

.section-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 12px;
}

.section-desc {
  font-size: 16px;
  color: var(--text-secondary);
}

/* ===== Categories Section ===== */
.categories-section {
  padding: 80px 0;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.category-card {
  position: relative;
  padding: 28px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: var(--transition);
  cursor: pointer;
  overflow: hidden;
}

.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--cat-color, var(--brand-primary));
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: var(--radius-lg);
}

.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--cat-color, var(--brand-primary));
}

.category-card:hover::before {
  opacity: 0.05;
}

.category-icon {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--cat-bg, rgba(99,102,241,0.1));
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.category-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}

.category-count {
  font-size: 14px;
  color: var(--text-tertiary);
  position: relative;
  z-index: 1;
}

/* ===== Tools Section ===== */
.tools-section {
  padding: 60px 0 100px;
  background: var(--bg-primary);
}

/* Filter Bar */
.filter-bar {
  position: sticky;
  top: 68px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 7px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.filter-pill:hover {
  color: var(--text-primary);
  border-color: var(--brand-primary);
}

.filter-pill.active {
  color: #fff;
  background: var(--brand-gradient-soft);
  border-color: transparent;
  box-shadow: var(--shadow-brand);
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pricing-filter {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  padding: 3px;
}

.pricing-pill {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 100px;
  transition: var(--transition-fast);
}

.pricing-pill:hover {
  color: var(--text-primary);
}

.pricing-pill.active {
  background: var(--brand-primary);
  color: #fff;
}

.sort-select select {
  padding: 8px 32px 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  font-family: inherit;
}

/* Results Info */
.results-info {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 20px;
  padding-left: 4px;
}

/* Tools Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Tool Card */
.tool-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tool-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}

.tool-card:hover::after {
  opacity: 1;
}

.tool-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.tool-logo {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  transition: var(--transition);
}

.tool-card:hover .tool-logo {
  transform: scale(1.05);
}

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

.tool-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hot-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  color: #fff;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.affiliate-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  border-radius: 4px;
  letter-spacing: 0.3px;
  cursor: help;
}

.affiliate-info-card {
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(249,115,22,0.06));
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}

.affiliate-info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.affiliate-info-icon {
  font-size: 18px;
}

.affiliate-info-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.affiliate-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.affiliate-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.affiliate-info-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.affiliate-info-value {
  font-size: 14px;
  font-weight: 600;
  color: #f59e0b;
}

.affiliate-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(239,68,68,0.08);
  border-radius: 6px;
}

.affiliate-disclosure {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: 8px;
  opacity: 0.7;
}

.modal-visit.has-affiliate {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

.tool-vendor {
  font-size: 13px;
  color: var(--text-tertiary);
}

.tool-description {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.tool-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tool-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tool-tag {
  font-size: 12px;
  font-weight: 500;
  padding: 3px 10px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 100px;
}

.tool-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tool-rating {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tool-rating .star {
  color: #f59e0b;
  font-size: 14px;
}

.pricing-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
}

.pricing-badge.free { background: rgba(16,185,129,0.12); color: #059669; }
.pricing-badge.freemium { background: rgba(245,158,11,0.12); color: #d97706; }
.pricing-badge.paid { background: rgba(239,68,68,0.12); color: #dc2626; }

[data-theme="dark"] .pricing-badge.free { color: #34d399; }
[data-theme="dark"] .pricing-badge.freemium { color: #fbbf24; }
[data-theme="dark"] .pricing-badge.paid { color: #f87171; }

/* No Results */
.no-results {
  text-align: center;
  padding: 80px 20px;
}

.no-results-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.no-results h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.no-results p {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ===== About Section ===== */
.about-section {
  padding: 80px 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
}

.about-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 60px;
  align-items: center;
}

.feature-list {
  margin-top: 32px;
}

.feature-item {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-light);
}

.feature-item:last-child {
  border-bottom: none;
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.feature-item h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.feature-item p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.about-visual {
  display: flex;
  justify-content: center;
}

.visual-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.visual-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.visual-row:last-child {
  border-bottom: none;
}

.visual-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}

.visual-row span:nth-child(2) {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.visual-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-tertiary);
}

/* ===== Footer ===== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  padding: 60px 0 30px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
}

.footer-tagline {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.footer-links {
  display: flex;
  gap: 60px;
}

.footer-col h5 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 0;
  transition: var(--transition-fast);
}

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

.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(0.97);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal::-webkit-scrollbar {
  width: 6px;
}

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

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

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

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

.modal-body {
  padding: 32px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-logo {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.modal-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.modal-vendor {
  font-size: 14px;
  color: var(--text-tertiary);
}

.modal-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.modal-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.modal-badge.rating { background: rgba(245,158,11,0.12); color: #d97706; }
.modal-badge.category { background: rgba(99,102,241,0.12); color: var(--brand-primary); }

[data-theme="dark"] .modal-badge.rating { color: #fbbf24; }
[data-theme="dark"] .modal-badge.category { color: #a5b4fc; }

.modal-description {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.modal-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.modal-feature {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.modal-feature::before {
  content: '✓';
  color: var(--brand-primary);
  font-weight: 700;
}

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

.modal-visit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--brand-gradient-soft);
  border-radius: var(--radius-md);
  transition: var(--transition);
  box-shadow: var(--shadow-brand);
}

.modal-visit:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 35px rgba(99,102,241,0.35);
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 100;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--brand-gradient-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-brand);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: var(--transition);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  transform: translateY(-3px);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-card {
  animation: fadeInUp 0.4s ease-out backwards;
}

.tool-card:nth-child(1) { animation-delay: 0.02s; }
.tool-card:nth-child(2) { animation-delay: 0.04s; }
.tool-card:nth-child(3) { animation-delay: 0.06s; }
.tool-card:nth-child(4) { animation-delay: 0.08s; }
.tool-card:nth-child(5) { animation-delay: 0.10s; }
.tool-card:nth-child(6) { animation-delay: 0.12s; }
.tool-card:nth-child(7) { animation-delay: 0.14s; }
.tool-card:nth-child(8) { animation-delay: 0.16s; }
.tool-card:nth-child(9) { animation-delay: 0.18s; }

/* ============================================
   PC Sidebar Layout (Desktop >= 1024px)
   ============================================ */
.pc-sidebar {
  display: none;
}

.pc-topbar {
  display: none;
}

.app-header {
  display: none;
}

.app-tabbar {
  display: none;
}

.app-page {
  display: none;
}

.app-page.active {
  display: block;
}

/* ===== PC Layout (Desktop) ===== */
@media (min-width: 1024px) {
  .pc-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    padding: 24px 16px;
  }

  .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 32px;
    padding: 0 12px;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 28px;
  }

  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
  }

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

  .sidebar-link.active {
    background: rgba(99,102,241,0.1);
    color: var(--brand-primary);
    font-weight: 600;
  }

  .sidebar-section {
    margin-bottom: auto;
  }

  .sidebar-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    padding: 0 14px;
    margin-bottom: 8px;
  }

  .sidebar-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    width: 100%;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    text-align: left;
  }

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

  .sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
  }

  .sidebar-theme {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    width: 100%;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
  }

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

  .sidebar-theme-label {
    font-size: 14px;
  }

  .sidebar-version {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: center;
    margin-top: 12px;
  }

  /* PC Topbar */
  .pc-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 32px;
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
  }

  [data-theme="dark"] .pc-topbar {
    background: rgba(15,15,26,0.85);
  }

  .pc-topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 500px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
  }

  .pc-topbar-search:focus-within {
    border-color: var(--brand-primary);
    box-shadow: var(--shadow-brand);
  }

  .pc-topbar-search input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 15px;
    color: var(--text-primary);
    font-family: inherit;
  }

  .pc-topbar-search input::placeholder {
    color: var(--text-tertiary);
  }

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

  .pc-topbar-hint {
    font-size: 13px;
    color: var(--text-tertiary);
  }

  /* Main wrapper shifted for sidebar */
  .main-wrapper {
    margin-left: 260px;
  }

  /* Hide mobile-only elements */
  .app-header,
  .app-tabbar,
  .app-search,
  .app-page:not(#page-home),
  .app-about,
  .app-footer {
    display: none !important;
  }

  /* Show only home page content on PC */
  #page-home {
    display: block !important;
  }

  /* PC wider grid */
  .tools-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .category-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* PC hero adjustments */
  .hero {
    padding: 80px 32px 60px;
  }

  .hero-title {
    font-size: 48px;
  }

  /* Sticky filter bar accounts for topbar */
  .filter-bar {
    top: 73px;
  }

  .container {
    max-width: 1400px;
  }
}

/* ===== APP Layout (Mobile < 1024px) ===== */
@media (max-width: 1023px) {
  /* Hide PC elements */
  .pc-sidebar,
  .pc-topbar {
    display: none !important;
  }

  .main-wrapper {
    margin-left: 0;
  }

  /* App Header */
  .app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-light);
  }

  [data-theme="dark"] .app-header {
    background: rgba(15,15,26,0.9);
  }

  .app-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 800;
  }

  .app-header-title {
    font-size: 20px;
  }

  .app-header-right {
    display: flex;
    gap: 8px;
  }

  .app-header-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
  }

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

  /* App Main */
  .app-main {
    min-height: calc(100vh - 130px);
    padding-bottom: 80px;
  }

  /* App pages */
  .app-page {
    display: none;
  }

  .app-page.active {
    display: block;
    animation: fadeInUp 0.3s ease-out;
  }

  /* Hide home page hero search on mobile (use search tab instead) */
  .app-search {
    display: block;
  }

  /* App page headers */
  .app-page-header {
    padding: 24px 20px 16px;
  }

  .app-page-header h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
  }

  .app-page-header p {
    font-size: 14px;
    color: var(--text-secondary);
  }

  /* App category grid */
  .app-category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 0 20px 40px;
  }

  /* App search */
  .app-search-full {
    max-width: 100%;
    padding: 0 20px;
  }

  .search-tags-popular {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
    align-items: center;
  }

  .search-tags-label {
    font-size: 13px;
    color: var(--text-tertiary);
  }

  .app-search-grid {
    grid-template-columns: 1fr;
    margin-top: 20px;
  }

  /* App profile */
  .app-about {
    padding: 0;
    background: var(--bg-primary);
    border: none;
  }

  .app-about-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .app-profile-actions {
    display: flex;
    gap: 12px;
    padding: 0 20px 32px;
  }

  .app-profile-btn {
    flex: 1;
    padding: 14px;
    font-size: 15px;
  }

  .app-profile-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    box-shadow: none;
  }

  .app-footer {
    padding: 30px 0;
  }

  .app-version-text {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
  }

  /* App Bottom Tab Bar */
  .app-tabbar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 900;
    height: 64px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-light);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  [data-theme="dark"] .app-tabbar {
    background: rgba(15,15,26,0.95);
  }

  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    height: 100%;
    color: var(--text-tertiary);
    transition: var(--transition-fast);
    position: relative;
  }

  .tab-item.active {
    color: var(--brand-primary);
  }

  .tab-item span {
    font-size: 10px;
    font-weight: 600;
  }

  .tab-item-center {
    position: relative;
  }

  .tab-center-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--brand-gradient-soft);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(99,102,241,0.4);
    margin-top: -20px;
    transition: var(--transition);
  }

  .tab-center-btn:hover {
    transform: scale(1.08);
  }

  /* Mobile tool grid */
  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  /* Mobile hero */
  .hero {
    padding: 24px 20px 40px;
  }

  .hero-title {
    font-size: 32px;
  }

  .hero-subtitle {
    font-size: 15px;
  }

  .hero-badge {
    font-size: 12px;
  }

  /* Mobile filter bar */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    top: 57px;
  }

  .filter-pills {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .filter-pill {
    flex-shrink: 0;
  }

  .filter-controls {
    flex-wrap: wrap;
  }

  .pricing-filter {
    flex: 1;
  }

  .sort-select {
    flex: 1;
  }

  .sort-select select {
    width: 100%;
  }

  /* Mobile stats */
  .stats-container {
    flex-wrap: wrap;
    gap: 16px;
  }

  .stat-divider {
    display: none;
  }

  .stat-number {
    font-size: 26px;
  }

  /* Mobile about */
  .about-grid {
    grid-template-columns: 1fr;
  }

  /* Mobile modal */
  .modal {
    max-height: 90vh;
  }

  .modal-body {
    padding: 24px 20px;
  }

  .modal-header {
    flex-direction: column;
    gap: 12px;
  }

  /* Mobile back-to-top */
  .back-to-top {
    bottom: 80px;
    right: 16px;
  }

  /* Mobile chat widget */
  .chat-widget {
    bottom: 76px;
    right: 16px;
  }

  .chat-panel {
    width: calc(100vw - 32px);
    height: 420px;
  }

  .chat-fab {
    width: 48px;
    height: 48px;
  }

  /* Mobile submit */
  .submit-modal {
    max-width: 100%;
  }

  .submit-body {
    padding: 24px 20px;
  }

  .form-row-2 {
    flex-direction: column;
  }

  .container {
    padding: 0 20px;
  }

  .section-title {
    font-size: 26px;
  }

  .categories-section {
    padding: 40px 0;
  }
}

/* ===== Small Mobile (< 480px) ===== */
@media (max-width: 480px) {
  .hero-title {
    font-size: 26px;
  }

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

  .category-grid,
  .app-category-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 16px;
  }

  .tool-card {
    padding: 18px;
  }

  .tool-logo {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .tool-name {
    font-size: 15px;
  }
}

/* ============================================
   Customer Service Chat Widget
   ============================================ */
.chat-widget {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 1500;
}

/* FAB Button */
.chat-fab {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--brand-gradient-soft);
  border-radius: 50%;
  box-shadow: 0 8px 30px rgba(99,102,241,0.4);
  transition: var(--transition);
}

.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(99,102,241,0.5);
}

.chat-fab-icon { display: block; }
.chat-fab-close { display: none; }
.chat-widget.open .chat-fab-icon { display: none; }
.chat-widget.open .chat-fab-close { display: block; }

.chat-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  border-radius: 100px;
  border: 2px solid var(--bg-primary);
}

.chat-fab-badge:empty { display: none; }

/* Chat Panel */
.chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: var(--transition);
  overflow: hidden;
}

.chat-widget.open .chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--brand-gradient-soft);
  color: #fff;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-title {
  font-size: 16px;
  font-weight: 700;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.chat-minimize {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  opacity: 0.8;
}

.chat-minimize:hover {
  background: rgba(255,255,255,0.2);
  opacity: 1;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 100px; }

.chat-msg {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: chatMsgIn 0.3s ease-out;
}

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

.chat-msg.bot {
  align-self: flex-start;
}

.chat-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: var(--radius-md);
  word-break: break-word;
}

.chat-msg.bot .chat-msg-bubble {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
  background: var(--brand-gradient-soft);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-time {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 0 4px;
}

/* Typing Indicator */
.chat-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
}

.chat-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick Replies */
.chat-quick-replies {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
  border-top: 1px solid var(--border-light);
}

.quick-reply {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-primary);
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 100px;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.quick-reply:hover {
  background: rgba(99,102,241,0.15);
  border-color: var(--brand-primary);
}

/* Chat Input */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--transition-fast);
}

.chat-input:focus {
  border-color: var(--brand-primary);
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-send {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--brand-gradient-soft);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.chat-send:hover {
  transform: scale(1.05);
}

/* Adjust back-to-top to not overlap chat */
.back-to-top {
  bottom: 96px;
}

/* ============================================
   Submit Tool Modal
   ============================================ */
.submit-modal {
  max-width: 600px;
}

.submit-body {
  padding: 32px;
}

/* Tabs */
.submit-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 4px;
}

.submit-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.submit-tab.active {
  background: var(--bg-secondary);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.submit-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--brand-primary);
  border-radius: 100px;
}

.submit-count:empty,
.submit-count[data-count="0"] {
  display: none;
}

/* Panes */
.submit-pane {
  display: none;
}

.submit-pane.active {
  display: block;
  animation: fadeInUp 0.3s ease-out;
}

.submit-intro {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Form */
.submit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row-2 {
  flex-direction: row;
  gap: 16px;
}

.form-row-2 > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.req {
  color: #ef4444;
}

.form-input {
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  transition: var(--transition-fast);
}

.form-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-textarea {
  resize: vertical;
  min-height: 70px;
}

.submit-btn {
  margin-top: 8px;
  padding: 12px 24px;
  font-size: 15px;
  align-self: stretch;
}

/* Success */
.submit-success {
  text-align: center;
  padding: 40px 20px;
}

.success-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.submit-success h3 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.submit-success p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* Submissions List */
.submit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.submit-list::-webkit-scrollbar { width: 4px; }
.submit-list::-webkit-scrollbar-track { background: transparent; }
.submit-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 100px; }

.submit-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.submit-item:hover {
  border-color: var(--border-color);
}

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

.submit-item-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.submit-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.submit-item-meta {
  font-size: 12px;
  color: var(--text-tertiary);
}

.submit-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.submit-status.pending {
  background: rgba(245,158,11,0.12);
  color: #d97706;
}

.submit-status.approved {
  background: rgba(16,185,129,0.12);
  color: #059669;
}

.submit-status.rejected {
  background: rgba(239,68,68,0.12);
  color: #dc2626;
}

[data-theme="dark"] .submit-status.pending { color: #fbbf24; }
[data-theme="dark"] .submit-status.approved { color: #34d399; }
[data-theme="dark"] .submit-status.rejected { color: #f87171; }

.submit-empty {
  text-align: center;
  padding: 60px 20px;
}

.submit-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.submit-empty p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Responsive for chat */
@media (max-width: 768px) {
  .chat-widget { bottom: 20px; right: 20px; }
  .chat-panel {
    width: calc(100vw - 40px);
    height: 450px;
  }
  .back-to-top { bottom: 84px; right: 20px; }
  .submit-modal { max-width: 100%; }
  .submit-body { padding: 24px 20px; }
  .form-row-2 { flex-direction: column; }
}
