:root {
  --shadow-1:0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
  --shadow-2:0 10px 30px rgba(0,0,0,.5);
  --r-sm:6px; --r:8px; --r-lg:12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-0); color: var(--text); font-size: 13px;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
[data-lucide] { width: 16px; height: 16px; stroke-width: 1.75; }

/* Auth */
.auth-screen { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(ellipse at top, var(--bg-1) 0%, var(--bg-0) 60%); }
.auth-card { width: 380px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 32px; box-shadow: var(--shadow-2); }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand [data-lucide] { width: 36px; height: 36px; color: var(--accent); }
.brand-name { font-weight: 700; letter-spacing: 2px; font-size: 18px; }
.brand-sub { font-size: 11px; color: var(--text-mute); letter-spacing: 3px; text-transform: uppercase; }
.auth-hint { padding: 10px 12px; margin-bottom: 16px; background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r); font-size: 11.5px; color: var(--text-mute); line-height: 1.5; }
.auth-form label { display: block; margin-bottom: 14px; font-size: 12px; color: var(--text-mute); }
.auth-form input { display: block; width: 100%; padding: 10px 12px; margin-top: 6px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text); font-size: 13px; }
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-error { color: var(--bad); min-height: 18px; font-size: 12px; margin-bottom: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--bg-3); color: var(--text); cursor: pointer; font-weight: 500;
  transition: background .12s, border-color .12s; }
.btn:hover { background: var(--bg-4); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-b); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: var(--bad); border-color: #a02323; color: #fff; }
.btn-danger:hover { background: #c02929; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-mute); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-lg { padding: 10px 16px; font-size: 13px; width: 100%; justify-content: center; }
.btn-compact { padding: 5px 10px; font-size: 11px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: transparent; border: 1px solid transparent;
  border-radius: var(--r); color: var(--text-mute); cursor: pointer;
  transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn.sm { width: 24px; height: 24px; }

/* Save state button */
.save-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; background: transparent;
  border: 1px solid transparent; border-radius: var(--r);
  cursor: pointer; color: var(--text-mute);
  transition: background .12s, color .12s, border-color .12s;
  margin-left: 2px;
}
.save-btn:hover { background: var(--bg-2); }
.save-btn.saved  { color: var(--good); }
.save-btn.dirty  { color: var(--warn); }
.save-btn.saving { color: var(--info); }
.save-btn.saving [data-lucide] { animation: spin 1s linear infinite; }

/* Team badge */
.team-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 999px; font-size: 10.5px; font-weight: 600;
  color: var(--text-mute); text-transform: uppercase; letter-spacing: 1px;
}
.team-badge [data-lucide] { width: 11px; height: 11px; }
.team-badge.personal { border-style: dashed; }

/* Header */
.app { display: flex; flex-direction: column; height: 100vh; }
.app-header { display: flex; align-items: center; justify-content: space-between;
  height: 50px; padding: 0 12px; background: var(--bg-1); border-bottom: 1px solid var(--line);
  gap: 12px; flex-shrink: 0; }
.hdr-left, .hdr-right, .hdr-center { display: flex; align-items: center; gap: 8px; }
.hdr-left { flex: 1; min-width: 0; }
.hdr-right { justify-content: flex-end; }
.divider { width: 1px; height: 24px; background: var(--line); }
.brand-mini { display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; letter-spacing: 1.5px; font-size: 12px; }
.brand-mini [data-lucide] { color: var(--accent); width: 18px; height: 18px; }
.project-title { background: transparent; border: 1px solid transparent; color: var(--text);
  font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: var(--r);
  min-width: 200px; max-width: 400px; }
.project-title:hover { background: var(--bg-2); }
.project-title:focus { outline: none; border-color: var(--line-2); background: var(--bg-2); }
.project-title:disabled { color: var(--text-mute); cursor: not-allowed; }

.view-switch { display: flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; }
.vs-btn { display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; background: transparent; border: 0; border-radius: var(--r-sm);
  color: var(--text-mute); cursor: pointer; font-weight: 500; font-size: 12px; }
.vs-btn.active { background: var(--bg-4); color: var(--text); }

.user-menu { position: relative; }
.dropdown { position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-2); min-width: 220px; padding: 6px; z-index: 100; }
.dd-header { padding: 8px 10px; font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dd-item { display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; background: transparent; border: 0; border-radius: var(--r-sm);
  color: var(--text); cursor: pointer; text-align: left; font-size: 12px;
  text-decoration: none; }
.dd-item:hover { background: var(--bg-3); }
.dd-sep { height: 1px; background: var(--line); margin: 6px 0; }
.dd-label { padding: 4px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-dim); font-weight: 600; }
.dd-select { margin: 4px 8px 4px; width: calc(100% - 16px);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 6px 8px; border-radius: var(--r-sm); font-size: 12px; cursor: pointer; }
.dd-select:focus { outline: none; border-color: var(--accent); }

/* Body */
.app-body { display: flex; flex: 1; min-height: 0; }

/* Sidebar */
.sidebar { width: 240px; background: var(--bg-1); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .2s ease; overflow: hidden; }
.sidebar.collapsed { width: 0; border: none; }
.side-section { padding: 10px 8px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  max-height: 40%; overflow-y: auto; }
.side-panel { padding: 10px 8px; overflow-y: auto; }
.side-panel.flex-1 { flex: 1; }
.side-header { display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px; margin-bottom: 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-mute); font-weight: 600; }
.project-list, .scene-list, .cast-list, .location-list { display: flex; flex-direction: column; gap: 2px; }

.side-team-group { margin-bottom: 8px; }
.side-team-header {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; margin-top: 4px;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--text-dim); font-weight: 700;
}
.side-team-header [data-lucide] { width: 11px; height: 11px; }

.side-item { display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: var(--r-sm); cursor: pointer;
  color: var(--text); font-size: 12px; user-select: none; min-width: 0; }
.side-item:hover { background: var(--bg-3); }
.side-item.active { background: var(--bg-3); color: var(--accent); }
.side-item [data-lucide] { color: var(--text-mute); width: 14px; height: 14px; flex-shrink: 0; }
.side-item.active [data-lucide] { color: var(--accent); }
.side-item-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.side-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item-sub { font-size: 10px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item-meta { color: var(--text-dim); font-size: 10px; }
.side-thumb { width: 22px; height: 22px; border-radius: var(--r-sm); background: var(--bg-0);
  object-fit: cover; flex-shrink: 0; border: 1px solid var(--line); }
.side-thumb-empty { width: 22px; height: 22px; border-radius: var(--r-sm); background: var(--bg-2);
  border: 1px solid var(--line); display: grid; place-items: center; color: var(--text-dim); flex-shrink: 0; }
.side-thumb-empty [data-lucide] { width: 11px; height: 11px; }

/* Sidebar tabs */
.side-tabs { display: flex; padding: 6px 8px; gap: 4px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.side-tab { flex: 1; padding: 6px 4px; background: transparent; border: 0; border-radius: var(--r-sm);
  color: var(--text-mute); cursor: pointer; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.side-tab [data-lucide] { width: 12px; height: 12px; }
.side-tab:hover { background: var(--bg-2); color: var(--text); }
.side-tab.active { background: var(--bg-3); color: var(--accent); }

/* Canvas */
.canvas { flex: 1; overflow: auto; padding: 20px; min-width: 0; }

/* Board view */
.scene-block { margin-bottom: 28px; }
.scene-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.scene-bar h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text);
  background: transparent; border: 0; padding: 4px 6px; border-radius: var(--r-sm); }
.scene-bar h2:hover { background: var(--bg-2); }
.scene-bar h2:focus { outline: none; background: var(--bg-2); }
.scene-bar .scene-count { font-size: 11px; color: var(--text-dim); }
.scene-bar .spacer { flex: 1; }

.panel-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.panel-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; }
.panel-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.panel-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Unified drag/drop state across all views */
.panel-card.dragging, .tl-card.dragging, .ol-panel.dragging { opacity: .4; }
.panel-card.drag-over { border-color: var(--accent); }
.tl-card.drag-over, .ol-panel.drag-over { outline: 2px solid var(--accent); outline-offset: -2px; }

.panel-img { position: relative; background: var(--bg-1); aspect-ratio: 3/2;
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.panel-img img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; user-select: none; }
.panel-img-empty { color: var(--text-dim); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.panel-img-empty [data-lucide] { width: 32px; height: 32px; opacity: .4; }

.panel-status { position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.65); backdrop-filter: blur(6px);
  padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase; color: #fff;
  display: inline-flex; align-items: center; gap: 4px; }
.panel-status.queued, .panel-status.processing { color: var(--info); }
.panel-status.error   { color: var(--bad); }
.panel-status.ready   { display: none; }
.panel-status .spinner { width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel-num { position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.65); backdrop-filter: blur(6px);
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace; color: #fff; }

.panel-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.panel-title { font-weight: 600; font-size: 12px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-title:empty::before { content: 'Untitled panel'; color: var(--text-dim); font-weight: 400; }
.panel-notes { font-size: 11px; color: var(--text-mute);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap; word-break: break-word; }
.panel-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 999px; font-size: 10px; color: var(--text-mute); }
.chip [data-lucide] { width: 11px; height: 11px; }
.chip.chip-cast     { background: var(--chip-cast-bg); border-color: var(--chip-cast-border); color: var(--chip-cast-text); }
.chip.chip-location { background: var(--chip-loc-bg);  border-color: var(--chip-loc-border);  color: var(--chip-loc-text); }

.panel-add { border: 1.5px dashed var(--line-2); background: transparent;
  display: flex; align-items: center; justify-content: center;
  min-height: 220px; aspect-ratio: 3/2; cursor: pointer; border-radius: var(--r-lg);
  color: var(--text-mute); transition: background .15s, border-color .15s, color .15s; }
.panel-add:hover,
.panel-add.drag-over { background: var(--bg-2); border-color: var(--accent); color: var(--accent); }
.panel-add [data-lucide] { width: 32px; height: 32px; }
.panel-add > * { pointer-events: none; }

/* Context menu */
.context-menu { position: fixed; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-2); padding: 6px; min-width: 180px; z-index: 1000; }
.cm-item { display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; background: transparent; border: 0; border-radius: var(--r-sm);
  color: var(--text); cursor: pointer; text-align: left; font-size: 12px; }
.cm-item:hover { background: var(--bg-3); }
.cm-item.danger { color: var(--bad); }
.cm-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* Inspector */
.inspector { width: 360px; background: var(--bg-1); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0; }
.insp-head { display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 13px; flex-shrink: 0; }
#insp-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-head-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.insp-head-actions .btn { padding: 5px 10px; font-size: 11px; }
.insp-head-actions:empty { display: none; }
.insp-body { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 16px; flex: 1; }

.insp-preview { aspect-ratio: 3/2; border-radius: var(--r); overflow: hidden;
  background: var(--bg-0); display: flex; align-items: center; justify-content: center;
  position: relative; border: 1px solid var(--line); cursor: zoom-in; }
.insp-preview img { width: 100%; height: 100%; object-fit: contain; }
.insp-preview-empty { color: var(--text-dim); font-size: 12px; padding: 20px; text-align: center; cursor: default; }
.insp-preview .overlay { position: absolute; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text); font-size: 12px; }
.insp-preview .overlay .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; }
.insp-preview.portrait { aspect-ratio: 2/3; }

.readonly-banner {
  padding: 8px 10px; background: var(--bg-2); border: 1px dashed var(--line-2);
  border-radius: var(--r); font-size: 11px; color: var(--text-mute); line-height: 1.4;
}
.readonly-banner strong { color: var(--text); }

/* Fields + tooltip help icon */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-mute); font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; color: var(--text-dim); cursor: help;
  border-radius: 50%;
}
.help [data-lucide] { width: 12px; height: 12px; }
.help:hover { color: var(--accent); }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field textarea, .field select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text); padding: 8px 10px; font-size: 12px; width: 100%;
}
.field textarea { resize: vertical; min-height: 60px; font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field input:disabled, .field textarea:disabled, .field select:disabled { opacity: .55; cursor: not-allowed; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seed-row { display: flex; gap: 6px; }
.seed-row input { flex: 1; font-family: 'JetBrains Mono', monospace; }

.insp-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-mute); font-weight: 600; margin-top: 6px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 4px;
}
.insp-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.insp-actions .btn { flex: 1; justify-content: center; }

/* Chip-set (cast picker) */
.chip-set { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-btn {
  padding: 4px 10px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--text-mute); cursor: pointer; font-size: 11px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s;
}
.chip-btn:hover { border-color: var(--line-2); color: var(--text); }
.chip-btn.active { background: var(--chip-active-bg); border-color: var(--chip-active-border); color: var(--chip-active-text); font-weight: 600; }
.chip-btn:disabled { opacity: .6; cursor: not-allowed; }
.chip-btn img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; }
.chip-empty { padding: 6px 10px; font-size: 11px; color: var(--text-dim); font-style: italic; }

/* Character builder dropdowns */
.char-builder-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
  padding: 10px; background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: 8px;
}
.char-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.char-field label {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-mute); font-weight: 600;
}
.char-field select, .char-field input {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--text); padding: 5px 7px; font-size: 11px; width: 100%;
  cursor: pointer;
}
.char-field select:focus, .char-field input:focus { outline: none; border-color: var(--accent); }
.char-builder-hint {
  font-size: 10.5px; color: var(--text-dim); margin: 0 0 6px; font-style: italic;
}

/* Timeline */
.timeline { display: flex; gap: 10px; padding: 20px; overflow-x: auto; align-items: stretch; min-height: 100%; }
.tl-scene { flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 10px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r-lg); }
.tl-scene-hdr { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 4px; }
.tl-scene-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-mute);
  font-weight: 600; padding: 2px 6px; border-radius: var(--r-sm); cursor: text; min-width: 40px; }
.tl-scene-title[contenteditable="true"]:hover,
.tl-scene-title[contenteditable="true"]:focus { background: var(--bg-2); outline: none; color: var(--text); }
.tl-scene-dur { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.tl-row { display: flex; gap: 6px; }
.tl-card { width: 180px; flex-shrink: 0; display: flex; flex-direction: column; cursor: pointer; }
.tl-card .panel-img { aspect-ratio: 3/2; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.tl-card-duration { text-align: center; font-size: 10px; color: var(--text-mute);
  font-family: 'JetBrains Mono', monospace; margin-top: 4px; }
.tl-card-title {
  font-size: 11px; font-weight: 600; color: var(--text);
  margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-card-chips {
  display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px;
}
.tl-card-chips .chip {
  font-size: 9.5px; padding: 1px 6px;
}
.tl-card-chips .chip [data-lucide] { width: 9px; height: 9px; }

.tl-add { width: 140px; flex-shrink: 0; border: 1.5px dashed var(--line-2);
  background: transparent; cursor: pointer; color: var(--text-mute);
  border-radius: var(--r); display: flex; align-items: center; justify-content: center;
  min-height: 120px; transition: background .15s, border-color .15s, color .15s; }
.tl-add:hover, .tl-add.drag-over { background: var(--bg-2); border-color: var(--accent); color: var(--accent); }
.tl-add [data-lucide] { width: 28px; height: 28px; }
.tl-add > * { pointer-events: none; }

/* Outline */
.outline { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.ol-scene-hdr { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.ol-scene-hdr h2 { margin: 0; font-size: 15px; padding: 2px 6px; border-radius: var(--r-sm); cursor: text; }
.ol-scene-hdr h2[contenteditable="true"]:hover,
.ol-scene-hdr h2[contenteditable="true"]:focus { background: var(--bg-2); outline: none; }
.ol-scene-meta { font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.ol-scene h2 { margin: 0 0 10px; font-size: 15px; }
.ol-panel { display: grid; grid-template-columns: 120px 1fr; gap: 14px;
  padding: 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: 10px; cursor: pointer; }
.ol-panel:hover { border-color: var(--line-2); }
.ol-panel img { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: var(--r-sm); cursor: zoom-in; }
.ol-panel .no-img { aspect-ratio: 3/2; background: var(--bg-1); border-radius: var(--r-sm); display: grid; place-items: center; color: var(--text-dim); }
.ol-info h3 { margin: 0 0 6px; font-size: 13px; }
.ol-info .prompt { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-mute); margin: 4px 0; white-space: pre-wrap; }
.ol-info .dialogue-block { margin: 8px 0; }
.ol-info .d-line { margin: 0 0 8px; }
.ol-info .d-line:last-child { margin-bottom: 0; }
.ol-info .d-speaker {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; font-size: 10px; color: var(--text);
  margin: 0 0 2px; padding-left: 12px;
}
.ol-info .d-text {
  font-size: 12px; font-style: italic; color: var(--text);
  margin: 0 0 0 8px;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--line-2);
}

.ol-panel-add { border: 1.5px dashed var(--line-2); background: transparent;
  padding: 18px; cursor: pointer; color: var(--text-mute); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 10px; font-weight: 500; font-size: 12px;
  transition: background .15s, border-color .15s, color .15s; }
.ol-panel-add:hover, .ol-panel-add.drag-over { background: var(--bg-2); border-color: var(--accent); color: var(--accent); }
.ol-panel-add [data-lucide] { width: 18px; height: 18px; }
.ol-panel-add > * { pointer-events: none; }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 500; }
.modal-backdrop.stacked { z-index: 900; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  width: 520px; max-width: 92vw; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-2); }
.modal.narrow { width: 420px; }
.modal.wide { width: 820px; }
.modal.xwide { width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.modal-msg { font-size: 13px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }

.modal-grid { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.modal-grid .modal-preview { aspect-ratio: 2/3; background: var(--bg-0); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; position: relative; display: grid; place-items: center; cursor: zoom-in; }
.modal-grid.loc .modal-preview { aspect-ratio: 3/2; }
.modal-grid .modal-preview img { width: 100%; height: 100%; object-fit: cover; }
.modal-grid .modal-preview-empty { color: var(--text-dim); font-size: 11px; text-align: center; padding: 10px; cursor: default; }
.modal-grid .modal-preview .overlay { position: absolute; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--text); font-size: 12px; }
.modal-grid .modal-preview .overlay .spinner {
  width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}

.modal-fields { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Admin / team management */
.m-tabs { display: flex; gap: 4px; margin-bottom: 14px; background: var(--bg-1);
  border-radius: var(--r); padding: 4px; }
.m-tab { flex: 1; padding: 8px; background: transparent; border: 0; border-radius: var(--r-sm);
  color: var(--text-mute); cursor: pointer; font-weight: 500; font-size: 12px; }
.m-tab.active { background: var(--bg-3); color: var(--text); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.admin-table th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-mute); font-weight: 600; }
.admin-table tr:hover td { background: var(--bg-1); }
.admin-table .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.admin-table .actions .btn { white-space: nowrap; }
.admin-table .pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 999px; font-size: 10px; color: var(--text-mute);
}
.admin-table .pill.admin-pill { color: var(--accent); border-color: var(--accent); }
.admin-table .badge { font-size: 9.5px; padding: 1px 6px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text-mute);
  margin-right: 3px; display: inline-block; }

.admin-section { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.admin-section h4 { margin: 0; font-size: 13px; }

.member-row { display: grid; grid-template-columns: 1fr 150px 100px auto; gap: 10px;
  align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-name { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.member-name [data-lucide] { width: 12px; height: 12px; color: var(--text-mute); }
.member-role-select { background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); border-radius: var(--r-sm); padding: 4px 6px; font-size: 12px; }
.member-role-select:focus { outline: none; border-color: var(--accent); }
.role-desc { font-size: 10px; color: var(--text-dim); font-style: italic; line-height: 1.3; }

.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px;
  padding: 10px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--r); }
.perm-grid label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; cursor: pointer; }
.perm-grid input[type=checkbox] { accent-color: var(--accent); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.lightbox-inner { position: relative; max-width: 95vw; max-height: 95vh; }
.lightbox-inner img {
  max-width: 95vw; max-height: 95vh; display: block;
  border-radius: 4px; box-shadow: 0 25px 80px rgba(0,0,0,.7);
}
.lightbox-close {
  position: absolute; top: -44px; right: 0;
  background: transparent; border: 0; color: #fff;
  font-size: 32px; line-height: 1; cursor: pointer; padding: 4px 10px;
}
.lightbox-close:hover { color: var(--accent); }
.lightbox-caption {
  position: absolute; bottom: -34px; left: 0; right: 0;
  text-align: center; color: #ccc; font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

/* Slideshow */
.slideshow {
  position: fixed; inset: 0; z-index: 4000;
  background: #000; color: #fff;
  display: flex; flex-direction: column;
  animation: fade-in .2s ease;
  user-select: none;
}
.ss-stage {
  flex: 1; position: relative;
  display: flex; flex-direction: row;
  padding: 60px 32px 24px;
  gap: 20px;
  min-height: 0;
  overflow: hidden;
}
.ss-scene-title {
  position: absolute; top: 20px; left: 0; right: 0;
  text-align: center; font-size: 12px; text-transform: uppercase;
  letter-spacing: 5px; color: rgba(255,255,255,.55); font-weight: 600;
  padding: 0 24px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ss-image {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: opacity .2s;
}
.ss-image img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  box-shadow: 0 25px 80px rgba(0,0,0,.8);
  border: 1px solid rgba(255,255,255,.08);
}
.ss-no {
  color: rgba(255,255,255,.4); font-size: 13px;
  padding: 40px 60px; border: 1px dashed rgba(255,255,255,.2);
  letter-spacing: 2px; text-transform: uppercase;
}
.ss-dialogue {
  flex: 0 0 360px;
  overflow-y: auto;
  padding: 20px 22px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  display: flex; flex-direction: column; gap: 14px;
  align-self: stretch;
  pointer-events: auto;
}
.ss-dialogue.empty {
  display: flex;
  align-items: center; justify-content: center;
  color: rgba(255,255,255,.35);
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  font-style: italic;
}
.ss-line {
  display: block;
  animation: ss-fade-in .3s ease;
}
@keyframes ss-fade-in { from { opacity: 0; transform: translateY(6px); } }
.ss-speaker {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
  color: rgba(255,255,255,.7); font-weight: 700; margin-bottom: 4px;
}
.ss-text {
  background: rgba(0,0,0,.5);
  padding: 8px 12px; border-radius: 4px;
  font-size: 14px; line-height: 1.55;
  color: #f5f5f5;
  border-left: 2px solid var(--accent);
  white-space: pre-wrap; word-break: break-word;
}
.ss-controls {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  background: rgba(0,0,0,.92);
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.ss-controls button {
  background: transparent; border: 0; color: #fff;
  width: 36px; height: 36px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background .12s;
}
.ss-controls button:hover { background: rgba(255,255,255,.12); }
.ss-controls button [data-lucide] { width: 18px; height: 18px; }
.ss-progress {
  flex: 1; height: 4px;
  background: rgba(255,255,255,.15); border-radius: 2px;
  overflow: hidden;
}
.ss-fill {
  height: 100%; background: var(--accent);
  width: 0%; transition: width .12s linear;
}
.ss-duration {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.ss-duration:focus { outline: none; border-color: var(--accent); }
.ss-duration option { background: #111; color: #fff; }
.ss-counter {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: rgba(255,255,255,.7); min-width: 60px; text-align: center;
}
.ss-close-btn {
  width: 36px; height: 36px;
}

/* Toasts */
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 14px; font-size: 12px; min-width: 260px; box-shadow: var(--shadow-2);
  display: flex; align-items: center; gap: 10px; animation: slide-in .25s ease; }
.toast.err { border-color: var(--bad); }
.toast.ok  { border-color: var(--good); }
.toast [data-lucide] { flex-shrink: 0; }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } }

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

/* Print fallback */
@media print {
  .app-header, .sidebar, .inspector, .toasts { display: none !important; }
  .canvas { padding: 0; overflow: visible; }
  .panel-card { break-inside: avoid; border-color: #999; background: #fff; color: #000; }
  .panel-card .panel-body { background: #fff; }
  body, .app, .app-body { background: #fff; overflow: visible; height: auto; }
}

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