:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #22223a;
  --text-primary: #e8e8f0;
  --text-secondary: #9090a8;
  --text-muted: #606080;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sponsored: #f59e0b;
  --border: #1e1e32;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

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

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header / Nav */
.nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 16px;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  max-width: 1200px;
  margin: 0 auto;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.nav-brand img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-links a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

/* Hero / Search */
.hero {
  padding: 60px 16px 40px;
  text-align: center;
}

.hero-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 16px;
  box-shadow: 0 0 40px var(--accent-glow);
}

.hero h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.search-box {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 14px 48px 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.search-box button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

.search-box button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Search results */
.search-header {
  margin-bottom: 20px;
}

.search-header form {
  display: flex;
  gap: 8px;
  max-width: 560px;
  margin-bottom: 12px;
}

.search-header input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

.search-header input:focus {
  border-color: var(--accent);
}

.search-header button {
  background: var(--accent);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.search-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 3px;
  width: fit-content;
}

.search-tabs a {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.search-tabs a.active {
  background: var(--accent);
  color: white;
}

/* Image strip */
.image-strip {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.image-strip::-webkit-scrollbar {
  display: none;
}

.image-strip-item {
  flex: 0 0 auto;
  width: 180px;
  height: 130px;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  transition: transform 0.3s;
}

.image-strip-item:hover {
  transform: scale(1.03);
}

.image-strip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-strip-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  color: white;
  padding: 20px 6px 6px;
  font-size: 0.75rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Result cards */
.result {
  padding: 14px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border-radius: var(--radius);
  transition: all 0.2s;
  overflow-wrap: break-word;
  word-wrap: break-word;
  min-width: 0;
}

.result:hover {
  background: var(--bg-card-hover);
}

.result.sponsored {
  border-left: 3px solid var(--sponsored);
}

.result-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--sponsored);
  margin-bottom: 2px;
}

.scam-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.report-emojis {
  cursor: pointer;
  font-size: 0.8rem;
  vertical-align: middle;
  user-select: none;
}
.report-emojis:hover {
  opacity: 0.7;
}

.result-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.result-title img {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 50%;
}

.result-link {
  font-size: 0.8rem;
  color: var(--accent);
  overflow-wrap: anywhere;
  word-break: break-all;
  display: block;
  margin-bottom: 2px;
}

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

.result-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.result-stats {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
}

@media (min-width: 640px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s;
  word-wrap: break-word;
}

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

/* Tags cloud */
.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 6px 14px;
  background: var(--bg-card);
  border-radius: 50px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
}

.tag:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tag-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Categories */
.categories-list {
  list-style: none;
  padding: 0;
}

.categories-list li {
  margin-bottom: 4px;
}

.categories-list a {
  display: block;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.categories-list a:hover {
  background: var(--accent);
  color: white;
}

/* Forms */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
  color: var(--text-muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

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

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

/* Popup modal */
.popup {
  background-color: rgba(0,0,0,0.7);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.popup-content {
  display: none;
  max-width: 500px;
  width: 90%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  position: relative;
  padding: 28px;
  margin: 16px;
  box-sizing: border-box;
  box-shadow: var(--shadow);
}

.popup-content .close {
  position: absolute;
  right: 12px;
  top: 12px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.popup-content .close:hover {
  opacity: 1;
}

.showPopup .popup {
  display: flex;
}

.showPopup .popup-content {
  display: block;
  animation: popupIn 0.3s forwards;
}

@keyframes popupIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 32px 16px;
  margin-top: 40px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.footer-inner .donate-address {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
}

.footer-inner .donate-icon {
  width: 32px;
  height: 32px;
  margin: 4px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 12px 0;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* Onion address */
.onion-addr {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
  text-align: center;
  padding: 8px;
}

/* Messages */
#message {
  margin-bottom: 12px;
}

/* Tables (admin) */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  background: var(--bg-card);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(124, 58, 237, 0.05);
}

/* Admin dashboard */
.admin-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (min-width: 768px) {
  .admin-layout {
    grid-template-columns: 220px 1fr;
  }
}

.admin-sidebar {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
}

.admin-sidebar a {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
  transition: all 0.2s;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
  background: var(--accent);
  color: white;
}

.admin-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 300px;
}

.admin-content h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}

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

/* Login box */
.login-box {
  max-width: 360px;
  margin: 60px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.login-box h2 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 1.3rem;
}

.login-box .user-box {
  position: relative;
  margin-bottom: 20px;
}

.login-box .user-box input {
  width: 100%;
  padding: 12px 0;
  font-size: 0.95rem;
  color: var(--text-primary);
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  background: transparent;
}

.login-box .user-box label {
  position: absolute;
  top: 12px;
  left: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: 0.3s;
}

.login-box .user-box input:focus ~ label,
.login-box .user-box input:valid ~ label {
  top: -12px;
  left: 0;
  color: var(--accent);
  font-size: 0.75rem;
}

.login-box .btn {
  width: 100%;
  margin-top: 24px;
}

/* Utility */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }

/* Responsive nav */
@media (max-width: 639px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px;
    gap: 2px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 12px;
    width: 100%;
  }

  .nav-toggle {
    display: block;
  }

  .hero {
    padding: 40px 16px 30px;
  }

  .hero h1 {
    font-size: 1.4rem;
  }

  .search-box input {
    padding: 12px 44px 12px 14px;
    font-size: 0.9rem;
  }

  .search-box button {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .image-strip-item {
    width: 140px;
    height: 100px;
  }

  .admin-sidebar {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 8px;
  }

  .admin-sidebar a {
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 8px 12px;
  }
}

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 20px 0;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color, #2a2a3e);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.2s, border-color 0.2s;
}
.page-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}
.page-btn.current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: default;
}
.page-info {
  margin-left: 8px;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* Stats page */
.stats-page {
  padding: 20px 0;
}
.stats-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-number {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stats-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.stats-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stat-bar-label {
  width: 90px;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
  min-width: 4px;
}
.stat-bar-count {
  width: 48px;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}
.stat-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 8px 0;
}
.top-links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.top-link-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.top-link-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-primary);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}
.top-link-info {
  flex: 1;
  min-width: 0;
}
.top-link-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-link-url {
  font-size: 0.75rem;
  color: var(--accent);
  overflow-wrap: anywhere;
  word-break: break-all;
}
.top-link-visits {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Print */
@media print {
  .nav, .footer { display: none; }
}
