/* Interface fonts, served with the app (no requests to font services): SIL Open Font License */
@font-face { font-family: "DM Sans"; font-weight: 400; font-display: swap; src: url(ui-fonts/dm-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 600; font-display: swap; src: url(ui-fonts/dm-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 700; font-display: swap; src: url(ui-fonts/dm-sans-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Cormorant Garamond"; font-weight: 600; font-display: swap; src: url(ui-fonts/cormorant-garamond-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Lora"; font-style: normal; font-display: swap; src: url(ui-fonts/lora-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Lora"; font-style: italic; font-display: swap; src: url(ui-fonts/lora-latin-400-italic.woff2) format("woff2"); }
/* Wisteria Dragon book formatter: the editor.
   Three panes like a desk: the book's outline on the left, the page you're writing in the middle,
   the finished page (print or ebook) on the right. Brand: purple #7958B3, lavender #B1A6F5, ink #1A0B1E. */
:root {
  --p: #7958B3; --p-soft: #f1edf9; --l: #B1A6F5; --ink: #1A0B1E; --muted: #6b6480; --line: #e6e1ef;
  --bg: #f6f4fa; --paper: #fff; --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Lora", Georgia, serif;
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--sans); color: var(--ink); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.top { height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--ink); color: #fff; }
.brand { font: 600 17px/1 "Cormorant Garamond", Georgia, serif; letter-spacing: .02em; white-space: nowrap; }
.brand b { color: var(--l); font-weight: 600; }
.top .book-title { flex: 1; color: #d9d3ea; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .saved { font-size: 12px; color: #a99fc4; white-space: nowrap; }
.btn { border: 1.5px solid var(--p); background: #fff; color: var(--p); border-radius: 9px; padding: 8px 14px; font-weight: 600; }
.btn.primary { background: var(--p); color: #fff; }
.top .btn { border-color: #4a3a5e; background: transparent; color: #fff; }
.top .btn.primary { background: var(--p); border-color: var(--p); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- three panes ---------- */
.app { display: grid; grid-template-columns: clamp(190px, 18vw, 270px) minmax(0, 1fr) clamp(330px, 30vw, 440px); grid-template-rows: minmax(0, 1fr); height: calc(100% - 56px); }
/* each pane scrolls on its own (grid and flex children must be allowed to be shorter than their content) */
.app > * { min-height: 0; }
.right .pane { min-height: 0; }
.side { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 10px 40px; }
.side h4 { margin: 18px 8px 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.side h4 button { border: 0; background: none; color: var(--p); font-weight: 700; font-size: 18px; line-height: 1; padding: 0 4px; letter-spacing: 0; }
.item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; user-select: none; }
.item:hover { background: var(--bg); }
.item.sel { background: var(--p-soft); box-shadow: inset 3px 0 0 var(--p); }
.item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .k { font-size: 11px; color: var(--muted); white-space: nowrap; }
.item.part { font-weight: 700; margin-top: 6px; }
.item.in-part { padding-left: 20px; }
.item.drag-over { box-shadow: inset 0 2px 0 var(--p); }
.item .grip { color: #c4bdd3; cursor: grab; font-size: 12px; }

.center { overflow-y: auto; background: var(--bg); }
.sheet { max-width: 760px; margin: 22px auto 120px; background: var(--paper); border-radius: 14px; box-shadow: 0 10px 40px -18px rgba(121,88,179,.35); padding: 26px 56px 60px; }
.sec-head { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; align-items: center; padding-bottom: 16px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.sec-head label { font-size: 12px; color: var(--muted); font-weight: 600; }
.sec-head input, .sec-head select, .details input, .details select { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; }
.sec-head input:focus, .details input:focus { outline: none; border-color: var(--p); }
.sec-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.sec-actions button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--muted); }
.sec-actions button:hover { color: var(--p); border-color: var(--l); }
.sec-actions .danger:hover { color: #c8433f; border-color: #f0c4c2; }

/* toolbar */
.toolbar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 2px; padding: 10px 0; background: var(--paper); border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.toolbar button, .toolbar select { border: 1px solid transparent; background: none; border-radius: 7px; padding: 5px 6px; min-width: 26px; color: var(--ink); white-space: nowrap; }
.toolbar button:hover, .toolbar select:hover { background: var(--bg); }
.toolbar button.on { background: var(--p-soft); color: var(--p); border-color: var(--l); }
.toolbar .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.toolbar select { border-color: var(--line); }

/* the writing surface: book-like, but not the final design */
.ProseMirror { outline: none; font: 17px/1.7 var(--serif); min-height: 50vh; white-space: pre-wrap; word-wrap: break-word; }
.ProseMirror p { margin: 0 0 .1em; text-indent: 1.5em; }
.ProseMirror p:first-child, .ProseMirror .pm-scene + p, .ProseMirror h2 + p, .ProseMirror h3 + p, .ProseMirror h4 + p { text-indent: 0; }
.ProseMirror h2, .ProseMirror h3, .ProseMirror h4 { font-family: var(--sans); margin: 1.2em 0 .4em; }
.ProseMirror h2 { font-size: 21px; } .ProseMirror h3 { font-size: 18px; } .ProseMirror h4 { font-size: 16px; }
.ProseMirror .pm-scene { text-align: center; margin: .9em 0; user-select: none; display: flex; justify-content: center; align-items: center; min-height: 1.4em; }
.ProseMirror .pm-scene .orn-text { font-size: 17px; }
.ProseMirror blockquote { margin: .8em 2em; font-size: 16px; }
.ProseMirror .verse { margin: .8em 0 .8em 2.2em; white-space: pre-wrap; }
.ProseMirror .epigraph { margin: .6em 0 1.2em 30%; font-size: 15px; font-style: italic; }
.ProseMirror .caption { text-align: center; text-indent: 0; font-size: 14px; font-style: italic; color: var(--muted); }
.ProseMirror .callout { background: var(--p-soft); border-left: 3px solid var(--p); padding: 10px 14px; margin: 1em 0; font-size: 16px; }
.ProseMirror ul, .ProseMirror ol { margin: .6em 0; padding-left: 1.6em; }
.ProseMirror figure { margin: 1em 0; text-align: center; }
.ProseMirror figure img { max-width: 100%; height: auto; border-radius: 4px; }
.ProseMirror figure .missing { padding: 18px; border: 1.5px dashed #e0a7a5; color: #a33f3b; border-radius: 8px; font: 13px var(--sans); }
.ProseMirror .pm-icon img { height: 1em; vertical-align: -.12em; }
.ProseMirror .pm-table table { border-collapse: collapse; margin: 1em auto; font: 14px var(--sans); }
.ProseMirror .pm-table td, .ProseMirror .pm-table th { border: 1px solid var(--line); padding: 4px 9px; }
.ProseMirror .pm-table img { max-width: 140px; display: block; }
.ProseMirror-selectednode { outline: 2px solid var(--l); border-radius: 4px; }
.ProseMirror-gapcursor:after { border-top-color: var(--p); }

/* book details */
.details { display: grid; grid-template-columns: 150px 1fr; gap: 12px 14px; align-items: center; }
.details h2 { grid-column: 1 / -1; font: 600 26px/1.2 "Cormorant Garamond", Georgia, serif; margin: 0 0 6px; }
.details label { font-size: 12px; color: var(--muted); font-weight: 600; }
.details .hint { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -6px; }

/* ---------- right pane: preview + design ---------- */
.right { display: flex; flex-direction: column; background: #ece8f3; border-left: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; background: #fff; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 9px 12px; font-weight: 600; color: var(--muted); border-bottom: 2.5px solid transparent; }
.tabs button.on { color: var(--p); border-bottom-color: var(--p); }
.pane { flex: 1; overflow-y: auto; padding: 16px; }
.preview-pages { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.preview-pages .pv-page { width: 100%; background: #fff; box-shadow: 0 8px 24px -12px rgba(26,11,30,.35); }
.preview-pages .pv-page svg { display: block; width: 100%; height: auto; }
.preview-pages .pv-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.preview-note { font-size: 12px; color: var(--muted); text-align: center; margin: 0 0 10px; min-height: 1.4em; }
.ebook-frame { width: 100%; max-width: 380px; height: 640px; margin: 0 auto; display: block; border: 10px solid #222; border-radius: 22px; background: #fff; }
.design h5 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.design h5:first-child { margin-top: 0; }
.theme-cards { display: grid; gap: 8px; }
.theme-card { display: block; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.theme-card b { display: block; } .theme-card span { font-size: 12px; color: var(--muted); }
.theme-card.on { border-color: var(--p); box-shadow: inset 0 0 0 1.5px var(--p); background: var(--p-soft); }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field select { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 8px; font-size: 13px; }
.seg button.on { background: var(--p); color: #fff; }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; }

/* ---------- start screen ---------- */
.start { position: fixed; inset: 56px 0 0; display: grid; place-items: center; background: var(--bg); z-index: 5; }
.start .card { width: min(560px, 92vw); background: #fff; border-radius: 18px; padding: 36px; text-align: center; box-shadow: 0 20px 50px -20px rgba(121,88,179,.35); }
.start h1 { font: 600 34px/1.15 "Cormorant Garamond", Georgia, serif; margin: 0 0 8px; }
.start p { color: var(--muted); margin: 0 0 22px; }
.drop { display: block; border: 2px dashed var(--l); border-radius: 14px; padding: 30px 16px; cursor: pointer; background: #faf9fd; }
.drop.over { background: var(--p-soft); border-color: var(--p); }
.drop b { display: block; font-size: 16px; margin-bottom: 4px; color: var(--p); }
.start .alt { margin-top: 16px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.start .private { margin-top: 18px; font-size: 12px; color: var(--muted); }

/* ---------- dialogs ---------- */
.modal { position: fixed; inset: 0; background: rgba(26,11,30,.45); display: grid; place-items: center; z-index: 20; }
.modal .box { width: min(620px, 94vw); max-height: 86vh; overflow-y: auto; background: #fff; border-radius: 16px; padding: 24px 26px; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal .status { color: var(--muted); margin: 6px 0 14px; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.report ul { list-style: none; padding: 0; margin: 0; }
.report h6 { margin: 14px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.report li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f2eff6; }
.report li p { margin: 1px 0 0; color: var(--muted); font-size: 13px; }
.ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; }
.pass .ic { background: #3d9a6a; } .warn .ic { background: #d89a1e; } .fail .ic { background: #c8433f; } .info .ic { background: var(--l); }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 30%; background: var(--p); animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar i { animation: none; width: 100%; } }

@media (max-width: 1180px) { .sheet { padding: 20px 28px 50px; } }

/* books saved on this device */
.start .card { position: relative; max-height: calc(100vh - 90px); overflow-y: auto; }
.start .close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 26px; color: var(--muted); line-height: 1; }
.recent h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 24px 0 8px; text-align: left; }
.recent ul { list-style: none; margin: 0; padding: 0; text-align: left; }
.recent li { display: flex; gap: 8px; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.recent .open { flex: 1; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 10px; }
.recent .open:hover { background: var(--bg); }
.recent .open b { display: block; } .recent .open span { font-size: 12px; color: var(--muted); }
.recent .del { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 0 12px; border-left: 1px solid var(--line); }
.recent .del:hover { color: #c8433f; }

/* chapter navigation at the foot of the page */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); }
.pager button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 14px; text-align: left; max-width: 48%; }
.pager button:hover { border-color: var(--l); color: var(--p); }
.pager button small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.pager .next { margin-left: auto; text-align: right; }
/* picture options under a selected picture */
.pm-image { position: relative; }
.pic-tools { display: none; flex-direction: column; gap: 7px; margin: 10px auto 0; padding: 12px 14px; max-width: 560px; background: #faf9fd; border: 1px solid var(--line); border-radius: 12px; font: 13px var(--sans); text-align: left; }
.ProseMirror-selectednode .pic-tools, .pm-image:focus-within .pic-tools { display: flex; }
.pic-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pic-row.end { justify-content: flex-end; }
.pic-label { width: 104px; flex: none; font-weight: 600; color: var(--muted); font-size: 12px; }
.pic-tools button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 9px; }
.pic-tools button.on { background: var(--p); color: #fff; border-color: var(--p); }
.pic-tools button:disabled { opacity: .4; cursor: default; }
.pic-tools button.danger:hover { color: #c8433f; border-color: #f0c4c2; }
.pic-tools input { flex: 1; min-width: 200px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; }
.pic-note { font-size: 12px; color: var(--muted); margin: -3px 0 0 109px; }
.pic-badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.badge { font: 12px var(--sans); padding: 2px 9px; border-radius: 99px; background: var(--p-soft); color: var(--p); }
.badge.warn { background: #fdf1dc; color: #8a5a00; }
.pm-caption { font: italic 14px var(--serif); color: var(--muted); margin-top: 6px; }
.ProseMirror figure.wrap-left { text-align: left; } .ProseMirror figure.wrap-right { text-align: right; }
.pic-section-hint { font-size: 13px; color: var(--muted); background: var(--p-soft); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }

.toolbar label.tb-btn { border: 1px solid transparent; border-radius: 7px; padding: 5px 8px; cursor: pointer; white-space: nowrap; }
.toolbar label.tb-btn:hover { background: var(--bg); }
.ProseMirror.drop-pic { outline: 2px dashed var(--l); outline-offset: 8px; border-radius: 6px; }

/* toasts with an Undo button */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; background: var(--ink); color: #fff; padding: 10px 14px 10px 16px; border-radius: 10px; z-index: 40; box-shadow: 0 10px 30px -10px rgba(26,11,30,.5); }
.toast button { border: 0; background: var(--l); color: var(--ink); font-weight: 700; border-radius: 7px; padding: 5px 12px; }
/* word counts */
.side .count { margin: 18px 8px 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sec-actions .words { margin-left: auto; align-self: center; font-size: 12px; color: var(--muted); }
/* ebook cover */
.cover-field { display: flex; gap: 16px; align-items: flex-start; }
.cover-field img, .cover-empty { width: 110px; aspect-ratio: 1 / 1.6; object-fit: cover; border-radius: 4px; box-shadow: 0 6px 18px -8px rgba(26,11,30,.45); flex: none; }
.cover-empty { display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: 12px; box-shadow: none; border: 1.5px dashed var(--line); }
.cover-field .btn { display: inline-block; font-size: 13px; padding: 7px 12px; }
/* tables */
.ProseMirror .pm-table { margin: 1em 0; }
.ProseMirror .pm-table table { border-collapse: collapse; margin: 0 auto; font: 14px var(--sans); }
.ProseMirror .pm-table th, .ProseMirror .pm-table td { border: 1px solid var(--line); padding: 0; min-width: 90px; vertical-align: top; }
.ProseMirror .pm-table th { background: var(--p-soft); }
.ProseMirror .pm-table .cell { padding: 6px 9px; outline: none; min-height: 1.4em; white-space: pre-wrap; }
.ProseMirror .pm-table .cell:focus { box-shadow: inset 0 0 0 2px var(--l); }
.ProseMirror .pm-table img { max-width: 140px; display: block; margin: 6px auto 0; }
.table-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-top: 8px; font: 13px var(--sans); }
.table-tools button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 4px 9px; }
.table-tools button:disabled { opacity: .4; }
.table-tools .danger:hover { color: #c8433f; border-color: #f0c4c2; }
/* find and replace */
.find { position: fixed; top: 66px; right: 452px; width: 380px; max-height: calc(100vh - 90px); display: flex; flex-direction: column; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; z-index: 25; box-shadow: 0 20px 50px -20px rgba(26,11,30,.45); }
.find-head { display: flex; justify-content: space-between; align-items: center; }
.find .x { border: 0; background: none; font-size: 22px; color: var(--muted); line-height: 1; }
.find input:not([type]) { padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; }
.find input:not([type]):focus { outline: none; border-color: var(--p); }
.find-opts { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.find-opts .btn { margin-left: auto; padding: 6px 12px; font-size: 13px; }
.find-info { margin: 0; font-size: 12px; color: var(--muted); }
.find-results { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.find-results li { display: flex; gap: 6px; border-bottom: 1px solid #f2eff6; }
.find-results .go { flex: 1; text-align: left; border: 0; background: none; padding: 7px 4px; font-size: 13px; }
.find-results .go:hover { background: var(--bg); }
.find-results .go small { display: block; color: var(--muted); font-size: 11px; }
.find-results mark { background: #fbe8a6; color: inherit; }
.find-results .one { border: 0; background: none; color: var(--p); font-size: 12px; padding: 0 6px; }
@media (max-width: 1180px) { .find { right: 372px; } }
/* whole-book preview */
.pv-bar { position: sticky; top: 0; z-index: 3; background: var(--bg, #f6f4f9); padding: 8px 0; display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
.pv-bar .seg { width: 230px; }
.pv-bar input { width: 64px; padding: 5px 8px; border: 1.5px solid var(--line); border-radius: 8px; }
.pv-bar label { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.ProseMirror .pm-table .cell:empty::before { content: attr(data-ph); color: var(--muted, #8a8090); }
.top .wc { margin-left: 12px; font-size: 12px; color: #b1a6f5; }
.ebook-cover { width: 100%; max-width: 380px; aspect-ratio: 1 / 1.6; margin: 0 auto; display: block; border: 10px solid #222; border-radius: 22px; background: #111; object-fit: contain; }
.ebook-cover.empty { display: grid; place-items: center; color: #aaa; font-size: 13px; text-align: center; padding: 24px; box-sizing: border-box; }
.pane > .seg { margin: 0 auto 10px; width: 260px; }
.cover-checks { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.cover-checks li { display: grid; grid-template-columns: 16px auto 1fr; gap: 7px; align-items: baseline; margin: 4px 0; }
.cover-checks b { color: var(--ink, #1a0b1e); font-weight: 600; white-space: nowrap; }
.cover-checks .mk { width: 16px; height: 16px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; transform: translateY(2px); }
.cover-checks .ok .mk { background: #3f8f5a; } .cover-checks .warn .mk { background: #b7791f; } .cover-checks .bad .mk { background: #b83a3a; } .cover-checks .info .mk { background: #7958b3; }
.pm-image img.pic-line { border: 1.5px solid #1a0b1e; box-sizing: border-box; }
.pm-image img.pic-frame { border: 1.5px solid #1a0b1e; padding: 6px; background: #fff; box-sizing: border-box; }
.pm-image img.pic-rounded { border-radius: 10px; }
.pic-row button.link { border: 0; background: none; color: var(--p, #7958b3); text-decoration: underline; padding: 4px 6px; margin-left: auto; font-size: 12px; }
.orn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.orn-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font: inherit; }
.orn-tile:hover { border-color: var(--l, #b1a6f5); }
.orn-tile.on { border-color: var(--p, #7958b3); box-shadow: 0 0 0 2px rgba(121,88,179,.18); }
.orn-art { height: 32px; display: flex; align-items: center; justify-content: center; }
.orn-art img { max-width: 100%; }
.orn-text { font-family: "Lora", Georgia, serif; font-size: 15px; letter-spacing: .25em; color: #1a0b1e; }
.orn-name { font-size: 11.5px; color: var(--muted); }
.orn-tile.add .orn-art { font-size: 22px; color: var(--p, #7958b3); }
.seg button:disabled { opacity: .45; cursor: default; }
.orn-sample { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; font: 13px/1.5 "Lora", Georgia, serif; color: #1a0b1e; }
.orn-sample p { margin: 0; text-indent: 0; }
.orn-sample-break { display: flex; justify-content: center; align-items: center; min-height: 26px; margin: 8px 0; }
.headpic-field { display: flex; gap: 10px; align-items: center; }
.headpic-field select { flex: 1; }
.headpic-thumb { height: 38px; max-width: 90px; object-fit: contain; border-radius: 4px; border: 1px solid var(--line); background: #fff; }
.btn.small { font-size: 12.5px; padding: 6px 10px; display: inline-block; }
.headpic-design { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.headpic-design img { width: 96px; max-height: 96px; object-fit: contain; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.heading-preview { text-align: center; margin: 18px 0 8px; padding: 14px 0 18px; border-bottom: 1px dashed var(--line); }
.heading-preview img { max-width: 100%; display: block; margin: 8px auto; }
.heading-preview .hp-label { font: 12px var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.heading-preview .hp-name { font: italic 22px "Lora", Georgia, serif; color: #1a0b1e; margin-top: 4px; }
.width-row { display: flex; gap: 10px; align-items: center; }
.width-row input[type=range] { flex: 1; accent-color: var(--p, #7958b3); }
.seg.mini { width: auto; flex: none; } .seg.mini button { padding: 5px 9px; font-size: 12px; }
.heading-preview .hp-name.muted { color: var(--muted); font-size: 16px; }
.sheet.justified .ProseMirror p:not([data-align]) { text-align: justify; hyphens: auto; }
.sheet.ragged .ProseMirror p:not([data-align]) { text-align: left; }
.toolbar button.tb-align { padding: 5px 6px; min-width: 0; }
.toolbar button.tb-align svg { display: block; }
.toolbar select { max-width: 104px; }
.toolbar .sep { margin: 4px 2px; }
.toolbar label.tb-btn { padding: 5px 6px; }
/* centred and right-aligned paragraphs are exceptions: a small marker in the margin makes them easy to find */
.ProseMirror p[data-align] { position: relative; }
.ProseMirror p[data-align]::before { content: ""; position: absolute; left: -16px; top: .35em; width: 3px; height: calc(100% - .5em); min-height: .9em; border-radius: 2px; background: var(--l, #b1a6f5); }
.sec-head .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.num-field { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.num-field .num-auto { font-weight: 600; color: var(--ink, #1a0b1e); min-width: 90px; }
.num-field .hint { font-size: 12px; color: var(--muted); flex-basis: 100%; margin-top: -4px; }
.num-field label.check { font-size: 13px; color: var(--ink, #1a0b1e); font-weight: 400; display: flex; gap: 6px; align-items: center; }
.saved.act { cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.saved.act:focus-visible { outline: 2px solid #B1A6F5; outline-offset: 2px; border-radius: 4px; }
/* footnote and endnote marks: numbered by counters, so numbers stay right as notes move */
@counter-style foot-symbols { system: symbolic; symbols: "*" "†" "‡" "§" "‖" "¶"; }
.ProseMirror { counter-reset: fn en; }
.ProseMirror .pm-note { cursor: pointer; font: 600 0.68em/1 "DM Sans", system-ui, sans-serif; padding: 0 2px; margin-left: 1px; border-radius: 3px; vertical-align: super; color: #5E4392; background: #EEE9FB; user-select: none; }
.ProseMirror .pm-note.foot::after { counter-increment: fn; content: counter(fn); }
.ProseMirror .pm-note.foot.sym::after { content: counter(fn, foot-symbols); }
.ProseMirror .pm-note.end { color: #7a4a12; background: #fbeedb; }
.ProseMirror .pm-note.end::after { counter-increment: en; content: counter(en); }
.ProseMirror .pm-note:hover, .ProseMirror .pm-note.ProseMirror-selectednode { outline: 2px solid #B1A6F5; outline-offset: 1px; }
.note-box { width: min(560px, 92vw); }
.note-box .seg { margin: 4px 0 10px; }
.note-box .note-text { min-height: 90px; max-height: 40vh; overflow: auto; border: 1px solid #CFC6EE; border-radius: 8px; padding: 10px 12px; font: 15px/1.5 Lora, Georgia, serif; color: #1A0B1E; background: #fff; outline: none; }
.note-box .note-text:focus { border-color: #7958B3; box-shadow: 0 0 0 3px #EEE9FB; }
.note-box .hint { font-size: 12px; color: #6b6176; margin: 6px 0 0; }
/* version history */
.history-box { width: min(560px, 94vw); }
.history-box .name-row { display: flex; gap: 8px; margin: 10px 0 6px; }
.history-box .name-row input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit; }
.versions { max-height: 50vh; overflow-y: auto; margin: 6px 0 14px; }
.versions h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #6b6176; }
.version { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0ecf6; }
.version .when { width: 64px; flex: none; font-variant-numeric: tabular-nums; color: #3D3346; font-size: 14px; }
.version .what { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.version .what small { color: #6b6176; font-size: 12px; }
.version .btn { padding: 6px 12px; }
.a11y-checks li { align-items: flex-start; }
.a11y-checks li > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.a11y-checks li > div > span { color: #4A4053; font-size: 13px; line-height: 1.45; }
.a11y-checks .goto { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; color: #5E4392; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font: inherit; }
.a11y-checks li { grid-template-columns: 16px 1fr; }
.a11y-checks b { white-space: normal; }
#pane > .seg button { white-space: nowrap; }
/* themes: two columns of name + genre; the chosen one shows its description */
.theme-cards { grid-template-columns: 1fr 1fr; }
.theme-card { text-align: left; padding: 9px 11px; }
.theme-card .genre { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.theme-card.on { grid-column: 1 / -1; }
.theme-card.on span:last-child:not(.genre) { display: block; margin-top: 4px; color: #3D3346; }
/* heading styles: small live samples in the chosen heading font */
.hs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.hs-tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-height: 112px; padding: 10px 10px 8px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; overflow: hidden; text-align: center; }
.hs-tile:hover { border-color: #B1A6F5; }
.hs-tile.on { border-color: var(--p); box-shadow: inset 0 0 0 1.5px var(--p); }
.hs-tile .hh { font-size: 15px; line-height: 1.15; color: #1A0B1E; transition: opacity .2s; margin: auto 0; }
.hs-tile .hh img { max-width: 70%; }
.hs-tile .hh.own small { display: block; font: 9px/1.2 Georgia, serif; letter-spacing: .24em; margin-bottom: 3px; }
.hs-tile .hh.own i { font-size: 17px; }
.hs-tile .hs-name { font-size: 11.5px; color: var(--muted); }
.hs-tile.on .hs-name { color: var(--p); font-weight: 600; }
/* chapter form: a label lines up with the first line of its field, even when the field runs to two lines */
.sec-head { align-items: start; }
.sec-head > label, .sec-head > .lbl { padding-top: 11px; }
.sec-head > .num-field { padding-top: 9px; }
.sec-head > .sec-actions { align-self: center; }
/* the editor's heading drawn in the book's own heading style */
.heading-preview.styled { text-align: center; }
.heading-preview.styled .hh { font-size: 26px; line-height: 1.2; color: #1A0B1E; margin: 4px auto 0; max-width: 34em; }
.heading-preview.styled .hh img { max-height: 1.1em; }
.heading-preview.styled .hp-pov { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; margin-top: 8px; }
.toolbar svg { display: block; }
.heading-preview.styled .hh img { display: inline-block; margin: 0; width: auto; }
.heading-preview.styled .hh .horn { display: block; }

/* ---------- narrower windows: the top bar never wraps or overlaps ---------- */
.top .btn { white-space: nowrap; flex-shrink: 0; }
.top .saved { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.top .book-title { min-width: 60px; }
@media (max-width: 1280px) {
  .top { gap: 8px; }
  .top .wc { display: none; }

  .top .btn { padding: 7px 11px; }
}
@media (max-width: 1100px) {
  .top .saved { max-width: 190px; }
  .toolbar button, .toolbar select { padding: 5px 4px; }
}

/* ---------- heading tiles: which one is the theme's own ---------- */
.hs-tile { position: relative; }
.hs-badge { position: absolute; top: 6px; right: 6px; font: 600 10px/1 "DM Sans", sans-serif; letter-spacing: .04em; color: var(--p); background: var(--p-soft); border-radius: 999px; padding: 3px 7px; }

/* ---------- a title that repeats its chapter number ---------- */
.title-hint { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: -4px; font-size: 12.5px; color: #6b5a12; background: #fdf6dc; border: 1px solid #f0e2a8; border-radius: 8px; padding: 8px 10px; }
.title-hint span { flex-basis: 100%; }
@media (max-width: 1100px) {
  .sec-head { grid-template-columns: 112px 1fr; gap: 10px 10px; }
}

/* the toolbar tightens with the editor column's own width (not the window's), so it stays on one line */
.center { container-type: inline-size; }
@container (max-width: 760px) {
  .toolbar { gap: 0; }
  .toolbar button, .toolbar select, .toolbar label.tb-btn { padding: 5px 4px; }
  .toolbar .sep { margin: 4px 2px; }
  .toolbar select { max-width: 86px; }
  .toolbar button { min-width: 22px; }
}

/* ---------- links ---------- */
.ProseMirror a.pm-link { color: inherit; text-decoration: underline; text-decoration-color: var(--l); text-underline-offset: 3px; }
.ProseMirror a.pm-link.store { text-decoration-style: dashed; text-decoration-color: var(--p); }
.link-box { width: min(560px, 92vw); }
.link-box .seg { margin: 4px 0 12px; }
.link-box .field { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; margin: 6px 0; }
.link-box .field span { font-size: 13px; color: var(--muted); }
.link-box .field input { width: 100%; }
.link-box .hint { font-size: 12.5px; color: var(--muted); margin: 6px 0; }
.link-box .err { color: #b3261e; }
.link-box input { border: 1.5px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; }
.link-box input:focus { outline: none; border-color: var(--p); }

/* ---------- export ebooks ---------- */
.export-box { width: min(600px, 94vw); }
.store-list { border: 1px solid var(--line); border-radius: 10px; margin: 10px 0 14px; max-height: 52vh; overflow: auto; }
.store-row { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.store-row:last-child { border-bottom: 0; }
.store-row > label.check { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px; margin: 0; cursor: pointer; }
.store-row label.check > span { display: flex; flex-direction: column; }
.store-row small { font-size: 12px; color: var(--muted); }
.store-row .st { font-size: 12.5px; white-space: nowrap; }
.store-row .st.ok { color: #2e7d32; }
.store-row .st.warn { color: #9a5b00; }
.store-row .st.info { color: var(--muted); }
.store-checks { margin: 8px 0 0 30px; }
.export-box .where { display: flex; align-items: center; gap: 12px; }
.export-box .where > span { font-size: 13px; color: var(--muted); }
.export-box .where .seg { flex: 1; }
.export-box ul.made { padding-left: 18px; margin: 8px 0; font-size: 13px; }
.export-box ul.made li { margin: 4px 0; }
.export-box p.warn { color: #9a5b00; }
.store-checks li > div > span { display: block; color: var(--muted); }
.store-checks li > div > b { display: block; }
