/* The editors (/edit-text, /edit-markdown, /edit-word), on style.css's tokens: a toolbar of clear icon buttons, a big writing
   area, and for Word a page that looks like a page. */
.editor { max-width: 980px; }
.ed-panel { padding: var(--s3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* open, new, file name */
.ed-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: 2px 2px var(--s3); }
.ed-bar .btn { height: 42px; font-size: 14.5px; padding: 0 14px; }
.ed-bar .btn svg { width: 18px; height: 18px; }
.ed-name { flex: 1 1 200px; display: flex; justify-content: flex-end; min-width: 0; }
.ed-name input { width: min(320px, 100%); height: 42px; padding: 0 12px; font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink); text-align: right;
                 background: transparent; border: 1px solid transparent; border-radius: 10px; text-overflow: ellipsis; transition: border-color .15s, background .15s; }
.ed-name input:hover { border-color: var(--line-strong); }
.ed-name input:focus { outline: 0; text-align: left; background: var(--card); border-color: color-mix(in srgb, var(--ink) 40%, transparent);
                       box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 6%, transparent); }

/* toolbar: icon buttons, pressed when the selection already has that style */
.ed-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 4px; margin: 0 0 var(--s3); background: var(--soft); border-radius: var(--r); }
.ed-tools button, .ed-colour { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 9px; background: none;
                               color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.ed-tools button svg, .ed-colour svg { width: 20px; height: 20px; }
.ed-tools button:hover, .ed-colour:hover { background: var(--card); color: var(--ink); }
.ed-tools button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.ed-tools button.ed-wide { display: inline-flex; gap: 8px; width: auto; padding: 0 12px; font: inherit; font-size: 14px; font-weight: 600; }
.ed-gap { width: 1px; height: 22px; margin: 0 6px; background: var(--line-strong); }
.ed-colour { position: relative; }
.ed-colour input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ed-style select { height: 40px; padding: 0 30px 0 10px; font-size: 14px; border-radius: 9px; background-color: var(--card); }

/* find and replace */
.ed-find { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin: 0 0 var(--s3); }
.ed-find input { flex: 1 1 160px; min-width: 0; height: 42px; padding: 0 12px; font: inherit; font-size: 14.5px; color: var(--ink); background: var(--sunk);
                 border: 1px solid var(--line-strong); border-radius: 10px; }
.ed-find input:focus { outline: 0; background: var(--card); border-color: color-mix(in srgb, var(--ink) 40%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 6%, transparent); }
.ed-find .btn { height: 42px; font-size: 14px; padding: 0 14px; }
.ed-found { font-size: 13.5px; color: var(--muted); min-width: 70px; }

/* the writing area; the highlights sit behind a see-through textarea with exactly the same text layout */
.ed-area { position: relative; }
.ed-text, .ed-marks { display: block; width: 100%; min-height: 52vh; margin: 0; padding: 16px 18px; font: 16px/1.65 var(--font); letter-spacing: normal; tab-size: 4;
                      white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; border: 1px solid var(--line-strong); border-radius: var(--r); overflow-y: scroll; }
.ed-text.tall, .ed-marks.tall { min-height: 62vh; }
.ed-text { position: relative; z-index: 1; resize: vertical; color: var(--ink); background: var(--sunk); transition: border-color .15s, box-shadow .15s, background .15s; }
.ed-text::placeholder { color: var(--faint); }
.ed-text:focus { outline: 0; background: var(--card); border-color: color-mix(in srgb, var(--k) 45%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--k) 12%, transparent); }
.ed-marks { position: absolute; inset: 0; height: 100%; min-height: 0; color: transparent; background: var(--card); pointer-events: none; visibility: hidden;
            scrollbar-color: transparent transparent; }
.ed-area.finding .ed-marks { visibility: visible; }
.ed-area.finding .ed-text { background: transparent; }
.ed-marks mark { color: transparent; background: color-mix(in srgb, #F5B400 32%, transparent); border-radius: 3px; }
.ed-marks mark.now { background: color-mix(in srgb, #F57C00 60%, transparent); }

/* Markdown: write and preview side by side; on phones, one at a time */
.ed-tabs { display: none; margin: 0 0 var(--s3); }
.ed-tabs button { display: inline-flex; align-items: center; gap: 7px; }
.ed-tabs svg { width: 17px; height: 17px; }
.ed-split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.ed-split .ed-text, .ed-split .ed-marks { min-height: 60vh; }
.ed-preview { min-height: 60vh; max-height: 75vh; overflow: auto; padding: 16px 22px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }

/* Word: a page */
.ed-note { margin: 0 2px var(--s3); font-size: 13.5px; color: var(--muted); }
.ed-sheet { padding: clamp(10px, 3vw, 28px); background: var(--soft); border-radius: var(--r-lg); }
.ed-doc { max-width: 760px; min-height: 62vh; margin: 0 auto; padding: clamp(22px, 6vw, 64px) clamp(20px, 6vw, 72px); background: var(--card); color: var(--ink);
          border-radius: 6px; box-shadow: var(--sh-2); outline: 0; caret-color: var(--k); }
.ed-doc:focus { box-shadow: var(--sh-2), 0 0 0 3px color-mix(in srgb, var(--k) 22%, transparent); }
.ed-doc:empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; }

/* how a document reads, in the preview and on the Word page */
.ed-doc-style { font-size: 16px; line-height: 1.65; overflow-wrap: break-word; }
.ed-doc-style > :first-child { margin-top: 0; }
.ed-doc-style h1 { font-size: 1.85em; line-height: 1.2; letter-spacing: -.02em; margin: .2em 0 .5em; }
.ed-doc-style h2 { font-size: 1.4em; line-height: 1.25; letter-spacing: -.015em; margin: 1.2em 0 .45em; }
.ed-doc-style h3 { font-size: 1.15em; margin: 1.1em 0 .4em; }
.ed-doc-style p { margin: 0 0 .8em; }
.ed-doc-style ul, .ed-doc-style ol { margin: 0 0 .8em; padding-left: 1.5em; }
.ed-doc-style li { margin: .15em 0; }
.ed-doc-style blockquote { margin: 0 0 .8em; padding: .1em 0 .1em 1em; border-left: 3px solid var(--line-strong); color: var(--muted); }
.ed-doc-style code { font: .88em/1.5 var(--mono); padding: .1em .35em; background: var(--soft); border-radius: 5px; }
.ed-doc-style pre { margin: 0 0 .8em; padding: 12px 14px; overflow-x: auto; background: var(--soft); border-radius: 10px; }
.ed-doc-style pre code { padding: 0; background: none; }
.ed-doc-style table { border-collapse: collapse; margin: 0 0 1em; max-width: 100%; }
.ed-doc-style th, .ed-doc-style td { border: 1px solid var(--line-strong); padding: 5px 9px; text-align: left; vertical-align: top; }
.ed-doc-style th { background: var(--soft); }
.ed-doc-style img { max-width: 100%; height: auto; }
.ed-doc-style a { color: var(--document); }
.ed-doc-style hr { border: 0; border-top: 1px solid var(--line-strong); margin: 1.4em 0; }

/* counts and messages */
.ed-foot { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s3) 4px 0; font-size: 13.5px; color: var(--muted); }
.ed-status.bad { color: var(--bad); }

@media (max-width: 900px) {
  .ed-tabs { display: inline-flex; }
  .ed-split { grid-template-columns: 1fr; }
  .ed-split[data-show="write"] .ed-preview, .ed-split[data-show="preview"] .ed-area { display: none; }
}
@media (max-width: 640px) {
  .ed-panel { padding: var(--s2); }
  .ed-name { flex-basis: 100%; justify-content: stretch; }
  .ed-name input { width: 100%; text-align: left; border-color: var(--line); }
  .ed-tools button, .ed-colour { width: 44px; height: 44px; }
  .ed-gap { display: none; }
  .ed-text, .ed-marks { font-size: 16px; padding: 12px 14px; }
  .ed-sheet { padding: 0; background: none; }
  .ed-doc { padding: 20px 18px; box-shadow: none; border: 1px solid var(--line); }
}
