:root {
  --bg: #f4f7fb;
  --bg-strong: #eef4fb;
  --surface: #ffffff;
  --surface-alt: #f8fbff;
  --surface-ink: #10253f;
  --line: #d8e3ee;
  --line-strong: #bfd0e1;
  --text: #13253b;
  --text-soft: #57708a;
  --brand: #0f7490;
  --brand-strong: #0a5d74;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.14);
  --teal-soft: rgba(15, 116, 144, 0.12);
  --success: #0f8a5f;
  --warning: #c2700d;
  --warning-soft: rgba(194, 112, 13, 0.12);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);
  --shadow: 0 20px 50px rgba(13, 37, 63, 0.09);
  --shadow-soft: 0 12px 30px rgba(13, 37, 63, 0.06);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --content-width: 1380px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 116, 144, 0.1), transparent 32%),
    linear-gradient(180deg, #f6faff 0%, #f4f7fb 32%, #eef2f8 100%);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.site-shell {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(191, 208, 225, 0.65);
  border-radius: 22px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 0.96rem;
}

.brand-copy span {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.topbar-nav a {
  text-decoration: none;
  color: var(--text-soft);
  font-weight: 600;
}

.topbar-nav a:hover {
  color: var(--brand-strong);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 24px;
  margin-bottom: 28px;
  padding: 36px;
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(19, 37, 59, 0.96) 0%, rgba(18, 53, 89, 0.96) 44%, rgba(14, 71, 92, 0.96) 100%);
  color: #eff7ff;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.82), transparent);
  pointer-events: none;
}

.hero-copy,
.hero-aside {
  position: relative;
  z-index: 1;
}

.hero-badge,
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8ddcf0;
}

.hero h1,
.section-heading h2,
.results-header h2,
.stack-card h3,
.term-dialog h3 {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

.hero h1 {
  margin: 14px 0 12px;
  font-size: clamp(2.2rem, 4vw, 4.2rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.hero-subtitle {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #dceaf8;
}

.hero-lead {
  max-width: 64ch;
  margin: 0;
  font-size: 1rem;
  line-height: 1.75;
  color: rgba(239, 247, 255, 0.86);
}

.hero-highlights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.hero-chip,
.hero-card,
.panel,
.mode-card,
.insight-card,
.example-card,
.glossary-card,
.source-card,
.metric-card,
.stack-card,
.helper-callout,
.example-narrative {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.hero-chip {
  padding: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.hero-chip strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.hero-chip span,
.hero-card,
.results-disclaimer,
.field-note,
.section-note,
.notes-list,
.warnings-list,
.insight-card p,
.glossary-card p,
.source-card p,
.example-card p,
.example-narrative p {
  line-height: 1.6;
}

.hero-card {
  padding: 24px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.hero-list {
  margin: 14px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.workspace-main,
.calculator-stack {
  display: grid;
  gap: 20px;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(191, 208, 225, 0.65);
  box-shadow: var(--shadow-soft);
}

.section-panel {
  padding: 28px;
}

.section-heading,
.results-header,
.stack-card-header,
.term-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.section-heading h2,
.results-header h2,
.stack-card h3 {
  margin: 8px 0 0;
  font-size: 1.55rem;
  line-height: 1.1;
}

.section-note,
.results-disclaimer,
.field-note,
.metric-caption,
.result-summary-banner p,
.action-feedback,
.footer p,
.pill,
.mode-card p,
.mode-points,
.cost-row small,
.stack-card li {
  color: var(--text-soft);
}

.section-note {
  max-width: 34ch;
  margin: 0;
  font-size: 0.95rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mode-card {
  display: grid;
  gap: 12px;
  padding: 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.mode-card:hover,
.example-card:hover,
.source-card:hover,
.glossary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card:has(input:checked) {
  border-color: rgba(15, 116, 144, 0.55);
  box-shadow: 0 16px 28px rgba(15, 116, 144, 0.14);
  background:
    linear-gradient(180deg, rgba(15, 116, 144, 0.08) 0%, rgba(255, 255, 255, 0.96) 100%);
}

.mode-pill,
.pill,
.badge,
.example-meta span,
.source-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.mode-pill,
.pill {
  background: rgba(15, 116, 144, 0.1);
  color: var(--brand-strong);
}

.mode-card strong,
.metric-card strong,
.example-card strong,
.glossary-card strong,
.source-card strong,
.insight-card strong {
  font-size: 1.02rem;
}

.mode-points {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.compact-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.95rem;
  font-weight: 700;
}

.inline-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.field input,
.field select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.52);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.field[data-invalid="true"] input,
.field[data-invalid="true"] select {
  border-color: rgba(180, 35, 24, 0.55);
  background: rgba(180, 35, 24, 0.03);
}

.field-error {
  font-size: 0.82rem;
  color: var(--danger);
}

.input-combo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
}

.helper-callout {
  margin-top: 18px;
  padding: 18px 20px;
  background:
    linear-gradient(135deg, rgba(15, 116, 144, 0.08) 0%, rgba(37, 99, 235, 0.08) 100%);
  border: 1px solid rgba(15, 116, 144, 0.18);
}

.helper-callout strong {
  display: block;
  margin-bottom: 10px;
}

.helper-callout ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.workspace-side {
  min-width: 0;
}

.sticky-panel {
  position: sticky;
  top: 18px;
}

.results-panel {
  padding: 26px;
  display: grid;
  gap: 18px;
}

.results-disclaimer {
  margin: 0;
  font-size: 0.92rem;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  border: 1px solid transparent;
  border-radius: 14px;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
}

.button-secondary {
  color: var(--surface-ink);
  background: rgba(37, 99, 235, 0.1);
}

.button-tertiary {
  color: var(--brand-strong);
  background: rgba(15, 116, 144, 0.1);
}

.button-ghost {
  color: var(--text-soft);
  border-color: var(--line);
  background: transparent;
}

.action-feedback {
  min-height: 1.4rem;
  margin: -4px 0 0;
  font-size: 0.88rem;
}

.result-summary-banner {
  padding: 18px 20px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(18, 53, 89, 0.96) 0%, rgba(15, 116, 144, 0.96) 100%);
  color: #f5fbff;
}

.result-summary-banner strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.02rem;
}

.result-summary-banner p {
  margin: 0;
  color: rgba(245, 251, 255, 0.82);
}

.result-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid var(--line);
}

.metric-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.metric-title strong {
  font-size: 0.95rem;
}

.metric-value {
  font-size: 1.48rem;
  font-weight: 800;
  line-height: 1.1;
}

.metric-caption {
  margin-top: 6px;
  font-size: 0.85rem;
}

.stack-card {
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid var(--line);
}

.formula-list,
.notes-list {
  margin: 14px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
}

.cost-breakdown {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(216, 227, 238, 0.7);
}

.cost-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.cost-row strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.95rem;
}

.cost-row .cost-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--surface-ink);
}

.warnings-card {
  border-color: rgba(194, 112, 13, 0.24);
  background:
    linear-gradient(180deg, rgba(194, 112, 13, 0.06) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.warnings-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.warning-item,
.info-item {
  padding: 14px 16px;
  border-radius: 14px;
}

.warning-item {
  background: var(--warning-soft);
  color: #8b5310;
}

.info-item {
  background: var(--teal-soft);
  color: var(--brand-strong);
}

.interpretation-panel,
.glossary-grid,
.sources-grid {
  margin-top: 28px;
}

.insight-grid,
.examples-grid,
.glossary-grid,
.sources-grid {
  display: grid;
  gap: 16px;
}

.insight-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.insight-card,
.example-card,
.glossary-card,
.source-card {
  padding: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid var(--line);
}

.example-card,
.source-card,
.glossary-card {
  display: grid;
  gap: 10px;
}

.examples-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.example-card {
  position: relative;
  cursor: pointer;
}

.example-card.active {
  border-color: rgba(15, 116, 144, 0.45);
  box-shadow: 0 16px 30px rgba(15, 116, 144, 0.12);
}

.example-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-meta span {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
}

.example-narrative {
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(15, 116, 144, 0.08) 100%);
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.glossary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.source-card {
  grid-template-rows: auto auto 1fr auto;
}

.sources-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.source-tag {
  background: rgba(15, 116, 144, 0.1);
  color: var(--brand-strong);
}

.source-link,
.glossary-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  background: rgba(19, 37, 59, 0.96);
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.glossary-link {
  border: 0;
  cursor: pointer;
}

.badge-info {
  background: rgba(15, 116, 144, 0.12);
  color: var(--brand-strong);
}

.pill-warning {
  background: rgba(194, 112, 13, 0.14);
  color: #8b5310;
}

.info-button,
.dialog-close {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand-strong);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.term-dialog {
  width: min(720px, calc(100vw - 24px));
  border: 0;
  border-radius: 24px;
  padding: 0;
  background: transparent;
}

.term-dialog::backdrop {
  background: rgba(10, 20, 33, 0.48);
  backdrop-filter: blur(6px);
}

.term-dialog-body {
  padding: 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  border: 1px solid rgba(191, 208, 225, 0.75);
  box-shadow: var(--shadow);
}

.term-detail {
  padding: 16px 0;
  border-top: 1px solid rgba(216, 227, 238, 0.75);
}

.term-detail:first-of-type {
  border-top: 0;
  padding-top: 10px;
}

.term-detail h4 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.term-detail p {
  margin: 0;
  line-height: 1.7;
  color: var(--text-soft);
}

.footer {
  margin-top: 30px;
  padding: 22px 0 8px;
  text-align: center;
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sticky-panel {
    position: static;
  }

  .compact-grid,
  .glossary-grid,
  .sources-grid,
  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .hero,
  .mode-grid,
  .form-grid,
  .examples-grid {
    grid-template-columns: 1fr;
  }

  .hero-highlights,
  .result-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
    align-items: start;
  }

  .section-heading,
  .results-header,
  .stack-card-header {
    flex-direction: column;
  }

  .section-note {
    max-width: none;
  }
}

@media (max-width: 720px) {
  .site-shell {
    padding: 16px 14px 36px;
  }

  .hero,
  .section-panel,
  .results-panel {
    padding: 22px;
  }

  .topbar-nav,
  .actions-row {
    width: 100%;
  }

  .topbar-nav {
    justify-content: space-between;
  }

  .hero-highlights,
  .result-card-grid,
  .compact-grid,
  .glossary-grid,
  .sources-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .input-combo {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar-nav,
  .actions-row,
  .footer,
  .info-button,
  .glossary-link,
  .source-link {
    display: none !important;
  }

  .site-shell {
    max-width: none;
    padding: 0;
  }

  .hero,
  .panel {
    box-shadow: none;
    border-color: #cfd8e3;
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}
