/* ──────────────────────────────────────────────────────────────────────────
 * topics_portal.css — Mr Sharma's topic-selection portal
 * Loaded only on /tp/* pages (extends global style.css).
 * ────────────────────────────────────────────────────────────────────────── */

/* Portal-specific colour tokens (extend the global palette) */
:root {
  --amber: #92400e;       --amber-light: #fef3c7;
  --red-light: #fde8d8;   --red-dark: #7c2d12;
  --purple-light: #f3e8ff;--purple-dark: #6b21a8;
  --blue-light: #dbeafe;  --blue-dark: #1e40af;
  --green: #166534;       --green-light: #dcfce7;
}

body { min-height: 100vh; background: var(--bg); }

/* ── Email recipient dialog ───────────────────────────────────────────── */
dialog.email-dialog {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--bg-card, #fff);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
dialog.email-dialog::backdrop {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.email-dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 8px;
}
.email-dialog-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.email-dialog-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.4rem; line-height: 1; color: var(--text-muted);
  padding: 4px 10px; border-radius: 6px;
}
.email-dialog-close:hover { background: var(--bg); color: var(--text); }
.email-dialog-body {
  padding: 4px 18px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.email-dialog-sub {
  font-size: 0.82rem; color: var(--text-muted); margin: 0 0 4px;
}
.email-radio {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 0.88rem;
}
.email-radio:hover { border-color: var(--indigo); }
.email-radio:has(input:checked) {
  border-color: var(--indigo); background: var(--indigo-light);
}
.email-radio input[type="radio"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--indigo); }
.email-radio .muted { color: var(--text-muted); font-weight: 400; font-size: 0.8rem; }
.email-other-input {
  margin-top: 4px; width: 100%; box-sizing: border-box;
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.88rem; font-family: inherit; color: var(--text);
  background: var(--bg-card); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.email-other-input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
.email-check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  font-size: 0.85rem; color: var(--text);
  cursor: pointer;
}
.email-check input { accent-color: var(--indigo); flex-shrink: 0; }
.email-dialog-error {
  background: #fef2f2; color: #991b1b;
  border: 1px solid #fecaca; border-radius: 6px;
  padding: 8px 11px; font-size: 0.82rem;
}
.email-dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
}
.email-dialog-actions .btn-ghost,
.email-dialog-actions .btn-primary {
  padding: 8px 16px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; font-family: inherit;
  border: 1.5px solid var(--border);
}
.email-dialog-actions .btn-ghost { background: var(--bg-card); color: var(--text); }
.email-dialog-actions .btn-ghost:hover { background: var(--bg); }
.email-dialog-actions .btn-primary {
  background: var(--indigo); color: white; border-color: var(--indigo);
}
.email-dialog-actions .btn-primary:hover { background: var(--indigo-dark); }
.email-dialog-actions .btn-primary:disabled { background: var(--border); border-color: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ── Server-save failure banner ───────────────────────────────────────── */
.tp-save-error {
  position: sticky; top: 0; z-index: 250;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: #fef2f2;
  border-bottom: 2px solid #dc2626;
  color: #7f1d1d;
  padding: 10px 18px;
  font-size: 0.85rem; line-height: 1.4;
}
.tp-save-error[hidden] { display: none; }
.tp-save-error-msg     { flex: 1; min-width: 0; }
.tp-save-error-msg strong { font-weight: 700; margin-right: 4px; }
.tp-save-error-retry {
  flex-shrink: 0;
  background: #dc2626; color: white; border: none;
  padding: 6px 14px; border-radius: 7px;
  font-size: 0.8rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
}
.tp-save-error-retry:hover { background: #b91c1c; }

/* ── Top nav ────────────────────────────────────────────────────────────── */
.tp-nav {
  height: 58px; padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.tp-nav .nav-spacer { flex: 1; }
.tp-nav .nav-logo-dot { width: 30px; height: 30px; border-radius: 7px; font-size: 0.78rem; }
.tp-nav .nav-title { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.tp-nav .nav-badge {
  background: var(--indigo-light); color: var(--indigo-dark);
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 10px; border-radius: 12px; letter-spacing: 0.04em;
}
.tp-nav .nav-logout { font-size: 0.8rem; color: var(--text-muted); text-decoration: none; margin-left: 10px; }
.tp-nav .nav-logout:hover { color: var(--indigo); }

/* ── Login & success gates (full-screen indigo gradient) ─────────────────
   Slice C: gate now mirrors the public landing-page hero rhythm —
   bigger logo dot (48px), bolder typography (clamp h2, weight 800,
   tighter letter-spacing), more generous card padding, dark-mode
   parity on the gradient depth. */
.gate-wrap, .success-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #4338ca 100%);
  padding: 2rem;
}
@media (prefers-color-scheme: dark) {
  /* Match the deeper dark-mode hero gradient used by landing.html */
  .gate-wrap, .success-wrap {
    background: linear-gradient(135deg, #0a0820 0%, #1a1740 55%, #2a2670 100%);
  }
}
.gate-card, .success-card {
  background: white; border-radius: 16px;
  padding: 3rem 2.5rem 2.5rem;
  width: 100%; max-width: 440px;
  text-align: center;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.35);
}
.gate-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 1.5rem; }
.gate-logo-dot {
  width: 48px; height: 48px; background: var(--indigo);
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 1rem;
  letter-spacing: -0.5px;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.gate-logo-text { font-weight: 700; font-size: 1.1rem; color: var(--text); text-align: left; line-height: 1.3; }
.gate-logo-sub  { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.gate-h {
  font-size: clamp(1.5rem, 3.5vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}
.gate-sub  { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 1.75rem; line-height: 1.5; }
.gate-input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 0.95rem; font-family: inherit;
  color: var(--text); outline: none; margin-bottom: 1rem;
  transition: border-color 0.15s;
}
.gate-input:focus { border-color: var(--indigo); }
.gate-btn {
  width: 100%; background: var(--indigo); color: white; border: none;
  border-radius: 8px; padding: 11px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.gate-btn:hover { background: var(--indigo-dark); }
.gate-error {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
  border-radius: 7px; padding: 8px 12px; font-size: 0.82rem; margin-bottom: 0.8rem;
}

.success-icon-wrap {
  width: 64px; height: 64px; margin: 0 auto 1rem;
  background: var(--green-light); color: var(--green);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.success-card h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 0.5rem; }
.success-card p  { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.25rem; line-height: 1.6; }
.success-badge {
  background: var(--indigo-light); color: var(--indigo-dark);
  border-radius: 10px; padding: 10px 18px; display: inline-block;
  font-weight: 700; font-size: 1rem; margin-bottom: 1.5rem;
}
.success-summary {
  margin: 1.25rem 0;
  display: flex; flex-direction: column; gap: 8px;
  text-align: left;
}
.success-row {
  padding: 10px 14px; border-radius: 8px;
  font-size: 0.85rem; line-height: 1.4;
  border: 1px solid transparent;
}
.success-row strong { font-size: 1rem; font-weight: 800; }
.success-row-applied { background: var(--green-light); color: var(--green); border-color: rgba(22,163,74,0.25); }
.success-row-conflict { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.success-row-skipped  { background: var(--bg); color: var(--text-muted); border-color: var(--border); }
.back-link { font-size: 0.85rem; color: var(--indigo); text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ── Portal layout ─────────────────────────────────────────────────────── */
.portal-wrap   { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 8rem; }
.portal-header { margin-bottom: 1.25rem; }
.portal-header h1 { font-size: 1.4rem; font-weight: 800; margin-bottom: 0.2rem; }
.portal-header p  { font-size: 0.85rem; color: var(--text-muted); }

/* (Selected-balance bar removed — counts are now baked into the filter pills below.) */

/* ── Search bar ───────────────────────────────────────────────────────── */
.search-wrap  { position: relative; margin-bottom: 0.75rem; }
.search-icon  {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-input {
  width: 100%; box-sizing: border-box;
  padding: 9px 36px 9px 36px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 0.88rem; font-family: inherit; color: var(--text);
  background: white; outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--indigo); }
.search-clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); display: none; padding: 2px; line-height: 1;
}
.search-clear:hover { color: var(--text); }
.search-empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.9rem; display: none; }

/* ── Filter pills (now also show per-category counts) ─────────────────── */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px 5px 13px;
  border-radius: 20px;
  font-size: 0.8rem; font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
  background: var(--bg-card); color: var(--text-muted);
  font-family: inherit;
}
.filter-pill:hover  { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
/* Active state: inset ring in the pill's own colour — works for every tint */
.filter-pill.active { box-shadow: inset 0 0 0 2px currentColor; }

/* Category tints — each pill always shows its category color so the row
   doubles as the per-category count display. */
.filter-pill.filter-all          { background: var(--indigo-light); color: var(--indigo-dark); }
.filter-pill.filter-cat-HPB-General  { background: var(--blue-light);   color: var(--blue-dark); }
.filter-pill.filter-cat-OLT          { background: var(--red-light);    color: var(--red-dark); }
.filter-pill.filter-cat-Pancreas     { background: var(--amber-light);  color: var(--amber); }
.filter-pill.filter-cat-Liver-Bile   { background: var(--green-light);  color: var(--green); }
.filter-pill.filter-cat-Journal-Club { background: var(--purple-light); color: var(--purple-dark); }

.pill-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: 10px;
  background: rgba(0,0,0,0.10);
  color: inherit;
  font-size: 0.7rem; font-weight: 800;
  line-height: 1;
}
.filter-pill.active .pill-count { background: rgba(0,0,0,0.18); }

/* ── "Add a topic" inline form ────────────────────────────────────────── */
.add-topic-bar {
  display: flex; gap: 8px; margin-bottom: 1rem; align-items: center;
  background: var(--primary-bg);
  border: 1.5px dashed var(--indigo); border-radius: 10px;
  padding: 10px 12px;
}
.add-topic-input  { flex: 1; min-width: 0; width: auto; }
.add-topic-select { flex-shrink: 0; width: auto; }
.add-topic-btn {
  background: var(--indigo); color: white; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  white-space: nowrap; flex-shrink: 0; transition: background 0.15s;
}
.add-topic-btn:hover    { background: var(--indigo-dark); }
.add-topic-btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ── Topic cards ──────────────────────────────────────────────────────── */
.topic-list { display: flex; flex-direction: column; gap: 6px; }

.topic-card {
  background: white; border: 1.5px solid var(--border); border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.topic-card.selected { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
.topic-card.hidden   { display: none; }
.topic-card.is-favourite { border-left-width: 3px; border-left-color: #f59e0b; background: rgba(245,158,11,0.04); }

/* Star + delete buttons in the topic row */
.t-fav, .t-delete {
  flex-shrink: 0;
  background: none; border: none; padding: 4px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  line-height: 0;
}
/* Small purple "community suggestion" indicator next to the topic title.
   Matches the same icon used on the builder side (partials/topic_card.html). */
.t-suggestion {
  display: inline-flex; align-items: center;
  color: #8b5cf6;
  flex-shrink: 0;
  margin-left: 4px;
  cursor: help;
}
.t-fav svg { fill: none; transition: fill 0.15s, color 0.15s; }
.t-fav:hover { color: #f59e0b; }
.topic-card.is-favourite .t-fav { color: #f59e0b; }
.topic-card.is-favourite .t-fav svg { fill: #f59e0b; }
.t-delete:hover { color: #dc2626; background: #fef2f2; }

.topic-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; }
.topic-check {
  width: 18px; height: 18px; border-radius: 5px;
  border: 2px solid var(--border); flex-shrink: 0;
  cursor: pointer; accent-color: var(--indigo);
}
.topic-title-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.t-title {
  font-size: 0.9rem; font-weight: 600; color: var(--text);
  outline: none; display: block; flex: 1; min-width: 0;
}
.t-title:focus { background: var(--indigo-light); border-radius: 4px; padding: 1px 4px; }
.t-edit-icon {
  color: var(--text-muted); opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.topic-card.selected .t-edit-icon,
.topic-card:hover    .t-edit-icon { opacity: 0.5; }
.topic-card.selected .t-edit-icon:hover { opacity: 1; color: var(--indigo); }

.cat-pill {
  display: inline-block;
  padding: 2px 9px; border-radius: 10px;
  font-size: 0.68rem; font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}
.cat-HPB-General  { background: var(--blue-light);   color: var(--blue-dark); }
.cat-OLT          { background: var(--red-light);    color: var(--red-dark); }
.cat-Pancreas     { background: var(--amber-light);  color: var(--amber); }
.cat-Liver-Bile   { background: var(--green-light);  color: var(--green); }
.cat-Journal-Club { background: var(--purple-light); color: var(--purple-dark); }

/* ── Expanded details (per-card field grid) ───────────────────────────── */
.topic-details {
  max-height: 0; overflow: hidden;
  transition: max-height 0.25s ease, padding 0.15s;
  padding: 0 14px;
}
.topic-card.selected .topic-details { max-height: 400px; padding: 0 14px 12px; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  border-top: 1px solid var(--border); padding-top: 10px;
}
@media (max-width: 560px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-field { display: flex; flex-direction: column; gap: 3px; }
.detail-field.full { grid-column: 1 / -1; }
.detail-field label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.detail-field input,
.detail-field textarea {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 0.85rem; font-family: inherit;
  color: var(--text); background: white; outline: none;
  transition: border-color 0.15s; resize: vertical; width: 100%;
}
.detail-field input:focus,
.detail-field textarea:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }

/* ── Global notes & step-2 review ─────────────────────────────────────── */
.global-notes-wrap  { margin-top: 1.5rem; }
.global-notes-label {
  font-size: 0.82rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px; display: block;
}
.global-notes-ta {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 0.88rem; font-family: inherit;
  color: var(--text); resize: vertical; min-height: 80px; outline: none;
  transition: border-color 0.15s;
}
.global-notes-ta:focus { border-color: var(--indigo); }

#step2-content      { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 8rem; display: none; }
.step2-header       { margin-bottom: 1.5rem; }
.step2-back {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.82rem; color: var(--indigo);
  background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 0 0 0.75rem;
}
.step2-back:hover { text-decoration: underline; }
.step2-title-row    { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.step2-title-row h1 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.step2-title-row p  { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

/* ── Step 2: real session slot list (mirrors the builder) ─────────────── */
.slot-legend {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  font-size: 0.74rem; color: var(--text-muted);
  margin-bottom: 12px;
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-tip  { margin-left: auto; font-style: italic; }
.legend-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-empty     { background: white; border: 1.5px solid var(--border); }
.legend-filled    { background: var(--indigo); }
.legend-locked    { background: #d97706; }
.legend-cancelled { background: var(--text-muted); }

/* Picks bench (unplaced topics) ───────────────────────────────────────── */
.picks-bench {
  background: var(--primary-bg);
  border: 1.5px dashed var(--indigo);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.picks-bench[hidden] { display: none; }
.picks-bench-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.picks-bench-label {
  font-size: 0.74rem; font-weight: 700;
  color: var(--indigo-dark);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.picks-bench-hint { font-size: 0.7rem; color: var(--text-muted); font-style: italic; }
.picks-bench-list {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.picks-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: white;
  border: 1.5px solid var(--indigo);
  border-radius: 16px;
  padding: 4px 11px 4px 8px;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text);
  cursor: grab;
  transition: transform 0.1s, box-shadow 0.1s;
  max-width: 320px;
}
.picks-chip:hover { box-shadow: 0 2px 8px rgba(79,70,229,0.18); transform: translateY(-1px); }
.picks-chip:active { cursor: grabbing; }
.picks-chip.dragging { opacity: 0.4; }
.picks-chip-title  {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; max-width: 240px;
}

/* ── Slot cards ────────────────────────────────────────────────────────── */
.slot-list { display: flex; flex-direction: column; gap: 8px; }

.slot-card {
  display: flex; align-items: stretch; gap: 12px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 78px;   /* keeps empty + filled cards rhythmically aligned */
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
  position: relative;
}
.slot-card.slot-empty .slot-body {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.slot-card.slot-filled {
  border-color: var(--indigo);
  background: rgba(79,70,229,0.04);
  box-shadow: 0 1px 0 rgba(79,70,229,0.08);
}
.slot-card.slot-filled[draggable="true"] { cursor: grab; }
.slot-card.slot-filled.dragging { opacity: 0.4; cursor: grabbing; }
.slot-card.slot-locked {
  border-color: #fcd34d;
  background: #fffbeb;
}
.slot-card.slot-cancelled {
  border-style: dashed;
  background: var(--bg);
  opacity: 0.6;
}
.slot-card.slot-cancelled .slot-date { text-decoration: line-through; opacity: 0.7; }
.slot-card.drag-over {
  border-color: var(--indigo);
  background: rgba(79,70,229,0.1);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.18);
}
.slot-card.drag-reject {
  border-color: #dc2626;
  background: rgba(220,38,38,0.06);
}

/* Date strip */
.slot-date {
  flex-shrink: 0;
  width: 56px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding-top: 2px;
  border-right: 1px solid var(--border);
  padding-right: 12px;
  margin-right: 0;
  user-select: none;
}
.slot-card.slot-filled .slot-date,
.slot-card.slot-locked .slot-date {
  border-right-color: rgba(0,0,0,0.06);
}
.slot-day {
  font-size: 1.55rem; font-weight: 800; line-height: 1;
  color: var(--text);
}
.slot-mon {
  font-size: 0.7rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-top: 1px;
}
.slot-dow {
  font-size: 0.65rem; color: var(--text-muted);
  margin-top: 4px;
}

/* Main column — wraps body + warning so the warning isn't wiped when
   JS rebuilds .slot-body's innerHTML on a topic change. */
.slot-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}

/* Body */
.slot-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
  justify-content: center;
}
.slot-empty-row {
  display: flex; align-items: center; gap: 8px;
}
.slot-empty-row .cs-wrap { flex: 1; max-width: 420px; }
.slot-empty-hint {
  margin-top: 6px;
  font-size: 0.72rem; color: var(--text-muted); font-style: italic;
}
.slot-empty-msg {
  font-size: 0.78rem; color: var(--text-muted); font-style: italic;
}
.slot-locked-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.slot-topic-title {
  font-size: 0.92rem; font-weight: 600; color: var(--text);
  flex: 1; min-width: 0;
  word-break: break-word;
}
.slot-topic-meta {
  font-size: 0.72rem; color: var(--text-muted);
  margin-top: 2px;
}
.slot-cancelled-label { font-size: 0.82rem; font-style: italic; color: var(--text-muted); }
.slot-cancelled-reason {
  font-size: 0.78rem; color: var(--text);
  margin-top: 6px; padding: 6px 10px;
  background: rgba(0,0,0,0.04); border-radius: 6px;
  line-height: 1.35;
}
.slot-cancelled-reason strong { color: var(--text-muted); font-weight: 700; margin-right: 4px; }
.slot-locked-tag {
  font-size: 0.62rem; font-weight: 700;
  background: #fcd34d; color: #78350f;
  padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.04em;
  flex-shrink: 0;
}
.slot-tag-cancelled { background: var(--text-muted); color: white; }

/* Holiday clash warning — appears below the topic row on any slot whose
   date overlaps a bank holiday or school break. Amber to grab attention
   without competing with the indigo "filled" state. */
.slot-warning {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 6px;
  font-size: 0.72rem; line-height: 1.3;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 5px;
  padding: 3px 8px;
  align-self: flex-start;
}
.slot-warning svg { color: #d97706; flex-shrink: 0; }
.slot-card.slot-has-warning { border-left: 3px solid #fcd34d; }

/* Filled slot — topic header row + compact field grid */
.slot-topic-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.slot-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin-top: 2px;
}
.slot-field { display: flex; min-width: 0; }
.slot-field-full { grid-column: 1 / -1; }
/* Inputs use platform-standard sizing from forms.css; just stretch full-width here */
.slot-field input,
.slot-field .cs-wrap { width: 100%; }

/* Move-to row sits beneath the field grid as a small footer action */
.slot-moveto-row {
  margin-top: 6px;
  display: flex; align-items: center; gap: 8px;
}
.slot-moveto-row .cs-wrap { max-width: 220px; }

@media (max-width: 560px) {
  .slot-fields { grid-template-columns: 1fr; }
}

/* Picker (.custom-select inside an empty slot) */
.slot-card .cs-wrap { flex: 1; min-width: 200px; }

/* Right-side controls — × clear + ⋮⋮ drag handle */
.slot-controls {
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  justify-content: center;
}
.slot-controls[hidden] { display: none; }
.slot-clear {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 4px; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.slot-clear:hover { color: #dc2626; background: #fef2f2; }
.slot-handle {
  color: var(--text-muted);
  cursor: grab; padding: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  user-select: none;
}
.slot-handle:hover { color: var(--indigo); background: rgba(79,70,229,0.06); }
.slot-handle:active { cursor: grabbing; }

/* When in lift mode: visually mark the lifted slot, dim non-targets */
.slot-card.slot-lifted {
  border-color: var(--indigo) !important;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.20);
  cursor: default;
}
body.is-lifting .slot-card:not(.slot-lifted):not(.slot-locked):not(.slot-cancelled) {
  cursor: copy;
}
body.is-lifting .slot-card:not(.slot-lifted):not(.slot-locked):not(.slot-cancelled):hover {
  border-color: var(--indigo);
  background: rgba(79,70,229,0.05);
}
body.is-lifting .slot-card:not(.slot-lifted):not(.slot-locked):not(.slot-cancelled):hover .slot-date {
  color: var(--indigo);
}
/* While lifting, all interactive controls inside non-lifted slots become
   inert so a click anywhere on them is treated as "place here". The
   slot-handle (so you can lift another instead) stays interactive. */
body.is-lifting .slot-card:not(.slot-lifted) input,
body.is-lifting .slot-card:not(.slot-lifted) select,
body.is-lifting .slot-card:not(.slot-lifted) textarea,
body.is-lifting .slot-card:not(.slot-lifted) .cs-trigger,
body.is-lifting .slot-card:not(.slot-lifted) .slot-clear { pointer-events: none; }

/* Lift banner — sticky at top of the slot list while a slot is lifted */
.lift-banner {
  position: sticky;
  top: 8px;
  z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--indigo);
  color: white;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  box-shadow: 0 6px 16px rgba(79,70,229,0.35);
  animation: lift-in 0.2s ease;
}
.lift-banner[hidden] { display: none; }
.lift-banner-msg {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.85rem; min-width: 0;
}
.lift-banner-msg strong { font-weight: 700; }
.lift-banner-cancel {
  background: rgba(255,255,255,0.2); color: white;
  border: 1px solid rgba(255,255,255,0.4); border-radius: 7px;
  padding: 5px 11px; font-size: 0.78rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  flex-shrink: 0;
  transition: background 0.15s;
}
.lift-banner-cancel:hover { background: rgba(255,255,255,0.32); }
@keyframes lift-in { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 560px) {
  .slot-card { padding: 10px 12px; gap: 10px; }
  .slot-date { width: 48px; padding-right: 10px; }
  .slot-day  { font-size: 1.35rem; }
}

.review-list { display: flex; flex-direction: column; gap: 8px; }
.review-card {
  background: white; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.review-card.drag-over { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
.review-card.dragging  { opacity: 0.35; }
.review-top      { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.drag-handle     { cursor: grab; color: var(--text-muted); flex-shrink: 0; line-height: 0; }
.drag-handle:active { cursor: grabbing; }
.review-num {
  width: 22px; height: 22px; background: var(--indigo); color: white;
  border-radius: 50%; font-size: 0.7rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.review-title-input {
  flex: 1; border: none; border-bottom: 1.5px solid transparent;
  font-size: 0.92rem; font-weight: 600; font-family: inherit;
  color: var(--text); background: transparent; outline: none;
  padding: 2px 4px; min-width: 0;
  transition: border-color 0.15s;
}
.review-title-input:focus { border-bottom-color: var(--indigo); background: var(--indigo-light); border-radius: 4px 4px 0 0; }
.review-remove {
  margin-left: auto; flex-shrink: 0; background: none; border: none;
  cursor: pointer; color: var(--text-muted); padding: 4px;
  border-radius: 4px; line-height: 0;
}
.review-remove:hover { color: #dc2626; background: #fef2f2; }
.review-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 560px) { .review-fields { grid-template-columns: 1fr; } }
.review-field { display: flex; flex-direction: column; gap: 3px; }
.review-field.full { grid-column: 1 / -1; }
.review-field label {
  font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.review-field input {
  border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 10px; font-size: 0.84rem; font-family: inherit;
  color: var(--text); background: white; outline: none;
  transition: border-color 0.15s;
}
.review-field input:focus { border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(79,70,229,0.1); }
.step2-empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 0.9rem; }

/* ── Sticky bottom submit bar ─────────────────────────────────────────── */
.submit-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: white; border-top: 1px solid var(--border);
  padding: 12px 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; z-index: 100;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.07);
}
/* Override: `.submit-bar` and `.u-hidden` are both single-class
   selectors, so their specificity is equal. Because this file loads
   AFTER style.css (where .u-hidden lives), `display: flex` above
   wins the cascade and the step2 bar shows on top of step1's. The
   two-class selector below has higher specificity and restores the
   intended hiding semantics. Regression caught visually on
   topics.hpbteaching.app step 1 — see commit history. */
.submit-bar.u-hidden { display: none; }
.submit-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.submit-count { font-size: 0.95rem; color: var(--text); }
.submit-count strong { font-size: 1.1rem; font-weight: 800; }
.submit-saved {
  font-size: 0.72rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
  min-height: 14px;
}
.submit-saved.visible { color: var(--green); }
.submit-btn {
  background: var(--indigo); color: white; border: none; border-radius: 9px;
  padding: 10px 22px; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s; white-space: nowrap;
}
.submit-btn:hover    { background: var(--indigo-dark); }
.submit-btn:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
.save-btn {
  background: white; color: var(--indigo); border: 1.5px solid var(--indigo);
  border-radius: 9px; padding: 10px 22px; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: all 0.15s; white-space: nowrap;
}
.save-btn:hover { background: var(--indigo-light); }
.save-btn.saved { color: #166534; border-color: #16a34a; background: #f0fdf4; }
.submit-btns { display: flex; gap: 8px; flex-shrink: 0; }
.action-btn {
  background: white; color: var(--text-muted);
  border: 1.5px solid var(--border); border-radius: 9px;
  padding: 10px 16px; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all 0.15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.action-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.action-btn.sent  { color: #166534; border-color: #16a34a; background: #f0fdf4; }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.section-empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); font-size: 0.9rem; }

@media (max-width: 480px) {
  .tp-nav      { padding: 0 1rem; }
  .portal-wrap { padding: 1rem 0.75rem 8rem; }
  .submit-bar  { padding: 10px 1rem; }
}

/* ── Print (review page only) ─────────────────────────────────────────── */
@media print {
  .tp-nav, #step1-bar, #step2-bar,
  .review-remove, .drag-handle, .step2-back,
  .review-num, .step2-title-row p { display: none !important; }
  #step2-content { padding: 1rem 0 !important; display: block !important; }
  #step1-content { display: none !important; }
  .review-card   { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid; margin-bottom: 6px; padding: 8px 10px; }
  .review-title-input { font-size: 0.95rem !important; }
  body { background: white !important; }
}

/* ── Dark mode ────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --amber: #fbbf24;        --amber-light: rgba(245,158,11,0.18);
    --red-light: rgba(220,38,38,0.18);  --red-dark: #fca5a5;
    --purple-light: rgba(147,51,234,0.18); --purple-dark: #d8b4fe;
    --blue-light: rgba(37,99,235,0.18); --blue-dark: #93c5fd;
    --green: #4ade80;        --green-light: rgba(34,197,94,0.18);
  }
  /* Login / success keep their light card on the dark gradient */
  .gate-card,
  .success-card { background: #f1f5f9; }
  .gate-card .gate-h, .gate-card .gate-sub, .gate-card .gate-logo-text,
  .success-card h2, .success-card p { color: #1e293b; }
  .gate-card .gate-logo-sub { color: #475569; }
  .gate-card .gate-input    { background: #ffffff; color: #1e293b; border-color: #cbd5e1; }
  .gate-card .gate-error    { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

  /* Dark equivalents for elements with hard-coded white backgrounds */
  .search-input              { background: var(--input-bg); }
  .add-topic-bar             { background: var(--primary-bg); }
  /* Filter-pill tints: keep the colour relationships but use the dark
     palette tokens (var(--blue-light) etc. already adapt in dark mode). */
  .topic-card                { background: var(--bg-card); }
  .detail-field input,
  .detail-field textarea     { background: var(--input-bg); }
  .global-notes-ta           { background: var(--input-bg); }
  .submit-bar                { background: var(--bg-card); box-shadow: 0 -4px 16px rgba(0,0,0,0.4); }
  .save-btn                  { background: var(--bg-card); }
  .review-card               { background: var(--bg-card); }
  .review-field input        { background: var(--input-bg); }
  .action-btn                { background: var(--bg-card); }
}
