/* §345 The book editor (assets/book-editor.js): the book's own pages in the middle, the page list at the left, "This part",
   "The book" and the assistant at the right. It takes the content area; the sidebar and the top bar stay. */
.main-content.bked-open > :not(.topbar):not(#book-editor) { display: none !important; }
.bked { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h, 64px)); min-height: 520px; background: var(--canvas); color: var(--ink); }
.bked:fullscreen { height: 100vh; }
.bked-loading { margin: auto; padding: 40px; text-align: center; color: var(--muted); display: grid; gap: 14px; justify-items: center; }

.bked-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.bked-title { display: grid; min-width: 0; flex: 1 1 200px; }
.bked-title b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bked-title small { color: var(--muted); font-size: 12.5px; }
.bked-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bked-changes { font-size: 12.5px; color: var(--brand-orange); font-weight: 600; }
.bked-zoom { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 6px; }
.bked-zoom span { min-width: 44px; text-align: center; font-size: 12.5px; }
.bked-progress { position: relative; height: 26px; background: var(--peach-soft); border-bottom: 1px solid var(--line); overflow: hidden; }
.bked-progress span { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--peach); transition: width .8s ease; }
.bked-progress b { position: relative; display: block; padding: 4px 16px; font-size: 12.5px; }

.bked-body { flex: 1; display: grid; grid-template-columns: 116px minmax(0, 1fr) minmax(280px, 340px); min-height: 0; }
.bked-thumbs { overflow-y: auto; padding: 10px 8px; border-right: 1px solid var(--line); background: var(--card); display: grid; align-content: start; gap: 10px; }
.bked-thumb { display: grid; justify-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 4px; cursor: pointer; font: inherit; font-size: 11.5px; color: var(--muted); }
.bked-thumb canvas { width: 88px; height: 124px; background: #fff; }
.bked-pages { overflow: auto; padding: 24px; display: grid; justify-content: center; align-content: start; gap: 24px; outline: none; }
.bked-page { position: relative; background: #fff; box-shadow: var(--shadow-sm); border-radius: 2px; }
.bked-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.bked-pno { position: absolute; right: -34px; bottom: 6px; font-size: 12px; color: var(--muted); }
/* §402: a light frame at rest, so the parts that can be changed are seen without the mouse (and on a touch screen) */
.bked-region { position: absolute; left: 4%; right: 4%; border: 2px dashed rgba(31, 92, 115, .28); border-radius: 6px; cursor: pointer; }
.bked-region:focus-visible { outline: none; border-color: var(--brand-blue-bright); }
.bked-region.is-selected { border-color: var(--brand-orange); border-style: solid; background: rgba(217, 122, 48, .06); }
.pb-made-sub { margin: 14px 0 2px; font-size: 13.5px; color: var(--ink); }
.bked-chip { position: absolute; top: -12px; left: 8px; max-width: 90%; display: none; padding: 2px 8px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.bked-region.is-selected .bked-chip { display: block; background: var(--brand-orange); }
@media (hover: hover) { .bked-region:hover { border-color: var(--brand-blue-bright); border-style: solid; background: rgba(31, 92, 115, .04); } .bked-region:hover .bked-chip { display: block; } .bked-thumb:hover { border-color: var(--brand-blue-bright); } }

.bked-side { border-left: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.bked-tabs { display: flex; gap: 4px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.bked-tabs button { flex: 1; border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); padding: 9px 6px; border-bottom: 3px solid transparent; cursor: pointer; }
.bked-tabs button.is-on { color: var(--ink); border-bottom-color: var(--brand-orange); }
.bked-panel { overflow-y: auto; padding: 14px 16px 24px; min-height: 0; }
.bked-hint { color: var(--muted); font-size: 13.5px; display: grid; gap: 6px; }
.bked-part { display: grid; gap: 12px; }
.bked-part h3 { margin: 0; font-size: 16px; }
.bked-where { margin: 0; font-size: 12.5px; color: var(--muted); }
.bked-group { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.bked-group > b { font-size: 13px; }
/* §378: the picture that prints on the page now, above the control that replaces it */
.bked-pic-now { display: grid; gap: 4px; }
.bked-pic-now img { max-width: 100%; max-height: 120px; width: auto; border-radius: 6px; border: 1px solid var(--line); justify-self: start; }
.bked-pic-now small { color: var(--muted); font-size: 12px; }
.bked-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.bked-seg label { cursor: pointer; }
.bked-seg input { position: absolute; opacity: 0; pointer-events: none; }
.bked-seg span { display: inline-block; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12.5px; }
.bked-seg input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.bked-seg input:focus-visible + span { outline: 2px solid var(--brand-blue-bright); outline-offset: 1px; }
.bked-part-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bked-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.bked-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.bked-list li { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.bked-ideas { display: grid; gap: 4px; justify-items: start; font-size: 13px; }
.bked-first { max-width: 520px; margin: 40px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 12px; }
.bked-first h2 { margin: 0; font-size: 20px; }
.bked-first-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }

.bked-bubble { position: fixed; z-index: 4000; width: min(340px, calc(100vw - 16px)); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 12px; }
.bked-bubble-in { display: grid; gap: 8px; }
.bked-bubble-in > b { font-size: 13px; }
.bked-bubble-row { display: flex; justify-content: flex-end; }
.bked-bubble-quick { border-top: 1px solid var(--line-soft); padding-top: 6px; display: grid; }
.bked-menu { display: grid; gap: 2px; }
.bked-menu a.cb-more-item { text-decoration: none; }
.bked-menu-note { margin: 4px 6px; font-size: 12.5px; color: var(--muted); max-width: 280px; }

@media (max-width: 900px) {
  .bked-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .bked-thumbs { display: none; }
  .bked-side { border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; }
  .bked-pages { padding: 12px; }
  .bked-pno { right: 4px; }
}

/* with the ✨ assistant open (440 px at the right), the editor makes room for it: its own right column steps aside */
@media (min-width: 901px) {
  body.as-is-open .main-content.bked-open { padding-right: min(440px, 100vw); }
  body.as-is-open .bked-body { grid-template-columns: 116px minmax(0, 1fr); }
  body.as-is-open .bked-side { display: none; }
}

/* the way in, on the Printed books tab */
.pb-made-head .pb-editor-open { justify-self: start; width: auto; margin-top: 6px; }

/* §381: proposals. The proposer's banner; the tabs scroll sideways when four do not fit; a part with proposals waiting
   carries a dashed frame and its number; the proposals themselves are small cards (theme colours only, so both themes read) */
.bked-banner { padding: 8px 16px; background: rgba(217, 122, 48, .12); border-bottom: 1px solid var(--line); color: var(--ink); font-size: 13px; line-height: 1.45; }
.bked-tabs { overflow-x: auto; scrollbar-width: none; }
.bked-tabs::-webkit-scrollbar { display: none; }
.bked-tabs button { flex: 1 0 auto; white-space: nowrap; }
.bked-count { display: inline-block; min-width: 18px; margin-left: 5px; padding: 0 5px; border-radius: 999px; background: var(--brand-orange); color: #fff; font-size: 11px; line-height: 18px; text-align: center; vertical-align: 1px; }
.bked-count:empty { display: none; }
.bked-region.has-props { border-color: rgba(217, 122, 48, .6); border-style: dashed; }
.bked-region.has-props.is-selected { border-style: solid; }
.bked-mark { position: absolute; top: -11px; right: 8px; padding: 1px 7px; border-radius: 999px; background: var(--brand-orange); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; pointer-events: none; }
.bked-waiting { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 10px; padding: 8px 10px; border-radius: 8px; background: rgba(217, 122, 48, .12); color: var(--ink); font-size: 13px; }
.bked-propose-tip { margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(217, 122, 48, .12); color: var(--ink); font-size: 13px; }
.bked-props { display: grid; gap: 10px; }
.bked-myprop, .bked-prop { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: var(--ink); }
.bked-myprop { border-color: var(--brand-orange); }
.bked-prop + .bked-prop { margin-top: 2px; }
.bked-prop.is-decided { opacity: .82; }
.bked-prop-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 8px; }
.bked-prop-head b { font-size: 13px; }
.bked-prop-head small, .bked-prop-when { color: var(--muted); font-size: 12px; }
.bked-prop-changes { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-size: 13px; overflow-wrap: anywhere; }
.bked-prop-note, .bked-prop-comment, .bked-prop-reply { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.bked-prop-note { color: var(--muted); }
.bked-prop-reply { padding-left: 8px; border-left: 3px solid var(--line); }
.bked-prop-warn { margin: 0; padding: 6px 8px; border-left: 3px solid var(--brand-orange); background: rgba(217, 122, 48, .1); color: var(--ink); font-size: 12.5px; overflow-wrap: anywhere; }
.bked-prop-status { padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.bked-prop-status.is-open { border-color: var(--brand-orange); color: var(--ink); }
.bked-prop-status.is-accepted { border-color: var(--green, #2f9e74); color: var(--ink); }
.bked-prop-where { justify-self: start; padding: 0; text-align: left; font-weight: 600; }
.bked-prop-page.is-selected { border-top-color: var(--brand-orange); }
.bked-decided summary { cursor: pointer; font-size: 13px; }
.bked-decided .bked-list li { align-items: flex-start; }
.bked-decided .bked-list small { color: var(--muted); white-space: nowrap; }
.bked-comments li span { overflow-wrap: anywhere; }
.bked-bubble-note { display: block; margin: 0 6px 4px; color: var(--muted); font-size: 12px; }
@media (max-width: 900px) { .bked-banner { padding: 8px 12px; } }
/* the proposer's way in, in the course builder's row of buttons (empty until the course has a book to show) */
.cb-book-entry:empty { display: none; }
