:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --header-bg: #1e1b4b;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.07), 0 10px 30px rgba(0,0,0,.08);
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #162032;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --header-bg: #0f0d2a;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.2);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: background .2s, color .2s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* ── Header ── */
.site-header {
  background: var(--header-bg);
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}

.brand {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -.3px;
}

.brand:hover { color: #c7d2fe; }

.stats-badge {
  font-size: .75rem;
  color: rgba(255,255,255,.5);
}

.theme-toggle {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.theme-toggle:hover { background: rgba(255,255,255,.18); }

/* ── Hero ── */
.hero {
  background: var(--header-bg);
  padding: 3.5rem 0 5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0; right: 0;
  height: 60px;
  background: var(--bg);
  clip-path: ellipse(60% 100% at 50% 100%);
}

.hero-title {
  color: #fff;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  margin-bottom: .5rem;
  letter-spacing: -.5px;
}

.hero-sub {
  color: rgba(255,255,255,.6);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.search-form { position: relative; z-index: 1; }

.search-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: 14px;
  max-width: 640px;
  margin: 0 auto;
  padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow-lg);
  transition: border-color .2s, box-shadow .2s;
}

.search-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,.15), var(--shadow-lg);
}

.search-icon {
  color: var(--text-muted);
  font-size: 1rem;
  margin-right: 10px;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text);
  font-family: var(--font);
}

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

.search-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .5rem 1.2rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}

.search-btn:hover { background: var(--primary-hover); }
.search-btn:active { transform: scale(.97); }

.search-error {
  margin-top: 1rem;
  color: #fca5a5;
  font-size: .9rem;
  position: relative;
  z-index: 1;
}

/* ── Results ── */
.results-section { padding: 1.5rem 0 4rem; }

.result-summary {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.summary-query, .summary-ip, .summary-http {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.summary-query strong { font-size: 1.1rem; color: var(--primary); }
.summary-ip strong, .summary-http strong { font-size: .95rem; }

/* ── Grid ── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.card-full { grid-column: 1 / -1; }

@media (max-width: 680px) {
  .results-grid { grid-template-columns: 1fr; }
  .card-full { grid-column: 1; }
}

/* ── Result Card ── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s;
}

.result-card:hover { box-shadow: var(--shadow-lg); }

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.1rem;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background .15s, border-color .15s;
}

.card-header-row:hover { background: var(--surface-2); }
.card-header-row.open { border-bottom-color: var(--border); }

.card-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .9rem;
}

.card-icon { color: var(--primary); font-size: 1rem; }

.toggle-chevron {
  color: var(--text-muted);
  font-size: .75rem;
  transition: transform .2s;
}
.toggle-chevron.rotated { transform: rotate(180deg); }

.card-body-content {
  overflow: hidden;
  transition: max-height .3s ease, padding .3s;
  max-height: 2000px;
  padding: 1rem 1.1rem;
}

.card-body-content.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.card-loading {
  color: var(--text-muted);
  font-size: .875rem;
  padding: .5rem 0;
}

/* ── Status Badges ── */
.status-badge .badge { font-size: .72rem; }

.spinner-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

.loading-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--border);
  border-radius: 50%;
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── Tables ── */
.data-table {
  width: 100%;
  font-size: .85rem;
  border-collapse: collapse;
}

.data-table th {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: .4rem .6rem;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
  vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }

/* ── KV rows ── */
.kv-row {
  display: flex;
  gap: .5rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}

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

.kv-key {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 140px;
  flex-shrink: 0;
}

.kv-val { word-break: break-word; }

/* ── Record type badges ── */
.rec-type {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  padding: .15em .5em;
  border-radius: 4px;
  background: #e0e7ff;
  color: #3730a3;
}

[data-theme="dark"] .rec-type { background: #312e81; color: #a5b4fc; }

.rec-type.A     { background: #d1fae5; color: #065f46; }
.rec-type.AAAA  { background: #dbeafe; color: #1e40af; }
.rec-type.MX    { background: #fef3c7; color: #92400e; }
.rec-type.NS    { background: #f3e8ff; color: #6b21a8; }
.rec-type.TXT   { background: #fce7f3; color: #9d174d; }
.rec-type.SOA   { background: #f0fdf4; color: #14532d; }
.rec-type.CNAME { background: #fff7ed; color: #9a3412; }
.rec-type.SRV   { background: #f1f5f9; color: #475569; }
.rec-type.CAA   { background: #ecfdf5; color: #065f46; }

[data-theme="dark"] .rec-type.A     { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .rec-type.AAAA  { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .rec-type.MX    { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .rec-type.NS    { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .rec-type.TXT   { background: #500724; color: #fbcfe8; }
[data-theme="dark"] .rec-type.SOA   { background: #052e16; color: #86efac; }
[data-theme="dark"] .rec-type.CNAME { background: #431407; color: #fed7aa; }

/* ── Security headers ── */
.sec-header-row { display: flex; align-items: flex-start; gap: .5rem; padding: .3rem 0; font-size: .82rem; }
.sec-header-name { font-family: monospace; flex: 1; color: var(--text); }
.sec-header-val { font-family: monospace; font-size: .75rem; color: var(--text-muted); word-break: break-all; flex: 2; }
.sec-icon-ok { color: var(--success); }
.sec-icon-bad { color: var(--danger); }

/* ── Score ring ── */
.score-ring {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin-right: 1rem;
}
.score-num { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.score-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Propagation ── */
.prop-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.prop-dot.ok { background: var(--success); }
.prop-dot.fail { background: var(--danger); }
.prop-dot.err { background: var(--text-muted); }

/* ── Code blocks ── */
.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: .78rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  max-height: 320px;
  overflow-y: auto;
}

/* ── Screenshot ── */
.ss-img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ── SSL expiry coloring ── */
.days-ok { color: var(--success); font-weight: 600; }
.days-warn { color: var(--warning); font-weight: 600; }
.days-bad { color: var(--danger); font-weight: 600; }

/* ── Custom port input ── */
.port-custom-row {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.port-custom-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .75rem;
  font-size: .875rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.port-custom-row input:focus { border-color: var(--primary); }

.port-custom-row button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .4rem .9rem;
  font-size: .875rem;
  cursor: pointer;
  white-space: nowrap;
}

.port-custom-row button:hover { background: var(--primary-hover); }

/* ── Footer ── */
.site-footer-bar {
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  font-size: .82rem;
  color: var(--text-muted);
  background: var(--surface);
}

.site-footer-bar a { color: var(--primary); text-decoration: none; }
.site-footer-bar a:hover { text-decoration: underline; }

[data-theme="dark"] .site-footer-bar {
  background: #162032;
  border-top-color: #475569;
}

/* ── Geo flag ── */
.geo-flag { font-size: 1.4rem; margin-right: .3rem; }

/* ── Email provider badge ── */
.email-provider-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .75rem;
  padding: .55rem .75rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--ep-color) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ep-color) 25%, transparent);
  font-size: .82rem;
}

.ep-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ep-color);
  flex-shrink: 0;
}

.ep-label {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.ep-name {
  font-weight: 700;
  color: var(--ep-color);
}

.ep-via {
  font-size: .73rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Screenshot error ── */
.ss-error {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .25);
  border-radius: 8px;
  padding: .65rem .85rem;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.ss-error .bi { color: #ef4444; flex-shrink: 0; margin-top: .1rem; }

[data-theme="dark"] .ss-error {
  background: rgba(239, 68, 68, .12);
  border-color: rgba(239, 68, 68, .3);
}

/* ── Abuse score ── */
.abuse-bar-wrap { background: var(--border); border-radius: 4px; height: 8px; flex: 1; overflow: hidden; }
.abuse-bar { height: 100%; border-radius: 4px; transition: width .6s; }
