/* ============================================================
   EBOOKERR — Demo Section Styles
   ============================================================ */

/* ── Section ── */
.demo-section { overflow: hidden; }
.demo-bottom-cta {
  text-align: center; margin-top: 40px;
}
.demo-bottom-cta p { font-size: 16px; color: rgba(255,255,255,.55); margin-bottom: 20px; }

/* ── Browser chrome ── */
.demo-browser {
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 40px 120px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.07);
  background: #0F0A1E;
}
.demo-chrome {
  background: #1A1040; padding: 12px 18px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.demo-chrome .dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.demo-chrome .dot.red    { background: #FF5F57; }
.demo-chrome .dot.yellow { background: #FEBC2E; }
.demo-chrome .dot.green  { background: #28C840; }
.demo-url-bar {
  flex: 1; background: rgba(255,255,255,.06); border-radius: 6px;
  padding: 5px 14px; font-size: 12px; color: rgba(255,255,255,.35);
  font-family: monospace; margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.demo-url-bar strong { color: rgba(255,255,255,.55); }

/* ── App ── */
.demo-app { display: flex; flex-direction: column; height: 580px; min-height: 500px; }

/* Top bar */
.demo-topbar {
  background: #0F0A1E; height: 52px; display: flex; align-items: center;
  padding: 0 16px; gap: 12px; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.demo-logo-sm {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 800; font-size: 15px; white-space: nowrap; flex-shrink: 0;
}
.demo-logo-sm svg { flex-shrink: 0; }
.demo-logo-sm .logo-dot { color: #EC4899; }
.demo-title-field {
  flex: 1; background: rgba(255,255,255,.07); border: 1.5px solid rgba(255,255,255,.1);
  border-radius: 7px; color: #fff; font-size: 14px; font-weight: 600;
  padding: 7px 14px; outline: none; font-family: inherit; min-width: 140px;
  transition: border-color .2s;
}
.demo-title-field:focus { border-color: #EC4899; background: rgba(255,255,255,.1); }
/* Always allowed to scroll horizontally, not just below the 900px
   breakpoint further down — with 8 action buttons now in this row, a
   plain desktop-width window can already run out of space just as easily,
   and without this the title field above (the only flexible item, the
   buttons are all flex-shrink:0) is what silently gets crushed to a sliver
   instead of the button row scrolling. */
.demo-top-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 1; min-width: 0; /* min-width:0 lets a flex item actually shrink below its content's natural width instead of the default "never smaller than content" */
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.demo-top-right::-webkit-scrollbar { display: none; }
.demo-top-right > * { flex-shrink: 0; } /* the buttons themselves stay full-size and scroll as a group, rather than each one individually squishing */
.demo-save-status { font-size: 11px; color: rgba(255,255,255,.35); white-space: nowrap; }
.demo-save-status.saved { color: #6EE7B7; }

.demo-tbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 7px; font-size: 12px; font-weight: 700;
  cursor: pointer; border: none; font-family: inherit; transition: all .2s; white-space: nowrap;
}
.demo-tbtn-ghost {
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.15);
}
.demo-tbtn-ghost:hover { background: rgba(255,255,255,.14); color: #fff; }
.demo-tbtn-save {
  background: linear-gradient(135deg,#10B981,#059669); color: #fff;
  box-shadow: 0 2px 10px rgba(16,185,129,.35);
}
.demo-tbtn-save:hover { box-shadow: 0 4px 16px rgba(16,185,129,.5); }

/* Body */
.demo-body {
  display: grid; grid-template-columns: 200px 1fr 200px; grid-template-rows: minmax(0, 1fr);
  flex: 1; min-height: 0; overflow: hidden;
}

/* Chapter sidebar */
.demo-ch-col {
  background: #0D0928; display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.06); overflow: hidden; min-height: 0;
}
.demo-ch-hdr {
  padding: 12px 14px 8px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06); flex-shrink: 0;
}
.demo-ch-hdr > span:first-child { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: rgba(255,255,255,.35); text-transform: uppercase; }
.demo-ch-badge { font-size: 11px; color: rgba(255,255,255,.3); background: rgba(255,255,255,.07); padding: 2px 7px; border-radius: 10px; }

.demo-ch-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 0; scrollbar-color: rgba(255,255,255,.7) transparent; scrollbar-width: thin; }
.demo-ch-list::-webkit-scrollbar { width: 6px; }
.demo-ch-list::-webkit-scrollbar-track { background: transparent; }
.demo-ch-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.7); border-radius: 3px; }
.demo-ch-list::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.9); }

.demo-ch-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 12px 9px 6px; cursor: pointer; border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.demo-ch-item:hover { background: rgba(255,255,255,.04); }
.demo-ch-item.active {
  background: rgba(124,58,237,.25); border-left-color: #EC4899;
}
.demo-ch-drag {
  flex-shrink: 0; width: 14px; text-align: center; cursor: grab;
  color: rgba(255,255,255,.2); font-size: 12px; opacity: 0; transition: opacity .15s, color .15s;
}
.demo-ch-item:hover .demo-ch-drag { opacity: 1; }
.demo-ch-drag:hover { color: rgba(255,255,255,.55); }
.demo-ch-item.dragging { opacity: .35; }
.demo-ch-item.drag-over-top { box-shadow: inset 0 2px 0 #EC4899; }
.demo-ch-item.drag-over-bottom { box-shadow: inset 0 -2px 0 #EC4899; }
.demo-ch-num {
  width: 20px; height: 20px; border-radius: 5px;
  background: rgba(255,255,255,.07); display: flex; align-items: center;
  justify-content: center; font-size: 10px; font-weight: 700; color: rgba(255,255,255,.4); flex-shrink: 0;
}
.demo-ch-item.active .demo-ch-num { background: #EC4899; color: #fff; }
/* Touch-only reorder controls (see IS_TOUCH in creator.js) - always
   visible since touch devices have no hover state to reveal them with. */
.demo-ch-move { flex-shrink: 0; display: flex; flex-direction: column; gap: 1px; }
.demo-ch-move-btn {
  background: none; border: none; color: rgba(255,255,255,.35); cursor: pointer;
  font-size: 8px; line-height: 1; padding: 2px; min-height: 0;
}
.demo-ch-move-btn:active { color: rgba(255,255,255,.8); }
.demo-ch-label {
  font-size: 12px; color: rgba(255,255,255,.6); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500;
}
.demo-ch-item.active .demo-ch-label { color: #fff; font-weight: 600; }
.demo-ch-del {
  opacity: 0; background: none; border: none; color: rgba(255,255,255,.3);
  cursor: pointer; font-size: 12px; padding: 2px 4px; line-height: 1;
  transition: opacity .15s, color .15s;
}
.demo-ch-item:hover .demo-ch-del { opacity: 1; }
.demo-ch-del:hover { color: #EF4444; }
/* Touch devices have no hover state, so a delete button that only
   appears on hover needs a first tap just to reveal it - which looks
   exactly like "nothing happens" and the second tap can miss. Keep it
   visible (dimmed) at all times wherever hover can't be relied on. */
@media (hover: none) {
  .demo-ch-del { opacity: .6; }
}

/* Part divider item in the chapter list */
.demo-ch-item.demo-part-item { padding-left: 6px; margin: 4px 0; }
.demo-ch-item.demo-part-item:not(.active) { background: rgba(255,255,255,.03); }
.demo-part-label {
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  color: rgba(236,72,153,.85); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.demo-ch-item.demo-part-item.active .demo-part-label { color: #fff; }

.demo-add-wrap { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.demo-add-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: rgba(124,58,237,.18); border: 1.5px dashed rgba(124,58,237,.45);
  color: rgba(255,255,255,.6); border-radius: 7px; padding: 9px;
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; transition: all .2s;
}
.demo-add-btn:hover { background: rgba(124,58,237,.3); border-color: #EC4899; color: #fff; }
.demo-add-btn-ghost { background: transparent; border-color: rgba(255,255,255,.15); color: rgba(255,255,255,.5); }
.demo-add-btn-ghost:hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.3); color: rgba(255,255,255,.85); }

/* Editor column */
.demo-editor-col {
  background: #F5F3FF; display: flex; flex-direction: column;
  overflow-y: auto; min-height: 0; gap: 14px; padding: 20px;
  scrollbar-width: auto; scrollbar-color: #B0B7C3 #EDEBFB;
}
.demo-editor-col::-webkit-scrollbar { width: 14px; }
.demo-editor-col::-webkit-scrollbar-track { background: #EDEBFB; }
.demo-editor-col::-webkit-scrollbar-thumb { background: #B0B7C3; border-radius: 7px; border: 3px solid #EDEBFB; }
.demo-editor-col::-webkit-scrollbar-thumb:hover { background: #8B93A3; }

.demo-ch-title-inp {
  width: 100%; border: none; border-bottom: 2.5px solid #E5E7EB;
  padding: 8px 0; font-size: 20px; font-weight: 800; color: #1F2937;
  background: transparent; outline: none; font-family: inherit; transition: border-color .2s;
}
.demo-ch-title-inp:focus { border-bottom-color: #7C3AED; }
.demo-ch-title-inp::placeholder { color: #D1D5DB; }

.demo-img-drop {
  border: 2px dashed #D1D5DB; border-radius: 10px; padding: 20px;
  text-align: center; cursor: pointer; transition: all .2s; background: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.demo-img-drop:hover { border-color: #7C3AED; background: #F5F3FF; }
.demo-img-drop svg { color: #7C3AED; opacity: .5; }
.demo-img-drop strong { font-size: 13px; color: #374151; }
.demo-img-drop span  { font-size: 12px; color: #9CA3AF; }

.demo-rich-wrap {
  flex: 1; background: #fff; border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06); overflow: hidden; display: flex; flex-direction: column;
  min-height: 180px;
}
.demo-rich-toolbar {
  background: #FAFAFA; padding: 8px 14px; border-bottom: 1px solid #E5E7EB;
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
}
.dtb {
  background: none; border: none; padding: 5px 8px; border-radius: 5px; font-size: 12px;
  font-weight: 700; color: #6B7280; cursor: pointer; font-family: inherit; transition: all .15s;
}
.dtb:hover { background: #F3F4F6; color: #1F2937; }
.dtb-sep { width: 1px; height: 16px; background: #E5E7EB; margin: 0 4px; }
.demo-rich-editor {
  flex: 1; padding: 16px 20px; font-size: 14px; color: #374151; line-height: 1.75;
  outline: none; overflow-y: auto;
}
.demo-rich-editor:empty::before { content: attr(data-placeholder); color: #C0C6D0; }
.demo-rich-editor p { margin-bottom: 12px; }
.demo-rich-editor h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.demo-rich-editor blockquote { border-left: 3px solid #7C3AED; padding: 8px 16px; margin: 12px 0; background: #F5F3FF; border-radius: 0 6px 6px 0; font-style: italic; color: #6B7280; }

/* Settings panel */
.demo-settings-col {
  background: #fff; border-left: 1px solid #E5E7EB;
  overflow-y: auto; min-height: 0; display: flex; flex-direction: column;
  scrollbar-color: #C4B5FD transparent; scrollbar-width: thin;
}
.demo-settings-col::-webkit-scrollbar { width: 7px; }
.demo-settings-col::-webkit-scrollbar-track { background: transparent; }
.demo-settings-col::-webkit-scrollbar-thumb { background: #C4B5FD; border-radius: 4px; }
.demo-settings-col::-webkit-scrollbar-thumb:hover { background: #A78BFA; }
.demo-panel-sec { padding: 16px 14px; border-bottom: 1px solid #E5E7EB; }
.demo-panel-lbl { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #9CA3AF; margin-bottom: 12px; }
.demo-cover-drop {
  aspect-ratio: 3/4; border: 2px dashed #E5E7EB; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #F9FAFB; cursor: pointer; transition: all .2s; margin-bottom: 10px; overflow: hidden;
}
.demo-cover-drop:hover { border-color: #7C3AED; background: #F5F3FF; }
.demo-cover-inner { font-size: 32px; }
.demo-cover-drop.has-cover { padding: 0; }
.demo-cover-drop.has-cover .demo-cover-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#7C3AED,#EC4899); color: #fff; font-size: 40px; }
.demo-upload-btn {
  width: 100%; background: #F3F4F6; border: 1px solid #E5E7EB; border-radius: 7px;
  padding: 8px; font-size: 12px; font-weight: 600; color: #374151; cursor: pointer;
  font-family: inherit; transition: all .2s;
}
.demo-upload-btn:hover { background: #E5E7EB; }
.demo-input-row { margin-bottom: 10px; }
.demo-input-row label { display: block; font-size: 11px; font-weight: 600; color: #9CA3AF; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.demo-input {
  width: 100%; border: 1.5px solid #E5E7EB; border-radius: 6px;
  padding: 7px 10px; font-size: 12px; color: #374151; font-family: inherit;
  outline: none; background: #F9FAFB; transition: border-color .2s; box-sizing: border-box;
}
.demo-input:focus { border-color: #7C3AED; background: #fff; }
.demo-export-btn {
  width: 100%; background: linear-gradient(135deg,#7C3AED,#EC4899); color: #fff;
  border: none; border-radius: 8px; padding: 10px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit; display: flex; align-items: center; justify-content: center;
  gap: 7px; transition: opacity .2s; box-shadow: 0 3px 12px rgba(124,58,237,.3);
}
.demo-export-btn:hover { opacity: .88; }
.demo-export-btn.loading { opacity: .6; pointer-events: none; }
.demo-export-btn.done { background: linear-gradient(135deg,#10B981,#059669); box-shadow: 0 3px 12px rgba(16,185,129,.3); }

/* ── Preview Modal ── */
.demo-modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,6,28,.92); backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transition: opacity .3s ease;
}
.demo-modal-overlay.open { opacity: 1; pointer-events: all; }
.demo-modal-inner { display: flex; flex-direction: column; height: 100%; }
.demo-modal-bar {
  background: #0F0A1E; padding: 12px 24px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.demo-modal-bar span:first-child { color: rgba(255,255,255,.7); font-size: 14px; font-weight: 600; }
/* The faint default ghost style reads as barely-there against this bar's
   near-black background, right next to a bold green "Save as PDF" button -
   the one button people actually need to find (get back to editing) was
   the hardest one to see. Give it real contrast without turning it into a
   competing call-to-action. */
#crModalBack {
  background: rgba(255,255,255,.16);
  color: #fff;
  border-color: rgba(255,255,255,.32);
  font-weight: 700;
}
#crModalBack:hover { background: rgba(255,255,255,.28); }
.demo-modal-close {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.7); padding: 7px 14px; border-radius: 7px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all .2s;
}
.demo-modal-close:hover { background: rgba(255,255,255,.18); color: #fff; }
.demo-modal-book {
  flex: 1; overflow-y: auto; background: #F8F7F4;
  display: flex; justify-content: center; padding: 40px 20px;
}
.demo-modal-book::-webkit-scrollbar { width: 6px; }
.demo-modal-book::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
.demo-book-inner {
  width: 100%; max-width: 680px; background: #fff;
  box-shadow: 0 0 60px rgba(0,0,0,.15); border-radius: 4px; overflow: hidden;
}
.demo-book-cover {
  background: linear-gradient(135deg, #7C3AED, #EC4899);
  aspect-ratio: 3/4; max-height: 500px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 60px 50px;
  text-align: center; gap: 14px;
}
.demo-book-cover h1 { font-size: clamp(24px,4vw,40px); font-weight: 900; color: #fff; line-height: 1.15; }
.demo-book-cover .sub { font-size: 16px; font-style: italic; color: rgba(255,255,255,.8); }
.demo-book-cover .auth { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: rgba(255,255,255,.6); font-weight: 600; }
.demo-book-toc { padding: 50px 60px; border-bottom: 2px solid #EDEDED; }
.demo-book-toc h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 3px; color: #9CA3AF; margin-bottom: 28px; font-family: sans-serif; }
.demo-toc-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dotted #E5E7EB; }
.demo-toc-n { font-size: 11px; color: #7C3AED; font-weight: 700; width: 30px; flex-shrink: 0; font-family: sans-serif; }
.demo-toc-t { font-size: 15px; color: #1F2937; font-weight: 600; }
.demo-book-chapter { padding: 60px 60px 50px; border-bottom: 2px solid #EDEDED; }
.demo-ch-n { font-size: 10px; text-transform: uppercase; letter-spacing: 3px; color: #7C3AED; font-weight: 700; margin-bottom: 8px; font-family: sans-serif; }
.demo-ch-h { font-size: clamp(20px,3vw,30px); font-weight: 900; color: #1E1B4B; margin-bottom: 16px; }
.demo-ch-divider { width: 48px; height: 3px; background: linear-gradient(90deg,#7C3AED,#EC4899); border-radius: 2px; margin-bottom: 24px; }
.demo-ch-txt { font-size: 15px; line-height: 1.8; color: #374151; }
.demo-ch-txt p { margin-bottom: 14px; }

/* ── Cover color swatches ── */
.demo-cover-colors {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px;
}
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; transform: scale(1.1); box-shadow: 0 0 0 2px #7C3AED; }

/* ── Stats ── */
.demo-stats { display: flex; gap: 12px; }
.demo-stat {
  flex: 1; text-align: center; background: #F9FAFB; border-radius: 8px; padding: 10px;
  border: 1px solid #E5E7EB;
}
.demo-stat span { display: block; font-size: 20px; font-weight: 800; color: #7C3AED; line-height: 1; }
.demo-stat small { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #9CA3AF; font-weight: 600; }

/* ── Empty state ── */
.demo-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #9CA3AF; text-align: center; padding: 40px; height: 100%;
}
.demo-empty-state svg { opacity: .25; }
.demo-empty-state h3 { font-size: 16px; font-weight: 700; color: #374151; }
.demo-empty-state p  { font-size: 13px; }

/* ── Editor placeholder ── */
.demo-rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #C0C6D0; pointer-events: none;
}

/* ── Demo bottom CTA ── */
.demo-cta-badges {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.demo-cta-badges span { font-size: 13px; color: rgba(255,255,255,.5); }

/* ── Reset button in chrome ── */
.demo-clear-btn {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.4); padding: 4px 10px; border-radius: 5px;
  font-size: 11px; cursor: pointer; font-family: inherit; transition: all .2s; flex-shrink: 0;
}
.demo-clear-btn:hover { color: #EF4444; border-color: rgba(239,68,68,.4); }

/* ── Modal iframe wrapper ── */
.demo-modal-book iframe { display: block; width: 100%; height: 100%; border: none; }

/* ── Preview modal: make book scrollable ── */
.demo-modal-book {
  flex: 1; overflow: hidden; background: #F8F7F4; display: flex;
  flex-direction: column;
}

/* Settings/chapters panels: toggle buttons only shown once they become
   off-canvas drawers below (desktop keeps both visible as normal columns). */
.cr-settings-toggle-btn, .cr-ch-toggle-btn { display: none; }

/* Responsive */
@media (max-width: 900px) {
  .cr-settings-toggle-btn, .cr-ch-toggle-btn { display: inline-flex; }

  /* Both side columns become full-height off-canvas drawers instead of grid
     columns — previously the chapter list was just display:none below 640px
     with no way to reopen it at all, which made the editor unusable on
     phones (no way to switch chapters, add a chapter, or see the list). */
  .demo-body { grid-template-columns: 1fr; }

  .demo-ch-col {
    position: fixed; top: 0; left: -320px; width: 300px; max-width: 88vw; height: 100vh;
    z-index: 10001; box-shadow: 8px 0 30px rgba(0,0,0,.25);
    transition: left .25s ease;
  }
  .demo-ch-col.open { left: 0; }

  .demo-settings-col {
    position: fixed; top: 0; right: -320px; width: 300px; max-width: 88vw; height: 100vh;
    z-index: 10001; box-shadow: -8px 0 30px rgba(0,0,0,.25);
    transition: right .25s ease;
  }
  .demo-settings-col.open { right: 0; }

  .cr-settings-overlay, .cr-ch-overlay {
    position: fixed; inset: 0; background: rgba(15,10,30,.5);
    z-index: 10000; opacity: 0; visibility: hidden; transition: opacity .2s;
  }
  .cr-settings-overlay.open, .cr-ch-overlay.open { opacity: 1; visibility: visible; }
  body.admin-bar .demo-settings-col, body.admin-bar .demo-ch-col,
  body.admin-bar .cr-settings-overlay, body.admin-bar .cr-ch-overlay { top: 32px; }
  body.admin-bar .demo-settings-col, body.admin-bar .demo-ch-col { height: calc(100vh - 32px); }

  /* Topbar: too many buttons for a phone width to ever fit in one row without
     either cutting some off (the old bug) or shrinking them unreadably —
     let the button row scroll horizontally instead, so every button stays
     reachable with a swipe, and shrink the title field so it doesn't eat
     all the remaining space. */
  .demo-topbar { padding: 0 10px; gap: 8px; height: auto; min-height: 52px; flex-wrap: wrap; }
  .demo-title-field { min-width: 90px; }
  .demo-top-right {
    flex-shrink: 1; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; max-width: 100%;
  }
  .demo-top-right::-webkit-scrollbar { display: none; }
  .demo-tbtn { flex-shrink: 0; }
}
@media (max-width: 640px) {
  .demo-cta-badges { flex-direction: column; align-items: center; }
}
