@layer components {
  /* The document sheet (docs/planning/documents-writing.md §2): for whoever
     may write, the editor IS the page, from the first paint — no reading
     view that swaps in an editor on click, because the two would never draw
     a picture the same and the page would move under the click. So the
     editor at rest must look like a page: no outline on a picture under the
     pointer and no grab cursor until the editor has focus. Both are the
     gem's rules in `base`; a rule here wins by layer. */
  .document lexxy-editor:not(:focus-within) .attachment {
    outline: none;
    cursor: default;
  }

  /* Empty, the page says "Untitled" where the heading will be, in the
     heading's size, and one faint sentence under it. A new document is one
     empty heading (Document), which the gem does not call empty and so
     draws no placeholder for: the gem's own is drawn again here, from the
     same attribute, for that heading and for an editor emptied to a
     paragraph alike. The size is the gem's h1 (lexxy-content.css), which it
     exposes no property for; said once, so the hint's place follows it. */
  .document {
    --document-heading-size: 2em;
  }

  .document lexxy-editor.lexxy-editor--empty .lexxy-editor__content::before,
  .document .lexxy-editor__content:has(> h1:only-child > br:only-child)::before {
    content: attr(placeholder);
    position: absolute;
    opacity: 0.66;
    pointer-events: none;
    font-size: var(--document-heading-size);
    font-weight: bold;
    line-height: 1.2;
  }

  .document .composer {
    position: relative;
  }

  /* Under the heading's line, a half space down. */
  .document__hint {
    display: none;
    position: absolute;
    inset-block-start: calc(var(--document-heading-size) * 1.2 + var(--block-space-half));
    color: var(--color-ink-faint);
    pointer-events: none;
  }

  .document:has(lexxy-editor.lexxy-editor--empty, .lexxy-editor__content > h1:only-child > br:only-child) .document__hint {
    display: block;
  }

  /* The T stays with the words, never below the comments (the canvas, after
     the owner's note): sticky at the foot of the viewport while the words
     run past it, at the sheet's end once they stop. A save says nothing
     while it lands (owner, 2026-10-13: a word per save was busy); one that
     failed, or words waiting to land, speak in the note under the T. The
     row itself is utilities (documents/show). Stuck, it stands a space
     above the footer: the viewport's own foot is under the fixed bar, which
     hid a mail's T the same way (measured on the mail, 2026-11-02; a mail's
     is lexxy.css's .composer--long). */
  .document__tools {
    position: sticky;
    inset-block-end: calc(var(--footer-height) + var(--block-space));
  }

  /* On paper, and so in a PDF, a document is its words alone (the ⋯'s Print
     row, and the browser's own). Of the page, all goes that is neither the
     sheet, nor in it, nor around it; of the sheet, all but the words.
     !important, because a row that is a flex utility would stay: utilities
     win over this layer. */
  @media print {
    #main :not(.document, .document *, :has(.document)),
    .document > :not(.composer, .lexxy-content, [data-annotations-target~="editor"]),
    .document :is(lexxy-toolbar, .document__hint) {
      display: none !important;
    }
  }

  /* A phone writes a document as it writes everything else (lexxy.css): no
     toolbar, Markdown as you type, the paperclip in the T's place — and, as
     every composer's, only while you write. The keyboard's class, not focus,
     so the tap that blurs the editor still lands on it (layout.css). A bar
     fixed to the keyboard was tried and dropped (owner, 2026-11-02): fixed
     is laid out against the layout viewport, which iOS keeps behind the
     keys, so it stood somewhere below and the words ran over it. */
  @media (any-hover: none) {
    html:not(.keyboard-up) .document__tools .composer-attach {
      visibility: hidden;
    }
  }
}
