/* Scoped additions: keep the existing site's stylesheet in place. */
.chapter-main { width: min(1600px, 96%); max-width: 1600px; margin: auto; }
.chapter-layout { display: grid; grid-template-columns: minmax(320px, 30%) minmax(0, 1fr); gap: 20px; align-items: start; }
.chapter-sidebar { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.chapter-sidebar ul { padding-left: 20px; }
.chapter-sidebar li { margin: 12px 0; }
.chapter-sidebar small { display: block; opacity: .75; }
.chapter-toolbar, .chapter-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chapter-toolbar button, .outline-link, #recovery-notice button { border: 1px solid #82674e; border-radius: 5px; padding: 8px 12px; background: #201914; color: #f6ead6; cursor: pointer; }
.chapter-toolbar label { display: flex; align-items: center; gap: 6px; }
.chapter-toolbar select { padding: 6px; }
.chapter-paper { min-height: 560px; padding: clamp(20px, 4vw, 55px); background: #f7f0e3; color: #27201a; border: 1px solid #b99a75; border-radius: 6px; font: 19px/1.8 Georgia, serif; overflow-wrap: anywhere; white-space: pre-wrap; }
.chapter-paper p { margin: 0 0 1em; }
.chapter-paper h2, .chapter-paper h3, .chapter-paper h4 { color: #593b28; margin: 1em 0 .5em; line-height: 1.3; }
.chapter-paper ul, .chapter-paper ol { padding-left: 28px; }
.chapter-paper blockquote { border-left: 3px solid #ac784a; padding-left: 20px; margin: 15px 0; }
.chapter-paper:focus { outline: 3px solid #d78d34; outline-offset: 3px; }
.outline-link { display: block; width: 100%; text-align: left; margin: 8px 0; }
.chapter-main textarea, .chapter-main input:not([type=hidden]) { width: 100%; box-sizing: border-box; }
.chapter-main [hidden] { display: none !important; }
.chapter-reader { max-width: 820px; margin: auto; }
.chapter-reader .chapter-paper { min-height: 0; }
@media (max-width: 1000px) { .chapter-layout { grid-template-columns: 1fr; } .chapter-sidebar { position: static; max-height: none; } }

.chapter-layout > .admin-panel { min-width: 0; }
.chapter-sidebar { padding: 24px; box-sizing: border-box; }
.chapter-sidebar h2 { font-size: 1.3rem; margin: 0 0 14px; }
.chapter-sidebar h2:not(:first-child) { margin-top: 28px; }
.chapter-tree-help, .chapter-tree-empty { font-size: .9rem; opacity: .8; }
.chapter-book-group { border: 1px solid #6d523b; border-radius: 8px; margin: 14px 0; background: #191511; }
.chapter-book-group summary { padding: 16px; font-size: 1.05rem; font-weight: bold; cursor: pointer; color: #f5e7d0; overflow-wrap: anywhere; }
.chapter-book-group summary small { display: block; font-weight: normal; margin-top: 6px; }
.chapter-book-actions { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 16px 12px; font-size: .88rem; }
.chapter-book-actions a { color: #eeb16e; }
.chapter-sidebar .chapter-tree-list { list-style: none; margin: 0; padding: 0 12px 12px 22px; }
.chapter-sidebar .chapter-tree-list li { margin: 8px 0; }
.chapter-tree-list a { display: block; padding: 12px; border-left: 3px solid #73573e; border-radius: 0 5px 5px 0; background: #251e18; color: #f5e7d0; text-decoration: none; overflow-wrap: anywhere; }
.chapter-tree-list a:hover, .chapter-tree-list a[aria-current="page"] { border-left-color: #d78d34; background: #3c2b1c; }
.chapter-tree-number { display: block; color: #eeb16e; font-size: .85rem; font-weight: bold; margin-bottom: 5px; }
.chapter-tree-title { display: block; font-size: 1rem; line-height: 1.5; }
.chapter-tree-list small { margin-top: 6px; }
.chapter-tree-empty { padding: 0 16px; }
.chapter-book-group summary:focus-visible, .chapter-tree a:focus-visible { outline: 3px solid #d78d34; outline-offset: 3px; }

/* Document workspace: themed chrome surrounding a centered manuscript page. */
.chapter-workspace { background: #090909; color: #d6c2a2; }
.chapter-workspace .eb-admin-nav { margin-bottom: 0; padding-top: 12px; padding-bottom: 12px; }
.chapter-workspace .chapter-main { width: 100%; max-width: none; padding: 0; }
.chapter-workspace .workspace-heading { margin: 0; padding: 18px 28px; border: 0; border-bottom: 1px solid #3e3024; border-radius: 0; background: #171717; }
.workspace-heading > a { font-size: 13px; color: #d78d34; }
.chapter-workspace .workspace-heading h1 { margin: 4px 0; font: 24px/1.3 Georgia, serif; color: #d6c2a2; }
.workspace-heading .workspace-subtitle { margin: 0; font: 12px/1.5 Arial, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: #ae9475; }
.chapter-workspace .chapter-layout { grid-template-columns: minmax(300px, 25%) minmax(0, 1fr); gap: 0; }
.chapter-workspace .chapter-sidebar { margin: 0; border-radius: 0; border: 0; border-right: 1px solid #3e3024; padding: 24px; background: #12110f; }
.chapter-workspace .document-panel { padding: 0; margin: 0; border: 0; border-radius: 0; background: #211c18; }
.chapter-workspace #chapter-form { display: block; margin: 0; }
.document-titlebar { background: #171717; padding: 18px 24px 12px; border-bottom: 1px solid #3e3024; }
.chapter-workspace .document-title-label { display: block; font: 12px/1.5 Arial, sans-serif; color: #ae9475; }
.chapter-workspace .document-title-label input { display: block; background: transparent; color: #f3e3ca; border: 1px solid transparent; border-radius: 4px; padding: 8px 0; font: 24px/1.4 Georgia, serif; }
.chapter-workspace .document-title-label input:focus { border-color: #d78d34; outline: none; }
.document-mode { margin: 0; color: #b99a75; font-size: 12px; }
.chapter-workspace .chapter-actions { margin: 10px 0 0; }
.workspace-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 8px 24px; background: #171717; font: 12px/1.5 Arial, sans-serif; color: #ae9475; }
.workspace-controls button { background: transparent; border: 1px solid #705034; color: #e6c397; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.chapter-workspace .chapter-toolbar { position: sticky; top: 0; z-index: 5; margin: 0; padding: 10px 20px; background: #261e18; border-top: 1px solid #3e3024; border-bottom: 1px solid #6a4d33; gap: 5px; box-shadow: 0 3px 10px #0005; }
.chapter-workspace .chapter-toolbar button { padding: 7px 9px; font-size: 12px; }
.chapter-workspace .chapter-toolbar label { font: 12px Arial, sans-serif; margin: 0; }
.chapter-workspace .chapter-toolbar select { background: #171310; color: #d6c2a2; border: 1px solid #705034; border-radius: 4px; width: auto; }
.document-stage { padding: 38px clamp(16px, 3vw, 50px) 50px; background: #211c18; }
.chapter-workspace .document-stage .chapter-paper { max-width: 816px; min-height: 1056px; margin: auto; box-sizing: border-box; padding: clamp(30px, 5vw, 80px); border-radius: 1px; background: #efe3cc; box-shadow: 0 10px 35px #0007; font: 18px/1.85 Georgia, serif; }
.document-footer { padding: 14px 24px 28px; border-top: 1px solid #3e3024; background: #171717; }
.document-footer #writing-status { font: 12px/1.7 Arial, sans-serif; color: #bfa17b; }
.document-settings summary { cursor: pointer; color: #d78d34; padding: 8px 0; }
.document-settings label { display: block; margin: 14px 0; }
.document-settings input, .document-settings textarea { background: #211c18; color: #d6c2a2; border: 1px solid #6a4d33; padding: 10px; border-radius: 5px; }
.chapter-workspace #recovery-notice { padding: 16px 24px; background: #35271c; }
.chapter-main.outline-hidden .chapter-sidebar { display: none; }
.chapter-workspace .chapter-main.outline-hidden .chapter-layout { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1000px) { .chapter-workspace .chapter-layout { grid-template-columns: 1fr; } .chapter-workspace .chapter-sidebar { max-height: 350px; overflow: auto; border-bottom: 1px solid #3e3024; } }
@media (max-width: 600px) { .chapter-workspace .workspace-heading { padding: 14px 16px; } .document-titlebar, .workspace-controls, .document-footer { padding-left: 16px; padding-right: 16px; } .document-stage { padding: 18px 10px; } .chapter-workspace .document-stage .chapter-paper { min-height: 70vh; padding: 25px 20px; } }

/* Book hero and a full-height desktop manuscript workspace. */
.chapter-workspace .book-hero { padding: 12px 28px 16px; }
.book-back-link { display: inline-block; margin-bottom: 6px; }
.book-hero-center { display: grid; grid-template-columns: 62px minmax(0, auto) 62px; justify-content: center; align-items: center; gap: 20px; }
.book-hero-title { text-align: center; min-width: 0; }
.book-hero-image { display: block; width: 62px; height: 82px; object-fit: cover; border: 1px solid #9d6f3e; border-radius: 3px; background: #261e18; box-shadow: 0 4px 14px #0008; }
.book-hero-placeholder { display: grid; place-items: center; font: 23px Georgia, serif; color: #d78d34; }
.book-hero-balance { width: 62px; }
.chapter-paper .chapter-indent-1 { text-indent: 2em; }
.chapter-paper .chapter-indent-2 { text-indent: 4em; }
.chapter-paper .chapter-indent-3 { text-indent: 6em; }
.chapter-paper .chapter-indent-4 { text-indent: 8em; }
.chapter-paper .chapter-indent-5 { text-indent: 10em; }
.chapter-paper .chapter-indent-6 { text-indent: 12em; }
@media (min-width: 1001px) {
    body.chapter-workspace { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
    .chapter-workspace > .eb-admin-nav { flex: 0 0 auto; }
    .chapter-workspace .chapter-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin: 0; }
    .chapter-workspace .workspace-heading { flex: 0 0 auto; }
    .chapter-workspace .chapter-layout { flex: 1 1 auto; min-height: 0; align-items: stretch; }
    .chapter-workspace .chapter-sidebar { position: static; max-height: none; min-height: 0; overflow-y: auto; }
    .chapter-workspace .document-panel { min-height: 0; overflow-y: auto; }
    .chapter-workspace #chapter-form { min-height: 100%; display: flex; flex-direction: column; }
    .chapter-workspace .document-stage { flex: 1 0 auto; }
}
@media (max-width: 600px) { .book-hero-center { grid-template-columns: 45px minmax(0,1fr); gap: 12px; } .book-hero-image { width: 45px; height: 60px; } .book-hero-balance { display: none; } .book-hero-title { text-align: left; } .chapter-workspace .book-hero h1 { font-size: 20px; } }

/* Soft Gothic Western edges for the manuscript workspace and shared reader.
   Keep the manuscript opaque for long-form reading and editing. */
.chapter-workspace {background:radial-gradient(ellipse at 0 30%,#79549614,transparent 60%),#090909;}
.chapter-workspace .workspace-heading {
 background:radial-gradient(ellipse at 85% 0,rgba(126,88,167,.13),transparent 65%),linear-gradient(115deg,#191617,#121212);
 border-bottom-color:rgba(215,141,52,.18);box-shadow:0 8px 28px #0003;
}
.chapter-workspace .chapter-layout {gap:18px;padding:18px;box-sizing:border-box;}
.chapter-workspace .chapter-sidebar {
 border:1px solid rgba(215,141,52,.16);border-radius:18px;
 background:radial-gradient(ellipse at top left,#8055a01c,transparent 65%),#121113;
 box-shadow:0 10px 30px #0004;scrollbar-width:thin;scrollbar-color:#856248 #151316;
}
.chapter-workspace .document-panel {
 border:1px solid rgba(215,141,52,.16);border-radius:18px;
 background:#171416;box-shadow:0 14px 36px #0005;
 scrollbar-width:thin;scrollbar-color:#856248 #151316;
}
.chapter-workspace .document-titlebar {border-radius:18px 18px 0 0;}
.chapter-workspace :is(.document-titlebar,.workspace-controls,.document-footer) {
 background:linear-gradient(110deg,#1b171c,#151414);border-color:rgba(215,141,52,.17);
}
.chapter-workspace .document-footer {border-radius:0 0 18px 18px;}
.chapter-workspace .document-stage {background:radial-gradient(ellipse at top right,#8055a016,transparent 65%),#1b1719;}
.chapter-workspace .chapter-toolbar {
 background:linear-gradient(110deg,#271e28,#211b17);border-color:rgba(215,141,52,.23);
 box-shadow:0 6px 20px #0004;
}
.chapter-workspace .chapter-book-group {background:linear-gradient(125deg,#1e1921,#161414);border-color:rgba(215,141,52,.2);border-radius:13px;}
.chapter-workspace .chapter-tree-list a {border-left-color:#856248;border-radius:8px;background:linear-gradient(90deg,#d78d3410,transparent);}
.chapter-workspace .chapter-tree-list a:hover,
.chapter-workspace .chapter-tree-list a[aria-current="page"] {border-left-color:#d78d34;background:linear-gradient(90deg,#8055a038,#8055a008);}
.chapter-workspace .chapter-sidebar h2::after {content:"";display:block;height:1px;margin-top:12px;background:linear-gradient(90deg,#d78d3477,#8055a033,transparent);}
.chapter-workspace :is(.chapter-toolbar button,.outline-link,.workspace-controls button,.chapter-actions .btn) {border-radius:9px;border-color:rgba(215,141,52,.4);}
.chapter-workspace :is(button,a,input,textarea,select,summary,[contenteditable]):focus-visible {
 outline:2px solid #c6a0e5;outline-offset:3px;
}
.chapter-workspace .document-stage .chapter-paper,
.chapter-reader .chapter-paper {border-radius:10px;border-color:#b99a7577;box-shadow:0 12px 36px #0006,0 0 24px #8055a012;}
.chapter-workspace #chapter-source {padding:24px;box-sizing:border-box;background:#efe3cc;color:#27201a;border:1px solid #b99a75;border-radius:10px;font:18px/1.85 Georgia,serif;}
@media(max-width:600px) {
 .chapter-workspace .chapter-layout {gap:12px;padding:10px;}
 .chapter-workspace .chapter-sidebar {padding:18px;}
}
@media print {
 .chapter-workspace,.chapter-workspace .document-stage,.chapter-workspace .document-panel {background:white;box-shadow:none;}
 .chapter-workspace .document-stage .chapter-paper,.chapter-reader .chapter-paper {box-shadow:none;}
}

/* Shared control styling: .toolbar-group can also be used by other editors. */
.chapter-toolbar .toolbar-group { display:flex; flex-wrap:wrap; align-items:center; gap:6px; padding:5px 10px 5px 0; margin-right:4px; border-right:1px solid #85624866; }
.chapter-toolbar .toolbar-group:last-of-type { border-right:0; }
.chapter-workspace .chapter-toolbar { gap:4px 8px; align-items:center; }
.chapter-workspace .chapter-toolbar button, .chapter-workspace .chapter-toolbar select { min-height:36px; }
.chapter-toolbar button:hover { background:#493223; }
.chapter-toolbar button[aria-pressed="true"] { color:#fff1db; background:#68411e; border-color:#e4aa62; box-shadow:inset 0 -2px #e4aa62; }
.chapter-toolbar .editor-find { display:flex; flex-wrap:wrap; align-items:center; gap:10px; flex-basis:100%; padding-top:10px; border-top:1px solid #85624866; }
.chapter-toolbar .editor-find input:not([type=checkbox]) { width:160px; min-height:34px; background:#171310; color:#f6ead6; border:1px solid #82674e; border-radius:5px; padding:5px 8px; }
.chapter-toolbar .editor-find input[type=checkbox] { width:auto; }
#find-status { font:12px/1.5 Arial,sans-serif; color:#d6c2a2; }
body.chapter-focus { overflow:hidden; }
.chapter-focus .document-panel { position:fixed; inset:0; z-index:1000; overflow-y:auto; border-radius:0; }
.chapter-focus .document-titlebar { border-radius:0; }
.chapter-focus .chapter-toolbar { top:0; }
@media(max-width:600px) {
 .chapter-workspace .chapter-toolbar { padding:8px; }
 .chapter-toolbar .toolbar-group { border-right:0; margin:0; padding:3px 0; }
 .chapter-toolbar .editor-find label { flex-wrap:wrap; }
}
