/* ═══════════════════════════════════════════════════════
   ERDAuto — Redesigned Styles
   Modern, polished design with refined visual hierarchy
   ═══════════════════════════════════════════════════════ */

/* ─── Design Tokens ────────────────────────────────── */
:root {
  --bg: #ffffff;
  --bg-warm: #f7f7f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-elevated: #ffffff;
  --text: #0a0a0a;
  --text-secondary: #1f1f1f;
  --muted: #595959;
  --muted-2: #7a7a7a;
  --border: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.18);
  --border-focus: rgba(0, 0, 0, 0.35);
  --primary: #0a0a0a;
  --primary-hover: #000000;
  --primary-soft: rgba(0, 0, 0, 0.06);
  --primary-ring: rgba(0, 0, 0, 0.16);
  --danger: #e53e3e;
  --danger-soft: rgba(229, 62, 62, 0.08);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.08);
  --warning: #f59e0b;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);
  --ring: 0 0 0 3px var(--primary-ring);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --transition-fast: 0.12s ease;
  --transition-normal: 0.2s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* ERD drawing tokens (match ERDPlus-like look) */
  --erd-stroke: #cbd5e1;
  --erd-fill: #ffffff;
}

/* ─── Dark mode overrides ─────────────────────── */
html[data-theme="dark"] {
  --bg: #000000;
  --bg-warm: #0b0b0b;
  --surface: rgba(10, 10, 10, 0.72);
  --surface-solid: #050505;
  --surface-elevated: #0e0e0e;

  --text: #f6f6f6;
  --text-secondary: #e6e6e6;
  --muted: #b4b4b4;
  --muted-2: #8a8a8a;

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --border-focus: rgba(255, 255, 255, 0.35);

  --primary: #f6f6f6;
  --primary-hover: #ffffff;
  --primary-soft: rgba(255, 255, 255, 0.1);
  --primary-ring: rgba(255, 255, 255, 0.22);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.42), 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 14px 44px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 24px 72px rgba(0, 0, 0, 0.6);

  --erd-stroke: #475569;
  --erd-fill: #0b0b0b;
}

html[data-theme="dark"] .btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #000;
}

html[data-theme="dark"] .btn-primary:hover {
  background: var(--primary-hover);
}

html[data-theme="dark"] .alert-notification,
html[data-theme="dark"] #help-panel {
  background: var(--surface-elevated);
}

html[data-theme="dark"] .modal-close:hover {
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .sql-textarea {
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] #canvas-background {
  background-image: radial-gradient(circle, rgba(226, 232, 240, 0.22) 1.3px, transparent 1.3px);
}

/* ─── AI Chat Panel (design-only) ─────────────────── */
body.ai-chat-open {
  overflow: hidden;
}

.ai-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 19000;
}

html[data-theme="dark"] .ai-chat-overlay {
  background: rgba(0, 0, 0, 0.58);
}

.ai-chat {
  position: fixed;
  top: 12px;
  bottom: 12px;
  width: min(440px, calc(100vw - 24px));
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: 20000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat.ai-chat--right {
  right: 12px;
}

.ai-chat.ai-chat--left {
  left: 12px;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ai-chat-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  user-select: none;
}

.ai-chat-title i {
  opacity: 0.9;
}

.ai-chat-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--primary-soft);
  border: 1px solid var(--border);
}

.ai-chat-actions {
  display: inline-flex;
  gap: 6px;
}

.ai-chat-iconbtn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-chat-iconbtn:hover {
  background: var(--primary-soft);
  border-color: var(--border-focus);
}

.ai-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ai-chat-hint {
  padding: 12px 14px 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.ai-chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-msg-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-2);
}

.ai-msg-bubble {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.72);
}

html[data-theme="dark"] .ai-msg-bubble {
  background: rgba(255, 255, 255, 0.06);
}

.ai-msg--assistant .ai-msg-bubble {
  border-top-left-radius: 8px;
}

.ai-msg--user {
  align-items: flex-end;
}

.ai-msg--user .ai-msg-bubble {
  border-top-right-radius: 8px;
  background: var(--primary-soft);
}

.ai-chat-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ai-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.ai-chat-chip {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-chat-chip:hover {
  background: var(--primary-soft);
  border-color: var(--border-focus);
  color: var(--text);
}

.ai-chat-composer {
  display: block;
}

.ai-chat-inputwrap {
  position: relative;
  width: 100%;
}

.ai-chat-input {
  width: 100%;
  resize: none;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 12px 44px 38px 14px;
  font-size: 13px;
  font-family: var(--font-sans);
  line-height: 1.35;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  outline: none;
  min-height: 72px;
  max-height: 160px;
}

.ai-chat-sendbtn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 1;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-chat-sendbtn i {
  font-size: 12px;
}

.ai-chat-sendbtn:hover:not(:disabled) {
  color: var(--text);
  background: transparent;
}

.ai-chat-sendbtn:focus-visible {
  outline: none;
  box-shadow: none;
}

.ai-chat-sendbtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─── AI Mode select (bottom-left of input) ────── */
.ai-chat-modeselect {
  position: absolute;
  left: 10px;
  bottom: 9px;
  z-index: 1;
  height: 24px;
  padding: 0 22px 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  max-width: 115px;
}

.ai-chat-modeselect:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.ai-chat-modeselect:focus {
  border-color: var(--border-focus);
  color: var(--text);
}

/* ─── Workflows dashboard ───────────────────────── */
.wf-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  padding: 20px 24px 44px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.wf-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.wf-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.wf-logo {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}

.wf-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.wf-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
}

.wf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.wf-actions .btn,
.wf-hero-actions .btn {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 10px;
}

.wf-actions .btn i {
  margin-right: 6px;
}

.wf-eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin-bottom: 8px;
}

.wf-subtext {
  color: var(--muted);
  font-size: 13px;
}

.wf-hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.wf-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wf-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.wf-section-head h2 {
  font-size: 16px;
  letter-spacing: -0.01em;
}

.wf-section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.wf-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.wf-search-box i {
  position: absolute;
  left: 12px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.wf-search-box input {
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 13px;
  width: 200px;
  transition: all var(--transition-fast);
}

.wf-search-box input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.wf-sort-select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23595959' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.wf-sort-select:hover {
  border-color: var(--border-strong);
}

.wf-sort-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.wf-grid {
  display: block;
}

.wf-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--surface-solid);
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 14px;
  min-height: 100px;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-normal);
  position: relative;
}


.wf-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.wf-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 18px;
}

.wf-card-menu-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-solid);
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.wf-card-menu-btn:hover {
  background: var(--primary-soft);
  color: var(--text);
}

.wf-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wf-card-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted-2);
  margin-bottom: 8px;
}

.wf-card h3 {
  font-size: 17px;
  margin: 0;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wf-card-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.wf-card-timestamp {
  color: var(--muted-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.wf-card-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wf-card-timestamp i {
  font-size: 11px;
}

.wf-card-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.wf-card-type-badge--entity {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.22);
  color: #1d4ed8;
}

.wf-card-type-badge--relation {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.22);
  color: #047857;
}

html[data-theme="dark"] .wf-card-type-badge--entity {
  color: #93c5fd;
}

html[data-theme="dark"] .wf-card-type-badge--relation {
  color: #6ee7b7;
}

.wf-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
  align-self: flex-end;
}

.wf-btn-open {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  padding: 9px 16px;
}

.wf-btn-delete {
  padding: 9px 12px;
  font-size: 13px;
}

.wf-btn-delete:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.wf-empty {
  text-align: center;
  padding: 60px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.wf-empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 32px;
}

.wf-empty h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--text);
}

.wf-empty p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.wf-empty-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Workflow dropdown menu */
.wf-dropdown {
  position: absolute;
  z-index: 1000;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 6px;
}

.wf-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
  text-align: left;
}

.wf-dropdown-item:hover {
  background: var(--primary-soft);
}

.wf-dropdown-item i {
  width: 16px;
  font-size: 13px;
  color: var(--muted);
}

.wf-dropdown-item-danger {
  color: var(--danger);
}

.wf-dropdown-item-danger:hover {
  background: var(--danger-soft);
}

.wf-dropdown-item-danger i {
  color: var(--danger);
}

.wf-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Workflow groups */
.wf-group {
  margin-bottom: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.wf-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.wf-group-header i {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 14px;
}

.wf-group-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.wf-group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-left: auto;
}

.wf-group-rename {
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text-secondary);
  border-radius: 10px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.wf-group-rename:hover {
  background: var(--surface-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}

.wf-group-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  padding: 18px 20px 20px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0));
}

html[data-theme="dark"] .wf-group {
  background: var(--surface-elevated);
}

html[data-theme="dark"] .wf-group-header {
  background: var(--surface-elevated);
}

html[data-theme="dark"] .wf-group-content {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
}

/* Workflow modals */
.wf-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wf-modal[hidden] {
  display: none !important;
}

.wf-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.wf-modal-content {
  position: relative;
  z-index: 1;
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.wf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.wf-modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.wf-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.wf-modal-close:hover {
  background: var(--primary-soft);
  color: var(--text);
}

/* Allow modal footer buttons to look like normal buttons */
.wf-modal-close.btn {
  width: auto;
  height: auto;
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
  padding: 7px 16px;
}

.wf-modal-close.btn:hover {
  background: transparent;
  color: inherit;
  border-color: transparent;
}

.wf-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.wf-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.wf-plan-modal-content {
  max-width: 680px;
}

.wf-plan-modal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.wf-plan-notice {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.wf-plan-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.wf-plan-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.wf-plan-hero h4 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.wf-plan-description,
.wf-plan-footnote,
.wf-plan-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.wf-plan-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
}

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

.wf-plan-stat {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-warm);
}

.wf-plan-stat span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.wf-plan-stat strong {
  font-size: 22px;
  letter-spacing: -0.02em;
}

.wf-plan-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.wf-plan-actions .btn[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

html[data-theme="dark"] .wf-plan-notice {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.28);
}

/* SQL output styling */
.wf-sql-output {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
}

/* Input styling for modals */
.wf-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface-solid);
  transition: var(--transition-fast);
}

.wf-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.wf-empty-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .wf-shell {
    padding: 16px 16px 40px;
  }

  .wf-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .wf-plan-hero {
    flex-direction: column;
  }

  .wf-plan-stats {
    grid-template-columns: 1fr;
  }
}

/* Inline AI panel: compact layout to fit narrow right panel */
#ai-panel {
  padding: 12px;
  gap: 10px;
}

#ai-panel .ai-panel-title {
  gap: 8px;
  font-size: 13px;
}

#ai-panel .ai-chat-iconbtn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
}

#ai-panel .ai-chat-messages {
  gap: 10px;
}

#ai-panel .ai-chat-chip {
  padding: 5px 8px;
  font-size: 11px;
}

#ai-panel .ai-chat-chips {
  gap: 6px;
  margin-bottom: 8px;
}

#ai-panel .ai-chat-input {
  min-height: 90px;
  font-size: 13px;
  padding: 11px 42px 11px 12px;
}

#ai-panel .ai-chat-sendbtn {
  right: 8px;
  bottom: 8px;
  width: 24px;
  height: 24px;
}

/* Generator-style content (not a chat transcript) */
.ai-empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.45);
}

html[data-theme="dark"] .ai-empty {
  background: rgba(255, 255, 255, 0.04);
}

.ai-empty-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.ai-empty-desc {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.ai-run {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.65);
}

html[data-theme="dark"] .ai-run {
  background: rgba(255, 255, 255, 0.05);
}

.ai-run-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.ai-run-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ai-run-prompt {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai-run-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.ai-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  flex: 0 0 auto;
}

.ai-step.is-loading {
  color: var(--text-secondary);
}

.ai-step.is-loading .ai-step-dot {
  border-color: var(--border-focus);
  border-top-color: transparent;
  animation: aiSpin 0.9s linear infinite;
}

.ai-step.is-done {
  color: var(--text);
}

.ai-step.is-done .ai-step-dot {
  background: var(--success);
  border-color: var(--success);
}

.ai-step.is-done .ai-step-dot::after {
  content: '';
  display: block;
  width: 4px;
  height: 2px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translate(2px, 3px) rotate(-45deg);
}

.ai-step.is-pending .ai-step-dot {
  opacity: 0.5;
}

/* Chat-style generator response (assistant bubble) */
.ai-runbubble {
  padding: 10px 12px;
}

.ai-run-text {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
}

.ai-checklist {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-checkitem {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.ai-checkicon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--text);
  /* black in light mode */
  margin-top: 1px;
}

.ai-checkicon i {
  font-size: 12px;
  line-height: 1;
}

.ai-checkitem.is-loading {
  color: var(--text-secondary);
}

.ai-checkitem.is-done {
  color: var(--text);
}

.ai-checkitem.is-error {
  color: var(--danger, #ef4444);
}

.ai-checkitem.is-error .ai-checkicon {
  color: var(--danger, #ef4444);
}

.ai-checkitem.is-pending .ai-checkicon {
  opacity: 0.45;
}

/* Styled error message shown inside the assistant bubble */
.ai-error-text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--danger, #ef4444);
  margin-top: 10px;
  padding: 7px 10px;
  background: color-mix(in srgb, var(--danger, #ef4444) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger, #ef4444) 30%, transparent);
  border-radius: var(--radius-md, 8px);
}

.ai-run-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ai-run-actions .btn {
  padding: 5px 8px;
  font-size: 11px;
  border-radius: 10px;
}

.ai-run-actions .btn-primary:hover {
  transform: none;
}

.ai-run-actions .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

html[data-theme="dark"] .ai-chat-input {
  background: rgba(255, 255, 255, 0.06);
}

.ai-chat-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.ai-chat-disclaimer {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.35;
}

/* AI Answer text styling (for Q&A responses) */
.ai-answer-text {
  padding: 8px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  word-wrap: break-word;
}

.ai-answer-text p {
  margin: 0 0 12px 0;
}

.ai-answer-text p:last-child {
  margin-bottom: 0;
}

.ai-answer-text strong {
  font-weight: 600;
  color: var(--text-primary);
}

.ai-answer-text em {
  font-style: italic;
}

.ai-answer-text code {
  background: var(--primary-soft);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.ai-answer-text ul,
.ai-answer-text ol {
  margin: 8px 0;
  padding-left: 24px;
}

.ai-answer-text li {
  margin: 4px 0;
}

.ai-answer-text ul li {
  list-style-type: disc;
}

.ai-answer-text ol li {
  list-style-type: decimal;
}

@media (max-width: 720px) {
  .ai-chat {
    top: 0;
    bottom: 0;
    left: 0 !important;
    right: 0 !important;
    width: 100vw;
    border-radius: 0;
  }
}

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

html,
body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ─── Layout ────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Navbar ────────────────────────────────────── */
#navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 64px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

#navbar .nav-left {
  display: flex;
  gap: 24px;
  align-items: center;
}

#navbar .nav-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.6px;
  user-select: none;
}

#navbar .nav-logo span {
  background: linear-gradient(135deg, var(--text) 0%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#navbar a {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

#navbar a:hover {
  color: var(--text);
}

#navbar .nav-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Workflow title in the navbar */
.nav-title-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.auth-shell #btn-theme {
  display: inline-flex;
}

.auth-shell #navbar .nav-right a.btn-outline {
  display: none;
}

/* ─── Landing page ────────────────────────────────── */
.landing-shell {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 24px 40px;
  position: relative;
  overflow: hidden;
}

.landing-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.25;
  pointer-events: none;
}

html[data-theme="dark"] .landing-shell::before {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  opacity: 0.22;
}

.landing-nav {
  width: min(1100px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.landing-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
}

.landing-logo-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  letter-spacing: -0.03em;
}

html[data-theme="dark"] .landing-logo-badge {
  background: #fff;
  color: #000;
}

.landing-logo-text {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.landing-nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.landing-link {
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-2);
  transition: color var(--transition-fast);
}

.landing-link:hover {
  color: var(--text);
}

.landing-hero {
  width: min(900px, 100%);
  text-align: center;
  margin-top: 70px;
  position: relative;
  z-index: 1;
}

.landing-hero h1 {
  font-size: clamp(40px, 6vw, 72px);
  letter-spacing: -0.04em;
  margin: 0;
  font-weight: 800;
}

.landing-hero h1 span {
  color: var(--muted);
  display: inline-block;
}

.landing-hero p {
  margin: 18px auto 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.landing-hero-actions {
  margin-top: 26px;
  display: inline-flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-prompt {
  width: min(760px, 100%);
  margin-top: 38px;
  padding: 22px 22px 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 1;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.landing-prompt:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-md);
}

.landing-prompt-composer {
  display: block;
}

.landing-prompt-input {
  width: 100%;
  resize: none;
  border-radius: var(--radius-lg);
  border: none;
  padding: 12px 14px;
  font-size: 13px;
  font-family: var(--font-sans);
  line-height: 1.35;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  outline: none;
  min-height: 72px;
  max-height: 160px;
}

html[data-theme="dark"] .landing-prompt-input {
  background: rgba(255, 255, 255, 0.06);
}

.landing-prompt-input:focus {
  background: rgba(255, 255, 255, 0.82);
}

html[data-theme="dark"] .landing-prompt-input:focus {
  background: rgba(255, 255, 255, 0.08);
}

.landing-prompt-input::placeholder {
  color: var(--muted-2);
}

.landing-prompt-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.landing-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.landing-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-2);
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.landing-chip:hover {
  background: var(--primary-soft);
  border-color: var(--border-focus);
  color: var(--text);
}

.landing-prompt-hint {
  margin: 12px 4px 0;
  font-size: 12px;
  color: var(--muted-2);
  text-align: center;
}

.landing-prompt-generate {
  position: absolute;
  bottom: 18px;
  right: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.landing-prompt-generate:hover:not(:disabled) {
  background: #111;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.landing-prompt-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--muted);
}

.landing-prompt-generate i {
  font-size: 12px;
}

/* ─── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--primary-soft);
  border-color: var(--border-focus);
  color: var(--primary);
}

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: #111;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ─── Toolbar ───────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  font-family: var(--font-sans);
}

.tool-btn i {
  font-size: 13px;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.zoom-btn i {
  font-size: 13px;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.tool-btn:hover i {
  opacity: 1;
}

.tool-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.tool-btn.active i {
  opacity: 1;
}

.tool-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.tool-btn--save {
  position: relative;
}

.tool-btn--save .save-indicator {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--warning);
  display: none;
  margin-left: 6px;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.tool-btn--save .save-indicator.save-indicator--visible {
  display: inline-flex;
  opacity: 1;
  transform: scale(1);
  animation: save-indicator-pulse 1s ease-in-out infinite;
}

.tool-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

@keyframes save-indicator-pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(0.6);
    opacity: 0.55;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ─── Connect toggle ───────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 11px;
  cursor: pointer;
  transition: background var(--transition-normal);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-normal);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle input:checked+.toggle-slider {
  background: var(--primary);
}

.toggle input:checked+.toggle-slider::before {
  transform: translateX(18px);
}

/* toolbar right side */
#toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 3px;
  align-items: center;
}

/* AI Credits Display */
.ai-credits-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: default;
  transition: all var(--transition-fast);
}

.ai-credits-display:hover {
  background: var(--primary-soft);
  border-color: var(--border-strong);
}

.ai-credits-display i {
  color: #f59e0b;
  font-size: 14px;
}

#ai-credits-count {
  min-width: 20px;
  text-align: center;
}

.ai-credits-display.low-credits {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.ai-credits-display.low-credits i {
  color: var(--danger);
  animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ─── Main area ────────────────────────────────── */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── Canvas wrapper ──────────────────────────── */
#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  cursor: grab;
}

#canvas-wrap.connect-mode,
#canvas-wrap.connect-mode:active {
  cursor: crosshair;
}

#canvas-wrap.connect-mode .erd-node {
  cursor: crosshair;
}

#canvas-wrap:active {
  cursor: grabbing;
}

#canvas-background {
  position: absolute;
  inset: -5000px;
  z-index: 0;
  background-image: radial-gradient(circle, rgba(15, 23, 42, 0.14) 1.2px, transparent 1.2px);
  background-size: 16px 16px;
  pointer-events: none;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#canvas-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
  width: 100%;
  height: 100%;
}

#canvas-svg line,
#canvas-svg path {
  pointer-events: stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke var(--transition-fast);
}

#canvas-svg path:hover {
  stroke-width: 2.5 !important;
}

/* Marching-ants animation for selected connections */
@keyframes conn-march {
  to {
    stroke-dashoffset: -20;
  }
}

.conn-marching {
  stroke-dasharray: 7 4;
  animation: conn-march 0.45s linear infinite;
}

#canvas-svg text {
  pointer-events: none;
  user-select: none;
  font-family: var(--font-sans);
}

/* ─── Zoom controls ────────────────────────────── */
#zoom-controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-md);
}

.zoom-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.zoom-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.zoom-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.zoom-btn svg {
  width: 14px;
  height: 14px;
}

/* ─── Right Panel ──────────────────────────────── */
#right-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface-solid);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

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

/* The dynamic properties markup is rendered inside #panel-content.
   Give it its own vertical rhythm so fields/buttons don't stick together. */
#panel-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Properties vs AI swap containers */
#panel-content-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

#panel-content-wrap[hidden] {
  display: none !important;
}

#ai-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
}

#ai-panel[hidden] {
  display: none !important;
}

#ai-panel .ai-chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0;
}

#ai-panel .ai-chat-footer {
  margin-top: auto;
  padding: 0;
  border-top: none;
  background: transparent;
}

.right-panel-tabs {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.right-panel-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.right-panel-tab:hover {
  background: var(--primary-soft);
  border-color: var(--border-focus);
  color: var(--text);
}

.right-panel-tab.active {
  background: var(--surface-solid);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.right-panel-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.right-panel-section[hidden] {
  display: none !important;
}

/* Inline AI panel inside right panel */
.ai-panel {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}

.ai-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ai-panel .ai-chat-messages {
  padding: 0;
  gap: 10px;
}

.ai-panel .ai-chat-footer {
  padding: 0;
}

.panel-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel-field input[type="text"],
.panel-field select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  background: var(--surface-solid);
}

.panel-field input[type="text"]:focus,
.panel-field select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.panel-action-btn {
  width: 100%;
  padding: 9px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-solid);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.panel-action-btn i {
  font-size: 13px;
  width: 13px;
  height: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel-action-btn:hover {
  background: var(--primary-soft);
  border-color: rgba(37, 99, 235, 0.2);
  color: var(--primary);
}

/* Relationship panel helpers */
.panel-inline {
  margin-top: -6px;
}

.panel-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

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

.panel-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.4;
}

.panel-sep {
  height: 1px;
  background: var(--border);
  margin: 0;
}

.panel-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.5;
}

/* ─── Expand arrow ──────────────────────────────── */
#panel-toggle {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

#panel-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ─── Diagram nodes ─────────────────────────────── */
.erd-node {
  position: absolute;
  user-select: none;
  cursor: move;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Selection */
.erd-node.selected .node-shape {
  outline: none;
}

.erd-node.selected .entity-shape,
.erd-node.selected .attr-shape,
.erd-node.selected .label-shape {
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(10, 15, 30, 0.06);
}

.erd-node.selected .rel-diamond polygon {
  stroke: var(--text) !important;
}

/* Source node while drawing a connection */
.erd-node.connect-source .node-shape {
  outline: none;
  outline-offset: 0;
}

/* Highlight potential targets */
.connect-mode .erd-node:not(.connect-source):hover .node-shape {
  outline: none;
  outline-offset: 0;
}

.erd-node:hover .node-shape {
  filter: brightness(0.97);
}

/* ─── Entity ───────────────────────────────────── */
.entity-shape {
  min-width: 100px;
  min-height: 42px;
  padding: 8px 20px;
  border: 1.5px solid var(--erd-stroke);
  background: var(--erd-fill);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: none;
  transition: all var(--transition-fast);
  color: var(--text);
}

.entity-shape.weak {
  box-shadow: inset 0 0 0 2px var(--erd-fill), inset 0 0 0 4px var(--erd-stroke);
}

/* ─── Attribute ──────────────────────────────── */
.attr-shape {
  min-width: 80px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1.5px solid var(--erd-stroke);
  background: var(--erd-fill);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: none;
  transition: all var(--transition-fast);
  color: var(--text);
}

.attr-shape.unique {
  border-bottom: 2px double var(--erd-stroke);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.attr-shape.multivalued {
  box-shadow: 0 0 0 2px var(--erd-fill), 0 0 0 4px var(--erd-stroke);
}

.attr-shape.derived {
  border-style: dashed;
}

/* ─── Relationship ─────────────────────────────── */
.rel-shape {
  width: 90px;
  height: 46px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.rel-diamond {
  position: absolute;
  inset: 0;
}

.rel-label {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  color: var(--text-secondary);
}

.erd-node.selected .rel-label {
  color: var(--text);
}

/* ─── Label node ───────────────────────────────── */
.label-shape {
  min-width: 60px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px dashed var(--erd-stroke);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* ─── Connection line label ─────────────────── */
.conn-label {
  font-size: 11px;
  fill: var(--text-secondary);
}

/* ─── Context menu ──────────────────────────── */
#ctx-menu {
  position: fixed;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 1000;
  min-width: 180px;
  display: none;
}

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

.ctx-item i {
  font-size: 12px;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.6;
}

.ctx-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.ctx-item:hover i {
  opacity: 1;
}

.ctx-item.danger {
  color: var(--danger);
}

.ctx-item.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 3px 4px;
}

/* ─── Tooltip ───────────────────────────────── */
#tooltip {
  position: fixed;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 2000;
  display: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  animation: tooltipFadeIn 0.15s ease-out;
  letter-spacing: 0.01em;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ─── Modal ─────────────────────────────────── */
@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 16px;
  animation: fadeIn 0.15s ease-out;
}

.modal-box {
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  min-width: 320px;
  max-width: 760px;
  width: min(92vw, 760px);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  position: relative;
  animation: modalScaleIn 0.2s ease-out;
}

.modal-box::-webkit-scrollbar {
  width: 10px;
}

.modal-box::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.modal-box::-webkit-scrollbar-track {
  background: transparent;
}

.modal-box.dark {
  background: var(--text);
  color: #fff;
}

.modal-box.dark h3 {
  color: #fff;
}

.modal-box h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.sql-modal-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.sql-textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  background: #f8fafc;
  outline: none;
}

.sql-textarea:focus {
  box-shadow: var(--ring);
  border-color: var(--border-focus);
}

/* ─── Alert Notification ───────────────────── */
@keyframes alertSlideIn {
  from {
    transform: translateY(12px) scale(0.95);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes alertSlideOut {
  from {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  to {
    transform: translateY(12px) scale(0.95);
    opacity: 0;
  }
}

.alert-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  max-width: 340px;
  animation: alertSlideIn 0.2s ease-out;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.alert-notification.exit {
  animation: alertSlideOut 0.15s ease-out forwards;
}

.alert-notification h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.alert-notification p {
  font-size: 13px;
  margin: 0;
  line-height: 1.4;
  opacity: 0.9;
}

/* ─── Help panel ────────────────────────────── */
#help-panel {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  z-index: 10;
  display: none;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

/* ─── Status bar ────────────────────────────── */
#status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  font-weight: 500;
}

/* ─── Custom Dropdown ──────────────────────── */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-trigger {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-solid);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  font-family: var(--font-sans);
}

.dropdown-trigger:hover {
  border-color: var(--muted-2);
}

.dropdown-trigger.active {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.dropdown-trigger::after {
  content: '▾';
  font-size: 11px;
  color: var(--muted-2);
  transition: transform var(--transition-normal);
  margin-left: 8px;
  flex-shrink: 0;
}

.dropdown-trigger.active::after {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  margin-top: -1px;
  z-index: 1000;
  max-height: 202px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.dropdown-menu.portaled {
  border-top: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 0;
  z-index: 20000;
}

.dropdown-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-leading {
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.dropdown-leading .dropdown-check,
.dropdown-leading .dropdown-opt-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.dropdown-check {
  display: none;
  color: var(--primary);
}

.dropdown-option.selected .dropdown-check {
  display: inline-flex;
}

.dropdown-option.selected .dropdown-opt-icon {
  display: none;
}

.dropdown-option i {
  font-size: 12px;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dropdown-icon-placeholder {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.dropdown-option:hover {
  background: var(--primary-soft);
}

.dropdown-option.selected {
  background: rgba(37, 99, 235, 0.06);
  color: var(--primary);
  font-weight: 600;
}

.dropdown-option.selected::before {
  display: none;
}

/* ─── Cardinality badge ────────────────────── */
.card-badge {
  font-size: 10px;
  fill: var(--text-secondary);
  font-weight: 700;
  font-family: var(--font-sans);
}

.cardinality-label {
  font-size: 12px;
  paint-order: stroke;
  stroke: var(--surface-solid);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.card-symbol line,
.card-symbol circle,
.card-symbol ellipse {
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
}

/* ─── Table Shape (Relational Schema) ──────── */
.table-shape {
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  width: 220px;
  min-height: 100px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.table-header {
  background: #565656;
  color: #fff;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.table-cols {
  display: flex;
  flex-direction: column;
  max-height: 200px;
  overflow-y: auto;
}

.table-cols .col {
  display: flex;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  align-items: center;
  transition: background var(--transition-fast);
}

.table-cols .col:last-child {
  border-bottom: none;
}

.table-cols .col:hover {
  background: var(--surface-solid);
}

.table-cols .col-icons {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  min-width: 14px;
  font-size: 10px;
}

.table-cols .col-icons i {
  color: var(--primary);
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.table-cols .col-no-icon {
  display: inline-block;
  width: 14px;
  height: 1px;
  background: transparent;
}

.table-cols .col-name {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-cols .col-type {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.table-cols .col-fk {
  margin-left: 4px;
  font-size: 9px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.table-cols .col-empty {
  padding: 12px 8px;
  color: var(--muted-2);
  font-style: italic;
  text-align: center;
  font-size: 11px;
}

/* ─── Column editor (relational panel) ──────── */
.columns-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 10px;
}

.columns-title {
  font-weight: 700;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.columns-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
}

.columns-add-btn:hover {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.3);
}

.columns-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: transparent;
  border: none;
  margin-bottom: 8px;
}

.columns-empty {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background: rgba(0, 0, 0, 0.02);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.col-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: visible;
  background: var(--surface-solid);
  box-shadow: var(--shadow-xs);
  position: relative;
  z-index: 0;
  transition: all var(--transition-fast);
}

.col-card:hover {
  box-shadow: var(--shadow-sm);
}

.col-card.dropdown-open {
  z-index: 50;
}

.col-card.drag-over {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.col-card.dragging {
  opacity: 0.5;
}

.col-row {
  display: grid;
  grid-template-columns: 26px 1fr 32px 32px;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  align-items: start;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.col-card:not(.is-open) .col-row {
  border-bottom: none;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.col-card.is-open .col-row {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.col-drag-handle {
  grid-column: 1;
  grid-row: 1;
  height: 32px;
  width: 26px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  border-radius: var(--radius-sm);
  color: var(--muted-2);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: all var(--transition-fast);
}

.col-drag-handle:active {
  cursor: grabbing;
}

.col-drag-handle:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.col-name-input {
  grid-column: 2;
  min-width: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 7px 10px;
  font-size: 12px;
  outline: none;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface-solid);
}

.col-name-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.col-char-len {
  width: 100px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  font-size: 12px;
  outline: none;
  font-family: var(--font-sans);
}

.col-char-len:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.col-delete-btn {
  grid-column: 4;
  grid-row: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted-2);
  background: rgba(0, 0, 0, 0.02);
  height: 32px;
  width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  font-size: 12px;
}

.col-delete-btn:hover {
  background: var(--danger-soft);
  border-color: rgba(229, 62, 62, 0.3);
  color: var(--danger);
}

.col-accordion-toggle {
  grid-column: 3;
  grid-row: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted-2);
  background: rgba(0, 0, 0, 0.02);
  height: 32px;
  width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.col-accordion-toggle:hover {
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--primary-soft);
  color: var(--primary);
}

.col-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.015);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.col-type-option {
  grid-column: 1 / -1;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 20;
}

.col-type-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.col-type-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.col-type-container {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 30;
}

.col-type-container .custom-dropdown {
  width: 100%;
}

.col-type-container .dropdown-menu {
  z-index: 6000;
}

.col-type-option .col-char-len {
  width: 88px;
  padding: 7px 10px;
}

.col-type-option .col-custom-type {
  width: 100%;
  min-width: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  padding: 7px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  outline: none;
  color: var(--text);
}

.col-type-option .col-custom-type:focus {
  border-color: var(--border-focus);
  box-shadow: var(--ring);
}

.col-option {
  min-width: 0;
  flex: unset;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.col-option input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  margin: 0;
}

.col-option i {
  font-size: 10px;
  color: var(--muted-2);
  width: 12px;
}

.col-option:hover {
  border-color: rgba(37, 99, 235, 0.25);
  background: var(--primary-soft);
}

.col-option:hover i {
  color: var(--primary);
}

/* Table shape in canvas */
.erd-node .table-shape {
  width: 200px;
  cursor: grab;
  user-select: none;
}

.erd-node .table-shape:active {
  cursor: grabbing;
}

.erd-node.selected .table-shape {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring), var(--shadow-md);
}

.table-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.table-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.table-option:hover {
  background: white;
}

.table-option input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  margin: 0;
}

.table-option i {
  font-size: 12px;
  color: var(--muted);
  width: 12px;
}

/* ─── Focus ─────────────────────────────────── */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ─── Button loading (Export PNG) ─────────────── */
.tool-btn.is-loading {
  pointer-events: none;
  opacity: 0.78;
}

.tool-btn .btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.18);
  border-top-color: rgba(0, 0, 0, 0.55);
  animation: btn-spin 0.8s linear infinite;
  vertical-align: -2px;
}

html[data-theme="dark"] .tool-btn .btn-spinner {
  border-color: rgba(255, 255, 255, 0.22);
  border-top-color: rgba(255, 255, 255, 0.65);
}

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

/* ─── Extra safety ──────────────────────────── */
.custom-dropdown.open {
  position: relative;
  z-index: 7000;
}

.custom-dropdown.open .dropdown-menu {
  z-index: 8000;
}

/* ─── Reduced motion ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Scrollbar styling ─────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ─── Selection highlight ───────────────────── */
::selection {
  background: rgba(37, 99, 235, 0.15);
  color: var(--text);
}

/* --- Landing Page Styles ----------------------- */
.landing-page {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1000;
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  transition: var(--transition-fast);
}

.nav-links a:hover {
  color: var(--text);
}

.nav-actions {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-actions a:first-child {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

.btn-black {
  background: #000;
  color: #fff;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition-normal);
}

.btn-black:hover {
  opacity: 0.85;
}

/* Hero Section */
.hero {
  padding: 6rem 0 4rem;
  text-align: center;
  position: relative;
}

.hero-title {
  font-size: 5.5rem;
  font-weight: 850;
  letter-spacing: -3px;
  line-height: 0.95;
  margin-bottom: 2rem;
}

.hero-title span {
  display: block;
  opacity: 0.5;
}

.hero-subtitle {
  color: var(--muted);
  font-size: 1.25rem;
  max-width: 600px;
  margin: 0 auto 3rem;
  line-height: 1.6;
}

.hero-btns {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 5rem;
}

.btn-hero-primary {
  background: #000;
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 0.75rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition-normal);
}

.btn-hero-secondary {
  background: #fff;
  color: #000;
  padding: 1rem 2rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.125rem;
  transition: var(--transition-normal);
}

/* AI Prompt Bar */
.ai-bar-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.ai-input-wrapper {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  gap: 1rem;
}

.ai-input {
  flex: 1;
  border: none;
  font-size: 1.125rem;
  outline: none;
}

.btn-generate {
  background: #e5e5e5;
  color: #999;
  padding: 0.6rem 1.5rem;
  border-radius: 0.75rem;
  border: none;
  font-weight: 600;
  cursor: not-allowed;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-tags {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 0;
  border-top: 1px solid #f0f0f0;
  flex-wrap: wrap;
}

.tag {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.tag:hover {
  background: var(--primary-soft);
  color: var(--text);
}

/* Stats Section */
.stats {
  padding: 4rem 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.stat-item h3 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.stat-item p {
  color: var(--muted);
  font-size: 1rem;
}

/* Section Label */
.section-label {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #f0f0f0;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 2rem;
}

/* How It Works */
.how-it-works {
  padding: 8rem 0;
  text-align: center;
}

.section-title {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -2px;
  margin-bottom: 4rem;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  text-align: left;
}

.step-card {
  padding: 2.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  height: 100%;
}

.step-num {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 3rem;
  display: block;
}

.step-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.step-desc {
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.6;
}

/* Pricing Section */
.pricing {
  padding: 8rem 0;
  text-align: center;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-top: 4rem;
}

.pricing-card {
  padding: 3rem 2rem;
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  text-align: left;
  display: flex;
  flex-direction: column;
}

.pricing-card.popular {
  border-color: #000;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.popular-badge {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: #000;
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.plan-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.plan-price {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 2rem;
}

.plan-price span {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  flex: 1;
}

.plan-features li {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
}

.plan-features li i {
  color: #16a34a;
}

.btn-pricing {
  width: 100%;
  padding: 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: var(--transition-normal);
}

.btn-pricing.outline {
  border: 1px solid var(--border);
  color: #000;
}

.btn-pricing.solid {
  background: #000;
  color: #fff;
}

/* Footer */
.footer {
  padding: 4rem 0;
  border-top: 1px solid var(--border);
  background: #fafafa;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 4rem;
}

.footer-desc {
  max-width: 300px;
  color: var(--muted);
  margin-top: 1.5rem;
}

.footer-links h4 {
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.footer-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links li {
  margin-bottom: 0.75rem;
}

.footer-links a {
  text-decoration: none;
  color: var(--muted);
  transition: var(--transition-fast);
}

.footer-links a:hover {
  color: var(--text);
}

.footer-bottom {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Dark mode tweaks */
html[data-theme="dark"] .navbar {
  background: #000;
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .ai-bar-container {
  background: #111;
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .ai-input {
  background: transparent;
  color: #fff;
}

html[data-theme="dark"] .tag {
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .step-card,
html[data-theme="dark"] .pricing-card {
  background: #111;
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .footer {
  background: #000;
  border-top-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .section-label {
  background: #222;
}

html[data-theme="dark"] .btn-hero-secondary {
  background: #111;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .btn-black,
html[data-theme="dark"] .btn-hero-primary,
html[data-theme="dark"] .btn-pricing.solid {
  background: #fff;
  color: #000;
}

html[data-theme="dark"] .pricing-card.popular {
  border-color: #fff;
}

html[data-theme="dark"] .popular-badge {
  background: #fff;
  color: #000;
}

@media (max-width: 1024px) {
  .hero-title {
    font-size: 4rem;
  }

  .steps-grid,
  .pricing-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .hero-title {
    font-size: 3rem;
  }

  .steps-grid,
  .pricing-grid,
  .stats,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }
}

/* --- Modern Landing Page ----------------------- */
:root {
  --hero-font-size: clamp(3rem, 10vw, 7rem);
  --footer-bg: #000;
  --footer-text: #fff;
}

.landing-page {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  background-color: var(--bg);
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* Navbar: Backdrop Blur 2xl */
.navbar-landing {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 9999;
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border);
  height: 72px;
  display: flex;
  align-items: center;
}

.navbar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}

.logo-block {
  background: #000;
  color: #fff;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: -1px;
}

.nav-links {
  display: flex;
  gap: 2.5rem;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
}

.nav-links a:hover {
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.btn-login {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
}

.btn-get-started {
  background: #000;
  color: #fff;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
  transition: opacity var(--transition-normal);
}

.btn-get-started:hover {
  opacity: 0.85;
}

.mobile-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

.mobile-hamburger span {
  width: 24px;
  height: 2px;
  background: var(--text);
  transition: transform 0.3s;
}

/* Hero Section: Concentric Circles & Clamp Headline */
.hero-section {
  padding-top: 160px;
  padding-bottom: 80px;
  position: relative;
  text-align: center;
  overflow: hidden;
}

.hero-bg-accent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
}

.circle {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid var(--border);
  animation: breathe 8s infinite alternate ease-in-out;
}

.circle-1 {
  width: 500px;
  height: 500px;
  animation-delay: 0s;
}

.circle-2 {
  width: 800px;
  height: 800px;
  animation-delay: 2s;
}

.circle-3 {
  width: 1100px;
  height: 1100px;
  animation-delay: 4s;
}

@keyframes breathe {
  0% {
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0.3;
  }

  100% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 0.6;
  }
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-soft);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2rem;
  border: 1px solid var(--border-strong);
}

.ping-badge {
  width: 8px;
  height: 8px;
  background: #16a34a;
  border-radius: 50%;
  position: relative;
}

.ping-badge::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: inherit;
  border-radius: inherit;
  animation: ping 1.5s infinite;
}

@keyframes ping {

  75%,
  100% {
    transform: scale(3.5);
    opacity: 0;
  }
}

.hero-headline {
  font-size: var(--hero-font-size);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.9;
  margin-bottom: 2.5rem;
  color: #000;
}

.hero-headline .text-muted {
  opacity: 0.35;
}

.hero-subtext {
  font-size: 1.25rem;
  color: var(--muted);
  max-width: 650px;
  margin: 0 auto 3.5rem;
  line-height: 1.6;
}

.hero-cta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 6rem;
}

.btn-hero-primary {
  background: #000;
  color: #fff;
  padding: 1.2rem 2.8rem;
  border-radius: 1rem;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s;
}

.btn-hero-primary:hover {
  transform: translateY(-4px);
}

.btn-hero-secondary {
  background: var(--surface-elevated);
  color: var(--text);
  padding: 1.2rem 2.8rem;
  border-radius: 1rem;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.15rem;
  border: 1px solid var(--border);
  transition: background 0.2s;
}

/* AI Composer */
.ai-composer-container {
  max-width: 800px;
  margin: 0 auto;
}

.ai-composer {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 1.25rem;
  box-shadow: var(--shadow-xl);
}

.ai-input-group {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.25rem;
}

.ai-icon {
  font-size: 1.5rem;
  color: #6366f1;
}

.ai-composer-input {
  flex: 1;
  border: none;
  font-size: 1.2rem;
  outline: none;
  font-weight: 400;
}

.btn-generate-ai {
  background: #000;
  color: #fff;
  border: none;
  border-radius: 1rem;
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.ai-chips {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #f1f1f1;
  flex-wrap: wrap;
}

.chip {
  background: var(--bg-warm);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover {
  background: #000;
  color: #fff;
  border-color: #000;
}

/* Browser Chrome Video Preview */
.video-preview-section {
  padding: 40px 0 100px;
}

.browser-chrome {
  background: #fff;
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.1);
}

.browser-header {
  height: 48px;
  background: #f8f8f8;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 2rem;
  border-bottom: 1px solid var(--border);
}

.browser-dots {
  display: flex;
  gap: 8px;
}

.browser-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd;
}

.browser-url {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 28px;
  flex: 1;
  max-width: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  gap: 0.5rem;
}

.browser-content {
  position: relative;
  aspect-ratio: 16/9;
}

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

.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.browser-content:hover .preview-overlay {
  opacity: 1;
}

.play-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #fff;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 5px;
}

/* Stats Bar */
.stats-bar {
  border-top: 1px solid var(--border);
  padding: 6rem 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3rem;
  text-align: center;
}

.stat-number {
  font-size: 3.5rem;
  font-weight: 850;
  letter-spacing: -2px;
  margin-bottom: 0.5rem;
  color: #000;
}

.stat-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

/* How It Works (No Gap Grid) */
.how-it-works-section {
  padding: 100px 0;
  background: #fafafa;
}

.badge {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 4rem;
}

.steps-grid-no-gap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: 2rem;
  overflow: hidden;
  background: #fff;
}

.step-card-alt {
  padding: 4rem 3.5rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.step-card-alt:last-child {
  border-right: none;
}

.step-index {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 3.5rem;
}

.step-name {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.step-description {
  font-size: 1.15rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Features (Hover Lift + Inversion) */
.features-section {
  padding: 120px 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

.feature-card-lift {
  padding: 3rem;
  border-radius: 2rem;
  border: 1px solid var(--border);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: #fff;
  cursor: pointer;
}

.feature-card-lift:hover {
  transform: translateY(-12px);
  background: #000;
  border-color: #000;
  color: #fff;
}

.feature-icon {
  width: 56px;
  height: 56px;
  background: var(--bg-warm);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 2rem;
  transition: all 0.4s;
}

.feature-card-lift:hover .feature-icon {
  background: #fff;
  color: #000;
}

.feature-card-lift p {
  color: var(--muted);
  transition: color 0.4s;
}

.feature-card-lift:hover p {
  color: rgba(255, 255, 255, 0.7);
}

/* Pricing (Pop Highlight) */
.pricing-section {
  padding: 120px 0;
  background: #fdfdfd;
}

.pricing-grid-main {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.5rem;
}

.pricing-card-v2 {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 2.5rem;
  padding: 3.5rem 2.5rem;
  display: flex;
  flex-direction: column;
}

.pricing-pop {
  border-color: #000;
  border-width: 2px;
  position: relative;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.08);
  transform: scale(1.05);
  z-index: 2;
}

.pop-label {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: #000;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.plan-type {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.plan-price-v2 {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 2.5rem;
}

.plan-price-v2 span {
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 600;
  margin-left: 0.25rem;
}

.plan-list {
  list-style: none;
  padding: 0;
  margin: 0 0 3.5rem;
  flex: 1;
}

.plan-list li {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.plan-list li i {
  color: #16a34a;
  font-size: 0.9rem;
}

.btn-plan {
  width: 100%;
  padding: 1.25rem;
  border-radius: 1rem;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.2s;
}

.btn-plan-pro {
  background: #000;
  color: #fff;
  border-color: #000;
}

/* Testimonials */
.testimonials-section {
  padding: 80px 0 120px;
}

.testimonials-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3rem;
}

.testimonial-card {
  padding: 3rem;
  background: #fff;
  border-radius: 2rem;
  border: 1px solid var(--border);
  transition: transform 0.3s;
}

.testimonial-card:hover {
  transform: translateY(-8px);
}

.star-rating {
  color: #f59e0b;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.testimonial-card p {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.author-info {
  display: flex;
  flex-direction: column;
}

/* Footer: Gradient Divider & Layout */
.landing-footer {
  background: #fff;
  padding-bottom: 4rem;
}

.footer-gradient-divider {
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin-bottom: 6rem;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6rem;
}

.footer-brand-side p {
  max-width: 300px;
  color: var(--muted);
  margin-top: 1.5rem;
}

.footer-links-side {
  display: flex;
  gap: 6rem;
}

.footer-col h5 {
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.footer-col a {
  display: block;
  text-decoration: none;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.footer-col a:hover {
  color: var(--text);
}

.footer-bottom-v2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 2rem;
  border-top: 1px solid #f1f1f1;
  color: var(--muted);
  font-size: 0.9rem;
}

.social-icons {
  display: flex;
  gap: 1.5rem;
}

.social-icons a {
  color: var(--muted);
  transition: color 0.2s;
}

.social-icons a:hover {
  color: var(--text);
}

/* Scroll Revelations */
.reveal-fade {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reveal-fade.active {
  opacity: 1;
  transform: translateY(0);
}

.reveal-blur {
  opacity: 0;
  filter: blur(12px);
  transform: scale(0.95);
  transition: all 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reveal-blur.active {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

/* Responsive */
@media (max-width: 1024px) {
  .nav-links {
    display: none;
  }

  .mobile-hamburger {
    display: flex;
  }

  .steps-grid-no-gap,
  .pricing-grid-main,
  .stats-grid,
  .features-grid,
  .testimonials-grid {
    grid-template-columns: 1fr;
  }

  .step-card-alt {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .pricing-pop {
    transform: none;
    margin: 2rem 0;
  }

  .footer-content {
    flex-direction: column;
    gap: 4rem;
  }
}

@media (max-width: 768px) {
  .hero-headline {
    font-size: 3.5rem;
  }

  .hero-cta {
    flex-direction: column;
  }

  .btn-hero-primary,
  .btn-hero-secondary {
    width: 100%;
    justify-content: center;
  }
}

/* --- Layout Compression ----------------------- */
:root {
  --hero-font-size: clamp(2.5rem, 8vw, 5.5rem);
  /* Smaller clamp */
}

/* Hero Compression */
.hero-section {
  padding-top: 120px;
  padding-bottom: 60px;
}

.hero-subtext {
  font-size: 1.125rem;
  margin: 0 auto 2.5rem;
  max-width: 580px;
}

.btn-hero-primary,
.btn-hero-secondary {
  padding: 1rem 2.2rem;
  font-size: 1.05rem;
}

.ai-composer {
  padding: 1rem;
  border-radius: 1.5rem;
}

.ai-composer-input {
  font-size: 1.05rem;
}

.chip {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
}

/* Stats Bar Compression */
.stats-bar {
  padding: 4rem 0;
}

.stat-number {
  font-size: 2.75rem;
}

/* How It Works Compression */
.section-title {
  font-size: 2.75rem;
  margin-bottom: 3rem;
}

.step-card-alt {
  padding: 3rem 2.5rem;
}

.step-name {
  font-size: 1.75rem;
}

.step-description {
  font-size: 1.05rem;
}

/* Features Compression */
.feature-card-lift {
  padding: 2.25rem;
}

.feature-icon {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

/* Pricing Compression */
.pricing-section {
  padding: 80px 0;
}

.pricing-card-v2 {
  padding: 2.5rem 2rem;
  border-radius: 2rem;
}

.plan-price-v2 {
  font-size: 3.25rem;
}

.plan-list {
  margin-bottom: 2.5rem;
}

.plan-list li {
  font-size: 0.95rem;
}

.btn-plan {
  padding: 1rem;
}

/* Testimonials Compression */
.testimonial-card {
  padding: 2.25rem;
}

.testimonial-card p {
  font-size: 1.1rem;
}

/* Footer Compression */
.footer-gradient-divider {
  margin-bottom: 4rem;
}

.footer-content {
  margin-bottom: 4rem;
}

.footer-links-side {
  gap: 4rem;
}

/* ─── Auth Pages ─────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  background: var(--bg-warm);
  color: var(--text);
}

.auth-shell .btn-outline {
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--surface-solid);
}

.auth-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 0 40px;
}

.auth-main.auth-main--single {
  grid-template-columns: 1fr;
}

.auth-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-solid);
  box-shadow: var(--shadow-lg);
  padding: 26px 26px 24px;
  min-height: 380px;
}

.auth-card.auth-card--compact {
  padding: 26px 26px 24px;
}

.auth-header h1 {
  font-size: 1.55rem;
  margin-bottom: 5px;
  letter-spacing: -0.03em;
}

.auth-eyebrow {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted-2);
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtext {
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.45;
  font-size: 0.9rem;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-label {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.auth-input {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface-solid);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.auth-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--ring);
  background: var(--surface-solid);
}

.auth-submit {
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  font-weight: 700;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-top: 6px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 16px 0 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-google {
  width: 100%;
  justify-content: center;
  gap: 8px;
  border-color: var(--border-strong);
  color: var(--text-secondary);
  background: var(--surface-solid);
  padding: 10px 14px;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
}

.auth-google:hover {
  background: var(--primary-soft);
  border-color: var(--border-focus);
  color: var(--text);
}

.auth-google-icon {
  width: 16px;
  height: 16px;
}

.auth-alert {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.auth-error {
  color: var(--danger);
  font-size: 0.75rem;
}

.auth-footer {
  margin-top: 12px;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.auth-footer a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-side {
  display: flex;
  justify-content: center;
}

.auth-side-card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow-md);
  max-width: 360px;
}

.auth-side-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 16px;
}

.auth-side-card h2 {
  font-size: 1.35rem;
  margin-bottom: 12px;
}

.auth-side-card p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
}

.auth-side-meta {
  display: grid;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-side-label {
  display: inline-block;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

@media (max-width: 640px) {
  .auth-main {
    max-width: 100%;
    padding: 20px 16px 28px;
  }

  .auth-card,
  .auth-card.auth-card--compact {
    padding: 22px 18px;
  }
}

/* ─── Directory Styles ─────────────────────── */
.wf-directory {
  margin-bottom: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.wf-directory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-warm);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

.wf-directory-header:hover {
  background: var(--primary-soft);
}

.wf-directory-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.wf-directory-title i {
  color: var(--muted);
  font-size: 18px;
}

.wf-directory-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: var(--primary-soft);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.wf-directory-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.wf-directory-menu-btn:hover {
  background: var(--primary-soft);
  color: var(--text);
}

.wf-directory-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  min-height: 100px;
  transition: background var(--transition-fast);
}

.wf-directory-content.wf-drag-over {
  background: var(--primary-soft);
  border: 2px dashed var(--border-strong);
}

/* Dragging styles */
.wf-card.wf-dragging {
  opacity: 0.5;
}

.wf-card[draggable="true"] {
  cursor: grab;
}

.wf-card[draggable="true"]:active {
  cursor: grabbing;
}

.wf-related-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 8px;
  background: var(--success-soft);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  color: var(--success);
}

.wf-related-badge i {
  font-size: 10px;
}

/* Keep previous card design; shorten directory length without grid gaps */
.wf-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.wf-grid-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wf-directory {
  width: 100%;
  margin: 0;
}

.wf-directory-header {
  padding: 10px 12px;
}

.wf-directory-title {
  font-size: 14px;
}

.wf-directory-content {
  padding: 10px;
  gap: 10px;
}

/* Improve workflow card actions */
.wf-card {
  position: relative;
  padding-right: 150px;
  align-items: stretch;
}

.wf-card-header {
  align-self: flex-start;
}

.wf-card-menu-btn {
  position: absolute;
  top: 10px;
  right: 10px;
}

.wf-card-body {
  min-width: 0;
}

.wf-card-actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  margin-left: 0;
  align-self: auto;
}

.wf-btn-open {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 8px 14px;
}

@media (min-width: 1700px) {
  .wf-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .wf-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .wf-grid {
    grid-template-columns: 1fr;
  }
}