:root,
[data-theme="light"]{
  --bg:#f5f4fa;
  --surface:#ffffff;
  --surface-raised:#ffffff;
  --surface-hover:#f0eff6;
  --surface-overlay:#ffffff;
  --border:#e6e4ee;
  --border-strong:#d5d2e0;
  --text:#16151c;
  --text-muted:#5a5867;
  --text-faint:#6e6b7a;
  --danger:#d1392f;
  --danger-bg:#fbeae9;
  --success:#1f8f5f;
  --paper:#fafafa;
  --scrim:rgba(22,20,34,.4);
  --shadow-sm:0 1px 2px rgba(30,25,55,.06);
  --shadow-md:0 10px 26px -12px rgba(30,25,55,.16);
  --shadow-lg:0 26px 60px -22px rgba(30,25,55,.24);
  --accent-ink:#1d4ed8;
  color-scheme:light;
}
[data-theme="dark"]{
  --bg:#0b0b0e;
  --surface:#0e0e12;
  --surface-raised:#17171d;
  --surface-hover:#1e1e25;
  --surface-overlay:#18181e;
  --border:#232228;
  --border-strong:#302f38;
  --text:#f4f4f6;
  --text-muted:#a8a6b3;
  --text-faint:#9a97a3;
  --danger:#e0574d;
  --danger-bg:#2a1615;
  --success:#4dae7f;
  --paper:#fafafa;
  --scrim:rgba(6,6,9,.65);
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow-md:0 8px 24px -8px rgba(0,0,0,.55);
  --shadow-lg:0 24px 60px -20px rgba(0,0,0,.7);
  --accent-ink:#7fb0ff;
  color-scheme:dark;
}
:root{
  --accent-700:#1d4ed8;
  --accent-600:#2563eb;
  --accent-500:#3b82f6;
  --accent-400:#60a5fa;
  --accent-300:#93c5fd;
  --accent-200:#bfdbfe;
  --accent-050:#eff6ff;

  --font-sans:'Instrument Sans', system-ui, sans-serif;
  --font-mono:'JetBrains Mono', ui-monospace, monospace;

  --radius-sm:6px;
  --radius-md:10px;
  --radius-lg:16px;
  --radius-xl:22px;

  --ease-out:cubic-bezier(.16,1,.3,1);
}

*,*::before,*::after{box-sizing:border-box;}
html,body{min-height:100dvh;}
body{
  margin:0;
  background:
    radial-gradient(1200px 600px at 15% -10%, color-mix(in oklch, var(--accent-700), transparent 91%), transparent),
    radial-gradient(900px 500px at 100% 0%, color-mix(in oklch, var(--accent-600), transparent 94%), transparent),
    var(--bg);
  color:var(--text);
  font-family:var(--font-sans);
  -webkit-font-smoothing:antialiased;
  overflow-x:hidden;
  transition:background-color .2s, color .2s;
}
::selection{background:var(--accent-600); color:white;}
::-webkit-scrollbar{width:10px; height:10px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background:var(--border-strong); border-radius:8px; border:2px solid transparent; background-clip:padding-box;}
::-webkit-scrollbar-thumb:hover{background:var(--text-faint);}
:focus-visible{outline:2px solid var(--accent-400); outline-offset:2px; border-radius:4px;}
button{font-family:inherit;}
svg.icon{width:1em; height:1em; display:inline-block; vertical-align:-0.15em; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}
.skip-link{
  position:absolute; left:12px; top:-48px; z-index:400;
  background:var(--accent-600); color:#fff; font-size:13.5px; font-weight:600;
  padding:9px 16px; border-radius:8px; text-decoration:none;
  transition:top .15s var(--ease-out);
}
.skip-link:focus{top:12px; color:#fff;}

@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001ms !important; transition-duration:.001ms !important;}
}

#app{min-height:100dvh; display:flex; flex-direction:column;}

.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding:12px 18px; border-bottom:1px solid var(--border);
  position:sticky; top:0; z-index:40;
  background:color-mix(in oklch, var(--bg), transparent 8%);
  backdrop-filter:blur(14px);
}
.brand{display:flex; align-items:center; min-width:0; flex:1 1 auto;}
.brand-sub{
  font-family:'Caveat', cursive; font-size:26px; font-weight:700;
  color:var(--accent-600); min-width:0; overflow:hidden; flex:1 1 auto;
}
.topbar-actions{display:flex; align-items:center; gap:6px; flex-shrink:0;}
#themeToggleBtn{flex-shrink:0;}

.doc-title{
  display:block; font-size:13.5px; color:var(--text-muted); font-weight:500;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.page-indicator{
  font-family:var(--font-mono); font-size:12px; color:var(--text-faint);
  background:var(--surface-raised); border:1px solid var(--border);
  padding:4px 9px; border-radius:20px; display:flex; align-items:center; gap:6px;
}

main{flex:1; display:flex; flex-direction:column; min-height:0;}

.attrib{
  text-align:center; padding:10px 12px; font-size:12px; color:var(--text-faint);
  border-top:1px solid var(--border);
}
.attrib a{color:var(--accent-ink); font-weight:600; text-decoration:none;}
.attrib a:hover{text-decoration:underline;}

.empty-shell{
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:60px 20px 100px;
}
.empty-heading{text-align:center; max-width:520px; margin-bottom:34px;}
.empty-heading h1{
  font-size:clamp(28px,5vw,40px); font-weight:700; letter-spacing:-0.03em; line-height:1.12; margin:0 0 10px;
}
.empty-heading p{color:var(--text-muted); font-size:15.5px; line-height:1.55; margin:0;}
.empty-heading .accent{color:var(--accent-ink);}

.dropzone{
  position:relative;
  width:min(560px,92vw); border:1.5px dashed var(--border-strong); border-radius:var(--radius-xl);
  background:color-mix(in oklch, var(--surface), transparent 15%);
  padding:44px 30px; display:flex; flex-direction:column; align-items:center; gap:14px;
  cursor:pointer; transition:border-color .2s var(--ease-out), background .2s var(--ease-out), transform .2s var(--ease-out);
  text-align:center;
}
.dropzone:hover{border-color:var(--accent-500); background:color-mix(in oklch, var(--accent-700), transparent 93%);}
.dropzone.dragging{border-color:var(--accent-400); background:color-mix(in oklch, var(--accent-700), transparent 87%); transform:scale(1.01);}
.dropzone-icon{
  width:52px; height:52px; border-radius:16px;
  background:var(--surface-raised); border:1px solid var(--border-strong);
  display:flex; align-items:center; justify-content:center; color:var(--accent-ink); font-size:22px;
}
.dropzone h3{margin:0; font-size:16px; font-weight:600;}
.dropzone p{margin:0; color:var(--text-faint); font-size:13px;}
.dropzone input[type=file]{position:absolute; width:1px; height:1px; opacity:0; overflow:hidden; white-space:nowrap;}
.dropzone:focus-within{border-color:var(--accent-500); background:color-mix(in oklch, var(--accent-700), transparent 93%);}

.quick-row{display:flex; gap:10px; margin-top:22px; flex-wrap:wrap; justify-content:center;}

.notfound-badge{
  width:64px; height:64px; border-radius:20px;
  background:var(--danger-bg); color:var(--danger);
  display:flex; align-items:center; justify-content:center; font-size:28px;
  margin-bottom:18px;
}
.notfound-code{
  font-family:var(--font-mono); font-size:13px; font-weight:500;
  color:var(--text-faint); letter-spacing:.28em; text-indent:.28em; margin-bottom:10px;
}
.notfound-id{
  font-family:var(--font-mono); font-size:12.5px; color:var(--text);
  background:var(--surface-hover); border:1px solid var(--border);
  padding:1px 7px; border-radius:6px; word-break:break-all;
}

.saved-section{width:min(760px,92vw); margin-top:56px;}
.saved-section-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px;}
.saved-section-head h2{font-size:13px; text-transform:none; letter-spacing:0; color:var(--text-muted); font-weight:600; margin:0;}
.saved-grid{display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:12px;}
.saved-card{
  background:var(--surface-raised); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:12px; cursor:pointer; transition:border-color .15s, transform .15s;
  display:flex; flex-direction:row; align-items:center; gap:12px;
}
.saved-card:hover{border-color:var(--border-strong); transform:translateY(-2px);}
.saved-card-thumb{
  width:46px; height:58px; flex-shrink:0; border-radius:8px; background:var(--surface-hover); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center; color:var(--text-faint); font-size:20px;
}
.saved-card-info{flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:3px;}
.saved-card-name{font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.saved-card-meta{font-size:11px; color:var(--text-faint); font-family:var(--font-mono); white-space:nowrap;}
.saved-card-del{
  align-self:center; flex-shrink:0; width:30px; height:30px; border-radius:8px; border:none; background:transparent;
  color:var(--text-faint); display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:14px;
}
.saved-card-del:hover{background:var(--danger-bg); color:var(--danger);}

.workspace{flex:1; display:flex; min-height:0;}
.viewer-col{flex:1; display:flex; flex-direction:column; min-width:0; position:relative;}
.viewer-toolbar{
  display:flex; align-items:center; justify-content:center; gap:6px; flex-wrap:wrap;
  padding:10px; border-bottom:1px solid var(--border);
  background:color-mix(in oklch, var(--bg), transparent 4%);
}
.viewer-toolbar .spacer{flex:1;}
.viewer-scroll{
  flex:1; overflow:auto; display:flex; flex-direction:column; align-items:center; gap:26px;
  padding:32px 20px 120px; background:
    radial-gradient(circle at 50% 0%, color-mix(in oklch, var(--accent-700), transparent 95%), transparent 60%);
}
.page-wrap{position:relative; box-shadow:var(--shadow-lg); border-radius:2px; background:white; line-height:0;}
.page-wrap canvas{display:block; border-radius:2px;}
.page-num-tag{
  position:absolute; bottom:-26px; left:50%; transform:translateX(-50%);
  font-family:var(--font-mono); font-size:11px; color:var(--text-faint);
}

.sig-layer{position:absolute; inset:0;}
.sig-placed{
  position:absolute; cursor:grab; touch-action:none;
  border:1.5px solid transparent; border-radius:6px;
}
.sig-placed:hover, .sig-placed.active{border-color:var(--accent-400);}
.sig-placed img{width:100%; height:100%; display:block; pointer-events:none; user-select:none;}
.sig-placed .sig-toolbar{
  position:absolute; top:-38px; left:50%; transform:translateX(-50%);
  display:flex; gap:2px; background:var(--surface-raised); border:1px solid var(--border-strong);
  border-radius:9px; padding:3px; box-shadow:var(--shadow-md); opacity:0; pointer-events:none;
  transition:opacity .12s; white-space:nowrap;
}
.sig-placed.active .sig-toolbar{opacity:1; pointer-events:auto;}
.sig-mini-btn{
  width:26px; height:26px; border-radius:6px; border:none; background:transparent; color:var(--text-muted);
  display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:13px; flex-shrink:0;
}
.sig-mini-btn:hover{background:var(--surface-hover); color:var(--text);}
.sig-mini-btn.danger:hover{background:var(--danger-bg); color:var(--danger);}
.sig-toolbar-divider{width:1px; align-self:stretch; background:var(--border-strong); margin:3px 1px;}
.sig-resize-handle{
  position:absolute; right:-6px; bottom:-6px; width:14px; height:14px; border-radius:4px;
  background:var(--accent-500); border:2px solid var(--bg); cursor:nwse-resize;
  opacity:0; transition:opacity .12s;
}
.sig-placed.active .sig-resize-handle{opacity:1;}

.sidebar{
  width:280px; flex-shrink:0; border-left:1px solid var(--border);
  background:color-mix(in oklch, var(--surface), transparent 30%);
  display:flex; flex-direction:column; overflow-y:auto;
}
.sidebar-section{padding:18px 18px 6px;}
.sidebar-section + .sidebar-section{border-top:1px solid var(--border); padding-top:18px;}
.sidebar-label{font-size:11.5px; font-weight:600; color:var(--text-faint); margin:0 0 12px; display:flex; align-items:center; justify-content:space-between;}
.sig-lib-grid{display:grid; grid-template-columns:1fr 1fr; gap:8px; padding-bottom:16px;}
.sig-lib-item{
  position:relative; background:var(--paper); border:1.5px solid var(--border); border-radius:9px;
  height:58px; display:flex; align-items:center; justify-content:center; cursor:pointer; padding:6px;
  transition:border-color .15s, box-shadow .15s;
}
.sig-lib-item:hover{border-color:var(--accent-400); box-shadow:0 0 0 3px color-mix(in oklch, var(--accent-500), transparent 78%);}
.sig-lib-item img{max-width:100%; max-height:100%; object-fit:contain;}
.sig-lib-item .sig-lib-del{
  position:absolute; top:-6px; right:-6px; width:19px; height:19px; border-radius:50%;
  background:var(--surface-raised); border:1px solid var(--border-strong); color:var(--text-muted);
  display:flex; align-items:center; justify-content:center; font-size:10px; opacity:0; transition:opacity .12s;
}
.sig-lib-item:hover .sig-lib-del{opacity:1;}
.sig-lib-item .sig-lib-del:hover{background:var(--danger-bg); color:var(--danger); border-color:var(--danger);}
.sig-lib-empty{
  grid-column:1/-1; text-align:center; padding:22px 10px; color:var(--text-faint); font-size:12.5px;
  border:1px dashed var(--border-strong); border-radius:9px;
}

.pages-strip{display:flex; flex-direction:column; gap:8px; padding-bottom:14px;}
.pages-strip-item{
  display:flex; align-items:center; gap:9px; padding:7px 8px; border-radius:8px; cursor:pointer;
  border:1px solid transparent; font-size:12.5px; color:var(--text-muted);
}
.pages-strip-item:hover{background:var(--surface-hover);}
.pages-strip-item.active{border-color:var(--accent-600); background:color-mix(in oklch, var(--accent-700), transparent 88%); color:var(--text);}
.pages-strip-thumb{width:28px; height:36px; background:white; border-radius:2px; flex-shrink:0; box-shadow:0 0 0 1px rgba(0,0,0,.15);}
.pages-strip-item .pg-badge{
  margin-left:auto; font-family:var(--font-mono); font-size:10.5px; color:var(--text-faint);
  background:var(--surface-hover); padding:1px 6px; border-radius:5px;
}

.sidebar-backdrop{position:fixed; inset:0; background:var(--scrim); z-index:110; display:none;}
.sidebar-backdrop.open{display:block;}

.btn{
  --btn-h:36px;
  position:relative; overflow:hidden;
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  height:var(--btn-h); padding:0 14px; border-radius:var(--radius-md);
  font-size:13.5px; font-weight:500; font-family:inherit; border:0; cursor:pointer;
  user-select:none; white-space:nowrap; box-shadow:var(--shadow-sm);
  transition:transform .12s var(--ease-out), box-shadow .12s var(--ease-out), background .15s;
}
.btn:active{transform:translateY(1px);}
.btn:disabled{cursor:not-allowed; opacity:.45; transform:none;}
.btn .btn-bg{position:absolute; inset:0; border-radius:inherit; z-index:0; transition:background .15s;}
.btn .btn-content{position:relative; z-index:1; display:flex; align-items:center; gap:7px;}
.btn{flex-shrink:0;}
.btn .icon{width:16px; height:16px; flex-shrink:0;}
.btn-sm{--btn-h:30px; padding:0 11px; font-size:12.5px;}
.btn-sm .icon{width:15px; height:15px;}
.btn-lg{--btn-h:42px; padding:0 18px; font-size:14.5px;}
.btn-icon-only{width:var(--btn-h); padding:0; flex-shrink:0;}
.btn-icon-only .icon{width:18px; height:18px;}
.viewer-toolbar .btn-icon-only .icon{width:16px; height:16px;}
.sig-mini-btn .icon{width:14px; height:14px; flex-shrink:0;}
.saved-card-del .icon{width:15px; height:15px;}

.btn-primary{
  color:white;
  box-shadow:inset 0 1px 0 0 rgba(255,255,255,.16), 0 0 0 1px color-mix(in oklch, var(--accent-700), black 12%), var(--shadow-sm);
}
.btn-primary .btn-bg{background:linear-gradient(to bottom, var(--accent-500), var(--accent-700));}
.btn-primary:hover .btn-bg{background:linear-gradient(to bottom, var(--accent-600), var(--accent-700));}

.btn-secondary{
  color:var(--text); background:var(--surface-raised);
  box-shadow:inset 0 1px 0 0 rgba(255,255,255,.04), 0 0 0 1px var(--border-strong);
}
.btn-secondary:hover{background:var(--surface-hover);}

.btn-ghost{color:var(--text-muted); background:transparent; box-shadow:none;}
.btn-ghost:hover{background:var(--surface-hover); color:var(--text);}

.btn-danger{
  color:white;
  box-shadow:inset 0 1px 0 0 rgba(255,255,255,.14), 0 0 0 1px color-mix(in oklch, var(--danger), black 15%);
}
.btn-danger .btn-bg{background:linear-gradient(to bottom, #eb6c62, var(--danger));}
.btn-danger:hover .btn-bg{background:var(--danger);}

.segmented{
  position:relative;
  display:inline-flex; padding:3px; gap:2px; background:var(--surface-hover);
  border:1px solid var(--border); border-radius:var(--radius-md);
}
.segmented input{position:absolute; opacity:0; pointer-events:none;}
.segmented label{
  display:flex; align-items:center; gap:6px; padding:7px 14px; border-radius:8px;
  font-size:13px; font-weight:500; color:var(--text-faint); cursor:pointer;
  position:relative; transition:color .15s;
}
.segmented input:checked + label{color:var(--text);}
.segmented .seg-thumb{
  position:absolute; top:3px; bottom:3px; border-radius:8px; background:var(--surface-raised);
  box-shadow:0 0 0 1px var(--border-strong), var(--shadow-sm);
  transition:left .22s var(--ease-out), width .22s var(--ease-out);
  z-index:0;
}
.segmented label{z-index:1;}

.field-row{display:flex; align-items:center; gap:9px; cursor:pointer; user-select:none;}
.checkbox{
  width:18px; height:18px; border-radius:6px; border:1.5px solid var(--border-strong); background:var(--surface-raised);
  display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:background .15s, border-color .15s;
}
.checkbox svg{width:11px; height:11px; opacity:0; transform:scale(.5); transition:opacity .12s, transform .12s; stroke:white; stroke-width:3;}
input[type=checkbox]{display:none;}
input[type=checkbox]:checked + .checkbox{background:var(--accent-600); border-color:var(--accent-600);}
input[type=checkbox]:checked + .checkbox svg{opacity:1; transform:scale(1);}
.field-label{font-size:13px; color:var(--text-muted);}

.radio-dot{
  width:18px; height:18px; border-radius:50%; border:1.5px solid var(--border-strong); background:var(--surface-raised);
  display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:border-color .15s;
}
.radio-dot::after{content:''; width:8px; height:8px; border-radius:50%; background:var(--accent-500); opacity:0; transition:opacity .12s, transform .12s; transform:scale(.4);}
input[type=radio]{display:none;}
input[type=radio]:checked + .radio-dot{border-color:var(--accent-500);}
input[type=radio]:checked + .radio-dot::after{opacity:1; transform:scale(1);}

.pselect{position:relative; display:inline-block;}
.pselect-trigger{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  height:36px; padding:0 12px; border-radius:var(--radius-md); min-width:150px;
  background:var(--surface-raised); border:1px solid var(--border-strong); color:var(--text);
  font-size:13px; cursor:pointer;
}
.pselect-trigger:hover{border-color:var(--text-faint);}
.pselect-trigger .chev{transition:transform .18s var(--ease-out); color:var(--text-faint);}
.pselect.open .pselect-trigger .chev{transform:rotate(180deg);}
.pselect-menu{
  position:absolute; top:calc(100% + 6px); left:0; right:0; z-index:60;
  background:var(--surface-overlay); border:1px solid var(--border-strong); border-radius:var(--radius-md);
  box-shadow:var(--shadow-lg); padding:5px; max-height:260px; overflow-y:auto;
  transform-origin:top center;
}
.pselect-option{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:8px 10px; border-radius:7px; font-size:13px; cursor:pointer; color:var(--text-muted);
}
.pselect-option:hover{background:var(--surface-hover); color:var(--text);}
.pselect-option.selected{color:var(--text); background:color-mix(in oklch, var(--accent-600), transparent 85%);}
.pselect-option .opt-preview{font-size:16px;}

.overlay-root{position:fixed; inset:0; z-index:200; display:none;}
.overlay-root.active{display:block;}
.overlay-backdrop{position:absolute; inset:0; background:var(--scrim); backdrop-filter:blur(3px);}
.modal{
  position:absolute; top:50%; left:50%;
  width:min(560px,92vw); max-height:86vh; overflow:auto;
  background:var(--surface-overlay); border:1px solid var(--border-strong); border-radius:var(--radius-xl);
  box-shadow:var(--shadow-lg); display:flex; flex-direction:column;
}
.modal-head{display:flex; align-items:center; justify-content:space-between; padding:18px 20px; border-bottom:1px solid var(--border);}
.modal-head h3{margin:0; font-size:16px; font-weight:600; letter-spacing:-0.01em;}
.modal-head p{margin:2px 0 0; font-size:12.5px; color:var(--text-faint);}
.modal-close{
  width:28px; height:28px; border-radius:8px; border:none; background:transparent; color:var(--text-faint);
  display:flex; align-items:center; justify-content:center; cursor:pointer; flex-shrink:0;
}
.modal-close:hover{background:var(--surface-hover); color:var(--text);}
.modal-body{padding:20px;}
.modal-foot{display:flex; align-items:center; justify-content:flex-end; gap:8px; padding:16px 20px; border-top:1px solid var(--border);}
.modal-foot.spread{justify-content:space-between;}

.alert-dialog{width:min(400px,90vw);}
.alert-icon{
  width:42px; height:42px; border-radius:12px; display:flex; align-items:center; justify-content:center;
  background:var(--danger-bg); color:var(--danger); margin-bottom:14px; font-size:19px;
}

.toast-root{position:fixed; bottom:20px; left:50%; transform:translateX(-50%); z-index:300; display:flex; flex-direction:column-reverse; gap:8px; align-items:center; width:min(92vw,360px);}
.toast{
  display:flex; align-items:center; gap:10px; padding:11px 16px; border-radius:12px;
  background:var(--surface-overlay); border:1px solid var(--border-strong); box-shadow:var(--shadow-lg);
  font-size:13px; color:var(--text); width:100%;
}
.toast .toast-ic{width:20px; height:20px; border-radius:50%; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.toast.success .toast-ic{background:color-mix(in oklch, var(--success), transparent 78%); color:var(--success);}
.toast.error .toast-ic{background:color-mix(in oklch, var(--danger), transparent 78%); color:var(--danger);}
.toast.info .toast-ic{background:color-mix(in oklch, var(--accent-500), transparent 78%); color:var(--accent-ink);}

.sig-tabs-row{display:flex; justify-content:center; margin-bottom:18px;}
.sig-pane{display:none;}
.sig-pane.active{display:block;}

.draw-pad-wrap{
  background:var(--paper); border-radius:var(--radius-md); border:1px solid var(--border-strong);
  position:relative; overflow:hidden; touch-action:none;
}
.draw-pad-wrap canvas{display:block; width:100%; height:200px; cursor:crosshair;}
.draw-baseline{position:absolute; left:24px; right:24px; bottom:44px; border-bottom:1.5px dashed #c8c6d3; pointer-events:none;}
.draw-tools{display:flex; align-items:center; justify-content:space-between; margin-top:12px;}
.ink-swatches{display:flex; gap:7px;}
.ink-swatch{width:22px; height:22px; border-radius:50%; cursor:pointer; border:2px solid transparent; box-shadow:0 0 0 1px var(--border-strong);}
.ink-swatch.active{border-color:var(--accent-400);}

.type-input{
  width:100%; height:52px; background:transparent; border:none; border-bottom:1.5px solid var(--border-strong);
  color:var(--text); font-size:20px; padding:0 4px 8px; outline:none; margin-bottom:16px;
}
.type-input:focus{border-color:var(--accent-400);}
.type-preview-wrap{background:var(--paper); border-radius:var(--radius-md); border:1px solid var(--border-strong); height:130px; display:flex; align-items:center; justify-content:center; padding:10px; margin-bottom:14px;}
.type-preview{color:#111; font-size:44px; line-height:1; text-align:center; max-width:100%; overflow:hidden; white-space:nowrap;}
.font-grid{display:grid; grid-template-columns:1fr 1fr; gap:8px;}

.upload-pad{
  height:180px; border:1.5px dashed var(--border-strong); border-radius:var(--radius-md);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  cursor:pointer; color:var(--text-faint); background:var(--surface-hover);
}
.upload-pad:hover{border-color:var(--accent-500); color:var(--accent-ink);}
.upload-pad img{max-height:100%; max-width:100%; object-fit:contain;}

.sig-save-row{display:flex; align-items:center; justify-content:space-between; margin-top:16px;}

.hidden{display:none !important;}
.spinner{width:16px; height:16px; border-radius:50%; border:2px solid rgba(255,255,255,.3); border-top-color:white; animation:spin .7s linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}
.center-loader{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; color:var(--text-faint); font-size:13px;}

#sidebarToggleBtn{display:none;}

@media (max-width:860px){
  .sidebar{
    position:fixed; right:0; top:0; bottom:0; z-index:120; width:min(84vw,320px);
    transform:translateX(100%); transition:transform .25s var(--ease-out); box-shadow:var(--shadow-lg);
  }
  .sidebar.open{transform:translateX(0);}
  #sidebarToggleBtn{display:inline-flex;}
}

@media (max-width:640px){
  .topbar{padding:10px 12px;}
  #topbarActions .btn:not(.btn-icon-only){padding:0 9px;}
  #topbarActions .btn-icon-only{padding:0;}
  #topbarActions .btn-content > span:not(.icon){display:none;}
}

@media (max-width:420px){
  .quick-row .btn span:not(.icon){display:inline;}
  .viewer-toolbar{gap:8px;}
}
