/* Layout: the app is a passport. Home opens on a leather cover with the crew's tally, then entry pages
   (trips), visa pages (ink stamps) and a 77-province checklist. A trip opens on its data page with
   a stamp slot and a machine-readable strip. Everything else sits on security paper as ruled ledgers.
   Boldness lives in the ink stamps; the rest stays flat, ruled and quiet. */
:root{
  --paper:#E6EDE8; --sheet:#F5F8F5; --ink:#1B2440; --muted:#56637A; --rule:#C6D1CA; --guil:#CBD8D0;
  --accent:#24489E; --accent-ink:#FFFFFF; --accent-soft:#DAE3F4;
  --cover:#5A1D29; --cover-2:#43141E; --gold:#D4B26A; --gold-dim:rgba(212,178,106,.55);
  --ink-r:#B42F2A; --ink-v:#59409C; --ink-g:#1B7350; --ink-b:#24489E; --stamp-blend:multiply;
  --pos:#1B7350; --pos-soft:#D9ECE1; --neg:#B42F2A; --neg-soft:#F4DCDA;
  --print:#FBFBF8; --scrim:rgba(14,20,32,.55); --shadow:rgba(27,36,64,.14);
  --c1:#C4621B; --c2:#24489E; --c3:#6C46AE; --c4:#17806A; --c5:#B53272; --c6:#66717F;
  --f-display:"Chonburi", "Anuphan", Georgia, serif;
  --f-body:"Anuphan", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  --f-mrz:"Share Tech Mono", "OCR B", ui-monospace, "Courier New", monospace;
}
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){
  --paper:#10161B; --sheet:#171F26; --ink:#E5EAEE; --muted:#97A3AF; --rule:#2A3640; --guil:#1D2830;
  --accent:#93B0F2; --accent-ink:#0F151A; --accent-soft:#223049;
  --cover:#4A1822; --cover-2:#36101A; --gold:#DCC083; --gold-dim:rgba(220,192,131,.5);
  --ink-r:#EE8A82; --ink-v:#B9A3F2; --ink-g:#6CCFA0; --ink-b:#93B0F2; --stamp-blend:normal;
  --pos:#6CCFA0; --pos-soft:#17332A; --neg:#EE8A82; --neg-soft:#3B2024;
  --print:#ECEDE8; --scrim:rgba(0,0,0,.7); --shadow:rgba(0,0,0,.45);
  --c1:#EE9A5C; --c2:#93B0F2; --c3:#B79AF0; --c4:#5CCAB0; --c5:#F07FB4; --c6:#A0AAB8; color-scheme:dark } }
:root[data-theme="dark"]{
  --paper:#10161B; --sheet:#171F26; --ink:#E5EAEE; --muted:#97A3AF; --rule:#2A3640; --guil:#1D2830;
  --accent:#93B0F2; --accent-ink:#0F151A; --accent-soft:#223049;
  --cover:#4A1822; --cover-2:#36101A; --gold:#DCC083; --gold-dim:rgba(220,192,131,.5);
  --ink-r:#EE8A82; --ink-v:#B9A3F2; --ink-g:#6CCFA0; --ink-b:#93B0F2; --stamp-blend:normal;
  --pos:#6CCFA0; --pos-soft:#17332A; --neg:#EE8A82; --neg-soft:#3B2024;
  --print:#ECEDE8; --scrim:rgba(0,0,0,.7); --shadow:rgba(0,0,0,.45);
  --c1:#EE9A5C; --c2:#93B0F2; --c3:#B79AF0; --c4:#5CCAB0; --c5:#F07FB4; --c6:#A0AAB8; color-scheme:dark }

html{-webkit-text-size-adjust:100%}
body{background:var(--paper);color:var(--ink);font-family:var(--f-body);font-size:15px;line-height:1.6;font-variant-numeric:tabular-nums}
body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:30;background:var(--paper)}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
h1,h2,h3{margin:0;text-wrap:balance;line-height:1.25}
p{margin:0}
.gut{max-width:720px;box-sizing:border-box;margin:0 auto;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
main.gut{padding-block:8px 140px;display:flex;flex-direction:column;gap:28px}
.muted{color:var(--muted)}
.small{font-size:13px}
.num{font-variant-numeric:tabular-nums;white-space:nowrap}
.guil{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;opacity:.5}

/* buttons: ink on paper, squared like rubber-stamped forms */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:6px;background:var(--ink);color:var(--paper);font-weight:600;padding:10px 18px;min-height:44px}
.btn:disabled{opacity:.5;cursor:default}
.btn-line{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:1px solid var(--ink);border-radius:6px;background:transparent;padding:7px 14px;font-weight:600;min-height:38px}
.btn-line.sm{padding:4px 10px;min-height:32px;font-size:13px}
.btn-line:disabled{opacity:.45;cursor:default}
.btn-danger{border:1px solid var(--neg);color:var(--neg);background:transparent;border-radius:6px;padding:10px 18px;font-weight:600;min-height:44px}
.armed{background:var(--neg)!important;color:var(--sheet)!important;border-color:var(--neg)!important}
.icon-btn{display:inline-grid;place-items:center;width:44px;height:44px;border-radius:50%;border:0;background:transparent;color:inherit}
.icon-btn:hover{background:var(--sheet)}
.icon-btn svg{width:22px;height:22px}
.link{color:var(--accent);text-decoration:underline;text-underline-offset:3px;font-weight:500}

/* top bar */
.topbar{position:sticky;top:env(safe-area-inset-top,0px);z-index:20;background:var(--paper)}
.topbar .gut{display:flex;align-items:center;gap:6px;min-height:56px}
.topbar .where{flex:1;font-weight:600;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* cover */
.cover{position:relative;overflow:hidden;border-radius:4px 14px 14px 4px;background:radial-gradient(120% 90% at 30% 10%,var(--cover) 0%,var(--cover-2) 100%);color:var(--gold);padding:26px 22px 22px 30px;box-shadow:inset 8px 0 0 rgba(0,0,0,.18),0 10px 26px var(--shadow)}
.cover::before{content:"";position:absolute;inset:12px 12px 12px 20px;border:1px solid var(--gold-dim);border-radius:2px 8px 8px 2px;pointer-events:none}
.cover .emb{width:58px;height:58px;color:var(--gold);flex:none}
.cover-top{display:flex;gap:16px;align-items:center}
.cover h1{font-family:var(--f-display);font-weight:400;font-size:clamp(26px,7.5vw,34px);line-height:1.15;color:var(--gold)}
.cover .sub{font-size:13px;letter-spacing:.24em;color:var(--gold-dim);margin-top:2px}
.tally{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:22px;border-top:1px solid var(--gold-dim);padding-top:14px}
.tally div{display:flex;flex-direction:column}
.tally b{font-family:var(--f-display);font-weight:400;font-size:26px;line-height:1.2}
.tally b small{font-family:var(--f-body);font-size:14px;color:var(--gold-dim)}
.tally span{font-size:13px;color:var(--gold-dim)}
.cover .who{margin-top:16px;display:flex;gap:8px;flex-wrap:wrap;position:relative}
.cover .who button{border:1px solid var(--gold-dim);background:transparent;color:var(--gold);border-radius:999px;padding:4px 12px;font-size:13px;min-height:32px}
.cover .who button[aria-pressed="true"]{background:var(--gold);color:var(--cover-2);border-color:var(--gold);font-weight:600}

/* section tabs inside the passport */
.ptabs{display:flex;gap:22px;border-bottom:1px solid var(--rule);overflow-x:auto}
.ptabs button{border:0;background:transparent;padding:10px 0 9px;font-weight:600;color:var(--muted);border-bottom:2px solid transparent;margin-bottom:-1px;white-space:nowrap;min-height:44px}
.ptabs button[aria-current="page"]{color:var(--ink);border-bottom-color:var(--ink)}
.sec{display:flex;flex-direction:column;gap:12px}
.sec-h{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.sec-h h2{font-size:18px;font-weight:700}

/* trip entries */
.entries{border-top:1px solid var(--ink)}
.entry{display:grid;grid-template-columns:52px 1fr auto;gap:14px;align-items:center;width:100%;border:0;border-bottom:1px solid var(--rule);background:transparent;padding:16px 2px;text-align:left;color:inherit}
.entry:hover{background:var(--sheet)}
.entry .d{display:flex;flex-direction:column;line-height:1.2}
.entry .d b{font-size:24px;font-weight:700}
.entry .d span{font-size:12px;color:var(--muted)}
.entry .dest{font-family:var(--f-display);font-size:21px;line-height:1.25;overflow-wrap:anywhere}
.entry .meta{font-size:13px;color:var(--muted)}
.entry .mini{width:72px;height:72px;display:grid;place-items:center}
.entry .mini .stamp{width:72px;transform:rotate(var(--rot,0deg))}
.entry .mini.empty{width:64px;height:64px;border:1.5px dashed var(--rule);border-radius:50%;font-size:11px;color:var(--muted);text-align:center;line-height:1.2;padding:6px;box-sizing:border-box}
.tag{display:inline-block;font-size:12px;font-weight:600;color:var(--ink-r);border:1px solid var(--ink-r);border-radius:3px;padding:0 6px;margin-left:6px;vertical-align:2px;transform:rotate(-3deg)}

/* visa pages */
.vpage{position:relative;overflow:hidden;background:var(--sheet);border:1px solid var(--rule);border-radius:3px;padding:18px 14px 34px}
.vpage-h{position:relative;display:flex;justify-content:space-between;font-size:12px;color:var(--muted);letter-spacing:.12em}
.vgrid{position:relative;display:grid;grid-template-columns:1fr 1fr;gap:6px 4px;margin-top:8px}
.vslot{border:0;background:transparent;padding:0;display:grid;place-items:center;aspect-ratio:1/1;max-width:100%}
.vslot .stamp{width:88%;transform:translate(var(--dx,0),var(--dy,0)) rotate(var(--rot,0deg))}
.vpage-n{position:absolute;bottom:10px;left:0;right:0;text-align:center;font-family:var(--f-mrz);font-size:13px;color:var(--muted)}
.stamp{display:block;color:var(--ink-b);mix-blend-mode:var(--stamp-blend)}
.stamp svg{display:block;width:100%;height:auto;overflow:visible}

/* provinces */
.prog{height:8px;background:var(--rule);border-radius:999px;overflow:hidden}
.prog i{display:block;height:100%;background:var(--ink-r)}
.region{display:flex;flex-direction:column;gap:8px;padding:14px 0;border-top:1px solid var(--rule)}
.region h3{font-size:15px;font-weight:700;display:flex;justify-content:space-between}
.provs{display:flex;flex-wrap:wrap;gap:6px}
.prov{font-size:13px;padding:2px 9px;border-radius:3px;border:1px dashed var(--rule);color:var(--muted)}
.prov.on{border:1.5px solid var(--ink-r);color:var(--ink-r);font-weight:600}

/* trip data page */
.datapage{position:relative;overflow:hidden;background:var(--sheet);border:1px solid var(--rule);border-radius:3px}
.dp-in{position:relative;padding:14px 16px 0}
.dp-top{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);letter-spacing:.1em;padding-bottom:10px;border-bottom:1px solid var(--rule)}
.dp-grid{display:grid;grid-template-columns:118px 1fr;gap:16px;padding:16px 0 14px}
.dp-slot{width:118px;height:140px;border:1px solid var(--rule);background:var(--paper);display:grid;place-items:center;position:relative;border-radius:2px}
.dp-slot .stamp{width:116px;transform:rotate(var(--rot,0deg))}
.slot-btn{border:1.5px dashed var(--muted);border-radius:4px;background:transparent;width:96px;height:112px;font-size:13px;font-weight:600;color:var(--ink);line-height:1.35;padding:6px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px}
.slot-btn svg{width:26px;height:26px}
.slot-btn:disabled{color:var(--muted);font-weight:500;cursor:default}
.dp-fields{display:flex;flex-direction:column;gap:8px;min-width:0}
.f small{display:block;font-size:11px;color:var(--muted);letter-spacing:.04em;line-height:1.3}
.f b{font-weight:600}
.f .dest{font-family:var(--f-display);font-weight:400;font-size:clamp(26px,8vw,40px);line-height:1.15;overflow-wrap:anywhere}
.dp-places{display:flex;flex-wrap:wrap;gap:8px;padding-bottom:14px}
.pchip{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--rule);border-radius:4px;padding:4px 10px;font-size:13px;background:transparent;min-height:34px}
.pchip.done{border-color:var(--ink-r);color:var(--ink-r);font-weight:600}
button.pchip:not(:disabled){border-style:dashed;border-color:var(--ink);font-weight:600}
.mrz{position:relative;background:var(--paper);border-top:1px solid var(--rule);padding:10px 16px 12px;font-family:var(--f-mrz);font-size:clamp(8px,calc((min(100vw,720px) - 70px) / 30),15px);line-height:1.5;letter-spacing:.04em;white-space:pre;overflow:hidden;color:var(--ink)}
.avs{display:flex}
.av{display:inline-grid;place-items:center;width:30px;height:30px;border-radius:50%;color:#fff;font-size:13px;font-weight:600;border:2px solid var(--sheet);flex:none}
.avs .av+.av{margin-left:-8px}
.av.lg{width:36px;height:36px;font-size:15px}

/* ledgers */
.ledger{border-top:1px solid var(--ink)}
.row{display:flex;gap:12px;align-items:center;width:100%;text-align:left;border:0;border-bottom:1px solid var(--rule);background:transparent;padding:12px 2px;color:inherit}
button.row:hover{background:var(--sheet)}
.row .info{flex:1;min-width:0}
.row .ttl{font-weight:600;overflow-wrap:anywhere}
.row .sub{font-size:13px;color:var(--muted)}
.row .amt{text-align:right;font-weight:700}
.row .amt small{display:block;font-weight:500;font-size:12px;color:var(--muted)}
.cat{width:40px;height:40px;border-radius:6px;border:1.5px solid currentColor;display:grid;place-items:center;flex:none;font-size:12px;font-weight:700;line-height:1}
.day-h{display:flex;justify-content:space-between;font-size:13px;color:var(--muted);font-weight:600;padding:0 2px 6px}
.empty{border:1.5px dashed var(--rule);border-radius:4px;padding:26px 20px;display:flex;flex-direction:column;gap:10px;align-items:flex-start}
.empty h2{font-size:19px;font-weight:700}
.empty .acts{display:flex;flex-wrap:wrap;gap:10px;margin-top:4px}
.note{border-left:3px solid var(--accent);background:var(--accent-soft);padding:10px 14px;font-size:14px}

/* summary */
.total{display:flex;flex-direction:column;gap:2px}
.total .lbl{font-size:13px;color:var(--muted)}
.total .big{font-size:clamp(34px,10vw,48px);font-weight:700;line-height:1.1;letter-spacing:-.01em}
.figs{display:flex;flex-wrap:wrap;gap:6px 24px;font-size:14px;color:var(--muted)}
.figs b{color:var(--ink);font-weight:600}
.mine{border:1.5px solid currentColor;border-radius:4px;padding:10px 14px;font-weight:600;align-self:flex-start}
.mine.neg{color:var(--neg)} .mine.pos{color:var(--pos)} .mine.ok{color:var(--muted)}
.catbar{display:flex;height:8px;gap:2px}
.catbar i{display:block;height:100%}
.legend{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:4px 18px;font-size:14px}
.legend div{display:flex;align-items:center;gap:8px;min-width:0}
.legend span:last-child{margin-left:auto;font-weight:600}
.dot{width:9px;height:9px;border-radius:2px;flex:none}
.pos{color:var(--pos)} .neg{color:var(--neg)}
.you{font-size:11px;font-weight:600;border:1px solid var(--accent);color:var(--accent);border-radius:3px;padding:0 6px}
.paid-stamp{display:inline-block;color:var(--ink-r);border:2px solid currentColor;border-radius:3px;padding:0 6px;font-size:11px;font-weight:700;letter-spacing:.08em;transform:rotate(-6deg);mix-blend-mode:var(--stamp-blend);line-height:1.5;flex:none}
.allclear{display:flex;align-items:center;gap:10px;color:var(--pos);font-weight:600;padding:12px 2px;border-bottom:1px solid var(--rule)}

/* itinerary */
.day{display:grid;grid-template-columns:48px 1fr;gap:12px}
.day-badge{display:flex;flex-direction:column;align-items:center;border-right:1px solid var(--rule);padding-right:10px}
.day-badge b{font-family:var(--f-display);font-weight:400;font-size:26px;line-height:1.1}
.day-badge span{font-size:11px;color:var(--muted)}
.day.today .day-badge b{color:var(--ink-r)}
.day-body{display:flex;flex-direction:column;min-width:0}
.dlabel{font-weight:700;padding-bottom:6px}
.dlabel small{color:var(--ink-r);font-weight:600;margin-left:6px}
.plan{display:grid;grid-template-columns:50px 1fr;gap:10px;padding:10px 2px;border-top:1px solid var(--rule);text-align:left;width:100%;background:transparent;color:inherit}
.plan[role=button]{cursor:pointer}
.plan[role=button]:hover{background:var(--sheet)}
.plan .tm{font-weight:700}
.plan .ttl{font-weight:600;overflow-wrap:anywhere}
.plan .pl,.plan .nt{font-size:13px;color:var(--muted);overflow-wrap:anywhere}
.plan .nt{white-space:pre-wrap}
.add-in-day{align-self:flex-start;border:0;background:transparent;padding:8px 0;font-size:13px;color:var(--accent);font-weight:600;text-decoration:underline;text-underline-offset:3px;min-height:36px}

/* moments wall */
.wall{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:18px 14px;padding:6px 2px}
.ph{background:var(--print);padding:7px 7px 10px;border:0;border-radius:1px;box-shadow:0 2px 5px var(--shadow),0 10px 22px var(--shadow);display:flex;flex-direction:column;gap:6px;text-align:left;color:#1A2643;transform:rotate(var(--r,0deg));transition:transform .2s ease}
.ph:hover{transform:rotate(0deg) scale(1.02)}
.ph .img{aspect-ratio:1/1;background:#D9DDD6;overflow:hidden;display:grid;place-items:center}
.ph img{width:100%;height:100%;object-fit:cover;display:block}
.ph.broken img{display:none}
.ph.broken .img::after{content:"ดูรูปนี้ไม่ได้";font-size:12px;color:#5D6778}
.ph .cap{font-size:13px;line-height:1.35;min-height:1.35em;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
@media (prefers-reduced-motion: reduce){.ph{transition:none}.ph:hover{transform:rotate(var(--r,0deg))}}

/* tab bar */
.tabbar{position:fixed;left:0;right:0;bottom:0;z-index:20;background:var(--sheet);border-top:1px solid var(--rule);padding-bottom:env(safe-area-inset-bottom,0px)}
.tabbar .gut{display:grid;grid-template-columns:repeat(5,1fr)}
.tab{display:flex;flex-direction:column;align-items:center;gap:2px;border:0;background:transparent;padding:8px 0 9px;font-size:12px;color:var(--muted);min-width:0;border-top:2px solid transparent;margin-top:-1px}
.tab svg{width:22px;height:22px}
.tab[aria-current="page"]{color:var(--ink);font-weight:600;border-top-color:var(--ink)}
.fab{position:fixed;z-index:21;right:max(16px,env(safe-area-inset-right,0px),calc((100vw - 720px)/2 + 16px));bottom:calc(78px + env(safe-area-inset-bottom,0px));box-shadow:0 8px 20px var(--shadow)}

/* sheet */
#sheet{position:fixed;inset:0;z-index:40;background:var(--scrim);display:flex;align-items:flex-end;justify-content:center}
.sheet{background:var(--sheet);width:100%;max-width:640px;max-height:92vh;overflow:auto;border-radius:10px 10px 0 0;padding:6px max(18px,env(safe-area-inset-right,0px)) calc(20px + env(safe-area-inset-bottom,0px)) max(18px,env(safe-area-inset-left,0px));animation:up .22s ease-out;box-sizing:border-box}
@media (min-width:700px){#sheet{align-items:center}.sheet{border-radius:8px;max-height:88vh}}
@keyframes up{from{transform:translateY(24px);opacity:.6}to{transform:none;opacity:1}}
@media (prefers-reduced-motion: reduce){.sheet{animation:none}}
.sheet-h{display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:var(--sheet);padding:10px 0;z-index:1;border-bottom:1px solid var(--rule);margin-bottom:14px}
.sheet-h h3{font-size:18px}
.form{display:flex;flex-direction:column;gap:14px}
.fld{display:flex;flex-direction:column;gap:6px;border:0;padding:0;margin:0;min-width:0}
.fld>span,.fld legend{font-size:13px;font-weight:600;color:var(--muted);padding:0}
.fld input,.fld select,.fld textarea,.rate-row input,.place-add input{width:100%;box-sizing:border-box;border:0;border-bottom:1.5px solid var(--rule);border-radius:0;background:transparent;padding:8px 2px;min-height:44px;min-width:0}
.fld textarea{min-height:64px;resize:vertical;border:1.5px solid var(--rule);border-radius:4px;padding:8px 10px}
.fld input:focus,.fld select:focus,.fld textarea:focus,.rate-row input:focus,.place-add input:focus{border-color:var(--accent);outline:none}
.hint{font-size:12px;color:var(--muted)}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.row-amt{display:grid;grid-template-columns:1fr 110px;gap:12px}
.rate-row{display:grid;grid-template-columns:76px auto 1fr 44px;gap:8px;align-items:center}
.place-add{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:end}
.seg{display:flex;border:1.5px solid var(--ink);border-radius:6px;overflow:hidden}
.seg label{flex:1;text-align:center;padding:8px;font-weight:500;font-size:14px;cursor:pointer;position:relative}
.seg label+label{border-left:1.5px solid var(--ink)}
.seg input{position:absolute;opacity:0;pointer-events:none}
.seg label:has(input:checked){background:var(--ink);color:var(--sheet);font-weight:600}
.seg label:has(input:focus-visible){outline:2px solid var(--accent);outline-offset:-4px}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{position:relative;border:1px solid var(--rule);border-radius:4px;padding:6px 12px;font-size:14px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-height:36px;box-sizing:border-box}
.chip input{position:absolute;opacity:0;pointer-events:none}
.chip:has(input:checked){border-color:var(--ink);background:var(--ink);color:var(--sheet);font-weight:600}
.chip:has(input:focus-visible){outline:2px solid var(--accent)}
.chip .x{border:0;background:transparent;padding:0 0 0 4px;font-size:18px;line-height:1;color:inherit;min-width:24px;min-height:24px}
.share-row{display:grid;grid-template-columns:1fr 120px;gap:10px;align-items:center}
.share-row input{text-align:right}
.status-line{font-size:13px;font-weight:600}
.form-actions{display:flex;gap:10px;justify-content:space-between;align-items:center;flex-wrap:wrap;margin-top:6px}
.form-actions .btn{margin-left:auto}
.err{color:var(--neg);font-size:13px;font-weight:600}
.previews{display:grid;grid-template-columns:repeat(auto-fill,minmax(64px,1fr));gap:6px}
.previews img{width:100%;aspect-ratio:1/1;object-fit:cover;border-radius:2px}

/* lightbox */
#lightbox{position:fixed;inset:0;z-index:45;background:rgba(8,12,20,.94);color:#F2F4F1;display:flex;flex-direction:column;padding:calc(10px + env(safe-area-inset-top,0px)) max(12px,env(safe-area-inset-right,0px)) calc(14px + env(safe-area-inset-bottom,0px)) max(12px,env(safe-area-inset-left,0px))}
.lb-top{display:flex;justify-content:space-between;align-items:center}
.lb-img{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;gap:8px}
.lb-img img{max-width:100%;max-height:100%;object-fit:contain;border:6px solid #F2F4F1;min-width:0}
.lb-cap{max-width:640px;margin:10px auto 0;width:100%;display:flex;flex-direction:column;gap:8px}
.lb-cap .c{font-size:16px;white-space:pre-wrap;overflow-wrap:anywhere}
.lb-cap .m{font-size:13px;color:#B8C0CC}
.lb-acts{display:flex;gap:8px;flex-wrap:wrap}
#lightbox .icon-btn:hover{background:rgba(255,255,255,.1)}
#lightbox .btn-line{color:#F2F4F1;border-color:rgba(255,255,255,.4)}
#lightbox input{background:rgba(255,255,255,.08);color:#F2F4F1;border:1px solid rgba(255,255,255,.3);border-radius:6px;padding:8px 12px;width:100%;box-sizing:border-box}

/* the stamping moment */
#stampfx{position:fixed;inset:0;z-index:50;background:var(--scrim);display:grid;place-items:center;padding:24px}
.fx-page{position:relative;overflow:hidden;width:min(320px,86vw);aspect-ratio:4/5;background:var(--sheet);border-radius:3px;display:grid;place-items:center;box-shadow:0 20px 50px rgba(0,0,0,.35);animation:shake .25s .36s ease-out both}
.fx-page .stamp{position:relative;width:78%;animation:thud .6s cubic-bezier(.2,.9,.25,1.25) both}
.fx-cap{position:absolute;bottom:14px;left:0;right:0;text-align:center;font-weight:600;color:var(--ink);animation:fadein .3s .7s both}
@keyframes thud{0%{transform:translateY(-60px) scale(1.7) rotate(calc(var(--rot) - 10deg));opacity:0}55%{opacity:1}65%{transform:scale(.94) rotate(var(--rot))}100%{transform:scale(1) rotate(var(--rot));opacity:1}}
@keyframes shake{0%{transform:translateY(0)}30%{transform:translateY(3px)}60%{transform:translateY(-1px)}100%{transform:none}}
@keyframes fadein{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion: reduce){.fx-page,.fx-page .stamp,.fx-cap{animation:none}.fx-page .stamp{transform:rotate(var(--rot))}}

#toast{position:fixed;z-index:60;left:50%;transform:translateX(-50%);bottom:calc(140px + env(safe-area-inset-bottom,0px));background:var(--ink);color:var(--paper);padding:10px 16px;border-radius:6px;font-size:14px;font-weight:500;max-width:calc(100vw - 32px);text-align:center}
.member-add{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:end;margin-top:6px}
.member-add input{border:0;border-bottom:1.5px solid var(--rule);background:transparent;padding:8px 2px;min-height:44px;min-width:0}
.skeleton{height:150px;border-radius:4px;background:linear-gradient(90deg,var(--sheet) 0%,var(--paper) 50%,var(--sheet) 100%);background-size:200% 100%;animation:sh 1.4s infinite}
@keyframes sh{to{background-position:-200% 0}}
@media (prefers-reduced-motion: reduce){.skeleton{animation:none}}
@media (max-width:380px){.dp-grid{grid-template-columns:100px 1fr}.dp-slot{width:100px;height:124px}.dp-slot .stamp{width:98px}.slot-btn{width:84px;height:100px}}

/* ---------- additions for the standalone web app ---------- */
*,*::before,*::after{box-sizing:border-box}
html,body{margin:0}
body{padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
img{max-width:100%}
[hidden]{display:none!important}
.acct{display:inline-grid;place-items:center;width:40px;height:40px;border-radius:50%;border:1px solid var(--rule);background:var(--sheet);font-weight:700;color:var(--ink)}
.login{max-width:520px}
.login-form{display:flex;flex-direction:column;gap:14px}
.login-form .fld input{font-size:17px}
.login .or{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:13px}
.login .or::before,.login .or::after{content:"";flex:1;height:1px;background:var(--rule)}
.btn-wide{width:100%}
.code-in{letter-spacing:.4em;font-family:var(--f-mrz);font-size:22px!important;text-align:center}
.fine{font-size:12px;color:var(--muted);max-width:62ch}
.invite{display:flex;flex-direction:column;gap:10px}
.invite-link{font-family:var(--f-mrz);font-size:13px;background:var(--sheet);border:1px dashed var(--rule);border-radius:4px;padding:10px 12px;overflow-wrap:anywhere;user-select:all}
.join-list{display:flex;flex-direction:column;gap:8px}
.join-list .btn-line{justify-content:flex-start;min-height:48px;font-size:16px}
.setup code{font-family:var(--f-mrz);background:var(--sheet);padding:1px 6px;border-radius:3px}
