*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0b0f19;
  color: #d1d5db;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-size: 20px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
img { display: block; max-width: 100%; }
svg { display: block; }
.hidden { display: none !important; }
[x-cloak] { display: none !important; }

:root {
  --bg-main: #0f172a;
  --bg-panel: #1e293b;
  --bg-input: #334155;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-success: #10b981;
  --color-success-hover: #059669;
  --color-danger: #ef4444;
  --color-danger-hover: #dc2626;
  --color-purple: #8b5cf6;
  --color-purple-hover: #7c3aed;
  --radius: 6px;
  --radius-lg: 10px;
  --header-h: 52px;
  --sidebar-w: 300px;
  --toolbar-h: 52px;
  /* legacy aliases for header / other pages */
  --bg-base: #0f172a;
  --bg-surface: #1e293b;
  --bg-elevated: #334155;
  --bg-hover: #334155;
  --border: #334155;
  --border-light: #475569;
  --text-heading: #f8fafc;
  --text-body: #cbd5e1;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-subtle: rgba(59,130,246,0.15);
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
}

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

/* ── Header ── */
#app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
  user-select: none;
}
#header-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  gap: 8px;
}

#header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  flex-shrink: 0;
}
#header-brand-icon {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: logoPulse 3s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(59,130,246,0.3);
}
@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(59,130,246,0.3); }
  50% { box-shadow: 0 0 20px rgba(59,130,246,0.5), 0 0 40px rgba(139,92,246,0.2); }
}
#header-brand-name {
  color: var(--text-heading);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
  white-space: nowrap;
  background: linear-gradient(135deg, #f9fafb, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ── Header Tabs ── */
#header-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 8px;
  flex-shrink: 0;
}
.header-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.header-tab:hover {
  color: var(--text-heading);
  background: var(--bg-hover);
}
.header-tab.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

#header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  flex-shrink: 0;
}
#header-nav .nav-arrow {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
}
#header-nav .nav-arrow:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-heading); transform: scale(1.05); }
#header-nav .nav-arrow:disabled { opacity: 0.25; cursor: not-allowed; }
.nav-counter {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  width: 56px;
  text-align: center;
  font-family: monospace;
}

#header-context {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
#header-context-form { display: flex; align-items: center; gap: 4px; }
.context-input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-body);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  outline: none;
  width: 100px;
  transition: all 0.15s;
}
.context-input:hover { border-color: var(--border-light); }
.context-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-subtle); }
.context-input::placeholder { color: var(--text-faint); }

.header-select {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-body);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  max-width: 130px;
  transition: all 0.15s;
}
.header-select:hover { border-color: var(--border-light); }
.header-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-subtle); }

.btn-context {
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: white;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-context:hover { background: var(--accent-hover); box-shadow: 0 0 8px rgba(59,130,246,0.3); }

.btn-upload-label {
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all 0.15s;
  cursor: pointer;
}
.btn-upload-label:hover { background: var(--bg-hover); color: var(--text-heading); }

#header-context-badge {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-base);
  white-space: nowrap;
}
@media (min-width: 1200px) { #header-context-badge { display: flex; } }
#header-context-badge .env-label { color: var(--accent); font-weight: 600; }
#header-context-badge .road-label { color: var(--text-heading); font-weight: 500; }
#header-context-badge .sep { color: var(--border-light); }

.icon-sm { width: 18px; height: 18px; }
.icon-xs { width: 14px; height: 14px; }
.icon-xl { width: 40px; height: 40px; color: var(--text-faint); margin-bottom: 4px; }

/* ── Main Layout ── */
#app-main {
  display: flex;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}
#sidebar-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#sidebar-header h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  margin: 0;
}
.badge {
  background-color: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
#sidebar-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.1);
}
#sidebar-search {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.85rem;
  width: 100%;
}
#sidebar-search::placeholder { color: var(--text-faint); }
#entries-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.entry-item {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  background: rgba(255,255,255,0.02);
  align-items: center;
}
.entry-item:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--border-color);
}
.entry-item.active {
  background: rgba(59,130,246,0.1);
  border-color: rgba(59,130,246,0.3);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.1);
}
.entry-index {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.entry-item.active .entry-index {
  background: rgba(59,130,246,0.2);
  color: var(--accent);
  border-color: rgba(59,130,246,0.3);
}
.entry-thumb {
  width: 52px;
  height: 38px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #000;
  border: 1px solid rgba(255,255,255,0.06);
}
.entry-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.entry-item:hover .entry-thumb img,
.entry-item.active .entry-thumb img { opacity: 1; }
.entry-info { flex: 1; min-width: 0; }
.entry-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-item.active .entry-title { color: var(--accent); }
.entry-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-sub .tag {
  display: inline-block;
  background: rgba(0,0,0,0.25);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 9px;
  margin-right: 3px;
  color: var(--text-faint);
}
.entry-sub .tag.accent { color: var(--amber); border-color: rgba(245,158,11,0.2); }
.entry-item.snapshot .entry-title { color: var(--accent); }
.entry-item.dragging { opacity: 0.4; }
.entry-item.drag-over { border-top: 2px solid var(--accent); }
.entry-del {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-faint);
  opacity: 0;
  transition: all 0.12s;
}
.entry-item:hover .entry-del { opacity: 0.5; }
.entry-del:hover { opacity: 1 !important; background: rgba(239,68,68,0.15); color: var(--red); }

/* ── Sidebar Form (entry details) ── */
#sidebar-form {
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}
#sidebar-form-header {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.15);
}
#sidebar-form-body {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  overflow-y: auto;
  max-height: 420px;
}
.sf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.sf-field.full-width {
  grid-column: 1 / -1;
}
.sf-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.sf-field input,
.sf-field textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-body);
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
  transition: all 0.1s;
}
.sf-field input:focus,
.sf-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-subtle);
}
.sf-field input.sf-readonly {
  background: rgba(0,0,0,0.2);
  cursor: default;
  color: var(--text-faint);
  font-size: 11px;
}
.sf-field textarea {
  resize: vertical;
  min-height: 44px;
  max-height: 80px;
}
#sidebar-form-status {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  min-height: 18px;
}
#sidebar-form-actions {
  display: flex;
  justify-content: center;
  padding: 2px 0;
}
#sidebar-form-actions .panel-btn {
  font-size: 11px;
  padding: 5px 12px;
}
#btn-del-entry-sidebar {
  font-size: 10px;
  padding: 2px 6px;
  color: var(--red);
}
#json-panel-header .panel-btn {
  font-size: 10px;
  padding: 3px 8px;
}
.full-width {
  grid-column: 1 / -1;
}

/* ── Workspace ── */
#workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  flex: 1;
}
#canvas-panel {
  flex: 1;
  min-height: 0;
}

.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  /* overflow: hidden; */
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.2);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}
.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.panel-dot.green { background-color: var(--color-success); }
.panel-dot.blue { background-color: var(--color-primary); }
.panel-dot.purple { background-color: var(--color-purple); }

.panel-select, .bottom-select {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}
.panel-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.panel-select:hover, .bottom-select:hover { border-color: var(--text-muted); }
.panel-select:focus, .bottom-select:focus { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }

.panel-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.panel-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.panel-btn:active {
  transform: translateY(0);
}
.panel-btn.emerald {
  background: linear-gradient(135deg, #10b981, #059669);
}
.panel-btn.emerald:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}
.panel-btn.purple {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}
.panel-btn.purple:hover {
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}
.panel-btn.blue {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}
.panel-btn.blue:hover {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.panel-btn.green {
  background: linear-gradient(135deg, #10b981, #059669);
}
.panel-btn.green:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}
.panel-btn.ghost {
  background: transparent;
  color: var(--text-muted);
}
.panel-btn.ghost:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-heading);
  box-shadow: none;
}
.panel-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}
.panel-btn:hover::after {
  width: 300%;
  height: 300%;
}

/* Button loading state */
.panel-btn.loading,
.toolbar-btn.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}
.panel-btn.loading::before,
.toolbar-btn.loading::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

#canvas-container {
  flex: 1;
  position: relative;
  background-color: #020617;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

#main-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#canvas-container.crosshair { cursor: crosshair; }

/* ── Frame Form ── */
#frame-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  flex-shrink: 0;
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
#frame-form-header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
#frame-form-body {
  padding: 8px 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px 8px;
  max-height: 220px;
  overflow-y: auto;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.field.full {
  grid-column: 1 / -1;
}
.field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.field input,
.field select,
.field textarea {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-body);
  border-radius: 3px;
  padding: 5px 8px;
  font-size: 13px;
  outline: none;
  transition: all 0.1s;
}
.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--border-light); }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-subtle); }
.field textarea { resize: vertical; min-height: 28px; max-height: 60px; }

/* ── Bottom Toolbar ── */
#bottom-toolbar {
  flex-direction: row;
  align-items: center;
  padding: 8px 16px;
  gap: 8px;
  flex-wrap: wrap;
}

.tool-group, .action-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}
.tool-btn:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}
.tool-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
.toolbar-btn:active {
  transform: translateY(0);
}
.toolbar-btn.primary {
  background: var(--color-primary);
  color: #fff;
}
.toolbar-btn.primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.toolbar-btn.danger {
  color: var(--color-danger);
}
.toolbar-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}
/* Toolbar button ripple */
.toolbar-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}
.toolbar-btn:hover::after {
  width: 300%;
  height: 300%;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
  margin: 0 4px;
}

/* ── Figure Combobox ── */
.figure-combobox {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.figure-dropdown {
  position: absolute;
  bottom: 105%;
  left: 0;
  right: 0;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
.figure-dropdown.open {
  display: block;
}
.figure-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 12px;
  color: var(--text-body);
}
.figure-dropdown-item:hover,
.figure-dropdown-item.highlighted {
  background: var(--accent-subtle);
  color: var(--text-heading);
}
.figure-dropdown-item .fig-thumb {
  width: 36px;
  height: 28px;
  object-fit: contain;
  border-radius: 3px;
  background: #000;
  flex-shrink: 0;
}
.figure-dropdown-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

.toolbar-badge {
  padding: 7px 16px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.12s;
  border: 1px solid transparent;
}
.toolbar-badge.amber { background: rgba(245,158,11,0.15); color: var(--amber); border-color: rgba(245,158,11,0.2); }
.toolbar-badge.amber:hover { background: rgba(245,158,11,0.2); }
.toolbar-badge.green { background: rgba(16,185,129,0.15); color: var(--green); border-color: rgba(16,185,129,0.2); }
.toolbar-badge.green:hover { background: rgba(16,185,129,0.2); }

.placeholder-lg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-align: center;
  pointer-events: none;
}
.placeholder-lg span { font-size: 0.95rem; font-weight: 500; }
.placeholder-lg .text-xs { font-size: 0.75rem; color: var(--text-faint); }

/* ── Video Modal ── */
#video-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
}
#video-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11,15,25,0.85);
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
#video-modal-content {
  position: relative;
  width: min(90vw, 960px);
  height: min(85vh, 640px);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
#video-modal-header {
  height: 44px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
}
#video-modal-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ── Overlays ── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,15,25,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.15s ease;
}
#loading-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: modalIn 0.2s ease;
}
#loading-box span { color: var(--text-heading); font-size: 13px; font-weight: 600; }
.spin-icon { width: 28px; height: 28px; color: var(--accent); animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 300px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastSlide 0.25s ease forwards;
}
.toast.info { border-left: 3px solid var(--accent); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast .toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast.info .toast-icon { color: var(--accent); }
.toast.success .toast-icon { color: var(--green); }
.toast.error .toast-icon { color: var(--red); }
.toast .toast-msg { color: var(--text-heading); font-size: 12px; font-weight: 500; }
.toast.out { opacity: 0; transform: translateX(80px); transition: all 0.2s; }
@keyframes toastSlide {
  from { transform: translateX(80px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Shortcuts ── */
#shortcuts-modal {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  right: 12px;
  z-index: 45;
}
#shortcuts-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 320px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: fadeUp 0.15s ease;
}
#shortcuts-header {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}
#shortcuts-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.shortcut-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 6px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-heading);
}
.shortcut-row span { color: var(--text-body); }

/* ── Alpine transitions ── */
.fade-up-enter-active, .fade-up-leave-active { transition: all 0.2s ease; }
.fade-up-enter-from, .fade-up-leave-to { opacity: 0; transform: translateY(8px); }

.slide-in-right-enter-from { transform: translateX(100%); }
.slide-in-right-enter-active { transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.slide-in-right-enter-to { transform: translateX(0); }
.slide-out-right-leave-from { transform: translateX(0); }
.slide-out-right-leave-active { transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.slide-out-right-leave-to { transform: translateX(100%); }

.slide-in-left-enter-from { transform: translateX(-100%); }
.slide-in-left-enter-active { transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
.slide-in-left-enter-to { transform: translateX(0); }
.slide-out-left-leave-from { transform: translateX(0); }
.slide-out-left-leave-active { transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.slide-out-left-leave-to { transform: translateX(-100%); }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── JSON Editor Panel (right slide-out) ── */
#json-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  bottom: 0;
  width: 420px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 25;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
#json-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}
#json-panel:not(.hidden) {
  transform: translateX(0);
}
#json-panel-header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.15);
  flex-shrink: 0;
}
#json-panel-status {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  min-height: 22px;
  flex-shrink: 0;
}
#json-panel-status.success { color: var(--color-success); }
#json-panel-status.error { color: var(--color-danger); }
#json-editor {
  flex: 1;
  width: 100%;
  background: var(--bg-base);
  color: var(--text-body);
  border: none;
  padding: 12px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: none;
  outline: none;
  tab-size: 2;
}
#json-editor:focus {
  box-shadow: inset 0 0 0 1px var(--accent);
}