/* Fangwork v2: tokens and shared components. Look follows docs/prototype.html.
   Page-only styles live in the page module (ui.addStyle) so this file stays shared. */
/* Sarabun (SIL OFL, fonts/OFL-Sarabun.txt): Thai letters with loops, the face of school books and official
   letters, so older readers know it at a glance. */
@font-face { font-family: 'Sarabun'; font-weight: 400; font-display: swap; src: url(/fonts/sarabun-thai-400.woff2) format('woff2'); unicode-range: U+0E00-0E7F; }
@font-face { font-family: 'Sarabun'; font-weight: 500; font-display: swap; src: url(/fonts/sarabun-thai-500.woff2) format('woff2'); unicode-range: U+0E00-0E7F; }
@font-face { font-family: 'Sarabun'; font-weight: 600; font-display: swap; src: url(/fonts/sarabun-thai-600.woff2) format('woff2'); unicode-range: U+0E00-0E7F; }
@font-face { font-family: 'Sarabun'; font-weight: 700; font-display: swap; src: url(/fonts/sarabun-thai-700.woff2) format('woff2'); unicode-range: U+0E00-0E7F; }
@font-face { font-family: 'Sarabun'; font-weight: 400; font-display: swap; src: url(/fonts/sarabun-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Sarabun'; font-weight: 500; font-display: swap; src: url(/fonts/sarabun-latin-500.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Sarabun'; font-weight: 600; font-display: swap; src: url(/fonts/sarabun-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Sarabun'; font-weight: 700; font-display: swap; src: url(/fonts/sarabun-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }

/* "Daylight paddy": a bright page the colour of a rice field in the morning. Text is deep leaf green rather
   than black, the action colour is young-rice green, straw gold marks prices and highlights, and coral is kept
   only for time running out. --ink stays the text colour; --pri is the action colour.
   Always light, also when the phone is set to dark mode: the brief is a bright page that is easy to read. */
:root {
  --bg: #f4f8f0; --surface: #ffffff; --ink: #172a1c; --muted: #56685a; --line: #dde7d7; --wash: #eef4e9;
  --pri: #22863f; --on-pri: #ffffff; --pri-ink: #17692f; --pri-wash: #e2f2e5; --price: #d8432a;
  --coral: #e2533b; --coral-ink: #b3341d; --coral-wash: #fde5df;
  --straw: #f6b92f; --straw-ink: #855800; --straw-wash: #fff3cf; --green: #1c7c3d; --green-wash: #e0f2e4;
  --line-green: #06c755; --on-ink: #ffffff;
  --font: 'Sarabun', 'Noto Sans Thai', Tahoma, sans-serif;
  --r: 20px; --r-sm: 14px; --pill: 999px;
  --top-h: 56px; --nav-h: 60px; --nav-gap: 10px; --gut: 12px; --pad-b: 20px;
  color-scheme: light;
}

*, *::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: 18px; line-height: 1.55; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
:focus-visible { outline: 3px solid var(--straw); outline-offset: 2px; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell: one phone-width column, also on a computer ---------- */
.shell { max-width: 560px; margin: 0 auto; min-height: 100dvh; background: var(--bg); display: flex; flex-direction: column; position: relative; }
@media (min-width: 600px) { .shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 4px; padding: 0 8px 0 6px; background: var(--surface); border-bottom: 1.5px solid var(--line); }
.topbar .title { flex: 1; min-width: 0; font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logo { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 700; padding-left: 8px; text-decoration: none; color: var(--pri-ink); }
.topbar .logo .mark { width: 32px; height: 32px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--pri); color: #fff; }
.icon-btn { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; position: relative; text-decoration: none; flex: none; }
.icon-btn:active { background: var(--pri-wash); }
/* tab pages: the top bar is the start of the green shop band */
.topbar.brand-head { background: var(--pri); color: var(--on-pri); border-bottom-color: transparent; }
.brand-head .logo { color: var(--on-pri); }
.brand-head .logo .mark { background: #fff; color: #22863f; }
.brand-head .icon-btn:active { background: rgba(255, 255, 255, .16); }
.brand-head .btn.out { border-color: var(--on-pri); color: var(--on-pri); background: transparent; }
.brand-head .dot { box-shadow: 0 0 0 2px var(--pri); background: var(--straw); color: #2b1d00; }
.dot { position: absolute; top: 6px; right: 5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
main#view { flex: 1; display: flex; flex-direction: column; }
.page { flex: 1; padding: 12px var(--gut) var(--pad-b); display: flex; flex-direction: column; gap: 12px; }
.page.tight { gap: 10px; }
.bottomnav { position: sticky; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1.5px solid var(--line); padding: 0 4px env(safe-area-inset-bottom, 0px); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0 4px; font-size: 14px; color: var(--muted); text-decoration: none; min-height: var(--nav-h); justify-content: center; }
.bottomnav a svg { width: 54px; height: 30px; padding: 3px 15px; border-radius: var(--pill); box-sizing: border-box; }
.bottomnav a.on { color: var(--pri-ink); font-weight: 700; }
.bottomnav a.on svg { background: var(--pri-wash); }
.bottomnav a.sell svg { background: var(--pri); color: var(--on-pri); }
/* a sticky action bar at the bottom of a page (book, take, post) */
.actionbar { position: sticky; bottom: 0; z-index: 15; background: var(--surface); border-top: 1.5px solid var(--line); padding: 10px var(--gut) calc(10px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
body.no-nav .bottomnav { display: none; }
/* inside a page the bar reaches the screen edges, and on pages with the bottom nav it sits just above the nav
   (both are sticky at the bottom; without this the nav covers the bar) */
.page > .actionbar { margin: auto calc(-1 * var(--gut)) calc(-1 * var(--pad-b)); }
body:not(.no-nav) .page > .actionbar { bottom: calc(var(--nav-h) + 1.5px + env(safe-area-inset-bottom, 0px)); }
.grid2 .btn.sm { font-size: 16px; padding: 0 10px; }

/* ---------- type ---------- */
.h1 { font-size: 26px; font-weight: 700; line-height: 1.28; }
.h2 { font-size: 22px; font-weight: 700; line-height: 1.3; }
.h3 { font-size: 18px; font-weight: 700; line-height: 1.4; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.tiny { font-size: 14px; }
.strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.price { font-size: 18px; }
.price b { font-size: 34px; font-weight: 700; color: var(--price); }
.hot { color: var(--coral-ink); }
.ok-text { color: var(--green); }
.section-title { font-size: 19px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.s8 { gap: 8px; } .stack.s4 { gap: 4px; } .stack.s16 { gap: 16px; } .stack.s24 { gap: 24px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px; border-radius: var(--pill); font-size: 18px; font-weight: 700; text-decoration: none; text-align: center; border: 1.5px solid transparent; line-height: 1.25; }
.btn.block { width: 100%; }
.btn.pri { background: var(--pri); color: var(--on-pri); }
.btn.pri:active { background: var(--pri-ink); }
.btn.out { border: 2px solid var(--pri); color: var(--pri-ink); background: var(--surface); }
.btn.ghost { background: var(--pri-wash); color: var(--pri-ink); }
.btn.warm { background: var(--coral); color: #fff; }
.btn.line { background: var(--line-green); color: #fff; }
.btn.ok { background: var(--green); color: var(--on-ink); }
.btn.danger { border: 2px solid var(--coral-ink); color: var(--coral-ink); background: var(--surface); }
.btn.sm { min-height: 46px; font-size: 17px; padding: 0 16px; }
.btn.xs { min-height: 44px; font-size: 15px; padding: 0 12px; }
.btn[disabled], .btn.is-busy { opacity: .45; pointer-events: none; }
.link { color: var(--pri-ink); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.textbtn { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- segmented tabs ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--pill); padding: 3px; }
.seg button, .seg a { min-height: 44px; border-radius: var(--pill); font-weight: 700; font-size: 18px; text-align: center; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 4px; text-decoration: none; padding: 0 8px; }
.seg .on { background: var(--pri); color: var(--on-pri); }
.seg .count { font-size: 13px; line-height: 20px; min-width: 20px; background: var(--straw); color: #2b1d00; border-radius: 999px; padding: 0 6px; }

/* ---------- chips and option cards ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: var(--pill); border: 2px solid var(--line); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; background: var(--surface); }
.chip.on { background: var(--pri); color: var(--on-pri); border-color: var(--pri); }
.chip.small { min-height: 44px; font-size: 16px; padding: 0 12px; }
.opt { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--r); width: 100%; background: var(--surface); }
.opt.on { border-color: var(--pri); background: var(--pri-wash); }
.opt .r { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); margin-top: 3px; display: grid; place-items: center; }
.opt.on .r { border-color: var(--pri); }
.opt.on .r::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--pri); }
.opt b { display: block; font-size: 18px; }
.opt span.s { display: block; font-size: 15px; color: var(--muted); }
.opt[disabled] { opacity: .45; }

/* ---------- form fields ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > .k, .fld > label.k { font-weight: 700; font-size: 17px; }
.fld > .s { font-size: 14px; color: var(--muted); margin-top: -4px; }
.fld .err { font-size: 14px; color: var(--coral-ink); }
.inp { display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 14px; padding: 0 14px; min-height: 52px; background: var(--surface); }
.inp:focus-within { border-color: var(--pri); }
.inp input, .inp select { border: 0; background: none; font-size: 18px; font-weight: 600; width: 100%; min-width: 0; outline: none; padding: 10px 0; }
.inp select { font-size: 17px; appearance: none; -webkit-appearance: none; }
.inp .u { color: var(--muted); white-space: nowrap; }
textarea.ta { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; min-height: 96px; resize: vertical; background: var(--surface); font-size: 17px; }
textarea.ta:focus { border-color: var(--pri); outline: none; }
.check { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; padding: 10px 12px; border-radius: 14px; background: var(--pri-wash); }
.check input { width: 22px; height: 22px; margin: 3px 0 0; accent-color: var(--pri); }
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; border: 2px solid var(--line); background: var(--surface); border-radius: var(--r); overflow: hidden; }
.stepper button { height: 54px; font-size: 26px; font-weight: 600; text-align: center; color: var(--pri-ink); }
.stepper button:active { background: var(--wash); }
.stepper input { text-align: center; font-size: 28px; font-weight: 700; border: 0; background: none; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; outline: none; }
.stepper .u { display: block; text-align: center; font-size: 14px; color: var(--muted); margin-top: -8px; padding-bottom: 6px; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; background: var(--surface); }
.card.wash { background: var(--pri-wash); border-color: transparent; }
.card.strong { border: 2px solid var(--pri); border-radius: 18px; padding: 14px; }
.item { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); width: 100%; text-decoration: none; color: inherit; }
.item .th { width: 84px; height: 84px; border-radius: 12px; overflow: hidden; display: block; background: var(--straw-wash); }
.item .th img { width: 100%; height: 100%; object-fit: cover; }
.item .it { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding-top: 1px; }
.item .t { font-size: 17px; font-weight: 700; line-height: 1.35; }
.item .pr { font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--price); }
.meta { font-size: 14.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { font-style: normal; font-size: 14px; font-weight: 500; padding: 2px 10px; border-radius: var(--pill); background: var(--wash); white-space: nowrap; }
.tag.hot { background: var(--coral-wash); color: var(--coral-ink); font-weight: 600; }
.tag.ok { background: var(--green-wash); color: var(--green); font-weight: 600; }
.tag.warn { background: var(--straw-wash); color: var(--straw-ink); font-weight: 600; }
.tag.ink { background: var(--ink); color: var(--on-ink); font-weight: 600; }
.hero { height: 200px; border-radius: 16px; overflow: hidden; background: var(--straw-wash); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border-top: 1px solid var(--line); }
.facts > div { padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.facts > div:nth-child(odd) { padding-right: 10px; }
.facts dt { font-size: 15px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-size: 17px; }
.facts dd.hot { color: var(--coral-ink); }
.who { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-decoration: none; color: inherit; }
.who .n { font-weight: 700; }
.av { width: 46px; height: 46px; border-radius: 50%; background: var(--straw); color: #2b1d00; display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.sm { width: 34px; height: 34px; font-size: 14px; }
.av.lg { width: 72px; height: 72px; font-size: 26px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--green); }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--pri-wash); font-size: 15.5px; line-height: 1.5; }
.note > svg { flex: none; margin-top: 3px; }
.note.warn { background: var(--straw-wash); }
.note.ok { background: var(--green-wash); }
.note.bad { background: var(--coral-wash); }
.note .btn { align-self: flex-start; }
.sum { border-radius: 14px; background: var(--pri-wash); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 16px; }
.sum > div { display: flex; justify-content: space-between; gap: 12px; }
.sum .tot { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 700; font-size: 18px; }
.sum .v { font-variant-numeric: tabular-nums; text-align: right; }
.call { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.call .tel { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; user-select: all; }
.done-mark { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 6px 0 2px; }
.done-mark .ok { width: 64px; height: 64px; border-radius: 50%; background: var(--green-wash); color: var(--green); display: grid; place-items: center; }
.done-mark .h2 { margin-top: 6px; }

/* deal step strip and timeline */
.prog { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.prog div { font-size: 14px; font-weight: 600; color: var(--muted); padding-top: 8px; border-top: 5px solid var(--line); }
.prog div.y { border-color: var(--green); color: var(--green); }
.prog div.now { border-color: var(--straw); color: var(--ink); }
.tl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding-bottom: 10px; position: relative; }
.tl li::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--line); }
.tl li:last-child::before { display: none; }
.tl .d { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); position: relative; }
.tl li.y .d { background: var(--green); border-color: var(--green); color: var(--surface); }
.tl li.now .d { border-color: var(--straw); background: var(--straw-wash); color: var(--ink); }
.tl b { display: block; font-size: 16px; }
.tl span { font-size: 14px; color: var(--muted); }
.amt { font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.amt small { font-size: 16px; font-weight: 500; color: var(--muted); }
.qr { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--pri-wash); }
.qr .code { width: 140px; height: 140px; background: #fff; border-radius: 8px; padding: 6px; }
.qr .code svg { width: 100%; height: 100%; display: block; }
.stars { display: flex; gap: 6px; justify-content: center; }
.stars button { width: 48px; height: 48px; display: grid; place-items: center; color: var(--line); }
.stars button.on { color: var(--straw); }

/* listing page: the picture runs edge to edge at the top, like a shop product page */
.pg-listing > .hero:first-child { margin: -12px calc(-1 * var(--gut)) 0; border-radius: 0; height: 250px; }

/* shop-style tiles: two per row on home */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-decoration: none; color: inherit; min-width: 0; }
.tile:active { border-color: var(--pri); }
.tile .ti { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--straw-wash); }
.tile .ti img, .tile .ti svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tb-l, .tile .tb-r { position: absolute; top: 8px; font-style: normal; font-size: 13px; font-weight: 700; line-height: 22px; padding: 0 8px; border-radius: 8px; display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.tile .tb-l { left: 8px; background: var(--pri); color: #fff; }
.tile .tb-l.ink { background: var(--ink); color: var(--surface); }
.tile .tb-r { right: 8px; background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.tile .tb-r.hot { background: var(--coral); color: #fff; }
.tile .tbd { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 10px; min-width: 0; }
.tile .tt { font-size: 16px; font-weight: 700; line-height: 1.35; }
.tile .tp { color: var(--price); line-height: 1.25; margin: 1px 0 2px; }
.tile .tp b { font-size: 23px; font-weight: 700; }
.tile .tp small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.tile .tm { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 3px; min-width: 0; line-height: 1.4; }
.tile .tm svg { flex: none; }
.tile .tv { margin-top: 3px; align-self: flex-start; font-size: 13px; font-weight: 600; color: var(--green); background: var(--green-wash); border-radius: 6px; padding: 0 6px; display: inline-flex; align-items: center; gap: 3px; }

/* status dot for balers */
.st { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 2px 10px; border-radius: var(--pill); background: var(--wash); color: var(--muted); }
.st::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.st.free { background: var(--green-wash); color: var(--green); }
.st.busy { background: var(--coral-wash); color: var(--coral-ink); }

/* maps */
.map-box { height: 160px; border-radius: 14px; overflow: hidden; position: relative; background: var(--wash); }
.map-box .map, .map-pick .map { position: absolute; inset: 0; }
.map-pick { position: relative; height: 280px; border-radius: 14px; overflow: hidden; background: var(--wash); }
.map-pick .center-pin { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; transform: translate(-50%, -100%); pointer-events: none; z-index: 2; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.map-pick .where { position: absolute; left: 8px; right: 8px; top: 8px; z-index: 2; background: rgba(21,21,20,.82); color: #fff; font-size: 14px; padding: 6px 10px; border-radius: 10px; text-align: center; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos .ph { aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; position: relative; background: var(--wash); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.photos .ph button { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.photo-add { aspect-ratio: 1; border-radius: var(--r-sm); border: 2px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center; cursor: pointer; }

/* empty states, skeletons */
.empty { text-align: center; padding: 24px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); }
.empty .h3 { color: var(--ink); }
.sk { background: linear-gradient(90deg, var(--wash), var(--line), var(--wash)); background-size: 200% 100%; border-radius: 10px; min-height: 16px; }
@media (prefers-reduced-motion: no-preference) { .sk { animation: sk 1.2s linear infinite; } @keyframes sk { to { background-position: -200% 0; } } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--pri); display: inline-block; }
@media (prefers-reduced-motion: no-preference) { .spinner { animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } }

/* toast, sheet (bottom), dialog */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(528px, calc(100% - 32px)); background: var(--ink); color: var(--on-ink); padding: 12px 16px; border-radius: 14px; font-size: 15px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--coral-ink); color: var(--on-ink); }
.toast.good { background: var(--green); color: var(--on-ink); }
/* form pages have no bottom nav but a tall action bar: show the message under the top bar instead */
body.no-nav .toast { bottom: auto; top: calc(var(--top-h) + 12px + env(safe-area-inset-top, 0px)); }
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(560px, 100%); max-height: 90dvh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px var(--gut) calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
.sheet .grip { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: -8px auto 2px; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: up .18s ease-out; }
  .sheet { animation: sheetup .2s ease-out; }
  @keyframes up { from { opacity: 0; transform: translate(-50%, 8px); } }
  @keyframes sheetup { from { transform: translateY(24px); opacity: .6; } }
}

/* list rows (notifications, team tables) */
.rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.rows > a, .rows > div, .rows > button { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; width: 100%; }
.rows .unread { font-weight: 600; }
.rows .unread::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--pri); margin-top: 8px; flex: none; }

/* team pages: a bit denser, still touch friendly */
.team-head { background: var(--pri-ink); color: #fff; border-bottom-color: transparent; }
.team-head .icon-btn:active { background: rgba(255,255,255,.12); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.kpi { border-radius: 14px; background: var(--surface); border: 1px solid var(--line); padding: 8px 10px; min-width: 0; }
.kpi b { display: block; font-size: 24px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 13px; color: var(--muted); line-height: 1.35; display: block; }

/* ---------- shop panels: white full-width sections on the page colour, like a shop app's product page ---------- */
.page.panels { gap: 8px; }
.pn { margin: 0 calc(-1 * var(--gut)); padding: 12px var(--gut); background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.pn-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 18px; font-weight: 700; line-height: 1.4; }
.pn-h a, .pn-h .more { font-size: 15px; font-weight: 600; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 2px; min-height: 36px; }
/* label on the left, value on the right: dense fact rows */
.kv { display: flex; flex-direction: column; margin: 0; }
.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 16px; flex: none; }
.kv dd { margin: 0; font-weight: 600; font-size: 16.5px; text-align: right; min-width: 0; }
.kv dd.hot { color: var(--coral-ink); }

/* the green band under a green top bar (tab pages, account) with a white search-bar style place picker */
.band { margin: -12px calc(-1 * var(--gut)) 0; padding: 2px var(--gut) 14px; background: var(--pri); color: var(--on-pri); display: flex; flex-direction: column; gap: 8px; }
.band .band-tag { font-size: 15px; line-height: 1.45; opacity: .95; }
.band .h2 { color: var(--on-pri); }
.band .btn.out { border-color: var(--on-pri); color: var(--on-pri); background: transparent; }
.band .seg { border-color: transparent; }
.loc-bar { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 0 7px 0 14px; background: #fff; color: #172a1c; border-radius: 14px; text-align: left; }
.loc-bar .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; font-weight: 600; }
.loc-bar .chg { flex: none; font-size: 15px; font-weight: 700; color: #fff; background: #22863f; border-radius: 10px; padding: 5px 12px; }
.loc-bar svg { flex: none; color: #56685a; }

/* a listing with no photo: a Material symbol on a soft colour fills the picture box */
.ph-art { display: grid; place-items: center; width: 100%; height: 100%; background: var(--straw-wash); color: var(--straw-ink); }
.ph-art.field { background: var(--green-wash); color: var(--green); }
.ph-art.baler { background: var(--pri-wash); color: var(--pri-ink); }
.ph-art > svg { width: 46% !important; height: 46% !important; max-width: 112px; max-height: 112px; }
