:root{--bg:#1b1b1b;--chrome:#2b2b2b;--chrome2:#323232;--chrome3:#3a3a3a;--line:#474747;--txt:#d6d6d6;--dim:#9a9a9a;--accent:#2d8ceb;--field:#232323}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{background:var(--bg);color:var(--txt);font:11px/1.35 "Inter","Segoe UI",system-ui,sans-serif;overflow:hidden;user-select:none}
button,input,select{font:inherit;color:inherit}
button{background:var(--chrome2);border:1px solid var(--line);border-radius:3px;cursor:default}
button:hover{background:var(--chrome3)}
input[type=range]{-webkit-appearance:none;height:4px;background:#191919;border-radius:2px}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:10px;height:12px;border-radius:2px;background:#c9c9c9;border:1px solid #666}
select,input[type=text],input[type=number]{background:var(--field);border:1px solid var(--line);border-radius:3px;padding:2px 4px}
#app{display:grid;grid-template-rows:auto auto 1fr auto;height:100%}
#topbar{display:flex;align-items:center;gap:2px;background:var(--chrome);border-bottom:1px solid #101010;padding:2px 6px;height:28px}
#menubar{display:flex;gap:1px}
#menubar button{background:none;border:0;padding:3px 8px;border-radius:3px}
#menubar button:hover,#menubar button.open{background:#3f3f3f}
#topright{margin-left:auto;display:flex;align-items:center;gap:6px;color:var(--dim)}
#topright .ic{width:22px;height:20px;line-height:1;background:none;border:0;color:var(--dim);font-size:13px}
#topright .ic:hover{color:#fff;background:#3f3f3f;border-radius:3px}
#docname{max-width:280px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#optionsbar{display:flex;align-items:center;gap:10px;background:var(--chrome2);border-bottom:1px solid #101010;padding:3px 8px;min-height:30px}
.opt-group{display:flex;align-items:center;gap:8px}
.opt-group label{display:flex;align-items:center;gap:5px;color:#c8c8c8}
.opt-group .num{width:52px;text-align:right}
.opt-right{margin-left:auto;color:var(--dim)}
#workspace{display:grid;grid-template-columns:auto auto 1fr auto;min-height:0;overflow:hidden}
#toolbar{width:40px;background:var(--chrome);border-right:1px solid #101010;padding:4px 0;display:flex;flex-direction:column;align-items:center;gap:2px}
#toolbar button{width:32px;height:28px;display:flex;align-items:center;justify-content:center;background:transparent;border:1px solid transparent;border-radius:3px;color:#d0d0d0}
#toolbar button:hover{background:#3d3d3d}
#toolbar button.active{background:#3d6184;border-color:#54799e;color:#fff}
#toolbar svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
#toolbar .divider{width:24px;height:1px;background:var(--line);margin:4px 0}
#rail{width:120px;background:#232323;border-right:1px solid #101010;overflow-y:auto;padding:6px}
#rail::-webkit-scrollbar{width:8px}#rail::-webkit-scrollbar-thumb{background:#4a4a4a;border-radius:6px}
.thumb{position:relative;margin-bottom:8px;border:1px solid #444;background:#fff;cursor:pointer}
.thumb.active{outline:2px solid var(--accent)}
.thumb canvas{display:block;width:100%;height:auto}
.thumb span{position:absolute;bottom:0;right:0;background:rgba(0,0,0,.7);color:#fff;font-size:9px;padding:0 4px}
#viewport{position:relative;overflow:hidden;background:#141414}
#stage{position:absolute;inset:0;overflow:auto;display:flex;align-items:flex-start;justify-content:center;padding:24px}
#page-wrap{position:relative;background:#fff;box-shadow:0 8px 30px rgba(0,0,0,.6);flex:0 0 auto;height:fit-content}
#page,#overlay{display:block}
#overlay{position:absolute;inset:0}
#dropzone{position:absolute;inset:12px;border:2px dashed #4b4b4b;border-radius:6px;display:none;align-items:center;justify-content:center;color:#bbb;background:rgba(20,20,20,.85);font-size:13px}
#dropzone.on{display:flex}
#dock{width:240px;background:var(--chrome);border-left:1px solid #101010;overflow-y:auto}
.panel{border-bottom:1px solid #111}
.panel header{padding:4px 8px;background:#333;font-weight:600;border-bottom:1px solid #111}
.panel .body{padding:8px}
.panel .body .row{display:flex;gap:6px;margin:4px 0;align-items:center}
.panel .hint{color:#8d8d8d}
#hist{max-height:200px;overflow-y:auto;border:1px solid #111;background:#242424}
.hist{padding:3px 6px;border-bottom:1px solid #1a1a1a;color:#c3c3c3}
.hist.active{background:#3d6184;color:#fff}
#statusbar{display:flex;gap:14px;background:var(--chrome2);border-top:1px solid #101010;padding:3px 8px;color:#b9b9b9;height:22px}
#statusbar .spacer{flex:1}
#menu-layer{position:fixed;inset:0;z-index:50;display:none;pointer-events:none}
#menu-layer.open{display:block}
.menu{position:absolute;pointer-events:auto;min-width:200px;background:#2f2f2f;border:1px solid #4d4d4d;border-radius:4px;padding:4px;box-shadow:0 8px 24px rgba(0,0,0,.55)}
.menu .mi{display:flex;justify-content:space-between;gap:20px;padding:4px 8px;border-radius:3px;white-space:nowrap}
.menu .mi:hover{background:var(--accent);color:#fff}
.menu .k{color:#9a9a9a;font-size:10px}
.menu .hr{height:1px;background:#484848;margin:4px 2px}
#dialog-layer{position:fixed;inset:0;display:none;align-items:center;justify-content:center;background:rgba(0,0,0,.45);z-index:60}
#dialog-layer.open{display:flex}
.dlg{width:340px;background:var(--chrome);border:1px solid #555;border-radius:5px}
.dlg h3{margin:0;padding:8px 12px;background:#3a3a3a;border-bottom:1px solid #111;font-size:11px;border-radius:5px 5px 0 0}
.dlg .c{padding:12px;display:flex;flex-direction:column;gap:10px}
.dlg .c label{display:flex;gap:8px;align-items:center;color:#ccc}
.dlg .f{display:flex;justify-content:flex-end;gap:8px;padding:10px 12px;border-top:1px solid #111;background:#2a2a2a}
.dlg .f .pri{background:var(--accent);border-color:#4d9bf0;color:#fff;padding:3px 14px}
.dlg .f button{padding:3px 14px}
#toast{position:fixed;left:50%;bottom:44px;transform:translateX(-50%);background:rgba(28,28,28,.96);border:1px solid #555;padding:6px 14px;border-radius:4px;opacity:0;transition:opacity .18s;pointer-events:none;z-index:80}
#toast.on{opacity:1}
#signpad{background:#fff;border:1px solid #666;border-radius:4px;touch-action:none}
