/* inline editor — grayscale chrome only; manual's own design untouched. */
/* Password dialog. Uses the manual's own tokens so it belongs to the page
   rather than to the browser, which is the whole reason it is not prompt(). */
.medit-lock{position:fixed;inset:0;z-index:120;display:flex;align-items:center;justify-content:center;
  padding:24px;background:rgba(12,12,12,.46);backdrop-filter:blur(2px)}
.medit-lock form{width:100%;max-width:340px;display:flex;flex-direction:column;gap:12px;
  background:var(--bg,#fff);color:var(--text,#202020);border:1px solid var(--line,#ededed);
  border-radius:12px;padding:22px 22px 18px;box-shadow:0 18px 44px rgba(0,0,0,.22);
  font-family:var(--font-body,sans-serif)}
.medit-lock h2{margin:0;font-size:15px;font-weight:600;color:var(--heading,#0d0d0d);
  font-family:var(--font-title,inherit)}
.medit-lock p{margin:0;font-size:12.5px;line-height:1.55;color:var(--muted,#5d5d5d)}
.medit-lock input{font:inherit;font-size:14px;padding:9px 11px;border-radius:8px;width:100%;
  border:1px solid var(--line,#ededed);background:var(--chip,#f4f4f4);color:var(--text,#202020)}
.medit-lock input:focus-visible{outline:2px solid var(--blue,#0169cc);outline-offset:1px;border-color:transparent}
.medit-lock .row{display:flex;gap:8px;justify-content:flex-end;margin-top:2px}
.medit-lock button{font:inherit;font-size:13px;font-weight:600;padding:8px 15px;border-radius:8px;cursor:pointer;
  border:1px solid var(--line,#ededed);background:var(--bg,#fff);color:var(--text,#202020)}
.medit-lock button.go{background:var(--blue,#0169cc);border-color:transparent;color:#fff}
.medit-lock button[disabled]{opacity:.55;cursor:default}
.medit-lock .err{color:#c02626;font-size:12.5px;margin:0;display:none}
.medit-lock.bad .err{display:block}
.medit-fab{position:fixed;right:22px;bottom:22px;z-index:79;width:54px;height:54px;border-radius:50%;
  border:1px solid #e4e4e4;background:#fff;color:#1b1b1b;box-shadow:0 6px 18px rgba(0,0,0,.16);cursor:pointer;
  display:none;align-items:center;justify-content:center;transition:transform .12s,background .12s}
.medit-fab.show{display:flex}
.medit-fab:hover{transform:scale(1.06);background:#f4f4f4}
.medit-fab svg{width:24px;height:24px}
body.medit-on .medit-fab{display:none}
.medit-bar{position:fixed;left:0;right:0;bottom:0;z-index:80;display:none;gap:10px;align-items:center;
  padding:11px 16px;background:#fff;color:#333;box-shadow:0 -4px 16px rgba(0,0,0,.10);border-top:1px solid #ebebeb;
  font-family:var(--font-body,sans-serif)}
body.medit-on .medit-bar{display:flex}
.medit-bar .grow{flex:1}
.medit-bar button{border:none;border-radius:8px;padding:9px 16px;font:inherit;cursor:pointer}
.medit-save{background:#1b1b1b;color:#fff;font-weight:700}
.medit-cancel{background:transparent;color:#666;border:1px solid #d6d6d6 !important}
.medit-status{font-size:13px;color:#8a8a8a;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:40vw}
/* per-block floating toolbar (add / delete) */
.medit-tools{position:fixed;z-index:81;display:none;flex-direction:column;gap:2px;padding:3px;border-radius:9px;
  background:#fff;border:1px solid #e4e4e4;box-shadow:0 3px 12px rgba(0,0,0,.14);font-family:var(--font-body,sans-serif)}
.medit-tools.show{display:flex}
.medit-tools button{width:26px;height:26px;border:none;background:transparent;color:#555;cursor:pointer;
  border-radius:6px;font:inherit;font-size:15px;line-height:1;display:flex;align-items:center;justify-content:center;padding:0}
.medit-tools button:hover{background:#f0f0f0}
.medit-menu{position:fixed;z-index:82;display:none;min-width:150px;padding:5px;border-radius:10px;
  background:#fff;color:#1b1b1b;box-shadow:0 8px 24px rgba(0,0,0,.22);font-family:var(--font-body,sans-serif)}
.medit-menu.show{display:block}
.medit-menu button{display:block;width:100%;text-align:left;border:none;background:transparent;cursor:pointer;
  padding:8px 10px;border-radius:7px;font:inherit;font-size:14px;color:#1b1b1b}
.medit-menu button:hover{background:#f0f0f0}
.medit-addpage{display:none;width:100%;margin-top:8px;padding:8px 10px;border:1px dashed #bcbcbc;
  border-radius:8px;background:transparent;color:#666;cursor:pointer;font:inherit;font-size:13.5px;text-align:left}
.medit-addpage:hover{background:#f0f0f0;color:#1b1b1b}
body.medit-on .medit-addpage{display:block}
/* selection menu, Notion's layout */
.medit-format{position:fixed;z-index:83;display:none;flex-direction:column;width:auto;min-width:200px;padding:6px;
  background:#fff;color:#37352f;border-radius:10px;font-family:var(--font-body,sans-serif);font-size:14px;
  box-shadow:0 0 0 1px rgba(15,15,15,.05),0 3px 6px rgba(15,15,15,.1),0 9px 24px rgba(15,15,15,.2)}
.medit-format.show{display:flex}
.medit-format button{border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;border-radius:6px}
.medit-format button:hover,.medit-format button.on{background:rgba(55,53,47,.08)}
.fmt-turn{display:flex;align-items:center;gap:8px;width:100%;padding:5px 8px;text-align:left}
.fmt-tic{width:20px;height:20px;display:grid;place-items:center;color:rgba(55,53,47,.8)}
.fmt-tic svg{width:19px;height:19px}
.fmt-type{flex:1;white-space:nowrap}
.fmt-chev{width:16px;height:16px;color:rgba(55,53,47,.45)}
.fmt-sep{height:1px;margin:5px 4px;background:rgba(55,53,47,.09)}
.fmt-icons{display:flex;gap:4px;padding:0 2px}
.fmt-icons button{width:32px;height:30px;display:grid;place-items:center;font-size:16px}
.fmt-icons button svg{width:19px;height:19px}
.fmt-bold{font-weight:700}
.fmt-a span{display:grid;place-items:center;width:22px;height:22px;border:1px solid rgba(55,53,47,.2);border-radius:5px;
  font-size:13px;font-weight:600}
.fmt-colors{display:none;flex-direction:column;margin-top:5px;padding-top:5px;border-top:1px solid rgba(55,53,47,.09)}
.medit-format.colors .fmt-colors{display:flex}
.fmt-sub{padding:4px 8px 4px;font-size:12px;font-weight:500;color:rgba(55,53,47,.55)}
.fmt-row{display:flex;align-items:center;gap:10px;width:100%;padding:4px 8px;text-align:left}
.fmt-sw{width:22px;height:22px;display:grid;place-items:center;border:1px solid rgba(55,53,47,.16);border-radius:5px;
  font-size:13px;font-weight:600}
:root[data-theme="dark"] .medit-format{background:#252525;color:rgba(255,255,255,.88);box-shadow:0 0 0 1px rgba(255,255,255,.08),0 9px 24px rgba(0,0,0,.5)}
:root[data-theme="dark"] .medit-format button:hover,:root[data-theme="dark"] .medit-format button.on{background:rgba(255,255,255,.08)}
:root[data-theme="dark"] .fmt-sep{background:rgba(255,255,255,.08)}:root[data-theme="dark"] .fmt-colors{border-color:rgba(255,255,255,.08)}
:root[data-theme="dark"] .fmt-tic{color:rgba(255,255,255,.8)}
.medit-grip{cursor:grab}
.medit-grip:active{cursor:grabbing}
.medit-dropline{position:fixed;height:2px;background:#3a86ff;border-radius:2px;z-index:84;
  pointer-events:none;box-shadow:0 0 5px #3a86ff;display:none}
body.medit-dragging,body.medit-dragging *{cursor:grabbing !important;user-select:none !important}
/* สารบัญ in edit mode: a ⠿ to drag each chapter by, and its name typed into. */
.nav-grip{display:none;flex:none;width:14px;margin-left:-6px;color:#9a9a9a;cursor:grab;
  touch-action:none;user-select:none;-webkit-user-select:none}
body.medit-on .nav-grip{display:inline-block}
body.medit-on .nav-list .chapter-link:hover .nav-grip{color:#333}
body.medit-on .nav-list .ch-title{cursor:text;border-radius:4px;outline:none}
body.medit-on .nav-list .ch-title:focus{background:rgba(130,130,130,.12);box-shadow:0 0 0 3px rgba(130,130,130,.12)}
.chapter-link.nav-dragging{opacity:.45}
/* ในหน้านี้ in edit mode: the same ⠿ and typed-in name for each section. */
.toc-grip{display:none;width:14px;margin-left:-8px;color:#9a9a9a;cursor:grab;
  touch-action:none;user-select:none;-webkit-user-select:none}
body.medit-on .toc-panel a{display:flex;align-items:flex-start;gap:2px}
body.medit-on .toc-panel a[data-num]::before{order:1;flex:none;margin-right:.3em}
body.medit-on .toc-panel .toc-title{order:2}
body.medit-on .toc-grip{display:inline-block;flex:none}
body.medit-on .toc-panel a:hover .toc-grip{color:#333}
body.medit-on .toc-panel .toc-title{cursor:text;border-radius:4px;outline:none;min-width:0}
body.medit-on .toc-panel .toc-title:focus{background:rgba(130,130,130,.12);box-shadow:0 0 0 3px rgba(130,130,130,.12)}
.toc-panel a.toc-dragging{opacity:.45}
.medit-delpage{background:transparent;color:#c0392b !important;border:1px solid #e6c4c4 !important}
.medit-delpage:hover{background:#faf0f0}
/* Notion-like: in edit mode the whole doc is directly editable — click and
   type, no boxes. No persistent border; the focused block gets only a faint
   tint that clears when you move on. */
body.medit-on [data-eid]{border-radius:4px;cursor:text;transition:background .12s}
[data-eid][contenteditable="true"]:focus{outline:none}
body.medit-on img.shot{cursor:pointer}
body.medit-on img.shot:hover{outline:2px solid #3a86ff;outline-offset:2px}

/* Resize handles over the left/right edge of the picture under the pointer
   (Notion-style). The frame itself ignores the mouse, or it would cover the
   picture and stop a click from replacing it. */
.medit-rsz{position:fixed;z-index:78;display:none;pointer-events:none}
.medit-rsz.show{display:block}
.medit-rsz-h{position:absolute;top:0;bottom:0;width:22px;display:flex;align-items:center;
  justify-content:center;pointer-events:auto;cursor:ew-resize}
.medit-rsz-h::before{content:"";width:6px;height:min(58px,62%);border-radius:99px;
  background:rgba(22,22,24,.66);border:1.5px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.35)}
.medit-rsz-h:hover::before{background:rgba(22,22,24,.86)}
.medit-rsz-h.l{left:-11px} .medit-rsz-h.r{right:-11px}
.medit-rsz-lbl{position:absolute;right:10px;bottom:10px;display:none;padding:3px 8px;
  border-radius:6px;background:rgba(18,18,20,.78);color:#fff;font-size:11.5px;font-weight:600}
body.medit-rszing .medit-rsz-lbl{display:block}
body.medit-rszing,body.medit-rszing *{cursor:ew-resize !important;user-select:none !important}

/* ---- autosave state, next to the status text ---- */
.medit-dot{width:8px;height:8px;border-radius:50%;flex:none;background:#c9c9c9}
.medit-dot.saved{background:#22a06b}
.medit-dot.dirty,.medit-dot.saving{background:#e3a008;animation:medit-pulse 1s ease-in-out infinite}
.medit-dot.error,.medit-dot.conflict,.medit-dot.forbidden{background:#d1453b}
@keyframes medit-pulse{50%{opacity:.35}}
.medit-conflict{display:flex;gap:8px}
.medit-conflict:empty{display:none}
.medit-conflicted{outline:2px solid #d1453b;outline-offset:4px;border-radius:4px}
@media (prefers-reduced-motion:reduce){.medit-dot.dirty,.medit-dot.saving{animation:none}}

/* ---- empty blocks say what to do (Notion placeholder) ---- */
/* ::after, never ::before: a bullet's dot, a heading's number and a note's
   dot already live in ::before, and sharing it squeezed the hint into the
   5px dot -- one letter per line. */
body.medit-on .page [contenteditable="true"]:empty::after{color:#9a9a9a;pointer-events:none;
  position:static;display:inline;width:auto;height:auto;background:none;border:0;font-weight:400}
body.medit-on .page .step-text[contenteditable="true"]:empty{display:inline-block;min-width:1em}
body.medit-on .page [contenteditable="true"]:empty:focus::after{content:"พิมพ์ข้อความ หรือกด / เพื่อเลือกชนิดบล็อก"}
body.medit-on .page [contenteditable="true"][data-mb-filter]:empty::after{content:"พิมพ์เพื่อค้นหา…"}
body.medit-on .page h2[contenteditable="true"]:empty:not(:focus)::after,
body.medit-on .page h4[contenteditable="true"]:empty:not(:focus)::after{content:"หัวข้อ"}
body.medit-on .page p.line[contenteditable="true"]:empty{min-height:1.6em}

/* ---- slash menu and ⠿ menu, in the look of Notion's ---- */
.mb-pop{position:fixed;z-index:110;display:none;flex-direction:column;width:270px;max-height:min(380px,62vh);
  background:#fff;color:#37352f;border-radius:10px;
  box-shadow:0 0 0 1px rgba(15,15,15,.05),0 3px 6px rgba(15,15,15,.1),0 9px 24px rgba(15,15,15,.2);
  font-family:var(--font-body,sans-serif);font-size:14px;overflow:hidden}
.mb-pop.show{display:flex}
.mb-list{overflow:auto;padding:4px 0}
.mb-group{padding:8px 14px 4px;font-size:12px;font-weight:500;color:rgba(55,53,47,.55)}
.mb-empty{padding:8px 14px;color:rgba(55,53,47,.55)}
.mb-sep{height:1px;margin:5px 0;background:rgba(55,53,47,.09)}
.mb-item{display:flex;align-items:center;gap:10px;width:calc(100% - 8px);margin:0 4px;min-height:30px;padding:4px 10px;
  border:0;border-radius:6px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
.mb-item.on{background:rgba(55,53,47,.08)}
.mb-ic{flex:none;width:20px;height:20px;display:grid;place-items:center;color:rgba(55,53,47,.8)}
.mb-ic svg{width:19px;height:19px}
.mb-tx{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mb-pop kbd{margin-left:auto;font:12px ui-monospace,SFMono-Regular,Menlo,monospace;color:rgba(55,53,47,.4);background:none;border:0}
.mb-item.danger:hover,.mb-item.danger.on{color:#eb5757}
.mb-item.danger.on .mb-ic{color:#eb5757}
.mb-close{display:flex;align-items:center;width:100%;padding:9px 18px;border:0;border-top:1px solid rgba(55,53,47,.09);
  background:#fff;color:inherit;font:inherit;text-align:left;cursor:pointer}
.mb-close:hover{background:rgba(55,53,47,.05)}
:root[data-theme="dark"] .mb-pop{background:#252525;color:rgba(255,255,255,.88);
  box-shadow:0 0 0 1px rgba(255,255,255,.08),0 9px 24px rgba(0,0,0,.5)}
:root[data-theme="dark"] .mb-close{background:#252525;border-top-color:rgba(255,255,255,.08)}
:root[data-theme="dark"] .mb-item.on{background:rgba(255,255,255,.07)}
:root[data-theme="dark"] .mb-group,:root[data-theme="dark"] .mb-pop kbd{color:rgba(255,255,255,.45)}
:root[data-theme="dark"] .mb-ic{color:rgba(255,255,255,.8)}
:root[data-theme="dark"] .mb-sep{background:rgba(255,255,255,.08)}

/* the gutter: ＋ then ⠿ side by side, Notion's handle */
.medit-tools{flex-direction:row;gap:2px;padding:0;background:transparent;border:0;border-radius:0;box-shadow:none}
.medit-tools button{width:24px;height:24px;padding:0;border-radius:4px;color:rgba(55,53,47,.35);background:transparent;
  display:grid;place-items:center;transition:background .12s}
.medit-tools button svg{width:16px;height:16px}
.medit-tools #medit-grip{width:18px;cursor:grab}
.medit-tools #medit-grip svg{width:10px;height:16px}
.medit-tools button:hover{color:rgba(55,53,47,.6);background:rgba(55,53,47,.08)}
:root[data-theme="dark"] .medit-tools button{color:rgba(255,255,255,.35)}
:root[data-theme="dark"] .medit-tools button:hover{color:rgba(255,255,255,.7);background:rgba(255,255,255,.08)}
.medit-tip{position:fixed;z-index:120;display:none;transform:translateX(-50%);padding:4px 8px;border-radius:5px;
  background:#0f0f0f;color:rgba(255,255,255,.8);font:12px/1.45 var(--font-body,sans-serif);text-align:center;
  white-space:nowrap;pointer-events:none;box-shadow:0 2px 6px rgba(0,0,0,.2)}
.medit-tip b{color:#fff;font-weight:600}
.medit-tip.show{display:block}
.medit-dot{margin-right:2px}
@media (hover:none){.medit-tools{gap:4px;padding:3px;border-radius:9px;background:#fff;border:1px solid #e4e4e4;box-shadow:0 3px 12px rgba(0,0,0,.14)}
  .medit-tools button,.medit-tools #medit-grip{width:34px;height:34px;color:#555}.medit-tip{display:none!important}}
.medit-bar button{white-space:nowrap}
@media (max-width:600px){.medit-bar{gap:8px;padding:9px 12px}.medit-bar button{padding:8px 12px}
  .medit-status{max-width:none;flex:1;min-width:0}.medit-bar .grow{display:none}}
.medit-bar .medit-icon{width:34px;height:34px;padding:0;display:grid;place-items:center;border-radius:8px;
  background:transparent;color:#555}
.medit-bar .medit-icon svg{width:19px;height:19px}
.medit-bar .medit-icon:hover:not(:disabled){background:rgba(55,53,47,.08)}
.medit-bar .medit-icon:disabled{color:#c4c4c4;cursor:default}
