/*
 * explorer.css: Madar. From the mood board: a soft grey canvas, a white "clay" city,
 * white floating panels, black for anything you can press, colour only where there is data.
 * Land-use colours are defined once in geo.js (USE) and copied here as variables.
 */
:root {
  --canvas: #e7e8ea;
  --panel: #ffffff;
  --ink: #16181b;
  --muted: #6b7077;
  --hair: #e6e7ea;
  --soft: #f3f3f4;
  --res: #f5d77e; --mix: #ee9585; --com: #f5b27a; --civ: #b3acf2; --ind: #afc0cf; --green: #8fd39a;
  --accent: #f2c94c;
  --r-lg: 22px; --r: 14px;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.03), 0 14px 34px -20px rgba(20, 24, 30, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Inter Tight", "Inter", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--canvas); }
body { font: 14px/1.45 var(--sans); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

#map { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; background: rgba(255, 255, 255, 0.7) !important; border-radius: 8px 0 0 0; }
.maplibregl-ctrl-bottom-right { right: 0; bottom: 0; }

.panel { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow); }

/* Every button gives a small physical response: lift on hover, press in on click. */
.seg button, .round, .ctrl button, .chips button, .go, .more, .btn, .menu button, .layer, .walk > div, .nearest li {
  transition: transform 0.18s var(--ease), background-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.seg button:active, .round:active, .ctrl button:active, .chips button:active, .go:active, .btn:active, .menu button:active, .layer:active { transform: scale(0.95); }

/* --- Intro ----------------------------------------------------------------------------------- */
.intro { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: var(--canvas); pointer-events: none;
  animation: intro-out 0.9s var(--ease) 1.1s forwards; }
.intro span { font: 200 clamp(48px, 9vw, 120px)/1 var(--display); letter-spacing: -0.04em; animation: intro-word 1.4s var(--ease) both; }
@keyframes intro-word { from { opacity: 0; letter-spacing: 0.08em; filter: blur(8px); } to { opacity: 1; letter-spacing: -0.04em; filter: blur(0); } }
@keyframes intro-out { to { opacity: 0; visibility: hidden; } }

/* Panels arrive once, after the intro. */
.top, .left, .right, .ask, .ctrl { animation: arrive 0.7s var(--ease) both; }
.top { animation-delay: 1.5s; } .left { animation-delay: 1.65s; } .right { animation-delay: 1.75s; } .ctrl { animation-delay: 1.85s; } .ask { animation-delay: 1.95s; }
@keyframes arrive { from { opacity: 0; transform: translateY(12px); } }

/* --- Top bar ----------------------------------------------------------------------------------- */
.top { position: absolute; z-index: 5; left: 20px; right: 20px; top: 18px; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 9px 18px 9px 11px; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }
.brand svg { width: 28px; height: 28px; transition: transform 0.6s var(--spring); }
.brand .core { fill: var(--accent); transition: r 0.4s var(--spring); }
.brand:hover svg { transform: rotate(90deg); }
.search { position: relative; flex: 0 1 360px; display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 46px; }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { flex: 1; border: 0; outline: none; background: none; min-width: 0; }
.search:focus-within { box-shadow: var(--shadow), 0 0 0 2px var(--ink); }
.results { position: absolute; left: 0; right: 0; top: 54px; margin: 0; padding: 6px; list-style: none; background: #fff; border-radius: 18px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; animation: drop 0.25s var(--ease); }
.results li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 12px; cursor: pointer; }
.results li span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.results li[aria-selected="true"], .results li:hover { background: var(--soft); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

.seg { display: flex; padding: 4px; gap: 2px; position: relative; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 13px; color: var(--muted); font-weight: 500; }
.seg button:hover { color: var(--ink); background: var(--soft); }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.accent { background: var(--accent); color: var(--ink); }
.seg button.accent:hover { background: #f5d469; }
.spacer { flex: 1; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center; }
.round svg { width: 20px; height: 20px; }
.round[aria-pressed="true"] { background: var(--ink); color: #fff; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 50px; width: 290px; padding: 6px; display: flex; flex-direction: column; animation: drop 0.25s var(--ease); }
.menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 12px; }
.menu button:hover { background: var(--soft); }
.menu span { font-size: 12px; color: var(--muted); }
.units-wrap { position: relative; }
.units-wrap #units { font-variant-numeric: tabular-nums; min-width: 70px; }
.units-menu { width: 300px; padding: 12px; gap: 6px; }
.u-lab { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 4px 2px 0; }
.u-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--soft); border-radius: 14px; padding: 4px; }
.u-seg button { padding: 8px 10px; border-radius: 11px; color: var(--ink); }
.u-seg button small { font-size: 11px; color: var(--muted); font-weight: 400; }
.u-seg button.on, .u-seg button.on:hover { background: var(--ink); color: #fff; }
.u-seg button.on small { color: rgba(255, 255, 255, 0.7); }
.u-note { font-size: 12px; color: var(--muted); margin: 4px 2px 0; }

/* --- Left panel ------------------------------------------------------------------------------------ */
.left { position: absolute; z-index: 4; left: 20px; top: 82px; width: 320px; max-height: calc(100vh - 100px); overflow: auto; padding: 20px 22px; scrollbar-width: thin; }
.place { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.place b { color: var(--ink); font-weight: 600; }
.big { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 2px; }
.big span { font: 200 72px/0.95 var(--display); letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.big small { font-size: 20px; font-weight: 300; color: var(--muted); }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.slider { position: relative; margin: 18px 0 4px; height: 34px; }
.slider input { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: none; margin: 0; position: relative; z-index: 1; }
.slider input::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, var(--ink) var(--p, 47%), var(--hair) var(--p, 47%)); }
.slider input::-moz-range-track { height: 2px; background: var(--hair); }
.slider input::-moz-range-progress { height: 2px; background: var(--ink); }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 60px; height: 24px; margin-top: -11px; border-radius: 12px; background: transparent; border: 0; }
.slider input::-moz-range-thumb { width: 60px; height: 24px; border: 0; background: transparent; }
.slider output { position: absolute; top: 5px; left: var(--p, 47%); transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 12px; padding: 3px 10px; font-size: 12px; font-weight: 600; pointer-events: none; transition: transform 0.2s var(--spring); white-space: nowrap; z-index: 2; }
.slider:active output { transform: translateX(-50%) scale(1.12); }
.ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.hr { height: 1px; background: var(--hair); margin: 18px 0; }
.h { font-weight: 600; font-size: 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.h i { font-style: normal; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.mix { display: flex; height: 10px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--soft); }
.mix span { transition: flex-grow 0.6s var(--ease); min-width: 0; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; margin-top: 12px; font-size: 13px; }
.keys div { display: flex; align-items: center; gap: 8px; }
.keys em { font-style: normal; margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.walk { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.walk > div { background: var(--soft); border-radius: var(--r); padding: 10px 12px; cursor: pointer; }
.walk > div:hover { background: #ebebed; transform: translateY(-2px); }
.walk b { display: block; font: 300 28px/1.1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.walk span { color: var(--muted); font-size: 12px; }
.more { margin-top: 10px; border: 0; background: none; color: var(--muted); padding: 4px 0; font-size: 13px; }
.more:hover { color: var(--ink); }
.all { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; margin-top: 6px; }
.all span:nth-child(even) { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.all span.link { cursor: pointer; }
.all span.link:hover { text-decoration: underline; }

/* --- Right panel (collapsible) ----------------------------------------------------------------------- */
.right { position: absolute; z-index: 4; right: 20px; top: 82px; width: 290px; max-height: calc(100vh - 100px); overflow: auto; display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.5s var(--ease), opacity 0.4s var(--ease); scrollbar-width: none; }
body.right-hidden .right { transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none; }
.card { padding: 16px 18px; }
.layers { display: flex; flex-direction: column; gap: 3px; }
.layer { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; font-weight: 500; border: 0; background: none; text-align: left; width: 100%; }
.layer:hover { background: var(--soft); }
.layer.on { background: var(--soft); }
.layer .sw { width: 30px; height: 20px; border-radius: 7px; flex: none; }
.layer .tog { margin-left: auto; width: 30px; height: 18px; border-radius: 9px; background: var(--hair); position: relative; transition: background 0.25s var(--ease); flex: none; }
.layer .tog::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 2px; left: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: left 0.3s var(--spring); }
.layer.on .tog { background: var(--ink); }
.layer.on .tog::after { left: 14px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 70px; }
.bars span { flex: 1; border-radius: 4px 4px 0 0; background: #d4d5da; transition: height 0.6s var(--ease), background 0.3s; min-height: 2px; }
.bars span.hi { background: var(--ink); }
.legend-h { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.nearest { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nearest li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 12px; cursor: pointer; }
.nearest li:hover { background: var(--soft); }
.nearest .ic { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; }
.nearest .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.nearest .nm small { display: block; color: var(--muted); font-size: 11.5px; }
.nearest .ds { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }

/* --- Map controls ------------------------------------------------------------------------------------------ */
.ctrl { position: absolute; z-index: 4; right: 330px; bottom: 34px; display: flex; flex-direction: column; gap: 8px; transition: right 0.5s var(--ease); }
body.right-hidden .ctrl { right: 20px; }
.ctrl button { width: 44px; height: 44px; border-radius: 15px; background: #fff; border: 0; display: grid; place-items: center; font-size: 19px; box-shadow: var(--shadow); }
.ctrl button:hover { transform: translateY(-2px); }
.ctrl .compass { border-radius: 50%; width: 50px; height: 50px; }
.compass svg { width: 28px; height: 28px; transition: transform 0.2s linear; }

/* --- Catchment marker and labels on the map -------------------------------------------------------------- */
.centre { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 7px rgba(22, 24, 27, 0.14); cursor: grab; transition: box-shadow 0.3s var(--ease), transform 0.25s var(--spring); }
.centre:hover { transform: scale(1.15); box-shadow: 0 0 0 11px rgba(22, 24, 27, 0.12); }
.centre:active { cursor: grabbing; }
.centre::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 1.5px solid var(--ink); animation: pulse 2.6s var(--ease) infinite; }
@keyframes pulse { from { transform: scale(0.8); opacity: 0.7; } to { transform: scale(2.6); opacity: 0; } }
.ring-label { background: var(--ink); color: #fff; border-radius: 999px; padding: 5px 12px; font-weight: 600; font-size: 12px; white-space: nowrap; pointer-events: none; }
.pin { display: flex; flex-direction: column; align-items: center; animation: pin-drop 0.55s var(--spring) both; cursor: pointer; }
.pin .bub { background: #fff; border-radius: 15px; padding: 6px 11px 6px 6px; display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 12.5px; box-shadow: 0 10px 24px -14px rgba(0, 0, 0, 0.5); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.pin .ic { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.pin .stem { width: 2px; height: 22px; background: var(--ink); }
.pin .foot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 5px rgba(22, 24, 27, 0.12); }
@keyframes pin-drop { from { opacity: 0; transform: translateY(-26px) scale(0.8); } }
/* (measurement labels are drawn by the map: see measure-labels in app.js) */
.m-label { background: #fff; border-radius: 999px; padding: 3px 9px; font-size: 11.5px; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap; }

/* --- Ask ------------------------------------------------------------------------------------------------- */
.ask { position: absolute; z-index: 6; left: 50%; bottom: 22px; transform: translateX(-50%); width: min(640px, calc(100vw - 720px)); min-width: 420px; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; transition: opacity 0.3s var(--ease); }
.chips button { border: 0; background: rgba(255, 255, 255, 0.82); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 999px; padding: 7px 14px; font-size: 13px; box-shadow: 0 6px 18px -14px rgba(0, 0, 0, 0.5); }
.chips button:hover { background: #fff; transform: translateY(-2px); }
.askbar { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 18px; border-radius: 999px; transition: box-shadow 0.3s var(--ease); }
.askbar:focus-within { box-shadow: var(--shadow), 0 0 0 2px var(--ink); }
.askbar input { flex: 1; border: 0; outline: none; background: none; font-size: 15px; min-width: 0; }
.spark { width: 21px; height: 21px; fill: var(--ink); flex: none; transition: transform 0.6s var(--spring); }
.askbar:focus-within .spark { transform: rotate(45deg) scale(1.08); }
.thinking .spark { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.go { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #fff; border: 0; display: grid; place-items: center; flex: none; }
.go svg { width: 19px; height: 19px; }
.go:hover { transform: translateY(-2px); }
.answer { padding: 18px 20px; margin-bottom: 10px; border-radius: 24px; animation: rise 0.45s var(--ease); max-height: 46vh; overflow: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.answer .nums { display: flex; gap: 26px; flex-wrap: wrap; margin: 4px 0 6px; }
.answer .nums b { font: 300 38px/1 var(--display); letter-spacing: -0.03em; display: block; font-variant-numeric: tabular-nums; }
.answer .nums span { font-size: 12px; color: var(--muted); }
.answer p { margin: 8px 0 12px; font-size: 14.5px; line-height: 1.5; }
.answer .src { display: flex; gap: 6px; flex-wrap: wrap; }
.answer .src span { font-size: 11.5px; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 3px 10px; }
.answer .acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 500; font-size: 13px; background: var(--soft); }
.btn:hover { background: #e9e9eb; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.dark:hover { background: #2b2e33; }

.measure-pill { white-space: nowrap; position: absolute; z-index: 6; left: 50%; top: 82px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 999px; animation: drop 0.3s var(--ease); font-variant-numeric: tabular-nums; }
.measure-pill button { border: 0; background: var(--soft); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; }
.measure-pill button.dark { background: var(--ink); color: #fff; margin-right: -6px; }
.measure-list { position: absolute; z-index: 6; left: 50%; top: 136px; transform: translateX(-50%); width: 430px; max-width: calc(100vw - 32px); padding: 12px 14px; border-radius: 18px; font-variant-numeric: tabular-nums; animation: drop 0.3s var(--ease); }
.measure-list .mh { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.measure-list .mh span { color: var(--muted); }
.measure-list ul { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.measure-list li { display: grid; grid-template-columns: 12px 64px 1fr auto 26px 22px; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--hair); }
.measure-list .sw { width: 12px; height: 12px; border-radius: 4px; }
.measure-list .nm { width: 100%; border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 13px; padding: 3px 4px; border-radius: 6px; }
.measure-list .nm:hover, .measure-list .nm:focus { background: var(--soft); outline: none; }
.measure-list .val { display: flex; flex-direction: column; font-size: 13px; line-height: 1.25; }
.measure-list .val small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.measure-list .val > span { color: var(--muted); font-size: 11.5px; }
.measure-list .cmp { font-size: 11.5px; color: var(--muted); background: var(--soft); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.measure-list .cmp:empty { visibility: hidden; }
.measure-list li button { border: 0; background: transparent; border-radius: 999px; width: 24px; height: 24px; padding: 0; color: var(--muted); font-size: 16px; display: grid; place-items: center; }
.measure-list li button:hover { background: var(--soft); color: var(--ink); }
.measure-list li button svg { width: 14px; height: 14px; }
.measure-list .mf { display: flex; gap: 8px; margin-top: 8px; }
.measure-list .mf .btn { padding: 6px 12px; font-size: 12.5px; }
.tip { position: absolute; z-index: 7; pointer-events: none; padding: 10px 12px; border-radius: 14px; font-size: 12.5px; max-width: 260px; }
.tip b { display: block; font-size: 13px; }
.tip span { color: var(--muted); display: block; }
.toast { position: absolute; z-index: 9; left: 50%; top: 136px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px; animation: drop 0.3s var(--ease); max-width: 80vw; }

/* --- Smaller screens --------------------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .ask { width: calc(100vw - 400px); min-width: 0; left: 360px; transform: none; }
  .right { width: 260px; }
  .ctrl { right: 300px; }
}
@media (min-width: 701px) and (max-width: 860px) {
  .top { flex-wrap: wrap; }
  .search { flex: 1 1 100%; order: 5; }
  .left { top: auto; bottom: 96px; width: calc(100vw - 40px); max-height: 38vh; }
  .right { top: 140px; }
  .ask { left: 20px; right: 20px; width: auto; bottom: 14px; }
  .chips { display: none; }
  .ctrl { display: none; }
  .big span { font-size: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .intro { display: none; }
}

/* --- Diagram mode ------------------------------------------------------------------------------------- */
body.diagram .left, body.diagram .right, body.diagram .ask, body.diagram .ctrl, body.diagram .top > :not(.brand), body.diagram .measure-pill, body.diagram .measure-list, body.diagram .tip { display: none !important; }
.d-frame { position: absolute; z-index: 5; pointer-events: none; border-radius: 4px; box-shadow: 0 0 0 100vmax rgba(231, 232, 234, 0.86), 0 30px 60px -30px rgba(0, 0, 0, 0.35); transition: left 0.35s var(--ease), top 0.35s var(--ease), width 0.35s var(--ease), height 0.35s var(--ease); }
.d-tag { position: absolute; top: -26px; left: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
.d-tag b { color: var(--ink); font-weight: 600; }
.d-frame .tk { position: absolute; width: 16px; height: 16px; border: 2px solid var(--ink); }
.d-frame .t1 { left: -6px; top: -6px; border-right: 0; border-bottom: 0; } .d-frame .t2 { right: -6px; top: -6px; border-left: 0; border-bottom: 0; }
.d-frame .t3 { left: -6px; bottom: -6px; border-right: 0; border-top: 0; } .d-frame .t4 { right: -6px; bottom: -6px; border-left: 0; border-top: 0; }
.d-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.d-panel { position: absolute; z-index: 7; left: 20px; top: 82px; width: 352px; max-height: calc(100vh - 100px); overflow: auto; padding: 18px; scrollbar-width: thin; animation: arrive 0.45s var(--ease) both; }
.d-panel h2 { margin: 0; font-size: 18px; font-weight: 600; }
.d-sub { margin: 2px 0 6px; color: var(--muted); font-size: 12.5px; }
.d-lab { font-weight: 600; font-size: 13px; margin: 16px 0 8px; display: flex; justify-content: space-between; }
.d-lab i { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; }
.d-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.d-chips + .d-chips { margin-top: 6px; }
.chip { border: 0; background: var(--soft); border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 500; transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.18s var(--ease); }
.chip:hover { background: #e9e9eb; }
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--ink); color: #fff; }
.chip.fit { margin-top: 8px; }
.d-themes { display: grid; grid-template-columns: repeat(3, 1fr); }
.chip.theme { border-radius: 14px; padding: 6px 6px 8px; display: flex; flex-direction: column; align-items: stretch; gap: 5px; font-size: 12px; }
.chip.theme svg { width: 100%; height: 38px; border-radius: 9px; background: #fff; }
.d-views { display: grid; grid-template-columns: repeat(5, 1fr); }
.d-views .chip { padding: 8px 0; border-radius: 11px; }
.d-toggles { display: flex; flex-direction: column; gap: 2px; }
.d-toggles.two { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.dtog { display: flex; align-items: center; gap: 9px; border: 0; background: none; text-align: left; padding: 6px 6px; border-radius: 10px; font-size: 13px; }
.dtog:hover { background: var(--soft); }
.dtog:disabled { opacity: 0.4; cursor: not-allowed; }
.dtog .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.dtog .tog { margin-left: auto; width: 28px; height: 16px; border-radius: 8px; background: var(--hair); position: relative; flex: none; transition: background 0.25s var(--ease); }
.dtog .tog::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #fff; top: 2px; left: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: left 0.3s var(--spring); }
.dtog.on .tog { background: var(--ink); } .dtog.on .tog::after { left: 14px; }
.d-input { width: 100%; border: 1px solid var(--hair); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; outline: none; }
.d-input:focus { border-color: var(--ink); }
.d-nums .row { display: grid; grid-template-columns: 38% 1fr; gap: 6px; }
.d-nums .d-input { margin-bottom: 6px; }
.d-reset { float: right; border: 0; background: none; padding: 0; font: inherit; font-size: 11px; color: var(--muted, #6B7077); text-decoration: underline; cursor: pointer; }
.d-bar { position: absolute; z-index: 7; left: 396px; right: 24px; bottom: 18px; display: flex; gap: 8px; align-items: center; }
.d-hint { flex: 1; text-align: right; font-size: 12px; color: var(--muted); }
.dbtn { border: 0; background: #fff; border-radius: 999px; padding: 10px 18px; font-weight: 500; box-shadow: var(--shadow); transition: transform 0.18s var(--ease), background 0.2s; }
.dbtn:hover { transform: translateY(-2px); }
.dbtn:active { transform: scale(0.95); }
.dbtn.dark { background: var(--ink); color: #fff; }
.dbtn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* --- Phone layout (mobile.js adds body.mobile at ≤ 700 px) ------------------------------------------------- */
.sheet { display: none; }
body.mobile .sheet {
  display: flex; flex-direction: column; position: fixed; z-index: 8; left: 0; right: 0; bottom: 0;
  height: var(--sheet-h, 42vh); background: #fff; border-radius: 24px 24px 0 0;
  box-shadow: 0 -14px 40px -22px rgba(20, 24, 30, 0.45); padding-bottom: env(safe-area-inset-bottom);
  transition: height 0.38s var(--ease); animation: arrive 0.6s var(--ease) 1.6s both;
}
body.mobile .sheet.dragging { transition: none; }
.sheet-head { padding: 6px 16px 10px; touch-action: none; flex: none; }
.grab { display: block; width: 100%; border: 0; background: none; padding: 6px 0 10px; }
.grab span { display: block; width: 40px; height: 5px; border-radius: 3px; background: #d6d7da; margin: 0 auto; }
.stabs { display: flex; background: var(--soft); border-radius: 14px; padding: 3px; }
.stabs button { flex: 1; border: 0; background: none; border-radius: 11px; padding: 9px 0; font-weight: 500; font-size: 14px; color: var(--muted); transition: background 0.2s var(--ease), color 0.2s var(--ease); }
.stabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.spane { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 18px; overscroll-behavior: contain; }

/* Top bar: logo, search, 2D/3D only. */
body.mobile .top { left: 10px; right: 10px; top: calc(env(safe-area-inset-top) + 10px); flex-wrap: nowrap; gap: 8px; }
body.mobile .top > .seg:has([data-tool]), body.mobile .top > .seg:has(#diagram), body.mobile .top > .units-wrap, body.mobile #toggle-right, body.mobile .spacer { display: none; }
body.mobile .brand { font-size: 0; gap: 0; padding: 8px; }
body.mobile .search { flex: 1 1 0; min-width: 0; order: 0; height: 44px; padding: 0 12px; }
body.mobile .search input { width: 100%; min-width: 0; }
body.mobile .top > * { flex-shrink: 1; min-width: 0; }
body.mobile .top > .brand, body.mobile .top > .seg { flex-shrink: 0; }
body.mobile .search input { font-size: 16px; } /* 16 px stops iPhone zooming in on focus */
body.mobile .seg button { padding: 7px 11px; }
body.mobile .ctrl, body.mobile .measure-pill, body.mobile .measure-list, body.mobile .tip { display: none !important; }
body.mobile .toast { top: calc(env(safe-area-inset-top) + 64px); }
body.mobile .maplibregl-ctrl-bottom-right { bottom: var(--sheet-h, 42vh); }
/* Credits collapsed to the small (i) button on phones; tap it to read them. */
body.mobile .maplibregl-ctrl-attrib:not(.maplibregl-compact-show) .maplibregl-ctrl-attrib-inner { display: none; }

/* The panels inside the sheet: no floating cards. */
body.mobile .spane .left, body.mobile .spane .right, body.mobile .spane .ask {
  position: static; width: auto; max-height: none; overflow: visible; transform: none !important; opacity: 1 !important;
  pointer-events: auto !important; box-shadow: none; padding: 0; animation: none; background: none; min-width: 0; left: auto; right: auto; bottom: auto;
}
body.mobile .spane .right { display: flex; flex-direction: column; gap: 4px; }
body.mobile .spane .right .card { box-shadow: none; padding: 10px 0; border-radius: 0; border-bottom: 1px solid var(--hair); }
body.mobile .spane .layer { padding: 11px 6px; }
body.mobile .big span { font-size: 38px; letter-spacing: -0.03em; }
body.mobile .big { margin: 8px 0 0; }
body.mobile .big small { font-size: 15px; }
body.mobile .slider { margin-top: 14px; }
body.mobile .spane .chips { display: flex; justify-content: flex-start; }
body.mobile .spane .chips button { background: var(--soft); box-shadow: none; }
body.mobile .spane .answer { box-shadow: none; background: #f7f7f8; max-height: none; }
body.mobile .spane .askbar { box-shadow: none; border: 1.5px solid var(--ink); }
body.mobile .spane .askbar input { font-size: 16px; }
body.mobile .ring-label { font-size: 11px; padding: 4px 10px; }

/* --- Diagram mode on a phone: frame on top, settings in a sheet at the bottom --------------------------- */
.m-only { display: none; }
body.mobile .m-only { display: grid; width: 44px; height: 44px; }
body.mobile.diagram .sheet { display: none; }
body.mobile.diagram .top { top: calc(env(safe-area-inset-top) + 12px); }
body.mobile.diagram .d-panel {
  left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 50vh; max-height: none;
  border-radius: 24px 24px 0 0; padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
  box-shadow: 0 -14px 40px -22px rgba(20, 24, 30, 0.45);
}
body.mobile.diagram .d-panel h2, body.mobile.diagram .d-sub { display: none; }
body.mobile.diagram .d-lab:first-of-type { margin-top: 0; }
body.mobile.diagram .d-bar {
  left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(255, 255, 255, 0), #fff 30%); z-index: 8; gap: 6px;
}
body.mobile.diagram .d-hint { display: none; }
body.mobile.diagram #d-back { margin-right: auto; padding: 10px 14px; }
body.mobile.diagram .dbtn { padding: 10px 14px; }
body.mobile.diagram .d-tag { font-size: 11px; top: -20px; }
body.mobile.diagram .d-tag span { display: none; }
body.mobile.diagram .d-toggles.two { grid-template-columns: 1fr 1fr; }
body.mobile.diagram .dtog { padding: 9px 6px; }
body.mobile.diagram .chip { padding: 9px 12px; }
body.mobile.diagram .d-input { font-size: 16px; }

/* --- Climate mode ------------------------------------------------------------------------------------------- */
body.climate .right, body.climate .ask { display: none !important; }
.climate-panel { position: absolute; z-index: 4; right: 20px; top: 82px; width: 300px; max-height: calc(100vh - 100px); overflow: auto; display: flex; flex-direction: column; gap: 10px; scrollbar-width: none; animation: arrive 0.45s var(--ease) both; }
body.right-hidden .climate-panel { transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none; transition: transform 0.5s var(--ease), opacity 0.4s; }
.cl-big { font: 200 52px/1 var(--display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.cl-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.cl-seg { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.cl-seg button { border: 0; background: var(--soft); border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-weight: 500; transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.18s var(--ease); }
.cl-seg button:active { transform: scale(0.95); }
.cl-seg button.on { background: var(--ink); color: #fff; }
.cl-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cl-duo > div { border-radius: 14px; padding: 10px 12px; transition: background 0.4s var(--ease); }
.cl-duo b { display: block; font: 300 30px/1.1 var(--display); letter-spacing: -0.02em; }
.cl-duo span { display: block; font-size: 12px; font-weight: 500; }
.cl-duo small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.cl-dest { margin: 10px 0 6px; font-weight: 600; font-size: 13px; }
.cl-rrow { display: grid; grid-template-columns: 22px auto 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.cl-rrow span:nth-of-type(2) { color: var(--muted); }
.cl-rrow em { font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; }
.cl-line { height: 0; border-top: 4px solid #3B8F8A; border-radius: 2px; }
.cl-line.short { border-top: 3px dashed #6B7077; }
.cl-heatwrap { display: grid; grid-template-columns: 10px 1fr; gap: 6px; }
.cl-hm-months { display: grid; grid-template-rows: repeat(12, 1fr); font-size: 8.5px; color: var(--muted); line-height: 1; align-items: center; }
.cl-heat { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; cursor: pointer; }
.cl-heat i { height: 11px; border-radius: 2px; transition: transform 0.15s var(--ease), box-shadow 0.15s; }
.cl-heat i:hover { transform: scale(1.35); position: relative; z-index: 1; }
.cl-heat i.on { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); position: relative; z-index: 2; }
.cl-hl { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin: 4px 0 0 16px; }
.cl-key { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.cl-key span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 4px; }
.cl-windrow { display: flex; gap: 12px; align-items: center; }
.cl-windrow svg { width: 92px; height: 92px; flex: none; }
.cl-windrow .cl-note { margin: 0; }
.cl-fx { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; }
.cl-layers .cl-seg { margin-top: 8px; }
.cl-toggles button:not(.on) { background: var(--soft); }
.cl-toggles button::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: currentColor; opacity: 0.25; vertical-align: 1px; }
.cl-toggles button.on::before { opacity: 1; background: #FDE725; }
.cl-wtop { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cl-big small { font-size: 0.45em; font-weight: 400; letter-spacing: 0; margin-left: 2px; }
#cl-wspeed { font-size: 40px; }
.cl-wfrom { display: flex; align-items: center; gap: 8px; font-size: 12.5px; line-height: 1.25; }
.cl-wfrom svg { width: 40px; height: 40px; }
.cl-wfrom small { color: var(--muted); font-size: 11px; }
.cl-wbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 10px; gap: 2px; }
.cl-wbar i { flex: 1 1 0; transition: flex-grow 0.6s var(--ease); }
.cl-wbar .b { background: #7AD151; } .cl-wbar .m { background: #21918C; } .cl-wbar .s { background: #46337E; }
.cl-grad { margin-top: 10px; }
.cl-grad > span { display: block; height: 7px; border-radius: 4px; }
.cl-grad > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; margin-top: 3px; }
.cl-grad em { font-style: normal; }
.cl-sub { margin-top: 14px; font-size: 12.5px; font-weight: 600; display: flex; justify-content: space-between; }
.cl-sub i { font-style: normal; font-weight: 400; color: var(--muted); }
.cl-wday { display: grid; grid-template-columns: repeat(24, 1fr); margin-top: 6px; background: var(--soft); border-radius: 8px; padding: 3px 2px; }
.cl-wday button { border: 0; background: none; padding: 0; height: 22px; border-radius: 5px; cursor: pointer; }
.cl-wday button:hover { background: #fff; }
.cl-wday button.on { background: var(--ink); }
.cl-wday svg { width: 100%; height: 100%; display: block; }
.cl-wday + .cl-hl { margin-left: 0; }
.cl-windrow { margin-top: 10px; }
.cl-windrow .cl-seg { margin-top: 6px; }
.cl-fine { font-size: 11px; }
.cl-foot { margin: 0 4px 6px; font-size: 11px; color: var(--muted); }

.timeline { position: absolute; z-index: 6; left: 360px; right: 340px; bottom: 22px; padding: 12px 16px 10px; animation: arrive 0.45s var(--ease) both; }
body.right-hidden .timeline { right: 80px; }
.timeline.disabled .tl-row, .timeline.disabled .tl-ends { opacity: 0.35; pointer-events: none; }
.tl-months { display: flex; justify-content: space-between; gap: 2px; margin-bottom: 8px; }
.tl-months button { border: 0; background: none; border-radius: 9px; padding: 4px 7px; font-size: 12px; color: var(--muted); transition: background 0.2s var(--ease), color 0.2s; }
.tl-months button:hover { background: var(--soft); color: var(--ink); }
.tl-months button.on { background: var(--ink); color: #fff; }
.tl-row { display: flex; align-items: center; gap: 12px; }
.tl-play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 12px; flex: none; transition: transform 0.18s var(--ease); }
.tl-play:active { transform: scale(0.92); }
.tl-slider { position: relative; flex: 1; height: 34px; }
.tl-slider input { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: none; margin: 0; position: relative; z-index: 1; }
.tl-slider input::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, #DDE3EA, #FFE3A3 20%, #F2994A 50%, #FFE3A3 80%, #DDE3EA); }
.tl-slider input::-moz-range-track { height: 3px; background: linear-gradient(90deg, #DDE3EA, #FFE3A3 20%, #F2994A 50%, #FFE3A3 80%, #DDE3EA); }
.tl-slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 74px; height: 26px; margin-top: -12px; background: transparent; border: 0; }
.tl-slider input::-moz-range-thumb { width: 74px; height: 26px; border: 0; background: transparent; }
.tl-slider output { position: absolute; top: 4px; left: var(--p, 60%); transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 13px; padding: 4px 11px; font-size: 12px; font-weight: 600; pointer-events: none; white-space: nowrap; z-index: 2; }
.tl-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-left: 48px; }

/* Climate on the phone: inside the sheet's Climate tab. */
body.mobile .spane .climate-panel, body.mobile .spane .timeline { position: static; width: auto; max-height: none; overflow: visible; box-shadow: none; animation: none; padding: 0; transform: none !important; opacity: 1 !important; pointer-events: auto !important; }
body.mobile .spane .climate-panel .card { box-shadow: none; padding: 10px 0; border-radius: 0; border-bottom: 1px solid var(--hair); }
body.mobile .spane .timeline { margin: 2px 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--hair); border-radius: 0; }
body.mobile .tl-months { overflow-x: auto; }
body.mobile .stabs button { font-size: 13px; }
body.mobile .top .modes { display: none; }

body.mobile .cl-big { font-size: 38px; }
.d-link { font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.d-link:hover { color: var(--ink); }
body.mobile .d-link { display: none; }
