/*
 * admin-mobile.css — responsive layer over the pinned Decap CMS bundle.
 *
 * Decap 3.15.1 is a desktop-first React/Emotion app. On an iPhone 16
 * (393 CSS px) it renders ~800 px wide, producing three problems a
 * contributor hits immediately:
 *   1. ~407 px of dead horizontal scroll — the app shell carries a
 *      desktop min-width and the entry editor is a fixed side-by-side
 *      react-split-pane (form pane + live-preview iframe).
 *   2. The editor toolbar's Save / Publish / Delete / account controls
 *      overflow off the right edge and can't be reached.
 *   3. Form inputs are 15 px, so iOS Safari zooms the page on focus.
 *
 * We do NOT fork Decap to fix this (see
 * docs/decisions/0002-extend-decap-for-mobile-instead-of-forking.md).
 * Instead we override layout at a mobile breakpoint — the same
 * CSS-on-top approach the inline sidebar-overlay rule already used.
 *
 * Targeting: Emotion class hashes (`css-XXXX-Name`) rotate between Decap
 * versions, but the `-Name` suffix and react-split-pane's structural
 * classes (`.SplitPane` / `.Pane1` / `.Pane2` / `.Resizer`) are stable
 * across the versions we pin against. Every selector is an
 * attribute-substring or library-class match, so if Decap renames a
 * component the rule matches nothing and the layout falls back to
 * upstream defaults (degrades safe — never worse than today). The
 * `!important` flags beat Decap's Emotion + react-split-pane inline
 * styles, which a plain rule would lose specificity to.
 *
 * iOS WebKit compositing footguns (`body::before { position: fixed }`,
 * `@keyframes { transform: scale() }`, `backdrop-filter: blur()`) blank
 * the editor form on real iPhones and are banned by
 * e2e/admin-css-banned-patterns.test.js — keep this file clear of them.
 *
 * Breakpoint: 768 px. Phones in portrait (≤ ~430) and small tablets get
 * the single-column layout; an iPhone in landscape (852) stays wide
 * enough for the upstream side-by-side editor, so it keeps the desktop
 * layout.
 */

/* ── 0. Keyboard focus ring (all widths) ─────────────────────────────
 * Decap leaves buttons and links on the browser's default focus ring, a
 * dark 1-2 px line (computed `outline: rgb(16,16,16) auto`). On its dark
 * fills ("＋ Post", the Publish group) that ring is dark on dark and all but
 * invisible (UX round 3: ad-kbd K14), and on the collection sidebar the
 * links are exactly as wide as their scrolling list, so the outline was cut
 * off at both sides and showed only as top and bottom lines (jd-kbd F11b).
 *
 * Two tones so one of them contrasts with ANY fill or page color: a white
 * 2 px outline with a #1d4ed8 ring outside it. `:focus-visible` only, so a
 * mouse click looks exactly as before. Scoped to Decap's root so it cannot
 * leak into a consumer's public pages; no `!important`, Decap's Emotion
 * rules are a single class and lose to the id. */
#nc-root :is(button, a, [role="button"], [role="menuitem"], summary):focus-visible {
  outline: 2px solid #fff;
  outline-offset: 0;
  box-shadow: 0 0 0 4px #1d4ed8;
}
/* Sidebar collection links sit flush in an `overflow: auto` list, so any
 * ring drawn outside the link's box is clipped. Draw the whole ring inside
 * it instead: a #1d4ed8 outline pulled in by its own width, with the white
 * tone as an inset shadow. */
#nc-root [class*="SidebarNavList"] a:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 4px #fff;
}
/* Decap's dropdown lists (Publish, Status, Account, Quick add, Filter, Add
 * Component) are `overflow: hidden` with their items flush against the top
 * and sides, so the general outside ring is clipped on every menu item and
 * "Publish now" showed no focus at all (UX round 4 triage package 2, the
 * gap left by cms-platform#773). Same inside-the-box ring as the sidebar. It
 * has the same specificity as the general ring rule and comes after it, so
 * it wins for menu items only; keep it below that rule. */
#nc-root [role="menuitem"]:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 4px #fff;
}

/* The header-nav "Reviews" item (reviews-nav-link.js) is for the widths
 * where the floating Reviews button is hidden; rule 9 below shows it there.
 * Above them the floating button is the way in, as before. */
#cms-reviews-nav-item {
  display: none;
}

@media (max-width: 768px) {
  /* ── 1. Remove the desktop min-width floor ──────────────────────────
   * The shell + editor containers size themselves for the side-by-side
   * panes. Dropping their min-width lets the whole UI reflow to the
   * viewport width instead of forcing a horizontal scrollbar. */
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  #nc-root,
  [class*="AppWrapper"],
  [class*="AppHeader"],
  [class*="AppMainContainer"],
  [class*="Editor"],
  [class*="Toolbar"],
  [class*="CollectionContainer"],
  [class*="CollectionMain"],
  [class*="CollectionTop"],
  [class*="PreviewPaneContainer"] {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* The top app header (collection nav + quick-add + account avatar) and
   * the per-collection header (title + "New <entry>") are single-row
   * desktop flex bars whose right-hand controls otherwise slide off the
   * screen. Let them wrap so the avatar/quick-add and the New button
   * stay on-screen. */
  [class*="AppHeader"],
  [class*="AppHeaderContent"],
  [class*="AppHeaderActions"],
  [class*="CollectionTop"] {
    flex-wrap: wrap !important;
    height: auto !important;
  }
  /* The sticky header wrapper has a fixed 56px height; once its controls
   * wrap to extra rows, the overflow spills onto the content below (the
   * account avatar lands on the collection list). Let it grow. */
  [class*="AppHeader"] {
    min-height: 0 !important;
  }

  /* ── 2. Stop iOS Safari's focus-zoom ────────────────────────────────
   * iOS zooms the viewport whenever a focused field's font-size is
   * < 16 px. Decap's inputs/textareas are 15 px. */
  [class*="AppMainContainer"] input,
  [class*="AppMainContainer"] textarea,
  [class*="AppMainContainer"] select,
  [class*="AppMainContainer"] [role="textbox"] {
    font-size: 16px !important;
  }

  /* ── 3. Put the editor into normal document flow ────────────────────
   * Decap fills the screen with an absolutely-positioned, fixed-height
   * (100vh) editor container whose panes scroll internally. On a phone
   * that traps the form in a ~393px box and parks the toolbar's top half
   * behind the sticky app header. Drop the editor into normal flow so
   * the whole page scrolls and the toolbar sits below the header. */
  [class*="EditorContainer"] {
    position: static !important;
    height: auto !important;
  }

  /* ── 4. Collapse the side-by-side editor to a single column ─────────
   * Decap renders <SplitPane>{form}{preview-iframe}</SplitPane>: the
   * form is `.Pane1`, the live-preview iframe is `.Pane2`. The repo
   * already ships /preview/ as the editor's WYSIWYG (opened in a second
   * tab), so the inline preview pane is redundant on a phone and only
   * adds horizontal scroll. Give the form the full width, let it size to
   * its content, and drop the preview pane + drag handle. The eye toggle
   * still reaches the preview: rule 13 shows it full-width instead. */
  .SplitPane,
  .SplitPane .Pane1 {
    position: static !important;
    height: auto !important;
  }
  .SplitPane .Pane1 {
    width: 100% !important;
    left: 0 !important;
    flex: 1 1 100% !important;
  }
  .SplitPane .Pane2,
  .Resizer {
    display: none !important;
  }

  /* ── 5. Make the editor toolbar reachable ───────────────────────────
   * The toolbar is laid out for desktop width, so on a phone its Save /
   * Publish / Delete controls overflow off the right edge. Let it wrap
   * to as many rows as it needs, with each control in normal flow. */
  [class*="ToolbarContainer"] {
    position: static !important;
    height: auto !important;
    flex-wrap: wrap !important;
    row-gap: 0.4rem;
  }
  /* Each toolbar section (back link, Save/Publish/Delete, status) takes
   * its own full-width row; sections and their sub-sections wrap their
   * buttons, so nothing is squeezed into a sliver. */
  [class*="ToolbarContainer"] [class*="ToolbarSection"],
  [class*="ToolbarContainer"] [class*="ToolbarSubSection"] {
    flex-wrap: wrap !important;
    min-width: 0 !important;
    justify-content: flex-start !important;
    gap: 0.4rem;
  }
  [class*="ToolbarContainer"] [class*="ToolbarSection"] {
    flex: 1 1 100% !important;
  }
  /* Buttons size to their full label (no shrink, no ellipsis) and wrap
   * as whole units, instead of all collapsing onto one row until "Save"
   * truncates to "S." and "Delete published entry" to "Delete …". */
  [class*="ToolbarContainer"] button,
  [class*="ToolbarContainer"] [class*="ToolbarButton"],
  [class*="ToolbarContainer"] [class*="ToolbarDropdown"] {
    flex: 0 0 auto !important;
    width: auto !important;
    max-width: 100% !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* ── 6. Stack the collection list (sidebar over entries) ────────────
   * The collection screen is a desktop two-column flex row (collection
   * nav + entries). Stack it so the entries column isn't pushed off the
   * right edge. */
  [class*="CollectionContainer"] {
    display: block !important;
  }
  /* The entries column (header + controls + cards) right-aligns and
   * collapses to content width on a phone (its flow column aligns its
   * items to the end). Force it to a full-width, left-aligned single
   * column. */
  [class*="CollectionMain"] {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    /* Desktop reserves ~280px of left padding for the side rail; with
     * the nav stacked above, that gutter would crush the entries into a
     * sliver on the right. */
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  /* The descendant prefix lifts these to two-class specificity so they
   * beat Decap's own single-class Emotion rules, which would otherwise
   * win the tie on source order (Emotion injects its <style> at runtime,
   * after this linked sheet). */
  [class*="CollectionMain"] > *,
  [class*="CollectionContainer"] [class*="CollectionTopContainer"],
  [class*="CollectionContainer"] [class*="CollectionControlsContainer"],
  [class*="CollectionContainer"] [class*="CardsGrid"] {
    width: 100% !important;
    max-width: 100% !important;
    align-self: stretch !important;
  }

  /* Collection nav sidebar: was an inline rule in admin/index*.html.
   * Stack it above the entries with a bounded height instead of letting
   * it overlap the content as a side rail. `overflow-y: auto` already
   * makes it touch-scrollable once there are more collections than fit in
   * 35vh, but a hard-clipped 5th item gave no visual cue that scrolling
   * reveals more — it just looked cut off, with no scroll affordance
   * (cms-platform#329.6). An inset shadow at the bottom edge is the
   * standard "more content below" cue; it costs nothing when the list
   * already fits (no visible clipped edge, so nothing to shadow). */
  aside[class*="SidebarContainer"] {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: 35vh;
    overflow-y: auto;
    border-bottom: 1px solid #d0d7de;
    box-shadow: inset 0 -10px 8px -8px rgba(0, 0, 0, 0.25);
  }

  /* ── 7. Media library modal ─────────────────────────────────────────
   * The media-library modal (`StyledModal` card → `LibraryTop` header
   * with the title + Copy Path / Download / Delete / Upload buttons,
   * then `CardGridContainer`) is sized for desktop: the header's
   * non-wrapping button row has a ~500px min-content width that
   * overflows the card and runs the action buttons off the right edge
   * of the phone (they become unreachable). Widen the card to the
   * viewport and wrap the header + button rows so every control stays
   * on-screen. `StyledModal` is Decap's generic modal card, so this also
   * fits other dialogs (e.g. delete confirmations) to the phone.
   *
   * ── Upstream caught up in 3.15.x — these rules are now belt-and-braces,
   * and that is deliberate. DON'T delete them, and DON'T duplicate what
   * upstream now ships. Diffed 3.12.2 vs 3.15.1 bundles directly:
   *   - `StyledModal`: `grid-template-rows: 120px auto` → `auto 1fr` (plus
   *     `gap: 20px`, `width: 100%`). That fixed-120px header is the exact
   *     bug our override below works around. Ours keeps `minmax(0, 1fr)`
   *     on the body track, which is marginally stronger than bare `1fr`
   *     against overflow, so it stays.
   *   - `RowContainer` / `ButtonsContainer`: gained `flex-wrap: wrap`,
   *     `align-items: center`, `gap: 8px` (from `flex-shrink: 0`).
   *   - `SearchIcon`: gained `pointer-events: none`.
   *   - `CloseButton`: its ENTIRE absolute-positioning block moved inside
   *     `@media (min-width: 500px)`. Below 500px the modal's close "X" is
   *     now an ORDINARY IN-FLOW flex item in the header's first row
   *     (measured `position: static`, box 325,105 36x30 at 393px) instead
   *     of hanging outside the corner at `left/top: -40px`. It no longer
   *     straddles the corner on a phone. Nothing here needs to change for
   *     it, but any future rule that assumes the X is out of flow at
   *     phone widths is wrong.
   *
   * ── The `admin-no-occlusion` "Copy covered by <svg>" failure was NOT a
   * CSS bug, and this section is NOT its fix. Recorded because the 3.14.1
   * attempt mis-filed it as a media-library layout regression and a
   * precondition to add `pointer-events: none` here, and re-deriving that
   * wrong conclusion is easy. Measured at 393x852 against both bundles:
   * 3.15.x made Copy Path / Download `ResponsiveActionButton`s that render
   * ICON-ONLY below a breakpoint, with the label in a `visuallyHidden` 1x1
   * span and the `<svg>` in a SIBLING `IconWrapper`. The spec's
   * `getByText` resolved that invisible span, whose centre sits inside its
   * sibling icon — so the occlusion report was accurate about an element
   * no user can tap. The real buttons were reachable the whole time. Fixed
   * in the SPEC (probe `button, label`, not the text node), not in CSS. */
  [class*="StyledModal"] {
    width: calc(100vw - 1.5rem) !important;
    max-width: calc(100vw - 1.5rem) !important;
    min-width: 0 !important;
    /* Keep Decap's grid layout. The header row is a FIXED height
     * (`grid-template-rows: 120px auto`) sized for one button row; once
     * the buttons wrap it clips them, and the wrapped row renders behind
     * the asset grid (Delete disappears). Make the header track `auto`
     * so it grows to its content, and keep the body track filling the
     * rest — the asset grid is a react-window list whose height comes
     * from that body track, so dropping the grid (display:block) would
     * collapse it to 0 and show no images. */
    grid-template-rows: auto minmax(0, 1fr) !important;
  }
  [class*="LibraryTop"],
  [class*="RowContainer"],
  [class*="CardGridContainer"],
  [class*="SearchContainer"] {
    max-width: 100% !important;
    min-width: 0 !important;
  }
  /* The header has a fixed one-row height; once the buttons wrap to a
   * second row, the extra row overflows the (grid) cell and is hidden
   * behind the search bar — so "Delete selected" disappears. Let the
   * header grow to fit the wrapped rows. */
  [class*="LibraryTop"] {
    height: auto !important;
    min-height: 0 !important;
  }
  [class*="RowContainer"],
  [class*="ButtonsContainer"] {
    flex-wrap: wrap !important;
    row-gap: 0.5rem;
  }
  /* Action buttons keep their natural width and wrap as whole units
   * (Copy Path / Download / Delete / Upload), rather than being clipped. */
  [class*="ButtonsContainer"] > * {
    flex: 0 0 auto !important;
  }

  /* ── 8. Keep the floating Live Preview / Reviews buttons off form
   * controls (cms-platform#328.4) ─────────────────────────────────────
   * #live-preview-link / #reviews-link are position:fixed at bottom-right
   * (see the .floating-link rule in admin/index*.html) and stay on top
   * (z-index:10000) of whatever scrolls beneath them. On a phone the LAST
   * field in a short form — e.g. a file-upload widget's own buttons in a
   * Media Items entry — can land directly under them, half-covered and
   * hard to tap. Reserve blank clearance at the end of the control pane
   * so the buttons always float over empty space once the user has
   * scrolled to the bottom of the form, never a live control.
   *
   * 10rem covers both stacked buttons' combined footprint on the prod
   * shell (Live Preview: bottom 6rem, ~2.5rem tall; Reviews: bottom
   * 3.25rem) plus margin; the local shell's single button sits lower
   * still (bottom 1.5rem), so the same clearance covers it too.
   *
   * Scoped to the FORM pane, not the PREVIEW pane (already display:none
   * on mobile via rule 4 above, so this would be a no-op there anyway) —
   * same ControlPaneContainer-minus-PreviewPaneContainer distinction
   * admin/live-url-banner.js's ensureBanner() makes, kept here as a
   * belt-and-braces scope rather than relying on the display:none. */
  [class*="ControlPaneContainer"]:not([class*="PreviewPaneContainer"]) {
    padding-bottom: 10rem !important;
  }

  /* ── 9. Phone/tablet widths: no Reviews button, and room for the build
   * stamp over the list (cms-platform#625.9/.10) ──────────────────────
   * At ~742px the floating Reviews button and the deployed-commit /
   * platform pills (position:fixed, bottom-right, z-index:10000) covered
   * the DRAFT chip on the last Contents row and a list row's title, and
   * the last row could not be scrolled clear. The floating button is
   * dropped here (the anchor stays in the DOM) and Reviews is a header nav
   * item instead (below). The collection list gets bottom
   * clearance so its last row scrolls above the stamps and the Live
   * Preview button. */
  #reviews-link {
    display: none !important;
  }
  /* ...and Reviews moves into the top app bar instead, between Contents and
   * Media (reviews-nav-link.js inserts it; production shell only). The owner
   * approves visual-regression changes from a phone, so the dashboard needs
   * a way in here. Hidden at every other width by the rule above this
   * media block, so exactly one Reviews link shows at a time. */
  #cms-reviews-nav-item {
    display: list-item;
  }
  /* one-door-publish.js hides the Workflow link but leaves its <li>, and
   * Decap spaces the nav items `space-around` below 800px, so the empty item
   * still took a share of the row and pushed Media away from Reviews. Take
   * the emptied item out so the three are evenly spaced. Without `:has()`
   * (Safari < 15.4) the spacing is just uneven. */
  [class*="AppHeaderNavList"] > li:has(> [data-one-door-hidden="1"]) {
    display: none;
  }
  [class*="CollectionMain"] {
    padding-bottom: 5rem !important;
  }

  /* ── 10. Empty band above the editor header (cms-platform#625.11) ───────
   * Decap reserves the height of its absolutely-positioned toolbar with a
   * top margin on the editor box. Rule 3 makes the toolbar and the editor
   * static, so that margin is left as a blank ~65px band between the
   * notice banner and the toolbar. The toolbar is in flow here, so
   * nothing needs reserving. */
  [class*="EditorContainer"] {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  /* ── 11. Date field: Now / Clear stay on-screen (cms-platform#731) ──────
   * Decap's datetime control is a nowrap flex row of the native
   * `datetime-local` input (~245px intrinsic) plus the Now / Clear buttons.
   * At 390px the pair is ~377px wide in a ~358px card, so "Clear" was cut
   * off at the right edge. Let the buttons wrap under the input when they
   * do not fit. */
  [class*="DateTimeControl"] {
    flex-wrap: wrap !important;
    row-gap: 0.4rem;
  }

  /* ── 12. Live Preview is a small round icon button (cms-platform#757.1) ──
   * Rule 8's bottom clearance only helps once the form is scrolled to its
   * end: mid-form, the ~135px-wide "Live Preview" pill (fixed, bottom-right,
   * z-index 10000) sat over the Markdown / Rich Text toggle's label and the
   * Published row. Shrink it to a 44px circle (the tap-target minimum) tucked
   * into the corner. The visible label becomes visually hidden, not removed,
   * so the link keeps its accessible name; the shells' `title` stays too.
   * While a text field has focus (the on-screen keyboard is up, and Android
   * Chrome floats fixed elements just above it, over what is being typed) the
   * button is hidden; `visibility` rather than `display` because the shells'
   * route gate owns `display`. Checkboxes and the Published switch do not
   * raise a keyboard, so they leave it alone. `:has()` is unsupported before
   * Safari 15.4 / Chrome 105; there the rule is dropped and the button just
   * stays visible. Scoped to #live-preview-link: #reviews-link is already
   * hidden by rule 9. Source order beats the shells' inline `#live-preview-
   * link { bottom }` / `.floating-link` rules, which come first in <head>. */
  #live-preview-link {
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    gap: 0;
    justify-content: center;
    border-radius: 50%;
    right: 0.75rem;
  }
  #live-preview-link svg {
    width: 20px;
    height: 20px;
  }
  #live-preview-link .floating-link-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  body:has(
      input:not([type="checkbox"], [type="radio"], [type="button"], [type="submit"], [type="file"]):focus,
      textarea:focus,
      select:focus,
      [contenteditable="true"]:focus
    )
    #live-preview-link {
    visibility: hidden;
  }

  /* ── 13. The eye shows the preview full-width (cms-platform#645) ────────
   * Rule 4 hides `.Pane2`, so Decap's eye ("Toggle preview") toggled a pane
   * that could never show. admin/mobile-preview-toggle.js turns the eye into
   * a switch between two full-width views and marks the preview view with
   * `cms-mobile-preview` on <html> (set only while Decap has the preview pane
   * mounted). Without the class nothing here applies and the form layout
   * above is unchanged. With it, the form pane steps aside and the preview
   * pane takes the full width, with the shim's "Back to editing" bar on top.
   * The pane gets a definite height so the preview iframe (height: 100%) has
   * something to fill; it is in normal flow (rule 3), so the page scrolls. */
  html.cms-mobile-preview .SplitPane > .Pane1 {
    display: none !important;
  }
  html.cms-mobile-preview .SplitPane > .Pane2 {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100svh !important;
  }
  html.cms-mobile-preview .SplitPane > .Pane2 > [class*="PreviewPaneContainer"] {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;
  }
  /* The eye sits at the top-right of the editor (Decap's ViewControls), so
   * the bar keeps its right edge clear and the two never overlap. */
  html.cms-mobile-preview #cms-mobile-preview-back {
    display: flex !important;
    align-items: center;
    padding: 0.5rem 4.5rem 0.5rem 1rem;
    min-height: 3.5rem;
    box-sizing: border-box;
    border-bottom: 1px solid #d0d7de;
    background: #fff;
  }
  #cms-mobile-preview-back button {
    font: inherit;
    font-size: 16px;
    padding: 0.5rem 0.9rem;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    background: #f6f8fa;
    color: #1f2328;
    cursor: pointer;
  }
}

/* The back bar exists only for the phone preview view above; at any other
 * width (or after rotating to landscape) it stays out of the desktop
 * side-by-side preview. */
#cms-mobile-preview-back {
  display: none;
}

/* ── Tablet and phone (<= 1100px): the Back link stays on one line ─────────
 * Decap's desktop toolbar is a single 66px row: Back link, buttons, host
 * link + avatar. Its Back link (`[arrow] [title block]`) never shrank below
 * its longest word, so at 820px (an iPad portrait) "Writing in <label>
 * collection" and the saved-state line wrapped to four lines, clipped at the
 * top of the bar, and a long collection label ("Accomplishments") pushed the
 * toolbar 20px wider than the viewport, cutting off the avatar (UX round 4,
 * triage package 7). The one-line ellipsis the phone block (#731) already
 * gives the title now applies up to 1100px, where the buttons and the host
 * link leave the Back link its natural width again. `overflow: hidden` lets
 * the title block shrink (a clipping flex item's automatic minimum size is
 * zero); the text stays in the DOM, so the link's accessible name is still
 * the full title. */
@media (max-width: 1100px) {
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionBackLink"] {
    /* Rule 5 lets every section wrap at <= 768px; the arrow must not drop
     * above the title at 320px. */
    flex-wrap: nowrap !important;
    min-width: 0;
  }
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionBackLink"] > :not([class*="BackArrow"]) {
    overflow: hidden;
  }
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="BackCollection"],
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="BackStatus"] {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* The local-mode "saves to your working copy" chip prepends itself to the
 * toolbar with `order: -1`; it is 260px wide and `white-space: nowrap`, so in
 * the single tablet row it left the Back link 41px and pushed the avatar 130px
 * off screen. Let it shrink and end in an ellipsis. Tablet only: the phone
 * block below wraps it onto its own row, and its id selector would beat that
 * block's `max-width`. The deploy pills are left alone: they carry a message
 * that should not be cut at 9rem. */
@media (min-width: 601px) and (max-width: 1100px) {
  [class*="EditorContainer"] > [class*="ToolbarContainer"] > #cms-local-save-indicator {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ── Phone only (<= 600px): a sticky, compact editor toolbar (#731) ───────
 * Rule 3 above puts the editor in normal flow, so the toolbar that holds
 * Save / Publish / Delete scrolled away: after writing a long body an editor
 * scrolled ~8 screens back up to publish, and the three stacked rows (back
 * link + status, buttons, hostname + avatar) took ~185px of the first
 * screen. Here the toolbar sticks to the top and keeps its native controls
 * on one row: back arrow, action buttons, and avatar. The hostname link is
 * dropped (the editor's "View page" box and URL hint already name the site).
 * The Back link keeps its full accessible name, while saved-status text
 * retains Decap's existing ARIA attributes in the DOM. Every control is a
 * 44px target. Shim chips (local-mode indicator, deploy pills) wrap to a line
 * of their own under the buttons instead of squeezing the controls.
 *
 * `position: sticky` needs no scrolling ancestor between the toolbar and the
 * viewport. `html, body { overflow-x: hidden }` (rule 1) makes <body> a
 * scroll container (an `overflow-x` other than visible turns `overflow-y`
 * into auto), which pins the toolbar to a body that never scrolls, and the
 * editor box carries `overflow: hidden` too. `overflow-x: clip` clamps the
 * same horizontal overflow without creating a scroll container; where it is
 * unsupported (Safari < 16) the whole block is skipped and the toolbar
 * scrolls away as before. The toolbar is matched as a DIRECT child of the
 * editor box so Decap's other `...Toolbar...` components are untouched.
 *
 * The toolbar's z-index sits above Decap's in-editor controls (their highest
 * is 600) and below the floating links (10000) and Decap's modals (99999).
 *
 * On production Publish lives in the sibling `#cms-publish-state` bar.
 * It sticks directly beneath the toolbar, using the height measured by
 * publish-step-hint.js so wrapping and deploy pills cannot overlap it. */
@media (max-width: 600px) {
  /* Keep the dismiss target clear of the sticky toolbar during toast bounces
   * and of bottom notices whose height can grow as their text wraps. */
  [class*="Toastify__toast-container"] {
    top: 50% !important;
    bottom: auto !important;
  }
  [class*="Toastify__toast-container"] [class*="Toastify__close-button"] {
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  /* ── Title on one line, and 44px touch targets (#731) ────────────────
   * The back link is `[arrow] [title block]`. The title block (an unnamed
   * <div>) is a flex item that never shrank below "Writing in Media Items
   * collection" and pushed the avatar's section over it (the divider line ran
   * through the text). The one-line ellipsis rules for it live in the
   * 1100px block above. Decap's buttons are
   * 36px tall; the back link 36px; lift them all to 44px. */
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionBackLink"] {
    box-sizing: border-box;
    min-height: 44px;
  }
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] button,
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarDropdown"],
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="PublishedToolbarButton"] {
    height: 44px !important;
    line-height: 44px !important;
  }
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMeta"],
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="SettingsWrapper"],
  [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="AvatarDropdownButton"] {
    box-sizing: border-box;
    height: 44px;
  }

  @supports (overflow: clip) {
    body {
      overflow-x: clip !important;
    }
    [class*="EditorContainer"] {
      overflow: visible !important;
    }
    /* Decap's own app header is `position: sticky`. With body no longer a
     * scroll container (above) it would pin to the top of every collection
     * list screen too (~100px of fixed chrome, 127px at 320px); on main it
     * scrolled away with the page. Keep that: the header only exists on the
     * list and login screens, the editor has none. */
    header[class*="AppHeader"] {
      position: static !important;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] {
      position: sticky !important;
      display: grid !important;
      grid-template-columns: 44px minmax(0, 1fr) 44px;
      top: 0;
      z-index: 1000;
      background: #fff;
      align-items: center;
      column-gap: 4px;
      row-gap: 0;
    }
    [class*="EditorContainer"] > #cms-publish-state {
      position: sticky;
      top: var(--cms-editor-toolbar-height);
      /* Keep native toolbar dropdowns above this later sibling. */
      z-index: 999;
      background: #fff;
    }
    /* Idle can still contain Publish controls. Its inline transparent tone
     * must not let scrolling fields show through; other state tones are opaque. */
    [class*="EditorContainer"] > #cms-publish-state[data-state="idle"] {
      background: #fff !important;
    }
    [class*="EditorContainer"] > #cms-publish-state button {
      min-height: 44px;
      min-width: 44px;
    }
    /* Native controls fit one row even at 320px. The back arrow retains the
     * collection name for assistive technology without spending visual space. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionBackLink"] {
      flex: 0 0 44px !important;
      grid-column: 1;
      width: 44px;
      padding: 0;
      justify-content: center !important;
      min-width: 0 !important;
      order: 0;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionBackLink"] > :not([class*="BackArrow"]) {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="BackArrow"] {
      margin: 0;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMeta"] {
      flex: 0 0 44px !important;
      grid-column: 3;
      width: 44px;
      padding: 0;
      border-left: 0;
      order: 2;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="SettingsWrapper"] {
      width: 44px;
      padding: 0;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="AvatarDropdownButton"] {
      width: 44px !important;
      padding: 6px !important;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="AvatarDropdownButton"] img {
      width: 32px;
      height: 32px;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] {
      grid-column: 2;
      flex: 0 1 auto !important;
      flex-wrap: nowrap !important;
      order: 1;
      /* Rule 5's 0.4rem gap, applied to the empty "View Live" sub-section
       * that wraps below the buttons, left a 6px strip under them. */
      row-gap: 0;
      column-gap: 0;
      padding: 0;
    }
    /* Keep the Save and Published labels readable while the Delete icon
     * leaves room for both controls on a 320px phone. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] [class*="ToolbarSubSection"] {
      flex: 0 0 auto !important;
      flex-wrap: nowrap !important;
      column-gap: 0.25rem;
    }
    /* After Save, the native preview action can share this row. Its
     * desktop margin otherwise shrinks the neighboring action section
     * until Delete and Check for Preview paint over each other. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] [class*="PreviewButtonContainer"] {
      margin-right: 0;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] [class*="PreviewButtonContainer"] > button > span {
      margin-right: 0;
    }
    /* one-door-publish.js hides this native Status control. Its now-empty
     * wrapper still occupied a flex gap beside Save and Delete. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarDropdown"]:has(> div > [class*="StatusButton"][data-one-door-hidden="1"]) {
      display: none;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] button {
      min-width: 44px !important;
      font-size: 12px !important;
      padding-left: 4px !important;
      padding-right: 4px !important;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] [role="button"] {
      min-width: 44px !important;
      height: 44px !important;
      line-height: 44px !important;
      font-size: 12px !important;
      padding-left: 4px !important;
      padding-right: 4px !important;
    }
    /* Decap's dropdown caret is 10px wide and sits 10px from the right.
     * Reserve its space plus a gap so it cannot paint over the label. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] [role="button"][aria-haspopup="true"] {
      padding-right: 24px !important;
    }
    /* Rehearsal workflow drafts also expose Status and Check for Preview.
     * Keep all of those controls reachable on extra rows. Production's
     * one-door shim marks its hidden Status control, so it keeps one row. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"]:has([class*="StatusButton"]:not([data-one-door-hidden="1"])) [class*="ToolbarSectionMain"] {
      grid-column: 1 / -1;
      order: 3;
      flex-wrap: wrap !important;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"]:has([class*="StatusButton"]:not([data-one-door-hidden="1"])) [class*="ToolbarSubSection"] {
      flex-wrap: wrap !important;
    }
    /* Keep Decap's full Delete label in its accessible name. The icon is an
     * empty pseudo-element, so it contributes no extra spoken text. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] button[class*="DeleteButton"] {
      font-size: 0 !important;
      width: 44px !important;
      min-width: 44px !important;
      max-width: 44px !important;
      flex: 0 0 44px !important;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarSectionMain"] button[class*="DeleteButton"]::after {
      content: "";
      display: inline-block;
      width: 18px;
      height: 18px;
      vertical-align: middle;
      background: currentColor;
      mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 3h8v2h5v2H3V5h5zm-3 6h14l-1 12H6zm4 2v8h2v-8zm4 0v8h2v-8z'/%3E%3C/svg%3E") center / contain no-repeat;
      -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 3h8v2h5v2H3V5h5zm-3 6h14l-1 12H6zm4 2v8h2v-8zm4 0v8h2v-8z'/%3E%3C/svg%3E") center / contain no-repeat;
    }
    /* Shim chips that prepend themselves to the toolbar with `order: -1`:
     * the local "saves to your working copy" indicator and the deploy
     * status pills. In the first row they took the title's width (the
     * title squeezed to 4-5 lines and the avatar overlapped it). They now
     * sit under the buttons, on their own line only while they exist (the
     * deploy pills are hidden until a publish is running or failed). */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] > :not([class*="ToolbarSection"]) {
      grid-column: 1 / -1;
      order: 3 !important;
      flex: 0 1 auto !important;
      box-sizing: border-box;
      max-width: calc(100% - 20px);
      margin: 0 0 6px 10px !important;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    /* The deploy pills are links: keep them a 44px touch target. `display`
     * is deliberately not !important: while a pill has nothing to say its
     * inline `display: none` must still win. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] > a:not([class*="ToolbarSection"]) {
      display: flex;
      align-items: center;
      min-height: 44px;
    }
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="AppHeaderSiteLink"] {
      display: none !important;
    }
    /* Decap's own button margins plus the 0.4rem gaps above would push
     * "Delete published entry" onto a third row. */
    [class*="EditorContainer"] > [class*="ToolbarContainer"] button,
    [class*="EditorContainer"] > [class*="ToolbarContainer"] [class*="ToolbarDropdown"] {
      margin: 0 !important;
    }
    /* index-local.html pins the commit / platform pills at top 60px / 91px,
     * right 12px (z-index 10000): over the stuck button row, covering the
     * right end of Delete. Stack them above the floating Live Preview link
     * instead (bottom-right, as index.html does; `:not([style*="bottom"])`
     * leaves the production shell's pills, which already set `bottom`,
     * alone). */
    #cms-platform-pill:not([style*="bottom"]) {
      top: auto !important;
      bottom: 4.25rem;
    }
    #cms-commit-pill:not([style*="bottom"]) {
      top: auto !important;
      bottom: 6rem;
    }
  }
}

/* ── Desktop: the publish-state bar must not make the editor scroll ───────
 * (cms-platform#640). Decap's EditorContainer is `height: 100%; overflow:
 * hidden; padding-top: 66px` (room for the absolute toolbar) and its Editor
 * child is `height: 100%` of what is left. publish-step-hint.js inserts the
 * in-flow #cms-publish-state bar between them, so the container's content is
 * toolbar clearance + bar + a full-height editor: ~46px taller than the box,
 * and any focus or find-in-page scroll slid the Save/Publish toolbar off the
 * top. Make the container a flex column so the bar keeps its own height and
 * the editor pane shrinks by exactly that much. The toolbar is absolute, so
 * it is not a flex item. Above the phone breakpoint only: below it the
 * container is static and auto-height (rule 3) and the page scrolls. */
@media (min-width: 769px) {
  [class*="EditorContainer"] {
    display: flex;
    flex-direction: column;
  }
  [class*="EditorContainer"] > :not(#cms-publish-state) {
    flex: 1 1 auto;
    min-height: 0;
    /* The Editor box is `margin: 0 auto`, which collapses a flex item to its
     * content width (0) in a column; keep the full-width block it had. */
    width: 100%;
  }
  [class*="EditorContainer"] > #cms-publish-state {
    flex: 0 0 auto;
  }
}

/* ── Tablet and phone (<= 1100px): taps pass through Decap's toasts ───────
 * (UX round 4 triage package 6: ad A4, jd F13). Decap raises its toasts
 * ("Oops, you've missed a required field", "Entry saved") in a react-toastify
 * container at `top-right`, fixed to the viewport. Since #766 pinned the
 * editor toolbar to the top of a phone, that container sits exactly on
 * Publish and the avatar: on a 390px phone it is the full width and 64px tall
 * for the 8 s a toast stays up, so the retry tap after a failed Publish hit
 * the toast and did nothing. A toast never needs a tap (it closes itself, and
 * its text is for reading), so the container lets pointer events fall through
 * to whatever is under it.
 *
 * Checked against the shipped decap-cms 3.15.1 bundle (react-toastify):
 * no node sets `pointer-events`. The container is `position: fixed` with the
 * default `auto`, and the toast, its body and the close button inherit it, so
 * `none` on the container alone silences the whole subtree. The close button
 * is switched back to `auto` so a toast can still be dismissed by hand; it is
 * a corner of the toast (44px on phones), not the toolbar-wide strip it replaces. The
 * toast's own click-to-close and swipe-to-dismiss no longer fire (they need
 * the pointer); the close button and the 8 s timer remain.
 *
 * Selectors are react-toastify's own class names (not Emotion hashes), as
 * substring matches like the rest of this file, so a renamed class degrades
 * to Decap's default (toast catches taps), never worse than before.
 * validation-feedback.js reads these nodes with querySelector and closes a
 * stale toast with a script `.click()`; neither goes through hit-testing, so
 * this rule does not affect it.
 *
 * Why 1100px: the default container overlaps the avatar and Publish at 820
 * and 1100px. Phones <= 600px move it halfway down the viewport,
 * so the close target also clears the sticky toolbar. Desktop above 1100px is left
 * unchanged. */
@media (max-width: 1100px) {
  [class*="Toastify__toast-container"] {
    pointer-events: none;
  }
  [class*="Toastify__toast-container"] [class*="Toastify__close-button"] {
    pointer-events: auto;
  }
}
