.admin-wrap {
  padding: 28px;
  max-width: 940px;
  margin: 0 auto;
  width: 100%;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.admin-head h2 { font-size: 21px; margin-bottom: 5px; }
.admin-head p { color: var(--text-2); font-size: 13.5px; max-width: 560px; }

.signin-card {
  max-width: 400px;
  margin: 8vh auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 30px;
  box-shadow: var(--shadow-lg);
}
.signin-card .lock {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--brand-soft);
  color: var(--brand-text);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
}
.signin-card h2 { font-size: 19px; margin-bottom: 6px; }
.signin-card > p { color: var(--text-2); font-size: 13.5px; margin-bottom: 20px; }

/* ---------- dropzone ---------- */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-xl);
  padding: 34px 24px;
  text-align: center;
  background: var(--surface);
  margin-bottom: 24px;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.dropzone.drag {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.dropzone .up-icon {
  width: 52px; height: 52px;
  border-radius: var(--r-lg);
  background: var(--brand-soft);
  color: var(--brand-text);
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
}
.dropzone h3 { font-size: 16px; margin-bottom: 5px; }
.dropzone > p { font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.dropzone.busy { opacity: .75; pointer-events: none; }

.progress-line {
  height: 6px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 18px;
}
.progress-line > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand-500), var(--accent-400));
  border-radius: var(--r-pill);
  transition: width .3s var(--ease);
}
.progress-label { font-size: 12px; color: var(--text-2); margin-top: 8px; }

/* ---------- chapter editor ---------- */

.admin-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.admin-row .field { flex: 1; min-width: 240px; margin-bottom: 0; }

.admin-chapter {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.admin-chapter-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.admin-chapter-head input[type=text] {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  border-color: transparent;
  background: transparent;
  flex: 1;
  min-width: 180px;
}
.admin-chapter-head input[type=text]:hover { border-color: var(--line); background: var(--surface); }
.admin-chapter-meta {
  padding: 9px 14px;
  font-size: 11.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
}

.admin-slide-list { max-height: 480px; overflow-y: auto; }
.admin-slide-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.admin-slide-row:last-child { border-bottom: none; }
.admin-slide-row:hover { background: var(--surface-2); }
.admin-slide-row .idx {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  width: 22px;
  flex-shrink: 0;
}
.admin-slide-title {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-slide-actions { display: flex; gap: 5px; flex-shrink: 0; }

.stype-pill {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--surface-3);
  color: var(--text-2);
}
.stype-pill.content  { background: var(--brand-soft); color: var(--brand-text); }
.stype-pill.quiz     { background: var(--warn-bg); color: var(--warn-fg); }
.stype-pill.video    { background: var(--ok-bg); color: var(--ok-fg); }
.stype-pill.diagram  { background: #f1e9ff; color: #6b3fbf; }
.stype-pill.exercise { background: var(--bad-bg); color: var(--bad-fg); }
[data-theme="dark"] .stype-pill.diagram { background: #2a1f45; color: #c4b5fd; }

.add-slide-row { display: flex; gap: 8px; padding: 12px 14px; flex-wrap: wrap; align-items: center; }
.add-slide-row select { width: auto; min-width: 150px; }

.admin-empty-state {
  padding: 30px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text-2);
  text-align: center;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.field-opt { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.field-opt input[type=radio] { flex-shrink: 0; width: 17px; height: 17px; accent-color: var(--brand); }
.field-opt input[type=text] { flex: 1; }

@media (max-width: 640px) {
  .admin-wrap { padding: 18px 14px 40px; }
  .admin-slide-row { flex-wrap: wrap; }
}

/* ==================================================================
   The slide gallery
   ------------------------------------------------------------------
   The row list says a slide is called "TOOL SLIDE" and nothing else, which is
   no help when a deck holds four of them. This is the view where a deck of
   slides looks like a deck of slides.
   ================================================================== */

.slide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px;
  padding: 14px;
}

.slide-card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.slide-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }

.slide-card-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface-3);
}
.slide-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
}

.slide-card-noimage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 11.5px;
}

/* Over the image, so a 16:9 thumbnail is not made taller by its own label. */
.slide-card-index,
.slide-card-warn {
  position: absolute;
  top: 6px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  background: rgba(8, 12, 19, .68);
  color: #fff;
}
.slide-card-index { left: 6px; }
.slide-card-warn {
  right: 6px;
  display: grid;
  place-items: center;
  padding: 3px;
  color: var(--warn-fg);
  background: var(--warn-bg);
}

.slide-card-body {
  padding: 10px 11px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.slide-card-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  /* Two lines, then ellipsis — a deck's titles vary wildly in length and a
     card that grows to fit the longest one wrecks the grid. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slide-card-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  padding: 8px 9px;
}

/* ---------- the edit dialog, with the render beside the fields ---------- */

.modal.modal-wide { max-width: 940px; }

/* Only applied when there is a render to show; without one the dialog keeps
   its single-column layout rather than sitting in half a box. */
.modal-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.modal-preview {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.modal-preview img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-3);
  cursor: zoom-in;
}

/* The progress report reuses the dashboard's stat tiles, which are laid out
   four to a row. This page shows three. */
.admin-wrap .dash-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

@media (max-width: 860px) {
  .modal-split { grid-template-columns: minmax(0, 1fr); }
  .modal-preview { position: static; }
  .slide-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 10px; }
}

/* ---------- the course the console is working inside ---------- */

.admin-course-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.admin-course-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* The select takes the room; the buttons keep their natural width. */
.admin-course-row select { flex: 1; min-width: 180px; }

/* ---------- the console's sections ---------- */

.admin-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow-x: auto;
}
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.admin-nav-item:hover { background: var(--surface); color: var(--text); }
.admin-nav-item.on {
  background: var(--surface);
  color: var(--brand-text);
  box-shadow: var(--shadow-sm);
}

/* ---------- marking something as key content ---------- */

.highlight-opt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 9px;
  align-items: center;
  width: fit-content;
  margin: 4px auto 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  transition: border-color .12s var(--ease), background .12s var(--ease);
}
.highlight-opt:hover { border-color: var(--brand); }
/* Lit up while ticked, so the choice is obvious before the file is chosen. */
.highlight-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.highlight-opt input { width: 15px; height: 15px; margin: 0; cursor: pointer; }
.highlight-opt span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}
.highlight-opt:has(input:checked) span { color: var(--brand-text); }
.highlight-opt em {
  grid-column: 2;
  font-size: 11.5px;
  font-style: normal;
  color: var(--text-3);
}

/* The star toggle on a chapter header and a collection row. */
.icon-btn.starred { color: var(--brand); }
.icon-btn.starred svg { fill: currentColor; }

/* A document's title, editable in place like a chapter's. Transparent until
   you reach for it, so a list of documents still reads as a list. */
.doc-rename {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 550;
  border-color: transparent;
  background: transparent;
  padding: 5px 8px;
}
.doc-rename:hover { border-color: var(--line); background: var(--surface); }
.doc-rename:focus { border-color: var(--brand); background: var(--surface); }
