*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101228;
  color: #e8eaf0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top nav ─────────────────────────────────────────────── */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(16,18,40,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topnav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #ffb900;
  font-size: 1rem;
  letter-spacing: -0.3px;
  text-decoration: none;
}
.topnav .brand-mark {
  display: inline-block;
  width: 29px;
  height: 29px;
  vertical-align: middle;
}
.topnav .nav-links { display: flex; align-items: center; gap: 6px; }
.topnav .nav-link {
  color: #c8cadc;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.topnav .nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.topnav .nav-link.active { background: rgba(91,106,240,0.15); color: #a5b0ff; }
.topnav .nav-user {
  font-size: 0.8rem;
  color: #8b8fa8;
  margin-right: 8px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Layout ──────────────────────────────────────────────── */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  width: 100%;
}
.page.full-bleed { padding: 0; }

header.page-header { text-align: center; margin-bottom: 40px; }
header.page-header h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.5px; color: #ffb900; }
header.page-header p  { margin-top: 8px; color: #8b8fa8; font-size: 0.95rem; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: linear-gradient(160deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 40%, rgba(30,28,60,0.7) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-color: rgba(255,255,255,0.03);
  border-radius: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.07);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  margin-bottom: 24px;
}
.card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; color: #ffb900; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 0;
  border: none;
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  font-weight: 300;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: 0.85; }
.btn-primary   { background: #33FFAC; color: #101228; }
.btn-secondary { background: #2a2d3d; color: #c8cadc; border: 1px solid #3d4060; }
.btn-pack      { background: #42D9E5; color: #101228; font-size: 0.8rem; padding: 10px 12px; flex: 1; display: flex; justify-content: center; align-items: center; }
.btn-success   { background: #22c55e; color: #101228; }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-ghost     { background: #2a2d3d; color: #c8cadc; }
.btn-row       { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Status pills ────────────────────────────────────────── */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pill-green  { background: #14532d; color: #4ade80; }
.pill-yellow { background: #422006; color: #fbbf24; }
.pill-red    { background: #450a0a; color: #f87171; }

/* ── Quota bar ───────────────────────────────────────────── */
.quota-wrap { margin-top: 8px; }
.quota-label { font-size: 0.8rem; color: #8b8fa8; margin-bottom: 6px; }
.quota-bar-bg { background: #2a2d3d; border-radius: 6px; height: 10px; overflow: hidden; }
.quota-bar-fill { height: 100%; border-radius: 6px; background: #5b6af0; transition: width 0.4s; }

/* ── Info rows ───────────────────────────────────────────── */
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #2a2d3d; font-size: 0.85rem; }
.info-row:last-child { border-bottom: none; }
.info-label { color: #8b8fa8; }
.info-value { color: #e8eaf0; font-family: monospace; word-break: break-all; max-width: 300px; text-align: right; }

/* ── Terms checkbox ──────────────────────────────────────── */
.tos-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.tos-row input { margin-top: 3px; accent-color: #5b6af0; }
.tos-row label { font-size: 0.85rem; color: #8b8fa8; line-height: 1.5; }
.tos-row a { color: #5b6af0; text-decoration: none; }
.tos-row a:hover { text-decoration: underline; }

/* ── Response box ────────────────────────────────────────── */
.response-box {
  margin-top: 16px;
  background: #0f1117;
  border: 1px solid #2a2d3d;
  border-radius: 8px;
  padding: 14px;
  font-family: monospace;
  font-size: 0.78rem;
  color: #8b8fa8;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
.response-box.visible { display: block; }
.response-box.ok  { border-color: #22c55e; color: #4ade80; }
.response-box.err { border-color: #ef4444; color: #f87171; }

/* ── Auth visibility ─────────────────────────────────────── */
.requires-auth  { display: none; }
.requires-guest { display: none; }
.auth-loading .requires-auth,
.auth-loading .requires-guest { display: none; }

body.guest  .requires-guest { display: block; }
body.authed .requires-auth  { display: block; }
body.guest  .requires-auth  { display: none; }
body.authed .requires-guest { display: none; }

/* Outranks the `.requires-guest { display: block }` rule above so the splash
   keeps its flex centering instead of collapsing to a left-aligned block. */
body.guest .landing-splash { display: flex; }

/* The [hidden] attribute must win over the `.requires-auth` display rule above
   (author-origin, so it beats the UA [hidden] rule). The router toggles these
   two views via `hidden`; use id+attr specificity so hiding actually applies. */
#slabs-picker[hidden] { display: none; }

/* ── Landing / canvas ────────────────────────────────────── */
.landing-splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
}
.landing-splash h1 {
  font-size: 2.4rem;
  font-weight: 700;
  color: #ffb900;
  letter-spacing: -1px;
  margin-bottom: 12px;
}
.landing-splash p {
  color: #8b8fa8;
  font-size: 1rem;
  max-width: 520px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

#canvas-root {
  flex: 1;
  min-height: 0;
  display: flex;
}
#canvas-root[hidden] { display: none; }
.canvas-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0b0d1f;
}
.canvas-header {
  height: 44px;
  line-height: 44px;
  padding: 0 24px;
  background: #7536D8;
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.2px;
  text-align: center;
  border-bottom: 1px solid rgba(0,0,0,0.25);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  z-index: 5;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.canvas-flow-wrap {
  flex: 1;
  position: relative;
}
.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b8fa8;
  font-size: 0.9rem;
  pointer-events: none;
  background: rgba(11,13,31,0.35);
}
.canvas-overlay-error { color: #f87171; }

/* ── Prompts node (custom ReactFlow node) ─────────────────── */
.prompts-node {
  background: linear-gradient(160deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 40%, rgba(30,28,60,0.85) 100%);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.07);
  min-width: 460px;
  max-width: 640px;
  color: #e8eaf0;
}
.prompts-node-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 10px 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #ffb900;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.prompts-node.is-collapsed .prompts-node-title {
  border-bottom: none;
}
.prompts-empty {
  padding: 16px;
  color: #8b8fa8;
  font-size: 0.9rem;
}
.prompts-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
.prompts-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8b8fa8;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
}
.prompts-table tbody td {
  padding: 10px 14px;
  vertical-align: top;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.85rem;
  line-height: 1.5;
}
.prompts-table tbody tr:last-child td {
  border-bottom: none;
}
.prompts-property {
  color: #ffb900;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
  width: 1%;
}
.prompts-prompt {
  color: #e8eaf0;
}
.prompts-model {
  color: #42D9E5;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
  width: 1%;
}

/* ── Record node (one per synthesized record) ─────────────── */
.record-node {
  background: linear-gradient(160deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.015) 40%, rgba(30,28,60,0.85) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  min-width: 320px;
  max-width: 460px;
  color: #e8eaf0;
}
.record-node-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 14px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #42D9E5;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.record-node.is-collapsed .record-node-title {
  border-bottom: none;
}

.node-collapse-btn {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.65;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.85rem;
  line-height: 1;
  border-radius: 3px;
  transition: opacity 0.15s, background 0.15s;
}
.node-collapse-btn:hover,
.node-collapse-btn:focus-visible {
  opacity: 1;
  background: rgba(255,255,255,0.08);
  outline: none;
}
.record-node-empty {
  padding: 14px;
  color: #8b8fa8;
  font-size: 0.85rem;
}
.record-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}
.record-table tbody td {
  padding: 8px 14px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.82rem;
  line-height: 1.45;
}
.record-table tbody tr:last-child td {
  border-bottom: none;
}
.record-table tbody tr.record-media-row td {
  vertical-align: top;
}
.record-property {
  color: #8b8fa8;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.75rem;
  white-space: nowrap;
  width: 1%;
}
.record-value {
  color: #e8eaf0;
  word-break: break-word;
}
.record-value-input {
  display: block;
  flex: 1 1 120px;
  width: auto;
  min-width: 0;
  box-sizing: border-box;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.45;
  user-select: text;
  cursor: text;
}
.record-value-editor {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}
.record-value-swatch {
  appearance: none;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
  cursor: pointer;
}
.record-value-swatch:hover,
.record-value-swatch:focus-visible {
  border-color: #fff;
  outline: 1px solid rgba(255,255,255,0.45);
}
.record-color-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.record-color-name {
  flex: 0 0 auto;
  min-width: 70px;
  padding-left: 7px;
  border-left: 1px solid rgba(255,255,255,0.08);
  color: #8b8fa8;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
  text-transform: capitalize;
}
.record-value-input:hover,
.record-value-input:focus {
  border-color: rgba(91,106,240,0.6);
  background: rgba(16,18,40,0.7);
  outline: none;
}
.record-value-input.is-saving {
  opacity: 0.6;
}
.record-value-input.has-save-error {
  border-color: #f87171;
}
.record-value-input.is-hex {
  flex: 0 0 10ch;
  width: 10ch;
}

/* ── Artifact set picker (authed landing) ─────────────────── */
.hidden { display: none !important; }

#artifact-picker.artifact-picker {
  position: fixed;
  top: 51px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 48px 32px 64px;
  background: #0b0d1f;
}
.artifact-picker-header {
  max-width: 1080px;
  margin: 0 auto 32px;
}
.artifact-picker-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffb900;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.artifact-picker-header p {
  color: #8b8fa8;
  font-size: 0.95rem;
}

.artifact-grid {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.artifact-card {
  background: linear-gradient(160deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 40%, rgba(30,28,60,0.7) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.07);
  padding: 24px;
  text-align: left;
  color: #e8eaf0;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
}
.artifact-card-wrap {
  position: relative;
  display: block;
}
.artifact-card-wrap > .artifact-card {
  width: 100%;
  height: 100%;
}
.artifact-card-wrap > .artifact-card .artifact-card-title {
  padding-right: 32px;
}
/* Lift the whole card + its dots button together on wrap hover. */
.artifact-card-wrap:hover > .artifact-card,
.artifact-card-wrap:hover > .artifact-menu-btn {
  transform: translateY(-2px);
}
.artifact-card-wrap:hover > .artifact-card {
  border-color: rgba(91,106,240,0.5);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}
.artifact-menu-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #8b8fa8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.artifact-menu-btn:hover,
.artifact-menu-btn:focus-visible {
  background: rgba(255,255,255,0.08);
  color: #e8eaf0;
  outline: none;
}

.artifact-card-menu {
  position: absolute;
  z-index: 100;
  min-width: 140px;
  background: #1a1d2e;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.artifact-card-menu button {
  background: transparent;
  border: none;
  color: #e8eaf0;
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
}
.artifact-card-menu button:hover,
.artifact-card-menu button:focus-visible {
  background: rgba(91,106,240,0.2);
  outline: none;
}
.artifact-card-menu button.menu-danger { color: #f87171; }
.artifact-card-menu button.menu-danger:hover,
.artifact-card-menu button.menu-danger:focus-visible {
  background: rgba(239,68,68,0.18);
}
.confirm-dialog .confirm-text {
  font-size: 0.9rem;
  color: #c8cbe0;
  line-height: 1.5;
  margin: 0;
}
.confirm-dialog .confirm-text strong { color: #e8eaf0; }

.rename-dialog {
  margin: auto;
  border: 1px solid rgba(255,255,255,0.1);
  background: #1a1d2e;
  color: #e8eaf0;
  padding: 0;
  min-width: 360px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.rename-dialog::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.rename-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rename-form h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffb900;
  margin: 0 0 4px;
}
.rename-form label {
  font-size: 0.8rem;
  color: #8b8fa8;
}
.rename-form input {
  background: #101228;
  border: 1px solid rgba(255,255,255,0.1);
  color: #e8eaf0;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}
.rename-form input:focus {
  outline: none;
  border-color: #5b6af0;
}
.dialog-error {
  color: #f87171;
  font-size: 0.85rem;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.artifact-card:hover {
  transform: translateY(-2px);
  border-color: rgba(91,106,240,0.5);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}
.artifact-card:focus-visible {
  outline: 2px solid #5b6af0;
  outline-offset: 2px;
}

.artifact-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #ffb900;
  line-height: 1.3;
}
.artifact-card-id {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 0.72rem;
  color: #8b8fa8;
  word-break: break-all;
}
.artifact-card-meta {
  font-size: 0.85rem;
  color: #c8cadc;
  margin-top: auto;
}
.artifact-card-date {
  font-size: 0.75rem;
  color: #8b8fa8;
}

.artifact-card-new {
  background: transparent;
  border: 1px dashed rgba(51,255,172,0.35);
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #33FFAC;
}
.artifact-card-new:hover {
  border-color: rgba(51,255,172,0.7);
  background: rgba(51,255,172,0.04);
}
.artifact-card-new .artifact-card-title { color: #33FFAC; }
.artifact-card-new .artifact-card-meta  { color: #8b8fa8; }
.artifact-card-new-plus {
  font-size: 2.4rem;
  font-weight: 300;
  line-height: 1;
  color: #33FFAC;
}

.artifact-loading, .artifact-error {
  grid-column: 1 / -1;
  color: #8b8fa8;
  padding: 24px 0;
  font-size: 0.9rem;
}
.artifact-error { color: #f87171; }

/* Override ReactFlow controls colors for dark theme */
.react-flow__controls {
  background: #1a1d2e !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
}
.react-flow__controls button {
  background: #1a1d2e !important;
  color: #c8cadc !important;
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
}
.react-flow__controls button:hover { background: #2a2d3d !important; }
.react-flow__minimap {
  background: #0f1117 !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
}
.react-flow__attribution { background: transparent !important; }
.react-flow__attribution a { color: #3a3d52 !important; font-size: 0.7rem; }

/* Custom node styling */
.synth-node {
  background: linear-gradient(160deg, rgba(255,255,255,0.06) 0%, rgba(30,28,60,0.9) 100%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 12px 16px;
  min-width: 180px;
  color: #e8eaf0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.synth-node .synth-node-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #ffb900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.synth-node .synth-node-label { font-size: 0.9rem; color: #e8eaf0; }
.react-flow__node.selected .synth-node { border-color: #5b6af0; box-shadow: 0 0 0 2px rgba(91,106,240,0.35); }
.react-flow__handle { background: #5b6af0 !important; border: 2px solid #101228 !important; width: 10px !important; height: 10px !important; }

footer.page-footer { text-align: center; padding: 24px; font-size: 0.75rem; color: #3a3d52; }

/* ── Slabs gallery ─────────────────────────────────────────── */
#artifact-picker.slabs-view,
#slabs-picker.slabs-view {
  position: fixed;
  top: 51px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 48px 32px 64px;
  background: #0b0d1f;
}
.slabs-header {
  max-width: 1080px;
  margin: 0 auto 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.slabs-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffb900;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.slabs-header p { color: #8b8fa8; font-size: 0.95rem; }
.slabs-empty, .artifact-loading, .artifact-error {
  grid-column: 1 / -1;
  color: #8b8fa8;
  padding: 40px 0;
  text-align: center;
}
.artifact-error { color: #f87171; }
.slabs-empty code { color: #33FFAC; background: rgba(255,255,255,0.05); padding: 1px 6px; }

.slab-card { min-height: 200px; }
.slab-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-right: 28px; /* clear the absolute ⋯ menu button in the card corner */
}
.slab-status { text-transform: capitalize; flex-shrink: 0; }
.slab-thumbs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 4px 0;
}
.slab-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0b0d1f;
}
.slab-thumb-broken { visibility: hidden; }
.slab-thumbs-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  color: #6b6f88;
  font-size: 0.82rem;
  border: 1px dashed rgba(255,255,255,0.1);
}
.slab-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #8b8fa8;
  margin-top: auto;
}
.slab-card-date { color: #6b6f88; }
.slab-error {
  font-size: 0.75rem;
  color: #f87171;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Slab detail modal ─────────────────────────────────────── */
.slab-dialog {
  width: min(920px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.12);
  background: #14162c;
  color: #e8eaf0;
  padding: 0;
}
.slab-dialog::backdrop { background: rgba(6,7,18,0.72); }
.slab-dialog-head {
  position: sticky;
  top: 0;
  background: #14162c;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.slab-dialog-head h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.slab-dialog-sub { display: flex; align-items: center; gap: 10px; }
.slab-dialog-id { font-size: 0.72rem; color: #6b6f88; font-family: ui-monospace, monospace; }
.slab-dialog-body { padding: 20px 24px 28px; }
.slab-empty { color: #8b8fa8; padding: 24px 0; }

.synth-block {
  padding: 16px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.synth-block:last-child { border-bottom: none; }
.synth-index { font-size: 0.78rem; color: #ffb900; font-weight: 600; margin-bottom: 8px; }
.synth-fields { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.synth-field { display: flex; gap: 10px; font-size: 0.85rem; }
.synth-field-key { color: #8b8fa8; min-width: 110px; flex-shrink: 0; }
.synth-field-val { color: #e8eaf0; word-break: break-word; }
.synth-assets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.asset-image { margin: 0; }
.asset-image img {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.1);
  background: #0b0d1f;
  display: block;
}
.asset-image figcaption { font-size: 0.72rem; color: #6b6f88; margin-top: 4px; }
.asset-broken { display: none; }
.asset-file a { color: #42D9E5; font-size: 0.85rem; }
.asset-pending {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px dashed rgba(255,255,255,0.12);
  font-size: 0.8rem;
}
.asset-pending .asset-key { color: #8b8fa8; }

/* ── Canvas: header back-link + synth-node inline media ───── */
.canvas-header {
  display: flex;
  align-items: center;
  gap: 16px;
}
.canvas-back {
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.85;
  flex: 0 0 auto;
}
.canvas-back:hover { opacity: 1; text-decoration: underline; }
.canvas-header-label {
  flex: 1;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.canvas-undo-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  color: #e8eaf0;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.canvas-undo-btn:hover:not(:disabled),
.canvas-undo-btn:focus-visible {
  border-color: #5b6af0;
  background: rgba(91,106,240,0.18);
  outline: none;
}
.canvas-undo-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.synth-node-body { display: flex; flex-direction: column; }
.record-media-value { padding: 8px 14px !important; }
.synth-asset { margin: 0; }
.synth-asset-image a { display: block; }
.synth-asset-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  background: rgba(0,0,0,0.25);
}
.synth-asset-broken { display: none; }
.synth-asset-file a { color: #42D9E5; font-size: 0.85rem; }
.synth-asset-pending {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 6px;
  font-size: 0.8rem;
}
