/* Course builder styles + the collapsible sidebar.
 *
 * Everything new lives in this file; style.css is untouched. Component classes
 * are prefixed cb- (course builder) so they can't collide with existing screens.
 * Colours come from the institute's own brand variables (--brand*, set per
 * academy in base.html), so the builder follows each academy's branding.
 * Sections: 1 tokens, 2 sidebar (collapse / pills / disabled), 3 shared
 * controls, 4 course list. */

/* ---- 1. Tokens ------------------------------------------------------------ */
:root {
  --cb-ink: #0f172a;
  --cb-muted: #64748b;
  --cb-faint: #94a3b8;
  --cb-line: #e2e8f0;
  --cb-soft: #f8fafc;
  --cb-surface: #ffffff;
  --cb-accent: var(--brand);
  --cb-accent-dark: var(--brand-dark);
  --cb-accent-soft: var(--brand-light);
  --cb-navy: #1b2559;
  --cb-danger: #dc2626;
  --cb-warn-bg: #fef3c7;
  --cb-warn-ink: #92400e;
  --cb-radius: 10px;
  --cb-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 24px -14px rgba(15, 23, 42, 0.25);
  --cb-ring: 0 0 0 3px rgba(var(--brand-mid-rgb), 0.28);
  --cb-rail: 72px; /* collapsed sidebar width */
}

.cb-sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- 2. Sidebar: collapse, pills, disabled entries ------------------------ */
.nav-collapse-btn {
  display: none; margin-left: auto; flex-shrink: 0; width: 30px; height: 30px; padding: 0;
  align-items: center; justify-content: center; border: none; border-radius: 8px;
  background: transparent; color: var(--cb-muted); cursor: pointer;
}
.nav-collapse-btn:hover { background: #f1f5f9; color: var(--cb-ink); }
.nav-collapse-btn:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.navbrand-text { min-width: 0; }
.logout-ico { display: none; }

.nav-pill {
  margin-left: auto; align-self: center; flex-shrink: 0; padding: 2px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; line-height: 1.4;
  background: var(--cb-accent-soft); color: var(--cb-accent-dark);
}
.nav-pill-soon { background: #f1f5f9; color: #475569; }
.nav-dot { width: 8px; height: 8px; margin-left: 6px; align-self: center; flex-shrink: 0; border-radius: 50%; background: #ef4444; }
.navlink.is-disabled, .nav-child-link.is-disabled { opacity: 0.62; cursor: not-allowed; }
.navlink.is-disabled:hover, .nav-child-link.is-disabled:hover { background: transparent; color: #475569; }
.nav-child-link .navlabel { min-width: 0; }

.sidebar { transition: width 0.18s ease; }
.main-area { transition: margin-left 0.18s ease; }

@media (min-width: 768px) {
  .nav-collapse-btn { display: inline-flex; }
  html.nav-collapsed .sidebar { width: var(--cb-rail); }
  html.nav-collapsed .main-area { margin-left: var(--cb-rail); }
  html.nav-collapsed .navbrand { flex-direction: column; align-items: center; gap: 10px; padding: 16px 0 10px; }
  html.nav-collapsed .navbrand-text,
  html.nav-collapsed .navlabel,
  html.nav-collapsed .nav-chevron,
  html.nav-collapsed .nav-children,
  html.nav-collapsed .sidebar .nav-pill,   /* scoped: pills are also used inside dialogs */
  html.nav-collapsed .navuser,
  html.nav-collapsed .logout-text { display: none; }
  html.nav-collapsed .nav-collapse-btn { margin-left: 0; }
  html.nav-collapsed .nav-collapse-btn svg { transform: rotate(180deg); }
  html.nav-collapsed .sidenav { align-items: center; padding: 8px 10px; }
  html.nav-collapsed .navlink,
  html.nav-collapsed .nav-cat-btn { width: 44px; min-height: 44px; padding: 8px; justify-content: center; position: relative; }
  html.nav-collapsed .navlink .navicon,
  html.nav-collapsed .nav-cat-btn .navicon { margin-top: 0; }
  html.nav-collapsed .nav-category { align-items: center; }
  html.nav-collapsed .nav-dot { position: absolute; top: 8px; right: 8px; margin: 0; }
  html.nav-collapsed .sidefoot { padding: 12px 8px; align-items: center; }
  html.nav-collapsed .sidefoot-user { justify-content: center; }
  html.nav-collapsed .logout-btn { width: 40px; height: 40px; padding: 0; }
  html.nav-collapsed .logout-ico { display: block; }
}

/* ---- 3. Shared controls --------------------------------------------------- */
.cb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 8px; font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.cb-btn:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.cb-btn-primary { background: var(--cb-accent); color: #fff; }
.cb-btn-primary:hover { background: var(--cb-accent-dark); color: #fff; }
.cb-btn-outline { background: var(--cb-surface); color: var(--cb-ink); border-color: var(--cb-line); }
.cb-btn-outline:hover { background: var(--cb-soft); color: var(--cb-ink); }
.cb-btn-sm { min-height: 34px; padding: 0 14px; font-size: 13.5px; }
.cb-link { font-size: 13.5px; font-weight: 600; color: var(--cb-accent); }

.cb-toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
.cb-toast {
  padding: 11px 18px; border-radius: 8px; background: var(--cb-navy); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.5); animation: cb-toast-in 0.18s ease-out;
}
.cb-toast--error { background: #991b1b; }
@keyframes cb-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- 4. Course list ------------------------------------------------------- */
.cb-pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.cb-title { margin: 0 0 6px; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; color: var(--cb-ink); }
.cb-sub { margin: 0; font-size: 14.5px; color: #334155; }
.cb-sub a { font-weight: 600; }

.cb-toolbar { display: flex; align-items: stretch; gap: 16px; margin-bottom: 28px; }
.cb-toolbar-main {
  flex: 1; min-width: 0; display: flex; align-items: stretch; position: relative;
  border: 1px solid var(--cb-line); border-radius: 8px; background: var(--cb-surface);
}
.cb-filters { flex-shrink: 0; }
.cb-filter-btn {
  list-style: none; display: flex; align-items: center; gap: 8px; height: 100%; min-height: 46px; padding: 0 18px;
  border-right: 1px solid var(--cb-line); font-size: 15px; font-weight: 500; color: var(--cb-ink); cursor: pointer;
  border-radius: 8px 0 0 8px; user-select: none;
}
.cb-filter-btn::-webkit-details-marker { display: none; }
.cb-filter-btn:hover { background: var(--cb-soft); }
.cb-filter-btn:focus-visible { outline: none; box-shadow: inset var(--cb-ring); }
.cb-filters[open] .cb-filter-btn svg { transform: rotate(180deg); }
.cb-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; background: var(--cb-accent); color: #fff;
}
.cb-count[hidden] { display: none; }
.cb-popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 300px; max-width: calc(100vw - 32px); padding: 16px;
  display: flex; flex-direction: column; gap: 14px; background: var(--cb-surface);
  border: 1px solid var(--cb-line); border-radius: var(--cb-radius); box-shadow: var(--cb-shadow);
}
.cb-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #334155; }
.cb-field select {
  height: 40px; padding: 0 10px; border: 1px solid var(--cb-line); border-radius: 8px; background: #fff;
  font: inherit; font-size: 14px; font-weight: 400; color: var(--cb-ink);
}
.cb-field select:focus-visible { outline: none; border-color: var(--brand-mid); box-shadow: var(--cb-ring); }
.cb-popover-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.cb-search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 16px; color: var(--cb-faint); }
.cb-search:focus-within { color: var(--cb-accent); }
.cb-search input {
  flex: 1; min-width: 0; height: 44px; border: none; outline: none; background: transparent; box-shadow: none;
  padding: 0; font: inherit; font-size: 16px; color: var(--cb-ink);
}
.cb-search input::placeholder { color: var(--cb-faint); }
.cb-toolbar-main:focus-within { border-color: var(--brand-mid); box-shadow: var(--cb-ring); }

.cb-viewtoggle { display: flex; flex-shrink: 0; border: 1px solid var(--cb-line); border-radius: 8px; overflow: hidden; background: var(--cb-surface); }
.cb-viewbtn { width: 52px; display: inline-flex; align-items: center; justify-content: center; color: var(--cb-ink); }
.cb-viewbtn:hover { background: var(--cb-soft); color: var(--cb-ink); }
.cb-viewbtn.is-active { background: var(--cb-accent); color: #fff; }
.cb-viewbtn:focus-visible { outline: none; box-shadow: inset var(--cb-ring); }

[data-course-list][aria-busy="true"] [data-course-results] { opacity: 0.55; transition: opacity 0.15s ease; }

/* Cards */
.cb-courses { list-style: none; margin: 0; padding: 0; display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.cb-courses > li { min-width: 0; }
.cb-card {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
  background: var(--cb-surface); border: 1px solid var(--cb-line); border-radius: var(--cb-radius);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}
.cb-card:hover { box-shadow: var(--cb-shadow); border-color: #cbd5e1; }

.cb-cover { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--cb-soft); }
.cb-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cb-cover--ph {
  display: grid; place-items: center; background-color: var(--ph-bg);
  background-image: linear-gradient(var(--ph-line) 1px, transparent 1px), linear-gradient(90deg, var(--ph-line) 1px, transparent 1px);
  background-size: 32px 32px;
}
.cb-ph-0 { --ph-bg: #16225e; --ph-line: rgba(255, 255, 255, 0.09); --ph-shape: #f4f5c8; }
.cb-ph-1 { --ph-bg: #f1eee7; --ph-line: rgba(15, 23, 42, 0.06); --ph-shape: #7ee8b6; }
.cb-ph-2 { --ph-bg: #0f766e; --ph-line: rgba(255, 255, 255, 0.1); --ph-shape: #fde68a; }
.cb-ph-3 { --ph-bg: #fce8e3; --ph-line: rgba(15, 23, 42, 0.05); --ph-shape: #f4694f; }
.cb-ph-4 { --ph-bg: #e3e8ff; --ph-line: rgba(15, 23, 42, 0.05); --ph-shape: #4f46e5; }
.cb-ph-5 { --ph-bg: #1f2937; --ph-line: rgba(255, 255, 255, 0.08); --ph-shape: #93c5fd; }
.cb-shape { display: block; width: 22%; aspect-ratio: 1; background: var(--ph-shape); }
.cb-shape--diamond { transform: rotate(45deg) scale(0.78); }
.cb-shape--triangle { clip-path: polygon(50% 8%, 96% 92%, 4% 92%); width: 24%; }
.cb-shape--circle { border-radius: 50%; width: 20%; }
.cb-shape--ring { border-radius: 50%; background: transparent; border: 12px solid var(--ph-shape); width: 22%; }

.cb-status {
  position: absolute; top: 10px; left: 10px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--cb-warn-bg); color: var(--cb-warn-ink);
}
.cb-share {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; background: rgba(255, 255, 255, 0.95); color: var(--cb-ink); cursor: pointer;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
}
.cb-share:hover { background: #fff; color: var(--cb-accent); }
.cb-share:focus-visible { outline: none; box-shadow: var(--cb-ring); }

.cb-card-body { flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 12px 14px 12px; min-width: 0; }
.cb-card-title {
  font-size: 15.5px; font-weight: 600; line-height: 1.35; color: var(--cb-accent); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cb-card-title:hover { color: var(--cb-accent-dark); text-decoration: underline; }
.cb-card-creator { font-size: 13.5px; color: var(--cb-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-card-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.cb-enrolled { font-size: 13.5px; color: var(--cb-ink); display: inline-flex; align-items: center; gap: 4px; }
.cb-enrolled b { color: var(--cb-accent); font-weight: 700; }
.cb-info { display: inline-flex; color: var(--cb-muted); cursor: help; border-radius: 50%; }
.cb-info:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.cb-when { font-size: 13px; color: var(--cb-muted); white-space: nowrap; }
.cb-price { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.cb-price-now { font-size: 14px; font-weight: 700; color: var(--cb-ink); font-variant-numeric: tabular-nums; }
.cb-price-now.is-free { color: #047857; }
.cb-price-was { font-size: 12.5px; color: var(--cb-faint); font-variant-numeric: tabular-nums; }

.cb-actions { display: grid; grid-template-columns: repeat(6, 1fr); border-top: 1px solid var(--cb-line); }
.cb-act {
  height: 46px; display: inline-flex; align-items: center; justify-content: center; color: var(--cb-ink);
  border-left: 1px solid var(--cb-line); background: transparent;
}
.cb-act:first-child { border-left: none; }
a.cb-act:hover { background: var(--cb-accent-soft); color: var(--cb-accent-dark); }
a.cb-act:focus-visible { outline: none; box-shadow: inset var(--cb-ring); }
.cb-act.is-disabled { color: #b6c0cd; cursor: not-allowed; }

/* List layout: same markup, one row per course */
[data-course-list][data-view="list"] .cb-courses { grid-template-columns: 1fr; gap: 14px; }
[data-course-list][data-view="list"] .cb-card { display: grid; grid-template-columns: 176px minmax(0, 1fr) auto; align-items: stretch; }
[data-course-list][data-view="list"] .cb-cover { height: 100%; aspect-ratio: 3 / 2; }
[data-course-list][data-view="list"] .cb-card-body { justify-content: center; padding: 14px 18px; }
[data-course-list][data-view="list"] .cb-actions { border-top: none; border-left: 1px solid var(--cb-line); grid-template-columns: repeat(6, 52px); align-content: center; }
[data-course-list][data-view="list"] .cb-cover--ph .cb-shape--ring { border-width: 8px; }

.cb-listfoot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 30px; }
.cb-showing { margin: 0; font-size: 13.5px; color: var(--cb-muted); }
.cb-pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cb-pg {
  min-width: 36px; height: 36px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--cb-line); border-radius: 8px; background: var(--cb-surface); color: var(--cb-ink);
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
a.cb-pg:hover { background: var(--cb-soft); color: var(--cb-ink); }
a.cb-pg:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.cb-pg.is-current { background: var(--cb-accent); border-color: var(--cb-accent); color: #fff; }
.cb-pg-gap { padding: 0 4px; color: var(--cb-faint); }
.cb-classic { margin: 36px 0 0; font-size: 13px; color: var(--cb-muted); }

.cb-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 56px 20px; border: 1px dashed #cbd5e1; border-radius: var(--cb-radius); background: var(--cb-soft);
}
.cb-empty h2 { margin: 12px 0 0; font-size: 20px; font-weight: 700; color: var(--cb-ink); }
.cb-empty p { margin: 0 0 12px; max-width: 46ch; font-size: 14.5px; color: var(--cb-muted); }
.cb-empty-art {
  width: 132px; aspect-ratio: 3 / 2; border-radius: 8px; display: grid; place-items: center; overflow: hidden;
  background-color: var(--ph-bg); background-image: linear-gradient(var(--ph-line) 1px, transparent 1px), linear-gradient(90deg, var(--ph-line) 1px, transparent 1px);
  background-size: 22px 22px;
}
.cb-empty-art .cb-shape { width: 26%; }

@media (max-width: 900px) {
  [data-course-list][data-view="list"] .cb-card { grid-template-columns: 132px minmax(0, 1fr); }
  [data-course-list][data-view="list"] .cb-actions { grid-column: 1 / -1; border-left: none; border-top: 1px solid var(--cb-line); grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 640px) {
  .cb-title { font-size: 22px; }
  .cb-pagehead .cb-btn { width: 100%; }
  .cb-toolbar { flex-wrap: wrap; gap: 12px; }
  .cb-toolbar-main { flex-basis: 100%; }
  .cb-viewtoggle { margin-left: auto; height: 42px; }
  .cb-filter-btn { padding: 0 12px; }
  .cb-courses { grid-template-columns: 1fr; }
  [data-course-list][data-view="list"] .cb-card { grid-template-columns: 104px minmax(0, 1fr); }
  [data-course-list][data-view="list"] .cb-card-body { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .cb-toast { animation: none; }
}

/* ---- 5. Create-course form ------------------------------------------------ */
.cb-form { max-width: 1000px; margin: 0 auto; }
.cb-formhead { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; padding-bottom: 18px; border-bottom: 1px solid var(--cb-line); }
.cb-formhead h1 { flex: 1; margin: 0; font-size: 21px; font-weight: 600; color: var(--cb-ink); }
.cb-back { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--cb-ink); }
.cb-back:hover { background: #f1f5f9; color: var(--cb-ink); }
.cb-back:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.cb-btn-navy { background: var(--cb-navy); color: #fff; min-width: 96px; }
.cb-btn-navy:hover:not(:disabled) { background: #121a45; color: #fff; }
.cb-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.cb-formbody { max-width: 780px; display: flex; flex-direction: column; gap: 28px; }
.cb-fieldgroup { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cb-label, .cb-legend { font-size: 16px; font-weight: 600; color: var(--cb-ink); }
.cb-legend { padding: 0; margin-bottom: 12px; }
input.cb-input, select.cb-input, textarea.cb-input {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--cb-line); border-radius: 8px;
  background: var(--cb-surface); font: inherit; font-size: 16px; color: var(--cb-ink);
}
textarea.cb-input { padding: 12px 14px; line-height: 1.5; }
input.cb-input::placeholder { color: var(--cb-faint); }
.cb-input.is-invalid, .cb-editor-area.is-invalid { border-color: var(--cb-danger); }
.cb-error { margin: 0; font-size: 13.5px; font-weight: 500; color: var(--cb-danger); }
.cb-error[hidden] { display: none; }
.cb-alert { margin-bottom: 24px; padding: 12px 16px; border: 1px solid #fecaca; border-radius: 8px; background: #fef2f2; color: #991b1b; font-size: 14.5px; }
.cb-alert:focus { outline: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2); }

/* AI banner */
.cb-ai { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 20px; border-radius: 8px; background: #eceffe; }
.cb-ai p { flex: 1 1 260px; margin: 0; font-size: 14.5px; color: #1e293b; }
.cb-ai-tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 6px; background: #fff; color: var(--cb-navy); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.cb-btn-ai { background: linear-gradient(135deg, #3b82f6, #1e3a8a); color: #fff; }
.cb-btn-ai:hover:not(:disabled) { color: #fff; filter: brightness(1.08); }

/* Rich-text editor */
.cb-editor { border: 1px solid var(--cb-line); border-radius: 8px; background: var(--cb-surface); }
.cb-editor:focus-within { border-color: var(--brand-mid); box-shadow: var(--cb-ring); }
.cb-editor[hidden] { display: none; }
.cb-editor:has(.is-invalid) { border-color: var(--cb-danger); }
.cb-toolbar-rte { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--cb-line); background: var(--cb-soft); border-radius: 8px 8px 0 0; }
.cb-toolbar-rte button {
  width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; background: transparent; color: #334155; font: inherit; font-size: 16px; cursor: pointer;
}
.cb-toolbar-rte button:hover { background: #e2e8f0; }
.cb-toolbar-rte button[aria-pressed="true"] { background: var(--cb-accent-soft); color: var(--cb-accent-dark); }
.cb-toolbar-rte button:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.cb-rte-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--cb-line); }
.cb-editor-area { min-height: 220px; max-height: 480px; overflow-y: auto; padding: 14px 16px; font-size: 16px; line-height: 1.6; color: var(--cb-ink); outline: none; resize: vertical; border-radius: 0 0 8px 8px; }
.cb-editor-area ul, .cb-editor-area ol { margin: 0.4em 0; padding-left: 1.6em; }
.cb-editor-area p, .cb-editor-area div { margin: 0 0 0.6em; }
.cb-editor-area:empty::before { content: attr(data-placeholder); color: var(--cb-faint); }

/* Pricing */
.cb-pricing { border: none; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.cb-plan { display: flex; gap: 16px; padding: 20px; border: 1px solid transparent; border-radius: 8px; background: #f6f7fb; }
.cb-plan:has(input:checked) { border-color: var(--brand-mid); background: var(--cb-accent-soft); }
.cb-plan > input[type="radio"] { flex-shrink: 0; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); }
.cb-plan-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.cb-plan-head { display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.cb-plan-name { font-size: 16px; font-weight: 600; color: var(--cb-ink); }
.cb-plan-desc { font-size: 14px; color: var(--cb-muted); }
.cb-plan-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cb-plan-fields[hidden] { display: none; }
.cb-money { display: flex; align-items: stretch; border: 1px solid var(--cb-line); border-radius: 8px; background: var(--cb-surface); overflow: hidden; }
.cb-money:focus-within { border-color: var(--brand-mid); box-shadow: var(--cb-ring); }
.cb-money-sym { display: inline-flex; align-items: center; padding: 0 16px; min-width: 52px; justify-content: center; background: var(--cb-soft); border-right: 1px solid var(--cb-line); font-size: 17px; font-weight: 600; color: #334155; }
select.cb-currency { width: auto; min-width: 100px; min-height: 48px; padding: 0 8px; border: none; border-right: 1px solid var(--cb-line); border-radius: 0; background: var(--cb-soft); font: inherit; font-size: 14.5px; font-weight: 600; color: #334155; box-shadow: none; }
.cb-money input.cb-input { border: none; border-radius: 0; min-width: 0; box-shadow: none; }
.cb-money:has(.is-invalid) { border-color: var(--cb-danger); }
.cb-note { display: flex; align-items: flex-start; gap: 10px; margin: 6px 0 0; padding: 12px 16px; border-radius: 8px; background: #eceffe; font-size: 14px; color: #1e293b; }
.cb-note svg { flex-shrink: 0; margin-top: 2px; color: var(--cb-navy); }

@media (max-width: 720px) {
  .cb-plan-fields { grid-template-columns: 1fr; }
  .cb-formhead h1 { font-size: 18px; }
  .cb-plan { padding: 16px; }
}

/* ---- 6. AI suggestions modal ---------------------------------------------- */
.cb-ai-status { flex-basis: 100%; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; padding-top: 10px; border-top: 1px solid rgba(27, 37, 89, 0.12); font-size: 13.5px; color: #1e293b; }
.cb-ai-status[hidden] { display: none; }
.cb-ai-status svg { color: #047857; }
.cb-linkbtn { padding: 0; border: none; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--cb-accent); cursor: pointer; }
.cb-linkbtn:hover { text-decoration: underline; }
.cb-linkbtn:focus-visible { outline: none; box-shadow: var(--cb-ring); border-radius: 4px; }
.cb-glyph { display: inline-flex; flex-shrink: 0; }

dialog.cb-modal {
  width: min(720px, calc(100vw - 32px)); max-height: min(86vh, 760px); padding: 0; border: none; border-radius: 12px;
  background: var(--cb-surface); color: var(--cb-ink); box-shadow: 0 24px 60px -20px rgba(15, 23, 42, 0.45);
}
dialog.cb-modal[open] { display: flex; flex-direction: column; }
dialog.cb-modal::backdrop { background: rgba(15, 23, 42, 0.5); }
.cb-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--cb-line); }
.cb-modal-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; font-weight: 700; }
.cb-modal-body { flex: 1; min-height: 120px; overflow-y: auto; padding: 8px 20px 12px; }
.cb-modal-foot { padding: 12px 20px 16px; border-top: 1px solid var(--cb-line); background: var(--cb-soft); border-radius: 0 0 12px 12px; }
.cb-hint { margin: 0 0 10px; font-size: 13px; color: var(--cb-muted); }
.cb-hint[hidden] { display: none; }
.cb-modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap; }
.cb-modal-actions [hidden] { display: none; }
.cb-icon-btn { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: 6px; background: transparent; color: var(--cb-muted); cursor: pointer; flex-shrink: 0; }
.cb-icon-btn:hover { background: #f1f5f9; color: var(--cb-danger); }
.cb-icon-btn:focus-visible { outline: none; box-shadow: var(--cb-ring); }

.cb-ai-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 44px 0; text-align: center; color: var(--cb-muted); }
.cb-ai-loading[hidden], .cb-ai-error[hidden] { display: none; }
.cb-ai-loading p { margin: 0; }
.cb-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #dbe1f5; border-top-color: var(--cb-accent); animation: cb-spin 0.9s linear infinite; }
@keyframes cb-spin { to { transform: rotate(360deg); } }
.cb-ai-error { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin: 16px 0; padding: 14px 16px; border: 1px solid #fecaca; border-radius: 8px; background: #fef2f2; color: #991b1b; }
.cb-ai-error p { margin: 0; font-size: 14.5px; }

.cb-ai-sec { padding: 14px 0 6px; }
.cb-ai-sec + .cb-ai-sec { border-top: 1px solid #f1f5f9; }
.cb-ai-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.cb-ai-sec-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.cb-ai-desc p, .cb-ai-tagline { margin: 0 0 8px; font-size: 14.5px; line-height: 1.6; color: #334155; }
.cb-ai-highlights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cb-ai-highlights li { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: #334155; }
.cb-ai-highlights li > span:not(.cb-glyph) { flex: 1; }
.cb-ai-highlights .cb-glyph { color: var(--cb-accent); }
.cb-ai-points { display: flex; flex-direction: column; font-size: 14px; color: #334155; }
.cb-ai-point { display: grid; grid-template-columns: 56px 1fr 2fr 36px; align-items: center; gap: 12px; padding: 8px 10px; border-bottom: 1px solid #f1f5f9; }
.cb-ai-point-head { background: #eef0f6; border-radius: 6px 6px 0 0; border-bottom: none; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cb-muted); }
.cb-ai-point .cb-glyph { color: var(--cb-accent); justify-self: center; }
.cb-ai-point-title { font-weight: 600; color: var(--cb-ink); }
.cb-ai-none { margin: 20px 0; text-align: center; color: var(--cb-muted); }

@media (max-width: 600px) {
  .cb-ai-point { grid-template-columns: 36px 1fr 32px; }
  .cb-ai-point > span:nth-child(3) { grid-column: 2 / 3; grid-row: 2; font-size: 13px; color: var(--cb-muted); }
  .cb-ai-point-head > span:nth-child(3) { display: none; }
  .cb-modal-actions .cb-btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .cb-spinner { animation-duration: 3s; } }

/* ---- 7. Builder page ------------------------------------------------------- */
.cb-builder { max-width: 1180px; margin: 0 auto; padding-bottom: 84px; }
.cb-bhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--cb-line); }
.cb-btitle { flex: 1 1 200px; min-width: 0; margin: 0; font-size: 21px; font-weight: 600; color: var(--cb-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-pill { padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.cb-pill-draft { background: var(--cb-warn-bg); color: var(--cb-warn-ink); }
.cb-pill-live { background: #d1fae5; color: #065f46; }
.cb-savestate { font-size: 13px; color: var(--cb-muted); white-space: nowrap; }
.cb-savestate[data-state="saving"] { color: var(--cb-accent); }
.cb-savestate[data-state="error"] { color: var(--cb-danger); font-weight: 600; }
.cb-bactions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cb-btn-square { width: 44px; padding: 0; }
.cb-btn-block { width: 100%; }
.cb-btn-danger { background: var(--cb-danger); color: #fff; }
.cb-btn-danger:hover:not(:disabled) { background: #b91c1c; color: #fff; }
.cb-notice { margin-bottom: 20px; padding: 12px 16px; border: 1px solid #fde68a; border-radius: 8px; background: #fffbeb; font-size: 14px; color: #78350f; }

.cb-bgrid { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 32px; align-items: start; }
.cb-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; }
.cb-covercard { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--cb-line); border-radius: var(--cb-radius); background: var(--cb-surface); }
.cb-cover--builder { border-radius: 8px; border: 1px solid var(--cb-line); }
.cb-cover--builder img { position: absolute; inset: 0; }
.cb-cover-ph { position: absolute; inset: 0; display: grid; place-items: center; background-color: var(--ph-bg); background-image: linear-gradient(var(--ph-line) 1px, transparent 1px), linear-gradient(90deg, var(--ph-line) 1px, transparent 1px); background-size: 28px 28px; }
.cb-cover-ph[hidden], .cb-cover--builder img[hidden] { display: none; }
.cb-uploading { position: absolute; inset: 0; display: none; place-items: center; background: rgba(255, 255, 255, 0.7); }
.is-uploading .cb-uploading { display: grid; }
.cb-side-hint { margin: 0; font-size: 12.5px; color: var(--cb-muted); }
.cb-danger-link { align-self: flex-start; color: var(--cb-danger); }
.cb-danger-link[hidden] { display: none; }
.cb-sidebtns { display: flex; flex-direction: column; gap: 10px; }
.cb-sidebtns .cb-btn { min-height: 44px; }
.cb-sidelink { font-size: 13.5px; font-weight: 600; }

.cb-main { min-width: 0; }
.cb-chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.cb-chapters[hidden], .cb-empty-builder[hidden] { display: none; }
.cb-chapter { border: 1px solid var(--cb-line); border-radius: var(--cb-radius); background: var(--cb-surface); }
.cb-chapter.is-ghost { opacity: 0.45; background: var(--cb-accent-soft); border-style: dashed; }
.cb-chapter.is-chosen { box-shadow: var(--cb-shadow); }
.cb-chapter-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; }
.cb-handle { display: inline-flex; padding: 6px 2px; color: var(--cb-faint); cursor: grab; touch-action: none; }
.cb-handle:active { cursor: grabbing; }
.cb-collapse svg { transition: transform 0.15s ease; }
.is-collapsed .cb-collapse svg { transform: rotate(-90deg); }
input.cb-chapter-name {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: 6px; background: transparent;
  font: inherit; font-size: 16px; font-weight: 600; color: var(--cb-ink);
}
input.cb-chapter-name:hover { border-color: var(--cb-line); }
input.cb-chapter-name:focus { outline: none; border-color: var(--brand-mid); background: #fff; box-shadow: var(--cb-ring); }
input.cb-chapter-name[aria-invalid="true"] { border-color: var(--cb-danger); }
.cb-chapter-count { flex-shrink: 0; font-size: 13px; color: var(--cb-muted); white-space: nowrap; padding-right: 6px; }
.cb-chapter-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.cb-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cb-icon-btn:disabled:hover { background: transparent; color: var(--cb-muted); }
.cb-icon-btn.cb-danger:hover { color: var(--cb-danger); background: #fef2f2; }
.cb-icon-btn:not(.cb-danger):hover { color: var(--cb-accent-dark); }
.cb-chapter-body { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 4px 16px 16px 52px; }
.is-collapsed .cb-chapter-body { display: none; }
.cb-chapter-empty { margin: 0; font-size: 14px; color: var(--cb-muted); }

.cb-empty-builder { padding: 64px 20px; }
.cb-empty-actions { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* Pinned to the bottom of the viewport, beside the sidebar. (position: sticky can't be used: style.css sets
   overflow-x: hidden on html/body, which stops sticky elements sticking.) The offsets track the sidebar's width. */
.cb-addbar { position: fixed; bottom: 0; left: 232px; right: 0; z-index: 25; padding: 14px 40px; pointer-events: none; background: linear-gradient(to top, #fff 65%, rgba(255, 255, 255, 0)); }
.cb-addbar > * { pointer-events: auto; }
@media (max-width: 1199px) and (min-width: 768px) { .cb-addbar { left: 208px; padding-inline: 24px; } }
@media (min-width: 768px) { html.nav-collapsed .cb-addbar { left: var(--cb-rail); } }
@media (max-width: 767px) { .cb-addbar { left: 0; padding: 12px 16px; } }
.cb-addchapter {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 22px; border: none; border-radius: 8px;
  background: var(--cb-navy); color: #fff; font: inherit; font-size: 15.5px; font-weight: 600; cursor: pointer; box-shadow: 0 8px 20px -10px rgba(27, 37, 89, 0.7);
}
.cb-addchapter:hover:not(:disabled) { background: #121a45; }
.cb-addchapter:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.cb-addchapter:disabled { opacity: 0.55; cursor: not-allowed; }

dialog.cb-modal-sm { width: min(440px, calc(100vw - 32px)); }
.cb-confirm-text { margin: 12px 0 8px; font-size: 15px; line-height: 1.55; color: #334155; }

@media (max-width: 900px) {
  .cb-bgrid { grid-template-columns: 1fr; gap: 20px; }
  .cb-side { position: static; flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .cb-covercard { flex: 1 1 260px; }
  .cb-sidebtns { flex: 1 1 200px; }
}
@media (max-width: 640px) {
  .cb-btitle { font-size: 18px; flex-basis: 100%; order: 1; }
  .cb-bhead .cb-back { order: 0; }
  .cb-bhead .cb-pill { order: 0; }
  .cb-savestate { order: 2; }
  .cb-bactions { order: 3; width: 100%; }
  .cb-bactions .cb-btn:not(.cb-btn-square) { flex: 1; }
  .cb-chapter-head { flex-wrap: wrap; }
  input.cb-chapter-name { flex-basis: calc(100% - 100px); }
  .cb-chapter-count { order: 3; }
  .cb-chapter-actions { order: 4; width: 100%; justify-content: flex-end; }
  .cb-chapter-body { padding-left: 16px; }
}


/* ---- 8. Items and the Add item dialogs ---------------------------------------- */
.cb-items { list-style: none; margin: 0; padding: 0; align-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.cb-items:empty { display: none; }
.cb-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--cb-line); border-radius: 8px; background: var(--cb-soft); }
.cb-item.is-ghost { opacity: 0.45; border-style: dashed; }
.cb-item-handle { display: inline-flex; color: var(--cb-faint); cursor: grab; touch-action: none; }
.cb-item-kind { color: var(--cb-accent); }
.cb-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cb-item-name { font-size: 14.5px; font-weight: 600; color: var(--cb-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-item-detail { font-size: 12.5px; color: var(--cb-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-item-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
a.cb-icon-btn { text-decoration: none; }

dialog.cb-modal-wide { width: min(1020px, calc(100vw - 32px)); }
.cb-choices { display: grid; grid-template-columns: 1fr 1fr minmax(200px, 0.7fr); gap: 0; padding: 0; }
.cb-choices > section { padding: 12px 22px 18px; min-width: 0; }
.cb-choices > section + section { border-left: 1px solid var(--cb-line); }
.cb-choices h3 { margin: 6px 0 12px; font-size: 17px; font-weight: 700; text-align: center; color: #334155; }
.cb-choices ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cb-choice {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left;
  border: 1px solid transparent; border-radius: 8px; background: transparent; font: inherit; color: var(--cb-ink); cursor: pointer;
}
.cb-choice:hover:not(:disabled) { background: var(--cb-accent-soft); border-color: rgba(var(--brand-mid-rgb), 0.35); }
.cb-choice:focus-visible { outline: none; box-shadow: var(--cb-ring); }
.cb-choice-name { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.cb-choice-desc { font-size: 13.5px; color: var(--cb-muted); line-height: 1.45; }
.cb-choice.is-soon { opacity: 0.6; cursor: not-allowed; }
.cb-choices-import { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; }
.cb-choices-import p { margin: 0; font-size: 14px; color: var(--cb-muted); }
.cb-import-art { color: var(--cb-navy); }

.cb-item-form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.cb-item-form .cb-modal-body { padding-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.cb-item-form .cb-modal-foot .cb-error { margin: 0 0 10px; }
.cb-file { padding: 9px 10px; }
.cb-progress { position: relative; height: 26px; border-radius: 6px; background: #e8ebf5; overflow: hidden; }
.cb-progress[hidden] { display: none; }
.cb-progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--cb-accent); transition: width 0.15s linear; }
.cb-progress-text { position: relative; display: block; text-align: center; line-height: 26px; font-size: 12.5px; font-weight: 600; color: var(--cb-ink); mix-blend-mode: normal; }
.cb-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--cb-line); }
.cb-tab { padding: 10px 14px; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; font: inherit; font-size: 14.5px; font-weight: 600; color: var(--cb-muted); cursor: pointer; }
.cb-tab.is-active { color: var(--cb-accent-dark); border-bottom-color: var(--cb-accent); }
.cb-tab:focus-visible { outline: none; box-shadow: var(--cb-ring); border-radius: 6px 6px 0 0; }
.cb-tabpanel { display: flex; flex-direction: column; gap: 16px; }
.cb-tabpanel[hidden] { display: none; }
.cb-library { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow-y: auto; }
.cb-library-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--cb-line); border-radius: 8px; cursor: pointer; }
.cb-library-row:has(input:checked) { border-color: var(--brand-mid); background: var(--cb-accent-soft); }
.cb-library-row input { accent-color: var(--brand); }
.cb-library-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 860px) {
  .cb-choices { grid-template-columns: 1fr; }
  .cb-choices > section + section { border-left: none; border-top: 1px solid var(--cb-line); }
}
@media (max-width: 640px) {
  .cb-item { flex-wrap: wrap; }
  .cb-item-actions { width: 100%; justify-content: flex-end; }
}


/* ---- 9. AI outline dialog ---------------------------------------------------- */
.cb-outline-setup { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.cb-outline-setup[hidden] { display: none; }
.cb-optional { font-weight: 400; color: var(--cb-muted); font-size: 14px; }
.cb-outline { list-style: none; margin: 10px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: outline; }
.cb-outline-row {
  counter-increment: outline; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 10px 10px 10px 12px; border: 1px solid var(--cb-line); border-radius: 8px; background: var(--cb-soft);
}
.cb-outline-row::before {
  content: counter(outline); width: 28px; height: 28px; margin-top: 6px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--cb-accent-soft); color: var(--cb-accent-dark); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cb-outline-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
input.cb-outline-title { min-height: 40px; font-size: 15px; font-weight: 600; }
.cb-outline-summary { margin: 0 0 0 2px; font-size: 13px; color: var(--cb-muted); line-height: 1.45; }
.cb-outline-actions { display: flex; align-items: center; gap: 2px; padding-top: 4px; }
.cb-outline-add { margin-top: 4px; }
.cb-modal-foot .cb-error { margin: 0 0 10px; }
@media (max-width: 600px) {
  .cb-outline-row { grid-template-columns: 30px minmax(0, 1fr); }
  .cb-outline-actions { grid-column: 1 / -1; justify-content: flex-end; padding-top: 0; }
}

/* ---- 10. Publish / share dialog -------------------------------------------------- */
.cb-publish-body { display: flex; flex-direction: column; gap: 14px; padding-top: 14px; }
.cb-problems { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cb-problem { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 14px; border: 1px solid #fecaca; border-radius: 8px; background: #fef2f2; }
.cb-problem-text { font-size: 14.5px; color: #7f1d1d; }
.cb-copyrow { display: flex; gap: 10px; }
.cb-copyrow input.cb-input { flex: 1; min-width: 0; }
.cb-share-head { margin: 4px 0 0; font-size: 14px; font-weight: 700; color: #334155; }
.cb-share-grid { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cb-share-grid .cb-btn { min-height: 38px; padding: 0 16px; font-size: 14px; }
.cb-bactions .cb-linkbtn { padding: 0 6px; }
.cb-bactions [hidden] { display: none; }
@media (max-width: 600px) {
  .cb-problem { flex-direction: column; align-items: stretch; }
  .cb-copyrow { flex-direction: column; }
}

/* ---- 11. Public course page (/course/<slug>) -------------------------------------- */
.cpub-body { margin: 0; background: #fff; color: var(--cb-ink); }
.cpub-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 32px; border-bottom: 1px solid var(--cb-line); }
.cpub-brand { display: inline-flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; color: var(--cb-ink); text-decoration: none; }
.cpub-brand img { border-radius: 8px; object-fit: cover; }
.cpub-toplink { font-size: 14.5px; font-weight: 600; }
.cpub-preview { padding: 10px 32px; background: var(--cb-warn-bg); color: var(--cb-warn-ink); font-size: 14px; }
.cpub-main { max-width: 1120px; margin: 0 auto; padding: 36px 32px 64px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 48px; align-items: start; }
.cpub-content h1 { margin: 0 0 8px; font-size: 34px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; }
.cpub-tagline { margin: 0 0 22px; font-size: 19px; line-height: 1.45; color: #475569; }
.cpub-content h2 { margin: 34px 0 12px; font-size: 22px; font-weight: 700; }
.cpub-cover { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 10px; background: var(--cb-soft); }
.cpub-cover-inline { display: none; margin: 0 0 22px; }
.cpub-highlights { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cpub-highlights li { display: flex; align-items: flex-start; gap: 10px; font-size: 16px; line-height: 1.5; }
.cpub-highlights svg { flex-shrink: 0; margin-top: 2px; color: #059669; }
.cpub-rich { font-size: 16.5px; line-height: 1.7; color: #334155; overflow-wrap: anywhere; }
.cpub-rich p { margin: 0 0 12px; }
.cpub-rich ul, .cpub-rich ol { margin: 0 0 12px; padding-left: 1.5em; }
.cpub-learn { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cpub-learn li { display: flex; gap: 14px; padding: 16px; border: 1px solid var(--cb-line); border-radius: 10px; }
.cpub-learn-icon { flex-shrink: 0; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: var(--cb-accent-soft); color: var(--cb-accent-dark); }
.cpub-learn strong { display: block; font-size: 16px; }
.cpub-learn p { margin: 4px 0 0; font-size: 14.5px; line-height: 1.5; color: var(--cb-muted); }
.cpub-outline { list-style: none; margin: 0; padding: 0; counter-reset: pub; border: 1px solid var(--cb-line); border-radius: 10px; overflow: hidden; }
.cpub-outline li { counter-increment: pub; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--cb-line); font-size: 15.5px; }
.cpub-outline li:first-child { border-top: none; }
.cpub-outline-name::before { content: counter(pub) ". "; color: var(--cb-faint); font-variant-numeric: tabular-nums; }
.cpub-outline-count { flex-shrink: 0; font-size: 13.5px; color: var(--cb-muted); }
.cpub-side { position: sticky; top: 20px; }
.cpub-card { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid var(--cb-line); border-radius: 12px; background: #fff; box-shadow: var(--cb-shadow); }
.cpub-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.cpub-price-now { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cpub-price-now.is-free { color: #047857; }
.cpub-price-was { font-size: 16px; color: var(--cb-faint); }
.cpub-off { font-size: 13px; font-weight: 700; color: #047857; }
.cpub-cta { width: 100%; min-height: 48px; font-size: 16px; }
.cpub-note { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--cb-muted); }
.cpub-facts { list-style: none; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--cb-line); display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #475569; }
.cpub-foot { padding: 24px 32px 40px; border-top: 1px solid var(--cb-line); text-align: center; font-size: 13.5px; color: var(--cb-muted); }
@media (max-width: 900px) {
  .cpub-main { grid-template-columns: 1fr; gap: 28px; padding: 24px 16px 32px; }
  .cpub-foot { padding-bottom: 200px; }  /* room for the pinned enrol bar */
  .cpub-cover-inline { display: block; }
  .cpub-content h1 { font-size: 27px; }
  .cpub-learn { grid-template-columns: 1fr; }
  .cpub-top, .cpub-preview { padding-left: 16px; padding-right: 16px; }
  /* The enrol card becomes a bar pinned to the bottom of the screen: price on one side, the button on the other. */
  .cpub-side { position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 20; }
  .cpub-card { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 12px 16px; border-width: 1px 0 0; border-radius: 0; box-shadow: 0 -8px 24px -12px rgba(15, 23, 42, 0.35); }
  .cpub-side .cpub-cover, .cpub-facts { display: none; }
  .cpub-price-now { font-size: 24px; }
  .cpub-cta { width: auto; flex-shrink: 0; padding: 0 22px; }
  .cpub-note { flex-basis: 100%; font-size: 12.5px; }
}


/* ---- 12. Tests in a chapter ---------------------------------------------------------- */
.cb-tests { align-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.cb-tests[hidden] { display: none; }
.cb-tests-caption { margin: 4px 0 0; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cb-muted); }
.cb-test { background: #fff; }
.cb-test .cb-item-kind { color: #b45309; }
.cb-library-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cb-picker-links { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cb-picker-links [hidden] { display: none; }

.cb-picker-elsewhere { margin-top: 8px; padding: 10px 12px; background: var(--cb-warn-bg); color: var(--cb-warn-ink); border-radius: 8px; font-weight: 500; }
