:root {
  --bg: #0b0e13;
  --bg-soft: #10151d;
  --surface: #151b24;
  --surface-2: #1b2330;
  --surface-3: #222c3a;
  --border: #283343;
  --border-strong: #3a485b;
  --fg: #eef2f8;
  --fg-soft: #cbd3df;
  --muted: #8995a8;
  --accent: #78a9ff;
  --accent-strong: #4e8df7;
  --accent-2: #75ddb0;
  --danger: #ff7f83;
  --warn: #f5c76f;
  --ok: #75ddb0;
  --shadow: 0 18px 60px rgba(0, 0, 0, .34);
  --radius: 14px;
  --sidebar-w: 344px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 70% -20%, rgba(78, 141, 247, .12), transparent 38%),
    var(--bg);
  color: var(--fg);
  font: 14px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
body[data-view="workspace"] { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: rgba(16, 21, 29, .92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand-button,
.course-context {
  appearance: none;
  border: 0;
  color: var(--fg);
  background: transparent;
  cursor: pointer;
}
.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 3px 5px 3px 0;
  flex: 0 0 auto;
}
.brand-mark,
.welcome-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), #9a7dff);
  color: #08101e;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(78, 141, 247, .25);
}
.brand-copy {
  display: grid;
  text-align: left;
  line-height: 1.15;
}
.brand-copy b { font-size: 14px; letter-spacing: .01em; }
.brand-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: .04em; }

.course-context {
  min-width: 170px;
  max-width: 290px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-left: 1px solid var(--border);
  border-radius: 9px;
  text-align: left;
}
.course-context:hover { background: var(--surface); }
.course-context-copy { min-width: 0; flex: 1; display: grid; line-height: 1.15; }
.course-context-copy small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.course-context-copy strong { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.chevron { color: var(--muted); font-size: 17px; }

.materials {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.materials-label,
.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .11em;
}
.material-switch {
  min-width: 0;
  display: flex;
  gap: 3px;
  padding: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(27, 35, 48, .76);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.material-switch::-webkit-scrollbar { display: none; }
.material-switch button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-soft);
  cursor: pointer;
  font-size: 12px;
}
.material-switch button:hover { color: var(--fg); background: rgba(255, 255, 255, .035); }
.material-switch button.active { background: var(--accent); color: #08101e; font-weight: 700; }
.chk-icon {
  width: 13px;
  height: 13px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1.5px solid #56657a;
  border-radius: 4px;
  line-height: 1;
  position: relative;
}
.chk-icon::before { content: ""; position: absolute; inset: -6px; }
.material-switch button.checked .chk-icon { background: var(--accent-2); border-color: var(--accent-2); color: #07140f; }
.material-switch button.checked .chk-icon::after { content: "✓"; font-size: 10px; font-weight: 900; }
.material-switch button.active .chk-icon { border-color: #152038; }

.actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}
.btn {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: border-color .15s, background .15s, transform .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible,
.icon-button:focus-visible,
.brand-button:focus-visible,
.course-context:focus-visible,
.course-card-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #07101f; border-color: transparent; font-weight: 750; }
.btn-primary:hover:not(:disabled) { background: #8cb7ff; border-color: transparent; }
.btn-danger { background: var(--danger); color: #210a0b; border-color: transparent; }
.btn-quiet { background: transparent; }
.btn-new { border-color: rgba(117, 221, 176, .28); background: rgba(117, 221, 176, .08); color: #bdf2d8; }
.btn-new:hover:not(:disabled) { border-color: rgba(117, 221, 176, .5); background: rgba(117, 221, 176, .14); }
.btn-icon { width: 34px; padding: 0; font-size: 20px; line-height: 1; }
.btn-sm { min-height: 29px; padding: 5px 8px; font-size: 11px; }
.btn-large { min-height: 44px; padding: 10px 17px; font-size: 13px; }
.btn-dashed { width: 100%; border-style: dashed; background: transparent; color: var(--muted); }
.chk { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.chk input { accent-color: var(--accent); }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid rgba(120, 169, 255, .25);
  border-radius: 999px;
  color: #a9c8ff;
  background: rgba(120, 169, 255, .09);
  font-size: 10px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}
.status-badge.ok { color: #b7efd3; border-color: rgba(117, 221, 176, .25); background: rgba(117, 221, 176, .09); }
.status-badge.warn { color: #ffe1a7; border-color: rgba(245, 199, 111, .28); background: rgba(245, 199, 111, .09); }
.status-badge.danger { color: #ffb1b4; border-color: rgba(255, 127, 131, .28); background: rgba(255, 127, 131, .09); }

.progress {
  height: 25px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 68px;
  z-index: 29;
  overflow: hidden;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, rgba(78, 141, 247, .68), rgba(117, 221, 176, .68));
  transition: width .25s ease;
}
.progress-text { position: relative; padding: 0 14px; color: #f2f7ff; font-size: 11px; font-weight: 700; text-shadow: 0 1px 4px #07101f; }
body:has(.progress:not([hidden])) .layout { height: calc(100vh - 93px); }

/* Library */
.library-view { width: min(1240px, calc(100% - 44px)); margin: 0 auto; padding: 56px 0 90px; }
.library-hero {
  min-height: 230px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  padding: 38px 42px;
  border: 1px solid rgba(120, 169, 255, .18);
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(125deg, rgba(120, 169, 255, .13), rgba(117, 221, 176, .045) 54%, transparent),
    var(--surface);
  box-shadow: var(--shadow);
}
.library-hero::after {
  content: "";
  width: 380px;
  height: 380px;
  border: 1px solid rgba(120, 169, 255, .12);
  border-radius: 50%;
  position: absolute;
  right: -110px;
  top: -170px;
  box-shadow: 0 0 0 52px rgba(120, 169, 255, .025), 0 0 0 105px rgba(117, 221, 176, .018);
  pointer-events: none;
}
.library-hero > * { position: relative; z-index: 1; }
.library-hero .eyebrow { margin: 0 0 10px; color: #a9c8ff; }
.library-hero h1 { margin: 0; font-size: clamp(30px, 4vw, 52px); line-height: 1.05; letter-spacing: -.045em; }
.library-hero p:not(.eyebrow) { max-width: 650px; margin: 17px 0 0; color: var(--muted); font-size: 15px; }

.library-section { margin-top: 46px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.course-card { min-width: 0; }
.course-card-open {
  width: 100%;
  min-height: 245px;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .018), transparent 45%), var(--surface);
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.course-card-open:hover { transform: translateY(-3px); border-color: #41536c; box-shadow: 0 16px 42px rgba(0, 0, 0, .25); }
.course-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.course-symbol {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(120, 169, 255, .2), rgba(154, 125, 255, .12));
  border: 1px solid rgba(120, 169, 255, .2);
  color: #b9d2ff;
  font-size: 17px;
  font-weight: 800;
}
.course-card-body { display: grid; margin-top: 24px; }
.recent-label { margin-bottom: 5px; color: var(--accent-2); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.course-card-body strong { min-height: 48px; font-size: 17px; line-height: 1.35; }
.course-card-meta { margin-top: 8px; color: var(--muted); font-size: 11px; }
.course-progress { height: 4px; margin-top: 19px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.course-progress i { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.course-progress-label { margin-top: 6px; color: var(--muted); font-size: 10px; }
.course-card-action { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 18px; color: #b9d2ff; font-size: 12px; font-weight: 650; }
.course-card-action b { font-size: 17px; transition: transform .15s; }
.course-card-open:hover .course-card-action b { transform: translateX(3px); }
.empty-state {
  padding: 60px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: 18px;
  text-align: center;
  background: rgba(21, 27, 36, .5);
}
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 15px; border-radius: 15px; background: var(--surface-2); color: var(--accent); font-size: 24px; }
.empty-state h3 { margin: 0; font-size: 17px; }
.empty-state p { max-width: 480px; margin: 8px auto 18px; color: var(--muted); }
.skeleton-card { height: 245px; border-radius: 16px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 40%, var(--surface) 60%); background-size: 300% 100%; animation: shimmer 1.5s infinite; }
.load-error { grid-column: 1 / -1; display: grid; justify-items: start; gap: 7px; padding: 24px; border: 1px solid rgba(255, 127, 131, .25); border-radius: 14px; background: rgba(255, 127, 131, .055); }
.load-error span { color: var(--muted); }

/* Import and outline review */
.import-view { width: min(1060px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 90px; }
.import-heading { display: grid; grid-template-columns: 160px 1fr 160px; align-items: end; gap: 22px; margin-bottom: 24px; }
.import-title-wrap { text-align: center; }
.import-title-wrap .eyebrow { margin: 0 0 5px; }
.import-title-wrap h1 { margin: 0; font-size: 24px; letter-spacing: -.025em; }
.import-heading > :last-child { justify-self: end; }
.import-status-card,
.outline-review {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(21, 27, 36, .92);
  box-shadow: 0 18px 54px rgba(0, 0, 0, .2);
}
.import-status-card { padding: 27px 30px; }
.import-status-top { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.import-status-top h2 { margin: 13px 0 5px; font-size: 21px; }
.import-status-top p { margin: 0; color: var(--muted); }
.orbit { width: 42px; height: 42px; margin: 7px; border: 2px solid rgba(120, 169, 255, .16); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
.import-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; padding: 0; margin: 30px 0 0; list-style: none; }
.import-steps li { display: flex; align-items: center; gap: 10px; position: relative; color: var(--muted); }
.import-steps li:not(:last-child)::after { content: ""; height: 1px; position: absolute; left: 40px; right: 8px; top: 15px; background: var(--border); }
.import-steps li > span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface); font-size: 11px; font-weight: 750; position: relative; z-index: 1; }
.import-steps li > div { display: grid; min-width: 0; position: relative; z-index: 1; background: var(--surface); padding-right: 8px; }
.import-steps li b { color: var(--fg-soft); font-size: 11px; }
.import-steps li small { font-size: 9px; }
.import-steps li.complete > span { background: var(--accent-2); color: #07150f; border-color: var(--accent-2); }
.import-steps li.complete > span::before { content: "✓"; }
.import-steps li.complete > span { font-size: 0; }
.import-steps li.complete:not(:last-child)::after { background: rgba(117, 221, 176, .45); }
.import-steps li.active > span { color: #08101f; background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px rgba(120, 169, 255, .1); }
.import-steps li.active b { color: var(--fg); }
.import-steps li.failed > span { color: #210a0b; background: var(--danger); border-color: var(--danger); }
.notice-list { display: grid; gap: 8px; margin-top: 23px; }
.notice-list > div { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid rgba(245, 199, 111, .2); border-radius: 9px; background: rgba(245, 199, 111, .055); }
.notice-list b { color: #ffe1a7; font-size: 11px; }
.notice-list span { color: var(--fg-soft); font-size: 11px; }

.outline-review { margin-top: 18px; padding: 30px; }
.outline-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.outline-toolbar .eyebrow { margin: 0 0 7px; }
.outline-toolbar h2 { margin: 0; font-size: 22px; }
.outline-toolbar p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); }
.outline-summary { width: 62px; height: 62px; display: grid; place-items: center; align-content: center; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-2); line-height: 1.05; }
.outline-summary b { font-size: 20px; }
.outline-summary span { margin-top: 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.field { display: grid; gap: 6px; }
.field > span { color: var(--fg-soft); font-size: 11px; font-weight: 650; }
.field > span small { color: var(--muted); font-weight: 400; }
.field input,
.field select,
.topic-title-input,
.page-input {
  width: 100%;
  min-height: 39px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: 0;
  background: var(--bg-soft);
  color: var(--fg);
}
.field input:focus,
.field select:focus,
.topic-title-input:focus,
.page-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(120, 169, 255, .08); }
.course-title-field { margin-bottom: 18px; }
.course-title-field input { min-height: 45px; font-size: 15px; font-weight: 650; }
.outline-editor { display: grid; gap: 11px; }
.outline-section { border: 1px solid var(--border); border-radius: 13px; overflow: hidden; background: var(--bg-soft); }
.outline-section-head { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.order-pill { width: 30px; flex: 0 0 auto; color: var(--accent); font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 750; }
.field.compact { gap: 3px; }
.field.compact > span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.field.compact input { min-height: 34px; padding: 6px 9px; background: var(--surface); font-weight: 650; }
.grow { flex: 1; }
.reorder-actions { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.icon-button {
  width: 31px;
  height: 31px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--border-strong); color: var(--fg); }
.icon-button:disabled { opacity: .25; cursor: default; }
.icon-button.danger:hover:not(:disabled) { color: var(--danger); border-color: rgba(255, 127, 131, .35); }
.icon-button.mini { width: 27px; height: 27px; border-radius: 7px; font-size: 11px; }
.outline-topics { display: grid; padding: 7px 12px 4px; }
.outline-topic { display: grid; grid-template-columns: 28px 1fr 96px auto; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(40, 51, 67, .55); }
.outline-topic:last-child { border-bottom: 0; }
.topic-order { color: var(--muted); font-size: 10px; text-align: center; }
.topic-title-input, .page-input { min-height: 34px; padding: 6px 9px; font-size: 12px; }
.page-input { font-variant-numeric: tabular-nums; }
.add-topic { margin: 2px 12px 10px 48px; padding: 5px 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 11px; text-align: left; }
.add-topic:hover { color: #aacaff; }
.outline-empty { padding: 30px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--muted); text-align: center; }
.outline-review > .btn-dashed { margin-top: 11px; }
.outline-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 23px; padding-top: 18px; border-top: 1px solid var(--border); }
.save-state { margin-right: auto; color: var(--muted); font-size: 10px; }
.save-state.dirty { color: var(--warn); }
.save-state.saved { color: var(--ok); }

/* Workspace */
/* Bound both panes to the viewport; a long outline must scroll inside its rail. */
.layout { height: calc(100vh - 68px); display: grid; grid-template-columns: var(--sidebar-w) 5px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.sidebar { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: rgba(16, 21, 29, .86); }
.sidebar-head { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.counter { margin-left: auto; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.tree { min-height: 0; overflow-y: auto; padding: 3px 0 14px; scrollbar-color: var(--border-strong) transparent; }
.tree-empty { padding: 30px 20px; color: var(--muted); text-align: center; }
.section-group { margin: 0; }
.section-group > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  list-style: none;
  position: sticky;
  top: 0;
  z-index: 2;
  border-top: 1px solid var(--border);
  background: rgba(16, 21, 29, .96);
  color: var(--fg-soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}
.section-group:first-child > summary { border-top: 0; }
.section-group > summary::-webkit-details-marker { display: none; }
.section-group > summary::before { content: "›"; color: var(--muted); font-size: 17px; transition: transform .15s; }
.section-group[open] > summary::before { transform: rotate(90deg); }
.section-group .section-title { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-group .count { color: var(--muted); font-size: 10px; font-weight: 500; }
.section-cb { margin: 0 2px 0 0; accent-color: var(--accent); }
.topic {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 27px;
  border-left: 2px solid transparent;
  color: var(--fg-soft);
  cursor: pointer;
  user-select: none;
}
.topic:hover { background: rgba(255, 255, 255, .025); }
.topic.active { color: var(--fg); background: rgba(120, 169, 255, .1); border-left-color: var(--accent); }
.topic input[type="checkbox"] { margin: 0; accent-color: var(--accent); flex: 0 0 auto; }
.topic .num { width: 29px; flex: 0 0 auto; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.topic .title { min-width: 0; flex: 1; font-size: 12px; line-height: 1.3; }
.topic .dots { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.topic .dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: #354155; position: relative; }
.topic .dot.ok { background: var(--ok); box-shadow: 0 0 0 2px rgba(117, 221, 176, .08); }
.topic .dot.busy::after { content: ""; width: 10px; height: 10px; position: absolute; top: -2px; left: -2px; border: 1.5px solid rgba(245, 199, 111, .22); border-top-color: var(--warn); border-radius: 50%; animation: spin .75s linear infinite; }
.resizer { cursor: col-resize; background: var(--border); position: relative; transition: background .15s; }
.resizer:hover, .resizer.dragging { background: var(--accent); }
.resizer::after { content: ""; position: absolute; inset: 0 -4px; }
.content { min-width: 0; min-height: 0; overflow-y: auto; padding: 20px clamp(22px, 4vw, 54px) 90px; scrollbar-color: var(--border-strong) transparent; }
.status { min-height: 18px; margin-bottom: 9px; color: var(--muted); font-size: 10px; }
.viewer { width: min(100%, 1060px); }
.viewer h1, .viewer h2, .viewer h3 { color: #fff; }
.viewer h1 { margin: 0 0 15px; font-size: clamp(24px, 3vw, 34px); line-height: 1.16; letter-spacing: -.025em; }
.viewer .crumbs { margin-bottom: 10px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.placeholder { padding: 56px 20px; color: var(--muted); text-align: center; }
.compact-placeholder { padding: 32px 0; }
.inline-spinner { width: 13px; height: 13px; display: inline-block; margin-right: 5px; vertical-align: -2px; border: 1.5px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
.material-missing { display: grid; justify-items: center; gap: 8px; margin-top: 22px; padding: 48px 22px; border: 1px dashed var(--border-strong); border-radius: 15px; background: rgba(21, 27, 36, .45); }
.material-missing b { color: var(--fg); font-size: 15px; }
.material-missing .btn { margin-top: 9px; }
.missing-symbol { color: var(--accent); font-size: 30px; }
.error-state { border-color: rgba(255, 127, 131, .28); }
.workspace-welcome { max-width: 620px; padding: 10vh 0 0; }
.workspace-welcome .welcome-mark { width: 50px; height: 50px; margin-bottom: 24px; border-radius: 15px; font-size: 19px; }
.workspace-welcome .eyebrow { margin: 0 0 8px; }
.workspace-welcome h1 { margin: 0; font-size: clamp(34px, 6vw, 56px); letter-spacing: -.05em; }
.workspace-welcome p:not(.eyebrow) { max-width: 520px; color: var(--muted); font-size: 15px; }

/* LLM content design kit */
.viewer p { color: var(--fg-soft); }
.viewer ul, .viewer ol { padding-left: 22px; }
.viewer li { margin: 5px 0; }
.viewer dl { margin: 8px 0; }
.viewer dt { margin-top: 8px; font-weight: 650; }
.viewer dd { margin: 2px 0 0 16px; color: var(--fg-soft); }
.viewer details { margin: 7px 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.viewer details summary { color: var(--accent); cursor: pointer; }
.viewer code, .viewer pre { border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.viewer pre { padding: 12px; overflow: auto; }
.viewer code { padding: 1px 5px; }
.viewer .block { margin: 20px 0; }
.viewer .block > h3 { margin: 0 0 11px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.viewer .hero { margin: 0 0 20px; padding: 17px 19px; border: 1px solid rgba(120, 169, 255, .23); border-radius: 13px; background: linear-gradient(135deg, rgba(120, 169, 255, .11), rgba(117, 221, 176, .065)); font-size: 17px; font-weight: 650; line-height: 1.55; }
.viewer .callout { margin: 11px 0; padding: 11px 14px; border-left: 3px solid var(--accent); border-radius: 8px; background: var(--surface); }
.viewer .callout-key { border-left-color: var(--accent); background: rgba(120, 169, 255, .07); }
.viewer .callout-tip { border-left-color: var(--accent-2); background: rgba(117, 221, 176, .07); }
.viewer .callout-warn { border-left-color: var(--warn); background: rgba(245, 199, 111, .07); }
.viewer ul.tezis { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.viewer ul.tezis li { padding: 9px 12px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 9px; background: var(--surface); }
.viewer ol.steps { display: grid; gap: 7px; padding-left: 20px; }
.viewer ol.steps li::marker { color: var(--accent); font-weight: 750; }
.viewer .formula-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.viewer .formula { display: grid; gap: 7px; padding: 15px 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.viewer .formula .eq { padding: 9px 12px; overflow-x: auto; border-radius: 9px; background: var(--surface-2); font-size: 18px; text-align: center; }
.viewer .formula .name { font-weight: 650; }
.viewer .formula .vars { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 4px 0 0; }
.viewer .formula .vars dt { color: var(--accent); font-weight: 650; }
.viewer .formula .vars dd { margin: 0; color: var(--fg-soft); }
.viewer .formula .when { color: var(--muted); font-size: 11px; }
.viewer .formula .mistake { color: var(--warn); font-size: 11px; }
.viewer dl.defs { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 0; }
.viewer dl.defs dt { color: var(--accent); font-weight: 650; }
.viewer dl.defs dd { margin: 0; color: var(--fg-soft); }
.viewer ul.applications { display: grid; gap: 5px; padding-left: 18px; list-style: "→  "; }
.viewer ul.applications li::marker { color: var(--accent-2); }
.viewer ol.quiz, .viewer ol.problems { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; counter-reset: q; }
.viewer ol.quiz li, .viewer ol.problems > li { padding: 13px 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); counter-increment: q; position: relative; }
.viewer ol.quiz li::before { content: counter(q); width: 23px; height: 23px; display: grid; place-items: center; position: absolute; left: -11px; top: -9px; border-radius: 50%; background: var(--accent); color: #08101e; font-size: 11px; font-weight: 800; }
.viewer ol.quiz .q { margin-bottom: 6px; font-weight: 650; }
.viewer ol.quiz details, .viewer ol.problems details { padding: 0; border: 0; background: transparent; }
.viewer ol.quiz details summary, .viewer ol.problems details summary { color: var(--accent-2); }
.viewer ol.problems { counter-reset: p; gap: 15px; }
.viewer ol.problems > li { counter-increment: p; padding: 16px; }
.viewer ol.problems > li::before { content: counter(p); width: 23px; height: 23px; display: grid; place-items: center; position: absolute; left: -10px; top: -9px; border-radius: 50%; background: var(--accent-2); color: #07150f; font-size: 11px; font-weight: 800; }
.viewer ol.problems > li > .q { margin: 5px 0 8px; font-weight: 650; }
.viewer ol.problems > li > .given, .viewer ol.problems > li > .find { padding: 4px 0; color: var(--fg-soft); font-size: 12px; }
.viewer figure.infographic { margin: 0; padding: 0; overflow: auto; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.viewer figure.infographic img { display: block; width: auto; max-width: none; height: auto; cursor: zoom-in; }
.viewer figure.infographic figcaption { padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.viewer .badge { display: inline-block; padding: 2px 8px; border: 1px solid rgba(120, 169, 255, .28); border-radius: 999px; background: rgba(120, 169, 255, .12); color: var(--accent); font-size: 10px; }

/* Upload modal */
.modal {
  width: min(610px, calc(100% - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 19px;
  background: transparent;
  color: var(--fg);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(3, 6, 10, .78); backdrop-filter: blur(7px); }
.modal-card { padding: 27px; border: 1px solid var(--border-strong); border-radius: 19px; background: var(--surface); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-head .eyebrow { margin: 0 0 5px; }
.modal-head h2 { margin: 0; font-size: 23px; }
.modal-head > .icon-button { width: 34px; height: 34px; font-size: 19px; }
.drop-zone { min-height: 176px; display: grid; place-items: center; align-content: center; gap: 9px; margin-top: 23px; padding: 22px; border: 1px dashed var(--border-strong); border-radius: 14px; background: var(--bg-soft); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: rgba(120, 169, 255, .045); }
.drop-zone.has-file { border-style: solid; border-color: rgba(117, 221, 176, .35); background: rgba(117, 221, 176, .045); }
.drop-zone input { width: 1px; height: 1px; position: absolute; opacity: 0; pointer-events: none; }
.drop-icon { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(120, 169, 255, .3); border-radius: 13px; background: rgba(120, 169, 255, .1); color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .05em; }
.drop-copy { display: grid; gap: 3px; }
.drop-copy b { font-size: 13px; }
.drop-copy small { color: var(--muted); }
.drop-zone.has-file .drop-copy { display: none; }
.file-details { display: grid; gap: 3px; max-width: 100%; }
.file-details b { max-width: 430px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b7efd3; }
.file-details small { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-top: 17px; }
.privacy-note { margin: 15px 0 0; color: var(--muted); font-size: 10px; }
.form-status { margin-top: 13px; padding: 9px 11px; border: 1px solid rgba(120, 169, 255, .22); border-radius: 8px; background: rgba(120, 169, 255, .06); color: #b9d2ff; font-size: 11px; }
.form-status.ok { border-color: rgba(117, 221, 176, .25); background: rgba(117, 221, 176, .06); color: #b7efd3; }
.form-status.err { border-color: rgba(255, 127, 131, .28); background: rgba(255, 127, 131, .06); color: #ffb1b4; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.toast { max-width: min(420px, calc(100vw - 28px)); position: fixed; right: 17px; bottom: 17px; z-index: 10000; padding: 11px 14px; border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: 9px; background: var(--surface-2); box-shadow: var(--shadow); color: var(--fg); font-size: 12px; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.lightbox { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 4vh 4vw; background: rgba(0, 0, 0, .86); opacity: 0; pointer-events: none; transition: opacity .18s; }
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 9px; box-shadow: 0 14px 60px rgba(0, 0, 0, .65); }
.lightbox.loading img { display: none; }
.lightbox-status { display: none; color: rgba(255, 255, 255, .8); font-size: 14px; }
.lightbox.loading .lightbox-status { display: block; }
.lightbox button { width: 38px; height: 38px; position: absolute; top: 18px; right: 18px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 50%; background: rgba(0, 0, 0, .4); color: #fff; cursor: pointer; font-size: 23px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (max-width: 1180px) {
  .brand-copy small, .materials-label, #forceWrap { display: none; }
  .course-context { max-width: 220px; }
  .material-switch button { padding-inline: 7px; }
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .materials { order: 3; width: 100%; flex-basis: 100%; }
  .material-switch { width: 100%; }
  .progress { top: 116px; }
  .layout { height: calc(100vh - 116px); }
  body:has(.progress:not([hidden])) .layout { height: calc(100vh - 141px); }
  .import-steps { grid-template-columns: repeat(2, 1fr); gap: 15px 0; }
  .import-steps li:nth-child(2)::after { display: none; }
  .outline-topic { grid-template-columns: 24px 1fr 82px; }
  .outline-topic .reorder-actions { grid-column: 2 / -1; justify-self: end; }
}

@media (max-width: 700px) {
  body[data-view="workspace"] { overflow: auto; }
  .topbar { padding: 9px 11px; }
  .brand-copy { display: none; }
  .course-context { min-width: 0; max-width: none; flex: 1; border-left: 0; }
  .course-context .status-badge, .course-context .chevron { display: none; }
  .actions { gap: 5px; }
  .actions .btn { padding-inline: 9px; }
  #btnOutline, #btnPing { display: none !important; }
  .btn-new { font-size: 0; width: 35px; padding: 0; }
  .btn-new span { font-size: 19px; }
  .library-view { width: min(100% - 24px, 1240px); padding-top: 22px; }
  .library-hero { min-height: 280px; display: grid; align-content: end; padding: 27px 24px; }
  .library-hero h1 { font-size: 35px; }
  .library-hero .btn { justify-self: start; }
  .library-section { margin-top: 30px; }
  .course-grid { grid-template-columns: 1fr; }
  .import-view { width: calc(100% - 20px); padding-top: 14px; }
  .import-heading { grid-template-columns: auto 1fr; align-items: center; }
  .import-title-wrap { text-align: right; }
  .import-heading > :last-child { grid-column: 1 / -1; justify-self: stretch; }
  .import-status-card, .outline-review { padding: 20px 16px; }
  .import-steps { grid-template-columns: 1fr; }
  .import-steps li::after { display: none; }
  .outline-toolbar { align-items: center; }
  .outline-toolbar p:not(.eyebrow) { display: none; }
  .outline-section-head { align-items: flex-end; flex-wrap: wrap; }
  .outline-section-head .reorder-actions { margin-left: 38px; }
  .outline-topic { grid-template-columns: 22px 1fr; }
  .outline-topic .page-input { grid-column: 2; }
  .outline-topic .reorder-actions { grid-column: 2; }
  .outline-actions { flex-wrap: wrap; }
  .save-state { width: 100%; }
  .outline-actions .btn { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-card { padding: 22px 17px; }
  .layout { height: auto; display: grid; grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .sidebar { max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--border); }
  .resizer { display: none; }
  .content { min-height: 58vh; padding: 18px 18px 70px; }
  .progress { top: 116px; }
  body:has(.progress:not([hidden])) .layout { height: auto; }
}

/* Shared player for generated mini-games and interactive illustrations. */
.interactive-material { width:100%; min-width:0; margin:12px 0 24px; }
.interactive-intro { padding:18px 20px; border:1px solid var(--border); border-radius:14px 14px 0 0; background:var(--surface); }
.interactive-intro h2 { margin:0 0 8px; font-size:23px; line-height:1.25; }
.interactive-intro p { margin:6px 0; }
.interactive-intro .interactive-kind { margin:0 0 9px; color:var(--accent); font-size:11px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; }
.interactive-instructions { font-size:14px; }
.interactive-tools { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:12px 20px; border-inline:1px solid var(--border); background:var(--surface); }
.interactive-status { margin:0; font-size:13px; color:var(--muted); }
.interactive-material[data-state="error"] .interactive-status { color:var(--warn); }
.interactive-restart { flex:none; }
.interactive-stage { min-height:120px; overflow:hidden; border:1px solid var(--border); border-radius:0 0 14px 14px; background:#f6f7fb; }
.interactive-frame { display:block; width:100%; height:620px; border:0; background:#f6f7fb; }
.interactive-material[data-state="loading"] .interactive-stage { background:var(--surface); }
.interactive-material[data-state="error"] .interactive-stage { display:none; }
@media(max-width:600px) {
  .interactive-intro,.interactive-tools { padding:14px; }
  .interactive-intro h2 { font-size:20px; }
  .interactive-tools { align-items:flex-start; flex-direction:column; gap:10px; }
  .interactive-frame { height:560px; }
}

/* Keep the material tabs on their own row: account actions must not cover them. */
.topbar { flex-wrap:wrap; }
.topbar .studio-account { flex:0 0 auto; margin-left:auto; }
.topbar .actions { flex-wrap:wrap; margin-left:0; }
.topbar .materials { order:3; flex:1 0 100%; width:100%; }
.topbar .materials-label { flex:none; }
.topbar .material-switch { flex:1; }
@media(max-width:760px){.topbar .studio-account{flex:1 0 100%;}.topbar .actions{flex:1 0 100%;}.topbar .materials-label{display:none;}}

/* Keep the first game action visible below the textbook heading. */
.interactive-intro { padding:12px 16px; }
.interactive-intro h2 { margin-bottom:4px; font-size:21px; }
.interactive-intro .interactive-kind { margin-bottom:5px; }
.interactive-about { margin-top:6px; font-size:14px; }
.interactive-about summary { width:fit-content; cursor:pointer; font-size:13px; color:var(--muted); }
.interactive-about summary:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.interactive-about[open] summary { margin-bottom:8px; }
.interactive-tools { padding:8px 16px; }
@media(max-width:600px) {
  .interactive-intro { padding:12px; }
  .interactive-intro h2 { font-size:19px; }
  .interactive-tools { padding:8px 12px; flex-direction:row; align-items:center; gap:8px; }
  .interactive-status { font-size:12px; min-width:0; }
  .interactive-restart { padding:8px; font-size:12px; }
}
