:root{--dark:#0f6b5e;--teal:#16897c;--orange:#e49b35;--ink:#264940;--soft:#f5fbf8;--line:#d6e8e1}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}body{margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--soft);color:var(--ink)}button{font:inherit;cursor:pointer;border:1px solid #c8ded7;border-radius:10px;background:#fff;color:var(--dark);font-size:14px;font-weight:750;padding:10px 15px;min-height:42px}button.primary{background:var(--dark);color:#fff;border-color:var(--dark)}button:disabled{opacity:.45;cursor:default}.danger{color:#a33838;border-color:#e8baba}[hidden]{display:none!important}.site-header{background:#fff;border-bottom:1px solid var(--line);padding:17px max(20px,calc((100vw - 940px)/2));display:flex;justify-content:space-between;align-items:center}.site-header small{color:var(--teal);letter-spacing:.14em;font-weight:800}.site-header h1{font-size:24px;margin:4px 0}.site-header a{color:var(--dark)}.page{max-width:940px;margin:26px auto;padding:0 20px}.page h2{color:var(--dark);margin:0 0 8px}.page p{line-height:1.5}.actions{display:flex;gap:9px;flex-wrap:wrap;align-items:center;margin:14px 0}.panel{background:#fff;border:1px solid var(--line);border-radius:15px;padding:16px;margin:18px 0}.muted{font-size:13px;color:#658077}.overview{border-collapse:separate;border-spacing:0 8px;width:100%}.overview th{text-align:left;font-size:13px;color:#56766c;padding:5px}.overview td{padding:3px 5px}.overview td:first-child{font-weight:700}.slot{display:block;width:100%;border-radius:9px;background:#f2f6f5;border:1px solid #d9e6e2;min-height:45px;text-align:center;padding:11px 4px;color:#83938d}.slot.complete{background:#e1f5ed;border-color:#63b59e;color:#126759;cursor:pointer;font-weight:700}.hand-options,.finger-options{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;max-width:650px}.finger-options{grid-template-columns:repeat(4,1fr)}.hand-options .selected,.finger-options .selected{background:#e1f5ed;border:2px solid var(--teal)}.pending-preview{display:flex;gap:20px;align-items:center;background:#fff;padding:14px;border:1px solid var(--line);border-radius:12px;margin:16px 0}.pending-preview img{max-width:55%;max-height:230px;object-fit:contain}.pending-preview strong,.saved-value{font-size:24px;color:var(--dark)}.warning{background:#fff5e4;border:1px solid #e6ba75;border-radius:9px;padding:10px}.saved-image{max-width:100%;max-height:60vh;object-fit:contain;border:1px solid var(--line);background:white}.report-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}.report-sheet{width:210mm;min-height:297mm;background:#fff;color:#243d38;box-shadow:0 3px 20px #0001;margin:18px auto;padding:13mm 14mm 12mm;position:relative;break-after:page;page-break-after:always}.report-sheet:last-child{break-after:auto;page-break-after:auto}.report-head{border-bottom:3px solid var(--dark);padding-bottom:10px;margin-bottom:16px}.report-head h2{margin:0;color:var(--dark)}.report-head small{color:#678079}.report-footer{position:absolute;bottom:8mm;left:14mm;right:14mm;border-top:1px solid #d7e7e1;padding-top:5px;font-size:10px;color:#638077}.report-table{border-collapse:collapse;width:100%;margin:16px 0}.report-table th,.report-table td{border-bottom:1px solid #d8e8e2;text-align:left;padding:9px 6px}.report-table th{background:#edf7f2}.num{text-align:right!important}.report-info{font-size:13px;color:#57736b}.bars{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin:20px 0}.bar-panel{border:1px solid #d7e7e1;border-radius:9px;padding:10px;min-width:0}.bar-panel h3{font-size:16px;margin:0 0 9px}.bar-area{display:flex;align-items:flex-end;gap:10px;border-bottom:2px solid #839f94;height:100mm}.bar-col{flex:1;text-align:center;display:flex;align-items:center;flex-direction:column;justify-content:flex-end;height:100%;min-width:0}.bar-value{font-size:10px;white-space:nowrap;margin-bottom:4px}.bar{background:#16897c;width:65%;min-height:0;print-color-adjust:exact;-webkit-print-color-adjust:exact}.bar.right{background:#4b9388}.bar svg{display:block;width:100%;height:100%;overflow:hidden}.bar-label{font-size:10px;margin-top:5px}.report-note{background:#eef8f4;border-radius:9px;padding:12px;font-size:12px;line-height:1.45}.appendix-grid{display:grid;grid-template-columns:1fr 1fr;gap:10mm 7mm}.appendix-item{border:1px solid #dce9e4;border-radius:9px;padding:8px;min-height:99mm;break-inside:avoid}.appendix-item h3{margin:0 0 6px;font-size:13px}.appendix-item img{display:block;width:100%;height:72mm;object-fit:contain;background:#f6fbf8}.appendix-item .missing{height:72mm;display:flex;align-items:center;justify-content:center;color:#8da59a;background:#f6fbf8}.appendix-item p{font-size:12px;margin:5px 0}.qr-layout{display:flex;align-items:center;gap:20px;margin:40px 0}.qr-layout img{width:52mm;height:52mm;image-rendering:pixelated}.qr-layout p{font-size:14px;line-height:1.6}
#measureLayer{position:fixed;inset:0;z-index:30;background:#fbfefd;touch-action:none;overflow:hidden}#measureLayer canvas{position:absolute;inset:0;width:100%;height:100%;touch-action:none}.height-badge{position:fixed;z-index:4;top:max(8px,env(safe-area-inset-top));left:8px;background:#fff;color:var(--dark);font-weight:800;font-size:22px;padding:8px 12px;border-radius:12px;box-shadow:0 4px 12px #0001;pointer-events:none}.height-badge small{display:block;font-size:10px;color:#638078}.measure-controls{position:fixed;z-index:5;top:8px;right:8px;display:flex;flex-direction:column;gap:6px}.measure-controls button{min-width:95px;min-height:38px;font-size:13px;box-shadow:0 3px 10px #0001;padding:8px 12px}.tipHandle,.calHandle{position:fixed;z-index:6;left:0;top:0;touch-action:none;user-select:none;display:flex;align-items:center;gap:6px;border:2px solid #d18b27;border-radius:12px;background:#fff5dd;color:#89500e;padding:8px 12px;font-weight:800;font-size:13px;white-space:nowrap;box-shadow:0 3px 10px #0002;cursor:grab}.tipHandle:active,.calHandle:active{background:#ffe6b0}.tipHandle .arrow{font-size:18px}.measure-note{position:fixed;z-index:3;bottom:8px;left:50%;transform:translateX(-50%);background:#ffffffdc;border:1px solid var(--line);border-radius:10px;padding:6px 10px;color:#526d67;font-size:11px;text-align:center;max-width:85%;pointer-events:none}.calBanner{position:fixed;z-index:10;top:8px;right:8px;width:min(210px,28vw);background:#fffffff2;border:1px solid var(--line);border-radius:12px;box-shadow:0 4px 14px #0002;padding:8px 10px;font-size:11px}.calBanner strong{display:block;font-size:12px;color:var(--dark)}.calBanner p{line-height:1.3}.calBanner .actions{margin:7px 0 0;flex-wrap:nowrap;gap:5px}.calBanner button{min-width:0;flex:1;padding:5px;font-size:12px;min-height:34px}.intro-overlay{position:fixed;inset:0;z-index:12;display:flex;align-items:center;justify-content:center;padding:12px;background:#f5fbf8;overflow:auto;touch-action:pan-y}.intro-card{width:min(640px,100%);max-height:100%;overflow:auto;background:white;border:1px solid var(--line);border-radius:20px;padding:clamp(12px,2.5vw,20px);box-shadow:0 18px 45px #1c55401e;touch-action:pan-y}.intro-card>small{font-size:11px;font-weight:800;letter-spacing:.1em;color:var(--teal)}.intro-card h2{font-size:clamp(19px,3.5vw,24px);margin:5px 0}.intro-card p{font-size:13px;line-height:1.4}.cal-illustration{width:100%;max-height:110px;display:block;margin:6px auto}
@media(orientation:portrait){.measure-controls{top:auto;bottom:10px;right:50%!important;left:auto!important;transform:translateX(50%);display:grid;grid-template-columns:repeat(3,auto)}.measure-note{bottom:105px;max-width:92%}.calBanner{width:min(180px,42vw)}}@media(max-width:640px){.finger-options{grid-template-columns:repeat(2,1fr)}.pending-preview{flex-direction:column;align-items:start}.pending-preview img{max-width:100%}.page{padding:0 12px}.report-sheet{width:100%;min-height:0;padding:18px}.bars{grid-template-columns:1fr}.appendix-grid{gap:8px}.appendix-item{min-height:0}.appendix-item img,.appendix-item .missing{height:130px}}@page{size:A4;margin:0}@media print{body{background:#fff!important}#appPage>header,#homeScreen,#assignScreen,#savedScreen,.report-toolbar,#measureLayer{display:none!important}#reportScreen{display:block!important;margin:0;padding:0;max-width:none}#reportBody{display:block}.report-sheet{width:210mm;height:297mm;min-height:297mm;max-height:297mm;margin:0;padding:13mm 14mm 12mm;box-shadow:none;overflow:hidden}.bars{grid-template-columns:1fr 1fr}.bar-area{height:100mm}.appendix-grid{gap:10mm 7mm}.appendix-item{min-height:99mm}.appendix-item img,.appendix-item .missing{height:72mm}}

/* Non-blocking tilt warning: overlay is not drawn on the measurement canvas or screenshot. */
.tilt-warning{position:fixed;inset:0;z-index:9;background:rgba(227,45,45,.32);pointer-events:none;display:flex;align-items:flex-end;justify-content:center;padding:0 12px max(18px,env(safe-area-inset-bottom));}
.tilt-warning span{background:#a51f24;color:white;border-radius:12px;padding:10px 18px;font-size:16px;font-weight:800;box-shadow:0 4px 15px #0003;}

/* Compact landscape introduction: all controls visible without scrolling. */
.intro-overlay{overflow:hidden;touch-action:none}
.intro-card{overflow:hidden;max-height:calc(100dvh - 16px)}
.intro-card .intro-actions{margin:8px 0 0}
.intro-card .intro-actions button{min-height:36px;padding:7px 11px}
@media (orientation:landscape) and (max-height:600px){
 .intro-overlay{padding:7px}
 .intro-card{width:min(900px,100%);padding:10px 14px;max-height:calc(100dvh - 14px);display:grid;grid-template-columns:minmax(0,1fr) minmax(210px,36%);column-gap:14px;align-content:center}
 .intro-card>small,.intro-card>h2,.intro-card>.intro-setup,.intro-card>.intro-explain,.intro-card>.intro-actions{grid-column:1}
 .intro-card>small{font-size:10px}
 .intro-card h2{font-size:clamp(17px,2.4vw,22px);margin:3px 0}
 .intro-card p{font-size:clamp(11px,1.45vw,13px);line-height:1.3;margin:4px 0}
 .intro-card .cal-illustration{grid-column:2;grid-row:1 / span 5;align-self:center;justify-self:center;max-height:min(200px,calc(100dvh - 34px));width:100%;margin:0}
 .intro-card .intro-actions{gap:6px;margin:7px 0 0}
 .intro-card .intro-actions button{font-size:12px;min-height:34px;padding:6px 9px}
}
@media (orientation:landscape) and (max-height:340px){
 .intro-card{padding:7px 10px;column-gap:8px}
 .intro-card h2{font-size:17px}
 .intro-card p{font-size:11px;margin:2px 0}
 .intro-card .intro-actions{margin-top:4px}
 .intro-card .intro-actions button{min-height:30px;padding:4px 7px}
}

/* Compact finger assignment: controls first, screenshot second. */
body:has(#assignScreen:not([hidden])) .site-header{padding:7px max(12px,calc((100vw - 940px)/2));min-height:48px}
body:has(#assignScreen:not([hidden])) .site-header small{font-size:9px}
body:has(#assignScreen:not([hidden])) .site-header h1{font-size:17px;margin:1px 0}
body:has(#assignScreen:not([hidden])) .site-header a{font-size:13px}
#assignScreen{margin:8px auto 18px}
#assignScreen .assign-top{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:9px}
#assignScreen .assign-top h2{font-size:19px;margin:0}
#assignScreen .assign-height{color:var(--dark);font-size:20px;font-weight:800;white-space:nowrap}
#assignScreen .assign-form{display:grid;gap:8px}
#assignScreen .assign-group h3{font-size:13px;margin:0 0 5px}
#assignScreen .hand-options,#assignScreen .finger-options{max-width:none;gap:7px}
#assignScreen .hand-options button,#assignScreen .finger-options button{min-height:42px;padding:6px 5px;font-size:13px}
#assignScreen .finger-options{grid-template-columns:repeat(4,minmax(0,1fr))}
#assignScreen .assign-actions{margin:3px 0 0;gap:8px}
#assignScreen .assign-actions button{min-height:42px}
#assignScreen .pending-preview{margin:11px 0 0;padding:8px 10px;gap:10px;display:flex;align-items:center}
#assignScreen .pending-preview img{width:190px;max-width:35%;height:95px;object-fit:contain;object-position:left center}
#assignScreen .pending-preview p{margin:0;font-size:12px}
#assignScreen #replaceWarning{margin:0;font-size:12px}
@media(max-width:640px){#assignScreen .finger-options{grid-template-columns:repeat(4,minmax(0,1fr))}#assignScreen .pending-preview{flex-direction:row;align-items:center}#assignScreen .pending-preview img{max-width:42%}}
@media(orientation:landscape) and (max-height:600px){
 body:has(#assignScreen:not([hidden])) .site-header{padding-top:4px;padding-bottom:4px;min-height:40px}
 #assignScreen{margin-top:5px}
 #assignScreen .assign-top{margin-bottom:5px}
 #assignScreen .assign-top h2{font-size:17px}
 #assignScreen .assign-height{font-size:18px}
 #assignScreen .assign-form{gap:5px}
 #assignScreen .assign-group h3{margin-bottom:3px}
 #assignScreen .hand-options button,#assignScreen .finger-options button{min-height:34px;padding:4px;font-size:12px}
 #assignScreen .assign-actions button{min-height:34px;padding:5px 12px;font-size:12px}
 #assignScreen .pending-preview{margin-top:6px;padding:5px 9px}
 #assignScreen .pending-preview img{height:50px;width:120px}
}


/* Finger Height instructions: tall cards, large illustrations, as in Finger Spread. */
#homeScreen .home-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;flex-wrap:wrap}
#homeScreen .home-heading p{margin:4px 0 8px}
#homeScreen .home-actions{margin:0;flex-shrink:0}
#homeScreen .instruction-heading{margin:16px 0 12px}
#homeScreen .instruction-heading h3{font-size:18px;color:var(--dark);margin:0 0 4px}
#homeScreen .instruction-heading p{font-size:13px;color:#5a756d;margin:0}
#homeScreen .height-steps{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;align-items:stretch}
#homeScreen .height-step{min-width:0;display:flex;flex-direction:column;gap:12px;background:#fff;border:1px solid var(--line);border-radius:16px;padding:16px}
#homeScreen .height-step-heading{display:flex;align-items:center;gap:10px;min-height:34px}
#homeScreen .height-step-number{display:inline-grid;place-items:center;flex:0 0 32px;width:32px;height:32px;border-radius:50%;background:var(--dark);color:white;font-weight:800;font-size:15px}
#homeScreen .height-step h4{font-size:15px;line-height:1.25;margin:0;color:var(--dark)}
#homeScreen .height-step-image{display:flex;align-items:center;justify-content:center;background:#f7fbf9;border:1px solid #e5efea;border-radius:11px;overflow:hidden;min-height:245px;height:245px;padding:6px}
#homeScreen .height-step-image img{display:block;width:100%;height:100%;object-fit:contain}
#homeScreen .height-step p{font-size:13px;line-height:1.48;margin:0}
#homeScreen .panel{margin-top:18px}
/* Keep the three tall cards in a row on landscape phones, allowing normal page scrolling. */
@media(orientation:landscape) and (max-height:600px){
 #homeScreen{margin-top:12px}
 #homeScreen .instruction-heading{margin:12px 0 10px}
 #homeScreen .height-steps{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
 #homeScreen .height-step{padding:10px;gap:9px}
 #homeScreen .height-step h4{font-size:13px}
 #homeScreen .height-step-image{height:210px;min-height:210px;padding:4px}
 #homeScreen .height-step p{font-size:12px;line-height:1.4}
}
/* Portrait/mobile: one tall card per row, not an image/text split. */
@media(orientation:portrait) and (max-width:700px){
 #homeScreen .height-steps{grid-template-columns:1fr;gap:12px}
 #homeScreen .height-step{display:flex;flex-direction:column;padding:14px}
 #homeScreen .height-step-image{height:clamp(230px,65vw,360px);min-height:230px}
 #homeScreen .height-step p{font-size:14px}
}
@media print{#homeScreen .height-steps{display:none}}


/* v7: prominent, thumb-sized drag handles; no text-as-control. */
#measureLayer .tipHandle,#measureLayer .calHandle{
  width:58px;height:58px;min-width:58px;min-height:58px;
  padding:0;border-radius:50%;display:grid;place-items:center;
  border:3px solid #fff;background:#ed941d;color:#fff;
  box-shadow:0 0 0 3px #b96b0a,0 5px 18px rgba(88,50,5,.35);
  cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none;
}
#measureLayer .tipHandle:active,#measureLayer .calHandle:active{background:#c97009;cursor:grabbing}
#measureLayer .drag-cross{position:relative;display:block;width:35px;height:35px;font-family:Arial,sans-serif;font-weight:900;line-height:35px;font-size:28px;text-align:center}
#measureLayer .drag-cross span{position:absolute;inset:0;display:block}
#measureLayer .drag-cross span+span{font-size:25px}
#measureLayer .tipHandle:focus-visible,#measureLayer .calHandle:focus-visible{outline:3px solid #184b45;outline-offset:5px}
/* Onboarding only: all measurement UI is monochrome except the orange handle.
   Tilt/safety warning deliberately remains red. The actual canvas image data is unchanged. */
#measureLayer.focus-cal #paint,
#measureLayer.focus-cal .calBanner,
#measureLayer.focus-measure #paint,
#measureLayer.focus-measure .height-badge,
#measureLayer.focus-measure .measure-controls,
#measureLayer.focus-measure .measure-note{filter:grayscale(1)}
@media(prefers-reduced-motion:no-preference){
 #measureLayer.focus-cal .calHandle,#measureLayer.focus-measure .tipHandle{animation:mhl-handle-pulse 1.8s ease-in-out infinite}
 @keyframes mhl-handle-pulse{0%,100%{box-shadow:0 0 0 3px #b96b0a,0 5px 18px #58320555}50%{box-shadow:0 0 0 8px #e49b3544,0 5px 18px #58320555}}
}

/* White hand SVG, centered on orange drag handle */
#measureLayer .drag-cross svg{display:block;width:35px;height:35px;pointer-events:none}

/* v10: measurement instruction above the fingertip, away from the lower touch area */
#measureLayer .measure-note{
  top:max(9px,env(safe-area-inset-top));bottom:auto;
  left:50%;transform:translateX(-50%);
  max-width:min(390px,calc(100vw - 320px));
  padding:8px 12px;font-size:12px;line-height:1.3;
  color:#24463e;background:#ffffffed;border:1px solid #d6e8e1;
}
@media(max-width:760px){
  #measureLayer .measure-note{top:max(56px,calc(env(safe-area-inset-top) + 48px));max-width:min(460px,90vw)}
}

/* v11: visually distinguish the purple measurement point from the orange drag handle. */
#measureLayer .measure-note .purple-word{color:#8617df;font-weight:700}
#measureLayer .measure-note .orange-word{color:#bd6300;font-weight:700}

/* v16: keep the fingertip contact area inert during measurement only.
   Calibration still supports tapping and dragging on the canvas. */
#measureLayer.touch-guard #paint{pointer-events:none}
#measureLayer.touch-guard .measure-controls{
  padding:6px;border-radius:14px;
  background:rgba(255,255,255,.96);
  box-shadow:0 3px 16px rgba(17,65,53,.22);
  pointer-events:auto;
}
#measureLayer.touch-guard .measure-controls button{
  min-width:108px;min-height:40px;
  touch-action:manipulation;
  -webkit-user-select:none;user-select:none;
}
#measureLayer.touch-guard #save{
  min-height:56px;font-size:16px;
  border:2px solid #fff;
  box-shadow:0 0 0 2px var(--dark),0 3px 10px #0002;
  position:relative;z-index:1;
}
#measureLayer.touch-guard #save:active{filter:brightness(.92)}
@media(orientation:landscape) and (max-height:275px){
 #measureLayer.touch-guard .measure-controls{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;
 }
 #measureLayer.touch-guard .measure-controls button{min-width:0;min-height:35px}
 #measureLayer.touch-guard #save{grid-column:1/-1;grid-row:1;min-height:50px}
}
@media(orientation:portrait) and (max-width:400px){
 #measureLayer.touch-guard .measure-controls{width:calc(100vw - 16px);grid-template-columns:repeat(3,minmax(0,1fr))}
 #measureLayer.touch-guard .measure-controls button{min-width:0}
}

/* v17: readable translated finger names in the approval choices */
#assignScreen .finger-options button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:55px;padding:6px 4px;white-space:normal;line-height:1.15;overflow-wrap:anywhere}
#assignScreen .finger-options .finger-code{font-size:13px;font-weight:800}
#assignScreen .finger-options .finger-name{font-size:12px;font-weight:600}
@media(max-width:640px){#assignScreen .finger-options{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* v18: calibration can only begin in landscape. */
#calOrientationHint.cal-orientation-hint{display:block;margin:8px 0;padding:10px 12px;border:1px solid #e2ad61;border-radius:10px;background:#fff3df;color:#814c13;font-size:14px;line-height:1.4}
#calOrientationHint[hidden]{display:none!important}
#retentionNote{margin-top:5px}
