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

:root {
  /* shadcn dark palette */
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 217.2 32.6% 9%;
  --card-foreground: 210 40% 98%;
  --primary: 217.2 91.2% 59.8%;
  --primary-foreground: 222.2 47.4% 11.2%;
  --secondary: 217.2 32.6% 17.5%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 65.1%;
  --border: 217.2 32.6% 17.5%;
  --input: 217.2 32.6% 17.5%;
  --ring: 224.3 76.3% 48%;
  --destructive: 0 62.8% 30.6%;
  --radius: 0.5rem;

  /* semantic aliases (used in JS-generated HTML) */
  --bg:        hsl(var(--background));
  --surface:   hsl(var(--card));
  --text:      hsl(var(--foreground));
  --muted-color: hsl(var(--muted-foreground));
  --accent:    hsl(var(--primary));
  --accent-hover: hsl(217.2 91.2% 50%);
  --border-color: hsl(var(--border));
  --gray-bg:   hsl(217.2 32.6% 13%);
  --shadow:    0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);

  /* status colors — dark-friendly */
  --green:    hsl(142 71% 45%);
  --green-bg: hsl(142 71% 10%);
  --red:      hsl(0 72% 60%);
  --red-bg:   hsl(0 72% 12%);
  --amber:    hsl(38 92% 55%);
  --amber-bg: hsl(38 92% 10%);
  --blue:     hsl(217 91% 65%);
  --blue-bg:  hsl(217 91% 12%);
}

/* ── reset shorthand vars for components that use old names ── */
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
header {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
header h1 { font-size: 1.1rem; font-weight: 700; color: hsl(var(--foreground)); }
header p  { font-size: 0.85rem; color: hsl(var(--muted-foreground)); }
.logo { font-size: 1.5rem; }

/* ── Layout ── */
main { max-width: 860px; margin: 0 auto; padding: 2rem 1.25rem; }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid hsl(var(--border)); margin-bottom: 2rem; }
.tab-btn {
  padding: 0.6rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.9rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: hsl(var(--foreground)); }
.tab-btn.active { color: hsl(var(--primary)); border-bottom-color: hsl(var(--primary)); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Forms ── */
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: hsl(var(--foreground)); }
input[type="text"], input[type="email"], textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: hsl(var(--input));
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]::placeholder,
input[type="email"]::placeholder,
textarea::placeholder { color: hsl(var(--muted-foreground)); }
input[type="text"]:focus, input[type="email"]:focus, textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / .2);
}
textarea { resize: vertical; min-height: 120px; font-family: inherit; }

.field { margin-bottom: 1.25rem; }
.field-row { display: flex; gap: 0.75rem; }
.field-row .field { flex: 1; margin-bottom: 0; }

/* ── Buttons ── */
button.primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
button.primary:hover { opacity: .9; }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }

button.copy-btn {
  padding: 0.35rem 0.75rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  transition: background .15s;
}
button.copy-btn:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }

/* ── Cards ── */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 2px);
  padding: 1.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
  margin-bottom: 1.25rem;
}

/* ── API key display ── */
.key-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.55rem 0.75rem;
  margin-top: 1rem;
}
.key-box code {
  flex: 1;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 0.85rem;
  word-break: break-all;
  color: hsl(var(--primary));
}

/* ── Status badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-valid   { background: var(--green-bg); color: var(--green); }
.badge-invalid { background: var(--red-bg);   color: var(--red); }
.badge-risky   { background: var(--amber-bg); color: var(--amber); }
.badge-free    { background: var(--blue-bg);  color: var(--blue); }
.badge-role    { background: var(--amber-bg); color: var(--amber); }

/* ── Results table ── */
.results-wrap { overflow-x: auto; margin-top: 1.5rem; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--muted));
  border-bottom: 2px solid hsl(var(--border));
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}
td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
  color: hsl(var(--foreground));
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: hsl(var(--muted) / .4); }
.email-cell { font-family: monospace; font-size: 0.82rem; }
.suggestion { font-size: 0.78rem; color: hsl(var(--muted-foreground)); margin-top: 0.15rem; }
.check-list { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* ── Hint / note ── */
.hint {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.35rem;
}
.hint a { color: hsl(var(--primary)); text-decoration: none; }
.hint a:hover { text-decoration: underline; }

/* ── Docs ── */
.docs h2 { font-size: 1rem; font-weight: 700; margin: 1.5rem 0 0.75rem; color: hsl(var(--foreground)); }
.docs h3 { font-size: 0.9rem; font-weight: 700; margin: 1.25rem 0 0.5rem; color: hsl(var(--muted-foreground)); }
.docs p  { font-size: 0.875rem; margin-bottom: 0.75rem; color: hsl(var(--muted-foreground)); }
pre {
  background: hsl(222.2 47.4% 7%);
  color: hsl(210 40% 88%);
  border: 1px solid hsl(var(--border));
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  overflow-x: auto;
  margin: 0.5rem 0 1rem;
  line-height: 1.6;
}
code { font-family: 'Menlo', 'Consolas', monospace; color: hsl(var(--primary)); }
pre code { color: inherit; }
.endpoint-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.4rem;
  font-family: monospace;
}
.method-get  { background: var(--green-bg);  color: var(--green); }
.method-post { background: var(--blue-bg);   color: var(--blue); }

/* ── Alert messages ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-top: 1rem;
  border: 1px solid transparent;
}
.alert-error   { background: var(--red-bg);   color: var(--red);   border-color: hsl(0 62.8% 20%); }
.alert-success { background: var(--green-bg); color: var(--green); border-color: hsl(142 71% 15%); }
.alert-info    { background: var(--blue-bg);  color: var(--blue);  border-color: hsl(217 91% 18%); }

/* ── Loader ── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 600px) {
  .field-row { flex-direction: column; }
  main { padding: 1.25rem 1rem; }
}
