/* Semantic colors follow the system appearance; poems keep a solid reading surface. */
/* Transparent thumbs keep the gutter stable; hovering the thumb still allows dragging. */
@media screen and (forced-colors: none) {
  .auto-hide-scrollbars::-webkit-scrollbar,
  .auto-hide-scrollbars *::-webkit-scrollbar {width:10px;height:10px}
  .auto-hide-scrollbars::-webkit-scrollbar-track,
  .auto-hide-scrollbars *::-webkit-scrollbar-track,
  .auto-hide-scrollbars::-webkit-scrollbar-corner,
  .auto-hide-scrollbars *::-webkit-scrollbar-corner {background:transparent}
  .auto-hide-scrollbars::-webkit-scrollbar-thumb,
  .auto-hide-scrollbars *::-webkit-scrollbar-thumb {background:transparent;border:2px solid transparent;background-clip:padding-box;border-radius:10px}
  .auto-hide-scrollbars.scrollbar-active::-webkit-scrollbar-thumb,
  .auto-hide-scrollbars .scrollbar-active::-webkit-scrollbar-thumb,
  .auto-hide-scrollbars::-webkit-scrollbar-thumb:hover,
  .auto-hide-scrollbars *::-webkit-scrollbar-thumb:hover,
  .auto-hide-scrollbars::-webkit-scrollbar-thumb:active,
  .auto-hide-scrollbars *::-webkit-scrollbar-thumb:active {background-color:var(--muted)}
  .auto-hide-scrollbars::-webkit-scrollbar-button,
  .auto-hide-scrollbars *::-webkit-scrollbar-button {display:none}
  .auto-hide-scrollbars #c-tabs {scrollbar-width:auto}
}
:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --poem-ink: #424249;
  --muted: #626269;
  --surface: #fff;
  --silver: #f5f5f7;
  --inset: #f7f7f9;
  --control: #ededf0;
  --selected: #e3e3e8;
  --hover: #ebebef;
  --line: #dcdce1;
  --control-border: #8b8b93;
  --blue: #0066cc;
  --button-fill: #0066cc;
  --pale: #eaf2ff;
  --removed-bg: #fbe7e7;
  --removed-ink: #963333;
  --positive-bg: #edf5ef;
  --positive-ink: #35613f;
  --warning-bg: #fff5df;
  --warning-ink: #734d13;
  --toolbar: rgba(255,255,255,.94);
  /* SVG images cannot read CSS variables, so each surface tone has its own chevron. */
  --chevron-on-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%231d1d1f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --chevron-on-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23f5f5f7' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --select-chevron: var(--chevron-on-light);
  --mark-mine: #dcefeb;
  --mark-peer: #faf0cf;
}
@media screen and (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --select-chevron: var(--chevron-on-dark);
    --mark-mine: #1f4a44;
    --mark-peer: #574817;
    --ink: #f5f5f7;
    --poem-ink: #e6e6eb;
    --muted: #b8b8c0;
    --surface: #242426;
    --silver: #19191b;
    --inset: #2a2a2d;
    --control: #37373b;
    --selected: #434349;
    --hover: #343438;
    --line: #48484d;
    --control-border: #82828a;
    --blue: #8fc1ff;
    --button-fill: #005bbd;
    --pale: #253b55;
    --removed-bg: #482b30;
    --removed-ink: #ffc1c1;
    --positive-bg: #243b2c;
    --positive-ink: #aedcba;
    --warning-bg: #443719;
    --warning-ink: #f5d88f;
    --toolbar: rgba(36,36,38,.96);
  }
  .revision-bubble {background:var(--surface);border-color:var(--line);box-shadow:0 12px 35px #0005}
  .paper-back {background:var(--control);border-color:var(--line)}
  .hero-paper,.mini-page {border-color:var(--line)}
  dialog::backdrop {background:#0008}
}
@media screen and (prefers-contrast: more) {
  :root {
    --ink:#000;--poem-ink:#000;--muted:#35353a;
    --line:#6d6d73;--control-border:#48484d;
    --blue:#004c9b;--button-fill:#004c9b;--toolbar:#fff;
  }
  .header {backdrop-filter:none}
  button:disabled {opacity:1;border:1px dashed var(--control-border);color:var(--muted);background:var(--control)}
  .compare-columns mark {outline:1px solid var(--blue)}
  .compare-columns del {outline:1px solid var(--removed-ink)}
}
@media screen and (prefers-color-scheme: dark) and (prefers-contrast: more) {
  :root {
    --ink:#fff;--poem-ink:#fff;--muted:#e5e5ea;
    --line:#a0a0a8;--control-border:#d1d1d6;
    --blue:#c2deff;--button-fill:#004c9b;--toolbar:#242426;
  }
}
input,textarea,select {color:var(--ink)}
input:not([type=checkbox]):not([type=range]),textarea,select {background-color:var(--surface)}
/* Chromium pins the native arrow about 3px from the border and ignores padding, so every
   select draws its own. !important outranks per-control padding and background shorthands.
   Forced colors keep the native arrow, which follows the user's palette. */
@media screen and (forced-colors:none) {
  select {
    appearance:none;
    min-height:32px; /* The native control enforced this; narrower rules still set their own. */
    padding-right:26px!important;
    background-image:var(--select-chevron)!important;
    background-repeat:no-repeat!important;
    background-position:right 10px center!important;
    background-size:10px 6px!important;
  }
}
.poem-input,.title-input,.search-field input {background:transparent!important}
input::placeholder,textarea::placeholder {color:var(--muted);opacity:1}
.title-input::placeholder,.poem-input::placeholder,.revision-panel textarea::placeholder {color:var(--muted)}
.editor-state,.manuscript-meta,.manuscript-bottom,.panel-tabs button,.panel-description,
.panel-footnote,.feedback-card p {color:var(--muted);font-size:12px}
.panel-tabs button {font-size:13px}
.panel-tabs button[aria-selected=true] {color:var(--blue)}
.count-convention,.analysis-hint,.word-chip span {font-size:12px}
.editor-toolbar .editor-state {font-size:12px;min-width:max-content}
.editor-toolbar {flex-wrap:wrap;height:auto;min-height:74px;padding-block:14px;row-gap:10px}
.editor-actions {flex-wrap:wrap}
.icon-text,.small {font-size:13px}
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,
summary:focus-visible,[tabindex="0"]:focus-visible {outline:3px solid var(--blue);outline-offset:3px}
.title-input:focus-visible,.poem-input:focus-visible {box-shadow:-3px 0 var(--blue);outline:none}
dialog {background:var(--surface);max-height:calc(100dvh - 32px);overflow:auto}
.close-button {min-width:32px;min-height:32px}
.search-field:focus-within {outline:3px solid var(--blue);outline-offset:3px}
/* Pointer focus keeps selection/caret behavior without keyboard navigation rings. */
:root[data-focus-input=pointer] :focus,
:root[data-focus-input=pointer] .search-field:focus-within {outline:none}
:root[data-focus-input=pointer] .title-input:focus,
:root[data-focus-input=pointer] .poem-input:focus {box-shadow:none}
#document-preview-content p {color:#1d1d1f}
#document-preview-content {color-scheme:light}

/* Comparison uses one scrolling manuscript region, with short persistent controls. */
.compare-dialog {width:1120px;max-width:calc(100vw - 32px);padding:20px}
.compare-dialog[open] {height:min(820px,calc(100dvh - 32px));max-height:calc(100dvh - 32px);overflow:hidden;gap:0}
.compare-dialog .dialog-heading h2 {font-size:22px;margin:0}
.compare-description {margin:4px 0 12px;font-size:12px;line-height:1.5}
.compare-pickers {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px;flex-shrink:0}
.compare-pickers>div {min-width:0}
.compare-pickers label {margin:0 0 5px;font-size:12px}
.compare-pickers .revision-select {margin:0;min-height:34px;padding:6px 8px;font-size:13px}
.compare-summary {font-size:12px;line-height:1.5;margin:10px 0}
.compare-dialog .compare-columns {flex:1;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px;min-height:60px;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;border-block:1px solid var(--line);padding:16px 0}
.compare-columns>section {min-width:0}
.compare-columns>section+section {border-left:1px solid var(--line);padding-left:24px}
.compare-columns h3 {font-size:19px;line-height:1.5;margin:0 0 4px;overflow-wrap:anywhere}
.compare-stats {font-size:12px;line-height:1.5;margin:0 0 18px}
.compare-dialog .compare-columns pre {font:16px/1.95 var(--serif);color:var(--poem-ink);max-height:none;min-height:0;overflow:visible;margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
.compare-context {flex-shrink:0;font-size:12px;margin-top:10px;max-height:25dvh;overflow:auto}
.compare-context summary {cursor:pointer;color:var(--muted);line-height:1.6}
.compare-context>div {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:24px;padding-top:8px}
.compare-context h3 {font-size:12px;margin:0 0 4px}
.compare-context .revision-reason {font-size:12px;margin:0}
.compare-footer {margin-top:12px;gap:10px;flex-wrap:wrap;align-items:center}
.compare-footer p {font-size:12px;line-height:1.5}
.compare-actions {display:flex;gap:8px;margin-left:auto;flex-wrap:wrap}
.compare-actions .button {min-height:34px;font-size:12px;padding:7px 12px}
.compare-columns del {color:var(--removed-ink);background:var(--removed-bg)}
.compare-columns mark {color:var(--blue);background:var(--pale)}
@media (max-width:850px),(max-height:650px) {
  .compare-dialog {padding:16px}
  .compare-footer p {display:none}
  .compare-columns h3 {font-size:17px}
  .compare-stats {margin-bottom:12px}
  .compare-dialog .compare-columns {padding-block:12px}
}
@media (max-width:600px) {
  .compare-dialog {padding:12px;max-width:calc(100vw - 16px)}
  .compare-dialog[open] {height:calc(100dvh - 16px);max-height:calc(100dvh - 16px)}
  .compare-pickers,.compare-dialog .compare-columns {gap:12px}
  .compare-columns>section+section {padding-left:12px}
  .compare-actions {gap:6px}
  .compare-actions .button {padding-inline:9px;white-space:normal}
}
@media print {
  :root {color-scheme:light;--ink:#000;--poem-ink:#000;--muted:#333;--surface:#fff}
}

/* Keep a dialog's actions available while its fields and file list scroll. */
#work-info-dialog.scroll-dialog,.vault-links-dialog.scroll-dialog {
  padding:0;max-height:calc(100dvh - 32px);overflow:hidden;
}
.scroll-dialog[open],.scroll-dialog-form {
  display:flex;flex-direction:column;min-height:0;
}
.scroll-dialog-form {margin:0;overflow:hidden;max-height:inherit}
.scroll-dialog .dialog-heading {
  flex-shrink:0;padding:24px 24px 16px;
}
.scroll-dialog .dialog-heading h2 {margin:0;font-size:23px}
.scroll-dialog .dialog-scroll-body {
  flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;
  scrollbar-gutter:stable;padding:0 24px 20px;scroll-padding-block:12px;
}
#work-info-dialog .dialog-scroll-body>p {margin:0 0 24px;font-size:13px}
.scroll-dialog .dialog-actions {
  flex-shrink:0;margin:0;padding:16px 24px;border-top:1px solid var(--line);
  background:var(--surface);gap:10px;
}
.scroll-dialog .vault-results {max-height:none;overflow:visible}
.scroll-dialog .dialog-actions .icon-text {white-space:normal}
@media (max-width:520px),(max-height:500px) {
  #work-info-dialog.scroll-dialog,.vault-links-dialog.scroll-dialog {max-height:calc(100dvh - 16px)}
  .scroll-dialog .dialog-heading {padding:14px 16px 12px;gap:12px}
  .scroll-dialog .dialog-heading h2 {font-size:21px}
  .scroll-dialog .dialog-scroll-body {padding:0 16px 16px}
  .scroll-dialog .dialog-actions {padding:10px 16px;gap:8px}
  .scroll-dialog .dialog-actions .button {padding-inline:14px}
}
@media (max-width:520px) {
  .scroll-dialog .info-fields {grid-template-columns:minmax(0,1fr)}
}
