*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: var(--t-md); line-height: var(--lh); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.icon { width: var(--icon); height: var(--icon); flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* header */
.top { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: var(--s-4); min-height: 68px; padding: 0 max(var(--s-5), env(safe-area-inset-right)) 0 max(var(--s-5), env(safe-area-inset-left)); }
.logo { display: flex; align-items: center; gap: var(--s-2); font-weight: 800; font-size: 21px; letter-spacing: var(--track-tight); text-decoration: none; }
.logo-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; }
.logo-mark .icon { width: 18px; height: 18px; stroke-width: 2.4; }
.top-right { margin-left: auto; display: flex; gap: var(--s-2); align-items: center; }
.chip { display: inline-flex; align-items: center; gap: var(--s-2); border: 1px solid var(--line-2); border-radius: var(--r-pill); padding: 8px 14px; font-weight: 600; background: var(--bg); min-height: 40px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.chip .dot.on { background: var(--real); }

/* layout */
.app { display: grid; grid-template-columns: var(--chat-w) minmax(0, 1fr); height: calc(100vh - 69px); }
.chat { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.log { flex: 1; overflow-y: auto; padding: var(--s-5) var(--s-5) var(--s-4); display: flex; flex-direction: column; gap: var(--s-5); scroll-behavior: smooth; }
.results { overflow-y: auto; padding: var(--s-5) var(--s-6) var(--s-8); min-width: 0; position: relative; }
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); height: auto; }
  .chat { border-right: 0; border-bottom: 1px solid var(--line); }
  .log { overflow: visible; }
  .compose { position: sticky; bottom: 0; }
  .results { overflow: visible; padding: var(--s-5) var(--s-4) var(--s-8); }
}

/* turns */
.turn { display: grid; gap: var(--s-3); min-width: 0; }
.turn > * { min-width: 0; }
.turn.me { justify-items: end; }
.bubble { max-width: 88%; background: var(--soft); border-radius: var(--r-lg) var(--r-lg) 6px var(--r-lg); padding: 10px 15px; font-weight: 500; overflow-wrap: anywhere; white-space: pre-wrap; }
.who { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: var(--t-sm); }
.who .logo-mark { width: 24px; height: 24px; border-radius: 7px; }
.who .logo-mark .icon { width: 14px; height: 14px; }
.say { margin: 0; font-size: 16px; line-height: 1.5; }
.presets { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.preset { display: inline-flex; align-items: center; gap: var(--s-2); border: 1px solid var(--line-2); background: var(--bg); border-radius: var(--r-pill); padding: 9px 15px; font-weight: 600; min-height: var(--tap); transition: border-color var(--m-fast), background var(--m-fast), transform var(--m-press); }
.preset:hover { border-color: var(--ink); }
.preset:active { transform: scale(0.97); }
.preset[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.preset .c { color: var(--ink-3); font-weight: 500; font-size: 13px; }
.preset[aria-pressed="true"] .c { color: rgba(255, 255, 255, 0.75); }
.preset .icon { width: 16px; height: 16px; }
.preset.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.typing { display: flex; gap: 5px; padding: var(--s-2) 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: bob 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

/* ledger */
.ledger { list-style: none; margin: 0; padding: 14px 16px; display: grid; gap: 9px; border-radius: var(--r-card); background: var(--soft); }
.ledger li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: var(--t-sm); }
.ledger li.wait { color: var(--ink-3); }
.ledger .ok { color: var(--real); display: grid; }
.ledger .ok path { stroke-dasharray: 24; stroke-dashoffset: 0; animation: draw var(--m-base) var(--ease-out) backwards; }
.ledger .n { font-weight: 700; }

/* the watcher card */
.plan { border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow); }
.plan-h { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-1); }
.plan-h b { display: flex; gap: var(--s-2); align-items: center; font-size: 17px; }
.pill { font-size: var(--t-xs); font-weight: 700; padding: 4px 10px; border-radius: var(--r-pill); color: var(--real); background: var(--real-bg); }
.pill.off { color: var(--ink-2); background: var(--soft); }
.prow { display: grid; grid-template-columns: 18px 88px minmax(0, 1fr) auto; gap: 10px; align-items: start; border-top: 1px solid var(--line); padding: 11px var(--s-4); font-size: var(--t-sm); }
.prow .k { color: var(--ink-2); }
.prow .v { font-weight: 600; overflow-wrap: anywhere; }
.prow .v.unset { color: var(--ink-3); font-weight: 500; }
.prow.fresh { animation: flash 900ms var(--ease-out); }
.linkbtn { border: 0; background: none; padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; font-size: var(--t-sm); }
.plan-f { border-top: 1px solid var(--line); padding: var(--s-4); display: grid; gap: var(--s-3); }
.plan-f .match { color: var(--ink-2); display: flex; gap: var(--s-2); align-items: baseline; }
.plan-f .match b { font-size: var(--t-xl); color: var(--ink); letter-spacing: -0.02em; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 46px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); font-weight: 700; text-decoration: none; transition: transform var(--m-press); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: var(--bg); color: var(--ink); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.row { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }

/* outgoing emails in the chat */
.mail { min-width: 0; border: 1px solid var(--line-2); border-radius: var(--r-card); padding: var(--s-3) var(--s-4); display: grid; gap: 6px; background: var(--bg); }
.mail .to { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--t-sm); }
.mail .to b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail .state { display: inline-flex; gap: 4px; align-items: center; font-weight: 700; color: var(--real); white-space: nowrap; }
.mail .state .icon { width: 15px; height: 15px; }
.mail p { margin: 0; color: var(--ink-2); font-size: var(--t-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mail textarea { width: 100%; min-height: 110px; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 10px 12px; resize: vertical; line-height: 1.5; font-size: var(--t-sm); }
.slots { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.slot { display: grid; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 8px 12px; font-size: 13px; background: var(--bg); }
.slot b { font-size: var(--t-sm); }

/* composer */
.compose { display: flex; gap: var(--s-2); align-items: flex-end; margin: 0 var(--s-4) var(--s-4); border: 1px solid var(--line-2); border-radius: 24px; padding: 6px 6px 6px var(--s-4); background: var(--bg); box-shadow: var(--shadow); }
.compose textarea { flex: 1; border: 0; outline: 0; resize: none; padding: 10px 0; min-height: 24px; max-height: 150px; background: none; line-height: 1.4; }
.round { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; flex: none; transition: transform var(--m-press); }
.round:active { transform: scale(0.94); }
.round.ghost { background: var(--soft); color: var(--ink); }
.round.listening { background: var(--scam); color: var(--bg); }

/* results */
.res-h { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.res-h h1 { margin: 0; font-size: var(--t-xl); letter-spacing: -0.02em; }
.cats { display: flex; gap: var(--s-5); overflow-x: auto; padding: var(--s-4) 0 var(--s-1); margin-bottom: var(--s-5); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.cat { border: 0; background: none; display: grid; justify-items: center; gap: 6px; padding: 2px 2px 10px; color: var(--ink-2); font-weight: 600; font-size: var(--t-xs); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.cat:hover { color: var(--ink); border-bottom-color: var(--line-2); }
.cat[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.cat svg { width: 28px; height: 28px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 28px 18px; }
.card { display: grid; gap: 10px; min-width: 0; animation: rise var(--m-base) var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 25ms); }
.card-img { position: relative; aspect-ratio: 20 / 19; border-radius: var(--r-card); overflow: hidden; background: var(--map-bg); max-width: 100%; }
.img-btn { border: 0; padding: 0; background: none; display: block; width: 100%; height: 100%; position: relative; overflow: hidden; }
.tiles { position: absolute; inset: 0; transition: transform var(--m-slow) var(--ease-out); }
.card:hover .tiles { transform: scale(1.04); }
.tiles img { position: absolute; width: 256px; height: 256px; filter: grayscale(1) brightness(1.1) contrast(0.82); }
.card-img img.photo, .gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25)); }
.badge { position: absolute; top: 12px; left: 12px; background: var(--bg); border-radius: var(--r-pill); padding: 5px 10px; font-weight: 700; font-size: var(--t-xs); box-shadow: var(--shadow); display: inline-flex; gap: 5px; align-items: center; pointer-events: none; }
.badge .icon { width: 13px; height: 13px; stroke-width: 2.8; }
.badge.real .icon { color: var(--real); }
.badge.ask .icon { color: var(--ask); }
.badge.scam { background: var(--scam); color: var(--bg); }
.badge.sent { top: auto; bottom: 12px; background: var(--ink); color: var(--bg); }
.heart { position: absolute; top: 8px; right: 8px; border: 0; background: none; width: 40px; height: 40px; display: grid; place-items: center; }
.heart svg { width: 24px; height: 24px; fill: rgba(0, 0, 0, 0.35); stroke: var(--bg); stroke-width: 2; transition: transform var(--m-fast) var(--ease-spring); }
.heart[aria-pressed="true"] svg { fill: var(--scam); transform: scale(1.1); }
.meta { border: 0; background: none; padding: 0; text-align: left; display: grid; gap: 2px; min-width: 0; width: 100%; overflow: hidden; }
.meta > span { min-width: 0; }
.meta .l1 { display: flex; justify-content: space-between; gap: var(--s-2); font-weight: 700; }
.meta .l1 span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .val { font-weight: 500; font-size: 13px; white-space: nowrap; }
.meta .g { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .price { margin-top: 4px; }
.empty { text-align: center; color: var(--ink-2); padding: var(--s-8) var(--s-4); display: grid; gap: var(--s-2); justify-items: center; }
.empty .icon { width: 34px; height: 34px; color: var(--ink-3); }

/* the dot map */
.map { position: relative; background: var(--map-bg); overflow: hidden; touch-action: none; user-select: none; border-radius: var(--r-lg); }
.map > svg { display: block; width: 100%; height: 100%; cursor: grab; }
.map > svg:active { cursor: grabbing; }
.map .town { font-weight: 700; fill: #7D8279; letter-spacing: 0.04em; }
.map-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: var(--bg); border-radius: var(--r-pill); padding: 7px 13px; font-size: 13px; font-weight: 700; box-shadow: var(--shadow); display: flex; gap: 6px; align-items: center; white-space: nowrap; pointer-events: none; }
.map-hint .icon { width: 15px; height: 15px; }
.results .map.big { height: calc(100vh - 230px); min-height: 420px; }
.turn .map { height: 230px; border-radius: var(--r-card); }
.radius { display: flex; align-items: center; gap: var(--s-3); font-size: var(--t-sm); }
.radius input { flex: 1; accent-color: var(--ink); }

/* sheet and modal */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 50; display: grid; place-items: center; padding: var(--s-5); overflow-y: auto; animation: fade var(--m-base) var(--ease-out); }
.sheet { background: var(--bg); border-radius: var(--r-lg); width: min(1040px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; box-shadow: var(--shadow-lg); animation: up var(--m-slow) var(--ease-out); }
.sheet-top { position: sticky; top: 0; z-index: 2; background: var(--bg); display: flex; justify-content: space-between; align-items: center; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.sheet-body { padding: var(--s-5); display: grid; gap: var(--s-6); }
.hero { position: relative; aspect-ratio: 21 / 8; border-radius: var(--r-card); overflow: hidden; background: var(--map-bg); max-width: 100%; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s-7); align-items: start; }
.sheet h2 { margin: 0; font-size: 26px; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); }
.facts span { display: inline-flex; gap: 5px; align-items: center; }
.facts .icon { width: 15px; height: 15px; }
.why { display: grid; gap: var(--s-3); padding: var(--s-5) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.why h3 { margin: 0; font-size: var(--t-lg); }
.why ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-3); }
.why li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: var(--s-3); }
.why li .icon { width: 22px; height: 22px; }
.why.real li .icon { color: var(--real); }
.why.ask li .icon { color: var(--ask); }
.why.scam li .icon { color: var(--scam); }
.q { margin: 0; font-weight: 700; color: var(--ask); }
.strip { width: 100%; height: auto; display: block; }
.strip text { font-size: 12px; font-weight: 700; fill: var(--ink); font-family: var(--font); }
.strip text.lab { font-weight: 500; fill: var(--ink-2); }
.panel { position: sticky; top: 72px; border: 1px solid var(--line-2); border-radius: var(--r-card); padding: 22px; box-shadow: var(--shadow-lg); display: grid; gap: var(--s-3); }
.panel .p { font-size: 22px; }
.panel textarea { width: 100%; min-height: 160px; border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.modal { background: var(--bg); border-radius: var(--r-lg); width: min(440px, 100%); padding: var(--s-5); display: grid; gap: var(--s-4); box-shadow: var(--shadow-lg); animation: pop var(--m-base) var(--ease-spring); }
.modal h2 { margin: 0; font-size: 22px; }
.modal ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-3); }
.modal li { display: grid; grid-template-columns: 22px 1fr; gap: var(--s-3); }
.modal .apps { display: flex; align-items: center; gap: var(--s-3); justify-content: center; padding: var(--s-2) 0; }
.modal .apps .logo-mark { width: 44px; height: 44px; border-radius: 13px; }
.modal .apps .cal { width: 44px; height: 44px; border-radius: 13px; border: 1px solid var(--line-2); display: grid; place-items: center; }
.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 70; box-shadow: var(--shadow-lg); animation: toast var(--m-base) var(--ease-out); }
@media (max-width: 860px) {
  .scrim { padding: 0; place-items: end center; }
  .sheet { max-height: 100vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .cols { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .panel { position: static; box-shadow: none; }
  .hero { aspect-ratio: 16 / 9; }
}

/* motion */
.turn.enter { animation: rise var(--m-base) var(--ease-out) backwards; }
.turn.enter .preset { animation: rise var(--m-base) var(--ease-out) backwards; animation-delay: calc(120ms + var(--i, 0) * 30ms); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { opacity: 0; transform: translateY(24px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes draw { from { stroke-dashoffset: 24; } }
@keyframes bob { 0%, 100% { opacity: 0.3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes flash { 0% { background: var(--brand-soft); } 100% { background: transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.9s linear infinite; }
html.still *, html.still *::before, html.still *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* MapLibre maps */
.map.gl { background: #F2F1EE; }
.map.gl .maplibregl-ctrl-attrib { font-size: 11px; }
.gl-pin { width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; border: 3px solid var(--bg); box-shadow: var(--shadow-lg); cursor: grab; }
.gl-pin:active { cursor: grabbing; }
.gl-pin .icon { width: 18px; height: 18px; }
.credit { position: absolute; right: 8px; bottom: 6px; background: rgba(255, 255, 255, 0.85); border-radius: 6px; padding: 2px 6px; font-size: 11px; color: var(--ink-2); }
.gallery { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 46%); gap: var(--s-2); overflow-x: auto; scroll-snap-type: x mandatory; border-radius: var(--r-card); }
.gallery img { aspect-ratio: 4 / 3; scroll-snap-align: start; border-radius: var(--r-md); }
.x-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--soft); display: grid; place-items: center; transition: background var(--m-fast); }
.x-btn:hover { background: var(--line); }
.x-btn .icon { width: 20px; height: 20px; }
.hero.short { aspect-ratio: 21 / 5; }
@media (max-width: 860px) { .hero.short { aspect-ratio: 16 / 7; } }
@media (max-width: 640px) { .hide-sm { display: none; } }
