@layer surfaces {

/* ============================================================================
   Bottom dock (editor-v3 slice 4): supplemental documents quick-view over the
   manuscript. position:fixed but every edge is MEASURED by ui/editor_dock against
   the real chrome rects (nav rail / project drawer / lens rail / top bar / status
   bar) — inline left/right/bottom/height, so banners and wrapped bars can't start
   z-order fights. z 22: over content and the sticky status bar (20), under the
   sticky top bar (25).
   ========================================================================= */
.editor-dock {
  position: fixed;
  display: flex;
  flex-direction: column;
  background: var(--c-white);
  border-top: 1px solid var(--c-gray-200);
  box-shadow: 0 -10px 30px var(--c-shadow);
  z-index: 22;
}

.editor-dock-resize {
  flex: none;
  height: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: row-resize;
  touch-action: none;
  background: var(--c-gray-25);
}

.editor-surface[data-dock="full"] .editor-dock-resize {
  cursor: default;
}

.editor-dock-resize span {
  width: 34px;
  height: 3px;
  border-radius: 2px;
  background: var(--c-gray-300);
}

.editor-dock-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--c-gray-200);
}

.editor-dock-kind {
  flex: none;
  font-size: 0.59375rem;
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--c-gray-600);
}

.editor-dock-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--c-gray-900);
}

.editor-dock-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: none;
}

.editor-dock-open {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-gray-600);
  text-decoration: none;
  border: 1px solid var(--c-gray-300);
  border-radius: 7px;
  padding: 0.25rem 0.5rem;
}

.editor-dock-open:hover {
  color: var(--c-gray-900);
  border-color: var(--c-gray-400);
}

.editor-dock-modes {
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--c-gray-200);
  border-radius: 8px;
  padding: 2px;
}

.editor-dock-mode,
.editor-dock-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.625rem;
  height: 1.625rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--c-gray-400);
  cursor: pointer;
}

.editor-dock-mode:hover,
.editor-dock-close:hover {
  color: var(--c-gray-700);
  background: var(--c-gray-100);
}

.editor-dock-mode[aria-pressed="true"] {
  color: var(--c-gray-900);
  background: var(--c-gray-200);
}

.editor-dock-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.5rem 1.75rem;
}

.editor-dock-body h2,
.editor-dock-body h3 {
  margin: 1rem 0 0.5rem;
  color: var(--c-gray-900);
}

.editor-dock-body h2 { font-size: 1.125rem; }
.editor-dock-body h3 { font-size: 0.9375rem; }

.editor-dock-body p {
  margin: 0 0 0.75rem;
  max-width: var(--prose-w);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--c-gray-800);
}

.editor-dock-empty {
  color: var(--c-gray-500);
}

/* Explore tenant: header tabs + the reference-shelf card (ui/editor_explore). */
.editor-dock-tabs {
  display: inline-flex;
  gap: 2px;
  border: 1px solid var(--c-gray-200);
  border-radius: 8px;
  padding: 2px;
  flex: none;
}

.editor-dock-tab {
  border: 0;
  border-radius: 6px;
  background: none;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--c-gray-600);
  cursor: pointer;
}

.editor-dock-tab:hover {
  color: var(--c-gray-900);
  background: var(--c-gray-100);
}

.editor-dock-tab[aria-pressed="true"] {
  color: var(--c-white);
  background: var(--c-ink);
}

.editor-explore-note {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--c-gray-500);
}

/* The in-context strip: the sense-anchored closest fits, above whichever tab is active. */
.editor-explore-strip {
  max-width: var(--prose-w);
  margin-bottom: 1rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--c-gray-200);
}

.editor-explore-group--context .editor-explore-group-label {
  color: var(--c-accent);
}

/* Meter lens: one dot per syllable — primary stress large/ink, secondary mid, unstressed small/faint. */
.editor-explore-meter-beats {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
  min-height: 1rem;
}

.editor-explore-meter-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--c-gray-400);
}

.editor-explore-meter-dot[data-stress="1"] {
  width: 0.8125rem;
  height: 0.8125rem;
  background: var(--c-ink);
}

.editor-explore-meter-dot[data-stress="2"] {
  width: 0.625rem;
  height: 0.625rem;
  background: var(--c-gray-600);
}

.editor-explore-sense,
.editor-explore-classic {
  max-width: var(--prose-w);
  margin-bottom: 1.125rem;
}

.editor-explore-sense-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.editor-explore-sense-number {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--c-gray-500);
}

.editor-explore-sense-pos,
.editor-explore-classic-head {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--c-gray-600);
}

.editor-explore-classic-head {
  margin-bottom: 0.375rem;
}

.editor-explore-definition {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--c-gray-800);
}

.editor-explore-example {
  margin: 0 0 0.375rem;
  font-size: 0.875rem;
  font-style: italic;
  color: var(--c-gray-500);
}

.editor-explore-etymology {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--c-gray-500);
}

.editor-explore-group {
  max-width: var(--prose-w);
  margin-bottom: 1rem;
}

.editor-explore-group-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--ls-kicker);
  text-transform: uppercase;
  color: var(--c-gray-600);
  margin-bottom: 0.5rem;
}

.editor-explore-group--muted .editor-explore-group-label {
  color: var(--c-gray-500);
}

.editor-explore-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.editor-explore-chip {
  border: 1px solid var(--c-gray-300);
  border-radius: 7px;
  background: var(--c-gray-25);
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--c-gray-800);
  cursor: pointer;
}

.editor-explore-chip:hover {
  border-color: var(--c-gray-400);
  color: var(--c-gray-900);
}

.editor-explore-group--muted .editor-explore-chip {
  background: none;
  border-style: dashed;
  color: var(--c-gray-600);
}

/* Candidate chips (rhyme slates): the word explores, the "use" tail replaces the
   explored word in the lyric — the feedback loop's accept gesture. */
.editor-explore-chip--candidate {
  display: inline-flex;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.editor-explore-chip-word,
.editor-explore-chip-use {
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  padding: 0.25rem 0.625rem;
  color: var(--c-gray-800);
}

.editor-explore-chip-word:hover {
  color: var(--c-gray-900);
  background: var(--c-gray-100);
}

.editor-explore-chip-use {
  border-left: 1px solid var(--c-gray-200);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--c-gray-600);
}

.editor-explore-chip-use:hover {
  color: var(--c-white);
  background: var(--c-ink);
}

/* The workspace scrolls clear of the open dock (ui/editor_dock sets --dock-pad). */
.editor-surface[data-dock="bottom"] .editor-workspace,
.editor-surface[data-dock="full"] .editor-workspace {
  padding-bottom: var(--dock-pad, 21rem);
}

/* Side mode (2026-07-23): the dock is a right-hand column on wide screens — the wing
   carrying content. The page re-centers the workspace cluster in what remains
   (ui/editor_dock sets --dock-side-pad from measured width). */
.editor-surface[data-dock="side"] .editor-dock {
  flex-direction: row;
  border-top: 0;
  border-left: 1px solid var(--c-gray-200);
  box-shadow: -10px 0 30px var(--c-shadow);
}

.editor-surface[data-dock="side"] .editor-dock > .editor-dock-resize {
  height: auto;
  width: 9px;
  cursor: col-resize;
}

.editor-surface[data-dock="side"] .editor-dock > .editor-dock-resize span {
  width: 3px;
  height: 34px;
}

/* The header + body stack inside the remaining column (every mode: the wrapper is the
   dock's one flex child besides the handle, so bottom mode lays out exactly as before). */
.editor-dock-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 1800px) {
  .editor-page--frame:has(.editor-surface[data-dock="side"]:not([data-focus="true"])) {
    padding-right: var(--dock-side-pad, 27.5rem);
  }
}

/* The side toggle only exists where the wing does. */
.editor-dock-mode-side {
  display: none;
}

@media (min-width: 1800px) {
  .editor-dock-mode-side {
    display: inline-flex;
  }
}

/* The editable pane: the note-card primitive at document size. The book face at a
   slightly smaller optical size than the manuscript — it is a working note, not the
   draft — on a plain textarea that owns its own caret. */
.editor-dock-editor {
  flex: 1;
  width: 100%;
  min-height: 100%;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--c-ink);
  font-family: var(--font-prose);
  font-optical-sizing: auto;
  font-size: 1.0625rem;
  line-height: 1.65;
  padding: 1.25rem 1.5rem;
}

.editor-dock-editor:focus {
  outline: none;
}

.editor-dock-editor::placeholder {
  color: var(--c-gray-400);
}

.editor-surface[data-view-mode="board"] .editor-dock,
.editor-surface[data-focus="true"] .editor-dock {
  display: none;
}

@media (max-width: 1024px) {
  .editor-navrail {
    display: none;
  }

  .editor-page--frame {
    padding-left: 0;
    padding-right: 0;
  }

  /* No fixed rails on small screens: the lens rail becomes a static toolbar between the
     workspace and the drawer content, and the drawer flows statically like every other
     side surface. Must live AFTER the base rules — same specificity, source order wins. */
  .editor-lens-rail {
    position: static;
    width: auto;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.5rem 1rem;
    border-left: 0;
    border-top: 1px solid var(--c-gray-200);
  }

  .editor-lens-divider {
    width: 1px;
    height: 1.5rem;
    margin: 0 0.25rem;
  }

  .editor-lens-drawer {
    position: static;
    max-height: none;
    border-left: 0;
    padding: 0.5rem 1rem 1rem;
  }

  .editor-lens-drawer-close {
    display: none;
  }

  .editor-surface[data-panels-collapsed="true"] .editor-lens-rail,
  .editor-surface[data-panels-collapsed="true"] .editor-lens-drawer {
    display: none;
  }

  /* No fixed columns on small screens: the drawer flows below the workspace (its DOM
     position) and the panels toggle governs it along with the other side columns. Must
     live AFTER the base .editor-drawer rules — same specificity, so source order decides. */
  .editor-drawer {
    position: static;
    width: auto;
    border-right: 0;
    border-top: 1px solid var(--c-gray-200);
  }

  .editor-drawer-collapse {
    display: none;
  }
}

/* The find bar pins below the sticky top bar (viewport-anchored) so jumping between
   matches never scrolls it under the chrome. */
.editor-page--frame .editor-find-bar {
  position: fixed;
  top: calc(var(--topbar-h, 3.25rem) + 0.75rem);
  right: 1.5rem;
  z-index: 26;
}

}
