body.ln-writing-route {
    --lnws-bg: #f5f3eb;
    --lnws-paper: #fffdf7;
    --lnws-ink: #19392e;
    --lnws-line: #d6ddcf;
    --lnws-muted: #58685e;
    background: var(--lnws-bg) !important;
    color: var(--lnws-ink) !important;
}
body.ln-writing-route:has(#literunico-superdoc-v7[data-writing-environment="dark"]) {
    --lnws-bg: #172a23;
    --lnws-paper: #21382e;
    --lnws-ink: #eef6e9;
    --lnws-line: #4b6254;
    --lnws-muted: #ccd9ca;
}
.ln-writing-route .ln-writing-shell-chrome { display: none !important; }
.ln-writing-route .ln-writing-shell { max-width: none !important; width: 100% !important; padding: 0 !important; margin: 0 !important; }
.ln-writing-route .ln-writing-context {
    position: sticky; top: 0; z-index: 40; padding: 4px 14px !important; margin: 0 !important;
    max-width: none !important; width: 100%; background: var(--lnws-paper); border-bottom: 1px solid var(--lnws-line);
}
.ln-writing-bar { display: grid; gap: 3px; }
.ln-writing-title-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ln-writing-book { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.ln-writing-back { font-size: 12px; color: var(--lnws-muted); white-space: nowrap; }
.ln-writing-context .aw-writing-heading { display: flex; align-items: center; gap: 10px; min-width: 0; margin: 0 !important; }
.ln-writing-context .aw-writing-heading h1 { margin: 0 !important; font-size: 21px !important; line-height: 1.2 !important; max-width: 39vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ln-writing-context .aw-private-label { font-size: 11px; white-space: nowrap; }
.ln-writing-context #aw-editor-status { margin: 0 !important; color: var(--lnws-muted); font-size: 11px; line-height: 1.4; max-width: 350px; }
.ln-writing-context #aw-editor-status[role="alert"] { background: #fff2d5; color: #6e3c00; padding: 7px; border-radius: 6px; }
.ln-writing-context #aw-conflict-options, .ln-writing-context #aw-tool-feedback { margin: 5px 0 0; font-size: 12px; }
.ln-writing-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.ln-writing-controls .aw-writing-toolbar { display: flex; align-items: center; gap: 5px; margin: 0 !important; }
.ln-writing-context button, .ln-writing-options > summary {
    min-height: 31px; border: 1px solid var(--lnws-line); border-radius: 6px; padding: 5px 10px;
    background: var(--lnws-paper); color: var(--lnws-ink); font: inherit; font-size: 12px; line-height: 1.2; cursor: pointer;
}
.ln-writing-context button[aria-expanded="true"] { background: #dce9d6; color: #19392e; }
.ln-writing-context #aw-save-now { background: #214b3b; color: #fff; border-color: #214b3b; }
.ln-writing-context button:focus-visible, .ln-writing-context summary:focus-visible, .ln-writing-panel button:focus-visible { outline: 3px solid #bb8b28; outline-offset: 2px; }
.ln-writing-context #aw-evidence-now { display: none; }
.ln-writing-options { position: relative; }
.ln-writing-options > summary { list-style: none; }
.ln-writing-options > summary::-webkit-details-marker { display: none; }
.ln-writing-options-body { position: absolute; inset-block-start: calc(100% + 8px); inset-inline-end: 0; width: min(400px, calc(100vw - 28px)); max-height: 66vh; overflow: auto; padding: 12px; background: var(--lnws-paper); border: 1px solid var(--lnws-line); border-radius: 9px; box-shadow: 0 12px 30px #0002; }
.ln-writing-options-body .aw-writing-actions { display: grid; gap: 8px; margin: 0; }
.ln-writing-options-body .aw-hint { font-size: 12px; }
.ln-writing-options-body .ln-writing-comfort { position: static; flex-wrap: wrap; padding: 0; border: 0; background: var(--lnws-paper); color: var(--lnws-ink); }
.ln-writing-options-body .ln-writing-comfort__status { width: 100%; font-size: 12px; }
.ln-writing-options-body .ln-writing-comfort select { color: var(--lnws-ink); background: var(--lnws-paper); }
.ln-writing-layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 10px; padding: 0 10px; }
.ln-writing-canvas { min-width: 0 !important; width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
/* Typewriter mode needs scroll space above the first line as well as below
   the last one. This belongs to the screen, never the manuscript margins. */
@media screen {
    .ln-writing-canvas .ln-writing-typewriter #v7-superdoc-editor { padding-top: 42vh !important; }
}
.ln-writing-panel { color: var(--lnws-ink); background: var(--lnws-paper); border: 1px solid var(--lnws-line); border-radius: 9px; padding: 12px; overflow: auto; max-height: calc(100dvh - var(--ln-writing-header-height, 96px) - 24px); overscroll-behavior: contain; z-index: 35; }
.ln-writing-panel[hidden] { display: none !important; }
.ln-writing-panel-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ln-writing-panel h2 { margin: 0; font-size: 15px; line-height: 1.3; }
.ln-writing-panel-close { font-size: 11px; padding: 5px 7px; border: 1px solid var(--lnws-line); border-radius: 5px; background: var(--lnws-paper); color: var(--lnws-ink); cursor: pointer; }
.ln-writing-panel-help { color: var(--lnws-muted); font-size: 12px; line-height: 1.5; margin: 10px 0 0; }
.ln-writing-panel .v7-superdoc-lab__outline { margin: 0; border: 0; padding: 0; }
.ln-writing-panel .v7-superdoc-lab__outline-item { color: var(--lnws-ink); background: var(--lnws-paper); border-color: var(--lnws-line); }
.ln-writing-panel .aw-project-menu { width: 100%; }
.ln-writing-panel .aw-project-menu > summary { display: none; }
.ln-writing-panel .aw-project-menu-content { position: static; width: auto; padding: 0; background: transparent; box-shadow: none; border: 0; color: inherit; }
.ln-writing-panel .aw-project-menu-content nav { display: grid; gap: 8px; }
.ln-writing-panel .aw-project-menu-content p { font-size: 13px; line-height: 1.5; }
#ln-writing-planning { position: fixed; right: 12px; top: calc(var(--ln-writing-header-height, 96px) + 10px); width: min(360px, calc(100vw - 24px)); box-shadow: 0 12px 36px #0003; }
@media (min-width: 1180px) {
    .ln-writing-layout[data-chapters-open="true"] { grid-template-columns: 204px minmax(0, 1fr); }
    #ln-writing-chapters { grid-column: 1; grid-row: 1; position: sticky; top: calc(var(--ln-writing-header-height, 96px) + 10px); }
    .ln-writing-canvas { grid-column: -2 / -1; grid-row: 1; }
}
@media (max-width: 1179px) {
    #ln-writing-chapters { position: fixed; left: 12px; top: calc(var(--ln-writing-header-height, 96px) + 10px); width: min(320px, calc(100vw - 24px)); box-shadow: 0 12px 36px #0003; }
}
@media (max-width: 640px) {
    /* Keep the original comments in the review tools without letting the
       library's 320px desktop sidebar squeeze the mobile writing surface. */
    .ln-writing-canvas #v7-superdoc-editor .superdoc__right-sidebar,
    .ln-writing-canvas #v7-superdoc-editor .floating-comments { display: none !important; }
    .ln-writing-canvas #v7-superdoc-editor .superdoc__layers { min-width: 0; width: 100% !important; flex: 1 1 auto; }
    .ln-writing-route .ln-writing-context { padding: 7px 9px !important; }
    .ln-writing-title-row { flex-wrap: wrap; gap: 5px 9px; }
    .ln-writing-book { width: calc(100% - 66px); flex: auto; }
    .ln-writing-back { font-size: 10px; }
    .ln-writing-context .aw-writing-heading h1 { font-size: 17px !important; max-width: 47vw; }
    .ln-writing-context .aw-private-label { display: none; }
    .ln-writing-context #aw-editor-status { order: 3; max-width: none; width: 100%; font-size: 10px; }
    .ln-writing-controls { gap: 5px; flex-wrap: nowrap; }
    .ln-writing-context button, .ln-writing-options > summary { font-size: 11px; padding: 5px 8px; }
    .ln-writing-controls .aw-writing-toolbar > [data-aw-command], .ln-writing-controls .aw-writing-toolbar > [data-aw-paste] { display: none; }
    .ln-writing-layout { padding: 0 4px; }
    .ln-writing-options-body { position: fixed; top: calc(var(--ln-writing-header-height, 120px) + 8px); right: 10px; }
}
@media print {
    .ln-writing-context, .ln-writing-panel { display: none !important; }
    .ln-writing-layout { display: block !important; padding: 0 !important; }
}
