/* ==========================================================================
   Area Converter (/area-converter). Loaded on that page only, after
   css/style.css, whose tokens it uses. A tool like the CBM calculator
   (css/cbm.css): cards on the light background, tabular numbers, one
   orange action per area. Markup: content/area/app.html and js/area/app.js.
   ========================================================================== */

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ico { width: 1.15em; height: 1.15em; flex: none; }
.ac-with-icon { display: flex; align-items: flex-start; gap: .5rem; }
.ac-with-icon > .ico { margin-top: .15em; }

/* ---------- Hero ---------- */
.ac-hero .page-intro { max-width: 42rem; }
.ac-points { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin: 1.25rem 0 0; padding: 0; font: 500 .9375rem/1.4 var(--f-body); color: var(--ink-2); }
.ac-points li { display: inline-flex; align-items: center; gap: .45rem; }
.ac-points li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--sun); flex: none; }

/* ---------- Layout ---------- */
.ac-shell { padding: clamp(1.5rem, 4vw, 2.5rem) 0 clamp(2rem, 5vw, 3rem); }
.ac-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; scroll-margin-top: calc(var(--header-h) + 16px); }
.ac-card {
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.ac-h { margin: 0; font-size: 1.25rem; line-height: 1.3; letter-spacing: -.01em; }
.ac-hint { margin: .35rem 0 0; font-size: .875rem; line-height: 1.45; color: var(--muted); }
.ac-label { margin: 0 0 .5rem; font: 600 .9375rem/1.3 var(--f-body); color: var(--ink); }
.ac-alert { padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--sun); }
.ac-textbtn { display: inline; min-height: 24px; padding: .15rem 0; border: 0; background: none; color: var(--sun-ink); font-family: var(--f-body); font-size: inherit; font-weight: 600; line-height: 1.4; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ac-textbtn:hover { color: var(--ink); }

/* ---------- Calculator ---------- */
.ac-calc .field { margin-bottom: 0; }
.ac-calc #ac-region-note { margin-top: .5rem; }
.ac-calc #ac-region-note .ico { color: var(--teal-deep); }
.ac-pair { display: grid; gap: .5rem; margin-top: 1.5rem; }
.ac-io { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 14.5rem); gap: .5rem; }
.ac-shell .field select { padding-right: 2.25rem; background-position: right .7rem center; font-weight: 600; }
.ac-num { min-height: 3.5rem; background: var(--surface) !important; font: 700 1.5rem/1.2 var(--f-display) !important; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.ac-num.ac-passive { background: var(--bg-alt) !important; }
.field input[aria-invalid="true"] { border-color: var(--alarm); background: #FFF6F5; }
.ac-swap-row { display: flex; align-items: center; gap: .75rem; }
.ac-swap-row > span { flex: 1; height: 1px; background: var(--line); }
.ac-swap {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm); cursor: pointer; transition: border-color .2s, background-color .2s;
}
.ac-swap:hover { border-color: var(--rail); background: var(--well); }
.ac-swap .ico { width: 20px; height: 20px; }
.ac-msg { margin: .5rem 0 0; font-size: .875rem; line-height: 1.45; color: var(--muted); }
.ac-msg-error { padding: .5rem .75rem; border: 1px solid rgba(180, 35, 24, .3); border-radius: var(--r); background: #FFF6F5; color: var(--alarm); font-weight: 600; }
.ac-notice { margin: .75rem 0 0; padding: .55rem .75rem; border: 1px solid #BFE3EA; border-radius: var(--r); background: #EEF7F9; font-size: .875rem; line-height: 1.45; color: var(--ink-2); }
.ac-notice .ico { color: var(--teal-deep); }
.ac-summary { margin: .75rem 0 0; padding: .65rem .8rem; border-radius: var(--r); background: var(--bg-alt); font-size: .9375rem; line-height: 1.45; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ac-summary strong { color: var(--ink); }
.ac-approx { display: block; margin-top: .2rem; font-size: .8125rem; color: var(--brown); }
.ac-presets { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.ac-presets ul { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; }
.ac-chip {
  min-height: 40px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font: 500 .875rem/1 var(--f-body); font-variant-numeric: tabular-nums; cursor: pointer;
  transition: border-color .2s, background-color .2s, color .2s;
}
.ac-chip:hover { border-color: var(--sun); background: #FFF1EA; color: var(--ink); }
.ac-chip-local { border-color: #BFE3EA; background: #EEF7F9; color: var(--ink); }
.ac-chip-local span { color: var(--muted); }
.ac-chip-local:hover { border-color: var(--teal-deep); background: #EEF7F9; }

/* ---------- Results ---------- */
.ac-results { padding: 0; overflow: hidden; }
.ac-results-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .5rem; padding: 1.25rem clamp(1rem, 2.5vw, 1.5rem) .75rem; }
.ac-badge { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-alt); font: 600 .75rem/1.3 var(--f-body); color: var(--ink-2); }
.ac-table { width: 100%; border-collapse: collapse; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.ac-table th, .ac-table td { padding: .6rem .5rem; border-top: 1px solid var(--line); vertical-align: middle; }
.ac-table tr > :first-child { padding-left: clamp(1rem, 2.5vw, 1.5rem); text-align: left; font-weight: 400; }
.ac-table tr > :last-child { padding-right: clamp(.75rem, 2vw, 1.25rem); }
.ac-section th { padding-top: .8rem; padding-bottom: .35rem; background: var(--bg-alt); }
.ac-section span { font: 700 .75rem/1.3 var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ac-section small { display: block; margin-top: .15rem; font-size: .8125rem; color: var(--muted); }
.ac-src { background: #FFF6F0; }
.ac-unit-name { display: block; font-weight: 600; color: var(--ink); }
.ac-unit-meta { display: block; font-size: .8125rem; color: var(--muted); }
.ac-varies { display: inline-flex; align-items: center; gap: .3rem; margin-top: .3rem; padding: .1rem .5rem; border-radius: 999px; background: #FEF3DC; font: 600 .6875rem/1.4 var(--f-body); color: var(--brown); }
.ac-varies .ico { width: 12px; height: 12px; }
.ac-value { text-align: right; white-space: nowrap; font: 700 1.125rem/1.3 var(--f-display); color: var(--ink); }
.ac-value-long { white-space: normal; overflow-wrap: anywhere; font-size: .9375rem; }
.ac-copy-cell { width: 1%; text-align: right; }
.ac-copy {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-width: 40px; min-height: 40px; padding: 0 .65rem;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink-2);
  font: 600 .8125rem/1 var(--f-body); cursor: pointer; transition: border-color .2s, background-color .2s;
}
.ac-copy:hover { border-color: var(--rail); background: var(--well); color: var(--ink); }
.ac-copy.is-done { border-color: rgba(18, 112, 26, .4); background: #EDF7EE; color: var(--ok); }
.ac-copy.is-failed { border-color: rgba(180, 35, 24, .4); background: #FFF6F5; color: var(--alarm); }
.ac-records { margin: 0; padding: .8rem clamp(1rem, 2.5vw, 1.5rem); border-top: 1px solid var(--line); background: var(--bg-alt); font-size: .875rem; color: var(--ink-2); }
.ac-records b { font: 700 1rem/1.3 var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.ac-records small { display: block; color: var(--muted); }
.ac-more { border-top: 1px solid var(--line); }
.ac-more summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 clamp(1rem, 2.5vw, 1.5rem); font: 600 .875rem/1.3 var(--f-body); color: var(--ink-2); cursor: pointer; list-style: none; }
.ac-more summary::-webkit-details-marker { display: none; }
.ac-more summary::after { content: "▾"; font-size: .75rem; color: var(--muted); transition: transform .2s; }
.ac-more[open] summary::after { transform: rotate(180deg); }
.ac-more summary:hover { background: var(--well); }
.ac-empty { padding: 2.25rem clamp(1rem, 2.5vw, 1.5rem); border-top: 1px solid var(--line); text-align: center; }
.ac-empty-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: #EEF7F9; color: var(--teal-deep); }
.ac-empty-icon .ico { width: 24px; height: 24px; }
.ac-empty-title { margin: .75rem 0 0; font-weight: 600; color: var(--ink); }
.ac-empty-tries { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: 1rem; }
.ac-share { padding: 1rem clamp(1rem, 2.5vw, 1.5rem) 1.25rem; border-top: 1px solid var(--line); }
.ac-share-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.ac-share-row .btn { gap: .45rem; }
.ac-wa { background: #1FA855; border-color: #1FA855; color: #fff; }
.ac-wa:hover { background: #178A45; border-color: #178A45; color: #fff; }
.ac-wa.is-disabled { background: var(--well); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.ac-share .is-ok { color: var(--ok); font-weight: 600; }

/* ---------- Recent conversions ---------- */
.ac-history { margin-top: 1.5rem; }
.ac-history-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.ac-history-head .ac-h { font-size: 1.05rem; align-items: center; }
.ac-history-head .ico { color: var(--teal-deep); }
.ac-history ul { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0 0; padding: 0; }
.ac-history-item { min-height: 40px; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--ink-2); font: 400 .875rem/1.35 var(--f-body); font-variant-numeric: tabular-nums; text-align: left; cursor: pointer; }
.ac-history-item strong { color: var(--ink); }
.ac-history-item span { color: var(--muted); }
.ac-history-item:hover { border-color: var(--rail); background: var(--well); }

/* ---------- Compare two areas ---------- */
.ac-compare { margin-top: 2rem; }
.ac-compare-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.ac-compare-head .ac-h { align-items: center; }
.ac-compare-head .ac-h .ico { width: 24px; height: 24px; color: var(--teal-deep); }
.ac-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.25rem; }
.ac-compare-grid .field { margin-bottom: 0; min-width: 0; }
.ac-io-sm { grid-template-columns: minmax(0, 1fr) minmax(0, 13.5rem); }
.ac-err { margin: .35rem 0 0; font-size: .8125rem; font-weight: 600; color: var(--alarm); }
.ac-compare-out { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 1rem; align-items: start; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.ac-compare-out .field { margin-bottom: 0; }
.ac-placeholder { margin: 0; padding: 1rem; border: 1px dashed var(--line-strong); border-radius: var(--r); font-size: .875rem; color: var(--muted); }
.ac-compare-dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .35rem 1rem; margin: 0; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.ac-compare-dl dt { color: var(--muted); }
.ac-compare-dl dd { margin: 0; text-align: right; font-weight: 600; color: var(--ink); }
.ac-compare-dl .ac-diff { padding-top: .35rem; border-top: 1px solid var(--line); }
.ac-compare-dl dd.ac-diff { font-weight: 700; }
.ac-verdict { margin: .75rem 0 0; padding: .6rem .8rem; border-radius: var(--r); background: var(--bg-alt); font-weight: 600; color: var(--ink); }

/* ---------- Below the calculator ---------- */
.ac-disclaimer { max-width: 52rem; margin: 1.5rem 0 0; font-size: .8125rem; line-height: 1.55; color: var(--muted); }
.ac-popular { margin-top: 2rem; }
.ac-popular ul { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .1rem 1.5rem; margin: .6rem 0 0; padding: 0; }
.ac-popular a { display: inline-block; padding: .4rem 0; color: var(--sun-ink); font-weight: 500; text-underline-offset: 3px; }
.ac-guide { border-top: 1px solid var(--line); }

/* The guide's tables (inside .prose, which scrolls tables sideways on phones) */
.prose .ac-num-table td, .prose .ac-num-table th[scope="row"] { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prose .ac-num-table thead th { white-space: nowrap; }
.prose .ac-unit-table td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.prose .ac-unit-table td:nth-child(2), .prose .ac-unit-table td:nth-child(3) { text-align: right; }
.prose .ac-unit-table th[scope="row"] { min-width: 15rem; background: var(--surface); font-weight: 600; }
.prose .ac-unit-table th small { display: block; margin-top: .2rem; font-size: .8125rem; font-weight: 400; line-height: 1.45; color: var(--muted); }
.prose .ac-group th { background: var(--bg-alt); font-size: .8125rem; letter-spacing: .06em; text-transform: uppercase; }
.ac-tag { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font: 600 .75rem/1.5 var(--f-body); white-space: nowrap; }
.ac-tag-standard { background: #EDF7EE; color: var(--ok); }
.ac-tag-common { background: #EEF7F9; color: var(--sun-ink); }
.ac-tag-varies { background: #FEF3DC; color: var(--brown); }
.prose .ac-sources { font-size: .9375rem; }

/* ---------- Smaller screens ---------- */
@media (max-width: 900px) {
  .ac-layout { grid-template-columns: 1fr; }
  .ac-compare-out { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .ac-io, .ac-io-sm { grid-template-columns: 1fr; }
  .ac-compare-grid { grid-template-columns: 1fr; }
  .ac-copy span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ac-value { font-size: 1rem; }
}
@media print {
  .ac-share, .ac-presets, .ac-copy-cell, .ac-history, .ac-compare, .ac-swap-row, .more-tools { display: none !important; }
}
