:root {
  --bg: #14171C;
  --surface: #1C2129;
  --surface-raised: #232936;
  --line: #2C333F;
  --amber: #E8A33D;
  --amber-dim: #8C6A2E;
  --teal: #4FA6A6;
  --text: #E7E5DF;
  --muted: #8A8F98;
  --danger: #C9634A;
  --radius: 10px;
  --font-display: "Fraunces", serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-bottom: 76px;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
  background-color: var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at top, rgba(20,23,28,0) 0%, var(--bg) 72%);
  pointer-events: none;
  z-index: 0;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }

/* Topbar */
.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(232,163,61,0.18);
}
.brand h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.01em;
  margin: 0;
}
.brand-accent { color: var(--amber); font-weight: 500; }
.topbar-meta { font-size: 13px; }

/* Search panel */
.search-panel {
  position: relative;
  z-index: 1;
  margin: 4px 16px 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.field input, .field select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
}
.field input:focus, .field select:focus {
  border-color: var(--amber);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; margin-bottom: 14px; }

.scan-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 4px;
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: var(--amber);
  color: #14171C;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.scan-btn:active { transform: translateY(1px); }
.scan-sweep {
  position: absolute;
  top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: skewX(-20deg);
  display: none;
}
.scan-btn.scanning .scan-sweep {
  display: block;
  animation: sweep 1.1s linear infinite;
}
@keyframes sweep {
  0% { left: -40%; }
  100% { left: 100%; }
}
.scan-label { position: relative; }

/* Status */
.status-area {
  position: relative; z-index: 1;
  margin: 0 16px 12px;
  font-size: 14px;
  color: var(--muted);
  min-height: 0;
}
.status-area.error { color: var(--danger); }

/* Results */
.results {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px;
}

.ad-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.ad-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.ad-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-raised);
  object-fit: cover;
  flex-shrink: 0;
}
.ad-page {
  margin: 0;
  font-weight: 600;
  font-size: 14.5px;
}
.ad-domain { margin: 2px 0 0; font-size: 12px; }
.ad-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(79,166,166,0.14);
  color: var(--teal);
  white-space: nowrap;
}
.ad-copy {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ad-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  margin-bottom: 14px;
}
.ad-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ad-action {
  flex: 1;
  min-width: 100px;
  text-align: center;
  padding: 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-raised);
  cursor: pointer;
  font-family: var(--font-body);
}
.ad-action-primary {
  background: var(--amber);
  color: #14171C;
  border-color: var(--amber);
  font-weight: 600;
}
.ad-action-fav[aria-pressed="true"] {
  background: rgba(232,163,61,0.16);
  border-color: var(--amber-dim);
  color: var(--amber);
}

/* Tabbar */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 8px;
  cursor: pointer;
}
.tab.active { color: var(--amber); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}
