/* Captain Slides: the payonline / captain_study design system (near-black
   ground with accent glows, Manrope, pill nav chips, gradient CTA); dark by
   default, light via <html data-theme="light">. Editor-specific rules are at
   the end of the file. */

:root {
  --background: #0a0a0b;
  --foreground: #ffffff;
  --card: #151517;
  --muted: #1f1f1f;
  --muted-foreground: #9a9aa3;
  --border: #2a2a2e;
  --primary: #ffffff;
  --primary-foreground: #0a0a0b;
  --accent: #e60165;
  --accent-2: #8000db;
  --ring: var(--accent);
  --danger: #ff4d6d;
  --success: #35d073;
  --warn: #ffb020;
  --radius: 0.625rem;
  /* Long-form reading (lesson pages + editor): Manrope like the rest of the
     UI, but a softened text color, 600-weight headings and Notion-like
     spacing between paragraphs / list items (user decision 2026-09-13). */
  --doc-fg: #d4d4d8;
  --doc-heading: #f4f4f5;
  --doc-width: 46rem;
  --callout-bg: #232326;
  --code-bg: #1b1b1e;
  --inline-code: #ff6b6b;
  --sidebar-bg: rgba(10, 10, 11, 0.6);
  color-scheme: dark;
}
[data-theme="light"] {
  --background: #f7f7f9;
  --foreground: #16161a;
  --card: #ffffff;
  --muted: #ececf0;
  --muted-foreground: #63636e;
  --border: #dcdce2;
  --primary: #16161a;
  --primary-foreground: #ffffff;
  --doc-fg: #2b2b30;
  --doc-heading: #16161a;
  --callout-bg: #f1f1f4;
  --code-bg: #f1f1f4;
  --inline-code: #c92a2a;
  --sidebar-bg: rgba(255, 255, 255, 0.65);
  --success: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Manrope, -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--foreground);
  background:
    radial-gradient(55% 38% at 75% -5%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 65%),
    radial-gradient(45% 30% at 15% 105%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--background);
  background-attachment: fixed;
}
[data-theme="light"] body {
  background:
    radial-gradient(55% 38% at 75% -5%, color-mix(in srgb, var(--accent-2) 7%, transparent), transparent 65%),
    radial-gradient(45% 30% at 15% 105%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 60%),
    var(--background);
}
button { font: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted-foreground); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }

/* ---------- app shell: sidebar + content ---------- */

#app { display: flex; height: 100dvh; }
.sidebar {
  width: 15.5rem; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--sidebar-bg);
  padding: 1.1rem 0.8rem; gap: 0.15rem;
}
.brand { display: flex; align-items: center; padding: 0.2rem 0.5rem 1.1rem; min-width: 0; }
.brand-word { font-weight: 800; letter-spacing: -0.03em; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-dot {
  display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-left: 0.25rem; flex: none;
  background: linear-gradient(0deg, var(--accent), var(--accent-2));
}
.nav-items { display: flex; flex-direction: column; gap: 0.3rem; }
a.nav-item, a.card, a.row-card { text-decoration: none; }
.nav-item {
  display: flex; align-items: center; gap: 0.6rem; border: 1px solid transparent; background: transparent;
  color: var(--muted-foreground); padding: 0.5rem 0.9rem; min-height: 2.5rem; border-radius: 999px;
  cursor: pointer; text-align: left; font-size: 0.92rem; width: 100%; font-weight: 600;
}
.nav-item:hover { background: var(--muted); color: var(--foreground); }
.nav-item.active { background: var(--muted); color: var(--foreground); border-color: var(--border); }
.nav-item:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.nav-item .count {
  margin-left: auto; font-size: 0.72rem; font-weight: 800; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 0.05rem 0.45rem; min-width: 1.3rem; text-align: center;
}
.sidebar .spacer { flex: 1; }
.sidebar-user {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.6rem 0.6rem 0.1rem;
  border-top: 1px solid var(--border); margin-top: 0.5rem; cursor: pointer;
}
.sidebar-user:hover .u-name { color: var(--accent); }
.sidebar-user .u-name { font-size: 0.85rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.avatar {
  width: 2rem; height: 2rem; border-radius: 50%; flex: none; background: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 800;
  color: var(--muted-foreground); overflow: hidden; border: 1px solid var(--border);
}
.content { flex: 1; overflow-y: auto; min-width: 0; }
.content-inner { max-width: 64rem; margin: 0 auto; padding: 2rem 1.5rem 3.5rem; }
.content-inner.wide { max-width: 100rem; }
.page-title { margin: 0 0 0.4rem; font-size: 1.7rem; letter-spacing: -0.03em; font-weight: 800; text-wrap: balance; }
.page-desc { margin: 0 0 1.4rem; color: var(--muted-foreground); max-width: 44rem; line-height: 1.5; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .page-title { margin-bottom: 0.2rem; }
.page-head .actions { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.back-row { margin-bottom: 0.8rem; }
.back-link { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted-foreground); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.back-link:hover { color: var(--accent); }
.toolbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- cards / rows ---------- */

.section { margin-bottom: 2.4rem; }
.section-title { margin: 0 0 0.35rem; font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }
.section-desc { margin: 0 0 0.9rem; font-size: 0.88rem; color: var(--muted-foreground); max-width: 44rem; line-height: 1.5; }

/* Horizontal entity rows (programs, versions, cohorts, modules, participant
   programs/modules). One row = icon | body (title + meta) | actions. */
.rows { display: flex; flex-direction: column; gap: 0.6rem; }
.row-card {
  display: flex; align-items: center; gap: 0.9rem; position: relative;
  border: 1px solid var(--border); border-radius: 0.85rem; background: var(--card);
  padding: 0.85rem 1rem; color: var(--foreground);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.row-card.clickable { cursor: pointer; }
.row-card.clickable:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 10%, transparent); }
.row-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.row-icon { font-size: 1.5rem; line-height: 1; width: 2.2rem; text-align: center; flex: none; }
.row-icon.svg { color: var(--muted-foreground); display: inline-flex; justify-content: center; }
.row-icon.svg .icon { width: 1.35rem; height: 1.35rem; }
.row-body { flex: 1; min-width: 0; }
.row-title { font-weight: 800; font-size: 0.98rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.row-desc { font-size: 0.86rem; color: var(--muted-foreground); line-height: 1.45; margin-top: 0.15rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-meta { font-size: 0.8rem; color: var(--muted-foreground); margin-top: 0.25rem; display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.row-meta .icon { width: 0.95rem; height: 0.95rem; }
.row-actions { display: flex; gap: 0.35rem; align-items: center; flex: none; }
.row-arrow { color: var(--muted-foreground); flex: none; }
.row-arrow .icon { width: 1.1rem; height: 1.1rem; }
.row-card.dragging { opacity: 0.45; }
.row-card.drag-over { border-color: var(--accent); }
.drag-handle { display: inline-flex; align-items: center; justify-content: center; color: var(--muted-foreground); cursor: grab; flex: none; width: 1.4rem; height: 1.8rem; border-radius: 0.35rem; }
.drag-handle:hover { background: var(--muted); color: var(--foreground); }
.drag-handle:active { cursor: grabbing; }
.drag-handle .icon { width: 1rem; height: 1rem; }

.empty { color: var(--muted-foreground); font-size: 0.9rem; padding: 1.5rem 0; }
.empty-card {
  border: 1px dashed var(--border); border-radius: 0.85rem; padding: 1.8rem 1rem; text-align: center;
  color: var(--muted-foreground); font-size: 0.9rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.empty-card .icon { width: 1.6rem; height: 1.6rem; opacity: 0.7; }

/* ---------- buttons / inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius);
  border: 1px solid var(--border); padding: 0.45rem 1rem; min-height: 2.6rem; min-width: 2.6rem;
  background: transparent; color: var(--foreground); cursor: pointer; gap: 0.45rem; font-weight: 700;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s, filter 0.12s; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--muted); }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn-primary { background: linear-gradient(0deg, var(--accent) 0%, var(--accent-2) 100%); color: #fff; border-color: transparent; }
.btn-primary:hover { filter: brightness(1.12); background: linear-gradient(0deg, var(--accent) 0%, var(--accent-2) 100%); }
.btn-white { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.btn-white:hover { opacity: 0.9; }
.btn-outline, .btn-ghost { border-color: var(--border); }
.btn-sm { min-height: 2.1rem; min-width: 2.1rem; padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.btn-sm.btn-primary { background: var(--accent); }
.btn-icon { padding: 0.2rem; width: 2.1rem; min-width: 2.1rem; }
.btn-icon.btn-sm { width: 2.1rem; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn:disabled { opacity: 0.4; cursor: default; }
.input, .select, .textarea {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--foreground);
  padding: 0.4rem 0.7rem; min-height: 2.6rem; font: inherit; width: 100%;
}
.textarea { min-height: 5rem; resize: vertical; line-height: 1.5; padding-top: 0.55rem; }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.input-sm { min-height: 2.1rem; padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.badge {
  font-size: 0.7rem; font-weight: 700; padding: 0 0.55rem; height: 1.45rem; line-height: 1.35rem; border-radius: 999px; border: 1px solid var(--border);
  color: var(--muted-foreground); white-space: nowrap; background: var(--muted); display: inline-flex; align-items: center; gap: 0.3rem; vertical-align: middle;
}
.badge .icon { width: 0.8rem; height: 0.8rem; }
.badge.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 10%, transparent); }
.badge.accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.badge.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; height: 2rem; padding: 0 0.3rem 0 0.75rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--muted); font-size: 0.85rem; font-weight: 600;
}
.chip .btn-icon { width: 1.5rem; min-width: 1.5rem; height: 1.5rem; min-height: 1.5rem; border-radius: 50%; padding: 0; }
.chip .btn-icon .icon { width: 0.8rem; height: 0.8rem; }

/* ---------- login ---------- */

.center-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 40; background: var(--background); }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 1.1rem; padding: 2.3rem 1.9rem;
  max-width: 25rem; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 1rem; align-items: center;
}
.login-card h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; font-weight: 800; }
.login-card p { margin: 0; font-size: 0.9rem; color: var(--muted-foreground); }
.spinner { width: 1rem; height: 1rem; border-radius: 50%; flex: none; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground);
  font-weight: 700; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); background: var(--muted); white-space: nowrap;
}
.table td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; line-height: 1.4; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--muted); }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { vertical-align: middle; }
.table td.actions .btn + .btn { margin-left: 0.3rem; }
.table td.num { text-align: center; }
.table th.num { text-align: center; }
.count-link { color: var(--accent); cursor: pointer; font-weight: 700; text-decoration: underline dotted; text-underline-offset: 3px; }
.count-link.muted { color: var(--muted-foreground); }

/* ---------- forms ---------- */

.form-card { border: 1px solid var(--border); border-radius: 1rem; background: var(--card); padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.form-card h2 { margin: 0 0 0.9rem; font-size: 1rem; font-weight: 800; letter-spacing: -0.01em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.field > label { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground); }
.field .hint, .hint { font-size: 0.8rem; color: var(--muted-foreground); line-height: 1.45; }
.field-wide { grid-column: 1 / -1; }
.check-row { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; cursor: pointer; }
.check-row input[type="checkbox"], .check-row input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); margin: 0; flex: none; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; background: var(--muted); border: 1px solid var(--border); border-radius: 0.45rem; padding: 0.15rem 0.5rem; word-break: break-all; }
.color-swatches { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.swatch { width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--foreground); box-shadow: 0 0 0 2px var(--card); }
.swatch:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.color-dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-right: 0.45rem; vertical-align: middle; }

.toast {
  position: fixed; top: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--primary); color: var(--primary-foreground);
  padding: 0.6rem 1.1rem; border-radius: var(--radius); font-size: 0.9rem; font-weight: 700; z-index: 3000;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); max-width: 90vw; pointer-events: none;
}
.toast.err { background: var(--danger); color: #fff; }

/* ---------- tabs (hash-routed, as in captain_pipelines) ---------- */

.tabs { display: flex; gap: 0.4rem; margin: 0 0 1.1rem; flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid transparent; background: transparent;
  color: var(--muted-foreground); padding: 0.35rem 0.9rem; border-radius: 999px; cursor: pointer; font: inherit;
  font-size: 0.88rem; font-weight: 700; text-decoration: none;
}
.tab:hover { background: var(--muted); color: var(--foreground); }
.tab.active { background: var(--muted); color: var(--foreground); border-color: var(--border); }
.tab .icon { width: 1rem; height: 1rem; }

/* ---------- profile ---------- */

.profile-card { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); padding: 1.3rem 1.4rem; max-width: 36rem; margin-bottom: 1rem; }
.profile-card .avatar { width: 4rem; height: 4rem; font-size: 1.4rem; }
.profile-info { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; flex: 1; }
.profile-name { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em; }
.profile-meta { font-size: 0.85rem; color: var(--muted-foreground); word-break: break-all; }
.viewas-banner {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 2000; display: flex; align-items: center; gap: 0.8rem;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 0.88rem; padding: 0.5rem 0.7rem 0.5rem 1.1rem; border-radius: 999px;
  box-shadow: 0 8px 32px color-mix(in srgb, var(--accent) 35%, transparent); max-width: min(92vw, 40rem);
}
.viewas-banner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewas-banner .btn { color: #fff; border-color: rgba(255,255,255,0.5); }
.viewas-banner .btn:hover { background: rgba(255,255,255,0.15); }

/* ---------- modal ---------- */

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 1rem; padding: 1.3rem 1.4rem; width: 100%; max-width: 34rem; max-height: 90dvh; overflow: auto; position: relative; }
.modal h2 { margin: 0 0 0.9rem; font-size: 1.05rem; font-weight: 800; }
.modal.wide { max-width: 52rem; }
.modal.preview { max-width: 62rem; padding: 1.4rem 2rem 2rem; }
.modal-close { position: absolute; top: 0.8rem; right: 0.8rem; }

/* ---------- notifications ---------- */

.notif { display: flex; gap: 0.85rem; align-items: flex-start; padding: 0.85rem 1rem; border: 1px solid var(--border); border-radius: 0.85rem; background: var(--card); margin-bottom: 0.6rem; text-decoration: none; color: inherit; }
.notif.unread { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.notif-icon { width: 2.1rem; height: 2.1rem; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--muted); color: var(--muted-foreground); }
.notif-icon .icon { width: 1rem; height: 1rem; }
.notif.unread .notif-icon { background: var(--accent); color: #fff; }
.notif-title { font-weight: 700; font-size: 0.92rem; }
.notif.read .notif-title { font-weight: 600; }
.notif-body { font-size: 0.82rem; color: var(--muted-foreground); margin-top: 0.15rem; }

/* ---------- document (rendered blocks) ---------- */

.doc { font-size: 1rem; line-height: 1.65; color: var(--doc-fg); max-width: var(--doc-width); }
.doc-hero { font-size: 4.2rem; line-height: 1; margin: 0.5rem 0 0.6rem; }
.doc-title { font-size: 2.2rem; font-weight: 600; letter-spacing: normal; margin: 0 0 1rem; color: var(--doc-heading); line-height: 1.2; }
.doc h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: normal; margin: 1.5rem 0 0.25rem; padding: 3px 0; color: var(--doc-heading); line-height: 1.3; }
.doc h3 { font-size: 1.25rem; font-weight: 600; letter-spacing: normal; margin: 1.1rem 0 0.15rem; padding: 3px 0; color: var(--doc-heading); line-height: 1.3; }
.doc h4 { font-size: 1.05rem; font-weight: 600; margin: 0.8rem 0 0.1rem; padding: 3px 0; color: var(--doc-heading); }
.doc p { margin: 1px 0; padding: 3px 0; min-height: 1.2em; }
.doc strong { font-weight: 600; }
.doc ul, .doc ol { margin: 0; padding-left: 1.6rem; }
.doc li { margin: 0; padding: 5px 0; }
.doc li > ul, .doc li > ol { margin-top: 2px; }
.doc ul ul, .doc ol ul { list-style: circle; }
.doc ul ul ul { list-style: square; }
.doc ol, .doc ol ol, .doc ol ol ol { list-style: decimal; }
.doc a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
.doc a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.doc code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; background: var(--muted); color: var(--inline-code); padding: 0.1em 0.35em; border-radius: 0.35rem; }
.doc pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.85rem 1rem; overflow-x: auto; font-size: 0.86rem; line-height: 1.5; margin: 0.6rem 0; }
.doc pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.doc blockquote { margin: 4px 0; padding: 3px 0 3px 0.9rem; border-left: 3px solid var(--doc-heading); }
.doc .callout { display: flex; gap: 0.7rem; background: var(--callout-bg); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.85rem 1rem 0.85rem 0.85rem; margin: 0.6rem 0; }
.doc .callout-emoji { font-size: 1.35rem; line-height: 1.3; flex: none; }
.doc .callout-body { flex: 1; min-width: 0; }
.doc details { margin: 0; }
.doc summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: flex-start; gap: 0.3rem; padding: 5px 0; }
.doc summary::-webkit-details-marker { display: none; }
.doc summary::before { content: ""; display: inline-block; width: 0.45em; height: 0.45em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin: 0.55em 0.35em 0 0.2em; flex: none; transition: transform 0.15s; }
.doc details[open] > summary::before { transform: rotate(45deg); }
.doc .toggle-body { padding-left: 1.4rem; }
.doc figure { margin: 8px 0; }
.doc figure img { max-width: 100%; height: auto; display: block; border-radius: 0.5rem; }
.doc figure img.zoomable { cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; z-index: 2500; background: rgba(0, 0, 0, 0.88); display: flex; align-items: center; justify-content: center; padding: 2rem; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 0.5rem; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.lightbox-close { position: absolute; top: 1rem; right: 1rem; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.lightbox-close:hover { background: rgba(255, 255, 255, 0.15); }
.doc figcaption { font-size: 0.82rem; color: var(--muted-foreground); margin-top: 0.35rem; }
.doc .ratio { position: relative; width: 100%; border-radius: 0.6rem; overflow: hidden; background: var(--muted); }
.doc .ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.doc .child-page {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.55rem; margin: 0.15rem 0; border-radius: 0.5rem;
  color: var(--foreground); text-decoration: none; font-weight: 600;
}
.doc .child-page:hover { background: var(--muted); }
.doc .child-page .emoji { width: 1.4rem; text-align: center; font-size: 1.1rem; }
.doc .child-page .title { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.doc .child-page .badge { margin-left: 0.3rem; }
.doc .field { margin: 0.9rem 0; gap: 0.4rem; }
.doc .field .q { font-weight: 700; color: var(--foreground); font-size: 0.95rem; }
.doc .field .q .req { color: var(--danger); margin-left: 0.2rem; }
.doc .field .input, .doc .field .textarea { max-width: 100%; }
.doc .empty-line { min-height: 1.4em; }
.doc .file-drop { border: 1px dashed var(--border); border-radius: var(--radius); padding: 0.8rem; font-size: 0.88rem; color: var(--muted-foreground); background: var(--card); display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.details-card { border: 1px solid var(--border); border-radius: 0.85rem; background: var(--card); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.details-card summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 0.45rem; }
.details-card summary::-webkit-details-marker { display: none; }
.details-card summary::before { content: ""; display: inline-block; width: 0.45em; height: 0.45em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin-right: 0.3rem; transition: transform 0.15s; }
.details-card[open] > summary::before { transform: rotate(45deg); }
.details-card .doc { margin-top: 0.8rem; }

/* page navigation on the study side */
/* Same type as .back-link ("← Программы") so lesson paths line up with it. */
.crumbs { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; font-size: 0.88rem; font-weight: 600; color: var(--muted-foreground); margin-bottom: 0.8rem; min-width: 0; }
/* Titles are never cut: a long path wraps onto the next line instead. */
.crumbs a, .crumbs span[data-drop-page] { color: inherit; text-decoration: none; display: inline; gap: 0.3rem; align-items: center; padding: 0.1rem 0.3rem; border-radius: 0.4rem; line-height: 1.5; }
.crumbs > :first-child { padding-left: 0; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: 0.6; }
/* Same breathing room as the reference course: ~30px above, ~35px below. */
.pills { display: flex; gap: 0.3rem; flex-wrap: wrap; margin: 1.9rem 0 2.2rem; }
.pill {
  width: 2.25rem; height: 2.25rem; border-radius: 0.75rem; display: inline-flex; align-items: center; justify-content: center;
  background: var(--muted); color: var(--foreground); font-weight: 700; font-size: 0.88rem; text-decoration: none; border: 1px solid transparent;
}
.pill:hover { border-color: var(--border); }
.pill.active { background: var(--accent); color: #fff; }
/* Task status banner: icon + text, tinted by state. */
.task-status { display: flex; align-items: center; gap: 0.6rem; font-size: 0.92rem; font-weight: 600; padding: 0.75rem 1rem; border-radius: 0.85rem; border: 1px solid var(--border); background: var(--card); margin: 0.9rem 0; }
.task-status .icon { width: 1.1rem; height: 1.1rem; flex: none; }
.task-status.ok { color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--card)); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.task-status.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--card)); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.task-status.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--card)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.iteration { border: 1px solid var(--border); border-radius: 0.85rem; padding: 0.9rem 1rem 1rem; margin: 0.8rem 0; background: var(--card); }
.iteration-head { display: flex; gap: 0.55rem; align-items: center; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted-foreground); margin-bottom: 0.6rem; }
.iteration-head b { color: var(--foreground); }
.answer { margin: 0; }
.answer + .answer { margin-top: 0.75rem; }
.answer .q { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); font-weight: 800; }
.answer .v { white-space: pre-wrap; word-break: break-word; margin-top: 0.2rem; line-height: 1.5; }
.answer .v a { display: inline-flex; align-items: center; gap: 0.3rem; }
.verdict { display: flex; gap: 0.7rem; align-items: flex-start; margin-top: 0.9rem; padding: 0.7rem 0.9rem; border-radius: 0.7rem; background: var(--muted); }
.verdict .icon { width: 1rem; height: 1rem; flex: none; margin-top: 0.15rem; }
.verdict.ok .icon { color: var(--success); }
.verdict.danger .icon { color: var(--danger); }
.verdict-title { font-weight: 800; font-size: 0.9rem; }
.verdict-meta { font-size: 0.78rem; color: var(--muted-foreground); margin-top: 0.1rem; }
.verdict .doc { margin-top: 0.4rem; font-size: 0.95rem; }
.verdict .doc > :first-child { margin-top: 0; }
.verdict .doc > :last-child { margin-bottom: 0; }

/* ---------- editor ---------- */

.editor { position: relative; font-size: 1rem; line-height: 1.65; color: var(--doc-fg); }
.ed-text b, .ed-text strong { font-weight: 600; }
.ed-text code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; background: var(--muted); color: var(--inline-code); padding: 0.1em 0.35em; border-radius: 0.35rem; }
.ed-block.code .ed-text code { background: none; color: inherit; padding: 0; font-size: inherit; }
.ed-text a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
.ed-title-row { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; margin: 0 0 1rem; }
.ed-hero { font-size: 4.2rem; line-height: 1; cursor: pointer; border-radius: 0.6rem; padding: 0.1rem 0.3rem; margin: 0.4rem 0 0; user-select: none; }
.ed-hero:hover { background: var(--muted); }
/* Empty icon placeholder: dashed square with a plus, caption below. */
.ed-hero.empty { display: inline-flex; flex-direction: column; align-items: center; gap: 0.3rem; font-size: 0.75rem; color: var(--muted-foreground); font-weight: 700; padding: 0; background: transparent; }
.ed-hero.empty .sq { width: 3rem; height: 3rem; border: 1px dashed var(--border); border-radius: 0.6rem; display: inline-flex; align-items: center; justify-content: center; }
.ed-hero.empty .sq .icon { width: 1.1rem; height: 1.1rem; }
.ed-hero.empty:hover .sq { border-color: var(--accent); color: var(--accent); }
.ed-title { font-size: 2.2rem; font-weight: 600; letter-spacing: normal; line-height: 1.2; border: 0; background: transparent; color: var(--doc-heading); width: 100%; outline: none; padding: 0; font-family: inherit; }
.ed-title:empty::before { content: attr(data-placeholder); color: var(--muted-foreground); }
.ed-block { position: relative; display: flex; align-items: flex-start; }
.ed-gutter { width: 3rem; flex: none; display: flex; justify-content: flex-end; gap: 0.1rem; padding-right: 0.3rem; margin-left: -3rem; opacity: 0; transition: opacity 0.1s; padding-top: 0.2rem; }
.ed-block:hover > .ed-gutter, .ed-block.menu-open > .ed-gutter { opacity: 1; }
.ed-gbtn { width: 1.35rem; height: 1.35rem; border: 0; border-radius: 0.35rem; background: transparent; color: var(--muted-foreground); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.ed-gbtn:hover { background: var(--muted); color: var(--foreground); }
.ed-gbtn.handle { cursor: grab; }
.ed-gbtn .icon { width: 1rem; height: 1rem; }
.ed-main { flex: 1; min-width: 0; }
.ed-text { outline: none; white-space: pre-wrap; word-break: break-word; min-height: 1.4em; }
/* Placeholders only on the hovered or focused empty block, not on every empty line. */
.ed-block:hover > .ed-main > .ed-text:empty::before, .ed-block:hover > .ed-main > .ed-li > .ed-text:empty::before,
.ed-block:hover > .ed-main > .ed-callout-body > .ed-text:empty::before, .ed-block:hover > .ed-main > .ed-field > .ed-text:empty::before,
.ed-text:focus:empty::before { content: attr(data-placeholder); color: var(--muted-foreground); pointer-events: none; }
.ed-text[data-placeholder=""]::before { content: none !important; }
.ed-block.h1 .ed-text { font-size: 1.5rem; font-weight: 600; line-height: 1.3; margin: 1.5rem 0 0.25rem; padding: 3px 0; color: var(--doc-heading); }
.ed-block.h2 .ed-text { font-size: 1.25rem; font-weight: 600; line-height: 1.3; margin: 1.1rem 0 0.15rem; padding: 3px 0; color: var(--doc-heading); }
.ed-block.h3 .ed-text { font-size: 1.05rem; font-weight: 600; margin: 0.8rem 0 0.1rem; padding: 3px 0; color: var(--doc-heading); }
.ed-block.paragraph .ed-text { padding: 3px 0; margin: 1px 0; }
.ed-li { display: flex; gap: 0.5rem; align-items: flex-start; }
.ed-li .marker { flex: none; width: 1.4rem; text-align: right; padding-top: 5px; user-select: none; color: var(--doc-fg); }
.ed-li .ed-text { flex: 1; padding: 5px 0; }
.ed-block.bulleted > .ed-main > .ed-li .marker::before { content: "•"; font-size: 1.2em; line-height: 1; }
.ed-block.bulleted .ed-block.bulleted > .ed-main > .ed-li .marker::before { content: "◦"; }
.ed-block.bulleted .ed-block.bulleted .ed-block.bulleted > .ed-main > .ed-li .marker::before { content: "▪"; font-size: 0.9em; }
.ed-children { padding-left: 1.6rem; }
.ed-block.toggle > .ed-main > .ed-li .marker { cursor: pointer; }
.ed-block.toggle > .ed-main > .ed-li .marker::before { content: ""; display: inline-block; width: 0.45em; height: 0.45em; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin-bottom: 0.15em; transition: transform 0.15s; }
.ed-block.toggle.open > .ed-main > .ed-li .marker::before { transform: rotate(45deg); }
.ed-block.toggle:not(.open) > .ed-main > .ed-children { display: none; }
.ed-block.toggle > .ed-main > .ed-li .ed-text { font-weight: 600; }
.ed-block.quote > .ed-main { border-left: 3px solid var(--doc-heading); padding: 3px 0 3px 0.9rem; margin: 4px 0; }
.ed-block.callout > .ed-main { display: flex; gap: 0.7rem; background: var(--callout-bg); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.85rem 1rem 0.85rem 0.85rem; margin: 0.6rem 0; }
.ed-callout-emoji { font-size: 1.35rem; line-height: 1.3; cursor: pointer; border-radius: 0.4rem; padding: 0 0.15rem; flex: none; align-self: flex-start; user-select: none; }
.ed-callout-emoji:hover { background: var(--muted); }
.ed-callout-body { flex: 1; min-width: 0; }
.ed-block.divider > .ed-main { padding: 1rem 0; }
.ed-block.divider hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
.ed-block.code > .ed-main { margin: 0.4rem 0; }
.ed-block.code .ed-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.85rem 1rem; line-height: 1.5; }
.ed-block.code .ed-lang { font-size: 0.72rem; color: var(--muted-foreground); margin-bottom: 0.2rem; }
.ed-block.code .ed-lang input { font: inherit; background: transparent; border: 0; color: inherit; outline: none; border-bottom: 1px dashed var(--border); width: 8rem; }
.ed-media { margin: 8px 0; }
.ed-media img { max-width: 100%; height: auto; display: block; border-radius: 0.5rem; }
.ed-media .ratio { position: relative; width: 100%; border-radius: 0.6rem; overflow: hidden; background: var(--muted); }
.ed-media .ratio iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.ed-media .ed-caption { font-size: 0.82rem; color: var(--muted-foreground); margin-top: 0.35rem; outline: none; min-height: 1.2em; }
.ed-media .ed-caption:empty::before { content: "Подпись…"; color: var(--muted-foreground); opacity: 0.6; }
.ed-media-tools { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.35rem; opacity: 0; transition: opacity 0.1s; }
.ed-block:hover .ed-media-tools, .ed-block.selected .ed-media-tools { opacity: 1; }
.ed-media.selected img, .ed-media.selected .ratio { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-placeholder { border: 1px dashed var(--border); border-radius: var(--radius); padding: 0.8rem 1rem; color: var(--muted-foreground); font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; cursor: pointer; background: var(--card); }
.ed-placeholder:hover { border-color: var(--accent); }
.ed-block.child_page > .ed-main .child-page { display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.55rem; margin: 0.1rem 0; border-radius: 0.5rem; color: var(--foreground); text-decoration: none; font-weight: 600; cursor: pointer; }
.ed-block.child_page > .ed-main .child-page:hover { background: var(--muted); }
.ed-block.child_page .emoji { width: 1.4rem; text-align: center; font-size: 1.1rem; }
.ed-block.child_page .title { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.ed-field { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 0.7rem 0.9rem; margin: 0.5rem 0; }
.ed-field .ed-field-kind { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground); font-weight: 800; display: flex; align-items: center; gap: 0.6rem; }
.ed-field .ed-field-kind .check-row { margin-left: auto; font-size: 0.75rem; text-transform: none; letter-spacing: 0; gap: 0.3rem; }
.ed-field .ed-text { font-weight: 700; margin: 0.25rem 0; }
.ed-field .ed-preview { border: 1px dashed var(--border); border-radius: 0.45rem; padding: 0.4rem 0.6rem; font-size: 0.85rem; color: var(--muted-foreground); }
.ed-field .ed-preview.tall { min-height: 3.6rem; }
.ed-block.selected > .ed-main { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 0.4rem; }
.ed-drop-line { position: absolute; height: 3px; background: var(--accent); border-radius: 2px; pointer-events: none; z-index: 5; display: none; }
.ed-drop-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.ed-block.drag-src { opacity: 0.35; }
.ed-block.child_page.drop-into > .ed-main .child-page,
.crumbs [data-drop-page].drop-target, .tree-node.drop-target { outline: 2px solid var(--accent); outline-offset: 1px; background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 0.5rem; }
.ed-tools { display: flex; gap: 0.3rem; align-items: center; }
.ed-tools .btn:disabled { opacity: 0.35; }
.ed-menu {
  position: absolute; z-index: 1200; background: var(--card); border: 1px solid var(--border); border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); width: 17rem; max-height: 22rem; overflow: auto; padding: 0.35rem;
}
.ed-menu input { width: 100%; margin-bottom: 0.3rem; }
.ed-menu .grp { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground); font-weight: 800; padding: 0.4rem 0.6rem 0.15rem; }
.ed-menu .item { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.88rem; font-weight: 600; width: 100%; border: 0; background: transparent; color: var(--foreground); text-align: left; }
.ed-menu .item:hover, .ed-menu .item.active { background: var(--muted); }
.ed-menu .item .icon { width: 1.05rem; height: 1.05rem; color: var(--muted-foreground); }
.ed-menu .item .sub { font-size: 0.72rem; color: var(--muted-foreground); font-weight: 500; }
.ed-toolbar { position: absolute; z-index: 1200; display: flex; gap: 0.1rem; background: var(--card); border: 1px solid var(--border); border-radius: 0.6rem; padding: 0.2rem; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); }
.ed-toolbar button { border: 0; background: transparent; color: var(--foreground); width: 1.9rem; height: 1.9rem; border-radius: 0.4rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; }
.ed-toolbar button:hover, .ed-toolbar button.on { background: var(--muted); }
.ed-toolbar button .icon { width: 1rem; height: 1rem; }
.ed-saving { font-size: 0.8rem; color: var(--muted-foreground); white-space: nowrap; }
.emoji-picker { position: absolute; z-index: 1300; background: var(--card); border: 1px solid var(--border); border-radius: 0.75rem; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); width: 20rem; max-width: 92vw; padding: 0.5rem; }
.emoji-picker > input { width: 100%; margin-bottom: 0.4rem; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.1rem; max-height: 13rem; overflow: auto; }
.emoji-grid button { border: 0; background: transparent; font-size: 1.35rem; line-height: 1; padding: 0.25rem 0; border-radius: 0.4rem; cursor: pointer; }
.emoji-grid button:hover { background: var(--muted); }
.emoji-picker .grp { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground); font-weight: 800; padding: 0.35rem 0.2rem 0.1rem; grid-column: 1 / -1; }
.emoji-picker .foot { display: flex; gap: 0.4rem; margin-top: 0.4rem; align-items: center; }
.emoji-picker .foot input { margin: 0; flex: 1; min-height: 2.1rem; }
.emoji-picker .foot .btn { min-height: 2.1rem; height: 2.1rem; }

/* Page editor layout: sticky header, editor column with a left gutter
   reserved for the "+"/handle buttons, page tree card on the right. */
.pe-page { padding-left: 3rem; }
.pe-head {
  position: sticky; top: 0; z-index: 20; margin: -2rem 0 1rem -3rem; padding: 1.1rem 0 0.8rem 3rem;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}
.pe-head-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.pe-head-row + .pe-head-row { margin-top: 0.45rem; }
.pe-head .crumbs { margin: 0; }
.pe-head .pe-title { font-weight: 800; font-size: 1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 24rem; }
.pe-head .spacer { flex: 1; }
.pe-head .pe-task { display: inline-flex; align-items: center; gap: 0.45rem; }
.pe-head .pe-task .input { width: 5rem; }
/* Editor column = the reading width (46rem), page tree 1.5x wider than
   before (25.5rem); on narrow screens both shrink proportionally. */
/* Gap to the page tree = the gap between the app sidebar and the text
   (content-inner padding 1.5rem + editor gutter 3rem). */
.editor-layout { display: flex; gap: 4.5rem; align-items: flex-start; }
.editor-col { flex: 1 1 var(--doc-width); max-width: var(--doc-width); min-width: 0; }
.ed-body, .ed-title-row { max-width: var(--doc-width); }
.tree-col { flex: 0 1 25.5rem; min-width: 14rem; position: sticky; top: 6.8rem; border: 1px solid var(--border); border-radius: 0.85rem; background: var(--card); padding: 0.9rem 0.9rem 1rem; max-height: calc(100dvh - 6rem); overflow: auto; font-size: 0.85rem; }
.tree-col .tree-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground); font-weight: 800; margin-bottom: 0.2rem; }
.tree-col .tree-hint { font-size: 0.75rem; color: var(--muted-foreground); line-height: 1.4; margin-bottom: 0.6rem; }
/* Module = parent row (emoji tile + title + "модуль" badge); its pages are
   indented under it with the same guide line as deeper levels. */
.tree-col .tree-root { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 0.6rem; background: var(--muted); color: var(--foreground); text-decoration: none; margin-bottom: 0.35rem; }
.tree-col .tree-root:hover { border-color: var(--accent); }
.tree-col .tree-root.active { border-color: var(--accent); }
.tree-col .tree-root .badge { margin-left: auto; }
.tree-root-emoji { font-size: 1.1rem; line-height: 1; }
.tree-node { display: flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.4rem; border-radius: 0.4rem; text-decoration: none; color: var(--foreground); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: grab; }
.tree-node:hover { background: var(--muted); }
.tree-node.active { background: var(--muted); font-weight: 700; }
.tree-node.dragging { opacity: 0.45; }
.tree-kids { padding-left: 0.9rem; border-left: 1px solid var(--border); margin-left: 0.7rem; }
.tree-kids-root { margin-left: 1rem; }
.tree-empty { font-size: 0.8rem; color: var(--muted-foreground); padding: 0.3rem 0.4rem; }

/* leaderboard */
.lb-wrap { overflow-x: auto; }
.lb { border-collapse: collapse; font-size: 0.9rem; min-width: 100%; }
.lb th, .lb td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; vertical-align: middle; }
.lb th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); background: var(--muted); }
.lb th:first-child, .lb td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); font-weight: 700; }
.lb th:first-child { background: var(--muted); }
.lb td.medal { font-size: 1.25rem; line-height: 1; }
.lb td.dash { color: var(--muted-foreground); }

/* ---------- icons ---------- */
.icon { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }
.btn .icon { width: 1.1em; height: 1.1em; }
.nav-item .icon { width: 1.15em; height: 1.15em; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); padding: 0.45rem 0.55rem; gap: 0.3rem; overflow-x: auto; scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { padding: 0.2rem 0.35rem; flex: none; }
  .brand-word { font-size: 1rem; max-width: 7rem; }
  .nav-items { flex-direction: row; gap: 0.25rem; }
  .nav-item { width: auto; flex: none; padding: 0.4rem 0.7rem; min-height: 2.25rem; font-size: 0.85rem; white-space: nowrap; }
  .nav-item .icon { display: none; }
  .nav-item .count { margin-left: 0.3rem; }
  .sidebar .spacer { display: none; }
  .sidebar-user { border-top: 0; margin: 0 0 0 auto; padding: 0.2rem 0.3rem; flex: none; }
  .sidebar-user .u-name { display: none; }
  .avatar { width: 1.75rem; height: 1.75rem; }
  .content-inner { padding: 1.1rem 0.85rem 2.5rem; }
  .page-title { font-size: 1.35rem; }
  .doc-title { font-size: 1.6rem; }
  .doc-hero { font-size: 3rem; }
  .row-card { flex-wrap: wrap; gap: 0.6rem 0.8rem; }
  .row-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .pe-page { padding-left: 2.4rem; }
  .pe-head { margin: -1.1rem 0 1rem -2.4rem; padding: 0.8rem 0 0.6rem 2.4rem; top: 0; }
  .pe-head .pe-title { max-width: 100%; }
  .editor-layout { flex-direction: column; }
  .editor-col { max-width: none; flex: none; width: 100%; }
  .tree-col { position: static; max-height: none; flex: none; width: 100%; min-width: 0; }
  .ed-gutter { width: 2.4rem; margin-left: -2.4rem; opacity: 1; }
  .ed-media-tools { opacity: 1; }
  .modal.preview { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ======================================================================
   Captain Slides: deck list + editor
   ====================================================================== */

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.deck-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 0.85rem; background: var(--card); overflow: hidden; color: var(--foreground); text-decoration: none; position: relative; transition: border-color 0.15s, box-shadow 0.15s; }
.deck-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 10%, transparent); }
.deck-thumb { position: relative; width: 100%; overflow: hidden; background: #0a0a0b; border-bottom: 1px solid var(--border); }
.deck-thumb.empty { aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; color: var(--muted-foreground); }
.deck-thumb.empty .icon { width: 2rem; height: 2rem; }
.deck-thumb-scale { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; pointer-events: none; }
.deck-card-body { padding: 0.75rem 0.9rem 0.85rem; }
.deck-card-title { font-weight: 800; font-size: 0.95rem; letter-spacing: -0.01em; }
.deck-card-meta { font-size: 0.8rem; color: var(--muted-foreground); margin-top: 0.2rem; }
.deck-card-actions { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; gap: 0.3rem; opacity: 0; transition: opacity 0.15s; }
.deck-card:hover .deck-card-actions { opacity: 1; }
.deck-card-actions .btn { background: var(--card); }

/* ---------- editor shell ---------- */

#editor-root { position: fixed; inset: 0; z-index: 30; background: var(--background); display: flex; flex-direction: column; }
.pe-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.8rem; border-bottom: 1px solid var(--border); background: var(--sidebar-bg); min-height: 3.4rem; flex: none; }
.pe-head .sep { width: 1px; height: 1.6rem; background: var(--border); margin: 0 0.25rem; flex: none; }
.pe-title { font-weight: 800; font-size: 0.95rem; border: 1px solid transparent; background: transparent; color: var(--foreground); border-radius: var(--radius); padding: 0.3rem 0.5rem; min-width: 8rem; max-width: 22rem; width: 18rem; }
.pe-title:hover { border-color: var(--border); }
.pe-title:focus { border-color: var(--accent); outline: none; }
.pe-head .spacer { flex: 1; }
.pe-status { font-size: 0.78rem; color: var(--muted-foreground); white-space: nowrap; display: inline-flex; align-items: center; gap: 0.35rem; }
.pe-status.err { color: var(--danger); }
.pe-status .icon { width: 0.9rem; height: 0.9rem; }
.pe-body { flex: 1; display: flex; min-height: 0; }
.pe-slides { width: 15.5rem; flex: none; border-right: 1px solid var(--border); overflow-y: auto; padding: 0.7rem; display: flex; flex-direction: column; gap: 0.6rem; background: var(--sidebar-bg); outline: none; }
.pe-slides:focus-visible { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent); }
.pe-slide { position: relative; display: flex; gap: 0.45rem; align-items: flex-start; cursor: pointer; border-radius: 0.5rem; padding: 0.25rem; border: 2px solid transparent; }
.pe-slide.selected { border-color: var(--accent); }
.pe-slide.current .pe-slide-num { color: var(--accent); }
.pe-slide.drag-over-before { box-shadow: 0 -3px 0 0 var(--accent); }
.pe-slide.drag-over-after { box-shadow: 0 3px 0 0 var(--accent); }
.pe-slide.dragging { opacity: 0.4; }
.pe-slide-num { font-size: 0.72rem; font-weight: 800; color: var(--muted-foreground); width: 1.2rem; text-align: right; padding-top: 0.1rem; flex: none; }
.pe-slide-thumb { position: relative; flex: 1; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 0.35rem; background: #0a0a0b; border: 1px solid var(--border); }
.pe-slide-thumb .pr-slide { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.pe-slide-tools { position: absolute; right: 0.35rem; bottom: 0.35rem; display: flex; gap: 0.2rem; opacity: 0; transition: opacity 0.12s; }
.pe-slide:hover .pe-slide-tools { opacity: 1; }
.pe-slide-tools .btn { width: 1.6rem; min-width: 1.6rem; height: 1.6rem; min-height: 1.6rem; padding: 0; background: var(--card); }
.pe-slide-tools .btn .icon { width: 0.85rem; height: 0.85rem; }
.pe-add-slide { margin-top: 0.2rem; }

.pe-canvas-wrap { flex: 1; position: relative; overflow: hidden; background: color-mix(in srgb, var(--background) 70%, #000); display: flex; align-items: center; justify-content: center; }
[data-theme="light"] .pe-canvas-wrap { background: #e4e4ea; }
.pe-canvas { position: relative; box-shadow: 0 20px 80px rgba(0,0,0,.55); }
.pe-canvas .pr-slide { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pe-canvas { user-select: none; -webkit-user-select: none; }
.pe-canvas .pr-el.editing { user-select: text; -webkit-user-select: text; }
.pe-canvas .pr-el { cursor: move; }
.pe-canvas .pr-el.pr-locked { cursor: default; }
.pe-canvas .pr-el * { pointer-events: none; }
.pe-canvas .pr-el.editing { cursor: text; outline: none; }
.pe-canvas .pr-el.editing * { pointer-events: auto; }
.pe-canvas .pr-el.editing [contenteditable] { outline: none; caret-color: var(--accent); }
.pe-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.pe-sel { position: absolute; border: 1.5px solid var(--accent); box-sizing: border-box; pointer-events: none; }
.pe-sel.locked { border-style: dashed; }
.pe-sel.hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pe-handle { position: absolute; width: 11px; height: 11px; background: #fff; border: 1.5px solid var(--accent); border-radius: 3px; pointer-events: auto; transform: translate(-50%, -50%); }
.pe-handle.nw, .pe-handle.se { cursor: nwse-resize; } .pe-handle.ne, .pe-handle.sw { cursor: nesw-resize; }
.pe-handle.n, .pe-handle.s { cursor: ns-resize; } .pe-handle.e, .pe-handle.w { cursor: ew-resize; }
.pe-guide { position: absolute; background: var(--accent); opacity: 0.85; pointer-events: none; }
.pe-guide.v { width: 1px; top: 0; height: 100%; } .pe-guide.h { height: 1px; left: 0; width: 100%; }
.pe-marquee { position: absolute; border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); pointer-events: none; }
.pe-zoom { position: absolute; right: 0.8rem; bottom: 0.7rem; display: flex; gap: 0.3rem; align-items: center; font-size: 0.78rem; color: var(--muted-foreground); }
.pe-zoom .btn { background: var(--card); }

.pe-props { width: 17rem; flex: none; border-left: 1px solid var(--border); overflow-y: auto; padding: 0.9rem; background: var(--sidebar-bg); font-size: 0.85rem; }
.pe-props h3 { margin: 0 0 0.6rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-foreground); font-weight: 800; }
.pe-props .group { margin-bottom: 1rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--border); }
.pe-props .group:last-child { border-bottom: 0; }
.pe-props .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.pe-props .grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3rem; }
.pe-props label.f { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.7rem; color: var(--muted-foreground); font-weight: 700; }
.pe-props label.f .input, .pe-props label.f .select { min-height: 2rem; padding: 0.15rem 0.45rem; font-size: 0.82rem; width: 100%; }
.pe-props .color-row { display: flex; gap: 0.35rem; align-items: center; }
.pe-props input[type="color"] { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--border); border-radius: 0.4rem; background: var(--card); cursor: pointer; }
.pe-props .btn-row { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.pe-props .btn-row .btn { flex: 1; }
.pe-props .btn.on { background: var(--muted); border-color: var(--accent); }
.pe-props .hint { margin-top: 0.4rem; }
.pe-head .btn-icon .icon, .pe-props .btn-icon .icon { width: 1.05rem; height: 1.05rem; }
.pe-empty { color: var(--muted-foreground); font-size: 0.82rem; line-height: 1.5; }
.pe-export-link { display: inline-flex; }
@media (max-width: 900px) { .pe-props { display: none; } .pe-slides { width: 9rem; } .pe-slide-num { display: none; } }
