/* =========================================================
   Paisa — shared styles
   Mobile-first · calm palette · light & dark themes
   ========================================================= */

:root {
  --bg: #f4f2ec;
  --surface: #fbfaf6;
  --surface-2: #efece4;
  --border: #e2ddd2;
  --text: #2c2f2e;
  --muted: #6b706c;
  --accent: #3d7a6a;
  --accent-ink: #f7f6f1;
  --accent-soft: #dfeae4;
  --accent-2: #a87a3d;
  --accent-2-soft: #f1e6d4;
  --good: #47744a;
  --danger: #a5574c;
  --danger-soft: #f3e2dd;
  --chart-1: #3d7a6a;
  --chart-2: #c4a06a;
  --chart-3: #8798ad;
  --chart-4: #b67a6e;
  --chart-5: #97a386;
  --chart-6: #a99bb8;
  --chart-grid: rgba(60, 60, 50, 0.08);
  --shadow: 0 1px 2px rgba(40, 40, 30, 0.04), 0 6px 18px rgba(40, 40, 30, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181a;
    --surface: #1c2022;
    --surface-2: #242a2c;
    --border: #2f3638;
    --text: #d5d9d3;
    --muted: #8f9792;
    --accent: #7fae9f;
    --accent-ink: #13201c;
    --accent-soft: #233430;
    --accent-2: #cda874;
    --accent-2-soft: #33291d;
    --good: #96bb8e;
    --danger: #d08e83;
    --danger-soft: #382523;
    --chart-1: #7fae9f;
    --chart-2: #cda874;
    --chart-3: #92a4ba;
    --chart-4: #c79186;
    --chart-5: #a9b594;
    --chart-6: #b3a6c2;
    --chart-grid: rgba(220, 220, 210, 0.07);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15181a;
  --surface: #1c2022;
  --surface-2: #242a2c;
  --border: #2f3638;
  --text: #d5d9d3;
  --muted: #8f9792;
  --accent: #7fae9f;
  --accent-ink: #13201c;
  --accent-soft: #233430;
  --accent-2: #cda874;
  --accent-2-soft: #33291d;
  --good: #96bb8e;
  --danger: #d08e83;
  --danger-soft: #382523;
  --chart-1: #7fae9f;
  --chart-2: #cda874;
  --chart-3: #92a4ba;
  --chart-4: #c79186;
  --chart-5: #a9b594;
  --chart-6: #b3a6c2;
  --chart-grid: rgba(220, 220, 210, 0.07);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
[hidden] { display: none !important; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- header & nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: .95rem; font-weight: 700;
}
.theme-toggle {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-toggle svg { width: 18px; height: 18px; }
.site-nav { border-top: 1px solid var(--border); }
.nav-inner { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; padding-bottom: 8px; scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav-inner a {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 999px; font-size: .9rem;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.nav-inner a:hover { color: var(--text); background: var(--surface-2); }
.nav-inner a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- page head & tabs ---------- */
main { padding: 20px 0 40px; }
.page-head { margin-bottom: 16px; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.tabs {
  display: flex; gap: 4px; padding: 4px; margin: 4px 0 18px;
  background: var(--surface-2); border-radius: 14px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: .92rem; font-weight: 550; padding: 9px 14px; border-radius: 10px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.panel-head { margin-bottom: 14px; }
.panel-head p { color: var(--muted); margin-top: 4px; font-size: .95rem; }

/* ---------- layout ---------- */
.calc { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.calc > * { min-width: 0; }
.results { display: grid; gap: 14px; align-content: start; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card > h3 { margin-bottom: 12px; color: var(--muted); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
@media (min-width: 900px) {
  .calc { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; }
  .inputs { position: sticky; top: 128px; }
  h1 { font-size: 2rem; }
}

/* ---------- fields ---------- */
.field + .field { margin-top: 18px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.field label { font-size: .93rem; color: var(--text); }
.field .help { display: block; font-size: .78rem; color: var(--muted); }
.num {
  display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 10px;
  min-width: 0;
}
.num:focus-within { border-color: var(--accent); }
.num input {
  width: 9ch; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600;
  font-variant-numeric: tabular-nums; padding: 8px 0; text-align: right; outline: none;
}
.num input::-webkit-outer-spin-button, .num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.affix { color: var(--muted); font-size: .88rem; }
.hint { margin-top: 6px; font-size: .8rem; color: var(--muted); text-align: right; min-height: 1.1em; }
.field-plain .field-head { margin-bottom: 0; }

input[type=range] {
  --fill: 50%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-2) var(--fill));
}
input[type=range]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-2); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; margin-top: -7px;
  background: var(--surface); border: 2px solid var(--accent);
}
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }

/* segmented radios & chips */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 18px; }
.seg label { flex: 1; position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg label { min-width: 0; }
.seg span { display: block; text-align: center; padding: 8px 4px; line-height: 1.25; border-radius: 9px; font-size: .86rem; color: var(--muted); font-weight: 550; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.group-label { font-size: .8rem; color: var(--muted); margin: 0 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .85rem;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; font-size: .92rem; margin: 4px 0 18px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.subhead { margin: 22px 0 12px; padding-top: 16px; border-top: 1px dashed var(--border); font-size: .85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- results ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.stat-label { display: block; font-size: .8rem; color: var(--muted); }
.stat-value { display: block; font-size: 1.12rem; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-sub { display: block; font-size: .78rem; color: var(--muted); margin-top: 2px; }
.stat-big { grid-column: 1 / -1; background: var(--accent-soft); }
.stat-big .stat-value { font-size: 1.75rem; color: var(--accent); }
.stat-big .stat-label { color: var(--accent); opacity: .85; }
.tone-good .stat-value { color: var(--good); }
.tone-warn .stat-value { color: var(--accent-2); }
.tone-bad .stat-value { color: var(--danger); }
.stat-big.tone-bad { background: var(--danger-soft); }
.stat-big.tone-bad .stat-value, .stat-big.tone-bad .stat-label { color: var(--danger); }

.note { margin-top: 12px; font-size: .88rem; color: var(--muted); }
.callout {
  border-radius: 12px; padding: 12px 14px; font-size: .9rem;
  background: var(--accent-2-soft); color: var(--text); border-left: 3px solid var(--accent-2);
}
.callout.good { background: var(--accent-soft); border-left-color: var(--accent); }
.callout.bad { background: var(--danger-soft); border-left-color: var(--danger); }
.callout strong { font-weight: 650; }

.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 280px; }
.chart-box.round { height: 220px; }
.chart-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .85rem; text-align: center; padding: 16px; }
@media (min-width: 600px) { .chart-box { height: 280px; } .chart-box.tall { height: 320px; } }

/* compare columns */
.compare { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .compare { grid-template-columns: 1fr 1fr; } }
.compare .col { background: var(--surface-2); border-radius: 12px; padding: 14px; border: 1px solid transparent; }
.compare .col.win { border-color: var(--accent); background: var(--accent-soft); }
.compare .col h4 { margin: 0 0 10px; font-size: .95rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: .88rem; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-variant-numeric: tabular-nums; font-weight: 550; text-align: right; }
.kv.total span { font-weight: 700; color: var(--text); }

/* tables */
.table-wrap { overflow: auto; max-height: 420px; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .86rem; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
tr.row-total td { font-weight: 700; background: var(--surface-2); }
tr.row-sub td { color: var(--muted); }
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.table-head .seg { margin: 0; min-width: 190px; }

/* formula / how it works */
details.formula { margin-top: 14px; }
details.formula summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.formula summary::-webkit-details-marker { display: none; }
details.formula summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; }
details.formula[open] summary::after { content: "−"; }
details.formula .body { margin-top: 12px; font-size: .9rem; color: var(--muted); display: grid; gap: 10px; }
details.formula code, .formula-line {
  font-family: var(--mono); font-size: .84rem; color: var(--text); background: var(--surface-2);
  padding: 2px 6px; border-radius: 6px;
}
.formula-line { display: block; padding: 10px 12px; overflow-x: auto; white-space: nowrap; }
details.formula ul { margin: 0; padding-left: 18px; }
.updated { font-size: .78rem; color: var(--muted); margin-top: 6px; }

/* ---------- home ---------- */
.hero { padding: 12px 0 8px; }
.hero h1 { font-size: 2rem; max-width: 18ch; }
.hero p { color: var(--muted); margin-top: 10px; max-width: 52ch; font-size: 1.02rem; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pill { font-size: .8rem; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.section-title { margin: 30px 0 12px; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.grid-cards { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid-cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid-cards { grid-template-columns: repeat(3, 1fr); } .hero h1 { font-size: 2.6rem; } }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  transition: border-color .2s ease, transform .2s ease;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-icon { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tool-icon.alt { background: var(--accent-2-soft); color: var(--accent-2); }
.tool-icon svg { width: 20px; height: 20px; }
.tool-card h3 { font-size: 1rem; margin-bottom: 3px; }
.tool-card p { font-size: .86rem; color: var(--muted); }
.features { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 8px; }
@media (min-width: 700px) { .features { grid-template-columns: repeat(3, 1fr); } }
.feature { padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.feature h3 { margin-bottom: 4px; font-size: .98rem; }
.feature p { font-size: .88rem; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0 36px; font-size: .84rem; color: var(--muted); }
.site-footer p + p { margin-top: 8px; }
.site-footer strong { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .site-header, .site-nav, .tabs, .site-footer .meta, .theme-toggle { display: none !important; }
  .card { box-shadow: none; }
}
