/* === CSS Variables === */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eef1f4;
  --bg-hover: #e1e6eb;
  
  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #8b949e;
  
  --accent: #0969da;
  --accent-hover: #0550ae;
  --accent-muted: #0969da20;
  
  --success: #1a7f37;
  --warning: #9a6700;
  --danger: #cf222e;
  
  --border: #d1d9e0;
  --border-muted: #e1e6eb;
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --header-height: 48px;
  --panel-width: 280px;
  --toolbar-height: 40px;
  
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  
  --transition: 150ms ease;
}

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

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

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === App Layout === */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* === Top Menu === */
#top-menu {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.menu-items {
  display: flex;
  gap: 8px;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.menu-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* === Main Content === */
#main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* === Left Panel === */
#left-panel {
  width: var(--panel-width);
  min-width: 200px;
  max-width: 500px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-header {
  height: var(--toolbar-height);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.panel-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

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

#tree-container {
  flex: 1;
  overflow: auto;
  padding: 8px;
}

/* === Resizer === */
#resizer {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background var(--transition);
  flex-shrink: 0;
}

#resizer:hover,
#resizer.dragging {
  background: var(--accent);
}

/* === Right Panel === */
#right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

#editor-toolbar {
  height: var(--toolbar-height);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

#diagram-name {
  font-weight: 500;
  color: var(--text-primary);
}

#diagram-status {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

#diagram-status.modified {
  color: var(--warning);
}

#diagram-status.saving {
  color: var(--accent);
}

#diagram-status.saved {
  color: var(--success);
}

.toolbar-right {
  display: flex;
  gap: 8px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.toolbar-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.toolbar-btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* Toggle button (info) */
.toolbar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  cursor: pointer;
}

.toolbar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

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

/* === Canvas Container === */
#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#canvas {
  width: 100%;
  height: 100%;
  display: none;
}

#canvas.active {
  display: block;
}

#welcome-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
}

#welcome-message svg {
  opacity: 0.3;
  margin-bottom: 20px;
}

#welcome-message h2 {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

#welcome-message p {
  font-size: 14px;
  max-width: 300px;
}

#welcome-message.hidden {
  display: none;
}

/* === jsTree Customization === */
.jstree-default {
  font-family: var(--font-sans);
  font-size: 13px;
}

.jstree-default .jstree-node {
  margin-left: 12px;
}

.jstree-default .jstree-anchor {
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.jstree-default .jstree-anchor:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.jstree-default .jstree-clicked {
  background: var(--accent-muted) !important;
  color: var(--accent) !important;
}

.jstree-default .jstree-hovered {
  background: var(--bg-hover);
}

.jstree-default .jstree-icon {
  color: var(--text-muted);
}

/* Custom jsTree icons */
.jstree-icon.jstree-icon-repo::before {
  content: "📦";
}

.jstree-icon.jstree-icon-folder::before {
  content: "📁";
}

.jstree-icon.jstree-icon-diagram::before {
  content: "📊";
}

.jstree-icon.jstree-icon-start::before {
  content: "▶️";
}

.jstree-icon.jstree-icon-end::before {
  content: "⏹️";
}

.jstree-icon.jstree-icon-task::before {
  content: "📋";
}

.jstree-icon.jstree-icon-usertask::before {
  content: "👤";
}

.jstree-icon.jstree-icon-servicetask::before {
  content: "⚙️";
}

.jstree-icon.jstree-icon-gateway::before {
  content: "◇";
}

.jstree-icon.jstree-icon-subprocess::before {
  content: "📦";
}

.jstree-icon.jstree-icon-data::before {
  content: "📄";
}

.jstree-icon.jstree-icon-datastore::before {
  content: "🗄️";
}

/* Object Definition - use standard icon (clipboard) */
.jstree-icon.jstree-icon-objdef {
  /* Keep default appearance */
}

/* Occurrence/Shortcut - link icon */
.jstree-icon.jstree-icon-occurrence::before {
  content: "🔗" !important;
}

/* === Context Menu === */
#context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 180px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  animation: contextFadeIn 100ms ease;
}

@keyframes contextFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#context-menu.hidden {
  display: none;
}

#context-menu ul {
  list-style: none;
}

#context-menu li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

#context-menu li:hover {
  background: var(--bg-hover);
}

#context-menu li.separator {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
  padding: 0;
  cursor: default;
}

#context-menu li.danger {
  color: var(--danger);
}

#context-menu li.danger:hover {
  background: rgba(207, 34, 46, 0.1);
}

#context-menu li svg {
  flex-shrink: 0;
}

/* === BPMN Right-Click Context Menu (styled like djs-context-pad) === */
.bpmn-context-menu {
  position: fixed;
  z-index: 1000;
  display: none;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
}

.bpmn-context-menu.visible {
  display: flex;
  gap: 2px;
  animation: menuFadeIn 0.15s ease;
}

.bpmn-context-menu .entry {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: #666;
  transition: background var(--transition), color var(--transition);
}

.bpmn-context-menu .entry:hover {
  background: var(--bg-hover);
  color: #333;
}

.bpmn-context-menu .entry.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.bpmn-context-menu .entry svg {
  width: 18px;
  height: 18px;
}

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

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text-primary);
  animation: toastSlideIn 200ms ease;
}

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

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--accent);
}

/* === bpmn-js Overrides === */
.djs-container {
  background: #fafbfc !important;
}

.djs-palette {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
}

.djs-palette-entries {
  background: transparent !important;
}

.djs-palette .entry:hover {
  background: var(--bg-hover) !important;
}

.djs-context-pad {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
}

/* Custom icons for context pad */
.djs-context-pad .entry.bpmn-icon-copy,
.djs-context-pad .entry.bpmn-icon-paste,
.djs-context-pad .entry.bpmn-icon-properties {
  position: relative;
}

.djs-context-pad .entry.bpmn-icon-properties::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M12 3h7a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-7'/%3E%3Cpath d='M3 9h6M3 15h6'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Ccircle cx='9' cy='15' r='2'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.djs-context-pad .entry.bpmn-icon-copy::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Crect x='9' y='9' width='13' height='13' rx='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.djs-context-pad .entry.bpmn-icon-paste::before {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3Crect x='8' y='2' width='8' height='4' rx='1'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.djs-context-pad .entry.bpmn-icon-copy:hover::before,
.djs-context-pad .entry.bpmn-icon-paste:hover::before,
.djs-context-pad .entry.bpmn-icon-properties:hover::before {
  filter: brightness(0.3);
}

.djs-popup {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* === Modal Dialog === */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modalFadeIn 150ms ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#modal-overlay.hidden {
  display: none;
}

#modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  max-width: 400px;
  animation: modalSlideIn 150ms ease;
}

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

#modal-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

#modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

#modal-body {
  padding: 16px 20px;
}

#modal-input {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

#modal-footer {
  padding: 12px 20px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.modal-btn:hover {
  background: var(--bg-hover);
}

.modal-btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.modal-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* === Attributes Panel === */
#attributes-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 320px;
  max-height: calc(100% - 40px);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  animation: attrPanelSlideIn 200ms ease;
}

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

#attributes-panel.hidden {
  display: none;
}

.attr-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.attr-panel-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.attr-panel-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.attr-panel-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.attr-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.attr-type-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-muted);
  border-radius: 20px;
  margin-bottom: 16px;
}

.attr-element-type {
  display: none;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

#attributes-form .form-group {
  margin-bottom: 16px;
}

#attributes-form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#attributes-form input[type="text"],
#attributes-form textarea,
#attributes-form select {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#attributes-form input[type="text"]:focus,
#attributes-form textarea:focus,
#attributes-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

#attributes-form textarea {
  min-height: 80px;
  resize: vertical;
}

#attributes-form textarea[readonly] {
  background: var(--bg-tertiary);
  cursor: default;
  color: var(--text-secondary);
}

#attributes-form textarea[readonly]:focus {
  border-color: var(--border);
  box-shadow: none;
}

#attributes-form .attr-hint {
  font-weight: 400;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

.attr-panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.attr-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.attr-btn:hover {
  background: var(--bg-hover);
}

.attr-btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.attr-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* === Connections Section (Collapsible) === */
.connections-section {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.connections-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

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

.connections-header svg {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
  transition: transform var(--transition);
}

.connections-section.expanded .connections-header svg {
  transform: rotate(90deg);
}

.connections-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.connections-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.connections-body {
  display: none;
  padding: 0 12px 12px;
}

.connections-section.expanded .connections-body {
  display: block;
}

.connection-group {
  margin-bottom: 10px;
}

.connection-group:last-child {
  margin-bottom: 0;
}

.connection-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.connection-group-label svg {
  width: 12px;
  height: 12px;
}

.connection-group-label.incoming svg {
  color: var(--success);
}

.connection-group-label.outgoing svg {
  color: var(--accent);
}

.connection-group-label.participant svg {
  color: var(--warning);
}

.connection-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.connection-item {
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.connection-item:last-child {
  margin-bottom: 0;
}

.connection-name {
  font-weight: 500;
}

.connection-type {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.connection-diagrams {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.connections-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 8px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.connections-info svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.connections-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 8px;
  background: var(--bg-primary);
  border: 1px dashed var(--border-muted);
  border-radius: var(--radius-sm);
}

.connections-empty svg {
  width: 16px;
  height: 16px;
  opacity: 0.5;
}

/* === Utility === */
.hidden {
  display: none !important;
}

/* === Generate Button === */
.toolbar-btn.generate-btn {
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  color: #fff;
  border-color: var(--accent);
}

.toolbar-btn.generate-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #6d28d9 100%);
  color: #fff;
  border-color: var(--accent-hover);
}

/* === Generate from Description Modal === */
#generate-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modalFadeIn 150ms ease;
}

#generate-modal-overlay.hidden {
  display: none;
}

#generate-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 150ms ease;
}

#generate-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

#generate-modal-header h4 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

#generate-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

#generate-modal-body .form-group {
  margin-bottom: 20px;
}

#generate-modal-body .form-group:last-child {
  margin-bottom: 0;
}

#generate-modal-body label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

#generate-modal-body input[type="text"],
#generate-modal-body textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#generate-modal-body input[type="text"]:focus,
#generate-modal-body textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

#generate-modal-body textarea {
  min-height: 250px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.description-hint {
  margin-bottom: 10px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.description-hint code {
  display: block;
  margin-top: 8px;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
}

#generate-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

#generate-modal-footer .modal-btn {
  padding: 10px 20px;
}

#generate-modal-footer .modal-btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #7c3aed 100%);
  border-color: var(--accent);
}

#generate-modal-footer .modal-btn.primary:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #6d28d9 100%);
  border-color: var(--accent-hover);
}

#generate-modal-footer .modal-btn.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* === AI Assistant Button === */
.menu-btn.ai-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 6px 14px;
}

.menu-btn.ai-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #fff;
}

.menu-btn.ai-btn.active {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* === Chat Panel === */
#chat-panel {
  width: 380px;
  min-width: 320px;
  max-width: 480px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  animation: chatSlideIn 200ms ease;
}

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

#chat-panel.hidden {
  display: none;
}

.chat-header {
  height: var(--toolbar-height);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.chat-header-left svg {
  opacity: 0.9;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-actions select {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}

.chat-header-actions select:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chat-header-actions select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.chat-header-actions .icon-btn {
  color: rgba(255, 255, 255, 0.8);
}

.chat-header-actions .icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Chat Messages Area */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.chat-welcome-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
  border-radius: 50%;
  margin-bottom: 16px;
  color: #10b981;
}

.chat-welcome h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-welcome p {
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-btn {
  padding: 10px 16px;
  font-size: 13px;
  color: #059669;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  text-align: left;
}

.mode-btn:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
}

/* Chat Message Bubbles */
.chat-message {
  display: flex;
  gap: 10px;
  max-width: 100%;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-message.assistant .chat-message-avatar {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
}

.chat-message.user .chat-message-avatar {
  background: var(--accent);
  color: #fff;
}

.chat-message-content {
  flex: 1;
  min-width: 0;
}

.chat-message.user .chat-message-content {
  text-align: right;
}

.chat-message-bubble {
  display: inline-block;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.5;
  max-width: 100%;
  text-align: left;
}

.chat-message.assistant .chat-message-bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-message.user .chat-message-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message-bubble p {
  margin: 0 0 8px 0;
}

.chat-message-bubble p:last-child {
  margin-bottom: 0;
}

.chat-message-bubble ul,
.chat-message-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.chat-message-bubble li {
  margin: 4px 0;
}

.chat-message-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
}

.chat-message-bubble pre {
  margin: 8px 0;
  padding: 10px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.chat-message-bubble pre code {
  padding: 0;
  background: none;
}

.chat-message-bubble strong {
  font-weight: 600;
}

/* BPMN diagram links in chat */
.chat-message-bubble .bpmn-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent-muted);
  color: var(--accent);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 12px;
  transition: var(--transition);
  border: 1px solid transparent;
}

.chat-message-bubble .bpmn-link:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
}

/* Create process button in chat */
.chat-message-bubble .create-process-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
  margin: 8px 0;
}

.chat-message-bubble .create-process-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.4);
}

.chat-message-bubble .create-process-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.chat-message-bubble .create-process-btn.created {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

/* Patch process button in chat */
.chat-message-bubble .patch-process-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
  margin: 8px 0;
}

.chat-message-bubble .patch-process-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(245, 158, 11, 0.4);
}

.chat-message-bubble .patch-process-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.chat-message-bubble .patch-process-btn.applied {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.chat-message-bubble h1,
.chat-message-bubble h2,
.chat-message-bubble h3,
.chat-message-bubble h4 {
  margin: 12px 0 8px 0;
  font-weight: 600;
}

.chat-message-bubble h1:first-child,
.chat-message-bubble h2:first-child,
.chat-message-bubble h3:first-child,
.chat-message-bubble h4:first-child {
  margin-top: 0;
}

.chat-message-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.chat-message.user .chat-message-meta {
  text-align: right;
}

/* Typing Indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}

.chat-typing span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.chat-typing span:nth-child(1) { animation-delay: 0s; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Chat Input Area */
.chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

#chat-status {
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: rgba(234, 179, 8, 0.1);
  color: #a16207;
  border: 1px solid rgba(234, 179, 8, 0.2);
}

#chat-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

#chat-status.hidden {
  display: none;
}

.chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#chat-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

#btn-chat-send {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  flex-shrink: 0;
}

#btn-chat-send:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: scale(1.05);
}

#btn-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === Attribute Types Icons === */
.jstree-icon.jstree-icon-attributes::before {
  content: "⚙️";
}

.jstree-icon.jstree-icon-attribute-type::before {
  content: "📝";
}

/* === Attribute Type Modal === */
#attr-type-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modalFadeIn 150ms ease;
}

#attr-type-modal-overlay.hidden {
  display: none;
}

.attr-type-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 400px;
  max-width: 500px;
  animation: modalSlideIn 150ms ease;
}

.attr-type-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.attr-type-modal .modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.attr-type-modal .modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.attr-type-modal .modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.attr-type-modal .modal-body {
  padding: 20px;
}

.attr-type-modal .modal-body .form-group {
  margin-bottom: 16px;
}

.attr-type-modal .modal-body .form-group:last-child {
  margin-bottom: 0;
}

.attr-type-modal .modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.attr-type-modal .modal-body input,
.attr-type-modal .modal-body select {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.attr-type-modal .modal-body input:focus,
.attr-type-modal .modal-body select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.attr-type-modal .modal-body input:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

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

.attr-type-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.attr-type-modal .btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.attr-type-modal .btn:hover {
  background: var(--bg-hover);
}

.attr-type-modal .btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.attr-type-modal .btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* === Add Attribute Button === */
.add-attr-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.add-attr-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.add-attr-btn svg {
  opacity: 0.7;
}

/* === Attribute Picker Dropdown === */
.attr-picker-dropdown {
  position: fixed;
  z-index: 1000;
  min-width: 200px;
  max-width: 280px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: contextFadeIn 100ms ease;
}

.attr-picker-dropdown.hidden {
  display: none;
}

.attr-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
}

.attr-picker-item:hover {
  background: var(--bg-hover);
}

.attr-picker-name {
  font-size: 13px;
  color: var(--text-primary);
}

.attr-picker-type {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* === Attribute Form Field Types === */
#attributes-form input[type="number"],
#attributes-form input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#attributes-form input[type="number"]:focus,
#attributes-form input[type="date"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* Checkbox Label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
}

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

/* === Version Badge & Dropdown === */
#version-badge-container {
  position: relative;
}

#version-badge-container.hidden {
  display: none;
}

.version-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.version-badge:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.version-badge.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

.version-badge .version-time {
  color: var(--text-muted);
  font-size: 11px;
}

.version-badge .dropdown-arrow {
  margin-left: 2px;
  transition: transform var(--transition);
}

.version-badge.active .dropdown-arrow {
  transform: rotate(180deg);
}

.version-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 280px;
  max-width: 340px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: dropdownFadeIn 150ms ease;
}

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

.version-dropdown.hidden {
  display: none;
}

.version-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.version-dropdown-action {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.version-dropdown-action:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.version-list {
  max-height: 300px;
  overflow-y: auto;
}

.version-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border-muted);
}

.version-item:last-child {
  border-bottom: none;
}

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

.version-item.current {
  background: var(--accent-muted);
}

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

.version-item-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.version-item.current .version-item-label {
  color: var(--accent);
}

.version-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

.version-item-diff {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diff-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 500;
}

.diff-tag.added {
  background: rgba(26, 127, 55, 0.12);
  color: var(--success);
}

.diff-tag.removed {
  background: rgba(207, 34, 46, 0.12);
  color: var(--danger);
}

.diff-tag.changed {
  background: rgba(154, 103, 0, 0.12);
  color: var(--warning);
}

/* === History Panel (Side Drawer) === */
#history-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 340px;
  height: 100%;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 150;
  animation: historyPanelSlideIn 200ms ease;
  box-shadow: var(--shadow-lg);
}

@keyframes historyPanelSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

#history-panel.hidden {
  display: none;
}

.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.history-panel-header h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.history-panel-header h4 svg {
  color: var(--accent);
}

.history-panel-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.history-panel-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.history-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.history-empty svg {
  opacity: 0.3;
  margin-bottom: 16px;
}

.history-empty p {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 4px 0;
}

.history-empty span {
  font-size: 12px;
}

.history-entry {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-muted);
  cursor: pointer;
  transition: background var(--transition);
}

.history-entry:hover {
  background: var(--bg-hover);
}

.history-entry.current {
  background: var(--accent-muted);
  border-left: 3px solid var(--accent);
}

.history-entry.previewing {
  background: rgba(154, 103, 0, 0.1);
  border-left: 3px solid var(--warning);
}

.history-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.history-entry-version {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.history-entry.current .history-entry-version {
  color: var(--accent);
}

.history-entry-version .current-badge {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  padding: 2px 6px;
  margin-left: 8px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
}

.history-entry-time {
  font-size: 11px;
  color: var(--text-muted);
}

.history-entry-diff {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-diff-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-diff-detail {
  font-size: 11px;
  color: var(--text-secondary);
  padding-left: 8px;
  border-left: 2px solid var(--border-muted);
  margin-top: 4px;
}

.history-diff-detail ul {
  margin: 0;
  padding: 0 0 0 14px;
  list-style: none;
}

.history-diff-detail li {
  margin: 2px 0;
  position: relative;
}

.history-diff-detail li::before {
  content: "•";
  position: absolute;
  left: -12px;
  color: var(--text-muted);
}

.history-panel-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.history-viewing-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(154, 103, 0, 0.1);
  color: var(--warning);
  font-size: 12px;
}

.history-viewing-banner.hidden {
  display: none;
}

.history-viewing-banner svg {
  flex-shrink: 0;
}

.history-viewing-banner span {
  flex: 1;
}

.history-restore-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--success);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.history-restore-btn:hover {
  background: #15803d;
}

.history-cancel-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.history-cancel-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* === Auth Button States === */
.menu-btn#btn-auth {
  transition: all var(--transition);
}

.menu-btn#btn-auth.authenticated {
  background: var(--accent-muted);
  color: var(--accent);
}

.menu-btn#btn-auth.authenticated:hover {
  background: var(--accent);
  color: #fff;
}

/* === Sign In Modal === */
#signin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modalFadeIn 150ms ease;
}

#signin-modal-overlay.hidden {
  display: none;
}

#signin-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 400px;
  animation: modalSlideIn 150ms ease;
}

#signin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

#signin-modal-header h4 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

#signin-modal-header .modal-close-btn {
  color: rgba(255, 255, 255, 0.8);
}

#signin-modal-header .modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

#signin-modal-body {
  padding: 24px;
}

.signin-intro {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}

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

#signin-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

#signin-form input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#signin-form input[type="email"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.signin-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.signin-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.signin-message {
  margin: 16px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
}

.signin-message.hidden {
  display: none;
}

.signin-message.success {
  background: rgba(26, 127, 55, 0.1);
  color: var(--success);
  border: 1px solid rgba(26, 127, 55, 0.2);
}

.signin-message.error {
  background: rgba(207, 34, 46, 0.1);
  color: var(--danger);
  border: 1px solid rgba(207, 34, 46, 0.2);
}

.signin-pending {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
}

.signin-pending.hidden {
  display: none;
}

.signin-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinnerRotate 0.8s linear infinite;
}

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

/* === Profile Modal === */
#profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: modalFadeIn 150ms ease;
}

#profile-modal-overlay.hidden {
  display: none;
}

#profile-modal {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 380px;
  animation: modalSlideIn 150ms ease;
}

#profile-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

#profile-modal-header h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

#profile-modal-body {
  padding: 24px;
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.profile-details {
  flex: 1;
  min-width: 0;
}

.profile-email {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.profile-user-id {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}

#profile-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.modal-btn.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.modal-btn.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* Profile features */
.profile-features {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.profile-features-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-features-list {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.profile-role {
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
  text-transform: capitalize;
}

/* Disabled buttons */
.menu-btn.disabled,
.toolbar-btn.disabled,
.icon-btn.disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.menu-btn.disabled:hover,
.toolbar-btn.disabled:hover,
.icon-btn.disabled:hover {
  background: transparent;
}

/* === Responsive === */
@media (max-width: 768px) {
  #left-panel {
    width: 240px;
    min-width: 180px;
  }
  
  .menu-btn span {
    display: none;
  }
  
  #generate-modal {
    width: 95%;
    max-height: 95vh;
  }
  
  #chat-panel {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 400px;
    z-index: 500;
    box-shadow: var(--shadow-lg);
  }
  
  .attr-type-modal {
    min-width: 90%;
    max-width: 95%;
  }
}

