/* LaunchCo Training Platform — foundation styles.
   Brand tokens are CSS variables; app.js overrides them at load from /api/branding,
   so the whole look is swappable per install. */

:root {
  /* Brand (defaults mirror lib/branding.js; JS overrides from settings) */
  --ink: #0c0f0a;
  --blue: #48639c;
  --accent: #bf2e8f;
  --sand: #e0dad2;
  --white: #ffffff;
  --black: #000000;
  --font-headline: 'Kdam Thmor Pro', system-ui, sans-serif;
  --font-body: 'Dosis', system-ui, sans-serif;

  /* Derived UI tokens */
  --bg: #f5f4f1;
  --panel: #ffffff;
  --line: #e7e3dc;
  --muted: #757067;
  --text: #23211d;
  --accent-ink: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(12, 15, 10, 0.06), 0 8px 24px rgba(12, 15, 10, 0.06);
  --sidebar-w: 244px;
  --header-h: 60px;
}

* { box-sizing: border-box; }
/* Global UI scale: rem is relative to this root size, so lowering it shrinks all
   rem-based text and spacing app-wide. Tuned down from 16px so the app (built on a
   4K screen) fits a normal HD monitor. Nudge this one number to rescale everything. */
html { font-size: 14.5px; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .headline { font-family: var(--font-headline); font-weight: 400; letter-spacing: 0.2px; }
a { color: var(--blue); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--text);
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.04s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: #cfc9bf; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn-danger { color: #b3261e; border-color: #e7c3c0; background: transparent; }
.btn-danger:hover { background: #b3261e; color: #fff; border-color: #b3261e; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(191, 46, 143, 0.14), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(72, 99, 156, 0.16), transparent 55%), var(--bg);
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.login-card .logo { height: 40px; margin-bottom: 1.5rem; }
.login-card h1 { font-size: 1.35rem; margin: 0 0 0.35rem; }
.login-card .sub { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.95rem; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 1rem; }
.field > label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
.field input, .field select, .field textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(191, 46, 143, 0.12);
}
.field textarea { min-height: 88px; resize: vertical; }
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.form-row .field { flex: 1 1 180px; }
.form-error { color: #b3261e; font-size: 0.9rem; margin: 0.25rem 0 0.75rem; min-height: 1.1em; }

/* ---------- App shell: top logo bar + icon rail + tree + content ---------- */
:root { --rail-w: 58px; --tree-w: 248px; --top-h: 62px; --rail-bg: #e0dad2; --topbar-logo-h: 44px; }
.app3 { display: grid; grid-template-columns: var(--rail-w) var(--tree-w) 1fr; grid-template-rows: var(--top-h) 1fr; height: 100vh; overflow: hidden; }
.app3.notree { grid-template-columns: var(--rail-w) 1fr; }
.app3.menuhidden { grid-template-columns: 1fr; }

.topbar { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; gap: 20px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 20px; }
.topbar-logo img { height: var(--topbar-logo-h); max-width: 320px; object-fit: contain; display: block; }
.topbar-main { display: flex; align-items: center; gap: 14px; }
.menutoggle { font-family: var(--font-body); font-weight: 600; }
.topbar-title { font-family: var(--font-headline); color: var(--muted); font-size: 1rem; }

/* Icon rail */
.rail { background: var(--rail-bg); border-right: 1px solid rgba(12, 15, 10, .1); display: flex; flex-direction: column; align-items: center; padding: 12px 0 14px; gap: 6px; height: 100%; overflow: auto; }
.rail-brand { width: 42px; height: 42px; border-radius: 11px; overflow: hidden; display: grid; place-items: center; margin-bottom: 10px; background: #fff; box-shadow: 0 1px 2px rgba(12, 15, 10, .08); }
.rail-brand img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.rail-top { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rail-bottom { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.rail-btn { position: relative; width: 46px; height: 46px; border-radius: 13px; border: none; background: transparent; color: #5f594f; display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s; }
.rail-btn:hover { background: rgba(12, 15, 10, .08); color: var(--ink); }
.rail-btn.active { background: transparent; color: var(--accent); }
.rail-btn.active:hover { background: rgba(12, 15, 10, .06); }
.rail-btn.active::before { content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--accent); }
.rail-ic { width: 22px; height: 22px; display: grid; place-items: center; }
.rail-ic svg { width: 22px; height: 22px; }
.rail-ic.av { position: relative; width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: #fff; font-size: .8rem; font-weight: 700; font-family: var(--font-headline); overflow: hidden; }
.rail-av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* System-wide tooltip (driven by data-tip / auto-upgraded title attributes) */
.tooltip { position: fixed; z-index: 1000; background: var(--ink); color: #fff; font-family: var(--font-body); font-size: .82rem; font-weight: 600; line-height: 1.3; padding: 6px 10px; border-radius: 8px; box-shadow: 0 4px 14px rgba(12, 15, 10, .22); pointer-events: none; opacity: 0; transform: translateY(1px); transition: opacity .12s ease, transform .12s ease; max-width: 260px; }
.tooltip.show { opacity: 1; transform: translateY(0); }
.tooltip::after { content: ''; position: absolute; border: 5px solid transparent; }
.tooltip[data-pos="right"]::after { right: 100%; top: 50%; transform: translateY(-50%); border-right-color: var(--ink); }
.tooltip[data-pos="left"]::after { left: 100%; top: 50%; transform: translateY(-50%); border-left-color: var(--ink); }
.tooltip[data-pos="top"]::after { top: 100%; left: 50%; transform: translateX(-50%); border-top-color: var(--ink); }
.tooltip[data-pos="bottom"]::after { bottom: 100%; left: 50%; transform: translateX(-50%); border-bottom-color: var(--ink); }
.vbadge { font-size: .74rem; font-weight: 600; color: #5f594f; font-family: var(--font-body); }
.vbadge.warn { color: #ffcf5a; }

/* Tree column */
.treecol { background: var(--panel); border-right: 1px solid var(--line); height: 100%; overflow: auto; }
.tree-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 8px; font-family: var(--font-headline); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tree-body { padding: 0 8px 16px; }
.tr-course { margin-bottom: 2px; }
.tr-row { display: flex; align-items: center; gap: 6px; border-radius: 8px; cursor: pointer; }
.tr-courserow { padding: 8px; font-weight: 700; }
.tr-courserow:hover { background: #f0ede8; }
.tr-courserow.sel { background: rgba(72, 99, 156, .12); }
.tr-caret { width: 14px; color: var(--muted); font-size: .8rem; text-align: center; }
.tr-cname { flex: 1; font-size: .95rem; }
.tr-chap { margin: 2px 0 4px 15px; border-left: 1px solid var(--line); padding-left: 6px; }
.tr-chaprow { padding: 3px 4px; }
.tr-chtitle { flex: 1; border: 1px solid transparent; background: transparent; font-family: var(--font-body); font-weight: 700; font-size: .85rem; padding: 3px 5px; border-radius: 6px; color: var(--text); min-width: 0; }
.tr-chtitle:focus { outline: none; background: #fff; border-color: var(--accent); }
.tr-chname { flex: 1; font-weight: 700; font-size: .85rem; padding: 3px 5px; }
.tr-page { padding: 5px 8px; margin-left: 6px; font-size: .9rem; color: var(--text); }
.tr-page:hover { background: #f0ede8; }
.tr-page.sel { background: rgba(191, 46, 143, .12); color: var(--accent); font-weight: 600; }
.tr-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; flex: 0 0 auto; }
.tr-pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-pactions { display: none; gap: 2px; flex: 0 0 auto; }
.tr-page:hover .tr-pactions { display: inline-flex; }
.tr-add { display: block; width: calc(100% - 6px); margin: 3px 0 8px 6px; text-align: left; border: 1px dashed var(--line); background: transparent; color: var(--muted); font-size: .82rem; padding: 4px 9px; border-radius: 6px; cursor: pointer; font-family: var(--font-body); }
.tr-add:hover { border-color: var(--accent); color: var(--accent); }
.tr-loading { padding: 6px 12px; color: var(--muted); font-size: .85rem; }

/* Sessions tree (status groups) */
.tr-group { margin-bottom: 4px; }
.tr-sub { margin-left: 12px; }
.tr-sub .tr-grouprow { font-weight: 600; font-size: .9rem; }
.tree-search { padding: 10px 10px 6px; }
.tree-search input { width: 100%; font-family: var(--font-body); font-size: .88rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fbfaf8; color: var(--text); }
.tree-search input:focus { outline: none; border-color: var(--accent); background: #fff; }
.tr-searchhint { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 4px 10px 6px; }
.tr-usub { font-size: .74rem; color: var(--muted); margin-left: 6px; }
.tr-check { flex: 0 0 auto; margin: 0; cursor: pointer; accent-color: var(--accent); }
.tr-name-click { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.tr-session.checked { background: rgba(72, 99, 156, .1); }
.tools-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 1.1rem; }

/* Docked "TOOLS" tab + slide-out drawer (Users multi-select). Overlays the content;
   the tree and detail stay put behind it. */
.toolsdock { position: fixed; top: var(--top-h); right: 0; bottom: 0; width: 0; z-index: 60; }
.toolsdock-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 340px; max-width: 86vw;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(12, 15, 10, .12);
  transform: translateX(100%); transition: transform .22s ease;
  display: flex; flex-direction: column; overflow: hidden;
}
.toolsdock.open .toolsdock-panel { transform: translateX(0); }
.toolsdock-tab {
  position: absolute; top: 26px; left: -42px; width: 42px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 0 10px; border: 1px solid var(--line); border-right: none;
  border-radius: 10px 0 0 10px; background: var(--panel); color: var(--text);
  cursor: pointer; box-shadow: -6px 0 18px rgba(12, 15, 10, .10);
  font-family: var(--font-body);
}
.toolsdock-tab:hover { color: var(--accent); }
.toolsdock-tab .td-caret { font-size: 1rem; line-height: 1; color: var(--muted); }
.toolsdock-tab .td-label { writing-mode: vertical-rl; text-orientation: mixed; letter-spacing: .16em; font-weight: 700; font-size: .74rem; }
.toolsdock-tab .td-badge {
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}
.td-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.td-title { margin: 0; font-family: var(--font-headline); font-size: 1.05rem; }
.td-count { font-size: .82rem; color: var(--accent); font-weight: 600; margin-top: 2px; }
.td-body { padding: 14px 16px; overflow: auto; flex: 1; }
.td-tool { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.td-tool + .td-tool { margin-top: 12px; }
.td-tool-title { margin: 0 0 4px; font-size: .96rem; }
.td-tool-note { margin: 0 0 10px; font-size: .82rem; color: var(--muted); line-height: 1.45; }
.td-tool-go { width: 100%; margin-top: 4px; }
.tr-grouprow { padding: 7px 8px; font-weight: 700; }
.tr-grouprow:hover { background: #f0ede8; }
.tr-session { padding: 6px 8px; margin-left: 6px; font-size: .92rem; color: var(--text); }
.tr-session:hover { background: #f0ede8; }
.tr-session.sel { background: rgba(191, 46, 143, .12); color: var(--accent); font-weight: 600; }
.tr-dot.live { background: #2a8a52; opacity: 1; }
.tr-dot.scheduled { background: var(--blue); opacity: 1; }
.tr-dot.ended { background: #b9b4ab; opacity: 1; }
.tr-dot.off { background: #c9c4bb; opacity: 1; }

.detail-grid { display: flex; gap: 2rem; flex-wrap: wrap; }
.detail-grid .dl { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .2rem; }

/* Content */
.content { overflow: auto; height: 100%; padding: 1.4rem 1.7rem; }
.content-pad { padding: 0; }
.editor-wrap { display: flex; flex-direction: column; }

/* User menu popup (anchored off the rail avatar) */
.user-menu { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .85rem; min-width: 210px; z-index: 200; display: flex; flex-direction: column; gap: .6rem; }
.um-head strong { font-family: var(--font-headline); }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.page-head .sub { color: var(--muted); margin: 0.25rem 0 0; }

/* ---------- Panels / cards / tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1.25rem; }
/* Course settings: single full-width column — each block spans the full width. */
.course-cols { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
.course-col-left, .course-col-right { min-width: 0; }
/* Colour swatch + editable hex field pair */
.colorpair { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.colorpair input[type=color] { width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; cursor: pointer; }
.colorpair input[type=color]::-webkit-color-swatch { border: none; border-radius: 50%; }
.hexin { width: 84px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-mono, ui-monospace, monospace); font-size: .82rem; text-transform: lowercase; background: #fff; color: var(--text); }
.hexin:focus { outline: none; border-color: var(--accent); }
.hexin.bad { border-color: #b3261e; }
.danger-zone { border-color: #e7c9c9; }
.danger-zone .panel-title { color: #b3261e; }
.btn.danger, .btn-ghost.danger { color: #b3261e; border-color: #e0b4b0; }
.btn.danger:hover, .btn-ghost.danger:hover { background: #b3261e; color: #fff; border-color: #b3261e; }
/* Typed-delete confirmation overlay */
.modal-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(12,15,10,.42); display: grid; place-items: center; padding: 20px; }
.modal-card { background: var(--panel); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(12,15,10,.35); padding: 22px; max-width: 440px; width: 100%; }
.modal-card h3 { color: #b3261e; }
.del-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 1rem; background: #fff; color: var(--text); }
.del-input:focus { outline: none; border-color: #b3261e; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
/* Archived view rows */
.arch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.arch-row:first-of-type { border-top: none; }
.arch-meta { display: flex; flex-direction: column; min-width: 0; }
.arch-title { font-weight: 600; }
.arch-sub { font-size: .78rem; color: var(--muted); }
/* ...but not when panels sit side-by-side in a grid or in a gap'd flex column,
   which provide their own spacing — otherwise the 2nd column is pushed down. */
.grid-2 > .panel + .panel,
.pv-side .panel + .panel,
.lv-side .panel + .panel,
.detail-main .panel + .panel,
.detail-side .panel + .panel,
.detail-col .panel + .panel { margin-top: 0; }

/* Detail pages: two top-aligned columns, each a flex column with its own gap. */
.detail-2col { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.detail-main, .detail-side, .detail-col { display: flex; flex-direction: column; gap: 1.25rem; }
.detail-col { max-width: 680px; }
@media (max-width: 900px) { .detail-2col { grid-template-columns: 1fr; } }
.panel-body { padding: 1.25rem; }
.panel-title { font-size: 1.05rem; margin: 0 0 1rem; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--line); font-size: 0.94rem; }
table.grid th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
table.grid tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: #efece7; color: var(--muted); }
.badge.on { background: rgba(72, 99, 156, 0.14); color: var(--blue); }
.badge.role { text-transform: capitalize; }
.badge.status-published { background: rgba(46, 160, 90, 0.15); color: #2a8a52; }
.badge.status-draft { background: #efece7; color: var(--muted); }
.badge.status-archived { background: #efe3e0; color: #a05; }

.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty h3 { margin: 0 0 0.35rem; color: var(--text); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
/* Brand colour swatches laid out several per row (uses the full width) */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px 14px; margin-bottom: 14px; }
.color-grid .field { margin-bottom: 0; min-width: 0; }
.color-grid .swatch-row { gap: 6px; }
.color-grid .swatch-row input[type=text] { max-width: none; width: 100%; min-width: 0; }
/* Brand button styles: all on one row, each a compact card with the preview below */
.bstyle-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.bstyle-cell { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.bstyle-cell .bstyle-label { flex: none; width: 100%; }
.bstyle-cell .bstyle-swatches { display: flex; gap: 10px; }
.bstyle-cell .bstyle-prev { margin-left: 0; }
.checklist { display: grid; gap: 0.35rem; max-height: 260px; overflow: auto; }
.checklist label { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 0.94rem; }
.swatch-row { display: flex; gap: 0.5rem; align-items: center; }
.swatch-row input[type='color'] { width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; }
/* Native colour inputs ignore border-radius unless appearance is reset — round them all. */
input[type='color'], input[type=color] { -webkit-appearance: none; -moz-appearance: none; appearance: none; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: inherit; }
input[type=color]::-moz-color-swatch { border: none; border-radius: inherit; }

.inline-note { color: var(--muted); font-size: 0.86rem; }
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 0.7rem 1.1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 0.92rem; }
.toast.err { background: #b3261e; }
.toast.ok { background: #2a8a52; }

/* ---------- Course builder ---------- */
.builder { display: grid; grid-template-columns: 300px 1fr; gap: 1.25rem; align-items: start; }
.tree-panel .panel-body { padding: 0.85rem; }
.chap { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 0.6rem; overflow: hidden; }
.chap-head { display: flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.5rem; background: #f4f1ec; }
.chap-title { flex: 1; border: 1px solid transparent; background: transparent; font-family: var(--font-body); font-weight: 700; font-size: 0.95rem; padding: 0.2rem 0.35rem; border-radius: 6px; color: var(--text); }
.chap-title:focus { outline: none; background: #fff; border-color: var(--accent); }
.row-actions { display: inline-flex; gap: 2px; }
.icon-btn { width: 24px; height: 24px; line-height: 1; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 0; }
.icon-btn:hover { border-color: #cfc9bf; color: var(--text); }
.icon-btn.danger:hover { background: #b3261e; color: #fff; border-color: #b3261e; }
.pagelist { padding: 0.4rem 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.page-item { display: flex; align-items: center; gap: 0.35rem; border-radius: 6px; padding: 0.1rem 0.15rem; }
.page-item.sel { background: rgba(191, 46, 143, 0.1); }
.page-name { flex: 1; text-align: left; border: none; background: transparent; cursor: pointer; font-family: var(--font-body); font-size: 0.92rem; padding: 0.3rem 0.4rem; color: var(--text); border-radius: 6px; }
.page-item.sel .page-name { color: var(--accent); font-weight: 600; }
.page-name:hover { background: #f0ede8; }
.addpage { align-self: flex-start; margin-top: 0.15rem; }

.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.85rem; flex-wrap: wrap; }
#page-title-input { flex: 1; min-width: 180px; font-family: var(--font-headline); font-size: 1.15rem; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.45rem 0.6rem; }
#page-title-input:focus { outline: none; border-color: var(--accent); }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; height: 560px; }
#page-html { width: 100%; height: 100%; resize: none; font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; font-size: 0.86rem; line-height: 1.5; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.75rem; background: #fbfaf8; color: #23211d; white-space: pre; overflow: auto; }
#page-html:focus { outline: none; border-color: var(--accent); }
.preview { width: 100%; height: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.preview-solo { height: calc(100vh - 190px); min-height: 420px; box-shadow: var(--shadow); }

@media (max-width: 980px) {
  .builder { grid-template-columns: 1fr; }
  .editor-split { grid-template-columns: 1fr; height: auto; }
  #page-html { height: 300px; }
  .preview { height: 360px; }
}

/* ---------- Live engine (presenter + participant) ---------- */
.present { display: grid; grid-template-columns: 210px 1fr 300px; gap: 1rem; align-items: start; }
.live { display: grid; grid-template-columns: 1fr 300px; gap: 1rem; align-items: start; }
.pv-tree .panel-body { padding: 0.75rem; max-height: 640px; overflow: auto; }
.pv-chap { margin-bottom: 0.6rem; }
.pv-chap-t { font-family: var(--font-headline); font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.pv-page { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 0.35rem 0.5rem; border-radius: 6px; cursor: pointer; font-family: var(--font-body); font-size: 0.9rem; color: var(--text); }
.pv-page:hover { background: #f0ede8; }
.pv-page.cur { background: rgba(191, 46, 143, 0.12); color: var(--accent); font-weight: 600; }
.pv-controls { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.live-frame { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.pv-side, .lv-side { display: flex; flex-direction: column; gap: 1rem; }
.pv-side .panel-body, .lv-side .panel-body { padding: 0.85rem; }

.people { display: flex; flex-direction: column; gap: 0.3rem; max-height: 160px; overflow: auto; }
.person { display: flex; align-items: center; gap: 0.45rem; font-size: 0.92rem; }
.pdot { width: 8px; height: 8px; border-radius: 50%; background: #2a8a52; display: inline-block; }
.pdot.t { background: var(--accent); }

.chat { height: 200px; overflow: auto; display: flex; flex-direction: column; gap: 0.3rem; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.5rem; background: #fbfaf8; margin-bottom: 0.5rem; }
.chat-msg { font-size: 0.9rem; }
.chat-who { font-weight: 700; color: var(--blue); }
.chat-form { display: flex; gap: 0.4rem; }
.chat-form input { flex: 1; padding: 0.45rem 0.55rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); }
.chat-form input:focus { outline: none; border-color: var(--accent); }
.responses { max-height: 200px; overflow: auto; display: flex; flex-direction: column; gap: 0.3rem; }
.resp { font-size: 0.88rem; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); }

@media (max-width: 1100px) {
  .present { grid-template-columns: 1fr; }
  .live { grid-template-columns: 1fr; }
  .live-frame { height: 420px; }
}

@media (max-width: 900px) {
  .app3, .app3.notree { grid-template-columns: var(--rail-w) 1fr; }
  .treecol { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Settings tabs + logo fields + range */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tab { border: none; background: transparent; padding: 0.6rem 1.1rem; font-family: var(--font-body); font-weight: 700; font-size: 0.95rem; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-bottom: 14px; }
.logo-grid .field { margin-bottom: 0; }
.logo-field { display: flex; align-items: center; gap: 0.5rem; }
.logo-field input[type='text'] { flex: 1; min-width: 0; }
.logo-field .btn { flex: 0 0 auto; }
.logo-thumb { height: 34px; max-width: 92px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 2px; flex: 0 0 auto; }
input[type='range'] { width: 100%; accent-color: var(--accent); }

/* User avatar block (top of the detail card) */
.avatar-block { display: flex; align-items: center; gap: 14px; margin-bottom: 1.1rem; }
.avatar-img { width: 96px; height: 96px; border-radius: 16px; object-fit: cover; background: #efece7; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); }
.avatar-ph { font-family: var(--font-headline); font-size: 1.7rem; color: var(--muted); }
.avatar-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* Top-bar help button */
.topbar-help { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--muted); font-weight: 800; font-size: 1rem; cursor: pointer; display: grid; place-items: center; font-family: var(--font-headline); }
.topbar-help:hover { border-color: var(--accent); color: var(--accent); }
.topbar-help.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.tr-empty { padding: 4px 12px 4px 26px; color: var(--muted); font-size: .82rem; }

/* Help: process-flow diagram */
.flow-v { padding: 4px 0; }
.fv-stage { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.fv-stage::before { content: ''; position: absolute; left: 17px; top: 38px; bottom: -2px; width: 2px; background: var(--line); }
.fv-stage:last-child { padding-bottom: 0; }
.fv-stage:last-child::before { display: none; }
.fv-marker { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-headline); font-weight: 800; color: #fff; flex: 0 0 auto; position: relative; z-index: 1; }
.fv-body { padding-top: 3px; }
.fv-head { font-family: var(--font-headline); font-size: 1.05rem; display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.fv-body p { margin: 0; color: var(--muted); font-size: .94rem; max-width: 64ch; }
.role-chip { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; color: #fff; font-weight: 700; font-family: var(--font-body); background: var(--muted); }
.role-chip.r-admin { background: var(--ink); }
.role-chip.r-mod { background: var(--blue); }
.role-chip.r-trainer { background: var(--accent); }
.role-chip.r-sys { background: #757067; }
.role-chip.r-live { background: #2a8a52; }
.role-chip.r-part { background: #2a8a52; }
.role-chip.r-client { background: #7a5cc0; }
.r-admin .fv-marker { background: var(--ink); }
.r-mod .fv-marker { background: var(--blue); }
.r-trainer .fv-marker { background: var(--accent); }
.r-sys .fv-marker { background: #757067; }
.r-live .fv-marker { background: #2a8a52; }
.r-client .fv-marker { background: #7a5cc0; }

.loop { display: flex; align-items: stretch; gap: 12px; }
.loop-side { flex: 1; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.loop-side strong { font-family: var(--font-headline); }
.loop-side span { color: var(--muted); font-size: .88rem; }
.loop-side.r-trainer { border-color: var(--accent); }
.loop-side.r-part { border-color: #2a8a52; }
.loop-mid { display: flex; flex-direction: column; justify-content: center; gap: 10px; min-width: 128px; text-align: center; }
.loop-a { font-weight: 700; font-size: .82rem; display: flex; flex-direction: column; }
.loop-a small { color: var(--muted); font-weight: 400; }
.loop-a.down { color: var(--accent); }
.loop-a.up { color: #2a8a52; }

.role-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .94rem; }
.role-row:last-child { border-bottom: none; }
.role-row .role-chip { flex: 0 0 auto; min-width: 78px; text-align: center; }
.help-ul { margin: 0; padding-left: 1.1rem; color: var(--text); }
.help-ul li { margin-bottom: .5rem; }
.help-ul code { background: #efece7; padding: 1px 5px; border-radius: 4px; font-size: .85em; font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* Dashboard stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; }
.stat-card { text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); padding: 1.2rem 1.25rem; cursor: pointer; font-family: var(--font-body); transition: border-color .15s, transform .04s; }
.stat-card:hover { border-color: var(--accent); }
.stat-card:active { transform: translateY(1px); }
.stat-n { font-family: var(--font-headline); font-size: 2rem; line-height: 1; color: var(--text); }
.stat-l { color: var(--muted); margin-top: 0.35rem; }
.stat-live { color: #2a8a52; font-size: .82rem; font-weight: 700; margin-top: 0.5rem; }

/* ── Visual page builder ─────────────────────────────────────────────── */
.pb-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(12,15,10,.5); display: grid; place-items: center; }
.pb-modal { width: 100vw; height: 100vh; background: var(--bg); border-radius: 0; box-shadow: none; display: flex; flex-direction: column; overflow: hidden; }
.pb-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.pb-title { flex: 1; font-family: var(--font-headline); font-size: 1.15rem; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 6px 10px; background: transparent; color: var(--text); }
.pb-title:hover { border-color: var(--line); }
.pb-title:focus { outline: none; border-color: var(--accent); background: #fff; }
.pb-top-actions { display: flex; gap: 8px; }
.pb-warn { display: flex; align-items: center; gap: 12px; padding: 9px 16px; background: #fff6e5; border-bottom: 1px solid #f0d9a8; color: #7a5a12; font-size: .88rem; }
.pb-warn span { flex: 1; }
.pb-warn-x { border: 1px solid #e0c584; background: #fff; color: #7a5a12; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-family: var(--font-body); font-size: .82rem; }
.pb-warn-x:hover { background: #f6ecd4; }
.pb-main { flex: 1; position: relative; min-height: 0; overflow: hidden; }
/* Floating, draggable panels (palette + inspector) so the canvas gets the full width. */
.pb-float { position: absolute; z-index: 30; width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 34px rgba(12,15,10,.22); display: flex; flex-direction: column; max-height: calc(100% - 28px); }
.pb-float.dragging { box-shadow: 0 16px 44px rgba(12,15,10,.30); }
.pb-palette-panel { top: 14px; left: 14px; }
.pb-inspector-panel { top: 14px; right: 14px; width: 288px; }
.pb-float-head { cursor: move; user-select: none; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #faf8f5; border-radius: 10px 10px 0 0; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.pb-float-body { padding: 12px; overflow: auto; }
.pb-palette { display: flex; flex-direction: column; gap: 8px; }
.pb-insp-h { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.pb-add { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--text); cursor: pointer; font-family: var(--font-body); font-size: .92rem; }
.pb-add:hover { border-color: var(--accent); color: var(--accent); }
.pb-add-ic { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; background: var(--sand); color: var(--ink); font-size: .8rem; }
.pb-add:hover .pb-add-ic { background: var(--accent); color: #fff; }
.pb-canvas-wrap { position: absolute; inset: 0; overflow: auto; padding: 20px; background: var(--bg); }
.pb-canvas { max-width: none; margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 32px; min-height: 200px; box-shadow: var(--shadow); }
.pb-empty { color: var(--muted); text-align: center; padding: 40px 0; }
.pb-block { position: relative; border: 1.5px solid transparent; border-radius: 8px; padding: 8px 10px; margin: 2px 0; cursor: pointer; }
.pb-block:hover { border-color: rgba(191,46,143,.35); }
.pb-block.sel { border-color: var(--accent); }
.pb-block-tools { position: absolute; top: -12px; right: 8px; display: none; gap: 3px; }
.pb-block.sel .pb-block-tools, .pb-block:hover .pb-block-tools { display: flex; }
.pb-bt { width: 24px; height: 24px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: .78rem; line-height: 1; padding: 0; box-shadow: var(--shadow); }
.pb-bt:hover { color: var(--accent); border-color: var(--accent); }
.pb-bt.danger:hover { color: #c0392b; border-color: #c0392b; }
/* Drag-to-reorder: grip handle + drop indicators */
.pb-grip { cursor: grab; display: inline-grid; place-items: center; user-select: none; }
.pb-grip:active { cursor: grabbing; }
.pb-dragging { opacity: .4; }
.pb-drop-before { box-shadow: inset 0 3px 0 0 var(--accent); }
.pb-drop-after { box-shadow: inset 0 -3px 0 0 var(--accent); }
.pb-drop-into { outline: 2px dashed var(--accent); outline-offset: -2px; }
.pb-dnd .pb-ai-frame { pointer-events: none; }
.pb-ph, .pb-imgph, .pb-spacerprev { color: var(--muted); font-style: italic; }
.pb-imgph { display: block; padding: 20px; border: 1px dashed var(--line); border-radius: 8px; text-align: center; }
.pb-spacerprev { display: grid; place-items: center; background: repeating-linear-gradient(45deg,#f3f0ea,#f3f0ea 6px,#fff 6px,#fff 12px); border-radius: 6px; font-size: .75rem; }
.pb-btnprev { display: inline-block; background: var(--accent); color: #fff; padding: 11px 20px; border-radius: 8px; font-weight: 600; font-family: var(--font-body); }
.pb-canvas h1 { font-family: var(--font-headline); }
.pb-canvas h2, .pb-canvas h3 { font-family: var(--font-headline); }
.pb-insp-empty { color: var(--muted); font-size: .9rem; }
.pb-field { margin-bottom: 14px; }
.pb-field > label { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.pb-field input[type=text], .pb-field input:not([type]), .pb-inspector input[data-pb-inp] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: .9rem; background: #fff; color: var(--text); }
.pb-field input:focus { outline: none; border-color: var(--accent); }
.pb-field input[type=range] { width: 100%; accent-color: var(--accent); }
.pb-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.pb-seg button { border: none; background: #fff; padding: 7px 12px; cursor: pointer; font-family: var(--font-body); font-size: .84rem; color: var(--muted); border-left: 1px solid var(--line); }
.pb-seg button:first-child { border-left: none; }
.pb-seg button.on { background: var(--accent); color: #fff; }
.pb-rt-toolbar { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 6px; }
.pb-rt-toolbar button { border: 1px solid var(--line); background: #fff; border-radius: 5px; padding: 5px 8px; cursor: pointer; font-size: .82rem; color: var(--text); min-width: 28px; }
.pb-rt-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.pb-rt { min-height: 120px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; font-family: var(--font-body); font-size: .92rem; line-height: 1.5; background: #fff; color: var(--text); overflow: auto; }
.pb-rt:focus { outline: none; border-color: var(--accent); }
.pb-imgbtn { width: 100%; text-align: center; }

/* Page builder — section/row/column layout */
.pb-palette-note { font-size: .72rem; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.pb-section { position: relative; border: 1px dashed transparent; border-radius: 10px; padding: 6px; margin-bottom: 12px; }
.pb-section:hover { border-color: #e4dfd6; }
.pb-section-head { display: flex; align-items: center; justify-content: space-between; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 0 4px 4px; opacity: 0; transition: opacity .12s; }
.pb-section:hover .pb-section-head { opacity: 1; }
.pb-row { display: flex; align-items: stretch; gap: 6px; margin-bottom: 8px; }
.pb-row-inner { flex: 1; display: flex; align-items: flex-start; min-width: 0; }
.pb-row-side { flex: 0 0 auto; display: flex; flex-direction: column; gap: 3px; align-items: center; opacity: 0; transition: opacity .12s; padding-left: 2px; }
.pb-row:hover .pb-row-side { opacity: 1; }
.pb-colctl { display: flex; align-items: center; gap: 2px; margin-bottom: 3px; }
.pb-colnum { font-size: .78rem; color: var(--muted); min-width: 12px; text-align: center; font-weight: 700; }
.pb-col { position: relative; min-width: 0; border: 1.5px dashed #e4dfd6; border-radius: 8px; padding: 8px; }
.pb-col.active { border-color: var(--accent); background: rgba(191, 46, 143, .02); }
.pb-col-empty { color: var(--muted); font-style: italic; font-size: .82rem; text-align: center; padding: 18px 6px; }
.pb-col-divider { flex: 0 0 14px; align-self: stretch; cursor: col-resize; position: relative; border-radius: 5px; }
.pb-col-divider::before { content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 2px; height: 28px; background: #d3ccc1; border-radius: 2px; transition: background .12s, width .12s; }
.pb-col-divider:hover::before, .pb-col-divider.dragging::before { background: var(--accent); width: 4px; }
.pb-row-add, .pb-section-add { display: block; width: 100%; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 8px; cursor: pointer; font-family: var(--font-body); font-size: .85rem; }
.pb-row-add:hover, .pb-section-add:hover { border-color: var(--accent); color: var(--accent); }
.pb-section-add { margin-top: 6px; border-style: solid; font-weight: 600; }

/* AI module (page builder) */
.pb-ai-card { border: 1.5px dashed var(--accent); border-radius: 8px; padding: 16px; background: rgba(191,46,143,.03); }
.pb-ai-badge { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 8px; }
.pb-ai-empty { color: var(--muted); font-style: italic; font-size: .9rem; }
.pb-ai-wrap { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.pb-ai-frame { width: 100%; height: 80px; border: 1px solid var(--line); border-radius: 6px; background: #fff; transition: height .12s ease; }
.pb-ai-prompt { width: 100%; font-family: var(--font-body); font-size: .9rem; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--text); resize: vertical; min-height: 92px; }
.pb-ai-prompt:focus { outline: none; border-color: var(--accent); }
.pb-ai-status { font-size: .8rem; color: var(--muted); margin-top: 8px; line-height: 1.45; }
.pb-ai-warn { font-size: .82rem; color: #8a5a00; background: #fff6e5; border: 1px solid #f0d9a8; border-radius: 6px; padding: 8px 10px; line-height: 1.45; }
.pb-ai-log { margin: 0; padding: 0 0 0 20px; font-size: .82rem; color: var(--text); line-height: 1.5; max-height: 140px; overflow: auto; }
.pb-ai-log li { margin: 2px 0; }
/* Saved-modules palette rows + inline "save to library" form */
.pb-saved-row { display: flex; align-items: stretch; gap: 6px; }
.pb-saved-row .pb-add { flex: 1; min-width: 0; }
.pb-savemod { margin-top: 6px; }
.pb-savemod-name { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: .9rem; background: #fff; color: var(--text); }
.pb-savemod-name:focus { outline: none; border-color: var(--accent); }
.pb-savemod-actions { display: flex; gap: 6px; margin-top: 6px; }
.pb-savemod-actions .btn { flex: 1; }

/* Settings — AI connection status */
.ai-status { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; margin-bottom: 1.1rem; }
.ai-status .ai-dot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: .8rem; color: #fff; flex: 0 0 auto; }
.ai-status.ok { background: #e7f6ec; color: #1c7a3f; }
.ai-status.ok .ai-dot { background: #2a8a52; }
.ai-status.warn { background: #fff6e5; color: #7a5a12; }
.ai-status.warn .ai-dot { background: #d99a1c; }
.ai-status.off { background: #f1efeb; color: var(--muted); }
.ai-status.off .ai-dot { background: #b9b4ab; }

/* Builder — style chips, palette swatches, section selection */
.pb-style-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-style-chip { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-family: var(--font-body); font-size: .82rem; font-weight: 600; }
.pb-style-chip.pb-chip-custom { background: #fff; color: var(--text); }
.pb-style-chip.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.pb-swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pb-sw { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.pb-sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.pb-sw.none { background: #fff; color: var(--muted); display: grid; place-items: center; font-size: .8rem; }
.pb-sw-custom { width: 26px; height: 26px; border-radius: 50%; border: 1px dashed var(--line); display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden; font-size: .72rem; color: var(--muted); }
.pb-sw-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pb-section.sel { outline: 2px solid var(--accent); outline-offset: 2px; }
.pb-row.sel { outline: 2px dashed var(--accent); outline-offset: 1px; border-radius: 8px; }
.pb-section-head[data-pb="section-select"] { cursor: pointer; }

/* Settings — button styles + palette editors */
/* Course button-style cards: two per row */
.bstyle-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bstyle-card-grid .bstyle-card { margin-bottom: 0; }
@media (max-width: 820px) { .bstyle-card-grid { grid-template-columns: 1fr; } }
.bstyle-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.bstyle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.bstyle-card .bstyle-row:last-child { margin-bottom: 0; }
.bstyle-row2 { border-top: 1px dashed var(--line); padding-top: 8px; gap: 16px; }
.bstyle-row2 input[type=number] { padding: 5px 6px; border: 1px solid var(--line); border-radius: 5px; font-family: var(--font-body); }
.bstyle-label { flex: 0 0 130px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); }
.swatch-mini { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; color: var(--muted); }
.swatch-mini input[type=color] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; }
.bstyle-prev { margin-left: auto; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: .85rem; }
.palette-row { display: flex; flex-wrap: wrap; gap: 8px; }
.palette-row input[type=color] { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; }
/* Make the native colour input fully fill the round swatch (no inner padding/border). */
.palette-row input[type=color]::-webkit-color-swatch-wrapper, .swatch-mini input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.palette-row input[type=color]::-webkit-color-swatch, .swatch-mini input[type=color]::-webkit-color-swatch { border: none; border-radius: 50%; }

/* Quiz modules — palette group, canvas preview, inspector editors */
.pb-palette-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 10px 0 2px; padding-top: 8px; border-top: 1px solid var(--line); }
/* Collapsible palette groups (Add module panel) */
.pb-palette { gap: 6px; }
.pb-pgroup { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.pb-pgroup-head { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border: none; background: #faf8f5; cursor: pointer; font-family: var(--font-body); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.pb-pgroup-head:hover { color: var(--accent); }
.pb-pgroup-caret { display: inline-block; width: 12px; font-size: .78rem; color: var(--accent); }
.pb-pgroup-body { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.pb-pgroup.collapsed .pb-pgroup-body { display: none; }
.pbq { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; }
.pbq-badge { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.pbq-prompt { font-weight: 700; margin-bottom: 2px; }
.pbq-desc { color: var(--muted); font-size: .85rem; margin-bottom: 8px; }
.pbq-opt { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; margin: 4px 0; font-size: .9rem; }
.pbq-ok { color: #2a8a52; font-weight: 700; }
.pbq-text-ph { padding: 8px 10px; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); font-style: italic; }
.pbq-note { color: var(--muted); font-size: .78rem; margin-top: 6px; }
.pbq-scale { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; margin-right: 4px; }
.pbq-ord { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; margin: 3px 0; font-size: .9rem; }
/* inspector option rows */
.pbq-optrow { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.pbq-optrow input[type=text], .pbq-optrow input:not([type]) { flex: 1; padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: .88rem; }
.pbq-mark { flex: 0 0 auto; width: 28px; height: 28px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; color: #c9c4bb; font-weight: 700; }
.pbq-mark.on { background: #2a8a52; border-color: #2a8a52; color: #fff; }
.pbq-num { flex: 0 0 auto; width: 20px; text-align: center; color: var(--muted); font-weight: 700; font-size: .82rem; }
.pb-inspector input[type=checkbox] { accent-color: var(--accent); margin-right: 6px; }
.pb-inspector input[type=number] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: var(--font-body); }

/* Section columns (scols) — each stacks its own rows */
.pb-srow { display: flex; align-items: stretch; gap: 0; }
.pb-scol { flex: 1; min-width: 0; }
.pb-scol-divider { flex: 0 0 16px; align-self: stretch; cursor: col-resize; position: relative; border-radius: 5px; }
.pb-scol-divider::before { content: ''; position: absolute; left: 50%; top: 6px; bottom: 6px; transform: translateX(-50%); width: var(--dw, 2px); background: var(--dc, #d3ccc1); border-radius: 2px; transition: background .12s, width .12s; }
.pb-scol-divider:hover::before, .pb-scol-divider.dragging::before { background: var(--accent); width: 4px; }
.pb-sec-ctl { display: inline-flex; align-items: center; gap: 3px; }
.pb-sec-ctl .pb-colnum { min-width: 12px; text-align: center; }

/* Floating panels: collapse/expand toggle */
.pb-float-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pb-float-toggle { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: .9rem; line-height: 1; padding: 2px 4px; border-radius: 5px; }
.pb-float-toggle:hover { background: rgba(0,0,0,.06); color: var(--text); }
.pb-float.collapsed .pb-float-body { display: none; }
.pb-float.collapsed { width: auto; }
.pb-float.collapsed .pb-float-head { border-bottom: none; border-radius: 10px; }
/* Docked panels — squared off, flush to their edge, body fills the height */
.pb-float.pb-docked { border-radius: 0; max-height: none; box-shadow: 0 0 18px rgba(12,15,10,.10); }
.pb-float.pb-docked .pb-float-head { border-radius: 0; }
.pb-float.pb-docked .pb-float-body { flex: 1 1 auto; min-height: 0; }
.pb-float.pb-dock-left { border-top: none; border-bottom: none; border-left: none; }
.pb-float.pb-dock-right { border-top: none; border-bottom: none; border-right: none; }
.pb-float.pb-dock-bottom { border-left: none; border-right: none; border-bottom: none; }
/* Drop-zone hint shown while dragging toward an edge */
.pb-dock-preview { position: absolute; z-index: 25; pointer-events: none; display: none; background: rgba(191,46,143,.14); border: 2px dashed var(--accent); border-radius: 8px; }
