/* CloudSchool application styles: learner player, studio, builder, roles. */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --ink: #24253a;
  --ink-2: #45465b;
  --muted: #6b6e85;
  --line: #e6e6ef;
  --line-2: #f0f0f5;
  --accent: #6f5ce7;
  --accent-ink: #5443c9;
  --accent-soft: #f1efff;
  --good: #2f9e6a;
  --good-soft: #e9f7f0;
  --warn: #b7791f;
  --warn-soft: #fff6e5;
  --bad: #c6374c;
  --bad-soft: #fdecef;
  --info: #3b6fd8;
  --info-soft: #ebf1fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(30 30 60 / 6%), 0 6px 20px rgb(30 30 60 / 6%);
  --header-height: 60px;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 340px; }
body { margin: 0; min-height: 100vh; background: var(--bg); line-height: 1.5; }
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: Manrope, "Segoe UI", sans-serif; letter-spacing: -0.02em; line-height: 1.25; margin: 0 0 0.4em; }
h1 { font-size: clamp(22px, 2.4vw, 28px); }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 0.75em; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header ------------------------------------------------------------------ */
.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; height: var(--header-height); padding: 0 24px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 94%); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 800 17px Manrope, sans-serif; letter-spacing: -0.5px; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: #fff; background: var(--accent); font-size: 15px; }
.brand-light { color: #8d8ea0; font-weight: 500; }
.top-nav { display: flex; gap: 4px; overflow-x: auto; }
.top-nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap; }
.top-nav a:hover { color: var(--ink); background: var(--line-2); }
.top-nav a.active { color: var(--accent-ink); background: var(--accent-soft); }
.top-account { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.account-name { max-width: 220px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

/* Buttons and forms ----------------------------------------------------------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.button:hover { border-color: #cfcfe0; background: var(--surface-2); }
.button:disabled { cursor: not-allowed; opacity: 0.55; }
.button.primary { border-color: var(--accent); color: #fff; background: var(--accent); }
.button.primary:hover { background: var(--accent-ink); }
.button.danger { border-color: var(--bad); color: #fff; background: var(--bad); }
.button.subtle { border-color: transparent; background: transparent; color: var(--muted); }
.button.subtle:hover { background: var(--line-2); color: var(--ink); }
.button.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.icon-button { display: inline-grid; width: 30px; height: 30px; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.icon-button:disabled { opacity: 0.4; cursor: default; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.field { display: grid; gap: 5px; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > span { display: flex; justify-content: space-between; gap: 8px; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, input.input, select.input, textarea.input { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 400; }
.field textarea, textarea.input { min-height: 80px; resize: vertical; line-height: 1.5; }
.field textarea.code, textarea.code { font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.field-help { color: var(--muted); font-weight: 400; font-size: 12px; }
.field-error { color: var(--bad); font-weight: 500; font-size: 12px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox-field input { width: 16px; height: 16px; accent-color: var(--accent); }
.field-group { margin: 0 0 12px; padding: 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-2); }
.field-group > legend { padding: 0 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.list-item { position: relative; margin-bottom: 8px; padding: 10px 36px 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.list-item .remove { position: absolute; top: 6px; right: 6px; }
.list-item-tools { position: absolute; top: 6px; right: 6px; display: flex; flex-direction: column; gap: 2px; }

/* Cards, pills, toasts, dialogs ---------------------------------------------- */
.card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--muted); background: var(--line-2); }
.pill-in_review { color: var(--warn); background: var(--warn-soft); }
.pill-approved { color: var(--info); background: var(--info-soft); }
.pill-scheduled { color: var(--accent-ink); background: var(--accent-soft); }
.pill-published, .pill-active, .pill-completed, .pill-reviewed { color: var(--good); background: var(--good-soft); }
.pill-unpublished, .pill-suspended, .pill-pending, .pill-denied { color: var(--bad); background: var(--bad-soft); }
.pill-sourced { color: var(--good); background: var(--good-soft); }
.pill-generated { color: var(--warn); background: var(--warn-soft); }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast { padding: 12px 14px; border-radius: 9px; color: #fff; background: #2b2d42; box-shadow: var(--shadow); white-space: pre-line; transition: opacity 0.3s, transform 0.3s; }
.toast-error { background: var(--bad); }
.toast-success { background: var(--good); }
.toast.leaving { opacity: 0; transform: translateY(6px); }
.dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 14px; box-shadow: 0 20px 60px rgb(20 20 50 / 30%); }
.dialog::backdrop { background: rgb(20 20 40 / 40%); }
.dialog-form { padding: 22px; }
.dialog-message { color: var(--muted); white-space: pre-line; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.empty-state { padding: 40px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; background: var(--surface); }
.status-banner { margin: 0 0 16px; padding: 12px 14px; border-radius: 9px; background: var(--info-soft); color: #234; }
.status-banner.warn { background: var(--warn-soft); }
.status-banner.bad { background: var(--bad-soft); }
.placeholder { padding: 24px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; background: var(--surface-2); }

/* Page layout ---------------------------------------------------------------- */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }
.page-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-heading p { margin: 0; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.toolbar .input { width: auto; min-width: 160px; }
.toolbar .search { flex: 1 1 240px; }
.tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--accent-ink); }

/* Learner dashboard ------------------------------------------------------------ */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.course-card { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform 0.15s; }
.course-card:hover { transform: translateY(-2px); }
.course-card-art { display: grid; height: 112px; place-items: center; background: linear-gradient(120deg, #2b2647, #463a72); color: #d9d2ff; font: 800 28px Manrope, sans-serif; }
.course-card-art img { width: 100%; height: 100%; object-fit: cover; }
.course-card-body { display: grid; gap: 6px; padding: 14px 16px 16px; }
.course-card-body h3 { margin: 0; }
.meter { height: 6px; overflow: hidden; border-radius: 99px; background: var(--line-2); }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.section-title { margin: 32px 0 12px; }

/* Player --------------------------------------------------------------------- */
.player { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.player-hero { margin-bottom: 18px; padding: 22px 24px; border-radius: 14px; color: #fff; background: linear-gradient(110deg, #292546, #3e3466); }
.player-hero p { color: #d8d3f3; }
.player-hero .meter { margin-top: 12px; background: rgb(255 255 255 / 18%); }
.player-hero .meter > span { background: #c9bcff; }
.lesson-view { min-width: 0; padding: 26px 30px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.lesson-view header { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.objectives { margin: 0 0 20px; padding: 14px 16px; border-radius: 10px; background: var(--accent-soft); }
.objectives ul { margin: 6px 0 0; padding-left: 20px; }
.lesson-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.curriculum { position: sticky; top: calc(var(--header-height) + 16px); max-height: calc(100vh - var(--header-height) - 32px); overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.curriculum h2 { font-size: 15px; }
.curriculum-module { margin-top: 12px; }
.curriculum-module > strong { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.curriculum-lesson { display: grid; grid-template-columns: 22px 1fr; gap: 8px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.curriculum-lesson:hover { background: var(--line-2); }
.curriculum-lesson.current { background: var(--accent-soft); }
.curriculum-lesson .state { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 11px; color: var(--muted); }
.curriculum-lesson.completed .state { border-color: var(--good); color: #fff; background: var(--good); }
.curriculum-lesson.locked { color: var(--muted); }
.curriculum-lesson small { display: block; color: var(--muted); }
.preview-banner { position: sticky; top: var(--header-height); z-index: 10; padding: 8px 24px; color: #4a3400; background: #ffe7a8; font-weight: 600; text-align: center; }
.tutor { margin-top: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.tutor-messages { display: grid; gap: 10px; max-height: 360px; overflow: auto; margin-bottom: 10px; }
.tutor-message { padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-2); }
.tutor-message.user { justify-self: end; max-width: 85%; color: #fff; background: var(--accent); border-color: var(--accent); }
.tutor-form { display: flex; gap: 8px; }
.tutor-form textarea { flex: 1; min-height: 44px; }

/* Blocks ------------------------------------------------------------------------ */
.block { margin: 0 0 18px; }
.prose { color: var(--ink-2); line-height: 1.7; }
.prose p:last-child { margin-bottom: 0; }
.prose code, .block-question code { padding: 1px 5px; border-radius: 5px; background: var(--line-2); font-family: "Cascadia Code", Consolas, monospace; font-size: 0.92em; }
.prose pre { overflow: auto; padding: 12px; border-radius: 8px; color: #e8e8f3; background: #1e1f2e; }
.prose pre code { padding: 0; background: none; }
.prose .table-wrap { overflow-x: auto; margin: 0 0 0.75em; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.95em; line-height: 1.5; }
.prose th, .prose td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { color: var(--ink); background: var(--line-2); font-weight: 600; }
.prose blockquote { margin: 0 0 0.75em; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.block-heading { margin-top: 26px; }
.block-callout { padding: 12px 14px; border-left: 4px solid var(--info); border-radius: 8px; background: var(--info-soft); }
.callout-title { display: block; margin-bottom: 4px; }
.callout-tip { border-color: var(--accent); background: var(--accent-soft); }
.callout-success { border-color: var(--good); background: var(--good-soft); }
.callout-warning { border-color: var(--warn); background: var(--warn-soft); }
.callout-danger { border-color: var(--bad); background: var(--bad-soft); }
.callout-note { border-color: var(--muted); background: var(--line-2); }
.block-steps ol { display: grid; gap: 10px; margin: 0; padding-left: 22px; }
.block-steps li strong { display: block; }
.block-image { margin: 0; }
.block-image img { display: block; max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
figcaption { margin-top: 6px; color: var(--muted); font-size: 13px; }
.video-frame { position: relative; padding-top: 56.25%; overflow: hidden; border-radius: 10px; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.block-file { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.block-file p { margin: 0; color: var(--muted); font-size: 13px; }
.block-file .button { margin-left: auto; }
.file-icon { display: grid; width: 40px; height: 44px; place-items: center; border-radius: 6px; color: #fff; background: var(--bad); font-size: 11px; font-weight: 800; }
.block-embed { display: grid; gap: 3px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; background: var(--surface-2); }
.block-embed:hover { border-color: var(--accent); }
.block-embed p { margin: 0; color: var(--muted); }
.embed-host { color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.block-code, .block-terminal { margin: 0; overflow: hidden; border-radius: 10px; }
.block-code figcaption, .block-terminal figcaption { display: flex; justify-content: space-between; margin: 0; padding: 6px 12px; color: #c7c8da; background: #2a2b3d; font-size: 12px; }
.block-code pre, .block-terminal pre { margin: 0; overflow: auto; padding: 14px; color: #e8e8f3; background: #1e1f2e; font: 12.5px/1.6 "Cascadia Code", Consolas, monospace; }
.copy-button { border: 0; background: none; color: #c7c8da; cursor: pointer; font-size: 12px; }
.terminal-command .prompt { color: #8bd5a0; }
.terminal-output { color: #a5a7bd; }
.block-diagram { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.block-title { margin: 0 0 8px; font-weight: 700; color: var(--ink); }
.diagram-scroll { overflow-x: auto; }
.diagram-svg { display: block; min-width: 320px; max-width: 100%; height: auto; }
.diagram-node { cursor: pointer; }
.diagram-node:focus { outline: none; }
.diagram-node:focus rect:first-child, .diagram-node.selected rect:first-child { stroke-width: 3.2; }
.diagram-detail { min-height: 40px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface); font-size: 13px; }
.diagram-detail p { margin: 0; }
.diagram-text { margin-top: 6px; font-size: 13px; color: var(--muted); }
.block-question { padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; }
.question-kind { margin-bottom: 6px; color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.question-options { display: grid; gap: 6px; margin: 10px 0; }
.question-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.question-option.correct { border-color: var(--good); background: var(--good-soft); }
.question-option.incorrect { border-color: var(--bad); background: var(--bad-soft); }
.option-mark { margin-left: auto; color: var(--good); font-size: 12px; font-weight: 700; }
.feedback-good { color: var(--good); font-weight: 700; }
.feedback-bad { color: var(--bad); font-weight: 700; }
.block-exercise { padding: 16px; border: 1px solid #efe2c8; border-radius: 12px; background: #fffcf6; }
.block-exercise header { display: flex; justify-content: space-between; gap: 10px; }
.lab-count { color: var(--muted); font-size: 13px; }
.lab-scenario, .lab-prereq, .lab-verify { margin: 10px 0; }
.lab-steps { display: grid; gap: 6px; padding-left: 20px; }
.lab-steps label { display: flex; gap: 8px; }
.lab-steps input { margin-top: 4px; accent-color: var(--accent); }
.lab-deliverable { display: grid; margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: var(--surface); }
.lab-deliverable span { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; }
.lab-safety { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); font-size: 13px; }
.lab-safety p { margin: 0 0 4px; }
.block-ai { padding: 14px 16px; border: 1px solid #ddd6ff; border-radius: 10px; background: linear-gradient(140deg, #f7f5ff, #fff); }
.provenance { margin-top: 6px; color: var(--muted); font-size: 12px; }

/* Studio ---------------------------------------------------------------------- */
.studio-list { display: grid; gap: 10px; }
.studio-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.studio-row.dragging { opacity: 0.5; }
.studio-row.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.drag-handle { display: grid; width: 26px; height: 32px; place-items: center; border: 0; border-radius: 6px; color: #a0a2b6; background: none; cursor: grab; }
.drag-handle:hover { background: var(--line-2); color: var(--ink); }
.studio-row h3 { margin: 0 0 4px; font-size: 15px; }
.studio-row h3 a { color: var(--ink); text-decoration: none; }
.studio-row h3 a:hover { color: var(--accent-ink); }
.studio-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--muted); font-size: 13px; }
.tag { padding: 1px 8px; border-radius: 999px; background: var(--line-2); font-size: 12px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; display: grid; min-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.menu-list button { padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; }
.menu-list button:hover, .menu-list button:focus { background: var(--line-2); }
.menu-list button.danger { color: var(--bad); }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 12px 0; }
.template-option { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; cursor: pointer; }
.template-option[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.template-option small { color: var(--muted); }
.side-panel { position: fixed; inset: var(--header-height) 0 0 auto; z-index: 25; width: min(520px, 100vw); overflow: auto; padding: 22px; border-left: 1px solid var(--line); background: var(--surface); box-shadow: -10px 0 30px rgb(20 20 50 / 10%); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.stat strong { display: block; font: 800 22px Manrope, sans-serif; }
.stat span { color: var(--muted); font-size: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 40px; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; }

/* Builder ------------------------------------------------------------------------ */
.builder-body { overflow: hidden; }
.builder-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 54px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.builder-bar h1 { margin: 0; font-size: 16px; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { color: var(--muted); font-size: 13px; }
.save-state.saving { color: var(--warn); }
.save-state.error { color: var(--bad); font-weight: 600; }
.builder-bar .spacer { flex: 1; }
.builder { display: grid; grid-template-columns: 300px minmax(0, 1fr) 360px; height: calc(100vh - var(--header-height) - 55px); }
.builder-panel { min-height: 0; overflow: auto; background: var(--surface); }
.builder-left { border-right: 1px solid var(--line); }
.builder-right { border-left: 1px solid var(--line); }
.builder-center { overflow: auto; padding: 28px 32px 120px; background: var(--bg); }
.panel-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); background: var(--surface); }
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.panel-body { padding: 14px; }
.tree { margin: 0; padding: 6px; list-style: none; }
.tree ul { margin: 0; padding: 0 0 0 14px; list-style: none; }
.tree-item { display: flex; align-items: center; gap: 4px; min-height: 34px; padding: 2px 4px 2px 6px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; user-select: none; }
.tree-item:hover { background: var(--line-2); }
.tree-item.selected { border-color: #d9d3ff; background: var(--accent-soft); }
.tree-item .tree-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item .tree-icon { display: inline-grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; color: var(--muted); font-size: 12px; }
.tree-item.module > .tree-label { font-weight: 700; }
.tree-item .tree-tools { display: none; gap: 0; }
.tree-item:hover .tree-tools, .tree-item.selected .tree-tools, .tree-item:focus-within .tree-tools { display: flex; }
.tree-item.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.tree-item.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.tree-item.drop-inside { outline: 2px dashed var(--accent); }
.tree-item.dragging { opacity: 0.4; }
.tree-badge { padding: 0 6px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 700; }
.canvas { max-width: 820px; margin: 0 auto; }
.canvas-head { margin-bottom: 18px; }
.canvas-title { width: 100%; padding: 4px 0; border: 0; background: transparent; font: 800 26px Manrope, sans-serif; letter-spacing: -0.02em; }
.canvas-title:focus { outline: none; box-shadow: 0 2px 0 var(--accent); }
.block-card { position: relative; margin: 0 0 4px; padding: 12px 14px 12px 40px; border: 1px solid transparent; border-radius: 10px; background: var(--surface); }
.block-card:hover { border-color: var(--line); }
.block-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.block-card.dragging { opacity: 0.4; }
.block-card.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.block-card.drop-after { box-shadow: 0 3px 0 var(--accent); }
.block-card .block-handle { position: absolute; top: 10px; left: 8px; }
.block-card .block-type { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.block-card .block-tools { position: absolute; top: 8px; right: 8px; display: none; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.block-card:hover .block-tools, .block-card.selected .block-tools, .block-card:focus-within .block-tools { display: flex; }
.block-card .block-editor { margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--line); }
.block-card .block { margin: 0; }
.ai-review { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); font-size: 13px; }
.inserter { display: flex; justify-content: center; height: 18px; margin: 2px 0; opacity: 0; transition: opacity 0.15s; }
.inserter:hover, .inserter:focus-within, .canvas:hover .inserter.last { opacity: 1; }
.inserter button { height: 18px; padding: 0 10px; border: 1px dashed var(--accent); border-radius: 99px; background: var(--surface); color: var(--accent-ink); font-size: 12px; cursor: pointer; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 50vh; overflow: auto; }
.palette button { display: grid; gap: 2px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-align: left; cursor: pointer; }
.palette button:hover, .palette button:focus { border-color: var(--accent); background: var(--accent-soft); }
.palette small { color: var(--muted); }
.palette-category { grid-column: 1 / -1; margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.readonly-banner { margin: 0 0 16px; padding: 10px 14px; border-radius: 9px; background: var(--warn-soft); }
.issue-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.issue-list li { padding: 8px 10px; border-radius: 8px; background: var(--bad-soft); font-size: 13px; cursor: pointer; }
.issue-list li.warning { background: var(--warn-soft); }
.history-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.history-list li { padding: 10px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 13px; }
.ai-suggestion { margin: 10px 0; padding: 12px; border: 1px solid #ddd6ff; border-radius: 10px; background: #fbfaff; }
.ai-suggestion .block { margin-bottom: 8px; }
.comment { padding: 10px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 13px; }
.comment.resolved { opacity: 0.55; }
.correct-options { display: grid; gap: 4px; }
.option-row { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }

/* Roles ---------------------------------------------------------------------- */
.split { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.role-list { display: grid; gap: 6px; }
.role-list button { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; cursor: pointer; }
.role-list button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.role-list small { color: var(--muted); }
.matrix-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
.matrix thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.matrix .group-row th { color: var(--muted); background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.matrix td.center, .matrix th.center { text-align: center; }
.matrix select { padding: 3px 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.data-table th { color: var(--muted); font-size: 12px; }
.sensitive { color: var(--bad); font-size: 11px; font-weight: 700; }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 1180px) {
  .builder { grid-template-columns: 260px minmax(0, 1fr); }
  .builder-right { position: fixed; inset: calc(var(--header-height) + 55px) 0 0 auto; z-index: 15; width: min(380px, 100vw); box-shadow: -10px 0 30px rgb(20 20 50 / 12%); transform: translateX(105%); transition: transform 0.2s; }
  .builder-right.open { transform: none; }
}
@media (max-width: 860px) {
  .app-header { gap: 12px; padding: 0 14px; }
  .account-name { display: none; }
  .player { grid-template-columns: 1fr; }
  .curriculum { position: static; max-height: none; }
  .lesson-view { padding: 18px; }
  .builder { grid-template-columns: 1fr; height: auto; }
  .builder-body { overflow: auto; }
  .builder-left { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .builder-center { padding: 18px 14px 80px; }
  .split { grid-template-columns: 1fr; }
  .studio-row { grid-template-columns: minmax(0, 1fr); }
  .studio-row .drag-handle { display: none; }
}
