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

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #f1f5f9;
  min-height: 100vh;
}

/* ── Hero header ─────────────────────────────────────── */

.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
  color: #fff;
  padding: 40px 24px 36px;
}

.hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.hero-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
}

h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}

.tagline {
  margin: 0;
  color: #bfdbfe;
  font-size: 1rem;
  padding-left: 48px;
}

/* ── Main layout ─────────────────────────────────────── */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

/* ── Tool card ───────────────────────────────────────── */

.tool-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  padding: 28px;
  margin-bottom: 28px;
}

/* Expression bar */
.expression-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

#expression-input {
  flex: 1;
  padding: 13px 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.2rem;
  font-weight: 700;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #1e3a8a;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
  letter-spacing: 0.08em;
}

#expression-input:focus {
  border-color: #2563eb;
  background: #fff;
}

#expression-input.error {
  border-color: #dc2626;
  color: #991b1b;
  background: #fff8f8;
}

#copy-btn {
  padding: 13px 22px;
  background: #2563eb;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

#copy-btn:hover  { background: #1d4ed8; }
#copy-btn.copied { background: #16a34a; }

/* Description callout */
.description {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 20px;
  border-left: 4px solid transparent;
  font-weight: 500;
}

.description.valid {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1e3a8a;
}

.description.error {
  background: #fef2f2;
  border-color: #dc2626;
  color: #7f1d1d;
}

/* ── Presets ─────────────────────────────────────────── */

.presets {
  margin-bottom: 24px;
}

.presets-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  margin-bottom: 8px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.preset-btn:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.preset-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

/* ── Field editors ───────────────────────────────────── */

.fields-label,
.runs-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
  margin-bottom: 10px;
}

.fields {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
  overflow-wrap: break-word;
  text-align: center;
}

.field input {
  padding: 9px 8px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #f8fafc;
  color: #1e3a8a;
  text-align: center;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.field input:focus {
  border-color: #2563eb;
  background: #fff;
}

.field input.error {
  border-color: #dc2626;
  background: #fff8f8;
  color: #991b1b;
}

/* Next runs */
.runs-label { margin-top: 4px; }

#next-runs {
  list-style: none;
  margin: 0;
  padding: 0;
}

#next-runs li {
  padding: 9px 0;
  font-size: 0.9rem;
  color: #475569;
  border-bottom: 1px solid #f1f5f9;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 10px;
}

#next-runs li::before {
  content: '›';
  color: #2563eb;
  font-weight: 700;
  font-size: 1rem;
}

#next-runs li:last-child { border-bottom: none; }

/* ── Ad units ────────────────────────────────────────── */

.ad-unit {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 28px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  color: #94a3b8;
  font-size: 0.8rem;
}

/* ── Reference section ───────────────────────────────── */

.reference {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  padding: 28px;
}

.reference h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
}

.reference h3 {
  margin: 28px 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
}

.reference-intro {
  margin: 0 0 20px;
  color: #64748b;
  font-size: 0.9rem;
}

/* Field position diagram */
.field-positions {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  font-family: 'Courier New', Courier, monospace;
}

.field-pos-display {
  display: flex;
  gap: 16px;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.fp { color: #2563eb; }

.fp-labels {
  display: flex;
  gap: 0;
  font-size: 0.7rem;
  color: #64748b;
  font-family: system-ui, -apple-system, sans-serif;
}

.fp-labels span {
  min-width: 48px;
  text-align: center;
  padding: 0 4px;
}

.fp-labels span:first-child { padding-left: 0; }

/* Reference tables */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.ref-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 9px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
}

.ref-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
  vertical-align: top;
}

.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:hover td { background: #f8fafc; }

.ref-table code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.82rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  color: #2563eb;
  white-space: nowrap;
}

/* ── Footer ──────────────────────────────────────────── */

.site-footer {
  text-align: center;
  padding: 24px 20px;
  color: #94a3b8;
  font-size: 0.8rem;
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 560px) {
  .hero { padding: 28px 16px 24px; }
  h1 { font-size: 1.6rem; }
  .tagline { padding-left: 0; font-size: 0.9rem; }
  .tool-card, .reference { padding: 20px 16px; }
  .fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #expression-input { font-size: 1rem; }
  .field-pos-display { font-size: 1rem; gap: 10px; }
  .fp-labels { font-size: 0.62rem; }
}
