*{box-sizing:border-box}body{margin:0;background:#edf1f5;color:#192b40;font:16px system-ui}header{background:#172d45;color:white;padding:15px;display:flex;justify-content:space-between;align-items:center}header a{color:white;font-weight:bold;text-decoration:none}main{max-width:850px;margin:30px auto;padding:24px;background:white;border-radius:12px}label{display:block;margin:10px 0}input,button{font:inherit;padding:9px;border:1px solid #b6c2d0;border-radius:6px}label input{display:block;max-width:100%}button{background:#fff;cursor:pointer}button.active{background:#193e68;color:white}article{display:flex;gap:12px;align-items:center;padding:15px 0;border-bottom:1px solid #ddd;flex-wrap:wrap}article a{flex:1}.toolbar{position:sticky;top:0;background:white;padding:8px;display:flex;flex-wrap:wrap;gap:6px;align-items:center;z-index:3}.toolbar label{margin:0}.toolbar input{display:inline;width:65px}#sheet{position:relative;margin:20px auto;width:fit-content;max-width:98vw;background:white;box-shadow:0 2px 12px #0002}canvas{display:block;max-width:98vw;height:auto}#ink{position:absolute;inset:0;touch-action:none}#status{font-size:13px}@media(max-width:600px){main{margin:10px;padding:15px}.toolbar button{font-size:13px;padding:7px}}

#upload-panel{margin-top:16px;padding:14px;background:#edf1f5;border-radius:8px}#upload-progress{width:100%;height:20px;accent-color:#193e68}#upload-message{margin:8px 0 0;overflow-wrap:anywhere}button:disabled{opacity:.65;cursor:wait}
#textlayer{position:absolute;inset:0;pointer-events:none}.editabletext{position:absolute;pointer-events:auto;outline:1px dashed #7794b5}.editabletext textarea{display:block;width:100%;padding:0;margin:0;border:0;border-radius:0;background:transparent;resize:none;overflow:hidden;font-family:sans-serif;box-sizing:border-box;outline:none;white-space:pre}.editabletext:focus-within{outline:2px solid #2563eb}.editabletext button{position:absolute;top:-24px;padding:0 5px;height:24px;font-size:14px;touch-action:none}.movehandle{left:0;cursor:move}.deletehandle{right:0}.draftbox{position:absolute;border:1px dashed #2563eb;background:#2563eb15;pointer-events:none}

/* Responsive document workspace */
#workspace{overflow:auto;max-width:100%;padding:8px 0 24px;min-width:0}#sheet{max-width:none;margin:12px auto}#sheet canvas{width:100%;max-width:none;height:auto}#status{padding:5px 12px;background:#fff;min-height:26px;overflow-wrap:anywhere}.toolbar button{white-space:nowrap}.editabletext button{min-width:32px;height:30px;top:-30px}.editabletext textarea{touch-action:auto}article a{min-width:0;overflow-wrap:anywhere}header a{min-width:0}input{max-width:100%}
@media(max-width:768px){header{padding:10px;gap:8px}header a{font-size:15px}header button{font-size:14px}main{margin:10px;padding:16px}main h1{font-size:23px}main input:not([type=hidden]){width:100%}main button{min-height:44px}article{gap:8px}article small{flex-basis:100%}.toolbar{flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;gap:5px;padding:6px;scrollbar-width:thin}.toolbar>*{flex-shrink:0}.toolbar button{min-height:44px;font-size:14px;padding:8px 10px}.toolbar input{min-height:40px;width:55px}.toolbar label{display:flex;align-items:center;gap:4px;font-size:13px}#sheet{margin:8px auto}.editabletext button{min-width:36px;height:34px;top:-34px}#status{font-size:12px}#workspace{padding-bottom:48px}}

.editabletext.selected{outline:2px solid #2563eb}.toolbar #fontsize{width:76px}

.editabletext .resizehandle{top:auto;bottom:-12px;right:-12px;width:26px;height:26px;min-width:26px;background:#2563eb;color:white;border:1px solid white;cursor:nwse-resize;touch-action:none;z-index:2}.editabletext:not(.selected):not(:focus-within) .resizehandle{opacity:.55}@media(max-width:768px){.editabletext .resizehandle{width:36px;height:36px;min-width:36px;bottom:-16px;right:-16px}}

.editabletext .nudge{top:auto;bottom:-34px;min-width:30px;width:30px;height:28px;padding:0;display:none}.editabletext.selected .nudge{display:block}.editabletext.selected .resizehandle{bottom:-12px}.toolbar #lineheight{width:75px}

.dm-rows{position:absolute;inset:0;pointer-events:none;overflow:visible}.dm-rows[hidden]{display:none}.dm-row{position:absolute;white-space:pre;min-width:1em;pointer-events:auto;cursor:move;touch-action:none;user-select:none;font-family:sans-serif}.dm-row.active-row{outline:1px solid #2563eb;background:#2563eb12}.dm-row:hover{outline:1px dashed #7794b5}
#handpanel{position:sticky;top:0;z-index:5;background:#fff;padding:10px;box-shadow:0 2px 8px #0003}#handpanel[hidden]{display:none}#handpad{width:100%;max-width:100%;height:auto;max-height:24vh;touch-action:none;border:1px solid #aab8ca;background:repeating-linear-gradient(white 0,white 39px,#dce4ee 40px)}#handpanel button{margin-top:6px}#handhint{font-size:13px;margin-bottom:5px}
/* 2.0: compact editor, independently scrolling document */
.editor-page{height:100vh;height:100dvh;display:flex;flex-direction:column;overflow:hidden}.editor-page header{flex:none;padding:6px 12px}.editor-page header button{padding:5px 10px;font-size:13px}.editor-page .toolbar{position:relative;top:auto;flex:none;display:flex;flex-direction:column;align-items:stretch;overflow:visible;padding:5px 8px;gap:5px;box-shadow:0 1px 4px #0002}.tool-main,.tool-nav,.tool-menus{display:flex;align-items:center;gap:5px;min-width:0}.tool-main{overflow-x:auto;scrollbar-width:thin}.tool-main button{flex:none}.editor-page .toolbar button{min-height:34px;padding:5px 9px;font-size:13px}.tool-menus details{position:relative;flex:1;max-width:220px}.tool-menus summary{cursor:pointer;list-style:none;padding:7px 6px;background:#edf1f5;border-radius:6px;text-align:center;font-size:13px;white-space:nowrap}.tool-menus summary::after{content:' ▾'}.menu-content{position:absolute;top:100%;left:0;z-index:8;display:grid;gap:6px;background:white;border:1px solid #b6c2d0;border-radius:8px;padding:10px;min-width:175px;box-shadow:0 6px 20px #0003}.tool-menus details:last-child .menu-content{left:auto;right:0}.menu-content label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:13px}.tool-nav{flex-wrap:wrap;font-size:13px}.nav-spacer{flex:1}.editor-page #status{min-height:0;padding:0;font-size:11px;background:none;max-width:100%;overflow-wrap:anywhere}.editor-page #workspace{flex:1;min-height:0;overflow:auto;touch-action:none;overscroll-behavior:contain;padding:8px;position:relative}.editor-page #sheet{margin:0 auto;touch-action:none;max-width:none}.editor-page #sheet canvas{width:100%;height:100%;max-width:none}.editor-page #handpanel{position:relative;flex:none;top:auto}.editor-page .editabletext:not(.selected):not(:focus-within){outline:none}.editor-page .editabletext:not(.selected):not(:focus-within)>button{visibility:hidden}.editor-page .editabletext .nudge{display:none}.editor-page .editabletext textarea{touch-action:none}.editor-page .dm-row{touch-action:none}@media(max-width:420px){.editor-page .toolbar{padding:4px;gap:4px}.editor-page .toolbar button{padding:5px 7px;font-size:12px}.tool-menus summary{font-size:12px}.tool-nav #status{flex-basis:100%}.tool-menus details:nth-child(2) .menu-content{left:50%;transform:translateX(-50%)}.editor-page header a{font-size:14px}}
/* 2.1 library and sign-in */
.archive-page,.login-page{background:#f3f6fb;color:#17263d;line-height:1.5}.archive-page header{background:#fff;color:#17263d;border-bottom:1px solid #e1e7ef;padding:14px max(20px,calc((100vw - 1200px)/2));gap:12px}.archive-page header a{color:#17263d;font-size:17px}.archive-page header a:before{content:'▤';display:inline-grid;place-items:center;background:#2457d6;color:white;border-radius:10px;width:34px;height:34px;margin-right:10px}.library{max-width:1240px;margin:0 auto;padding:32px 20px;background:none}.library-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:24px}.eyebrow{font-size:11px;letter-spacing:.13em;font-weight:750;color:#536b91;margin:0 0 6px}.library h1,.login-card h1{font-size:clamp(25px,4vw,36px);letter-spacing:-.045em;line-height:1.15;margin:0 0 8px}.muted{color:#60718a;margin:0}.library h2,.login-card h2{font-size:16px;margin:0 0 12px}.library-layout{display:grid;grid-template-columns:235px minmax(0,1fr);gap:24px;align-items:start}.library-sidebar,#upload-form,.doc-card,.login-card{background:white;border:1px solid #e1e7ef;border-radius:18px;box-shadow:0 5px 20px #17263d08}.library-sidebar{padding:18px;min-width:0}.library button,.login-card button,.library input,.login-card input{border-radius:10px;border:1px solid #d6dfeb;min-height:44px}.library button,.login-card button{font-weight:600;color:#253a58}.library .primary,.login-card .primary{background:#2457d6;color:white;border-color:#2457d6;padding:11px 18px}.library button:hover,.login-card button:hover{filter:brightness(.96)}.folder-filter{display:flex;width:100%;text-align:left;justify-content:space-between;gap:8px;margin:5px 0;overflow-wrap:anywhere;background:#fff}.folder-filter.active{background:#eaf0ff;color:#2457d6;border-color:#dbe5ff}.app-install{margin-top:20px;padding-top:16px;border-top:1px solid #e1e7ef}.app-install button,.app-install a{width:100%;display:block;text-align:center;font-size:14px}.app-install button[hidden]{display:none}.app-install a{margin-top:10px;color:#2457d6}.app-install p{font-size:12px;color:#60718a;margin:8px 0 0}.library #upload-form{padding:20px;margin:0 0 24px}.library #upload-form[hidden],.doc-card[hidden]{display:none}.dropzone{display:grid;justify-items:center;gap:6px;border:2px dashed #b9cbed;border-radius:14px;background:#f8faff;padding:20px 12px;text-align:center;cursor:pointer}.upload-symbol{display:grid;place-items:center;width:40px;height:40px;border-radius:12px;background:#e5edff;color:#2457d6;font-size:26px}.dropzone small{color:#60718a}.dropzone input{width:100%;max-width:380px;background:white;font-size:14px}.upload-actions{display:flex;align-items:end;gap:12px}.upload-actions label{flex:1;margin:0;font-size:13px}.upload-actions input{width:100%;margin-top:5px}.library-search{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}.library-search h2{margin:0}.library-search h2 span{color:#60718a;font-weight:400}.library-search input{width: min(100%,300px);background:white}.doc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,230px),1fr));gap:16px}.doc-card{display:flex;flex-direction:column;align-items:stretch;gap:0;padding:0;overflow:hidden;min-width:0}.doc-preview{display:grid;place-items:center;background:#eaf0f8;height:145px;overflow:hidden;padding:12px;flex:none}.doc-preview img,.doc-preview canvas{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;box-shadow:0 2px 10px #17263d20}.doc-preview canvas[hidden],.pdf-placeholder[hidden]{display:none}.pdf-placeholder{background:white;border-radius:8px;padding:24px 18px;color:#b63b45;font-weight:800;box-shadow:0 3px 10px #17263d15}.doc-info{display:grid;gap:5px;padding:14px;flex:1}.doc-info small{color:#60718a;font-size:12px}.doc-name{color:#17263d;text-decoration:none;font-weight:650;overflow-wrap:anywhere}.doc-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px;border-top:1px solid #edf1f5}.open-doc{color:#2457d6;text-decoration:none;font-size:14px;font-weight:650}.library .delete-doc{font-size:12px;color:#a33b45;background:white}.login-page{min-height:100dvh;display:grid;place-items:center;padding:20px}.login-card{width:min(100%,440px);margin:0;padding:32px}.login-card img{border-radius:16px;margin-bottom:18px}.login-card form{margin-top:24px}.login-card input:not([type=hidden]),.login-card .primary{width:100%}.login-card label{font-size:14px}.login-card label input{margin-top:6px}.library :focus-visible,.login-card :focus-visible{outline:3px solid #759dff;outline-offset:2px}@media(max-width:760px){.library{margin:0;padding:18px 12px}.library-heading{align-items:stretch;flex-direction:column;margin-bottom:16px}.library-layout{grid-template-columns:minmax(0,1fr);gap:14px}.library-sidebar{padding:12px;display:flex;flex-wrap:wrap;gap:6px}.library-sidebar h2{width:100%;margin:0}.folder-filter{width:auto;max-width:100%;margin:0;font-size:13px}.library-sidebar .app-install{width:100%;margin-top:6px;padding-top:10px}.library-sidebar .app-install h2{display:none}.library #upload-form{padding:14px;margin-bottom:18px}.upload-actions,.library-search{align-items:stretch;flex-direction:column}.library-search input{width:100%}.doc-grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,155px),1fr));gap:10px}.doc-preview{height:110px}.doc-info,.doc-actions{padding:10px}.doc-actions{flex-wrap:wrap}.archive-page header{padding:10px 12px}.archive-page header a{font-size:14px}.archive-page header a:before{width:28px;height:28px;margin-right:6px}.login-card{padding:24px}}
/* 2.2 editor workspace */
.editor-page{display:grid;grid-template-columns:108px minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr);background:#e9eef5;color:#17263d}.editor-page header{grid-column:1/-1;background:#fff;color:#17263d;border-bottom:1px solid #dce4ef;padding:10px 18px}.editor-page header a{color:#2457d6}.editor-page header button{border:0;background:#f1f5fa;color:#526581}.editor-page .toolbar{grid-column:1;grid-row:2/4;z-index:10;background:#fff;border-right:1px solid #dce4ef;padding:10px 8px;gap:12px;box-shadow:none;justify-content:flex-start}.editor-page .tool-main,.editor-page .tool-menus{flex-direction:column;overflow:visible;align-items:stretch}.editor-page .tool-main button{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:54px;border:0;border-radius:10px;color:#526581;background:transparent;font-size:11px}.editor-page .tool-main button.active{background:#e5edff;color:#2457d6;font-weight:700}.tool-symbol{font-size:23px;line-height:1}.editor-page .tool-menus details{width:100%;max-width:none}.editor-page .tool-menus summary{background:#f1f5fa;color:#344963;border-radius:9px;padding:10px 4px}.editor-page .menu-content,.editor-page .tool-menus details:last-child .menu-content{top:0;left:calc(100% + 8px);right:auto;transform:none;border-color:#dce4ef;border-radius:12px;min-width:230px;box-shadow:0 12px 36px #17263d24}.editor-page .menu-content button{min-height:40px;text-align:left;border-color:#dce4ef}.editor-page .tool-nav{margin-top:auto;justify-content:center;gap:4px}.editor-page .tool-nav .nav-spacer{display:none}.editor-page .tool-nav button{border:0;background:#f1f5fa;min-width:26px;padding:5px}.editor-page #status{flex-basis:100%;text-align:center;color:#526581}.editor-page #workspace{grid-column:2;grid-row:3;padding:8px;min-width:0;background:#e9eef5}.editor-page #handpanel{grid-column:2;grid-row:2;min-width:0}.editor-page #sheet{box-shadow:0 4px 22px #17263d22}.editor-page button:focus-visible,.editor-page summary:focus-visible{outline:2px solid #2457d6;outline-offset:2px}
@media(max-width:760px){.editor-page{grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) auto}.editor-page header{grid-row:1;padding:7px 12px}.editor-page #handpanel{grid-column:1;grid-row:2}.editor-page #workspace{grid-column:1;grid-row:3}.editor-page .toolbar{grid-column:1;grid-row:4;border-right:0;border-top:1px solid #dce4ef;padding:5px 6px max(6px,env(safe-area-inset-bottom));gap:5px}.editor-page .tool-main{flex-direction:row;display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:2px}.editor-page .tool-main button{min-width:0;min-height:44px;padding:3px 0;font-size:clamp(8px,2.5vw,11px);gap:2px}.tool-symbol{font-size:20px}.editor-page .tool-menus{flex-direction:row;gap:5px}.editor-page .tool-menus summary{padding:7px 3px;font-size:12px}.editor-page .menu-content,.editor-page .tool-menus details:last-child .menu-content{top:auto;bottom:calc(100% + 6px);left:0;right:auto;min-width:min(230px,90vw);max-height:45dvh;overflow:auto;transform:none}.editor-page .tool-menus details:nth-child(2) .menu-content{left:50%;transform:translateX(-50%)}.editor-page .tool-menus details:last-child .menu-content{left:auto;right:0}.editor-page .tool-nav{order:-1;margin:0;flex-wrap:nowrap;justify-content:flex-start;gap:4px}.editor-page .tool-nav .nav-spacer{display:block}.editor-page .tool-nav button{min-height:30px}.editor-page #status{flex-basis:auto;max-width:26%;font-size:10px}.editor-page #handpad{max-height:18dvh}}
.hand-selection{position:absolute;border:1px dashed #2563eb;pointer-events:none;z-index:8;box-sizing:border-box}.hand-selection button{position:absolute;pointer-events:auto;touch-action:none;min-width:30px;width:30px;height:30px;padding:0;background:#2457d6;color:white;border:1px solid white;border-radius:7px}.hand-grip{right:-15px;bottom:-15px;cursor:nwse-resize}.hand-edit{left:0;top:-32px}.hand-delete{right:0;top:-32px}.editor-page #handpanel:not([hidden]){position:fixed;z-index:100;left:50%;transform:translateX(-50%);bottom:12px;top:auto;width:min(94vw,850px);border-radius:16px;padding:14px;box-shadow:0 8px 45px #14243d55}.editor-page #handpad{display:block;width:100%;height:auto;max-height:none;aspect-ratio:1000/240;background:white}.editor-page #handcommit{background:#2457d6;color:white}.editor-page #handpanel button{min-height:42px} @media(max-width:768px){.editor-page #handpanel:not([hidden]){bottom:max(12px,env(safe-area-inset-bottom));padding:10px}.hand-selection button{width:36px;height:36px}.hand-edit,.hand-delete{top:-38px}}
