/* Same semantic palette and manuscript typography; compact tools around the poem. */
@media screen {
  body:has(#editor-view:not([hidden])) > .header {height:52px;position:relative;backdrop-filter:none;background:var(--surface)}
  body:has(#editor-view:not([hidden])) > .header .nav {height:52px;min-height:0}
  body:has(#editor-view:not([hidden])) > .header .brand {font-size:18px}
  body:has(#editor-view:not([hidden])) > .header .button {padding-block:6px;min-height:32px}
  .editor-command-bar {position:sticky;top:0;z-index:30;background:var(--surface);border-bottom:1px solid var(--line);margin-bottom:16px}
  .editor-command-bar .editor-toolbar {height:auto;min-height:48px;padding-block:8px;gap:16px;flex-wrap:wrap}
  .editor-command-bar .editor-state {display:flex;color:var(--muted);flex-shrink:0}
  .editor-command-bar .editor-actions {gap:16px}
  .editor-command-bar .file-location {margin-top:0;margin-bottom:0;padding-bottom:8px;align-items:center;gap:12px;min-height:30px}
  .editor-command-bar .file-location button {padding:4px 0;min-height:28px}
  .editor-command-bar .selection-tools {margin:0 auto;padding-block:5px 9px;min-height:34px;gap:12px}
  .editor-command-bar .selection-tools:has(#selection-note:disabled) {display:none}
  .editor-command-bar .selection-tools button {min-height:28px;color:var(--blue)}
  .editor-command-bar .selection-tools .panel-description {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:55%}
  .editor-layout .manuscript {padding-top:24px;box-shadow:none}
  .editor-layout .manuscript-meta {margin-bottom:20px}
  .editor-layout .title-input {margin-bottom:20px}
  .revision-panel {position:sticky;top:calc(var(--editor-command-height, 88px) + 12px);max-height:calc(100dvh - var(--editor-command-height, 88px) - 76px);overflow:auto;scroll-padding-block:48px 16px;overscroll-behavior:contain;scrollbar-gutter:stable;padding-bottom:16px}
  .revision-panel .panel-tabs {position:sticky;top:0;background:var(--surface);z-index:3;margin-bottom:14px}
  .revision-panel .panel-tabs button {padding-block:12px 10px;min-height:40px}
  .revision-panel h2 {font-size:16px;margin:0}
  .revision-panel .panel-description {margin-top:6px;line-height:1.6}
  .revision-panel .field-label {margin-top:10px;font-size:13px}
  .revision-panel textarea {margin-top:6px;padding:8px 10px;font-size:13px;line-height:1.6;border-radius:6px}
  .annotation-section {margin-top:14px;padding-top:12px}
  #panel-notes:has(#annotation-editor:not([hidden])) > h2,
  #panel-notes:has(#annotation-editor:not([hidden])) > .panel-description {display:none}
  #panel-notes:has(#annotation-editor:not([hidden])) .annotation-section {border-top:0;margin-top:0;padding-top:0}
  .annotation-catalog {margin:8px 0}
  .annotation-catalog > summary {font-size:12px;color:var(--muted);cursor:pointer;line-height:1.6;padding-block:4px}
  .annotation-toolbar {margin:6px 0}
  #panel-notes:has(#annotation-editor:not([hidden])) .annotation-section > .subsection-heading {display:none}
  .annotation-source {padding-left:10px;margin:8px 0;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:4px 8px}
  .annotation-source blockquote {order:1;flex-basis:100%;font-size:14px;line-height:1.6;margin:2px 0;max-height:68px;overflow:auto}
  .annotation-source .icon-text {min-height:26px}
  .annotation-section textarea {min-height:64px!important;height:64px}
  .annotation-actions {position:sticky;bottom:-16px;background:var(--surface);padding-block:8px;margin:6px 0;gap:12px;z-index:2}
  .annotation-actions button {min-height:32px}
  #annotation-status {font-size:12px;margin-top:4px}
  #panel-notes > h2, #panel-notes > .panel-description {display:none}
  .general-notes {margin-top:14px;padding-top:8px}
  .fragment-toolbar {margin-top:8px}
  .fragments-section {margin-top:14px;padding-top:12px}
  .fragment-composer {border-top:1px solid var(--line);margin-top:12px;padding-top:8px}
  .fragment-composer summary {font-size:13px;line-height:1.6;cursor:pointer;padding-block:6px}
  .fragment-composer #fragment-draft {min-height:72px}
  .fragment-composer #add-fragment {margin-top:8px}
  .new-edition {margin:12px 0;padding-block:8px}
  .new-edition[open] summary {margin-bottom:6px}
  .new-edition .field-label {margin-top:8px}
  .new-edition #revision-name {margin-top:6px;min-height:36px;padding:8px 10px}
  .new-edition #revision-reason {min-height:64px;height:64px}
  .new-edition #save-revision-reason {display:block;width:100%;min-height:34px;margin-top:12px}
  .revision-storage-hint {font-size:12px;line-height:1.6}
  #preview-candidate-actions {position:sticky;top:calc(var(--editor-command-height, 88px) + 8px);background:var(--surface);z-index:4;padding-block:8px;border-bottom:1px solid var(--line);margin:8px 0 16px}
  .revision-preview {scroll-margin-top:calc(var(--editor-command-height, 88px) + 16px)}
  body:has(#editor-view:not([hidden])) {scroll-padding-top:calc(var(--editor-command-height, 88px) + 16px)}
  html:has(#editor-view:not([hidden])) {scroll-padding-top:calc(var(--editor-command-height, 88px) + 16px)}
  body.reading .editor-command-bar .editor-state {display:flex}
  body.reading .editor-command-bar .selection-tools {display:none}
}
@media screen and (max-width:900px) {
  .editor-command-bar .editor-toolbar {gap:10px}
  .editor-command-bar .editor-actions {gap:12px}
  .editor-command-bar .file-location {gap:8px;font-size:12px}
  .editor-command-bar .file-location #folder-location {max-width:48%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .editor-command-bar .file-location span {margin-left:auto;text-align:right;max-width:56%}
  .revision-panel {padding-inline:14px}
}
@media screen and (max-width:700px) {
  .editor-command-bar .editor-actions {flex-basis:100%;justify-content:space-between;gap:8px}
  .editor-command-bar .file-location {flex-wrap:wrap}
  .editor-command-bar .file-location #folder-location {max-width:100%}
  .editor-command-bar .file-location span {max-width:100%;text-align:left;margin-left:0}
  .revision-panel {position:static;max-height:none}
  .editor-command-bar .selection-tools .panel-description {max-width:100%}
}
/* Zoomed and very short windows keep all controls in normal flow, never over the entire canvas. */
@media screen and (max-height:440px) {
  .editor-command-bar,.revision-panel,#preview-candidate-actions,.annotation-actions,.revision-panel .panel-tabs {position:static;max-height:none}
}
@media print {.editor-command-bar {display:none!important}.revision-panel {display:none!important}}

/* Keep the connected file and separate copy readable as two distinct results. */
@media screen {
  .editor-command-bar .file-save-statuses {display:grid;gap:3px;min-width:0;max-width:60%;margin-left:auto;text-align:right}
  .editor-command-bar .file-location .file-save-statuses span {max-width:none;width:auto;margin:0;text-align:inherit}
}
@media screen and (max-width:700px) {
  .editor-command-bar .file-save-statuses {max-width:100%;width:100%;margin-left:0;text-align:left}
}
/* Native content sizing keeps the document height stable while typing. */
#poem-body {field-sizing:content;height:auto}

/* The field stays on top so typing, selection, and IME never touch the mirror. */
.manuscript-field {position:relative;isolation:isolate}
.manuscript-field #poem-body {position:relative;z-index:1}
.manuscript-marks {position:absolute;inset:0;z-index:0;margin:0;border-style:solid;border-color:transparent;color:transparent;pointer-events:none;user-select:none;overflow:hidden}
.manuscript-mark {color:transparent;background:var(--mark-peer);border-radius:3px}
.manuscript-mark.mine {background:var(--mark-mine)}
.manuscript-mark.active {box-shadow:0 2px 0 var(--blue)}
#poem-body[hidden] ~ .manuscript-marks,.reading .manuscript-marks {display:none}
@media (forced-colors:active) {
  .manuscript-mark {background:none;text-decoration:underline 2px CanvasText}
}
@media print {.manuscript-marks {display:none}}
