/* CalculatorGo: "Passbook" design. Cream ledger page on green security-print paper. */
:root {
  --paper: #fbf7ea;
  --ink: #17352b;
  --muted: #4d6b5f;
  --green: #1f5f4a;
  --red: #9b1c1c;
  --ground: #dcebe3;
  --serif: "Libre Caslon Text", Georgia, "Times New Roman", serif;
  --mono: "Overpass Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Hind", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--ground);
  background-image:
    repeating-radial-gradient(circle at 12% 18%, transparent 0 9px, rgba(31, 95, 74, 0.1) 9px 10px),
    repeating-radial-gradient(circle at 88% 82%, transparent 0 11px, rgba(31, 95, 74, 0.08) 11px 12px);
  background-attachment: fixed;
  color: var(--ink);
  font: 18px/1.65 var(--sans);
}
a { color: var(--green); }
a:hover { color: var(--red); }
.wrap { width: min(1060px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 10; }

/* Header */
.site-header .bar-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px 24px; padding: 22px 0 18px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 28px; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand small { font-weight: 400; font-style: italic; font-size: 15px; color: var(--muted); margin-left: 8px; }
.site-header nav { display: flex; gap: 6px 22px; flex-wrap: wrap; font-weight: 500; font-size: 16px; }
.site-header nav a { color: var(--ink); text-decoration: none; }
.site-header nav a:hover { color: var(--red); text-decoration: underline; }

main { padding: 4px 0 56px; }

/* The passbook page */
.sheet { background: var(--paper); border: 2px solid var(--ink); box-shadow: 0 10px 0 rgba(23, 53, 43, 0.18); }
.sheet-head { padding: 26px 36px 22px; border-bottom: 2px solid var(--ink); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 18px; }
.sheet-head > div:first-child { min-width: 0; flex: 1 1 360px; }
.crumbs { font: 12px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--red); text-decoration: underline; }
h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(34px, 5.2vw, 58px); line-height: 1.06; letter-spacing: -0.015em; margin: 6px 0 0; }
.lead { font-size: 19px; line-height: 1.55; color: #2b4a3f; max-width: 62ch; margin: 12px 0 0; }
.stamp { transform: rotate(-6deg); border: 3px solid var(--red); color: var(--red); padding: 6px 18px; font: 600 20px var(--mono); letter-spacing: 0.14em; border-radius: 6px; opacity: 0.85; user-select: none; flex: 0 0 auto; width: max-content; align-self: flex-end; margin: 0 6px 6px auto; }
.control input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.control input::-webkit-outer-spin-button, .control input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Calculator */
.calc { display: flex; flex-wrap: wrap; }
.calc-in { flex: 1 1 420px; min-width: 0; padding: 22px 36px 26px; border-right: 2px solid var(--ink); }
.calc-out { flex: 1 1 380px; min-width: 0; padding: 26px 36px; background: repeating-linear-gradient(180deg, transparent 0, transparent 35px, rgba(23, 53, 43, 0.08) 35px, rgba(23, 53, 43, 0.08) 36px); }
@media (max-width: 860px) { .calc-in { border-right: 0; border-bottom: 2px solid var(--ink); } }
@media (max-width: 560px) { .sheet-head, .calc-in, .calc-out, .prose { padding-left: 20px; padding-right: 20px; } }

.field { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 12px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--ink); }
.field:focus-within { border-bottom-color: var(--green); box-shadow: 0 1px 0 var(--green); }
@media (max-width: 520px) { .field { grid-template-columns: minmax(0, 1fr); } }
.field label { font: 600 12.5px/1.3 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
.control { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.control input, .control select { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 700 30px/1.25 var(--serif); padding: 0; outline: none; border-radius: 0; }
.control select { font-size: 19px; line-height: 1.4; padding: 4px 0; cursor: pointer; text-overflow: ellipsis; }
.control input[type="date"] { font-size: 22px; }
.affix { font: 400 22px var(--serif); color: var(--muted); }

.rl { font: 12px/1.4 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.result-main { display: flex; flex-direction: column; gap: 0; }
.rv { font-family: var(--serif); font-weight: 700; font-size: clamp(40px, 8.4vw, 84px); line-height: 1.1; letter-spacing: -0.02em; color: var(--green); white-space: nowrap; overflow: hidden; }
.result-list { margin: 12px 0 0; font: 14.5px/1.4 var(--mono); }
.result-list div { display: flex; justify-content: space-between; gap: 18px; padding: 7px 0; }
.result-list div:last-child { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 9px; font-weight: 600; }
.result-list dt { text-transform: uppercase; letter-spacing: 0.03em; }
.result-list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.result-error { color: var(--red); font-weight: 600; margin: 0; }
.bar { display: flex; height: 12px; border: 1px solid var(--ink); margin-top: 20px; }
.bar i { display: block; height: 100%; }
.seg-a { background: var(--ink); }
.seg-b { background: repeating-linear-gradient(45deg, var(--red), var(--red) 3px, var(--paper) 3px, var(--paper) 6px); }
.legend { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; font: 12.5px var(--mono); color: var(--muted); margin-top: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 1px solid var(--ink); }

/* Article inside the sheet */
.prose { padding: 8px 36px 30px; border-top: 2px solid var(--ink); }
.prose > * { max-width: 780px; }
.prose h2 { font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1.25; margin: 34px 0 8px; }
.prose p, .prose li { margin: 0 0 12px; }
.prose ol { padding-left: 24px; }
.formula { font: italic 400 21px/1.5 var(--serif); border-left: 3px solid var(--red); padding: 4px 0 4px 16px; margin: 6px 0 14px; color: #1d4637; }
.note { font-size: 14.5px; color: var(--muted); margin-top: 26px !important; }

.ledger-wrap { overflow-x: auto; max-width: 100% !important; margin: 10px 0 8px; }
table.ledger, table.example { width: 100%; border-collapse: collapse; font: 14.5px/1.4 var(--mono); min-width: 520px; }
table.example { min-width: 0; }
.ledger th, .example th { background: var(--ink); color: var(--paper); text-align: right; padding: 9px 14px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; font-size: 12.5px; }
.ledger th:first-child, .example th { text-align: left; }
.ledger td, .example td { padding: 8px 14px; border-bottom: 1px solid var(--ink); text-align: right; }
.ledger td:first-child, .example td:first-child { text-align: left; }
.example td:last-child { font-weight: 600; }
.ledger tbody tr:nth-child(even) { background: rgba(23, 53, 43, 0.05); }
.ledger-note { font-size: 14.5px; color: var(--muted); }

.faq details { border-bottom: 1px solid var(--ink); padding: 12px 0; }
.faq summary { cursor: pointer; font: 700 18px/1.4 var(--serif); }
.faq p { margin: 8px 0 2px; color: #2b4a3f; }

/* Cards / lists */
.related, .cat { padding: 0 36px 30px; }
.related h2, .cat-head h2 { font-family: var(--serif); font-weight: 700; font-size: 26px; margin: 0 0 12px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 3px; background: var(--paper); border: 1.5px solid var(--ink); padding: 14px 18px; text-decoration: none; color: var(--ink); transition: transform 0.12s, box-shadow 0.12s; }
.card:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); color: var(--ink); }
.card strong { font: 700 18px/1.3 var(--serif); }
.card span { font-size: 15px; line-height: 1.5; color: var(--muted); }
.cat { padding-top: 26px; border-top: 2px solid var(--ink); }
.cat-head h2 a { color: inherit; text-decoration: none; }
.cat-head h2 a:hover { text-decoration: underline; }
.cat-head p { margin: 0 0 14px; color: var(--muted); }
.hero { padding: 26px 36px 28px; }
.hero h1 { margin-top: 0; }
.search { width: 100%; max-width: 520px; font: 18px var(--sans); padding: 12px 14px; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); margin-top: 18px; border-radius: 0; }
.search:focus { outline: 3px solid rgba(31, 95, 74, 0.35); }
.muted { color: var(--muted); }
.page-body { padding: 8px 36px 30px; }
.list-top { padding: 22px 36px 8px; }

/* Footer */
.site-footer { background: var(--ink); color: #cfe0d6; padding: 32px 0; font-size: 16px; }
.site-footer a { color: #f0e6c8; }
.foot-grid { display: grid; gap: 24px; grid-template-columns: 1.4fr 1fr 1fr; }
@media (max-width: 700px) { .foot-grid { grid-template-columns: 1fr; } }
.foot-grid ul { list-style: none; padding: 0; margin: 8px 0 0; }
.foot-grid li { margin-bottom: 4px; }
.foot-grid strong { color: #fbf7ea; font-family: var(--serif); font-size: 18px; }
.foot-grid p { margin: 8px 0 0; }
.copy { margin: 24px 0 0; font-size: 14px; color: #9db8aa; }

.prose.page{border-top:0;padding-top:26px}
.prose.page h1{font-size:44px}

.control input.txt { font-size: 22px; font-family: var(--mono); font-weight: 600; letter-spacing: 0; }

.curpick select { font-size: 16px; font-family: var(--mono); font-weight: 600; }
.curpick label { color: var(--muted); }

/* Mobile (kept last so it wins over the desktop rules above) */
@media (max-width: 700px) {
  body { font-size: 17px; }
  .wrap { width: calc(100% - 24px); }
  .site-header .bar-row { padding: 14px 0 12px; gap: 6px 16px; }
  .brand { font-size: 24px; }
  .brand small { display: block; margin: 0; font-size: 13px; }
  .site-header nav { gap: 2px 16px; font-size: 15px; }
  .sheet-head, .calc-in, .calc-out, .prose, .related, .cat, .hero, .page-body, .list-top { padding-left: 18px; padding-right: 18px; }
  .sheet-head { padding-top: 18px; padding-bottom: 16px; }
  .stamp { display: none; }
  h1 { font-size: 34px; }
  .lead { font-size: 16px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .hero .lead, .sheet-head .lead.full { -webkit-line-clamp: unset; display: block; }
  .calc-in { padding-top: 8px; padding-bottom: 14px; }
  .field { padding: 10px 0; }
  .control input { font-size: 28px; }
  .calc-out { padding-top: 18px; padding-bottom: 20px; }
  .rv { font-size: 46px; }
  .prose h2 { font-size: 23px; margin-top: 28px; }
  .formula { font-size: 18px; }
  table.ledger, table.example { font-size: 13px; }
  .ledger th, .example th, .ledger td, .example td { padding: 7px 8px; }
  .related h2, .cat-head h2 { font-size: 23px; }
  .card { padding: 12px 14px; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .search { max-width: none; }
}

/* Ad slots: hidden until ads are switched on (build with ADS=1 to preview). */
.ad-slot[hidden] { display: none; }
.ad-slot { display: flex; align-items: center; justify-content: center; position: relative; margin: 28px auto; width: 100%; max-width: 728px; min-height: 250px; border: 1px dashed var(--line, #c9c2b4); background: transparent; overflow: hidden; clear: both; }
.ad-slot--top { min-height: 100px; }
.ad-slot .ad-label { position: absolute; top: 4px; left: 8px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; opacity: .55; }
