:root {
  --ink: #1a1f1c;
  --ink-soft: #3d4740;
  --muted: #5c675f;
  --paper: #eef3ef;
  --paper-2: #e2ebe4;
  --surface: #f7faf8;
  --brand: #0d5c4d;
  --brand-deep: #083f35;
  --accent: #c45c26;
  --accent-soft: #f3e0d4;
  --fees: #b45309;
  --cost: #64748b;
  --profit: #0f766e;
  --line: rgba(26, 31, 28, 0.12);
  --shadow: 0 18px 50px rgba(8, 63, 53, 0.1);
  --radius: 14px;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
  --max: 72rem;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(13, 92, 77, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(196, 92, 38, 0.1), transparent 50%),
    linear-gradient(180deg, #f4f8f5 0%, var(--paper) 40%, #e8f0ea 100%);
  line-height: 1.55;
  min-height: 100vh;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--brand);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--brand-deep);
}

.wrap {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

/* Header */
.site-header {
  padding: 1rem 0 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.55rem;
  background: linear-gradient(145deg, var(--brand) 0%, #14856f 55%, var(--accent) 140%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0.45rem;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 0.25rem;
  border-bottom-width: 3px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
}

/* Hero + calculator */
.hero {
  padding: 1.75rem 0 2.5rem;
}

.hero-copy {
  max-width: 38rem;
  margin-bottom: 1.5rem;
  animation: rise 0.7s ease both;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.12;
  margin: 0 0 0.75rem;
  color: var(--brand-deep);
}

.hero-lead {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 34rem;
}

.calculator {
  display: grid;
  gap: 1.25rem;
  animation: rise 0.85s 0.08s ease both;
}

@media (min-width: 900px) {
  .calculator {
    grid-template-columns: 1.05fr 0.95fr;
    gap: 1.5rem;
    align-items: start;
  }
}

.panel {
  background: color-mix(in srgb, var(--surface) 92%, white);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

@media (min-width: 640px) {
  .panel {
    padding: 1.5rem;
  }
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

.field-grid {
  display: grid;
  gap: 0.9rem;
}

@media (min-width: 560px) {
  .field-grid.two {
    grid-template-columns: 1fr 1fr;
  }
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.hint {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.8rem;
}

input[type="number"],
select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--brand) 55%, white);
  box-shadow: 0 0 0 3px rgba(13, 92, 77, 0.15);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

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

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 2.7rem;
  padding: 0.45rem 0.4rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.segmented input:checked + label {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.segmented input:focus-visible + label {
  box-shadow: 0 0 0 3px rgba(13, 92, 77, 0.2);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--line);
  margin-top: 0.35rem;
}

.toggle-copy {
  display: grid;
  gap: 0.15rem;
}

.toggle-copy strong {
  font-size: 0.92rem;
}

.toggle-copy span {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.switch {
  position: relative;
  width: 2.8rem;
  height: 1.55rem;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c5cfc8;
  transition: background 0.15s;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: #fff;
  top: 0.175rem;
  left: 0.175rem;
  transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(1.25rem);
}

.switch input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(13, 92, 77, 0.2);
}

.results {
  display: grid;
  gap: 0.85rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.95rem;
}

.result-row span:first-child {
  color: var(--muted);
}

.result-row strong {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.result-row.muted strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.result-total {
  margin-top: 0.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.result-keep {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(13, 92, 77, 0.1), rgba(196, 92, 38, 0.08));
  border: 1px solid color-mix(in srgb, var(--brand) 20%, transparent);
}

.result-keep strong {
  font-size: 1.35rem;
  color: var(--brand-deep);
  font-family: var(--font-display);
}

.result-profit strong.positive {
  color: var(--profit);
}

.result-profit strong.negative {
  color: #b91c1c;
}

.bar-wrap {
  margin-top: 0.35rem;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.bar {
  display: flex;
  height: 0.9rem;
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper-2);
}

.bar > i {
  display: block;
  height: 100%;
  transition: width 0.35s ease;
}

.bar-fees {
  background: var(--fees);
}

.bar-cost {
  background: var(--cost);
}

.bar-profit {
  background: var(--profit);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend i {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
}

.ad-slot {
  margin: 1.5rem auto;
  width: min(100% - 2rem, var(--max));
  min-height: 90px;
  border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.35);
}

/* Content sections */
.content {
  padding: 1rem 0 3.5rem;
}

.section {
  padding: 2.25rem 0;
  border-top: 1px solid var(--line);
  animation: rise 0.6s ease both;
}

.section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3vw, 1.9rem);
  letter-spacing: -0.025em;
  margin: 0 0 0.5rem;
  color: var(--brand-deep);
}

.section-lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  max-width: 40rem;
}

.fee-explain {
  display: grid;
  gap: 1rem;
}

@media (min-width: 800px) {
  .fee-explain {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

.fee-explain article {
  padding: 0;
}

.fee-explain h3 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  color: var(--ink);
}

.fee-explain p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.rates-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 36rem;
}

th,
td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: rgba(13, 92, 77, 0.07);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-deep);
}

tr:last-child td {
  border-bottom: none;
}

.tips {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.85rem;
  counter-reset: tip;
}

.tips li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: start;
}

.tips li::before {
  counter-increment: tip;
  content: counter(tip);
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.1rem;
}

.tips strong {
  display: block;
  margin-bottom: 0.15rem;
}

.tips p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.faq details {
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 0;
}

.faq summary {
  cursor: pointer;
  font-weight: 650;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  font-size: 1.25rem;
  color: var(--brand);
  line-height: 1;
}

.faq details[open] summary::after {
  content: "–";
}

.faq p {
  margin: 0.65rem 0 0.25rem;
  color: var(--ink-soft);
  max-width: 44rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 700px) {
  .footer-grid {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.footer-links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--brand);
}

.disclaimer {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  max-width: 36rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
