/* ============================================
   31 de Diciembre - Adventure Design Toolbox
   Dark Mode Stylesheet
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary: #0d0d14;
  --bg-secondary: #13131f;
  --bg-sidebar: #111119;
  --bg-card: #1a1a28;
  --bg-card-hover: #22223a;
  --bg-input: #16162a;
  --bg-modal: #1e1e30;
  --bg-badge: #2a1a4a;

  --accent: #7c5cfc;
  --accent-hover: #9b82ff;
  --accent-glow: rgba(124, 92, 252, 0.25);
  --accent-subtle: rgba(124, 92, 252, 0.1);
  --danger: #fc5c7c;
  --danger-hover: #ff7a95;
  --success: #2cb67d;
  --warning: #f0c351;
  --info: #5ca8fc;

  --text-primary: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #55556a;
  --text-inverse: #0d0d14;

  --border: #2a2a3e;
  --border-light: #3a3a52;
  --border-focus: #7c5cfc;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(124, 92, 252, 0.15);

  --sidebar-width: 260px;
  --topbar-height: 56px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--accent-hover);
}

/* 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-light);
}

/* Selection */
::selection {
  background: var(--accent);
  color: white;
}

/* ---------- App Layout ---------- */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-project {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-project-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #c77dff);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-project-info {
  overflow: hidden;
}

.sidebar-project-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-project-type {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  user-select: none;
}

.nav-item:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent-hover);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-item-icon {
  opacity: 1;
}

.nav-item-badge {
  margin-left: auto;
  background: var(--bg-badge);
  color: var(--accent);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

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

/* ---------- Top Bar ---------- */
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 50;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.breadcrumb-item {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.breadcrumb-item:hover {
  color: var(--text-primary);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 600;
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-export {
  background: linear-gradient(135deg, var(--accent), #c77dff);
  color: white;
  font-weight: 600;
  padding: 8px 20px;
}
.btn-export:hover {
  box-shadow: 0 0 24px rgba(124, 92, 252, 0.4);
  transform: translateY(-1px);
}

/* ---------- Workspace ---------- */
.workspace {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.workspace-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.workspace-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ---------- Card Grid ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-thumb {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 28px;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-input);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.card-badge {
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.card:hover .card-actions {
  opacity: 1;
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 360px;
  margin-bottom: 20px;
}

/* ---------- Forms ---------- */
.form-container {
  max-width: 720px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-modal);
  color: var(--text-primary);
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 16px;
}
.form-row > .form-group {
  flex: 1;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-checkbox-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Dynamic Array (Exits, Actions, etc.) ---------- */
.dynamic-array {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dynamic-array-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.dynamic-array-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dynamic-array-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.dynamic-array-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px;
  line-height: 1;
  transition: color var(--transition-fast);
}
.dynamic-array-remove:hover {
  color: var(--danger);
}

.dynamic-array-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition-fast);
  background: transparent;
  font-family: inherit;
}
.dynamic-array-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 8px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition-fast);
  border: none;
  background: transparent;
  font-family: inherit;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  background: var(--accent);
  color: white;
}

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-event {
  position: relative;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.timeline-event:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -27px;
  top: 20px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-primary);
}

.timeline-event-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.timeline-event-trigger {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.timeline-event-trigger code {
  background: var(--bg-badge);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--warning);
}

.timeline-event-actions {
  font-size: 12px;
  color: var(--text-muted);
}

.timeline-event-actions span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 4px;
  margin: 2px 4px 2px 0;
}

/* ---------- Dialogue Nodes ---------- */
.dialogue-node {
  position: relative;
  margin-left: 0;
  margin-bottom: 4px;
}

.dialogue-node .dialogue-node {
  margin-left: 24px;
  margin-top: 8px;
}

.dialogue-node-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: all var(--transition-fast);
}

.dialogue-node-card:hover {
  border-color: var(--border-light);
}

.dialogue-node-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.dialogue-node-connector {
  position: absolute;
  left: 20px;
  bottom: -8px;
  width: 2px;
  height: 12px;
  background: var(--border);
}

.dialogue-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.dialogue-node-speaker {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-subtle);
  padding: 2px 8px;
  border-radius: 10px;
}

.dialogue-node-id {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.dialogue-node-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.dialogue-node-responses {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dialogue-response {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dialogue-response:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.dialogue-response-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

.dialogue-response-text {
  flex: 1;
}

.dialogue-response-condition {
  font-size: 10px;
  color: var(--warning);
  background: rgba(240, 195, 81, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ---------- Notes (Markdown) ---------- */
.notes-container {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  height: calc(100vh - var(--topbar-height) - 120px);
}

.notes-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.notes-editor textarea {
  flex: 1;
  background: var(--bg-input);
  border: none;
  color: var(--text-primary);
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  resize: none;
  outline: none;
}

.notes-divider {
  width: 1px;
  background: var(--border);
}

.notes-preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-card);
}

.notes-preview h1, .notes-preview h2, .notes-preview h3 {
  color: var(--text-primary);
  margin: 16px 0 8px;
}
.notes-preview h1 { font-size: 24px; }
.notes-preview h2 { font-size: 20px; }
.notes-preview h3 { font-size: 16px; }

.notes-preview p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.7;
}

.notes-preview ul, .notes-preview ol {
  color: var(--text-secondary);
  padding-left: 20px;
  margin-bottom: 12px;
}

.notes-preview code {
  background: var(--bg-badge);
  color: var(--warning);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.notes-preview pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.notes-preview pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

.notes-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.notes-preview strong {
  color: var(--text-primary);
}

/* ---------- Note Status Badges ---------- */
.note-status-nueva {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
}
.note-status-en_progreso {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}
.note-status-completada {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}

.card-badge.note-status-badge {
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
  user-select: none;
}
.card-badge.note-status-badge:hover {
  transform: scale(1.08);
  filter: brightness(1.15);
}

/* ---------- Markdown Toolbar ---------- */
.md-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
  flex-wrap: wrap;
}

.md-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary, #a0a0b8);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.md-btn:hover {
  background: var(--bg-card-hover, #252540);
  color: var(--text-primary, #e0e0f0);
  border-color: var(--border-light, #3a3a5c);
}

.md-btn:active {
  transform: scale(0.95);
}

.md-btn b, .md-btn i, .md-btn s {
  font-size: 13px;
}

.md-btn code {
  font-size: 11px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
}

.md-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border, #2a2a44);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Adjust textarea border-radius when toolbar is present */
.notes-editor .md-toolbar + textarea {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* Code block language label */
.code-block-lang {
  display: inline-block;
  padding: 2px 10px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  border-radius: 4px 4px 0 0;
  margin-bottom: -1px;
  position: relative;
  top: 1px;
}

.notes-preview pre:has(+ .code-block-lang),
.notes-preview .code-block-lang + pre {
  border-top-left-radius: 0;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color var(--transition-fast);
}
.modal-close:hover {
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 300ms ease, toastOut 300ms ease 2700ms forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.toast-success {
  background: var(--success);
  color: white;
}

.toast-error {
  background: var(--danger);
  color: white;
}

.toast-info {
  background: var(--info);
  color: white;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ---------- Loading ---------- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Detail View ---------- */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.detail-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  font-family: inherit;
}
.detail-back:hover {
  color: var(--text-primary);
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
}

.detail-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Auto-save indicator ---------- */
.autosave-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  white-space: nowrap;
  animation: autosave-pulse 1.5s ease-in-out infinite;
}

@keyframes autosave-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ---------- Flag Toggle ---------- */
.flag-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.flag-toggle:hover {
  border-color: var(--border-light);
}

.flag-switch {
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}

.flag-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  top: 2px;
  left: 2px;
  transition: all var(--transition-fast);
}

.flag-toggle.active .flag-switch {
  background: var(--success);
}

.flag-toggle.active .flag-switch::after {
  transform: translateX(16px);
  background: white;
}

.flag-name {
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.flag-state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.flag-state.true {
  background: rgba(44, 182, 125, 0.15);
  color: var(--success);
}

.flag-state.false {
  background: rgba(252, 92, 124, 0.15);
  color: var(--danger);
}

/* ---------- JSON Preview ---------- */
.json-preview {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  overflow: auto;
  max-height: calc(100vh - var(--topbar-height) - 120px);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-secondary);
}

.json-preview .json-key { color: var(--accent); }
.json-preview .json-string { color: var(--success); }
.json-preview .json-number { color: var(--warning); }
.json-preview .json-boolean { color: var(--info); }
.json-preview .json-null { color: var(--text-muted); }

/* ---------- Image Upload ---------- */
.image-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.image-upload:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.image-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-upload-icon {
  font-size: 28px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.image-upload-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.image-upload-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.image-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

/* ---------- Responsive (optional for now) ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .workspace {
    padding: 20px 16px;
  }
}

/* ---------- Utility Classes ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Auth Screen ---------- */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(124, 92, 252, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(199, 125, 255, 0.06) 0%, transparent 50%);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  font-size: 40px;
  text-align: center;
  margin-bottom: 20px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-card .form-group {
  margin-bottom: 16px;
}

.auth-card .form-input {
  padding: 11px 14px;
}

.auth-error {
  min-height: 20px;
  font-size: 12px;
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.4;
}

.auth-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 12px 20px;
  font-size: 14px;
}

.auth-card .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-footer {
  margin-top: 20px;
  text-align: center;
}

.auth-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.auth-link:hover {
  color: var(--accent-hover);
}

.auth-toggle-row {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-toggle-row a {
  margin-left: 4px;
}

/* ---------- User Info in Sidebar Footer ---------- */
.sidebar-footer-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
  margin-bottom: 8px;
}

.sidebar-footer-email {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-user .btn-logout {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 14px;
  transition: color var(--transition-fast);
}

.sidebar-footer-user .btn-logout:hover {
  color: var(--danger);
}

/* ---------- Audio Module ---------- */
.audio-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.audio-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.audio-filter-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.audio-filter-btn.active {
  background: var(--accent);
  color: white;
}

.audio-filter-count {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: color-mix(in srgb, currentColor 15%, transparent);
}

.audio-filter-btn.active .audio-filter-count {
  background: rgba(255, 255, 255, 0.2);
}

.audio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.audio-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audio-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.audio-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.audio-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

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

.audio-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.audio-card-cat {
  font-weight: 600;
  font-size: 11px;
}

.audio-duration,
.audio-room {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.audio-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.audio-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.audio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.audio-tag {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--accent-subtle);
  color: var(--accent);
  white-space: nowrap;
}

.audio-tag-more {
  background: var(--bg-input);
  color: var(--text-muted);
}

.audio-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.audio-play-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.audio-play-btn.playing {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.audio-play-btn.playing:hover {
  background: var(--accent-hover);
}

/* Audio form inline player */
.audio-form-player {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.audio-form-player audio {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-sm);
}

/* ---------- Form Section Divider ---------- */
.form-section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0 24px;
  opacity: 0.5;
}

/* ---------- Hotspot Cards (Collapsible) ---------- */
.hotspot-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hotspot-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.hotspot-card:hover {
  border-color: var(--border-light);
}

.hotspot-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
  border-left: 3px solid var(--warning);
}

.hotspot-card-header:hover {
  background: var(--bg-card-hover);
}

.hotspot-card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.hotspot-icon {
  color: var(--warning);
  font-size: 14px;
  flex-shrink: 0;
}

.hotspot-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hotspot-slug-label {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
}

.hotspot-card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hotspot-chevron {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform var(--transition-fast);
}

.hotspot-card.collapsed .hotspot-chevron {
  transform: rotate(-90deg);
}

.hotspot-card-body {
  padding: 16px 16px 4px;
  border-top: 1px solid var(--border);
}

.hotspot-card.collapsed .hotspot-card-body {
  display: none;
}

/* ---------- Interaction Cards ---------- */
.interaction-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 8px;
}

.interaction-card:last-child {
  margin-bottom: 0;
}

.interaction-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.interaction-card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.interaction-card-header-left i {
  color: var(--info);
  font-size: 13px;
  flex-shrink: 0;
}

.interaction-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Hotspot Action Cards ---------- */
.hs-action-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 2px solid var(--success);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 6px;
}

.hs-action-card:last-child {
  margin-bottom: 0;
}

.hs-action-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.hs-action-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
}

/* ---------- Quick Create Button ---------- */
.quick-create-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.btn-quick-create {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
  padding: 0;
}

.btn-quick-create:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}

/* ---------- Combobox (searchable dropdown) ---------- */
.combobox {
  position: relative;
  flex: 1;
  min-width: 0;
}

.combobox-input {
  width: 100%;
  height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.combobox-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.combobox-input::placeholder {
  color: var(--muted);
  font-size: 13px;
}

.combobox-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  transition: transform 0.15s ease;
}

.combobox-arrow.open {
  transform: translateY(-50%) rotate(180deg);
}

.combobox-listbox {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  display: none;
  padding: 4px;
  margin: 0;
  list-style: none;
}

.combobox-listbox.open {
  display: block;
}

.combobox-option {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combobox-option:hover,
.combobox-option.highlighted {
  background: rgba(99, 102, 241, 0.08);
}

.combobox-option.selected {
  font-weight: 600;
  color: var(--primary);
}

.combobox-option.placeholder {
  color: var(--muted);
  font-style: italic;
}

.combobox-empty {
  padding: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Dashboard ---------- */
.dash-container {
  max-width: 900px;
}

.dash-project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 32px;
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(124, 92, 252, 0.06) 0%, transparent 60%);
}

.dash-project-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.dash-project-logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), #c77dff);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

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

.dash-project-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-project-name:hover {
  color: var(--accent-hover);
}

.dash-project-type {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-edit-name-btn {
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.dash-project-header:hover .dash-edit-name-btn {
  opacity: 1;
}

.dash-name-input {
  font-size: 22px !important;
  font-weight: 700 !important;
  padding: 6px 10px !important;
}

.dash-date-input {
  font-size: 12px !important;
  padding: 2px 6px !important;
  width: 140px;
}

.dash-project-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.dash-meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.dash-meta-item i {
  color: var(--accent);
  font-size: 13px;
}

.dash-section {
  margin-bottom: 32px;
}

.dash-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.dash-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dash-stat-card:hover {
  border-color: var(--stat-color, var(--border-light));
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.dash-stat-icon {
  font-size: 20px;
  color: var(--stat-color, var(--accent));
  margin-bottom: 8px;
}

.dash-stat-count {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.dash-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 500;
}

.dash-recent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dash-recent-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.dash-recent-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  color: var(--icon-color);
  background: color-mix(in srgb, var(--icon-color) 10%, transparent);
}

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

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

.dash-recent-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-recent-type {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-size: 10px;
}

.dash-recent-date {
  color: var(--text-muted);
}

.dash-empty-recent {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

/* ============================================
   Sprite Sheet Viewer
   ============================================ */

.sprite-container {
  max-width: 900px;
}

/* Upload Area */
.sprite-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 60px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-card);
}

.sprite-upload-area:hover,
.sprite-upload-area.sprite-upload-drag {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.04);
}

.sprite-upload-icon {
  font-size: 40px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.sprite-upload-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.sprite-upload-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Controls Bar */
.sprite-controls-bar {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.sprite-controls-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Main Area — Canvas + Info */
.sprite-main-area {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.sprite-canvas-wrap {
  background: #1a1a2e;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-width: 200px;
  min-height: 200px;
  flex: 1;
}

.sprite-canvas-wrap canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.sprite-info-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sprite-info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.sprite-info-label {
  color: var(--muted);
  white-space: nowrap;
}

.sprite-info-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

/* Playback */
.sprite-playback {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.sprite-playback-left {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.sprite-playback-center {
  flex: 1;
  min-width: 80px;
}

.sprite-playback-center input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.sprite-playback-right {
  flex-shrink: 0;
}

/* Directions */
.sprite-directions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sprite-dir-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.sprite-dir-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sprite-dir-btn {
  font-size: 11px !important;
  padding: 4px 10px !important;
}

/* Full Sheet Preview */
.sprite-sheet-preview-section {
  margin-top: 4px;
}

.sprite-sheet-preview-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  overflow-x: auto;
  text-align: center;
}

.sprite-sheet-preview-wrap canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100%;
}

/* ============================================
   Milestones — Vertical Timeline
   ============================================ */

.ms-timeline {
  position: relative;
  max-width: 750px;
  padding-left: 48px;
}

/* Vertical line */
.ms-timeline::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}

/* Single timeline item */
.ms-timeline-item {
  position: relative;
  padding-bottom: 32px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  cursor: pointer;
}

.ms-timeline-item:last-child {
  padding-bottom: 0;
}

/* Dot / Node */
.ms-timeline-dot {
  position: absolute;
  left: -48px;
  top: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid;
  flex-shrink: 0;
  z-index: 1;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.ms-timeline-item:hover .ms-timeline-dot {
  transform: scale(1.15);
  box-shadow: 0 0 12px var(--border-light);
}

/* Card */
.ms-timeline-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  transition: all var(--transition-fast);
  min-width: 0;
}

.ms-timeline-item:hover .ms-timeline-card {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

/* Card header: date + category */
.ms-timeline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ms-timeline-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-main);
  padding: 2px 10px;
  border-radius: 99px;
}

.ms-timeline-cat {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Title */
.ms-timeline-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}

/* Description */
.ms-timeline-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

/* Image in timeline card */
.ms-timeline-img {
  margin-top: 8px;
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 220px;
}

.ms-timeline-img img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
}

/* ============================================
   Milestone Form — Image area
   ============================================ */

.ms-form-image-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ms-form-img-preview {
  max-width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.ms-form-image-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============================================
   To-Do List
   ============================================ */

.todo-section {
  margin-top: 32px;
  max-width: 700px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.todo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.todo-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.todo-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.todo-header-title i {
  color: var(--accent);
}

.todo-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-main);
  padding: 2px 8px;
  border-radius: 99px;
}

.todo-progress-bar {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.todo-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Input row */
.todo-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.todo-input-row .form-input {
  flex: 1;
}

/* List */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.todo-item:hover {
  background: var(--bg-card-hover);
}

.todo-item.todo-checked .todo-text {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-check {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  font-size: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.todo-check:hover {
  color: var(--success);
}

.todo-item.todo-checked .todo-check {
  color: var(--success);
}

.todo-text {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
  cursor: default;
  transition: color var(--transition-fast);
  line-height: 1.4;
}

.todo-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 13px;
  color: transparent;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.todo-item:hover .todo-delete {
  color: var(--text-muted);
}

.todo-delete:hover {
  color: var(--danger) !important;
  background: rgba(239, 68, 68, 0.08);
}

/* Inline edit */
.todo-edit-input {
  font-size: 14px !important;
  padding: 4px 8px !important;
}

/* Empty state */
.todo-empty {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
}
/* ---------- Command Palette ---------- */
.cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.cmd-palette.visible {
  opacity: 1;
  visibility: visible;
}

.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.cmd-palette-dialog {
  position: relative;
  z-index: 1;
  width: 560px;
  max-width: 90vw;
  max-height: 420px;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmdSlideIn 150ms ease;
}

@keyframes cmdSlideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cmd-palette-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.cmd-palette-search-icon {
  color: var(--text-muted);
  font-size: 15px;
  flex-shrink: 0;
}

.cmd-palette-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  padding: 0;
}

.cmd-palette-input::placeholder {
  color: var(--text-muted);
}

.cmd-palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.cmd-palette-group-label {
  padding: 10px 16px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.cmd-palette-item:hover,
.cmd-palette-item.highlighted {
  background: var(--accent-subtle);
}

.cmd-palette-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--icon-color) 10%, transparent);
  color: var(--icon-color);
}

.cmd-palette-item-content {
  flex: 1;
  min-width: 0;
}

.cmd-palette-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-palette-item-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.cmd-palette-item-arrow {
  color: var(--text-muted);
  font-size: 11px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.cmd-palette-item:hover .cmd-palette-item-arrow,
.cmd-palette-item.highlighted .cmd-palette-item-arrow {
  opacity: 1;
}

.cmd-palette-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.cmd-palette-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.cmd-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1;
}

.cmd-kbd-sm {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}

.cmd-highlight {
  color: var(--accent-hover);
  font-weight: 600;
}

/* ---------- Command Palette Trigger (Topbar) ---------- */
.cmd-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.cmd-trigger:hover {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.cmd-trigger-text {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmd-kbd-trigger {
  padding: 1px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.4;
}


/* ---------- Puzzle Designer Module ---------- */
.puzzle-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.puzzle-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.puzzle-filter-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.puzzle-filter-btn.active {
  background: var(--accent);
  color: white;
}

.puzzle-filter-count {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: color-mix(in srgb, currentColor 15%, transparent);
}

.puzzle-filter-btn.active .puzzle-filter-count {
  background: rgba(255, 255, 255, 0.2);
}

.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.puzzle-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.puzzle-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.puzzle-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.puzzle-card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

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

.puzzle-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.puzzle-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.puzzle-card-diff {
  font-weight: 600;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.puzzle-card-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
}

.puzzle-card-room {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.puzzle-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.puzzle-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.puzzle-card-stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.puzzle-card-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.puzzle-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.puzzle-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(244, 114, 182, 0.12);
  color: #f472b6;
  white-space: nowrap;
}

.puzzle-tag-more {
  background: var(--bg-input);
  color: var(--text-muted);
}

/* Puzzle Form */
.puzzle-form-container {
  max-width: 800px;
}

.puzzle-name-input {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  padding: 4px 8px;
  border-bottom: 2px solid var(--border);
  transition: border-color var(--transition-fast);
  min-width: 0;
}

.puzzle-name-input:focus {
  border-color: var(--accent);
}

.puzzle-meta-row {
  display: flex;
  gap: 16px;
}

/* Steps Section */
.puzzle-steps-section {
  margin-top: 8px;
}

.puzzle-steps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.puzzle-steps-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.puzzle-steps-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.puzzle-steps-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.puzzle-steps-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* Step Card */
.puzzle-step-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.puzzle-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border);
}

.puzzle-step-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-badge);
  padding: 2px 8px;
  border-radius: 10px;
}

.puzzle-step-type {
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.puzzle-step-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.puzzle-step-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.puzzle-step-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.puzzle-step-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.puzzle-step-reqs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.puzzle-req-label {
  font-size: 11px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.puzzle-req-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  white-space: nowrap;
}

.puzzle-req-tag-flag {
  background: rgba(252, 92, 124, 0.12);
  color: var(--danger);
}

.puzzle-step-result {
  font-size: 12px;
  color: var(--success);
  background: rgba(44, 182, 125, 0.08);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(44, 182, 125, 0.2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.puzzle-step-hints {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.puzzle-hint-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(96, 165, 250, 0.1);
  color: #60a5fa;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.puzzle-hint-tag::before {
  content: '\f0eb';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 9px;
}

.puzzle-add-alt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  margin-top: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.puzzle-add-alt-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* Step Connector */
.puzzle-step-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  gap: 0;
}

.puzzle-step-connector-line {
  width: 2px;
  height: 12px;
  background: var(--border);
}

.puzzle-step-connector-arrow {
  color: var(--text-muted);
  font-size: 10px;
}

/* Alternative Paths */
.puzzle-step-alt-paths {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.puzzle-alt-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(199, 125, 255, 0.06);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: #c77dff;
}

.puzzle-alt-path {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.puzzle-alt-path:last-child {
  border-bottom: none;
}

.puzzle-alt-path-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.puzzle-alt-path-name {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}

.puzzle-alt-path-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.4;
}

.puzzle-alt-path-reqs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.puzzle-alt-path-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(251, 191, 36, 0.06);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Reward Section */
.puzzle-reward-section {
  margin-top: 8px;
}

.puzzle-reward-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Form Section Divider */
.form-section-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ============================================
   Visual Map — Mapa Visual de Habitaciones
   ============================================ */

.map-workspace {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* --- Toolbar --- */
.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.map-toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.map-toolbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-toolbar-title i {
  color: var(--accent);
}

.map-stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.map-stats span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.map-stats i {
  font-size: 11px;
}

.map-stat-warn {
  color: var(--warning) !important;
}

.map-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.map-zoom-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-zoom-level {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* --- Viewport --- */
.map-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle, color-mix(in srgb, var(--text-muted) 6%, transparent) 1px, transparent 1px);
  background-size: 30px 30px;
  cursor: grab;
}

.map-viewport:active {
  cursor: grabbing;
}

/* --- Canvas --- */
.map-canvas {
  width: 4000px;
  height: 3000px;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#map-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
}

/* --- Room Nodes --- */
.map-node {
  position: absolute;
  width: 160px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  z-index: 5;
  transition: box-shadow 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.map-node:hover {
  z-index: 10;
  border-color: var(--accent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 20%, transparent);
}

.map-node-connected {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.map-node-isolated {
  border-color: color-mix(in srgb, var(--text-muted) 25%, transparent);
  opacity: 0.6;
}

.map-node-isolated:hover {
  opacity: 1;
}

.map-node-selected {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent), 0 0 20px color-mix(in srgb, var(--accent) 20%, transparent) !important;
  z-index: 15 !important;
  opacity: 1 !important;
}

.map-node-dragging {
  cursor: grabbing;
  z-index: 20 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0.9;
}

.map-node-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.map-node-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.map-node-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.map-node-meta i {
  font-size: 9px;
}

/* --- Legend --- */
.map-legend {
  position: absolute;
  bottom: 44px;
  left: 12px;
  display: flex;
  gap: 14px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 10;
  backdrop-filter: blur(6px);
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.map-legend-line {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 1px;
}

.map-legend-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* --- Hint --- */
.map-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

/* --- Room Popup --- */
.map-room-popup {
  position: fixed;
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}

.map-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.map-popup-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.map-popup-close {
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  padding: 0 2px;
}

.map-popup-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-popup-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.map-popup-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.map-popup-stats i {
  font-size: 11px;
}

.map-popup-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.map-popup-exits {
  margin-bottom: 12px;
}

.map-popup-exit {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
  padding: 3px 0;
}

.map-popup-exit i:first-child {
  font-size: 10px;
  color: var(--accent);
}

.map-popup-exit-target {
  color: var(--accent);
  font-weight: 500;
}

.map-popup-cond {
  color: var(--warning);
  font-size: 10px;
  margin-left: 2px;
}

.map-popup-actions {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  gap: 6px;
}

/* ============================================
   Gallery — Referencias Visuales / Moodboard
   ============================================ */

/* --- Search Row --- */
.gallery-search-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 4px 12px;
}

.gallery-search {
  position: relative;
  flex: 1;
  max-width: 360px;
}

.gallery-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-muted);
}

.gallery-search-input {
  width: 100%;
  padding: 8px 32px 8px 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.gallery-search-input:focus {
  border-color: var(--accent);
}

.gallery-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 12px;
}

.gallery-count {
  font-size: 13px;
  color: var(--text-muted);
}

.gallery-no-results {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.gallery-no-results i {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
}

.gallery-no-results span {
  display: block;
  margin-bottom: 12px;
}

/* --- Filter Tabs --- */
.gallery-filters {
  display: flex;
  gap: 6px;
  padding: 0 4px 16px;
  flex-wrap: wrap;
}

.gallery-filter-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gallery-filter-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.gallery-filter-btn.active {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}

.gallery-filter-count {
  font-size: 11px;
  opacity: 0.7;
}

/* --- Masonry Grid --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 4px;
}

/* --- Image Card --- */
.gallery-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gallery-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.gallery-card-img-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-primary);
}

.gallery-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.gallery-card:hover .gallery-card-img {
  transform: scale(1.03);
}

.gallery-card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.3;
  font-size: 32px;
}

.gallery-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}

.gallery-card:hover .gallery-card-badge {
  opacity: 1;
}

.gallery-card-body {
  padding: 10px 12px;
}

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

.gallery-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.gallery-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  white-space: nowrap;
}

.gallery-tag-more {
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  color: var(--text-muted);
}

/* --- Upload Area --- */
.gallery-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-upload-area:hover,
.gallery-upload-dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.gallery-upload-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.gallery-upload-placeholder i {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
  opacity: 0.4;
}

.gallery-upload-text {
  font-size: 14px;
  font-weight: 500;
}

.gallery-upload-hint {
  font-size: 12px;
  opacity: 0.6;
  margin-top: 4px;
}

.gallery-upload-preview {
  position: relative;
  width: 100%;
  max-height: 350px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-upload-preview img {
  max-width: 100%;
  max-height: 340px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.gallery-upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.gallery-upload-remove:hover {
  background: var(--danger);
}

/* --- Lightbox --- */
.modal-lightbox {
  max-width: 850px !important;
  width: 90vw !important;
}

.gallery-lightbox {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gallery-lightbox-img {
  width: 100%;
  max-height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.gallery-lightbox-img img {
  max-width: 100%;
  max-height: 55vh;
  object-fit: contain;
}

.gallery-lightbox-placeholder {
  padding: 60px 0;
  color: var(--text-muted);
  opacity: 0.3;
}

.gallery-lightbox-info {
  padding: 0 4px;
}

.gallery-lightbox-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.gallery-lightbox-cat {
  font-size: 13px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.gallery-lightbox-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.gallery-lightbox-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.gallery-lightbox-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
