:root {
  --civic-navy: #1f3557;
  --fair-red: #c73e3a;
  --slate-gray: #4a5568;
  --bg-light: #f5f7fa;
  --divider: #e2e8f0;
  --econ-green: #2f855a;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--slate-gray);
  background:
    radial-gradient(circle at top left, rgba(31, 53, 87, 0.06), transparent 34%),
    radial-gradient(circle at top right, rgba(199, 62, 58, 0.05), transparent 30%),
    var(--bg-light);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.app-shell {
  width: min(1600px, 98vw);
  margin: 1rem auto 2rem;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(320px, 920px) minmax(140px, 1fr);
  gap: 1rem;
  align-items: start;
}

.layout {
  width: 100%;
  display: grid;
  gap: 1rem;
}

.rail {
  position: sticky;
  top: 1rem;
}

.rail-card {
  background: var(--white);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 0.65rem;
  min-height: 620px;
}

.rail-label {
  margin: 0 0 0.55rem;
  color: var(--civic-navy);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.rail .adsbygoogle {
  display: block;
  width: 100%;
  min-height: 600px;
}

.hero {
  background: var(--white);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 1.2rem;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.55rem;
  padding: 0.35rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-wordmark {
  width: min(220px, 60vw);
  height: auto;
  object-fit: contain;
}

.hero h1 {
  margin: 0;
  color: var(--civic-navy);
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  letter-spacing: -0.01em;
  font-weight: 700;
}

.tagline {
  margin: 0.4rem 0 0;
  color: var(--civic-navy);
  font-weight: 600;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.35rem 0 0.65rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--civic-navy);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 0.33rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.site-nav a:hover {
  background: #eef3fb;
}

.subhead {
  margin: 0.45rem 0 0;
  max-width: 64ch;
  line-height: 1.58;
}

.card,
.ad-slot,
.site-footer {
  background: var(--white);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 1rem;
}

label {
  display: block;
  color: var(--civic-navy);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--slate-gray);
  border-radius: 6px;
  padding: 0.72rem 0.75rem;
  background: var(--white);
  min-height: 44px;
}

input#zip {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.02em;
}

input:focus {
  outline: 2px solid var(--civic-navy);
  outline-offset: 1px;
  box-shadow: 0 0 0 3px rgba(31, 53, 87, 0.12);
}

button {
  border: 1px solid var(--fair-red);
  border-radius: 6px;
  padding: 0.72rem 0.95rem;
  background: var(--fair-red);
  color: var(--white);
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
}

button:hover {
  background: #b63935;
}

button:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.settings-grid {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
}

.result-card h2,
.formula-card h2 {
  margin: 0 0 0.55rem;
  color: var(--civic-navy);
  font-size: 1.2rem;
}

.seo-card h2 {
  margin: 0 0 0.55rem;
  color: var(--civic-navy);
  font-size: 1.15rem;
}

h3 {
  margin: 0.2rem 0 0.45rem;
  color: var(--civic-navy);
  font-size: 1rem;
}

.seo-card p {
  margin: 0.55rem 0 0;
  line-height: 1.58;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 0.75rem;
}

.metric {
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: #f9fbff;
  padding: 0.7rem;
}

.metric .label {
  display: block;
  color: var(--slate-gray);
  font-size: 0.82rem;
}

.metric .value {
  display: block;
  margin-top: 0.2rem;
  color: var(--civic-navy);
  font-size: 1.24rem;
  font-weight: 600;
}

.metric.metric-primary .value {
  color: var(--fair-red);
}

.breakdown {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

.breakdown td {
  border-top: 1px solid var(--divider);
  padding: 0.56rem 0.2rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
}

.breakdown td:last-child {
  text-align: right;
  color: var(--civic-navy);
  font-weight: 500;
}

.source-list {
  margin: 0.5rem 0 0.4rem;
  padding-left: 1.1rem;
  color: var(--slate-gray);
}

.source-list li {
  margin: 0.24rem 0;
  line-height: 1.4;
}

.hidden {
  display: none;
}

.ad-slot {
  min-height: 88px;
}

.ad-slot-inline .adsbygoogle {
  display: block;
  width: 100%;
  min-height: 90px;
}

.site-footer p {
  margin: 0;
  color: var(--slate-gray);
  font-size: 0.9rem;
  line-height: 1.55;
}

.meta {
  font-size: 0.86rem;
}

.footer-links a {
  color: var(--civic-navy);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

@media (max-width: 1279px) {
  .app-shell {
    width: min(950px, 96vw);
    grid-template-columns: 1fr;
    margin-top: 0.8rem;
  }

  .rail {
    display: none;
  }
}

@media (max-width: 900px) {
  .hero,
  .card,
  .ad-slot,
  .site-footer {
    padding: 0.9rem;
  }
}

@media (max-width: 640px) {
  .app-shell {
    gap: 0.8rem;
    margin: 0.6rem auto 1.5rem;
  }

  .hero h1 {
    font-size: 1.55rem;
    line-height: 1.2;
  }

  .tagline {
    margin-top: 0.3rem;
    font-size: 0.95rem;
  }

  .site-nav a {
    font-size: 0.78rem;
    padding: 0.28rem 0.48rem;
  }

  .subhead {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .brand-lockup {
    gap: 0.5rem;
    padding: 0.2rem 0;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-wordmark {
    width: min(185px, 58vw);
  }

  label {
    font-size: 0.86rem;
  }

  .settings-grid,
  .row,
  .result-summary {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .metric .value {
    font-size: 1.18rem;
  }

  .breakdown {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .breakdown td {
    white-space: nowrap;
    font-size: 0.85rem;
  }

  .ad-slot {
    min-height: 70px;
    padding: 0.65rem;
  }

  .site-footer p {
    font-size: 0.83rem;
  }
}

@media (max-width: 420px) {
  .hero,
  .card,
  .ad-slot,
  .site-footer {
    padding: 0.8rem;
  }

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

  input,
  button {
    font-size: 16px;
  }
}
