/* CalcBox — minimal, mobile-first */
:root {
  --bg: #fafaf8; --surface: #fff; --sunk: #f4f4f1; --text: #141414; --muted: #6b6b66; --faint: #a3a39c;
  --line: #e8e8e3; --line2: #d6d6cf; --accent: #e4570b; --accent-ink: #c2470a; --accent-soft: rgba(228, 87, 11, .09);
  --b1: #141414; --b2: #e4570b; --ok: #2f9e6b; --warn: #e0a100; --bad: #d64545;
  --r: 16px; --r-lg: 20px; --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 8px 24px rgba(20, 20, 20, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0d; --surface: #171716; --sunk: #1e1e1c; --text: #f3f3f0; --muted: #9d9d96; --faint: #6c6c66;
    --line: #262624; --line2: #34342f; --accent: #f06a22; --accent-ink: #ff8a4c; --accent-soft: rgba(240, 106, 34, .13);
    --b1: #f3f3f0; --b2: #f06a22; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e0d; --surface: #171716; --sunk: #1e1e1c; --text: #f3f3f0; --muted: #9d9d96; --faint: #6c6c66;
  --line: #262624; --line2: #34342f; --accent: #f06a22; --accent-ink: #ff8a4c; --accent-soft: rgba(240, 106, 34, .13);
  --b1: #f3f3f0; --b2: #f06a22; --shadow: none; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; transition: background-color .25s, color .25s;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.02em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.i { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; animation: in .35s ease-out both; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.logo { width: 30px; height: 30px; }
.theme-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; transition: border-color .2s, transform .2s;
}
.theme-btn:hover { border-color: var(--line2); }
.theme-btn:active { transform: scale(.94); }
.theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: block; }
}

/* hero + search */
.hero { padding: 28px 0 20px; }
.hero h1 { font-size: clamp(2.1rem, 8vw, 3.4rem); font-weight: 800; letter-spacing: -.035em; }
.hero h1 span { color: var(--faint); }
.search {
  position: relative; margin-top: 24px; display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search .i { margin-left: 16px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; height: 58px; padding: 0 12px; font-size: 17px; outline: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search kbd {
  margin-right: 14px; font: 600 12px var(--mono); color: var(--muted); border: 1px solid var(--line2);
  border-radius: 6px; padding: 2px 7px; display: none;
}
@media (hover: hover) and (pointer: fine) { .search kbd { display: inline-block; } }

/* pinned / recent */
.strip { margin-top: 20px; }
.strip h2, .cat-block h2, .related h2 { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; flex: none;
  height: 40px; padding: 0 14px 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 600; transition: border-color .2s, transform .2s;
}
.chip .i { width: 18px; height: 18px; color: var(--accent); }
.chip:hover { border-color: var(--line2); transform: translateY(-1px); }

/* filters */
.filters { display: flex; gap: 6px; margin: 28px 0 8px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  flex: none; height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s;
}
.filters button:hover { color: var(--text); }
.filters button.on { background: var(--text); color: var(--bg); }

/* grid */
.cat-block { margin-top: 24px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; min-height: 132px; display: flex; flex-direction: column;
  transition: transform .2s ease, border-color .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line2); box-shadow: var(--shadow); }
.card h3 { font-size: 15px; font-weight: 700; margin-top: 14px; letter-spacing: -.01em; }
.card p { margin: 3px 0 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
.card a::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
.ic { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.ic .i { width: 22px; height: 22px; }
.star {
  position: absolute; top: 10px; right: 10px; z-index: 1; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: var(--faint); display: grid; place-items: center; transition: color .2s, transform .2s;
}
.star:hover { color: var(--text); }
.star:active { transform: scale(.85); }
.star[aria-pressed="true"] { color: var(--accent); }
.star[aria-pressed="true"] svg { fill: currentColor; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ad slots — replace inner comment with AdSense <ins> code */
.ad-slot {
  display: grid; place-items: center; min-height: 90px; margin: 24px 0; border: 1px dashed var(--line2); border-radius: 12px;
  color: var(--faint); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
}
.ad-slot::before { content: "Ad"; }
.ad-slot.filled::before { content: none; }
.ad-slot.filled { border: 0; min-height: 0; display: block; }

/* tool page */
.crumbs { display: flex; gap: 6px; font-size: 13px; color: var(--muted); padding-top: 4px; }
.crumbs a:hover { color: var(--text); }
.tool-head { display: flex; align-items: center; gap: 14px; margin: 18px 0 20px; }
.tool-head .ic { width: 48px; height: 48px; border-radius: 14px; }
.tool-head .ic .i { width: 26px; height: 26px; }
.tool-head h1 { font-size: clamp(1.6rem, 6vw, 2.2rem); font-weight: 800; }
.tool-head p { margin: 2px 0 0; color: var(--muted); font-size: 15px; }
.tool-grid { display: grid; gap: 14px; align-items: start; }
@media (min-width: 860px) { .tool-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; } .res-col { position: sticky; top: 16px; } }
.panel, .result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
@media (min-width: 860px) { .panel, .result { padding: 24px; } }

/* form */
.panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; margin: 0; }
.f { grid-column: 1 / -1; min-width: 0; }
.f.half { grid-column: span 1; }
.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.inp {
  display: flex; align-items: center; position: relative; height: 54px; border: 1px solid var(--line); background: var(--sunk);
  border-radius: 12px; transition: border-color .2s, box-shadow .2s, background .2s;
}
.inp:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.inp input, .inp select {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; padding: 0 14px;
  font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.inp select { appearance: none; -webkit-appearance: none; font-size: 16px; padding-right: 38px; cursor: pointer; }
.inp .caret { position: absolute; right: 12px; width: 18px; height: 18px; pointer-events: none; color: var(--muted); }
.inp input[type="date"] { font-size: 16px; min-height: 52px; }
.inp .pre { padding-left: 14px; margin-right: -8px; color: var(--muted); font-weight: 600; }
.inp .suf { padding-right: 14px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.hint { font-size: 12px; color: var(--faint); min-height: 18px; margin-top: 4px; font-variant-numeric: tabular-nums; }
textarea {
  width: 100%; border: 1px solid var(--line); background: var(--sunk); border-radius: 12px; padding: 12px 14px;
  font-size: 16px; line-height: 1.5; resize: vertical; outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--sunk); font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s, color .2s, border-color .2s; user-select: none;
}
.seg span:hover { border-color: var(--line2); }
.seg input:checked + span { background: var(--text); border-color: var(--text); color: var(--bg); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-size: 15px; font-weight: 500; user-select: none; }
.chk input { position: absolute; opacity: 0; pointer-events: none; }
.sw { position: relative; width: 40px; height: 24px; flex: none; border-radius: 99px; background: var(--line2); transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s ease; }
.chk input:checked + .sw { background: var(--accent); }
.chk input:checked + .sw::after { transform: translateX(16px); }
.chk input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 16px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; font-size: 15px; font-weight: 600;
  transition: border-color .2s, background .2s, transform .15s;
}
.btn:hover { border-color: var(--line2); }
.btn:active { transform: scale(.97); }
.f-btn .btn { width: 100%; background: var(--text); color: var(--bg); border-color: var(--text); }
.spin { animation: spin .5s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

/* result */
.res-main { padding-bottom: 4px; }
.res-label { font-size: 14px; color: var(--muted); font-weight: 500; }
.res-big {
  font-size: clamp(2.3rem, 10vw, 3.2rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.1; margin-top: 6px;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.res-big.is-long { font-size: clamp(1.25rem, 5vw, 1.55rem); letter-spacing: -.01em; line-height: 1.35; }
.res-big.is-mono { font-family: var(--mono); letter-spacing: 0; font-weight: 700; }
.res-big.is-mono:not(.is-long) { font-size: clamp(1.4rem, 6.5vw, 1.9rem); }
.res-big.is-empty { color: var(--faint); }
.res-sub { margin-top: 4px; color: var(--muted); font-size: 15px; font-weight: 500; }
.res-err { margin-top: 6px; font-size: 14px; color: var(--accent-ink); }
.res-text {
  margin-top: 8px; padding: 14px; background: var(--sunk); border-radius: 12px; font-size: 16px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto;
}
.rows { margin: 16px 0 0; }
.rows div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 15px; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bars { margin-top: 18px; }
.bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--sunk); gap: 2px; }
.bar span { height: 100%; transition: width .45s cubic-bezier(.2, .7, .2, 1); }
.bar span:first-child { border-radius: 99px 0 0 99px; }
.bar span:last-child { border-radius: 0 99px 99px 0; }
.b0 { background: var(--b1); } .b1 { background: var(--b2); }
.legend { display: flex; gap: 18px; margin-top: 10px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend div { display: flex; align-items: center; gap: 6px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; }
.legend b { color: var(--text); font-weight: 650; }
.scale { margin-top: 18px; }
.scale-bar { position: relative; display: flex; height: 8px; gap: 2px; }
.scale-bar .sg { height: 100%; border-radius: 99px; opacity: .85; }
.sg0 { background: #6aa9e0; } .sg1 { background: var(--ok); } .sg2 { background: var(--warn); } .sg3 { background: var(--bad); }
.scale-dot {
  position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--text); transition: left .45s cubic-bezier(.2, .7, .2, 1);
}
.scale-lbl { display: flex; margin-top: 8px; font-size: 11px; color: var(--muted); }
.scale-lbl span { text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 20px; }
.actions .btn { padding: 0 8px; }
.actions .btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.actions .btn[aria-pressed="true"] svg { fill: currentColor; }
.disc { font-size: 12px; color: var(--faint); margin: 12px 4px 0; }
.how { margin: 28px 0 0; font-size: 14px; color: var(--muted); max-width: 720px; }
.how b { color: var(--text); font-weight: 650; margin-right: 6px; }
.related { margin-top: 28px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 50; transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* prose pages */
.prose { max-width: 680px; padding: 20px 0 8px; }
.prose h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); font-weight: 800; margin-bottom: 16px; }
.prose h2 { font-size: 18px; margin: 28px 0 8px; }
.prose p, .prose li { color: var(--muted); font-size: 16px; }
.prose a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.prose .date { font-size: 13px; color: var(--faint); }
.mail { display: inline-flex; margin-top: 8px; font-size: 20px; font-weight: 700; color: var(--text) !important; text-decoration: none !important; border-bottom: 2px solid var(--accent); }

/* footer */
.foot { margin-top: 64px; border-top: 1px solid var(--line); padding: 36px 0 28px; font-size: 14px; }
.foot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 16px; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } .foot-grid .fg-money ul { columns: 2; column-gap: 16px; } }
.foot h2 { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.foot ul { list-style: none; margin: 0; padding: 0; }
.foot li { padding: 3px 0; break-inside: avoid; }
.foot a { color: var(--muted); transition: color .2s; }
.foot a:hover { color: var(--text); }
.foot-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--faint); }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }

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

/* compact segmented control when sharing a row with an input */
.half .seg { flex-wrap: nowrap; gap: 4px; }
.half .seg label { flex: 1; min-width: 0; }
.half .seg span { width: 100%; height: 54px; justify-content: center; padding: 0 8px; }
@media (max-width: 400px) { .filters { gap: 2px; } .filters button { padding: 0 12px; } }

.made { margin: 24px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.made .heart { display: inline-block; animation: beat 2.4s ease-in-out infinite; }
@keyframes beat { 0%, 60%, 100% { transform: scale(1); } 30% { transform: scale(1.18); } }

/* FAQs */
.faq { margin-top: 28px; max-width: 720px; }
.faq h2 { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .02em; margin-bottom: 6px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 0; font-size: 15px; font-weight: 600;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; font-size: 20px; font-weight: 400; color: var(--muted); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: -4px 0 14px; color: var(--muted); font-size: 15px; }
