:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #eef3ef;
  --ink: #17201b;
  --muted: #607068;
  --line: #d9e1dc;
  --accent: #12695f;
  --accent-dark: #0d4e48;
  --warm: #9a5b1f;
  --shadow: 0 18px 45px rgba(23, 32, 27, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.14;
  letter-spacing: 0;
}

h1 {
  max-width: 860px;
  font-size: clamp(2rem, 6vw, 4.5rem);
}

h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

h3 {
  font-size: 1.05rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 244, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.brand__mark,
.brand__logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.brand__mark {
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
}

.brand__logo {
  display: block;
  flex: 0 0 auto;
  width: auto;
  max-width: min(216px, 52vw);
  height: 42px;
  object-fit: contain;
  object-position: left center;
}

.brand__text {
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: 0;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
  min-height: 44px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--surface-muted);
  color: var(--accent-dark);
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 8px 12px;
}

main {
  min-height: calc(100vh - 180px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(56px, 8vw, 110px) clamp(18px, 5vw, 72px) clamp(42px, 6vw, 88px);
}

.hero__content {
  max-width: 940px;
}

.lede {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.4vw, 1.3rem);
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--warm);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  padding: 10px 16px;
  text-decoration: none;
}

.button--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.hero__panel {
  display: grid;
  gap: 14px;
}

.hero__panel div,
.feature-card,
.tool-card,
.category-card,
.content-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero__panel div {
  padding: 22px;
}

.hero__panel span {
  color: var(--warm);
  font-size: 0.82rem;
  font-weight: 800;
}

.hero__panel strong {
  display: block;
  margin: 0 0 6px;
  font-size: 1.08rem;
}

.hero__panel p,
.feature-card p,
.tool-card p,
.category-card p,
.content-block p,
.page-intro p {
  color: var(--muted);
}

.section,
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(34px, 5vw, 72px) clamp(18px, 5vw, 72px);
}

.section__header,
.page-intro {
  max-width: 850px;
  margin-bottom: 28px;
}

.page-intro--compact {
  margin-bottom: 18px;
}

.page--narrow {
  max-width: 960px;
}

.feature-grid,
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

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

.feature-card,
.tool-card,
.category-card,
.content-block {
  padding: 24px;
}

.feature-card a {
  font-weight: 750;
}

.tool-list {
  display: grid;
  gap: 32px;
  max-width: 1040px;
}

.tool-category {
  display: grid;
  gap: 14px;
}

.tool-category__header {
  max-width: 760px;
}

.tool-category__header h2 {
  margin-bottom: 0;
}

.tool-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.tool-card--featured {
  border-color: rgba(18, 105, 95, 0.35);
  background: linear-gradient(180deg, #ffffff, #f3f8f5);
}

.tool-card h2,
.category-card h2,
.content-block h2 {
  margin-bottom: 8px;
}

.status {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 6px 10px;
}

.content-block {
  max-width: 820px;
}

.content-block h2:not(:first-child) {
  margin-top: 28px;
}

.simple-calculator {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 18px;
  max-width: 1100px;
  margin-bottom: 28px;
}

.simple-calculator__panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.simple-calculator__panel h2 {
  margin-bottom: 16px;
}

.calculator-empty-state {
  align-self: start;
  background: var(--surface-muted);
}

.calculator-empty-state p {
  color: var(--muted);
  margin-bottom: 0;
}

.simple-calculator__form {
  display: grid;
  gap: 16px;
}

.simple-calculator__form label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 750;
}

.simple-calculator__form input,
.simple-calculator__form select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.input-with-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.input-with-suffix input {
  border: 0;
  border-radius: 0;
}

.input-with-suffix span {
  color: var(--muted);
  font-weight: 750;
  padding: 0 12px 0 4px;
}

.simple-calculator__form input:focus,
.simple-calculator__form select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(18, 105, 95, 0.16);
}

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

.calculator-message {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.calculator-message.is-stale {
  color: var(--warm);
  font-weight: 750;
}

.field-note,
.result-note {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 400;
}

.result-grid {
  display: grid;
  gap: 12px;
}

.result-grid + .result-grid {
  margin-top: 14px;
}

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

.result-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 16px;
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  margin-bottom: 6px;
}

.result-grid strong {
  display: block;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.1;
}

.result-grid--compact strong {
  font-size: clamp(1rem, 2vw, 1.25rem);
}

.result-note {
  margin: 16px 0 0;
}

.projection-block {
  max-width: 1100px;
  margin-bottom: 28px;
}

.chart-block {
  max-width: 1100px;
  margin-bottom: 28px;
}

.projection-block .section__header {
  margin-bottom: 16px;
}

.chart-block .section__header {
  margin-bottom: 16px;
}

.chart-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.chart-wrap canvas {
  display: block;
  width: 100%;
  height: 320px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.projection-table {
  width: 100%;
  min-width: 700px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.projection-table__age {
  width: 8.3%;
}

.projection-table__money {
  width: 18.85%;
}

.projection-table__percent {
  width: 16.3%;
}

.projection-table__year {
  width: 14%;
}

.projection-table--comparison {
  min-width: 620px;
}

.projection-table--comparison .projection-table__money {
  width: 28.66%;
}

.projection-table--future-value {
  min-width: 700px;
}

.projection-table--future-value .projection-table__money {
  width: 21.5%;
}

.projection-table th,
.projection-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

.projection-table td {
  white-space: nowrap;
}

.projection-table th:first-child,
.projection-table td:first-child {
  text-align: left;
}

.projection-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}

.projection-table tr:last-child td {
  border-bottom: 0;
}

.calculator-page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px clamp(12px, 3vw, 32px) 42px;
}

.calculator-frame {
  display: block;
  width: 100%;
  height: 2500px;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

.calculator-frame--rrif {
  height: 1900px;
}

.calculator-frame--rrsp-tfsa {
  height: 1900px;
}

.calculator-frame--future-value {
  height: 1850px;
}

.calculator-frame--savings-goal {
  height: 1900px;
}

.calculator-frame--compound-growth {
  height: 1750px;
}

.calculator-frame--rrsp-tax-savings {
  height: 1450px;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 26px clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 860px) {
  .site-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    padding-block: 14px;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
  }

  .site-nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 8px;
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav a {
    width: 100%;
    padding: 12px;
  }

  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

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

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

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

  .simple-calculator {
    grid-template-columns: 1fr;
  }

  .calculator-frame {
    height: 3200px;
  }

  .calculator-frame--rrif {
    height: 2200px;
  }

  .calculator-frame--rrsp-tfsa {
    height: 2200px;
  }

  .calculator-frame--future-value {
    height: 2200px;
  }

  .calculator-frame--savings-goal {
    height: 2300px;
  }

  .calculator-frame--compound-growth {
    height: 2150px;
  }

  .calculator-frame--rrsp-tax-savings {
    height: 1850px;
  }

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

@media (max-width: 520px) {
  body {
    font-size: 1rem;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 2.7rem);
  }

  h2 {
    font-size: 1.35rem;
  }

  .site-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .brand {
    max-width: calc(100% - 92px);
  }

  .brand__text {
    white-space: normal;
    line-height: 1.15;
  }

  .hero,
  .section,
  .page,
  .calculator-page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero {
    padding-top: 40px;
  }

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

  .result-grid--compact {
    grid-template-columns: 1fr;
  }

  .feature-card,
  .tool-card,
  .category-card,
  .simple-calculator__panel,
  .content-block,
  .hero__panel div {
    padding: 18px;
  }

  .actions,
  .button,
  .calculator-actions {
    width: 100%;
  }

  .button {
    min-height: 48px;
  }

  .status {
    align-self: flex-start;
  }

  .calculator-frame {
    border-radius: 0;
    margin-left: -16px;
    width: calc(100% + 32px);
  }

  .projection-table th,
  .projection-table td {
    padding: 10px 12px;
  }

  .chart-wrap {
    padding: 10px;
  }

  .chart-wrap canvas {
    height: 310px;
  }
}

@media (max-width: 380px) {
  .brand__mark {
    width: 34px;
    height: 34px;
  }

  .brand__logo {
    max-width: min(190px, 50vw);
    height: 38px;
  }

  .nav-toggle {
    padding-left: 10px;
    padding-right: 10px;
  }
}
