/* WolfAssistant 3.3 — editor.css (module D): the structured editor (Capture & edit / New document) and the page editor.
   Tokens from app.css; logical properties throughout so RTL just works; phone first (bottom toolbar, stacked bilingual). */
.ed{position:fixed;inset:0;z-index:170;background:var(--bg);color:var(--ink);display:flex;flex-direction:column;overflow:hidden;font:15px/1.5 var(--font)}
.ed[hidden]{display:none}
.ed-head{display:flex;align-items:center;gap:8px;padding:calc(8px + var(--safe-t,0px)) 12px 8px;border-bottom:1px solid var(--line);background:var(--paper);flex:none;min-height:56px}
.ed-head h2{font-size:1rem;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ed-head .ed-sub{font-size:.76rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ed-body{flex:1;min-height:0;overflow:auto;-webkit-overflow-scrolling:touch;touch-action:pan-y;padding:14px 12px calc(84px + var(--safe-b,0px))}
.ed-body > .ed-wrap{max-width:980px;margin:0 auto}
.ed-foot{position:absolute;inset-inline:0;bottom:0;display:flex;align-items:center;gap:8px;padding:10px 12px calc(10px + var(--safe-b,0px));background:var(--paper);border-top:1px solid var(--line);z-index:2}
.ed-foot .sp{flex:1}
.ed-foot .btn,.ed-foot .btn.quiet{min-height:44px}
.ed .iconbtn{min-width:44px;min-height:44px}
.ed-meta{display:grid;grid-template-columns:1fr;gap:10px;margin-bottom:14px}
.ed-meta .f{min-height:44px}
.ed-meta .ed-row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.ed-meta label.small{display:block;margin-bottom:4px;color:var(--muted)}
.ed-title{font:600 1.15rem var(--disp);padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--paper);width:100%}
.ed-title:focus{outline:0;border-color:var(--blue);box-shadow:0 0 0 3px rgba(10,92,255,.14)}
.ed-warn{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:12px;background:var(--warnbg);color:var(--ink);font-size:.86rem;margin-bottom:12px}
.ed-sec{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:12px;margin-bottom:12px;box-shadow:var(--sh)}
.ed-sec-head{display:flex;align-items:center;gap:6px;margin-bottom:8px}
.ed-sec-head .ed-n{font:700 .74rem var(--disp);color:var(--blue);background:var(--frost);border-radius:8px;padding:3px 8px;flex:none}
.ed-sec-head .sp{flex:1}
.ed-h{font:600 1rem var(--disp);width:100%;padding:8px 10px;border:1px solid transparent;border-radius:10px;background:transparent;color:var(--ink)}
.ed-h:hover,.ed-h:focus{border-color:var(--line);background:var(--paper);outline:0}
.ed-h:focus{border-color:var(--blue)}
.ed-bi{display:grid;grid-template-columns:1fr;gap:12px}
.ed-side{min-width:0}
.ed-side-l{font-size:.72rem;font-weight:700;letter-spacing:.06em;color:var(--muted);text-transform:uppercase;margin:4px 0 6px}
@media(min-width:901px){.ed-bi{grid-template-columns:1fr 1fr}.ed-meta{grid-template-columns:2fr 1fr 1fr}.ed-meta .ed-row.full{grid-column:1/-1}}
.ed-blk{position:relative;border:1px solid transparent;border-radius:12px;padding:6px;margin:4px 0}
.ed-blk:hover,.ed-blk:focus-within{border-color:var(--line);background:var(--paper)}
.ed-blk-bar{display:none;align-items:center;gap:2px;position:absolute;inset-inline-end:6px;top:-14px;background:var(--paper);border:1px solid var(--line);border-radius:10px;padding:2px;box-shadow:var(--sh);z-index:1}
.ed-blk:hover .ed-blk-bar,.ed-blk:focus-within .ed-blk-bar,.ed-blk.sel .ed-blk-bar{display:inline-flex}
.ed-blk-bar button{width:34px;height:34px;border-radius:8px;display:grid;place-items:center;color:var(--ink2)}
.ed-blk-bar button:hover{background:var(--frost);color:var(--blue)}
.ed-blk-bar button svg.i{width:17px;height:17px}
.ed-blk-bar .ed-type{font-size:.7rem;font-weight:700;color:var(--muted);padding:0 8px;width:auto}
.ed-p{width:100%;min-height:64px;resize:vertical;border:0;background:transparent;color:var(--ink);font:inherit;padding:6px 8px;line-height:1.55}
.ed-p:focus{outline:0}
.ed-list{list-style:none;margin:0;padding:0}
.ed-list li{display:flex;align-items:flex-start;gap:8px;padding:2px 0}
.ed-list li .ed-mark{flex:none;width:22px;text-align:center;color:var(--blue);font-weight:700;padding-top:7px;font-size:.9rem}
.ed-list li input{flex:1;min-width:0;border:0;background:transparent;color:var(--ink);font:inherit;padding:6px 6px;border-bottom:1px dashed transparent}
.ed-list li input:focus{outline:0;border-bottom-color:var(--line2)}
.ed-list li .ed-x{width:32px;height:32px;border-radius:8px;color:var(--muted);display:grid;place-items:center;flex:none}
.ed-list li .ed-x:hover{background:var(--badbg);color:var(--bad)}
.ed-list li .ed-x svg.i{width:15px;height:15px}
.ed-addi{font-size:.82rem;color:var(--blue);padding:6px 8px;border-radius:8px;display:inline-flex;align-items:center;gap:6px}
.ed-addi:hover{background:var(--frost)}
.ed-tbl-wrap{overflow:auto;max-width:100%;touch-action:pan-x pan-y}
.ed-tbl{border-collapse:collapse;width:100%;min-width:320px;font-size:.9rem}
.ed-tbl td,.ed-tbl th{border:1px solid var(--line);padding:0;vertical-align:top;min-width:70px}
.ed-tbl th{background:var(--frost)}
.ed-tbl input,.ed-tbl textarea{width:100%;border:0;background:transparent;color:var(--ink);font:inherit;padding:8px 8px;min-height:38px;resize:none;line-height:1.4}
.ed-tbl th input{font-weight:700}
.ed-tbl input:focus,.ed-tbl textarea:focus{outline:0;box-shadow:inset 0 0 0 2px rgba(10,92,255,.35)}
.ed-tbl .ed-no{width:56px;min-width:56px}
.ed-tbl .ed-flag{width:44px;min-width:44px;text-align:center}
.ed-tbl .ed-flag button{width:100%;min-height:38px;font-size:1rem;color:var(--muted)}
.ed-tbl .ed-flag button.on{color:#D9343F}
.ed-tbl .ed-rowx{width:36px;min-width:36px;text-align:center;border-color:transparent}
.ed-tbl .ed-rowx button{width:32px;height:32px;border-radius:8px;color:var(--muted);display:grid;place-items:center;margin:auto}
.ed-tbl .ed-rowx button:hover{background:var(--badbg);color:var(--bad)}
.ed-tbl .ed-rowx svg.i{width:14px;height:14px}
.ed-tbl-bar{display:flex;gap:4px;flex-wrap:wrap;margin-top:6px;align-items:center}
.ed-tbl-bar .ed-chk{display:inline-flex;align-items:center;gap:6px;font-size:.8rem;color:var(--muted);margin-inline-start:auto}
.ed-addbar{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px;align-items:center}
.ed-addbar .mini{min-height:36px}
.ed-addsec{display:flex;justify-content:center;margin:8px 0 16px}
.ed-smart{position:fixed;z-index:180;background:var(--paper);border:1px solid var(--line);border-radius:14px;box-shadow:var(--sh2);padding:6px;min-width:220px;max-width:min(320px,calc(100vw - 24px))}
.ed-smart button{display:flex;align-items:center;gap:10px;width:100%;padding:10px 12px;border-radius:10px;text-align:start;color:var(--ink);min-height:44px}
.ed-smart button:hover{background:var(--frost);color:var(--blue)}
.ed-smart button svg.i{width:18px;height:18px;flex:none}
.ed-smart .ed-smart-h{font-size:.7rem;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);padding:6px 12px 2px}
.ed-busy{position:absolute;inset:0;display:grid;place-items:center;background:rgba(255,255,255,.55);border-radius:12px;font-size:.84rem;color:var(--blue);font-weight:600}
:root[data-theme="dark"] .ed-busy{background:rgba(6,26,64,.6)}
.ed-cards{display:flex;flex-direction:column;gap:8px;margin-top:8px}
.ed-kbd{font-size:.72rem;color:var(--muted);text-align:center;margin-top:12px}
@media(max-width:900px){.ed-kbd{display:none}}
.ed-empty{text-align:center;color:var(--muted);padding:40px 16px}

/* ---- the page editor ---- */
.pg-strip{display:flex;gap:8px;overflow-x:auto;padding:8px 12px;border-bottom:1px solid var(--line);background:var(--paper);flex:none;touch-action:pan-x;scrollbar-width:thin}
.pg-strip button{flex:none;width:58px;height:76px;border-radius:10px;border:2px solid var(--line);background:var(--surface2);color:var(--muted);font:600 .8rem var(--disp);display:grid;place-items:center;position:relative;overflow:hidden}
.pg-strip button img{width:100%;height:100%;object-fit:cover}
.pg-strip button span{position:absolute;bottom:3px;inset-inline-end:4px;font-size:.66rem;background:var(--paper);border-radius:6px;padding:1px 5px;color:var(--ink2)}
.pg-strip button.on{border-color:var(--blue)}
.pg-strip button.dirty::after{content:"";position:absolute;top:4px;inset-inline-start:4px;width:8px;height:8px;border-radius:50%;background:var(--warn,#E39B0B)}
.pg-stage{flex:1;min-height:0;overflow:auto;-webkit-overflow-scrolling:touch;touch-action:pan-x pan-y pinch-zoom;padding:16px 12px calc(96px + var(--safe-b,0px));background:var(--surface2)}
.pg-hint{font-size:.78rem;color:var(--muted);text-align:center;margin-bottom:8px}
.pg-page{position:relative;margin:0 auto;background:#fff;color:#000;box-shadow:0 10px 30px rgba(7,26,58,.25);transform-origin:top center;direction:ltr}
.pg-page img.pg-bg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;user-select:none}
.pg-line{position:absolute;margin:0;padding:0 1px;white-space:pre;overflow:visible;line-height:1;outline:1px dashed transparent;border-radius:2px;color:#000;cursor:text;font-family:"IBM Plex Sans","Helvetica Neue",Arial,sans-serif;min-width:8px}
.pg-page.has-bg .pg-line{color:transparent;caret-color:#000}
.pg-page.has-bg .pg-line.ed,.pg-page.has-bg .pg-line:focus,.pg-page.has-bg .pg-line.added{color:#000;background:#fff}
.pg-line.serif{font-family:"Times New Roman",Georgia,serif}.pg-line.mono{font-family:"Courier New",monospace}.pg-line.b{font-weight:700}
.pg-line[dir="rtl"]{font-family:"IBM Plex Sans Arabic","Noto Naskh Arabic","Segoe UI",sans-serif;text-align:right}
.pg-line:hover{outline-color:rgba(10,92,255,.5)}
.pg-line:focus{outline:2px solid var(--blue);outline-offset:1px;background:#fff;z-index:2}
.pg-line.ed{outline:1px dashed rgba(227,155,11,.9)}
.pg-line.added{outline:1px dashed rgba(10,92,255,.7)}
.pg-line.sel{outline:2px solid var(--blue);background:#EAF1FF}
.pg-line.drag{opacity:.75;cursor:grabbing;z-index:3}
.pg-menu{position:fixed;z-index:180;background:var(--paper);border:1px solid var(--line);border-radius:14px;box-shadow:var(--sh2);padding:6px;display:flex;flex-direction:column;min-width:200px}
.pg-menu button{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:10px;text-align:start;color:var(--ink);min-height:44px}
.pg-menu button:hover{background:var(--frost);color:var(--blue)}
.pg-menu button.danger{color:var(--bad)}
.pg-menu button svg.i{width:18px;height:18px}
.pg-zoom{display:inline-flex;align-items:center;gap:2px;background:var(--surface2);border:1px solid var(--line);border-radius:12px;padding:2px}
.pg-zoom button{width:40px;height:38px;border-radius:9px;display:grid;place-items:center;color:var(--ink2)}
.pg-zoom button:hover{background:var(--paper);color:var(--blue)}
.pg-zoom .pg-z{font-size:.78rem;min-width:44px;text-align:center;color:var(--muted)}
.pg-count{font-size:.8rem;color:var(--muted)}
@media(max-width:900px){.ed-foot .pg-count{display:none}.ed-head .ed-sub{display:none}}
.ed-close-x{display:grid;place-items:center}
