/* ═══════════════════════════════════════════════════════════════════════════
   Obsidian Enterprise — CMS Design System
   Fonts: Syne (display) · DM Sans (body) · JetBrains Mono (mono)
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0b0b0e;
  --surf-1:      #111115;   /* sidebar */
  --surf-2:      #18181d;   /* cards, panels */
  --surf-3:      #222228;   /* elevated / inputs */
  --surf-4:      #2c2c35;   /* hover */
  --border:      #2a2a32;
  --border-hi:   #3d3d4a;

  --text:        #e8e8f0;
  --text-2:      #a0a0b8;
  --muted:       #6b6b80;

  --blue:        #4f8eff;   /* images */
  --green:       #2dd472;   /* sounds */
  --amber:       #f09420;   /* movies */
  --violet:      #ae7aff;   /* meshes */
  --red:         #f05050;   /* danger */

  --accent:      var(--blue);
  --accent-light: rgba(79,142,255,.12);
  --success:     var(--green);
  --danger:      var(--red);
  --surface:     var(--surf-2);

  --radius:      8px;
  --radius-sm:   5px;
  --sidebar-w:   216px;
  --topbar-h:    52px;
  --trans:       150ms ease;
}

/* ── Light theme overrides ──────────────────────────────────────────────── */
html.light {
  --bg:          #eeeef3;
  --surf-1:      #e5e5ec;
  --surf-2:      #f2f2f7;
  --surf-3:      #ffffff;
  --surf-4:      #d8d8e2;
  --border:      #d0d0da;
  --border-hi:   #b8b8c6;

  --text:        #18181f;
  --text-2:      #48485e;
  --muted:       #8282a0;

  --accent-light: rgba(79,142,255,.10);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Suppress editor.css body max-width */
body { max-width: none; }

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

input, select, button, textarea { font: inherit; }

input, select, textarea {
  background: var(--surf-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  outline: none;
  transition: border-color var(--trans), box-shadow var(--trans);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,255,.18);
}
input::placeholder { color: var(--muted); }
input:disabled, select:disabled { opacity: 0.45; cursor: default; }

button {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surf-3);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: background var(--trans), border-color var(--trans), opacity var(--trans);
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--surf-4); border-color: var(--border-hi); }
button:active:not(:disabled) { opacity: 0.82; }
button:disabled { opacity: 0.38; cursor: default; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled) { filter: brightness(1.12); }

button.danger {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 30%, transparent);
  background: color-mix(in srgb, var(--red) 8%, transparent);
}
button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 15%, transparent); }

/* ── Shell layout ───────────────────────────────────────────────────────── */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surf-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar {
  transition: width 200ms ease, min-width 200ms ease;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.brand-text { flex: 1; min-width: 0; }

.sidebar-toggle {
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  padding: 3px 4px;
  line-height: 0;
  margin-top: 1px;
  transition: color var(--trans), background var(--trans);
}
.sidebar-toggle:hover { color: var(--text); background: var(--surf-3); }
.sidebar-toggle svg { transition: transform 200ms ease; display: block; }

/* ── Collapsed sidebar ──────────────────────────────────────────────────── */
html.sidebar-collapsed .sidebar { width: 48px; min-width: 48px; }
html.sidebar-collapsed .sidebar-brand { padding: 13px 8px; justify-content: center; }
html.sidebar-collapsed .brand-text { display: none; }
html.sidebar-collapsed .sidebar-section-label { display: none; }
html.sidebar-collapsed .nav-label { display: none; }
html.sidebar-collapsed .nav-item { padding: 9px; justify-content: center; border-left-color: transparent; }
html.sidebar-collapsed .nav-item.active {
  border-left-color: transparent;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
html.sidebar-collapsed .nav-icon { opacity: 1; }
html.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-brand .brand-label {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-brand .brand-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-top: 2px;
}

.sidebar-section {
  padding: 10px 0;
}
.sidebar-section-label {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
  cursor: pointer;
  border-top: none;
  border-right: none;
  border-bottom: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surf-2); color: var(--text); text-decoration: none; }
.nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(79,142,255,.1) 0%, transparent 100%);
  border-left-color: var(--accent);
}
.nav-item .nav-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.nav-icon {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--trans);
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Sidebar footer / theme toggle ─────────────────────────────────────── */
.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  margin-top: auto;
}

.theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--trans), color var(--trans);
  text-align: left;
}
.theme-toggle:hover { background: var(--surf-2); color: var(--text); }
.theme-toggle svg { flex-shrink: 0; }

/* Icon visibility per mode */
html:not(.light) .theme-toggle .icon-sun { display: none; }
html.light .theme-toggle .icon-moon { display: none; }

/* Label text via pseudo-element */
.theme-label::after { content: 'Light mode'; }
html.light .theme-label::after { content: 'Dark mode'; }

/* Collapsed sidebar — center icon, hide label */
html.sidebar-collapsed .sidebar-footer { padding: 8px 4px; }
html.sidebar-collapsed .theme-toggle { justify-content: center; padding: 7px; }
html.sidebar-collapsed .theme-label { display: none; }

/* ── Fullscreen toggle ──────────────────────────────────────────────────── */
.fullscreen-toggle {
  display: none; /* desktop: hidden */
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
}
.fullscreen-toggle:hover { background: var(--surf-2); color: var(--text); }
html.is-fullscreen .fullscreen-toggle .icon-expand   { display: none; }
html:not(.is-fullscreen) .fullscreen-toggle .icon-compress { display: none; }

/* ── Main content area ──────────────────────────────────────────────────── */
.page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Brand mark (inline in page header) ────────────────────────────────── */
.brand-mark {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  flex-shrink: 0;
}

/* ── Top bar (page header) ──────────────────────────────────────────────── */
.page-header {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  padding: 0 20px;
  background: var(--surf-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.page-header h1 {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.page-header .sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}
.page-header .hdr-meta {
  font-size: 12px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}
.page-header .spacer { flex: 1; }

/* ── Header tabs (injected by sidebar.js — its own bar above the page header) */
.header-tabs {
  height: 42px;
  min-height: 42px;
  padding: 0 16px;
  background: var(--surf-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.header-tabs::-webkit-scrollbar { display: none; }
.header-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--trans), background var(--trans), border-color var(--trans);
}
.header-tab:hover { color: var(--text); background: var(--surf-3); text-decoration: none; }
.header-tab:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.header-tab.active {
  color: var(--text);
  background: var(--surf-3);
  border-color: var(--border-hi);
}
.header-tab .tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.header-tab.active .tab-dot { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent); }

.page-header input {
  width: 160px;
  font-size: 13px;
  padding: 5px 9px;
}

.page-header button {
  font-size: 12px;
  padding: 5px 12px;
}

/* ── Page body (scrollable) ─────────────────────────────────────────────── */
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Status toast ───────────────────────────────────────────────────────── */
.status-bar {
  padding: 6px 20px;
  background: var(--surf-1);
  border-top: 1px solid var(--border);
  font-size: 12px;
  min-height: 30px;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}
#status {
  /* Legacy support — same as .status-bar content */
}

/* ── Section / Card ─────────────────────────────────────────────────────── */
.section {
  background: var(--surf-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.section-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-header h2 {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
}
.section-header .section-count {
  font-size: 11px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-left: auto;
}
.section-body { padding: 16px; }

/* ── Dashboard grid ─────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.dashboard-card {
  background: var(--surf-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--trans), box-shadow var(--trans), transform var(--trans);
}
.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-accent, var(--accent));
  opacity: 0;
  transition: opacity var(--trans);
}
.dashboard-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 4px 24px rgba(0,0,0,.3), 0 0 0 1px var(--card-accent, var(--accent)) inset;
  transform: translateY(-1px);
  text-decoration: none;
  color: var(--text);
}
.dashboard-card:hover::before { opacity: 1; }

.dashboard-card .card-icon {
  font-size: 24px;
  line-height: 1;
  display: block;
}
.dashboard-card .card-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.dashboard-card .card-count {
  font-size: 12px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}
.dashboard-card .card-arrow {
  margin-top: auto;
  font-size: 18px;
  color: var(--card-accent, var(--accent));
  align-self: flex-end;
  opacity: 0;
  transition: opacity var(--trans), transform var(--trans);
}
.dashboard-card:hover .card-arrow { opacity: 1; transform: translateX(3px); }

/* ── Upload area ────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
  color: var(--text-2);
  position: relative;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--text);
}
.upload-area p { margin: 0; font-size: 13px; }
.upload-area p + p { margin-top: 6px; font-size: 11px; color: var(--muted); }
.upload-area strong { color: var(--accent); }

#fileInput { display: none; }

/* Upload progress */
.upload-progress-wrap {
  display: none;
  margin-top: 12px;
}
.upload-progress-wrap progress {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  border: none;
  background: var(--surf-3);
  overflow: hidden;
}
.upload-progress-wrap progress::-webkit-progress-bar { background: var(--surf-3); }
.upload-progress-wrap progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
.upload-progress-wrap progress::-moz-progress-bar { background: var(--accent); }
#progressLabel { font-size: 11px; color: var(--muted); margin-top: 4px; font-family: 'JetBrains Mono', monospace; }

/* ── Images grid ────────────────────────────────────────────────────────── */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}

.asset-card {
  background: var(--surf-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--trans), box-shadow var(--trans);
}
.asset-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.asset-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: var(--surf-3);
  display: block;
}

.asset-card .card-body {
  padding: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surf-2);
}

.asset-card .filename {
  font-size: 11px;
  word-break: break-all;
  color: var(--text-2);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.3;
}

.asset-card .card-actions {
  display: flex;
  gap: 4px;
  margin-top: auto;
}

.asset-card button {
  flex: 1;
  font-size: 11px;
  padding: 4px 6px;
}

/* ── List rows (sounds / movies / meshes) ───────────────────────────────── */
.movies-list {
  display: grid;
  gap: 6px;
}

.movie-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surf-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: border-color var(--trans), background var(--trans);
}
.movie-row:hover {
  border-color: var(--border-hi);
  background: var(--surf-3);
}

.movie-icon {
  font-size: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

.movie-info { flex: 1; min-width: 0; }

.movie-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.movie-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

.movie-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.movie-actions button {
  font-size: 12px;
  padding: 5px 10px;
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
dialog {
  background: var(--surf-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px var(--border-hi);
  max-width: 560px;
  width: 95vw;
}
dialog::backdrop {
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surf-1);
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h2 {
  margin: 0;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--trans);
}
.modal-close:hover { color: var(--text); background: none; }

.modal-body {
  padding: 18px;
  max-height: 65vh;
  overflow-y: auto;
}
.modal-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.modal-body th {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.modal-body td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.modal-body td:first-child {
  font-weight: 700;
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}
.modal-body td:nth-child(2) {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-2);
  word-break: break-all;
}
.modal-body td:last-child { color: var(--text-2); }
.modal-body h3 {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 8px;
}
.modal-body pre {
  background: var(--surf-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-2);
  overflow-x: auto;
  margin: 0;
}
.modal-body code { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--amber); }
small code { font-size: 10px; }

/* Image full-preview modal */
#imgPreviewModal {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  width: max-content;
  height: max-content;
}

.img-preview-close {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, .6);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  z-index: 1;
}
.img-preview-close:hover { background: rgba(0, 0, 0, .85); }

.img-preview-img {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* Preview modal */
#previewModal {
  max-width: 800px;
  width: 95vw;
}
#previewModal video {
  width: 100%;
  display: block;
  border-radius: 0 0 var(--radius) var(--radius);
  background: #000;
}
#previewModal audio {
  width: 100%;
  padding: 16px;
  box-sizing: border-box;
  display: block;
}

/* ── Asset picker (in scenario page) ────────────────────────────────────── */
#pickerModal {
  max-width: 720px;
  width: 95vw;
}

.picker-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 18px 0;
}
.picker-tabs button {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.picker-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.picker-body {
  padding: 14px 18px 18px;
  max-height: 55vh;
  overflow-y: auto;
}

.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.pick-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--trans), box-shadow var(--trans);
  background: var(--surf-3);
}
.pick-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(79,142,255,.25);
}
.pick-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  background: var(--surf-3);
  display: block;
}
.pick-card .pick-name {
  padding: 4px 6px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'JetBrains Mono', monospace;
}

.pick-list { display: grid; gap: 5px; }
.pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
  background: var(--surf-2);
}
.pick-row:hover { border-color: var(--accent); background: var(--surf-3); }
.pick-row .pick-icon { font-size: 18px; flex-shrink: 0; }
.pick-row .pick-info { flex: 1; min-width: 0; }
.pick-row .pick-row-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick-row .pick-row-meta {
  font-size: 10px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Accent shorthands for type-coded nav ───────────────────────────────── */
.accent-blue   { --card-accent: var(--blue);   }
.accent-green  { --card-accent: var(--green);  }
.accent-amber  { --card-accent: var(--amber);  }
.accent-violet { --card-accent: var(--violet); }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }

/* ── Info / Ticker editor ───────────────────────────────────────────────── */
.edit-fields-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--surf-1);
  border-left: 1px solid var(--border);
}

.edit-fields-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.editor-list {
  list-style: none;
  margin: 0;
  padding: 5px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.editor-list li { cursor: grab; }
.editor-list li.dragging { opacity: 0.4; }
.editor-list li.drag-over > button {
  border-color: var(--accent);
  background: var(--accent-light);
}

.editor-list button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surf-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background var(--trans), border-color var(--trans), color var(--trans);
}
.editor-list button:hover { background: var(--surf-3); border-color: var(--border-hi); color: var(--text); }
.editor-list button.active {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
}
.editor-list button.unpublished {
  color: var(--muted);
  border-left-color: var(--border);
  opacity: 0.6;
}

.editor-list .empty {
  padding: 16px 10px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* field-row: label + input used by editor.js */
.field-row {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.field-row label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.field-row input,
.field-row select {
  width: 100%;
}
.field-row input[type="checkbox"] {
  width: auto;
  height: 16px;
  width: 16px;
  accent-color: var(--accent);
}

.image-thumbnail {
  max-width: 240px;
  max-height: 140px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surf-3);
  padding: 4px;
  margin-top: 6px;
}

#editFields.empty {
  color: var(--muted);
  font-size: 12px;
  padding: 32px 0;
  text-align: center;
}

/* ── Preview cards (inside left panel) ─────────────────────────────────── */
.panel-view-toggle {
  display: flex;
  gap: 2px;
  background: var(--surf-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  flex-shrink: 0;
}
.view-btn {
  padding: 3px 5px;
  border: none;
  background: transparent;
  border-radius: 3px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.view-btn:hover:not(:disabled) { background: transparent; border-color: transparent; color: var(--text-2); }
.view-btn.active { background: var(--surf-4); color: var(--text); }

.panel-subhdr {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-subhdr button {
  font-size: 10px;
  padding: 2px 8px;
  width: 100%;
}

.preview-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-card {
  background: var(--surf-2);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans), box-shadow var(--trans);
}
.preview-card:hover {
  border-color: var(--border-hi);
  background: var(--surf-3);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.preview-card.active {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surf-2));
}
.preview-card.unpublished { opacity: 0.5; }

.preview-card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surf-3);
}
.preview-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-card-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.preview-card-title {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-card-text {
  font-size: 11px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.45;
}
.preview-card-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surf-3);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  margin-top: 3px;
  align-self: flex-start;
}

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

/* ── Scenario Editor ────────────────────────────────────────────────────── */
.editor-body { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* Scenarios list panel */
.scenarios-panel {
  width: 220px; min-width: 220px;
  background: var(--surf-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0;
}
.panel-hdr {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.panel-hdr .panel-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); flex: 1;
}
.panel-hdr button { font-size: 11px; padding: 3px 10px; }

.new-scenario-form {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: none; flex-direction: column; gap: 6px;
  background: var(--surf-2); flex-shrink: 0;
}
.new-scenario-form input { font-size: 12px; padding: 5px 8px; }
.new-scenario-form .form-btns { display: flex; gap: 5px; }
.new-scenario-form .form-btns button { flex: 1; font-size: 11px; padding: 4px 8px; }

.scenarios-list {
  flex: 1; overflow-y: auto;
  padding: 5px;
  display: flex; flex-direction: column; gap: 1px;
}
.list-empty {
  padding: 20px 10px; font-size: 11px; color: var(--muted);
  text-align: center; line-height: 1.6;
}
.scenario-item {
  width: 100%; text-align: left;
  background: transparent; border: none;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background var(--trans), border-color var(--trans);
  display: flex; align-items: center; gap: 4px;
}
.scenario-item:hover { background: var(--surf-2); }
.scenario-item.active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-left-color: var(--accent);
}
.si-body {
  flex: 1; min-width: 0; padding: 8px 6px 8px 10px;
  cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.si-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-meta { font-size: 10px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.si-actions {
  display: none; flex-shrink: 0; gap: 2px; padding-right: 6px;
}
.scenario-item:hover .si-actions { display: flex; }
.si-actions button { font-size: 10px; padding: 2px 6px; }

/* Timeline side */
.timeline-side {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
  padding: 10px 12px; gap: 8px;
}
.scenario-controls {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.scenario-controls label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.scenario-controls input { width: 200px; font-size: 13px; padding: 5px 9px; }
.scenario-controls button { font-size: 12px; padding: 5px 12px; }
.scenario-controls .ctrl-sep { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; margin: 0 2px; }
.zoom-wrap { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.zoom-wrap span { font-size: 11px; color: var(--muted); min-width: 52px; text-align: center; font-family: 'JetBrains Mono', monospace; }
.zoom-wrap button { padding: 4px 10px; font-size: 14px; line-height: 1; }

.scenario-name-bar {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  min-height: 22px;
}

.timeline-hint { font-size: 11px; color: var(--muted); flex-shrink: 0; }

.timeline-frame {
  display: flex; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  background: var(--surf-2); flex: 1; min-height: 0;
}
.label-col {
  width: 90px; min-width: 90px;
  border-right: 1px solid var(--border);
  background: var(--surf-1);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.label-ruler { height: 30px; border-bottom: 1px solid var(--border); }
.label-track {
  height: 56px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 10px;
  font-size: 11px; font-weight: 700; gap: 6px; color: var(--text-2);
}
.label-track:last-child { border-bottom: none; }
.label-track .track-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.timeline-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; cursor: default; user-select: none; }
.timeline-content { display: flex; flex-direction: column; }

.ruler { height: 30px; position: relative; border-bottom: 1px solid var(--border); background: var(--surf-1); flex-shrink: 0; }
.ruler-tick { position: absolute; top: 0; height: 100%; display: flex; flex-direction: column; align-items: flex-start; }
.tick-line { width: 1px; background: var(--border); flex: 0 0 6px; }
.ruler-tick.major .tick-line { flex: 0 0 14px; background: var(--border-hi); }
.tick-label { font-size: 9px; color: var(--muted); white-space: nowrap; padding-left: 3px; margin-top: 1px; font-family: 'JetBrains Mono', monospace; }

.track { height: 56px; position: relative; border-bottom: 1px solid var(--border); background: var(--surf-2); }
.track:last-child { border-bottom: none; }
.track[data-type="image"] { background: color-mix(in srgb, var(--blue) 4%, var(--surf-2)); }
.track[data-type="sound"] { background: color-mix(in srgb, var(--green) 4%, var(--surf-2)); }
.track[data-type="video"] { background: color-mix(in srgb, var(--amber) 4%, var(--surf-2)); }

.event-block {
  position: absolute; top: 8px; height: 40px;
  border-radius: var(--radius-sm); cursor: grab;
  display: flex; align-items: center; overflow: hidden;
  color: #fff; font-size: 10px; font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); min-width: 18px;
}
.event-block:active { cursor: grabbing; }
.event-block.selected { box-shadow: 0 0 0 2px var(--surf-2), 0 0 0 4px #fff; z-index: 2; }
.event-block.dragging { opacity: 0.85; box-shadow: 0 6px 20px rgba(0,0,0,.5); z-index: 10; cursor: grabbing; }
.block-label { flex: 1; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.block-resize {
  width: 9px; min-width: 9px; height: 100%; cursor: ew-resize;
  background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.block-resize::after { content: '⋮'; font-size: 9px; color: rgba(255,255,255,.6); }
.event-block.open-ended .block-resize {
  background: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,.2) 2px, rgba(255,255,255,.2) 4px);
}

/* Properties panel */
.props-panel {
  width: 272px; min-width: 272px;
  background: var(--surf-1); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0;
}
.props-panel > h2 {
  margin: 0; padding: 12px 16px;
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border); color: var(--muted); flex-shrink: 0;
}
.props-body { padding: 14px 16px; display: grid; gap: 12px; }
.props-empty { padding: 32px 16px; color: var(--muted); font-size: 12px; text-align: center; line-height: 1.7; }
.field { display: grid; gap: 4px; }
.field label { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.field input, .field select { padding: 7px 10px; font-size: 13px; width: 100%; }
.asset-row { display: flex; gap: 6px; }
.asset-row input { flex: 1; min-width: 0; background: var(--surf-3); color: var(--text-2); }
.asset-row button { padding: 6px 10px; font-size: 11px; white-space: nowrap; }
.props-actions { padding: 12px 16px; border-top: 1px solid var(--border); display: grid; gap: 6px; flex-shrink: 0; margin-top: auto; }
.props-actions .btn-row { display: flex; gap: 6px; }
.props-actions button { flex: 1; padding: 8px 10px; font-size: 12px; }
.add-btns { display: grid; gap: 6px; padding: 14px 16px; }
.add-btns p { margin: 0 0 8px; font-size: 11px; color: var(--muted); }
.add-btn {
  width: 100%; padding: 9px 12px; border: 1px solid;
  border-radius: var(--radius-sm); background: transparent;
  cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
  text-align: left; display: flex; align-items: center; gap: 8px;
}
.add-btn:hover { filter: brightness(1.1); }

/* Picker modal header/close (scenario asset picker) */
.picker-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: var(--surf-1); border-radius: var(--radius) var(--radius) 0 0;
}
.picker-header h2 { margin: 0; font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; }
.picker-close { background: none; border: none; font-size: 18px; color: var(--muted); cursor: pointer; padding: 0 4px; line-height: 1; }
.picker-close:hover { color: var(--text); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

/* Stack the two editor panels vertically on narrow screens */
@media (max-width: 700px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; }

  .sidebar {
    width: 100% !important;
    min-width: 0 !important;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
    overflow-x: auto;
  }
  .sidebar-brand { border-bottom: none; padding: 10px 14px; flex: 0 0 auto; }
  .sidebar-footer { border-top: none; padding: 0; margin-left: auto; flex-shrink: 0; display: flex; align-items: center; }
  .theme-label { display: none; }
  .brand-text { display: none; }
  .sidebar-toggle { display: none; }
  .fullscreen-toggle { display: flex; }
  .sidebar-section { padding: 4px 6px; display: flex; flex-wrap: nowrap; gap: 0; flex-direction: row; flex: 1; }
  .sidebar-section-label { display: none; }
  .nav-label { display: none; }
  .nav-item { width: auto; padding: 8px 10px; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-left-color: transparent; border-bottom-color: var(--accent); }

  .page-main { min-height: 0; }

  .page-header { display: none; }

  /* Stack editor panels */
  .editor-body {
    flex-direction: column;
    overflow: visible;
    height: auto;
  }
  .scenarios-panel {
    width: 100% !important;
    min-width: 0 !important;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 240px;
  }
  .edit-fields-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    min-height: 300px;
  }
  /* Stack scenario editor's three columns */
  .timeline-side { min-width: 0; }
  .props-panel {
    width: 100% !important;
    min-width: 0 !important;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
