/* Handwriting to Text (site/js/hwocr.js). Soft, borderless controls; mobile first. */
.hw-drop{display:flex;flex-direction:column;align-items:center;gap:4px;padding:26px 16px;border-radius:var(--r-card,16px);background:var(--surface-sunk);text-align:center;cursor:pointer;color:var(--ink-soft);font-size:.88rem;position:relative;margin:0 0 12px;transition:background .15s}
.hw-drop strong{color:var(--ink);font-size:1rem}
.hw-drop input{position:absolute!important;left:0;top:0;width:1px!important;height:1px!important;min-width:0!important;max-width:1px!important;padding:0!important;margin:0!important;border:0!important;opacity:0;overflow:hidden;clip-path:inset(50%)}
.hw-drop.on,.hw-drop:focus-within,.hw-drop:hover{background:var(--accent-tint)}
.hw-drop.is-compact{flex-direction:row;justify-content:center;padding:12px}
.hw-drop.is-compact span{display:none}
.hw-strip{display:flex;gap:10px;overflow-x:auto;padding:12px 14px 8px 4px;margin:0 0 8px;scrollbar-width:thin}
.hw-tw{position:relative;flex:0 0 auto}
.hw-strip[hidden]{display:none}
.hw-thumb{position:relative;flex:0 0 auto;width:76px;height:96px;border-radius:10px;overflow:hidden;background:var(--surface-sunk);border:0;padding:0;cursor:pointer}
.hw-thumb img{width:100%;height:100%;object-fit:contain;display:block}
.hw-thumb.on{outline:2px solid var(--accent);outline-offset:1px}
.hw-thumb .hw-tn{position:absolute;left:4px;bottom:4px;font-size:.7rem;font-weight:700;background:rgba(0,0,0,.55);color:#fff;border-radius:6px;padding:1px 5px}
.hw-thumb .hw-st{position:absolute;left:5px;top:5px;width:10px;height:10px;border-radius:50%;background:var(--ink-muted);opacity:.0}
.hw-thumb[data-st="done"] .hw-st{opacity:1;background:#22c55e}
.hw-thumb[data-st="work"] .hw-st{opacity:1;background:var(--accent);animation:hwPulse 1s infinite}
.hw-thumb[data-st="err"] .hw-st{opacity:1;background:#ef4444}
@keyframes hwPulse{50%{opacity:.3}}
.hw-adj{margin:0 0 12px;border-radius:var(--r-card,16px);background:var(--surface-sunk);padding:16px}
.hw-adj[hidden]{display:none}
.hw-adj-stage{position:relative;display:block;width:max-content;max-width:100%;margin:0 auto;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.hw-clip{position:relative;overflow:hidden;border-radius:8px;line-height:0;background:var(--surface)}
.hw-adj-stage img{display:block;width:auto;height:auto;max-width:100%;max-height:min(66vh,600px);max-height:min(66dvh,600px);margin:0;-webkit-user-drag:none}
.hw-crop{position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;border:2px solid var(--accent);box-shadow:0 0 0 9999px rgba(15,23,42,.45);pointer-events:none}
.hw-handles{position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none}
.hw-handles i{position:absolute;width:44px;height:44px;margin:-22px 0 0 -22px;pointer-events:auto;touch-action:none;cursor:grab}
.hw-handles i::before{content:"";position:absolute;left:50%;top:50%;width:14px;height:14px;margin:-7px 0 0 -7px;border-radius:50%;background:var(--accent);border:2px solid #fff;box-shadow:0 1px 3px rgba(0,0,0,.35)}
.hw-adj-row{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:center;margin-top:10px}
.hw-tools{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-top:14px}
.hw-tb{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-height:56px;padding:8px 2px;border:0;border-radius:12px;background:var(--surface);color:var(--ink-soft);font:inherit;font-size:.74rem;font-weight:600;line-height:1.15;cursor:pointer;text-align:center;-webkit-tap-highlight-color:transparent}
.hw-tb svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex:none}
.hw-tb span{white-space:nowrap}
.hw-tb:hover{background:var(--surface-hover);color:var(--ink)}
.hw-tb:active{transform:scale(.97)}
.hw-tb:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.hw-tb-rm,.hw-tb-rm:hover{color:#dc2626}
.hw-tb-rm:hover{background:color-mix(in srgb,#dc2626 9%,var(--surface))}
[data-theme="dark"] .hw-tb-rm,[data-theme="dark"] .hw-tb-rm:hover{color:#f87171}
.hw-adj .hw-done{width:100%;min-height:48px;height:48px;margin-top:10px;justify-content:center;font-size:1rem}
@media (min-width:600px){.hw-tools{max-width:420px;margin-left:auto;margin-right:auto}.hw-adj .hw-done{max-width:420px;display:flex;margin-left:auto;margin-right:auto}}
.hw-chip{font:inherit;font-size:.85rem;font-weight:600;border:0;border-radius:999px;padding:8px 14px;background:var(--surface);color:var(--ink-soft);cursor:pointer;display:inline-flex;align-items:center;gap:6px;box-shadow:inset 0 0 0 1.5px var(--line)}
.hw-chip:hover{background:var(--surface-hover);color:var(--ink)}
.hw-chip[aria-pressed]::before{content:"";width:.95em;height:.95em;border-radius:50%;box-shadow:inset 0 0 0 1.5px var(--ink-muted);flex:none}
.hw-chip[aria-pressed="true"]{background:var(--accent);color:var(--on-accent,#fff);box-shadow:none}
.hw-chip[aria-pressed="true"]:hover{background:var(--accent-strong);color:var(--on-accent,#fff)}
.hw-chip[aria-pressed="true"]::before{box-shadow:none;background:currentColor;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3.2L13 4.8' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3.2L13 4.8' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;border-radius:0}
.hw-chip:focus-visible,.hw-seg button:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.hw-opts{display:grid;grid-template-columns:1fr;gap:10px;margin:0 0 12px}
@media (min-width:700px){.hw-opts{grid-template-columns:1.2fr 1fr}}
@media (min-width:1100px){.hw-opts{grid-template-columns:minmax(0,1.3fr) minmax(0,1fr) auto;align-items:start}.hw-toggles{padding-top:22px}.hw-toggles{grid-column:auto;padding-bottom:2px}}
.hw-opts select{width:100%}
.hw-seg{display:flex;gap:4px;padding:4px;border-radius:var(--r-ctl,10px);background:var(--surface-sunk)}
.hw-seg button{flex:1;font:inherit;font-weight:600;font-size:.88rem;border:0;cursor:pointer;padding:8px 10px;border-radius:calc(var(--r-ctl,10px) - 3px);background:transparent;color:var(--ink-soft)}
.hw-seg button[aria-pressed="true"]{background:var(--accent);color:var(--on-accent,#fff);box-shadow:0 1px 3px rgba(0,0,0,.18)}
.hw-toggles{display:flex;flex-wrap:wrap;gap:6px;grid-column:1/-1}
.hw-note{font-size:.8rem;color:var(--ink-muted);margin:6px 0 0}
.hw-beta{display:inline-block;font-size:.68rem;font-weight:700;letter-spacing:.02em;text-transform:uppercase;color:var(--warn,#b45309);background:color-mix(in srgb,var(--warn,#f59e0b) 14%,transparent);border-radius:6px;padding:1px 6px;margin-left:6px;vertical-align:1px}
.hw-prog{margin:10px 0 0}
.hw-prog[hidden]{display:none}
.hw-track{height:6px;border-radius:99px;background:var(--surface-sunk);overflow:hidden}
.hw-track i{display:block;height:100%;width:0;border-radius:99px;background:var(--accent);transition:width .2s}
.hw-prog span{display:block;margin-top:6px;font-size:.8rem;color:var(--ink-muted);font-variant-numeric:tabular-nums}
.hw-err{color:#dc2626;font-size:.88rem;margin:8px 0 0}
.hw-err:empty{display:none}
.hw-result[hidden]{display:none}
.hw-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:0 0 10px}
.hw-pager{display:flex;align-items:center;gap:4px;font-size:.88rem;color:var(--ink-soft);font-variant-numeric:tabular-nums}
.hw-pager button{font:inherit;border:0;background:var(--surface-sunk);color:var(--ink);width:34px;height:34px;border-radius:50%;cursor:pointer}
.hw-pager button:disabled{opacity:.35;cursor:default}
.hw-acts{display:flex;flex-wrap:wrap;gap:6px;margin-left:auto}
.hw-menu{position:relative}
.hw-menu-list{position:absolute;right:0;top:calc(100% + 6px);z-index:20;min-width:190px;padding:6px;border-radius:12px;background:var(--surface);box-shadow:0 10px 30px rgba(0,0,0,.18)}
.hw-menu-list[hidden]{display:none}
.hw-menu-list button{display:block;width:100%;text-align:left;font:inherit;font-size:.9rem;border:0;background:transparent;color:var(--ink);padding:9px 10px;border-radius:8px;cursor:pointer}
.hw-menu-list button:hover{background:var(--surface-hover)}
.hw-out{min-width:0}
.hw-result{margin-top:4px;padding-top:16px;border-top:1px solid var(--line)}
.hw-back,.hw-only-wide{display:none}
.hw-sub{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 10px}
.hw-sub .hw-legend{margin:0}
.hw-split{--a:50fr;--b:50fr;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,var(--a)) auto minmax(0,var(--b));height:clamp(520px,80vh,760px);min-height:0}
.hw-split>.hw-lines{order:1}.hw-split>.hw-sep{order:2}.hw-split>.hw-view{order:3}
.hw-split.text-only{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);max-width:820px}
.hw-split.text-only .hw-view,.hw-split.text-only .hw-sep{display:none}
.hw-view{position:relative;border-radius:var(--r-card,16px);background:var(--surface-sunk);overflow:hidden;touch-action:none;min-height:0;min-width:0;-webkit-user-select:none;user-select:none}
.hw-stage{position:absolute;left:0;top:0;transform-origin:0 0;will-change:transform}
.hw-stage img{display:block;width:100%;height:100%;-webkit-user-drag:none;pointer-events:none}
.hw-zoom{position:absolute;right:8px;bottom:8px;display:flex;gap:2px;padding:3px;border-radius:999px;background:color-mix(in srgb,var(--surface) 92%,transparent);box-shadow:0 2px 10px rgba(0,0,0,.18)}
.hw-zoom button{font:inherit;font-size:.85rem;font-weight:600;min-width:36px;height:36px;border:0;border-radius:999px;background:transparent;color:var(--ink);cursor:pointer;padding:0 8px}
.hw-zoom button:hover{background:var(--surface-hover)}
.hw-sep{position:relative;display:flex;align-items:center;justify-content:center;height:28px;cursor:row-resize;touch-action:none;outline:none;-webkit-tap-highlight-color:transparent}
.hw-sep i{display:block;width:44px;height:5px;border-radius:5px;background:var(--line-strong,#c4c8d4);transition:background .15s,width .15s}
.hw-sep:hover i,.hw-sep:focus-visible i,.hw-sep.drag i{background:var(--accent);width:56px}
.hw-sep:focus-visible{box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 45%,transparent);border-radius:10px}
@media (min-width:900px){
  .hw-only-wide{display:inline-flex}
  .hw-split{grid-template-columns:minmax(0,var(--a)) auto minmax(0,var(--b));grid-template-rows:minmax(0,1fr);height:clamp(520px,78vh,820px)}
  .hw-split>.hw-view{order:1}.hw-split>.hw-sep{order:2}.hw-split>.hw-lines{order:3}
  .hw-split.text-only{grid-template-columns:minmax(0,1fr)}
  .hw-sep{height:auto;width:28px;cursor:col-resize}
  .hw-sep i{width:5px;height:44px}
  .hw-sep:hover i,.hw-sep:focus-visible i,.hw-sep.drag i{width:5px;height:56px}
}
/* full-screen review on phones */
.hw-resume{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px 14px;border-radius:var(--r-card,16px);background:var(--surface-sunk);margin-top:6px}
.hw-resume[hidden]{display:none}
.hw-resume span{flex:1 1 100%;font-weight:600;color:var(--ink)}
html.hw-lock,html.hw-lock body{overflow:hidden}
@media (max-width:899.98px){
  .hw-result.hw-full{position:fixed;left:0;right:0;top:0;height:100vh;height:100dvh;z-index:2000;margin:0;border:0;background:var(--surface);display:flex;flex-direction:column;padding:calc(8px + env(safe-area-inset-top,0px)) 12px calc(8px + env(safe-area-inset-bottom,0px));box-sizing:border-box;overflow:hidden}
  .hw-full .hw-bar{flex-wrap:nowrap;gap:6px;margin:0 0 6px}
  .hw-full .hw-back{display:inline-flex;align-items:center;gap:2px;font:inherit;font-weight:600;font-size:.92rem;border:0;background:transparent;color:var(--accent);height:44px;padding:0 8px 0 2px;margin-left:-4px;cursor:pointer}
  .hw-full .hw-pager{flex:1;justify-content:center;font-size:.82rem;min-width:0;white-space:nowrap}
  .hw-full .hw-pager button{width:36px;height:36px}
  .hw-full .hw-acts{flex-wrap:nowrap;margin-left:0}
  .hw-full #hwShare{display:none}
  .hw-full .hw-acts .tool-btn,.hw-full .hw-acts .hw-chip{padding:0 12px;min-height:40px;height:40px;font-size:.88rem}
  .hw-full .hw-sub{margin:0 0 6px;flex-wrap:nowrap;overflow:hidden}
  .hw-full .hw-legend{flex-wrap:nowrap;gap:10px;white-space:nowrap;font-size:.74rem}
  .hw-full .hw-sub .hw-chip{height:32px;min-height:32px;padding:0 10px;font-size:.8rem;white-space:nowrap}
  .hw-full .hw-split{flex:1 1 auto;height:auto;min-height:0}
  .hw-full .hw-foot{display:none}
  .hw-full.hw-kb .hw-sub{display:none}
  .hw-full .hw-lines{padding-bottom:8px}
}
@media (max-width:400px){.hw-full .hw-tip{display:none}}
.hw-lines{display:flex;flex-direction:column;gap:2px;min-width:0;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding-right:2px}
.hw-box{position:absolute;border:0;padding:0;margin:0;background:transparent;border-radius:3px;cursor:pointer;box-shadow:inset 0 0 0 1.5px color-mix(in srgb,var(--accent) 55%,transparent)}
.hw-box[data-c="mid"]{background:rgba(245,158,11,.18);box-shadow:inset 0 0 0 1.5px rgba(245,158,11,.9)}
.hw-box[data-c="low"]{background:rgba(239,68,68,.16);box-shadow:inset 0 0 0 1.5px rgba(239,68,68,.9)}
.hw-box.on{box-shadow:inset 0 0 0 2.5px var(--accent);background:color-mix(in srgb,var(--accent) 14%,transparent)}
.hw-line{position:relative;border-radius:10px;padding:2px 2px 2px 10px;background:transparent}
.hw-line::before{content:"";position:absolute;left:2px;top:8px;bottom:8px;width:3px;border-radius:3px;background:transparent}
.hw-line[data-c="mid"]::before{background:#f59e0b}
.hw-line[data-c="low"]::before{background:#ef4444}
.hw-line.gap{margin-top:12px}
.hw-line.on{background:var(--surface-sunk)}
.hw-line canvas{display:none;width:100%;height:auto;border-radius:8px;margin:6px 0 2px;background:#fff}
.hw-line.on canvas{display:block}
.hw-line textarea{display:block;width:100%;box-sizing:border-box;resize:none;overflow:hidden;font:inherit;font-size:1rem;line-height:1.5;color:var(--ink);background:transparent;border:0;border-radius:8px;padding:6px 8px;min-height:2.2em}
.hw-line textarea:focus{outline:none;background:var(--surface)}
.hw-legend{display:flex;flex-wrap:wrap;gap:12px;font-size:.78rem;color:var(--ink-muted);margin:8px 0 0}
.hw-legend b{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:5px;vertical-align:-1px}
.hw-empty{color:var(--ink-muted);font-size:.9rem;padding:14px}
.hw-hist{margin-top:16px}
.hw-hist summary{cursor:pointer;font-weight:600;color:var(--ink-soft);padding:6px 0}
.hw-hist ul{list-style:none;margin:6px 0 0;padding:0;display:flex;flex-direction:column;gap:4px}
.hw-hist li{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:10px;background:var(--surface-sunk)}
.hw-hist li button.hw-open{flex:1;min-width:0;text-align:left;font:inherit;border:0;background:transparent;color:var(--ink);cursor:pointer;padding:0}
.hw-hist li .hw-h1{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.92rem}
.hw-hist li .hw-h2{display:block;font-size:.75rem;color:var(--ink-muted)}
.hw-hist li .hw-del{border:0;background:transparent;color:var(--ink-muted);cursor:pointer;font-size:1.1rem;padding:4px 8px;border-radius:8px}
.hw-hist li .hw-del:hover{background:var(--surface-hover);color:#dc2626}
/* Site form styles set label{display:block}; keep the drop zone a centred stack. */
.tool-workspace .hw-drop{display:flex;flex-direction:column;align-items:center;justify-content:center}
.tool-workspace .hw-drop.is-compact{flex-direction:row}
.tool-workspace .hw-drop strong,.tool-workspace .hw-drop span{display:block}
.tool-workspace .hw-drop svg{width:26px;height:26px;color:var(--accent);margin-bottom:2px}
.tool-workspace .hw-drop.is-compact svg{width:20px;height:20px;margin:0 8px 0 0}
.tool-workspace .hw-drop.is-compact span{display:none}
/* Remove (x) on each page: 44px touch target, 22px visible disc. */
.hw-x{position:absolute;right:-12px;top:-12px;width:44px;height:44px;padding:0;border:0;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:2;-webkit-tap-highlight-color:transparent}
.hw-x::before{content:"";position:absolute;width:24px;height:24px;border-radius:50%;background:var(--ink);box-shadow:0 0 0 2px var(--surface-sunk,#fff),0 1px 4px rgba(0,0,0,.3)}
.hw-x svg{position:relative;width:12px;height:12px;fill:none;stroke:var(--surface,#fff);stroke-width:2.2;stroke-linecap:round}
.hw-x:hover::before{background:#dc2626}
.hw-x:focus-visible{outline:none}.hw-x:focus-visible::before{box-shadow:0 0 0 2px var(--surface-sunk,#fff),0 0 0 4px var(--accent)}
@media (pointer:coarse){.hw-adj-row .hw-chip{min-height:44px}}

/* Camera: "Take photo" sits beside the drop zone; desktop shows an in-page viewfinder (no overlay). */
.tool-workspace .hw-add{display:flex;gap:8px;align-items:stretch;margin:0 0 12px}
.tool-workspace .hw-add .hw-drop{flex:1 1 auto;min-width:0;margin:0}
.hw-cambtn{flex:0 0 auto;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;min-width:96px;min-height:44px;padding:10px 14px;border:0;border-radius:var(--r-card,16px);background:var(--accent);color:var(--on-accent,#fff);font:inherit;font-size:.88rem;font-weight:600;cursor:pointer}
.hw-cambtn:hover{background:var(--accent-strong)}
.hw-cambtn:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.hw-cambtn svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.hw-cambtn span{white-space:nowrap}
.tool-workspace .hw-add:has(.is-compact) .hw-cambtn{flex-direction:row;min-width:0;padding:10px 16px;border-radius:var(--r-card,16px)}
.tool-workspace .hw-add:has(.is-compact) .hw-cambtn svg{width:20px;height:20px}
.hw-cam{margin:0 0 12px;padding:12px;border-radius:var(--r-card,16px);background:var(--surface-sunk)}
.hw-cam[hidden]{display:none}
.hw-cam-stage{display:flex;justify-content:center;border-radius:10px;overflow:hidden;background:#0b0e17}
.hw-cam-stage video,.hw-cam-stage img{display:block;width:100%;height:auto;max-height:min(62vh,520px);max-height:min(62dvh,520px);object-fit:contain}
.hw-cam-stage [hidden]{display:none}
.hw-cam .hw-adj-row .tool-btn{min-height:44px}
