/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #16233a;
  --ink-soft: #4a5a75;
  --line: #dde5f0;
  --brand: #1c5bd6;
  --brand-dark: #16408f;
  --brand-tint: #eaf1fe;
  --good: #1a7f4b;
  --warn: #b25a00;
  --danger: #c23434;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 35, 58, .06), 0 8px 24px rgba(22, 35, 58, .07);
  --wrap: 720px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1622;
    --surface: #172233;
    --ink: #e9eef7;
    --ink-soft: #a9b6ca;
    --line: #29374d;
    --brand: #5b93f0;
    --brand-dark: #3f78d8;
    --brand-tint: #1b2942;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.015em; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: fixed; top: -100px; left: 1rem;
  padding: .6rem 1rem; background: var(--surface); color: var(--ink);
  z-index: 9999; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow);
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Layout utilities
   ============================================================= */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 18px;
}

/* =============================================================
   4. Header
   ============================================================= */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--brand-tint);
  color: var(--brand);
}
.header-link {
  font-size: .92rem;
  font-weight: 500;
  color: var(--ink-soft);
}

/* =============================================================
   5. Hero + tool
   ============================================================= */
.hero { padding: 26px 18px 8px; }
h1 {
  font-size: clamp(1.5rem, 6vw, 2.05rem);
  margin-bottom: 10px;
}
.hero__sub {
  color: var(--ink-soft);
  font-size: 1.02rem;
  margin-bottom: 20px;
  max-width: 60ch;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
}

.tool-form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field--nested { margin-top: 10px; }
.field label,
.field__label {
  font-weight: 600;
  font-size: .95rem;
}
.field__hint {
  font-size: .85rem;
  color: var(--ink-soft);
  line-height: 1.45;
}
.field input[type="number"] {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.field input[type="number"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
  outline: none;
}

.check,
.radio {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
  font-size: .95rem;
  cursor: pointer;
}
.check input,
.radio input { width: 18px; height: 18px; accent-color: var(--brand); }

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background .15s var(--ease-out), transform .1s var(--ease-out);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
}
.btn--ghost:hover { background: var(--brand-tint); }

.tool-form__error {
  color: var(--danger);
  font-size: .9rem;
  font-weight: 500;
}

/* ---- Result ---- */
.tool-result { display: flex; flex-direction: column; gap: 18px; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.result-stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.result-stat--main {
  background: var(--brand-tint);
  border-color: transparent;
}
.result-stat__label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.result-stat__value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.result-stat--main .result-stat__value { color: var(--brand-dark); }
.result-stat__unit { font-size: .85rem; color: var(--ink-soft); }

.result-bar {
  height: 12px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.result-bar__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  border-radius: 999px;
  transition: width .5s var(--ease-out);
}

.result-gap {
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  background: var(--bg);
}
.result-gap h3 { font-size: 1rem; margin-bottom: 4px; }
.result-gap p { font-size: .95rem; color: var(--ink-soft); }
.result-gap--full { border-left-color: var(--good); }

.result-detail {
  font-size: .92rem;
  color: var(--ink-soft);
}

.disclaimer {
  background: var(--brand-tint);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: .88rem;
  line-height: 1.5;
}
.disclaimer p + p { margin-top: 6px; }
.disclaimer__date { color: var(--ink-soft); font-weight: 500; }

.privacy-badge {
  margin: 14px 2px 0;
  font-size: .88rem;
  color: var(--ink-soft);
}

/* State machine */
.tool-card[data-state="idle"] .tool-result { display: none; }
.tool-card[data-state="done"] .tool-form { display: none; }

/* =============================================================
   6. Ad slots (placeholders)
   ============================================================= */
.ad-slot {
  margin: 22px 0;
  min-height: 100px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.ad-slot--incontent { margin: 30px 0; }

/* =============================================================
   7. Content
   ============================================================= */
.content { padding: 10px 18px 40px; }
.content h2 {
  font-size: clamp(1.25rem, 4.5vw, 1.5rem);
  margin: 34px 0 12px;
}
.content > p { margin-bottom: 12px; color: var(--ink-soft); }
.content > p strong { color: var(--ink); }

.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0;
}
.steps li {
  display: flex;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.steps__num {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
}
.steps h3 { font-size: 1rem; margin-bottom: 2px; }
.steps p { font-size: .92rem; color: var(--ink-soft); }

.faq {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 15px;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  padding: 11px 0;
  list-style: none;
  position: relative;
  padding-right: 26px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 2px; top: 50%;
  transform: translateY(-50%);
  font-weight: 400;
  font-size: 1.3rem;
  color: var(--brand);
}
.faq details[open] summary::after { content: "\2013"; }
.faq details p {
  padding: 0 0 13px;
  font-size: .93rem;
  color: var(--ink-soft);
}

.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.tool-link {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px;
  color: var(--ink);
}
.tool-link:hover { text-decoration: none; border-color: var(--brand); }
.tool-link h3 { font-size: .98rem; margin-bottom: 3px; color: var(--brand-dark); }
.tool-link p { font-size: .88rem; color: var(--ink-soft); }

/* =============================================================
   8. Footer
   ============================================================= */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 22px 0 30px;
}
.site-footer p { font-size: .85rem; color: var(--ink-soft); margin-bottom: 10px; }
.site-footer__nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.site-footer__nav a { font-size: .88rem; font-weight: 500; }

/* =============================================================
   9. Responsive
   ============================================================= */
@media (min-width: 540px) {
  .result-grid { grid-template-columns: 1fr 1fr; }
  .result-stat--main { grid-column: 1 / -1; }
}
@media (min-width: 720px) {
  .hero { padding-top: 40px; }
  .tool-card { padding: 26px 24px; }
  .tools-grid { grid-template-columns: 1fr 1fr; }
}

/* =============================================================
   10. Reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .result-bar__fill { transition: none; }
}
