/* pbaumgarten.com — stylesheet (light theme)
   OneNote-inspired three-layer layout: Course > Topic > Document.
   No inline styles anywhere; per-course accent driven by --accent CSS variable.
   ========================================================================== */

/* ---- Design tokens ------------------------------------------------------- */
:root {
  /* Neutral surfaces (warm grey, OneNote-like) */
  --bg:            #ffffff;
  --surface:       #faf9f8;
  --surface-2:     #f3f2f1;
  --surface-3:     #ebe9e7;
  --border:        #e5e3e0;
  --border-strong: #d2cfca;

  /* Text */
  --text:        #242322;
  --text-muted:  #6b6862;
  --text-faint:  #908c85;

  /* Default accent (overridden per course) */
  --accent:       #7719aa;
  --accent-weak:  #f3e9f8;
  --accent-text:  #ffffff;

  /* Code / callouts */
  --code-bg:     #1e1e2e;
  --code-text:   #e4e4ef;

  /* Layout metrics */
  --topbar-h:        52px;
  --content-max:     820px;

  --radius:      8px;
  --radius-sm:   5px;
  --shadow-1:    0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-2:    0 2px 8px rgba(0,0,0,.10);

  --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-read: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

/* ---- Per-course accent palette -------------------------------------------- */
.accent-purple  { --accent:#7719aa; --accent-weak:#f3e9f8; }
.accent-blue    { --accent:#0078d4; --accent-weak:#e5f1fb; }
.accent-teal    { --accent:#038387; --accent-weak:#e1f3f3; }
.accent-green   { --accent:#107c10; --accent-weak:#e8f3e8; }
.accent-magenta { --accent:#b4009e; --accent-weak:#fbe7f8; }
.accent-orange  { --accent:#d83b01; --accent-weak:#fcebe3; }
.accent-red     { --accent:#c50f1f; --accent-weak:#fbe9ea; }
.accent-slate   { --accent:#4a5568; --accent-weak:#edf0f4; }

/* ---- Reset / base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* ---- Top bar ------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.topbar__brand:hover { text-decoration: none; }

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, #7719aa, #0078d4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.topbar__spacer { flex: 1; }

.topbar__user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar__user-email {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar__logout-form {
  display: inline;
}

.topbar__logout-btn {
  width: auto;
  padding: 7px 12px;
}

.topbar__login-btn {
  width: auto;
  padding: 7px 15px;
}

.iconbtn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
}

/* ==========================================================================
   HOME — course grid
   ========================================================================== */
.home {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.home__head { margin-bottom: 28px; }
.home__title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.home__subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 60ch;
}

.section-label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  margin: 32px 0 12px;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.course-card {
  position: relative;
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  color: var(--text);
  text-decoration: none;
}
.course-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
  text-decoration: none;
}

.course-card__bar { height: 8px; background: var(--accent); }

.course-card__body { padding: 16px 16px 18px; }

.course-card__top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.course-card__icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--accent-weak);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  flex: none;
}
.course-card__title { font-size: 16px; font-weight: 700; margin: 0; }
.course-card__short { color: var(--text-faint); font-size: 12px; }

.course-card__desc {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 14px;
  min-height: 38px;
}

.course-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-faint);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
}
.badge--public    { color:#107c10; border-color:#bfe0bf; background:#f1f8f1; }
.badge--protected { color:#0078d4; border-color:#bcdcf5; background:#eaf4fc; }
.badge--private   { color:#c50f1f; border-color:#eebcc0; background:#fbeef0; }

/* ---- Site footer --------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 56px;
}
.site-footer__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 44px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 40px;
}
.footer-about__name { font-size: 16px; font-weight: 800; margin: 0 0 6px; }
.footer-about p { margin: 0 0 14px; color: var(--text-muted); font-size: 13.5px; max-width: 48ch; }
.footer-about__bio-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
}

.footer-col__label {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  margin: 0 0 12px;
}

/* ---- Auth Pages ---------------------------------------------------------- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--topbar-h));
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-2);
}

.auth-card--wide {
  max-width: 500px;
}

.auth-card--wider {
  max-width: 700px;
}

.auth-card__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 24px;
  text-align: center;
}

.form-new {
  color: #0078d4;
}

.form-edit {
  color: #107c10;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: var(--border-strong);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}

.form-group textarea {
  resize: vertical;
  font-family: var(--font-mono);
}

.form-error {
  color: #c50f1f;
  font-size: 13px;
  margin-top: 6px;
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  width: 100%;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }

.btn--primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

.btn--primary:hover {
  filter: brightness(1.06);
  background: var(--accent);
}

.btn--full {
  width: 100%;
  display: block;
}

.course-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.course-section__title {
  font-size: 16px;
  margin: 0 0 16px;
  font-weight: 700;
}

.course-section__description {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.manage-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - var(--topbar-h));
}

.manage-sidebar {
  flex: 0 0 350px;
}

.manage-main {
  flex: 1;
}

.manage-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-1);
}

.manage-panel__title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--text);
}

.manage-panel__empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 32px 16px;
  text-align: center;
  margin: 0 0 16px;
}

.topics-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface);
}

.topic-item:hover {
  background: var(--surface-2);
}

.topic-item__content {
  flex: 1;
  min-width: 0;
}

.topic-item__title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin: 0;
}

.topic-item__subtitle {
  font-size: 12px;
  color: var(--text-faint);
  margin: 2px 0 0;
}

.topic-item__actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  flex: 0 0 auto;
}

.topic-item__btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.12s ease;
}

.topic-item__btn:hover {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.topic-item__drag-handle {
  margin-right: 8px;
  color: var(--text-muted);
  cursor: grab;
  font-size: 16px;
  line-height: 1;
  flex: 0 0 auto;
}

.topic-item[draggable="true"]:hover .topic-item__drag-handle {
  color: var(--text);
}

.topic-item.dragging {
  opacity: 0.5;
  background: var(--surface-3);
  border-color: var(--accent);
}

.topic-item.drag-over {
  border: 2px dashed var(--accent);
  background: var(--accent-weak);
}

@media (max-width: 1000px) {
  .manage-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .manage-sidebar {
    flex: none;
  }
}

.doc-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 24px;
  height: calc(100vh - var(--topbar-h));
  padding: 24px;
  max-width: 100%;
}

.manage-layout--doc {
  display: contents;
}

.doc-layout .manage-sidebar {
  height: fit-content;
}

.doc-layout .manage-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.manage-panel--content {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.doc-content-label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  padding: 16px 24px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  flex: 0 0 auto;
}

.doc-content-editor {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  background: var(--bg);
  color: var(--text);
  min-height: 0;
}

/* Style the CodeMirror editor when it replaces the textarea */
.doc-content-editor + .CodeMirror {
  flex: 1;
  min-height: 0;
  padding: 16px 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

.doc-content-editor:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent-weak);
}

/* EasyMDE / CodeMirror scrolling */
.CodeMirror {
  flex: 1;
  height: 100%;
  border: none;
}

.CodeMirror-scroll {
  overflow-y: scroll;
  overflow-x: auto;
}

.CodeMirror-gutters {
  flex-shrink: 0;
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 32px 16px;
  text-align: center;
}

.doc-empty {
  color: var(--text-faint);
  font-size: 13px;
  padding: 16px;
  text-align: center;
}

@media (max-width: 1000px) {
  .doc-layout {
    grid-template-columns: 1fr;
    gap: 16px;
    height: auto;
  }

  .doc-layout .manage-main {
    min-height: 500px;
  }
}

.auth-card__footer {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-card__footer a {
  color: var(--accent);
  font-weight: 600;
}

.colour-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.colour-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.colour-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--accent);
  flex: none;
  border: 1px solid var(--border);
  display: block;
}

.btn + .btn {
  margin-left: 10px;
}

.error-container {
  text-align: center;
  padding: 60px 24px;
}

.error-code {
  font-size: 36px;
  margin: 0 0 12px;
}

.error-message {
  font-size: 18px;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.btn--inline {
  display: inline-block;
  width: auto;
}

.login-prompt {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.qr-container {
  text-align: center;
  margin-bottom: 24px;
}

.qr-help {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.qr-note {
  color: var(--text-faint);
  font-size: 12px;
}

.home-section {
  margin-bottom: 20px;
}

.home-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.topbar-inline-form {
  display: inline;
}

.link-inherit {
  color: inherit;
  text-decoration: none;
}

.topic-link {
  color: inherit;
  text-decoration: none;
  flex: 1;
}

.doc-link {
  color: inherit;
}

.qr-code {
  text-align: center;
  margin: 20px 0;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.qr-code img {
  max-width: 200px;
  height: auto;
}

/* ==========================================================================
   COURSE — three-pane content view
   ========================================================================== */
.workspace {
  display: grid;
  grid-template-columns: 232px 248px 1fr;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}
.workspace.collapsed {
  grid-template-columns: 0 0 1fr;
}

.pane {
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  min-width: 0;
}
.pane__head {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.pane__eyebrow {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
}
.pane__title {
  font-size: 15px;
  font-weight: 700;
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pane__title .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); flex: none;
}

.pane__edit-btn,
.pane__add-btn {
  font-size: 14px;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.12s ease;
}

.pane__edit-btn {
  margin-left: auto;
}

.pane__add-btn {
  margin-left: 4px;
}

.pane__edit-btn:hover,
.pane__add-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.topics { list-style: none; margin: 0; padding: 8px; }
.topic {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  border: 1px solid transparent;
  text-decoration: none;
}
.topic:hover { background: var(--surface-3); cursor: pointer; }
.topic.is-active {
  background: var(--accent-weak);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  font-weight: 700;
}
.topic__bar {
  width: 3px; height: 18px; border-radius: 2px;
  background: transparent; flex: none;
}
.topic.is-active .topic__bar { background: var(--accent); }
.topic__count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 7px;
}

.docs { list-style: none; margin: 0; padding: 8px; }
.docs[hidden] { display: none; }
.doc {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}
.doc:hover { background: var(--surface-3); }
.doc.is-active {
  background: var(--bg);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-1);
}
.doc__icon { color: var(--text-faint); margin-top: 1px; flex: none; }
.doc.is-active .doc__icon { color: var(--accent); }
.doc__main { min-width: 0; }
.doc__title { font-weight: 600; font-size: 13.5px; text-decoration: none; }
.doc__sub { font-size: 11.5px; color: var(--text-faint); }
.doc__lock { margin-left: auto; color: var(--text-faint); font-size: 12px; }

.doc__drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  flex: 0 0 auto;
  margin-top: 1px;
}

.doc[draggable="true"]:hover .doc__drag-handle {
  color: var(--text);
}

.doc.dragging {
  opacity: 0.5;
  background: var(--surface-3);
  border-color: var(--accent);
}

.doc.drag-over {
  border: 2px dashed var(--accent);
  background: var(--accent-weak);
}

.content {
  overflow-y: auto;
  background: var(--bg);
}
.content__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 32px 40px 96px;
}

/* ---- HTML document iframe ------------------------------------------------ */
.html-doc-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

.doc-header { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 26px; }
.doc-header__eyebrow {
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.doc-header h1 {
  font-size: 30px;
  line-height: 1.2;
  margin: 6px 0 12px;
  letter-spacing: -0.01em;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* ---- Rendered document (reading) typography ------------------------------ */
.prose { font-size: 16px; line-height: 1.7; color: #2c2b29; }
.prose > * + * { margin-top: 1.05em; }
.prose h2 {
  font-size: 22px;
  margin-top: 1.8em;
  padding-bottom: .3em;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}
.prose h3 { font-size: 17px; margin-top: 1.5em; }
.prose p { margin: 0; }
.prose ul, .prose ol { margin: 0; padding-left: 1.4em; }
.prose li + li { margin-top: .35em; }
.prose strong { font-weight: 700; }
.prose code:not(pre code) {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.prose a { text-decoration: underline; text-underline-offset: 2px; }

.prose figure { margin: 1.6em 0; }
.prose figure img,
.figure-placeholder {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.figure-placeholder {
  aspect-ratio: 16 / 7;
  background: repeating-linear-gradient(45deg, var(--surface) 0 12px, var(--surface-2) 12px 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 13px;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.prose th, .prose td {
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--border);
}
.prose thead th { background: var(--surface-2); font-weight: 700; }
.prose tbody tr:nth-child(even) { background: var(--surface); }

/* ---- Callouts ------------------------------------------------------------ */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  border-left: 4px solid var(--text-faint);
}
.callout__icon { flex: none; font-size: 18px; line-height: 1.4; }
.callout__body { min-width: 0; }
.callout__title { font-weight: 700; margin-bottom: 2px; }
.callout--note    { border-left-color:#0078d4; background:#eef6fd; }
.callout--tip     { border-left-color:#107c10; background:#eef7ee; }
.callout--warning { border-left-color:#d83b01; background:#fdf0ea; }

/* ---- Code blocks --------------------------------------------------------- */
.codeblock {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #2c2c40;
  background: var(--code-bg);
  font-size: 13.5px;
  margin: 1.05em 0;
}
.codeblock__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #181826;
  color: #b9b9d0;
  font-size: 12px;
  border-bottom: 1px solid #2c2c40;
}
.codeblock__lang {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #cdcde6;
}
.codeblock__dots { display: flex; gap: 6px; }
.codeblock__dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.codeblock__dots i:nth-child(1){ background:#ff5f56; }
.codeblock__dots i:nth-child(2){ background:#ffbd2e; }
.codeblock__dots i:nth-child(3){ background:#27c93f; }
.codeblock__copy {
  margin-left: auto;
  background: transparent;
  border: 1px solid #3a3a52;
  color: #b9b9d0;
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 11.5px;
  cursor: pointer;
}
.codeblock__copy:hover { background:#2a2a3e; color:#fff; }
.codeblock pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  line-height: 1.6;
  color: #000;
}
.codeblock code { font-family: inherit; }

/* ---- Syntax highlighting (Pygments default light style) ----------------------- */
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.codeblock .hll { background-color: #ffffcc }
.codeblock { background: #f8f8f8; }
.codeblock .c { color: #3D7B7B; font-style: italic }
.codeblock .err { border: 1px solid #F00 }
.codeblock .k { color: #008000; font-weight: bold }
.codeblock .o { color: #333 }
.codeblock .p { color: #000 }
.codeblock .ch { color: #3D7B7B; font-style: italic }
.codeblock .cm { color: #3D7B7B; font-style: italic }
.codeblock .cp { color: #9C6500 }
.codeblock .cpf { color: #3D7B7B; font-style: italic }
.codeblock .c1 { color: #3D7B7B; font-style: italic }
.codeblock .cs { color: #3D7B7B; font-style: italic }
.codeblock .gd { color: #A00000 }
.codeblock .ge { font-style: italic }
.codeblock .ges { font-weight: bold; font-style: italic }
.codeblock .gr { color: #E40000 }
.codeblock .gh { color: #000080; font-weight: bold }
.codeblock .gi { color: #008400 }
.codeblock .go { color: #333 }
.codeblock .gp { color: #000080; font-weight: bold }
.codeblock .gs { font-weight: bold }
.codeblock .gu { color: #800080; font-weight: bold }
.codeblock .gt { color: #04D }
.codeblock .kc { color: #008000; font-weight: bold }
.codeblock .kd { color: #008000; font-weight: bold }
.codeblock .kn { color: #008000; font-weight: bold }
.codeblock .kp { color: #008000 }
.codeblock .kr { color: #008000; font-weight: bold }
.codeblock .kt { color: #B00040 }
.codeblock .m { color: #333 }
.codeblock .s { color: #BA2121 }
.codeblock .na { color: #687822 }
.codeblock .nb { color: #008000 }
.codeblock .nc { color: #00F; font-weight: bold }
.codeblock .no { color: #800 }
.codeblock .nd { color: #A2F }
.codeblock .ni { color: #717171; font-weight: bold }
.codeblock .ne { color: #CB3F38; font-weight: bold }
.codeblock .nf { color: #00F }
.codeblock .nl { color: #767600 }
.codeblock .nn { color: #00F; font-weight: bold }
.codeblock .nt { color: #008000; font-weight: bold }
.codeblock .nv { color: #19177C }
.codeblock .ow { color: #A2F; font-weight: bold }
.codeblock .w { color: #444 }
.codeblock .mb { color: #333 }
.codeblock .mf { color: #333 }
\.codeblock \.mh { color: #333 }
.codeblock .mi { color: #666 }
.codeblock .mo { color: #666 }
.codeblock .sa { color: #BA2121 }
.codeblock .sb { color: #BA2121 }
.codeblock .sc { color: #BA2121 }
.codeblock .dl { color: #BA2121 }
.codeblock .sd { color: #BA2121; font-style: italic }
.codeblock .s2 { color: #BA2121 }
.codeblock .se { color: #AA5D1F; font-weight: bold }
.codeblock .sh { color: #BA2121 }
.codeblock .si { color: #A45A77; font-weight: bold }
.codeblock .sx { color: #008000 }
.codeblock .sr { color: #A45A77 }
.codeblock .s1 { color: #BA2121 }
.codeblock .ss { color: #19177C }
.codeblock .bp { color: #008000 }
.codeblock .fm { color: #00F }
.codeblock .vc { color: #19177C }
.codeblock .vg { color: #19177C }
.codeblock .vi { color: #19177C }
.codeblock .vm { color: #19177C }
.codeblock .il { color: #666 }

/* ---- Mobile -------------------------------------------------------------- */
@media (max-width: 900px) {
  .auth-card {
    max-width: 100%;
    padding: 24px;
  }

  .workspace { grid-template-columns: 1fr; }
  .pane {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    width: 80%;
    max-width: 320px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-2);
  }
  .workspace.show-nav .pane.pane--topics { transform: translateX(0); }
  .workspace.show-nav .pane.pane--docs   { transform: translateX(0); left: min(80%,320px); }
  .content__inner { padding: 24px 20px 80px; }
}

/* ---- EasyMDE editor integration ---------------------------------- */
.EasyMDEContainer {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.EasyMDEContainer .CodeMirror {
  flex: 1;
  min-height: 0;
  overflow-y: scroll !important;
}

.EasyMDEContainer .editor-preview-side {
  flex: 1;
  min-height: 0;
  overflow-y: scroll !important;
}

.editor-toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
}

.editor-toolbar button {
  color: var(--text-muted);
}

.editor-toolbar button:hover,
.editor-toolbar button.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* Font Awesome CSS for EasyMDE icons (minimal inline version) */
.fa {
  display: inline-block;
  font-family: "Arial", sans-serif;
  font-style: normal;
  font-weight: normal;
  font-size: 13px;
  text-rendering: auto;
}

.fa-bold:before { content: "B"; font-weight: bold; }
.fa-italic:before { content: "I"; font-style: italic; }
.fa-strikethrough:before { content: "S"; text-decoration: line-through; }
.fa-heading:before { content: "H"; font-weight: bold; }
.fa-quote-left:before { content: "❝"; }
.fa-list-ul:before { content: "•"; }
.fa-list-ol:before { content: "1."; }
.fa-link:before { content: "🔗"; }
.fa-image:before { content: "🖼"; }
.fa-code:before { content: "</>" }
.fa-table:before { content: "▦"; }
.fa-eye:before { content: "👁"; }
.fa-columns:before { content: "□|□"; }
.fa-expand:before { content: "⤡"; }
.fa-undo:before { content: "↶"; }
.fa-redo:before { content: "↷"; }
.fa-question-circle:before { content: "?"; }

/* ---- File upload ------------------------------------------------------------- */
.manage-panel--files {
  max-height: 200px;
  overflow-y: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  margin-top: 0;
}

.doc-files-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text);
}

.file-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-weak);
}

.file-upload-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-weak);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.file-upload-prompt {
  pointer-events: none;
}

.file-upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.file-upload-zone p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

#file-input {
  display: none;
}

.files-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface);
  transition: all 0.2s ease;
}

.file-item.uploading {
  opacity: 0.6;
  background: var(--surface-2);
}

.file-item.error {
  background: #fce4e4;
  border-color: #f5b8b8;
}

.file-link {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  gap: 10px;
}

.file-link:hover {
  color: var(--accent);
}

.file-icon {
  flex: 0 0 auto;
  font-size: 14px;
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.file-size {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

.file-progress {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

.file-error {
  flex: 0 0 auto;
  font-size: 12px;
  color: #c50f1f;
  margin-left: 8px;
}

.file-delete-btn {
  flex: 0 0 auto;
  margin-left: 8px;
  padding: 4px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
}

.file-delete-btn:hover {
  background: #fce4e4;
  border-color: #f5b8b8;
  color: #c50f1f;
}

/* Files attached section in document view */
.files-attached {
  margin-top: 3em;
  padding-top: 2em;
  border-top: 1px solid var(--border);
}

.files-attached h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 12px;
}

.files-attached .files-list {
  margin: 0;
  padding: 0;
}

.files-attached .file-item {
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.files-attached .file-link {
  color: var(--accent);
  text-decoration: none;
}

.files-attached .file-link:hover {
  text-decoration: underline;
}
