/* casa-mai-ieftina: the city as a price list of the commute. Cool slate paper, a teal-to-ember ramp, receipts for the verdict. */
:root {
  --bg: #eef2f5; --bg-2: #e3e9ee; --card: #f8fafb; --ink: #121821; --mut: #45505e; --line: #cdd6de; --line-soft: #dde4ea;
  --acc: #b3303f; --acc-ink: #8f1f30; --link: #1d4f86; --ok: #0f6b5c;
  --map-bg: #e6ebef; --map-water: #b4cad8; --map-park: #d3dfd5; --map-road: #8b97a3; --map-road2: #a9b3bd; --map-rail: #6f7b88;
  --map-uat: #59636f; --map-label: #121821; --map-halo: rgba(246, 248, 250, .92);
  --pw: #1f2937; --pw2: #5b3fb5; --pa: #0f6b5c; --pb: #b3303f;
  --receipt: #fbfcfd; --receipt-line: #c9d2da;
  --topbar: 48px; --serif: 'Fraunces', Georgia, serif; --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --shadow: 0 1px 0 rgba(18, 24, 33, .05), 0 14px 34px -16px rgba(18, 24, 33, .32);
  color-scheme: light;
}
:root.dark {
  --bg: #0b0f17; --bg-2: #111827; --card: #121a27; --ink: #eef1f5; --mut: #b6bfcb; --line: #283345; --line-soft: #1d2636;
  --acc: #ff7a8f; --acc-ink: #ffa3b1; --link: #9cc4ff; --ok: #52d1b8;
  --map-bg: #0d131d; --map-water: #18324a; --map-park: #13241f; --map-road: #4a5668; --map-road2: #333d4d; --map-rail: #6b7789;
  --map-uat: #8a96a8; --map-label: #f2f4f7; --map-halo: rgba(11, 15, 23, .9);
  --pw: #eef1f5; --pw2: #b9a3ff; --pa: #52d1b8; --pb: #ff7a8f;
  --receipt: #111925; --receipt-line: #2b3648;
  --shadow: 0 1px 0 rgba(0, 0, 0, .4), 0 16px 38px -16px rgba(0, 0, 0, .8);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar) + 12px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--sans); overflow-anchor: none; }
a { color: var(--link); text-underline-offset: 2px; }
.mut { color: var(--mut); }
.small { font-size: 14.5px; }
.skip { position: absolute; left: -9999px; top: 0; z-index: 99; background: var(--ink); color: var(--bg); padding: 8px 12px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
button { font: inherit; color: inherit; }

/* topbar */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--topbar); display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font: 500 14px/1 var(--sans); border-bottom: 1px solid var(--line-soft); }
.home { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 600; white-space: nowrap; }
.motif { width: 22px; height: 22px; flex: none; }
.topnav { display: flex; gap: 16px; overflow: hidden; }
.topnav a { color: var(--mut); text-decoration: none; white-space: nowrap; }
.topnav a:hover { color: var(--ink); }
.spacer { flex: 1; }
.lang { color: var(--ink); text-decoration: none; font-weight: 600; padding: 6px 4px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer; flex: none; font-size: 18px; line-height: 1; }
.icon-btn:hover { border-color: var(--ink); }
.icon-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.progress { position: sticky; top: var(--topbar); z-index: 39; height: 2px; margin-top: -2px; pointer-events: none; overflow: hidden; }
.progress span { display: block; height: 2px; width: 100%; background: linear-gradient(90deg, #1d7f79, #e9b04e, #c4413a); transform: translateX(-100%); }
@media (max-width: 860px) { .topnav { display: none; } }

/* ---------- the tool ---------- */
.tool { display: grid; grid-template-columns: minmax(380px, 470px) 1fr; min-height: calc(100svh - var(--topbar)); }
.panel { padding: 30px 28px 40px; border-right: 1px solid var(--line-soft); }
.kicker { font: 600 12.5px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--acc); margin: 0 0 12px; }
h1 { font: 600 clamp(30px, 3.1vw, 42px)/1.08 var(--serif); letter-spacing: -.015em; margin: 0 0 14px; font-variation-settings: 'opsz' 96; text-wrap: balance; }
h1 em { font-style: italic; color: var(--acc); font-weight: 500; }
.deck { font-size: 17.5px; color: var(--mut); margin: 0 0 22px; text-wrap: pretty; }
.fs { border: 0; padding: 0; margin: 0 0 18px; }
.fs > legend, .step { font: 600 12.5px/1.2 var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--mut); margin: 0 0 10px; padding: 0; display: flex; align-items: center; gap: 8px; }
.step b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 11px; letter-spacing: 0; }
.slot { position: relative; margin: 0 0 10px; }
.slot > label { display: flex; align-items: center; gap: 8px; font: 600 14.5px/1.3 var(--sans); margin-bottom: 6px; }
.badge { width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; font: 700 11.5px/1 var(--sans); color: #fff; flex: none; }
:root.dark .badge { color: #0b0f17; }
.badge.w0 { background: var(--pw); } .badge.w1 { background: var(--pw2); } .badge.a { background: var(--pa); } .badge.b { background: var(--pb); }
:root:not(.dark) .badge.w0 { color: #fff; }
.qwrap { display: flex; gap: 6px; }
.qwrap input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: 15.5px var(--sans); }
.qwrap input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 25%, transparent); }
.qwrap .icon-btn { width: 42px; height: 42px; border-radius: 10px; }
.sugg { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 300px; overflow: auto; }
.sugg li { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 15px; line-height: 1.3; }
.sugg li small { display: block; color: var(--mut); font-size: 12.5px; }
.sugg li[aria-selected=true], .sugg li:hover { background: var(--bg-2); }
.note { margin: 6px 0 0; font-size: 13.5px; color: var(--acc-ink); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--mut); align-items: flex-start; }
.field input[type=text], .field input[type=number], .field input[inputmode] { height: 38px; width: 120px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink); font: 500 15.5px var(--mono); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 0 11px; height: 36px; cursor: pointer; font-size: 14px; color: var(--mut); min-width: 36px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--bg); font-weight: 600; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.presets button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--mut); }
.presets button:hover { color: var(--ink); border-color: var(--ink); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); border-radius: 999px; padding: 8px 15px; font: 600 14px/1.1 var(--sans); cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.small { padding: 6px 12px; font-size: 13.5px; }
.linkish { border: 0; background: none; padding: 0; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-size: 14px; }
.car { margin: 8px 0 0; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13.5px; color: var(--mut); }
.car [data-e] { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.car [data-e] + [data-e] { margin-top: 6px; }
.car input { width: 70px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); font: 500 15px var(--mono); }
.e2 { border-left: 3px solid var(--pw2); padding-left: 10px; }

/* verdict: a receipt */
.verdict { position: relative; margin: 22px 0 18px; padding: 20px 20px 16px; background: var(--receipt); border: 1px solid var(--receipt-line); border-radius: 4px; box-shadow: var(--shadow); }
.verdict::after { content: ''; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px; background: radial-gradient(circle at 6px -2px, transparent 6px, var(--receipt) 6.5px) 0 0 / 12px 8px repeat-x; filter: drop-shadow(0 1px 0 var(--receipt-line)); }
.v-head { font: 500 20px/1.35 var(--serif); margin: 0 0 8px; text-wrap: balance; }
.v-big { display: block; font: 700 clamp(36px, 4vw, 48px)/1.05 var(--serif); color: var(--acc); letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: lining-nums; }
.v-buy { margin: 0 0 6px; font-size: 16px; }
.v-split { margin: 0 0 12px; font-size: 14px; color: var(--mut); }
.v-empty { margin: 0; color: var(--mut); }
.v-foot { margin: 10px 0 0; font-size: 12.5px; color: var(--mut); }
.ledger { width: 100%; border-collapse: collapse; font: 14px/1.35 var(--sans); }
.ledger th, .ledger td { padding: 6px 4px; border-top: 1px dashed var(--receipt-line); text-align: right; font-variant-numeric: tabular-nums; }
.ledger th[scope=row] { text-align: left; font-weight: 400; color: var(--mut); }
.ledger thead th { border-top: 0; font-weight: 600; font-size: 13px; vertical-align: bottom; }
.ledger td { font-family: var(--mono); font-size: 13.5px; white-space: nowrap; }
.ledger tr.tot th, .ledger tr.tot td { border-top: 1.5px solid var(--ink); font-weight: 700; color: var(--ink); }
.ledger tr.sub th, .ledger tr.sub td { border-top: 0; font-size: 12.5px; padding-top: 0; }
.hk { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; font: 700 10.5px/1 var(--sans); color: #fff; vertical-align: 1px; }
:root.dark .hk { color: #0b0f17; }
.hk.a { background: var(--pa); } .hk.b { background: var(--pb); }
.who { font-weight: 600; font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; }
.who.w0 { color: var(--ink); } .who.w1 { color: var(--pw2); }
.share-mine { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 18px; }
.status { font-size: 13px; color: var(--mut); margin: 6px 0 0; min-height: 1em; }
.yearbox { margin: 26px 0 0; }
.yearbox h3 { font: 600 16px/1.3 var(--sans); margin: 0 0 10px; }
.yr { margin: 0 0 12px; }
.yr p { margin: 0 0 6px; font-size: 14px; }
.cells { display: grid; grid-template-columns: repeat(53, 1fr); gap: 1.5px; }
.cells i { aspect-ratio: 1; background: var(--line-soft); border-radius: 1px; }
.cells i.on.a { background: var(--pa); } .cells i.on.b { background: var(--pb); }
details.assume { margin: 18px 0 0; border-top: 1px solid var(--line-soft); padding-top: 12px; }
details.assume summary { cursor: pointer; font-weight: 600; font-size: 15px; }
details.assume .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; margin-top: 12px; }
details.assume .field.wide { grid-column: 1 / -1; }
details.assume input[type=range] { width: 100%; accent-color: var(--acc); }
details.assume .hint { font-size: 12.5px; color: var(--mut); line-height: 1.4; }
details.assume output { font: 600 14px var(--mono); color: var(--ink); }

/* the map */
.stage { position: sticky; top: var(--topbar); height: calc(100svh - var(--topbar)); margin: 0; background: var(--map-bg); overflow: hidden; touch-action: none; }
#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map.drag { cursor: grabbing; } #map.placing { cursor: crosshair; } #map.over-pin { cursor: move; }
.map-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; align-items: center; }
.map-tools .icon-btn, .map-tools .btn { background: var(--card); box-shadow: var(--shadow); }
.tool { grid-template-areas: 'panel map'; }
.panel { grid-area: panel; } .stage { grid-area: map; }
.mapmode { grid-area: map; position: sticky; top: calc(var(--topbar) + 12px); align-self: start; justify-self: start; margin-left: 12px; z-index: 3; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; height: 0; overflow: visible; }
.mapmode .seg { background: var(--card); box-shadow: var(--shadow); }
.legend { position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.legend .lg-t { font: 600 12.5px/1.3 var(--sans); background: var(--map-halo); padding: 3px 7px; border-radius: 6px; align-self: flex-start; }
.legend .lg-r { display: flex; align-items: flex-end; gap: 0; max-width: 520px; background: var(--map-halo); padding: 6px 8px 4px; border-radius: 8px; }
.lg-c { flex: 1; height: 10px; position: relative; }
.lg-c i, .lg-end { position: absolute; top: 12px; left: 0; transform: translateX(-50%); font: 500 10.5px/1 var(--mono); font-style: normal; color: var(--ink); white-space: nowrap; }
.lg-c:first-child i { transform: none; }
.lg-end { position: static; transform: none; margin-left: 6px; padding-bottom: 1px; }
.legend .lg-r { padding-bottom: 20px; }
.mini { position: absolute; right: 12px; top: 60px; max-width: 240px; background: var(--receipt); border: 1px solid var(--receipt-line); border-radius: 6px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 13.5px; line-height: 1.35; }
.mini b { display: block; font: 700 24px/1.1 var(--serif); color: var(--acc); }
.placing-hint, .busy { position: absolute; left: 50%; top: 58px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 7px 12px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--shadow); white-space: nowrap; }
.nomap { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--mut); margin: 0; }
.pop { position: absolute; z-index: 5; width: 270px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 14px; line-height: 1.4; }
.pop h4 { margin: 0 24px 4px 0; font: 600 15px/1.25 var(--sans); }
.pop .x { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--mut); width: 28px; height: 28px; }
.pop .c-v { margin: 0 0 8px; font: 600 15.5px/1.3 var(--serif); color: var(--acc); }
.pop .r { display: flex; flex-direction: column; margin: 0 0 6px; font-size: 13.5px; color: var(--mut); }
.pop .c-act { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- reading sections ---------- */
.block { padding: 64px 0 8px; }
.wrap { max-width: 42rem; margin: 0 auto; padding: 0 20px; }
.wide { max-width: 62rem; margin: 18px auto; padding: 0 20px; }
h2 { font: 600 clamp(25px, 2.6vw, 32px)/1.15 var(--serif); letter-spacing: -.01em; margin: 0 0 16px; text-wrap: balance; position: relative; }
h2 .anchor { position: absolute; left: -1.1em; color: var(--line); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h2 .anchor:focus { opacity: 1; }
h3 { font: 600 18px/1.3 var(--sans); margin: 26px 0 8px; }
.block p { margin: 0 0 14px; text-wrap: pretty; }
.towns { width: 100%; border-collapse: collapse; font-size: 15px; }
.towns th, .towns td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); text-align: right; font-variant-numeric: tabular-nums; }
.towns th:first-child, .towns td:first-child { text-align: left; }
.towns thead th { font-size: 13px; color: var(--mut); font-weight: 600; border-bottom: 1.5px solid var(--ink); vertical-align: bottom; }
.towns .bar { display: inline-block; height: 8px; border-radius: 2px; background: var(--acc); vertical-align: middle; margin-right: 6px; opacity: .85; }
.towns tr.buc td { font-weight: 600; background: var(--bg-2); }
.scrollx { overflow-x: auto; }
.fig { margin: 0; }
.fig figcaption { font-size: 14px; color: var(--mut); margin: 0 0 10px; }
.formula { font: 500 15px/1.6 var(--mono); background: var(--card); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.manual { background: var(--card); border: 1px solid var(--line-soft); border-radius: 14px; padding: 18px; }
.manual .row .field input { width: 110px; }
.sources { padding-left: 18px; font-size: 15px; }
.sources li { margin: 0 0 8px; }
.page-share { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.share-row .lbl { font-size: 13.5px; color: var(--mut); margin-right: 2px; }
.share-row a, .share-row button { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 1px solid var(--line-soft); border-radius: 999px; color: var(--ink); background: transparent; cursor: pointer; }
.share-row a:hover, .share-row button:hover { border-color: var(--acc); color: var(--acc); }
.share-row svg { width: 18px; height: 18px; }
@media (pointer: coarse) { .share-row a, .share-row button { width: 44px; height: 44px; } }
footer { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; padding: 40px 20px 60px; font-size: 14px; color: var(--mut); border-top: 1px solid var(--line-soft); margin-top: 60px; }
footer a { color: var(--mut); }

/* phones and narrow windows: text first, the map as a band, never under the text */
@media (max-width: 1023px) {
  .tool { display: flex; flex-direction: column; min-height: 0; }
  .panel { display: contents; }
  .intro { order: 1; padding: 22px 16px 6px; }
  .stage { order: 2; position: relative; top: auto; height: min(40svh, 380px); min-height: 260px; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
  .inputs { padding: 16px 16px 0; }
  .result { padding: 0 16px 10px; }
  .legend .lg-r { max-width: none; }
  .mini { display: none; }
  .mapmode { order: 3; position: static; height: auto; margin: 10px 16px 0; flex-direction: row; flex-wrap: wrap; }
  .mapmode .seg { box-shadow: none; }
  .legend .lg-t { display: none; }
  .inputs { order: 4; } .result { order: 5; }
  .legend { right: 12px; }
  details.assume .grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) { .lg-c i { font-size: 9.5px; } .lg-c:nth-child(even) i { display: none; } h1 { font-size: 28px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

.row .field.daysf { flex-basis: 100%; }
.mapmode > * { flex: none; }
@media (max-width: 1280px) { .mini { top: auto; bottom: 118px; } }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

.resets { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; }
.hint { font-size: 12.5px; color: var(--mut); line-height: 1.35; max-width: 34ch; }
.strip { display: none; }
@media (max-width: 1023px) {
  .strip { order: 2; display: block; margin: 0; padding: 10px 16px; background: var(--receipt); border-bottom: 1px solid var(--receipt-line); font-size: 14.5px; line-height: 1.4; }
  .strip[hidden] { display: none !important; }
  .strip b { color: var(--acc); font: 700 18px/1 var(--serif); white-space: nowrap; }
  .strip a { margin-left: 4px; font-size: 13.5px; }
  .mapmode { order: 3; } .stage { order: 2; }
}
/* reading rail: hairline dots in the right gutter of the article half */
.rail { position: fixed; right: 14px; top: 50%; transform: translateY(-50%); z-index: 20; display: flex; flex-direction: column; gap: 10px; opacity: 0; pointer-events: none; transition: opacity .3s; }
body.reading .rail { opacity: 1; pointer-events: auto; }
.rail a { position: relative; display: block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--mut); }
.rail a[aria-current] { background: var(--acc); border-color: var(--acc); }
.rail a span { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: 12.5px; background: var(--card); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; opacity: 0; pointer-events: none; }
.rail a:hover span, .rail a:focus-visible span { opacity: 1; }
@media (max-width: 1199px) { .rail { display: none; } }

.lg-k { display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; font-weight: 500; color: var(--mut); white-space: nowrap; }
.kp { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 4px; font: 700 9px/1 var(--sans); font-style: normal; color: #fff; margin-left: 6px; }
.kp.w { background: var(--pw); } .kp.a { background: var(--pa); } .kp.b { background: var(--pb); }
:root.dark .kp { color: #0b0f17; }
.legend .lg-t { max-width: 100%; white-space: normal; }
.v-ex { margin: 0 0 10px; padding: 0 0 10px; border-bottom: 1px dashed var(--receipt-line); font-size: 13px; color: var(--mut); }
@media (max-width: 1023px) { .legend .lg-t { display: block; font-size: 11.5px; } .lg-k { display: none; } }
