:root{
  --bg:#F5F5F7; --surface:#FFFFFF; --field:#EDEDF0; --field2:#E3E3E8;
  /* --muted passes WCAG AA (4.5:1) on --bg, --surface and --field; --faint is for decoration only */
  --text:#1D1D1F; --muted:#6A6A70; --faint:#8E8E93; --placeholder:#94949A;
  --hair:rgba(0,0,0,.07); --hair2:rgba(0,0,0,.13);
  --ink:#1D1D1F; --green:#34C759; --green-deep:#1E7A3A; --red:#B3261E;
  --focus:#0A66D9;
  --r-lg:18px; --r-md:12px;
  --shadow-soft:0 1px 2px rgba(0,0,0,.04), 0 12px 32px rgba(0,0,0,.06);
  --shadow-pill:0 2px 8px rgba(0,0,0,.06), 0 12px 28px rgba(0,0,0,.08);
  --spring:cubic-bezier(.34,1.2,.3,1);
  --ease:cubic-bezier(.22,.8,.24,1);
  --st:env(safe-area-inset-top, 0px);
  --sb:env(safe-area-inset-bottom, 0px);
}
*{box-sizing:border-box; margin:0; padding:0; -webkit-tap-highlight-color:transparent;}
[hidden]{display:none !important;}
html,body{height:100%;}
body{
  background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","SF Pro Display","Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  display:flex; justify-content:center; overflow:hidden;
  -webkit-font-smoothing:antialiased; -webkit-text-size-adjust:100%; text-size-adjust:100%;
}
button,input,textarea{font:inherit; color:inherit;}
button{cursor:pointer; background:none; border:none;}
button:disabled{cursor:default;}
:focus-visible{outline:2px solid var(--focus); outline-offset:2px;}
input:focus-visible, textarea:focus-visible{outline:none;}
.sr{position:absolute !important; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap; border:0;}

#app{
  position:relative; width:100%; max-width:440px;
  height:100vh; height:100svh; height:100dvh;
  background:var(--bg); overflow:hidden;
}
@media (min-width:560px) and (min-height:720px){
  body{align-items:center;}
  #app{height:min(92vh,880px); height:min(92dvh,880px); border-radius:34px; box-shadow:var(--shadow-soft); border:1px solid var(--hair);}
}
.view{
  position:absolute; inset:0; display:flex; flex-direction:column; background:var(--bg);
  /* no overshoot on full-screen slides – a spring here briefly reveals the other view at the edge */
  transition:transform .45s var(--ease), opacity .35s ease;
}
#focusView{transform:translateX(100%);}
body.focus #listView{transform:translateX(-18%); opacity:.35;}
body.focus #focusView{transform:none;}

/* ---------- shared controls ---------- */
.iconBtn{
  display:flex; align-items:center; justify-content:center; min-width:40px; min-height:40px;
  color:var(--muted); padding:10px; border-radius:999px; transition:background .15s, color .15s;
}
.iconBtn:active{background:var(--field);}
.pill{
  border-radius:999px; padding:8px 16px; min-height:36px; font-size:13.5px; font-weight:500;
  background:var(--field); color:var(--text); white-space:nowrap; transition:opacity .15s, background .15s;
}
.pill:active{opacity:.8;}
.pill:disabled{opacity:.4;}
.pill.primary{background:var(--ink); color:#fff;}
.pill.danger{background:var(--red); color:#fff;}
.pill.softDanger{background:rgba(179,38,30,.1); color:var(--red);}

/* ---------- list view ---------- */
.lvHead{padding:calc(22px + var(--st)) 12px 6px 20px; display:flex; align-items:center; gap:2px;}
.lvHead h1{font-size:30px; font-weight:600; letter-spacing:-.03em; flex:1;}
#lvCount{font-size:13px; color:var(--muted); font-weight:500; margin-right:4px; white-space:nowrap;}
#editBtn .lbl{display:none; font-size:15px; font-weight:600; color:var(--ink); padding:0 6px;}
body.editMode #editBtn{background:var(--field);}
body.editMode #editBtn .ico{display:none;}
body.editMode #editBtn .lbl{display:inline;}
#dataPop{
  position:absolute; top:calc(68px + var(--st)); right:14px; z-index:12;
  background:var(--surface); border:1px solid var(--hair); border-radius:14px;
  box-shadow:var(--shadow-pill); padding:6px; display:flex; flex-direction:column; gap:2px; min-width:210px;
}
#dataPop button{font-size:14.5px; font-weight:500; color:var(--text); padding:11px 14px; border-radius:10px; text-align:left;}
#dataPop button:active{background:var(--field);}
#statusRow{display:flex; align-items:center; gap:8px; padding:0 20px 4px; min-height:36px;}
#streakChip{
  font-size:12.5px; font-weight:600; color:var(--muted); background:var(--field);
  border-radius:999px; padding:6px 12px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
#proBtn{
  margin-left:auto; flex:0 0 auto; border:1px solid var(--hair2); color:var(--text);
  font-size:12.5px; font-weight:600; padding:6px 14px; min-height:32px; border-radius:999px; letter-spacing:.02em;
}
#proBtn:active{background:var(--field);}
#activationBanner{
  margin:4px 20px 8px; background:var(--surface); border:1px solid var(--hair);
  border-radius:14px; padding:12px 14px; box-shadow:var(--shadow-soft);
}
#activationTrack{display:flex; gap:5px; margin-bottom:7px;}
#activationTrack i{flex:1; height:5px; border-radius:3px; background:var(--field);}
#activationTrack i.on{background:var(--green);}
#activationText{font-size:12.5px; color:var(--muted); font-weight:500;}
#editBar, #confirmBar{display:flex; align-items:center; gap:8px; padding:4px 20px 8px; flex-wrap:wrap;}
#selCount{flex:1; font-size:13.5px; color:var(--muted); font-weight:500;}
#confirmText{flex:1 1 170px; font-size:13.5px; font-weight:500; line-height:1.35;}

#lvScroll{
  flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain;
  display:flex; flex-direction:column; padding:4px 0 12px;
}
.card{
  list-style:none; margin:6px 20px; background:var(--surface); border-radius:var(--r-lg);
  box-shadow:var(--shadow-soft); overflow:hidden; flex:0 0 auto;
}
.card:empty{display:none;}
.itemRow{display:flex; align-items:center; position:relative; transition:background .15s;}
.card .itemRow + .itemRow{border-top:1px solid var(--hair);}
.itemRow.sel{background:rgba(0,0,0,.035);}
.itemRow.flash{animation:flash 1.3s ease;}
@keyframes flash{from{background:rgba(52,199,89,.2);} to{background:transparent;}}
.itemMain{
  flex:1; display:flex; align-items:center; gap:12px; min-width:0; align-self:stretch;
  padding:14px 10px 14px 16px; color:var(--text); text-align:left; transition:background .15s, opacity .3s;
}
.itemMain:active{background:var(--field);}
.itemMain:focus-visible{outline-offset:-3px; border-radius:inherit;}
.itemRow.arch .itemMain{opacity:.6;}
.ind{flex:0 0 38px; height:38px; display:flex; align-items:center; justify-content:center; position:relative;}
.thumbI{width:38px; height:38px; border-radius:50%; object-fit:cover; display:block;}
.init{width:38px; height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:15px; font-weight:600;}
.ind.goalRing::after{content:""; position:absolute; inset:-3.5px; border:2px solid var(--green); border-radius:50%;}
.bdgStar{
  position:absolute; right:-5px; top:-5px; font-size:11px; line-height:1;
  color:var(--ink); background:var(--surface); border-radius:50%; padding:2.5px; box-shadow:0 1px 3px rgba(0,0,0,.12);
}
.dot{width:8px; height:8px; border-radius:50%; background:#C3C7CE; transition:background .3s;}
.dot.goal{background:var(--green);}
.cb{
  flex:0 0 22px; height:22px; border-radius:7px; border:1.5px solid var(--hair2);
  display:flex; align-items:center; justify-content:center; color:#fff; transition:background .15s, border-color .15s;
}
.itemRow.sel .cb{background:var(--ink); border-color:var(--ink);}
.itemTexts{flex:1; min-width:0; display:flex; flex-direction:column; gap:1px;}
.itemName{font-size:16px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; letter-spacing:-.01em;}
.itemSub{font-size:13px; color:var(--muted); font-variant-numeric:tabular-nums; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.itemEnd{flex:0 0 auto; display:flex; flex-direction:column; align-items:flex-end; gap:1px; padding-left:6px;}
.itemVal{font-size:17px; font-weight:500; font-variant-numeric:tabular-nums; white-space:nowrap;}
.itemVal.goal{color:var(--green-deep);}
.itemCnt{font-size:12.5px; color:var(--muted); font-variant-numeric:tabular-nums; white-space:nowrap;}
.plus1{
  flex:0 0 auto; margin-right:12px; min-width:48px; min-height:40px;
  border:1px solid var(--hair2); border-radius:999px; padding:0 12px;
  font-size:13px; font-weight:600; color:var(--muted);
  transition:transform .25s var(--spring), background .15s;
}
.plus1:active{transform:scale(.88); background:var(--field);}
.plus1:disabled{opacity:.35;}
.restoreBtn{
  flex:0 0 auto; margin-right:12px; min-height:36px; border-radius:999px; padding:0 14px;
  font-size:13px; font-weight:500; background:var(--field); color:var(--muted);
}
#archWrap{margin:6px 0 0;}
.archHead{
  display:flex; align-items:center; gap:6px; margin:0 20px; padding:10px 4px;
  font-size:13px; font-weight:600; color:var(--muted); border-radius:8px;
}
.archHead svg{transition:transform .3s;}
.archHead.open svg{transform:rotate(180deg);}
#emptyMsg{
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:8px; color:var(--muted); font-size:15px; text-align:center; padding:24px 40px; line-height:1.6;
}
#emptyMsg:active{opacity:.6;}
#emptyMsg b{font-weight:600; color:var(--text); font-size:18px; letter-spacing:-.01em;}
#emptyMsg .cta{margin-top:6px; font-size:13.5px; font-weight:600; color:var(--text); background:var(--field); border-radius:999px; padding:8px 16px;}
.addForm{display:flex; gap:8px; padding:10px 16px calc(14px + var(--sb)); background:var(--bg);}
.addForm input{
  border:none; background:var(--surface); border-radius:var(--r-md); padding:13px 15px;
  font-size:16px; min-width:0; box-shadow:var(--shadow-soft); transition:box-shadow .18s;
}
.addForm input:focus{outline:none; box-shadow:0 0 0 2.5px rgba(29,29,31,.22);}
input::placeholder, textarea::placeholder{color:var(--placeholder);}
input[aria-invalid="true"]{box-shadow:0 0 0 2px rgba(179,38,30,.6) !important;}
.inName{flex:1.6;}
.inNum{flex:1;}
.addBtn{
  flex:0 0 48px; background:var(--ink); color:#fff; border-radius:var(--r-md);
  font-size:23px; line-height:1; transition:transform .35s var(--spring), opacity .12s;
}
.addBtn:active{transform:scale(.88); opacity:.85;}

/* ---------- toast ---------- */
#toast{
  position:absolute; left:50%; bottom:calc(84px + var(--sb)); z-index:50;
  display:flex; align-items:center; gap:10px; width:max-content; max-width:calc(100% - 32px);
  background:rgba(29,29,31,.94); color:#fff; font-size:14px; font-weight:500; line-height:1.35;
  padding:11px 18px; border-radius:20px; box-shadow:0 8px 24px rgba(0,0,0,.18);
  opacity:0; pointer-events:none; transform:translate(-50%, 8px);
  transition:opacity .3s, transform .35s var(--spring);
}
#toast.show{opacity:1; pointer-events:auto; transform:translate(-50%, 0);}
#toast.hasAct{padding:7px 7px 7px 18px;}
body.focus #toast{top:calc(62px + var(--st)); bottom:auto; transform:translate(-50%, -8px);}
body.focus #toast.show{transform:translate(-50%, 0);}
#toastMsg{min-width:0;}
#toastAct{
  flex:0 0 auto; background:rgba(255,255,255,.16); color:#fff; font-size:13.5px; font-weight:600;
  padding:8px 14px; border-radius:999px; white-space:nowrap;
}
#toastAct:active{background:rgba(255,255,255,.26);}

/* ---------- focus view ---------- */
.fvHead{
  display:flex; align-items:center; justify-content:space-between;
  padding:calc(14px + var(--st)) 10px 0; min-height:56px; position:relative; z-index:9;
}
.ghostBtn{
  display:flex; align-items:center; gap:3px; color:var(--muted); font-size:15px; font-weight:500;
  padding:9px 12px; border-radius:999px; transition:background .15s;
}
.ghostBtn:active{background:var(--field);}
#resetPop{
  position:absolute; top:calc(58px + var(--st)); right:10px; z-index:10; width:min(300px, calc(100% - 20px));
  background:var(--surface); border:1px solid var(--hair); border-radius:16px; box-shadow:var(--shadow-pill);
  padding:14px; display:flex; flex-direction:column; gap:12px; font-size:14px; line-height:1.4;
}
#resetPop .row{display:flex; gap:8px; justify-content:flex-end;}
#stage{position:relative; flex:1 1 0; min-height:0; display:flex; flex-direction:column;}
#cv{position:absolute; inset:0; width:100%; height:100%; display:block; cursor:pointer; touch-action:none;}
#cv:focus-visible{outline:2px solid var(--focus); outline-offset:-8px; border-radius:24px;}
#stageSpace{flex:1; position:relative; z-index:2; pointer-events:none;}
#hint{
  position:absolute; bottom:8px; left:16px; right:16px; text-align:center;
  font-size:13px; color:var(--muted); pointer-events:none; opacity:0; transition:opacity .6s;
}
#goalChip{
  position:absolute; top:14px; left:50%; transform:translateX(-50%) translateY(-6px);
  background:var(--green-deep); color:#fff; font-size:13px; font-weight:600;
  letter-spacing:.01em; padding:7px 15px; border-radius:999px; opacity:0; pointer-events:none;
  transition:opacity .5s, transform .5s var(--spring); z-index:3; max-width:86%; text-align:center;
}
#goalChip.show{opacity:1; transform:translateX(-50%) translateY(0);}
.pt{position:absolute; width:5px; height:5px; border-radius:50%; pointer-events:none; z-index:2;}
#infoPanel{
  position:relative; z-index:2; flex:0 0 auto; min-height:132px;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:3px; padding:6px 20px 4px; pointer-events:none;
}
#infoPanel > *{pointer-events:auto;}
#fName{
  font-size:12.5px; font-weight:600; color:var(--muted); letter-spacing:.12em; text-transform:uppercase;
  max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
#valRow{
  display:flex; align-items:baseline; justify-content:center; flex-wrap:wrap; column-gap:10px;
  padding:0 10px; border-radius:16px; color:var(--text); transition:background .15s;
}
#valRow:active{background:rgba(0,0,0,.04);}
#val{
  font-size:clamp(42px, 15vw, 58px); font-weight:200; letter-spacing:-.03em; line-height:1.04;
  font-variant-numeric:tabular-nums; transition:transform .4s var(--spring), color .4s; display:inline-block;
}
#val.pop{transform:scale(1.06);}
#val.goal{color:var(--green-deep);}
#valBig{display:inline-flex; align-items:baseline; gap:6px; white-space:nowrap;}
#valUnit{font-size:22px; font-weight:400; color:var(--text);}
#calc{font-size:17px; font-weight:400; color:var(--muted); white-space:nowrap; font-variant-numeric:tabular-nums;}
#parts{border-bottom:1.5px dotted currentColor; padding-bottom:1px; font-variant-numeric:tabular-nums;}
#partsEdit{display:none; align-items:center; gap:6px; padding:6px 0; flex-wrap:wrap; justify-content:center;}
#partsEdit.open{display:flex;}
#partsEdit label{font-size:13px; color:var(--muted); font-weight:500; margin-right:2px;}
#partsInput{
  width:70px; border:none; background:var(--surface); border-radius:10px; padding:8px 6px;
  font-size:16px; text-align:center; box-shadow:inset 0 0 0 1px var(--hair2); -moz-appearance:textfield;
}
#partsInput:focus{box-shadow:inset 0 0 0 2px rgba(29,29,31,.35);}
#partsInput::-webkit-inner-spin-button, #partsInput::-webkit-outer-spin-button{-webkit-appearance:none; margin:0;}
.stepBtn{
  width:38px; height:38px; border-radius:50%; background:var(--field); color:var(--text);
  font-size:20px; line-height:1; display:flex; align-items:center; justify-content:center;
}
.stepBtn:active{background:var(--field2);}
.stepBtn:disabled{opacity:.35;}
#orig{font-size:13px; color:var(--muted); min-height:18px; font-variant-numeric:tabular-nums; text-align:center;}
#forecast{font-size:12.5px; color:var(--muted); min-height:16px; text-align:center; padding-top:2px;}
#metaRow{display:flex; align-items:center; gap:8px; padding-top:7px; min-height:40px; flex-wrap:wrap; justify-content:center;}
.chip{
  display:inline-flex; align-items:center; gap:5px; min-height:34px; padding:6px 13px; border-radius:999px;
  background:var(--field); color:var(--muted); font-size:12.5px; font-weight:500; white-space:nowrap;
  transition:background .2s, color .2s;
}
.chip:active{background:var(--field2);}
.chip.goalMet, .chip.profit{background:rgba(52,199,89,.12); color:var(--green-deep);}
.chip.profit{cursor:default; font-weight:600;}
.chip.add{background:none; box-shadow:inset 0 0 0 1px var(--hair2);}
.chip svg{flex:0 0 auto;}

#peek{flex:0 0 auto; display:flex; justify-content:center; padding:8px 16px calc(14px + var(--sb));}
#peekPill{
  display:flex; align-items:stretch; max-width:100%;
  background:rgba(255,255,255,.86);
  -webkit-backdrop-filter:blur(22px) saturate(1.6); backdrop-filter:blur(22px) saturate(1.6);
  border:1px solid var(--hair); border-radius:999px; box-shadow:var(--shadow-pill); overflow:hidden;
}
#peekPill button:focus-visible{outline-offset:-3px;}
.peekSide{
  display:flex; align-items:center; gap:6px; color:var(--muted); font-size:14px; font-weight:500;
  padding:12px 16px; min-width:0; max-width:132px; transition:background .15s;
}
.peekSide span{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.peekSide:active{background:var(--field);}
#prevBtn{border-right:1px solid var(--hair);}
#nextBtn{border-left:1px solid var(--hair);}
#openBtn{
  flex:0 0 auto; display:flex; flex-direction:column; align-items:center; justify-content:center;
  color:var(--text); padding:7px 22px 6px; transition:background .15s;
}
#openBtn:active{background:var(--field);}
#countBadge{font-size:11px; font-weight:500; color:var(--muted); letter-spacing:.03em;}

/* ---------- bottom sheets ---------- */
#scrim{
  position:absolute; inset:0; background:rgba(20,20,22,.28);
  opacity:0; pointer-events:none; transition:opacity .32s; z-index:5;
}
body.sheetOpen #scrim, body.infoOpen #scrim{opacity:1; pointer-events:auto;}
.sheetBase{
  position:absolute; left:10px; right:10px; bottom:10px; z-index:6;
  background:rgba(255,255,255,.96);
  -webkit-backdrop-filter:blur(24px) saturate(1.6); backdrop-filter:blur(24px) saturate(1.6);
  border-radius:26px; box-shadow:var(--shadow-pill); border:1px solid var(--hair);
  display:flex; flex-direction:column; padding-bottom:max(6px, var(--sb));
  /* hidden sheets must not be reachable with Tab or a screen reader */
  visibility:hidden; transform:translateY(calc(103% + 10px));
  transition:transform .5s var(--spring), visibility 0s linear .5s;
}
.sheetBase:focus{outline:none;}
#sheet{max-height:62%;}
#infoSheet{max-height:82%;}
body.sheetOpen #sheet, body.infoOpen #infoSheet{
  visibility:visible; transform:translateY(0); transition:transform .5s var(--spring), visibility 0s;
}
.handleWrap{padding:12px 0 6px; cursor:grab; touch-action:none; flex:0 0 auto;}
.handle{width:36px; height:5px; border-radius:3px; background:var(--hair2); margin:0 auto;}
.sheetTitle{font-size:13px; font-weight:600; color:var(--muted); text-align:center; padding-bottom:10px; letter-spacing:.08em; text-transform:uppercase; flex:0 0 auto;}
#listSheet{list-style:none; overflow-y:auto; padding:0 10px 4px; display:flex; flex-direction:column; gap:2px; overscroll-behavior:contain; min-height:0;}
#listSheet .itemRow{border-radius:14px; overflow:hidden;}
#listSheet .itemRow.active{background:var(--field);}
#listSheet .itemRow.active .itemName{font-weight:600;}
#listSheet .itemMain{padding:12px 14px;}
#listSheet .ind{flex-basis:20px;}
.newRow{
  display:flex; align-items:center; justify-content:center; gap:8px; flex:0 0 auto;
  border-radius:14px; margin:2px 10px 6px; color:var(--muted); font-size:15px; font-weight:500;
  padding:13px; transition:background .15s;
}
.newRow:active{background:var(--field);}
.sheetAddForm{display:flex; gap:8px; padding:2px 14px 12px; flex:0 0 auto;}
.sheetAddForm input{border:none; background:var(--field); border-radius:var(--r-md); padding:12px 14px; font-size:16px; min-width:0;}
.sheetAddForm input:focus{box-shadow:0 0 0 2px rgba(29,29,31,.22);}
.sheetAddForm .sName{flex:1.6;}
.sheetAddForm .sNum{flex:1;}
.sheetAddForm button{flex:0 0 46px; background:var(--ink); color:#fff; border-radius:var(--r-md); font-size:21px; line-height:1;}

.ifBody{overflow-y:auto; padding:2px 20px 16px; display:flex; flex-direction:column; gap:16px; overscroll-behavior:contain; min-height:0;}
.ifRow2{display:flex; gap:10px;}
.ifRow2 .ifField{flex:0 0 118px;}
.ifRow2 .ifField.grow{flex:1 1 auto; min-width:0;}
.ifField{display:flex; flex-direction:column; gap:6px;}
.ifField > label, .ifLbl{font-size:13px; font-weight:600; color:var(--muted);}
.ifField input, .ifField textarea{
  border:none; background:var(--field); border-radius:var(--r-md);
  padding:12px 14px; font-size:16px; width:100%; min-width:0;
}
.ifField textarea{min-height:78px; resize:vertical; line-height:1.4;}
.ifField input:focus, .ifField textarea:focus{box-shadow:0 0 0 2px rgba(29,29,31,.22);}
.ifHelp{font-size:12.5px; color:var(--muted); line-height:1.5;}
.ifHelp b{color:var(--text); font-weight:600;}
#ifSoldNote b.gain{color:var(--green-deep);}
#ifImgs{display:flex; flex-wrap:wrap; gap:10px; padding-top:4px;}
.thumb{position:relative; width:76px; height:76px;}
.thumbOpen{display:block; width:100%; height:100%; border-radius:12px; overflow:hidden; background:var(--field); padding:0;}
.thumbOpen img{width:100%; height:100%; object-fit:cover; display:block;}
.thumbX{
  position:absolute; top:-7px; right:-7px; width:28px; height:28px; border-radius:50%;
  background:rgba(29,29,31,.82); color:#fff; border:2px solid var(--surface);
  display:flex; align-items:center; justify-content:center;
}
.ifAdd{
  width:76px; height:76px; border-radius:12px; border:1.5px dashed var(--hair2);
  color:var(--muted); font-size:24px; display:flex; align-items:center; justify-content:center;
}
.ifAdd:active{background:var(--field);}

/* ---------- image viewer ---------- */
#viewer{
  position:absolute; inset:0; z-index:45; background:rgba(12,12,14,.92);
  display:flex; align-items:center; justify-content:center;
  opacity:0; visibility:hidden; transition:opacity .25s, visibility 0s linear .25s;
}
#viewer.show{opacity:1; visibility:visible; transition:opacity .25s, visibility 0s;}
#viewerImg{max-width:calc(100% - 32px); max-height:calc(100% - 140px); border-radius:12px; object-fit:contain;}
#viewerClose{
  position:absolute; top:calc(14px + var(--st)); right:14px; width:42px; height:42px; border-radius:50%;
  background:rgba(255,255,255,.16); color:#fff; display:flex; align-items:center; justify-content:center;
}

/* ---------- paywall (inside the app frame, also on desktop) ---------- */
.modal{
  position:absolute; inset:0; z-index:40; display:flex; align-items:flex-end;
  background:rgba(20,20,22,.4); opacity:0; visibility:hidden;
  transition:opacity .3s, visibility 0s linear .4s;
}
.modal.show{opacity:1; visibility:visible; transition:opacity .3s, visibility 0s;}
.modalSheet{
  width:100%; background:var(--surface); border-radius:26px 26px 0 0;
  padding:26px 24px calc(20px + var(--sb));
  transform:translateY(100%); transition:transform .4s var(--spring);
}
.modalSheet:focus{outline:none;}
.modal.show .modalSheet{transform:translateY(0);}
.modalSheet h2{font-size:22px; font-weight:600; letter-spacing:-.02em; margin-bottom:4px;}
.pySub{font-size:14px; color:var(--muted); margin-bottom:18px;}
.pyList{list-style:none; display:flex; flex-direction:column; gap:10px; margin-bottom:20px;}
.pyList li{display:flex; align-items:center; gap:10px; font-size:14.5px;}
.pyList svg{flex:0 0 auto; color:var(--green-deep);}
.pyPlans{display:flex; gap:10px; margin-bottom:16px;}
.pyPlan{
  flex:1; display:block; border:1.5px solid var(--hair2); border-radius:14px; padding:13px 14px;
  cursor:pointer; position:relative; transition:border-color .15s, background .15s;
}
.pyPlan input{position:absolute; opacity:0; pointer-events:none;}
.pyPlan.sel{border-color:var(--ink); background:var(--field);}
.pyPlan:has(input:focus-visible){outline:2px solid var(--focus); outline-offset:2px;}
.pyPlan .badge{
  position:absolute; top:-9px; right:10px; background:var(--green-deep); color:#fff;
  font-size:10.5px; font-weight:700; padding:2px 8px; border-radius:999px;
}
.pyPlan .l, .pyPlan .v, .pyPlan .s{display:block;}
.pyPlan .l{font-size:12.5px; color:var(--muted); font-weight:500;}
.pyPlan .v{font-size:18px; font-weight:600; margin-top:2px;}
.pyPlan .s{font-size:12px; color:var(--muted); margin-top:1px;}
.btnPrimary{width:100%; background:var(--ink); color:#fff; font-size:16px; font-weight:600; padding:15px; border-radius:14px;}
.btnPrimary:active{opacity:.85;}
.btnPrimary:disabled{opacity:.45;}
.btnGhost{display:block; margin:10px auto 0; color:var(--muted); font-size:14px; font-weight:500; padding:10px 14px; border-radius:999px;}

/* ---------- pointer devices ---------- */
@media (hover:hover){
  .iconBtn:hover, .ghostBtn:hover, .peekSide:hover, #openBtn:hover, .newRow:hover,
  #dataPop button:hover, #proBtn:hover, .archHead:hover, .btnGhost:hover{background:var(--field);}
  .itemMain:hover{background:rgba(0,0,0,.025);}
  .chip:not(.profit):hover, .plus1:hover, .restoreBtn:hover, .stepBtn:hover{background:var(--field2);}
  #valRow:hover{background:rgba(0,0,0,.035);}
}
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{transition-duration:.01ms !important; transition-delay:0s !important; animation-duration:.01ms !important; animation-iteration-count:1 !important;}
}
