:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e6ec;
  --text: #1c2430;
  --muted: #65707d;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eaf1fe;
  --danger-bg: #fdecea;
  --danger-text: #b91c1c;
  --info-bg: #eaf2fd;
  --info-text: #1e40af;
  --success-bg: #e7f6ec;
  --success-text: #166534;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.85em; }
.muted { color: var(--muted); }
.muted a { color: var(--accent); }

/* --- layout ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.6rem 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.topnav { display: flex; align-items: center; gap: 0.25rem; flex: 1; }

.nav-link {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--accent-soft); color: var(--accent-dark); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.topnav-user { display: flex; align-items: center; gap: 0.75rem; }
.topnav-user .user { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

.container { max-width: 1000px; margin: 2rem auto; padding: 0 1.5rem; }
.container-wide { max-width: 1280px; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 0 1.5rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.page-head p { margin: 0; }
.page-head-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.page-head-actions form { margin: 0; }
.page-meta .badge { vertical-align: baseline; }

/* --- cards & tables ----------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-table { padding: 0.5rem 0.75rem; }

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.card-title { margin: 0; font-size: 1.15rem; }

.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1.5rem; }
.empty-state p { margin: 0.35rem 0; }
.empty-state .btn { margin-top: 1rem; }
.empty-emoji { font-size: 2.5rem; line-height: 1; margin-bottom: 0.75rem; }

table.sessions { width: 100%; border-collapse: collapse; }
table.sessions th {
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
table.sessions td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.sessions tr:last-child td { border-bottom: none; }
table.sessions tbody tr { transition: background 0.1s ease; }
table.sessions tbody tr:hover td { background: #f8fafd; }

.session-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.session-link:hover { text-decoration: underline; }

/* --- badges -------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
  background: #eef1f4;
  color: var(--text);
}
.badge-queued       { background: #f1f5f9; color: #475569; }
.badge-transcribing { background: #fef3c7; color: #92400e; }
.badge-generating   { background: #ede9fe; color: #5b21b6; }
.badge-done         { background: var(--success-bg); color: var(--success-text); }
.badge-error        { background: var(--danger-bg); color: var(--danger-text); }
.badge-shared       { background: var(--accent-soft); color: var(--accent-dark); }

/* --- buttons & forms ------------------------------------------------------ */

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.35rem 0.85rem;
}
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.85rem; }
.btn-danger { color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-bg); }

.form { display: flex; flex-direction: column; gap: 0.5rem; }
.form label { font-size: 0.9rem; font-weight: 600; margin-top: 0.5rem; }
.form input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
.form input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.form button { margin-top: 1rem; align-self: flex-start; }
.form-select { max-width: 100%; width: 100%; }

.login-wrap { display: flex; justify-content: center; padding-top: 3rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin-top: 0; }
.login-card .btn { align-self: stretch; }

/* --- flashes --------------------------------------------------------------- */

.flash {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.flash-error   { background: var(--danger-bg); color: var(--danger-text); }
.flash-info    { background: var(--info-bg); color: var(--info-text); }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash a { color: inherit; font-weight: 600; }

/* --- recorder-download --------------------------------------------------------- */

.download-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.download-icon { font-size: 2.5rem; line-height: 1; }
.download-info { flex: 1; min-width: 220px; }
.download-info .card-title { margin-bottom: 0.15rem; }
.download-info p { margin: 0; }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 1.05rem; }

.steps-list { margin: 0.5rem 0 0; padding-left: 1.4rem; }
.steps-list li { margin-bottom: 0.5rem; }
.download-note { margin: 1rem 0 0; font-size: 0.9rem; }

/* --- breadcrumbs ------------------------------------------------------------- */

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.breadcrumbs a { color: var(--accent); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); }
.crumb-current { color: var(--muted); }

/* --- workspace / wiki ----------------------------------------------------------- */

.workspace-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.ws-sidebar {
  position: sticky;
  top: 4.4rem; /* onder de sticky topbar */
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.ws-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.25rem 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.6rem;
}
.ws-sidebar-title {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.ws-sidebar-title:hover { color: var(--accent-dark); }
.ws-sidebar-empty { margin: 0.25rem; font-size: 0.9rem; }

.ws-content { min-width: 0; }

.recent-meta { font-size: 0.85rem; margin-left: 0.5rem; }

.wiki-tree { list-style: none; margin: 0; padding: 0; }
.wiki-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 1.4rem;
  border-left: 1px solid var(--border);
}
.wiki-tree li { margin: 0; }

.wiki-tree-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
}
.wiki-tree-row:hover { background: #f8fafd; }
.wiki-tree-row.active { background: var(--accent-soft); }
.wiki-tree-row.active .wiki-tree-link { color: var(--accent-dark); font-weight: 600; }
.wiki-tree-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.93rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-tree-link:hover { color: var(--accent-dark); text-decoration: underline; }
.wiki-tree-add {
  margin-left: auto;
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.wiki-tree-row:hover .wiki-tree-add { opacity: 1; }

.wiki-children { list-style: none; margin: 0; padding: 0; }
.wiki-children li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.wiki-children li:last-child { border-bottom: none; }

.wiki-content { min-height: 6rem; }

/* --- share-dropdown (sessie → workspace) -------------------------------------------- */

.share-panel { position: relative; }
.share-panel summary {
  list-style: none;
  user-select: none;
}
.share-panel summary::-webkit-details-marker { display: none; }
.share-panel[open] summary { background: var(--accent-soft); }
.share-form {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 10;
  width: 320px;
  max-width: 90vw;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1rem 1.25rem 1.25rem;
}
.share-form button { margin-top: 0.5rem; }
.share-hint { font-size: 0.85rem; margin: 0.25rem 0 0; }

/* --- SOP content ------------------------------------------------------------ */

.sop-content h1, .sop-content h2, .sop-content h3 { margin-top: 1.25rem; }
.sop-content h2:first-of-type { margin-top: 0; }
.sop-content code {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.9em;
}
.sop-content pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}
.sop-content table { border-collapse: collapse; }
.sop-content th, .sop-content td { border: 1px solid var(--border); padding: 0.35rem 0.7rem; }

/* --- steps -------------------------------------------------------------------- */

.steps-section h2 { font-size: 1.2rem; }
.steps { display: flex; flex-direction: column; gap: 1rem; }

.step-card {
  display: flex;
  gap: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.step-thumb img {
  width: 220px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
}
.no-shot {
  width: 220px;
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.step-body h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.step-body p { margin: 0 0 0.5rem; font-size: 0.9rem; }

.voiceover {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.9rem;
  border-left: 3px solid var(--accent);
  background: #f8fafc;
  border-radius: 0 6px 6px 0;
  font-style: italic;
}

.annotate-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}
.annotate-link:hover { text-decoration: underline; }

/* --- document-embed: screenshots in het gegenereerde document ----------------- */

.sop-content img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.5rem 0 1rem;
  display: block;
}

/* --- regenerate + template-keuze ------------------------------------------------ */

.regen-form { display: flex; align-items: center; gap: 0.5rem; }
.template-select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--card);
  max-width: 220px;
}
.template-select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* --- templates-pagina -------------------------------------------------------------- */

.row-actions { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
.form textarea {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  resize: vertical;
}
.form textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* --- annotatie-editor ----------------------------------------------------------------- */

.annotate-card { padding: 1rem; }
.annotate-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.tool-group { display: flex; gap: 0.35rem; align-items: center; }
.tool-group-right { margin-left: auto; }
.tool-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.35rem 0.7rem;
}
.tool-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }
.annotate-canvas-wrap { overflow: auto; }
#annotateCanvas {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: default;
}
.annotate-help { margin: 0.75rem 0 0; font-size: 0.85rem; }

/* --- responsief ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .workspace-layout { grid-template-columns: 1fr; }
  .ws-sidebar { position: static; max-height: none; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 1rem; }
  .topnav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .topnav-user { margin-left: auto; }
  .step-card { flex-direction: column; }
  .step-thumb img, .no-shot { width: 100%; }
  .share-form { right: auto; left: 0; }
}
