/* Formatted text: the display (.md) and the editor (.ed, see scripts/editor). */
.md{overflow-wrap:anywhere}
.md>:first-child{margin-top:0}.md>:last-child{margin-bottom:0}
.md p,.md ul,.md ol,.md blockquote,.md pre{margin:0 0 .5em}
.md ul,.md ol,.ed .ProseMirror ul,.ed .ProseMirror ol{padding-left:1.4em}
.md li>p{margin:0}
.md h1,.md h2,.md h3,.md h4,.md h5,.md h6{font:700 1.05em/1.3 var(--font);margin:.6em 0 .25em}
.md h1,.ed .ProseMirror h1{font-size:1.3em}.md h2,.ed .ProseMirror h2{font-size:1.15em}
/* Checklists (#341): the box is a character in the text (app/core/markdown.py), the editor draws its own */
.md li.task{list-style:none;margin-left:-1.2em}
.md li.task.done{color:var(--ink2)}
.md blockquote,.ed .ProseMirror blockquote{border-left:3px solid var(--line);padding-left:10px;margin-left:0;color:var(--ink2)}
.md code,.ed .ProseMirror code{background:var(--wash);padding:0 3px;border-radius:3px;font-size:.92em}
.md pre,.ed .ProseMirror pre{background:var(--wash);padding:6px 9px;border-radius:var(--r-ctl);overflow-x:auto;white-space:pre-wrap}
.md pre code,.ed .ProseMirror pre code{background:none;padding:0}
.md hr,.ed .ProseMirror hr{border:0;border-top:1px solid var(--line);margin:.6em 0}

/* The textarea stays in the form: reachable for the browser's validation, invisible to people */
textarea.ed-src{position:absolute;width:1px;height:1px;min-height:0;padding:0;border:0;opacity:0;pointer-events:none;resize:none}
.ed{position:relative;border:1px solid var(--line);border-radius:var(--r-ctl);background:var(--s2);color:var(--ink);min-width:0}
.ed:focus-within{outline:2px solid var(--accent);outline-offset:-1px}
/* The bar is smaller than the text it serves: it only shows while typing and floats, so nothing jumps */
.ed-bar{display:none;gap:1px;padding:1px;position:absolute;right:4px;bottom:100%;margin-bottom:-1px;z-index:5;background:var(--s2);border:1px solid var(--line);border-radius:var(--r-ctl) var(--r-ctl) 0 0}
.ed:focus-within .ed-bar{display:flex}
.ed-bar button{width:22px;height:20px;min-height:0;margin:0;padding:0;border:0;border-radius:3px;background:none;color:var(--ink);font:12px/1 var(--font);cursor:pointer;touch-action:manipulation}
.ed-bar button:hover{background:var(--wash)}
.ed-bar button[aria-pressed=true]{background:var(--brand);color:var(--on-brand)}
.ed-bar button:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.ed-b{font-weight:700!important}.ed-i{font-style:italic!important}.ed-s{text-decoration:line-through}.ed-l{font-size:14px!important}
.ed .ProseMirror{min-height:30px;max-height:50vh;overflow-y:auto;padding:6px 9px;white-space:pre-wrap;white-space:break-spaces;overflow-wrap:anywhere;outline:0;font-variant-ligatures:none}
.ed .ProseMirror p,.ed .ProseMirror ul,.ed .ProseMirror ol,.ed .ProseMirror blockquote,.ed .ProseMirror pre{margin:0 0 .5em}
.ed .ProseMirror>:last-child{margin-bottom:0}
.ed .ProseMirror li>p{margin:0}
.ed .ProseMirror h1,.ed .ProseMirror h2,.ed .ProseMirror h3,.ed .ProseMirror h4,.ed .ProseMirror h5,.ed .ProseMirror h6{font-family:var(--font);font-weight:700;line-height:1.3;margin:.6em 0 .25em}
.ed .ProseMirror h3,.ed .ProseMirror h4,.ed .ProseMirror h5,.ed .ProseMirror h6{font-size:1.05em}
.ed .ProseMirror li.task{list-style:none;display:flex;gap:6px;align-items:flex-start;margin-left:-1.2em}
.ed .ProseMirror .ed-check-text{flex:1;min-width:0}
.ed .ProseMirror li.task.done>.ed-check-text{color:var(--ink2);text-decoration:line-through}
.ed-check{flex:none;display:inline-grid;place-items:center;width:1.05em;height:1.05em;margin-top:.2em;border:1.5px solid var(--ink2);border-radius:3px;cursor:pointer;background:var(--s2);color:var(--on-brand);font-size:.8em;line-height:1}
li.done>.ed-check{background:var(--brand);border-color:var(--brand)}
li.done>.ed-check::after{content:"✓"}
.ed .ProseMirror-hideselection *::selection{background:transparent}
.ed .ProseMirror-selectednode{outline:2px solid var(--accent)}
.ed-empty .ProseMirror::before{content:attr(data-placeholder);color:var(--ink2);position:absolute;pointer-events:none}
fieldset:disabled .ed{background:none}
fieldset:disabled .ed .ProseMirror{min-height:0;color:var(--ink2)}
@media (pointer:coarse),(max-width:720px){
  /* Fingers need the big targets: under the text, so it doesn't hide what is being typed */
  .ed-bar{gap:4px;position:static;margin:0;padding:3px;border-width:1px 0 0;border-radius:0;order:1}
  .ed:focus-within{display:flex;flex-direction:column}
  .ed-bar button{width:44px;height:44px;font-size:17px}
  .ed .ProseMirror{font-size:16px}
}

.ed-sep{width:1px;align-self:stretch;margin:2px;background:var(--line)}
.ed-bar button:disabled{opacity:.35;cursor:default}
.ed-grow{font-size:13px!important}
.ed-bar button.ed-h{font-size:11px!important;font-weight:700}

/* The tall writing window (#341, scripts/editor/src/panel.js): on the right on a desktop, the whole screen on a phone */
.edp{position:fixed;z-index:60;top:0;right:0;bottom:0;width:min(520px,100vw);display:flex;flex-direction:column;
  background:var(--s1);color:var(--ink);border-left:1px solid var(--line);box-shadow:-8px 0 28px rgba(0,0,0,.18)}
.edp[hidden]{display:none}
.edp.edp-wide{width:min(980px,100vw)}
.edp-head{display:flex;align-items:center;gap:8px;padding:10px 12px 6px 16px}
.edp-title{flex:1;min-width:0;margin:0;font-size:1.05em;overflow-wrap:anywhere}
.edp-x{flex:none;width:36px;height:36px;min-height:0;margin:0;padding:0;border:0;border-radius:var(--r-ctl);background:none;color:var(--ink2);font-size:18px}
.edp-x:hover{background:var(--wash);color:var(--ink)}
.edp-status{padding:0 16px;font-size:.9em}
.edp-status:empty{display:none}
.edp-status.warn{margin:0 12px 6px;padding:8px 10px;border-radius:var(--r-ctl);background:var(--warn-bg);border-left:3px solid var(--warn);color:var(--ink)}
.edp-status.err{margin:0 12px 6px;padding:8px 10px;border-radius:var(--r-ctl);background:var(--bad-bg);border-left:3px solid var(--bad);color:var(--ink);font-weight:600}
.edp-status.ok{margin:0 12px 6px;padding:8px 10px;border-radius:var(--r-ctl);background:var(--ok-bg);border-left:3px solid var(--ok);color:var(--ink)}
.edp-bar.ed-bar{display:flex;flex-wrap:wrap;position:static;gap:2px;margin:0 12px;padding:4px;border:1px solid var(--line);border-radius:var(--r-ctl)}
.edp-bar.ed-bar[hidden]{display:none}
.edp-bar.ed-bar button{width:26px;height:30px;font-size:14px}
.edp-body{flex:1;min-height:0;display:flex;gap:12px;padding:8px 12px}
.edp-mine,.edp-theirs{flex:1;min-width:0;display:flex;flex-direction:column}
.edp-theirs[hidden]{display:none}
.edp-label{display:none;margin-bottom:4px;font-size:.8em;color:var(--ink2);text-transform:uppercase;letter-spacing:.04em}
.edp-two .edp-label,.edp-theirs .edp-label{display:block}
.edp .edp-ed{flex:1;min-height:0;display:flex;flex-direction:column}
.edp .edp-ed:focus-within{outline:2px solid var(--accent);outline-offset:-1px}
.edp .edp-ed .ProseMirror{flex:1;max-height:none;min-height:0;overflow-y:auto;padding:12px 14px;font-size:1.02em;line-height:1.5}
.edp-saved{flex:1;min-height:0;overflow-y:auto;padding:12px 14px;border:1px dashed var(--line);border-radius:var(--r-ctl);background:var(--wash)}
.edp-choose{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}
.edp-foot{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:10px 12px 14px;border-top:1px solid var(--line)}
.edp-actions{display:flex;flex-wrap:wrap;gap:8px}
.edp-actions .btn{margin:0}
.edp-keys{margin-left:auto}
/* a field whose text is open in the window says so where it stands */
.lock-inpanel>.lock-view{opacity:.55}
@media (max-width:720px){
  .edp,.edp.edp-wide{width:100vw;border-left:0;box-shadow:none}
  html.edp-on,html.edp-on body{overflow:hidden}
  .edp-body{flex-direction:column}
  .edp-keys{display:none}
}
@media (pointer:coarse),(max-width:720px){
  /* above the text, in one row that scrolls sideways: the keyboard covers the bottom of the screen */
  .edp .edp-bar.ed-bar{order:0;flex-wrap:nowrap;overflow-x:auto;margin:0 12px;padding:3px;border-width:1px;border-radius:var(--r-ctl)}
  .edp-bar.ed-bar button{flex:none;width:40px;height:40px;font-size:16px}
  .edp .edp-ed .ProseMirror{font-size:16px}
  .edp-foot .btn{min-height:44px}
}

/* Underline and tables (#360): Markdown "++…++" and "| a | b |" */
.ed-u-line{text-decoration:underline}
.md table,.ed .ProseMirror table{border-collapse:collapse;margin:0 0 .5em;max-width:100%;font-size:.95em}
.md table{display:block;overflow-x:auto}
.md th,.md td,.ed .ProseMirror th,.ed .ProseMirror td{border:1px solid var(--line);padding:3px 8px;text-align:left;vertical-align:top;min-width:3em}
.md th,.ed .ProseMirror th{background:var(--wash);font-weight:700}
.ed .ProseMirror .tableWrapper{overflow-x:auto;margin:0 0 .5em}
.ed .ProseMirror table{table-layout:fixed;width:100%}
.ed .ProseMirror td,.ed .ProseMirror th{position:relative;white-space:pre-wrap}
.ed .ProseMirror .selectedCell::after{content:"";position:absolute;inset:0;background:var(--accent);opacity:.18;pointer-events:none}
.ed-tablebar{display:flex;flex-wrap:wrap;gap:4px;flex-basis:100%;margin-top:3px;padding-top:3px;border-top:1px solid var(--line)}
.ed-tablebar[hidden]{display:none}
.ed-bar .ed-tablebar button{width:auto;padding:0 8px;font-size:12px}
@media (pointer:coarse),(max-width:720px){
  .edp .edp-bar.ed-bar:has(.ed-tablebar:not([hidden])){flex-wrap:wrap}  /* in a table: its row shows under the bar */
  .ed-bar .ed-tablebar button{height:36px;font-size:14px}
}
