/* Fruta Amiga — tokens in DESIGN.md. */
@font-face { font-family: 'Atkinson'; src: url('/fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url('/fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('/fonts/fredoka-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --leaf: #2e7d32; --leaf-ink: #ffffff; --leaf-soft: #e3f1e3;
  --g0: #ffffff; --g50: #f3f6f2; --g100: #e6ebe4; --g200: #cfd7cc; --g300: #b1bbad; --g500: #75806f;
  --g700: #475144; --g800: #2d352b; --g900: #1b211a; --g950: #111510;
  --warn: #b3261e;
  --bg: var(--g0); --surface: var(--g0); --sunk: var(--g50); --line: var(--g200); --ink: var(--g900); --ink-2: var(--g700); --ink-3: var(--g500);
  --area-on: #2e7d32; --area-off: #75806f;
  --r-btn: 16px; --r-tile: 20px; --r-sheet: 24px; --r-tag: 8px; --r-bubble: 18px;
  --display: 'Fredoka', 'Atkinson', sans-serif; --body: 'Atkinson', sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --leaf: #66bb6a; --leaf-ink: #0f1a10; --leaf-soft: #1f3320; --warn: #f2b8b5;
    --bg: var(--g950); --surface: var(--g900); --sunk: var(--g900); --line: var(--g800); --ink: var(--g50); --ink-2: var(--g200); --ink-3: var(--g300);
    --area-on: #66bb6a; --area-off: #b1bbad; }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 19px/1.45 var(--body); -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
a { color: var(--leaf); }
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }

#app { display: flex; flex-direction: column; min-height: 100dvh; max-width: 640px; margin: 0 auto; }

/* header: logo left, language + menu right */
.top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 1000; direction: ltr; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex: 1; min-width: 0; }
.logo { width: 40px; height: 40px; flex: none; }
.logo svg, .big-ico svg, .tile-img svg, .sheet-fruit svg, .mine-fruit svg, .thread-fruit svg, .who-fruit svg, .seek-ico svg, .place-pin svg { width: 100%; height: 100%; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font: 600 24px/1.1 var(--display); letter-spacing: .2px; }
.tagline { font-size: 14px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang, .menu-btn { min-height: 48px; min-width: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; }
.burger, .burger::before, .burger::after { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 1px; position: relative; }
.burger::before, .burger::after { content: ''; position: absolute; left: 0; }
.burger::before { top: -6px; } .burger::after { top: 6px; }
@media (max-width: 360px) { .menu-btn span[data-t] { display: none; } .tagline { display: none; } }

/* home */
#view.home { flex: 1; display: flex; flex-direction: column; min-height: 0; height: calc(100dvh - 65px - env(safe-area-inset-top)); }
.map-wrap { position: relative; flex: 1; min-height: 240px; }
#map, #place-map { position: absolute; inset: 0; background: var(--sunk); }
.locate { position: absolute; left: 12px; bottom: 12px; z-index: 500; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 2px 8px rgb(0 0 0 / .12); }
.ico-target { width: 18px; height: 18px; border: 2.5px solid currentColor; border-radius: 50%; position: relative; }
.ico-target::after { content: ''; position: absolute; inset: 4px; background: currentColor; border-radius: 50%; }
.legend { display: flex; gap: 16px; padding: 8px 16px; font-size: 16px; color: var(--ink-2); border-top: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--area-on); } .dot.off { background: var(--area-off); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); }
.big { min-height: 76px; border-radius: var(--r-btn); border: 0; font: 700 21px/1.15 var(--body); display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; transition: filter .15s ease-out; }
.big:active { filter: brightness(.92); }
.big-have { background: var(--leaf); color: var(--leaf-ink); }
.big-seek { background: var(--sunk); color: var(--ink); border: 2px solid var(--leaf); }
.big-ico { width: 40px; height: 40px; flex: none; }
.ico-search { position: relative; width: 30px; height: 30px; }
.ico-search::before { content: ''; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border: 3.5px solid currentColor; border-radius: 50%; }
.ico-search::after { content: ''; position: absolute; left: 20px; top: 19px; width: 10px; height: 4px; background: currentColor; border-radius: 2px; transform: rotate(45deg); transform-origin: left center; }
.btn-chats { grid-column: 1 / -1; }
.ico-chat { width: 22px; height: 18px; border: 2.5px solid currentColor; border-radius: 6px; position: relative; flex: none; }
.ico-chat::after { content: ''; position: absolute; left: 3px; bottom: -6px; width: 7px; height: 7px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; background: inherit; transform: skewY(-35deg); }
.badge { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--warn); color: #fff; font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
@media (prefers-color-scheme: dark) { .badge { color: var(--g950); } }
.seekbar { position: absolute; top: 12px; left: 12px; right: 64px; z-index: 500; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; box-shadow: 0 2px 8px rgb(0 0 0 / .12); font-size: 17px; }
.seek-ico { width: 32px; height: 32px; flex: none; }
.seek-text { flex: 1; min-width: 0; }
.seek-clear { min-height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk); font-weight: 700; font-size: 16px; }
.empty { position: absolute; left: 12px; right: 12px; top: 84px; z-index: 500; background: var(--surface); border-radius: 16px; padding: 12px 16px; box-shadow: 0 2px 12px rgb(0 0 0 / .15); }
.empty p { margin: 0 0 8px; }

/* map marks */
.area { filter: url(#fa-blur); }
.area-on { fill: var(--area-on); fill-opacity: .42; stroke: none; }
.area-off { fill: var(--area-off); fill-opacity: .36; stroke: none; }
@media (prefers-color-scheme: dark) { .leaflet-tile-pane { filter: brightness(.82) saturate(.9); } }
.leaflet-container path.area { stroke-width: 0; }
.fruit-pin span { display: block; width: 52px; height: 52px; padding: 7px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .25); border: 3px solid var(--area-on); }
.fruit-pin span svg { width: 100%; height: 100%; display: block; }
.fruit-pin.off span { border-color: var(--area-off); filter: grayscale(1); opacity: .75; }
.leaflet-container { font: 15px var(--body); }
.leaflet-control-zoom a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 24px !important; }

/* buttons */
.btn { min-height: 60px; width: 100%; border-radius: var(--r-btn); border: 2px solid var(--line); background: var(--surface); font: 700 21px/1.2 var(--body); display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 16px; text-decoration: none; color: var(--ink); transition: filter .15s ease-out; }
.btn:active { filter: brightness(.94); }
.btn-primary { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.btn-quiet { min-height: 48px; font-size: 18px; }
.btn:disabled { opacity: .7; cursor: default; }
.link-quiet { background: none; border: 0; color: var(--ink-3); text-decoration: underline; font-size: 17px; min-height: 44px; padding: 0 4px; }
.spin { width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* screens */
#view.screen { flex: 1; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.bar { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.back { min-height: 52px; padding: 0 14px 0 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 19px; display: inline-flex; align-items: center; gap: 6px; }
.chev { width: 12px; height: 12px; border-left: 3px solid currentColor; border-bottom: 3px solid currentColor; transform: rotate(45deg); margin-left: 6px; }
.title { font: 600 30px/1.15 var(--display); margin: 0; }
.lead { font-size: 20px; margin: 0; color: var(--ink-2); }
.fine { font-size: 16px; color: var(--ink-3); margin: 0; }
.q { font-weight: 700; margin: 0; }

.fruit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fruit-tile { border: 2px solid var(--line); border-radius: var(--r-tile); background: var(--surface); padding: 12px 8px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 20px; min-height: 150px; transition: border-color .15s ease-out; }
.fruit-tile:active, .fruit-tile.picked { border-color: var(--leaf); background: var(--leaf-soft); }
.tile-img { width: 92px; height: 92px; }
.other-box { display: flex; flex-direction: column; gap: 12px; }

.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.field small { font-weight: 400; color: var(--ink-3); }
.field input, .send-row textarea { min-height: 56px; border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 20px; background: var(--surface); }
.field input:focus, .send-row textarea:focus { border-color: var(--leaf); outline: none; }
.hint { font-size: 16px; }
.check { display: flex; align-items: center; gap: 14px; font-weight: 700; font-size: 20px; min-height: 60px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 12px; }
.check input { width: 30px; height: 30px; accent-color: var(--leaf); flex: none; }
.form-err { color: var(--warn); font-weight: 700; margin: 0; }

/* place */
.place-wrap { position: relative; height: 46dvh; min-height: 260px; border-radius: var(--r-tile); overflow: hidden; border: 1px solid var(--line); }
.place-pin { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; z-index: 500; pointer-events: none; filter: drop-shadow(0 2px 3px rgb(0 0 0 / .3)); }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-btn { min-height: 76px; border: 2px solid var(--line); border-radius: var(--r-btn); background: var(--surface); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 10px 14px; text-align: left; }
.choice-btn b { font-size: 20px; } .choice-btn span { font-size: 16px; color: var(--ink-3); }
.choice-btn.on { border-color: var(--leaf); background: var(--leaf-soft); box-shadow: inset 0 0 0 1px var(--leaf); }

/* my trees */
.mine { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.mine-row { display: flex; gap: 12px; padding: 14px; border: 2px solid var(--line); border-radius: var(--r-tile); }
.mine-fruit { width: 64px; height: 64px; flex: none; }
.mine-body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; align-items: flex-start; }
.mine-body b { font-size: 22px; }
.toggle { min-height: 56px; width: 100%; border-radius: var(--r-btn); border: 2px solid var(--g300); background: var(--sunk); display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px; font-weight: 700; font-size: 20px; margin-top: 4px; }
.toggle-knob { width: 64px; height: 40px; border-radius: 12px; background: var(--g300); position: relative; flex: none; transition: background .15s ease-out; }
.toggle-knob::after { content: ''; position: absolute; top: 4px; left: 4px; width: 32px; height: 32px; border-radius: 9px; background: #fff; transition: transform .15s ease-out; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.toggle.is-on { border-color: var(--leaf); background: var(--leaf-soft); }
.toggle.is-on .toggle-knob { background: var(--leaf); }
.toggle.is-on .toggle-knob::after { transform: translateX(24px); }

/* sheet */
.sheet-back { position: fixed; inset: 0; z-index: 2000; background: rgb(0 0 0 / 0); display: flex; align-items: flex-end; justify-content: center; transition: background .22s ease-out; }
.sheet-back.open { background: rgb(0 0 0 / .35); }
.sheet { position: relative; width: 100%; max-width: 640px; background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; transform: translateY(100%); transition: transform .22s ease-out; }
.sheet-back.open .sheet { transform: none; }
.sheet-close { position: absolute; right: 10px; top: 10px; width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 30px; line-height: 1; }
.sheet-head { display: flex; gap: 14px; align-items: center; padding-right: 56px; }
.sheet-fruit { width: 84px; height: 84px; flex: none; }
.sheet h2 { font: 600 28px/1.15 var(--display); margin: 0 0 6px; }
.tag { display: inline-block; padding: 3px 10px; border-radius: var(--r-tag); font-size: 16px; font-weight: 700; }
.tag-on { background: var(--leaf-soft); color: var(--leaf); }
.tag-off { background: var(--sunk); color: var(--ink-3); border: 1px solid var(--line); }
.sheet-line { margin: 0; }
.sheet-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 6px; }

/* chats */
.threads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.thread a { display: flex; gap: 12px; align-items: center; padding: 12px; border: 2px solid var(--line); border-radius: var(--r-tile); text-decoration: none; color: var(--ink); }
.thread.unread a { border-color: var(--leaf); }
.thread-fruit { width: 52px; height: 52px; flex: none; }
.thread-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.thread-body b { font-size: 21px; }
.thread-last { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }

#view.chat { gap: 10px; padding-bottom: 0; }
.chat-who { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-fruit { width: 32px; height: 32px; flex: none; }
.safety { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--leaf-soft); color: var(--ink); font-weight: 700; font-size: 17px; display: flex; gap: 10px; align-items: center; }
.ico-shield { width: 18px; height: 22px; flex: none; background: var(--leaf); clip-path: polygon(50% 0, 100% 18%, 100% 50%, 50% 100%, 0 50%, 0 18%); }
.msgs { list-style: none; margin: 0; padding: 4px 0; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: var(--r-bubble); display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.msg.theirs { align-self: flex-start; background: var(--sunk); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.mine { align-self: flex-end; background: var(--leaf); color: var(--leaf-ink); border-bottom-right-radius: 6px; }
.msg-time { font-size: 14px; opacity: .75; align-self: flex-end; }
.msg-hint { color: var(--ink-3); text-align: center; padding: 16px; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); align-items: stretch; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-btn { min-height: 52px; padding: 6px 14px; border-radius: 14px; border: 2px solid var(--leaf); background: var(--surface); color: var(--ink); font-weight: 700; font-size: 18px; }
.quick-btn.addr { border-style: dashed; }
.send-row { display: flex; gap: 8px; align-items: stretch; }
.send-row textarea { flex: 1; resize: none; min-height: 56px; max-height: 140px; }
.send-btn { width: auto; min-width: 96px; }
.composer .link-quiet { align-self: center; }

/* menu */
.menu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.menu-item { display: flex; align-items: center; min-height: 60px; width: 100%; padding: 0 16px; border-radius: var(--r-btn); border: 2px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 700; font-size: 20px; text-align: left; }
.menu-item.danger { color: var(--warn); }
.donate { font-size: 16px; color: var(--ink-3); margin: 8px 0 0; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 3000; background: var(--g900); color: var(--g50); padding: 14px 18px; border-radius: 14px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .15s ease-out, transform .15s ease-out; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-color-scheme: dark) { #toast { background: var(--g50); color: var(--g900); } }

/* static pages (about, privacy, feedback) */
body.page { padding: 0 16px 48px; }
.prose { max-width: 640px; margin: 0 auto; }
.prose h1 { font: 600 32px/1.15 var(--display); margin: 24px 0 12px; }
.prose h2 { font: 600 24px/1.2 var(--display); margin: 28px 0 8px; }
.prose textarea, .prose select, .prose input[type=email] { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 19px; background: var(--surface); min-height: 56px; }
.page-top { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); max-width: 640px; margin: 0 auto; }
.page-top img { width: 36px; height: 36px; }
.page-top b { font: 600 22px var(--display); }
a[target=_blank]::after { content: ''; display: inline-block; width: .7em; height: .7em; margin-left: .2em; vertical-align: baseline; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M5 1H1v10h10V7M7 1h4v4M11 1L5 7' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M5 1H1v10h10V7M7 1h4v4M11 1L5 7' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E") center/contain no-repeat; }
.leaflet-control-attribution a[target=_blank]::after { display: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
