/* Que UI — Font Imports */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* Que UI — Design System Variables */
:root {
  /* Brand */
  --brand-green: #00c97b;
  --brand-green-dark: #0a8a55;

  /* Background Tiers */
  --bg-base: #0A0A0A;
  --bg-surface: #111111;
  --bg-elevated: #1A1A1A;
  --bg-overlay: #222222;

  /* Borders & Dividers */
  --border-subtle: #1E1E1E;
  --border-default: #2A2A2A;
  --border-strong: #333333;

  /* Text Hierarchy */
  --text-primary: #EDEDED;
  --text-secondary: #A0A0A0;
  --text-tertiary: #666666;
  --text-disabled: #444444;

  /* Accent (derived from brand green #00c97b) */
  --accent: #00c97b;
  --accent-hover: #00b06c;
  --accent-muted: rgba(0, 201, 123, 0.15);
  --accent-border: rgba(0, 201, 123, 0.25);

  /* Semantic Colors */
  --success: #00c97b;
  --warning: #F5A623;
  --error: #E5484D;
  --info: #3B82F6;

  /* Typography */
  --font-brand: 'Space Grotesk', sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* Spacing & Interaction */
  --radius-card: 8px;
  --radius-button: 6px;
  --radius-badge: 4px;
  --transition: 150ms ease;
}

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

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-primary);
  background: var(--bg-base);
  color-scheme: dark;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Layout */
#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
}

.logo {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-default);
  height: 61px;
}

.logo-icon {
  width: 14px;
  height: 22px;
  color: var(--brand-green);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: var(--brand-green);
}

.logo-tld {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: 18px;
  color: var(--text-tertiary);
  letter-spacing: -0.5px;
}

.plan-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-muted);
  color: var(--brand-green);
  border: 1px solid var(--accent-border);
  margin-left: auto;
}

.nav-links {
  list-style: none;
  padding: 12px;
  flex: 1;
}

.nav-group-label {
  font-family: var(--font-brand);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  padding: 12px 12px 4px;
}

.nav-group-label:first-child {
  padding-top: 0;
}

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.sidebar-user-icon {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.sidebar-user-email {
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-button);
  transition: var(--transition);
  font-size: 13px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Icon inside buttons (inline left) */
.btn-icon-left {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-links a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-links a.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
}

.content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-base);
  height: 61px;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  color: var(--text-primary);
}

#page-content {
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  flex: 1;
}

/* Page visibility */
.page {
  display: block;
}

.hidden {
  display: none !important;
}

.page.hidden {
  display: none;
}

/* Banner */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  margin-bottom: 16px;
  font-size: 13px;
}

.banner-warning {
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.3);
  color: var(--warning);
}

.banner-link {
  color: var(--warning);
  text-decoration: underline;
  font-weight: 500;
  white-space: nowrap;
  margin-left: 16px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 20px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
}

.stat-label {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 13px;
}

/* Sections */
.section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-default);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  max-height: 70vh;
  overflow-y: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.table-wrapper .table {
  border: none;
  border-radius: 0;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 2;
}

.table th::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border-subtle);
}

/* Sortable columns */
.table th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 28px;
  transition: color var(--transition);
}

.table th[data-sort]:hover {
  color: var(--text-secondary);
}

.table th[data-sort] .sort-indicator {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  font-size: 8px;
  line-height: 1;
  color: var(--text-disabled);
  transition: color var(--transition);
}

.table th[data-sort].sort-asc .sort-indicator .sort-asc-icon,
.table th[data-sort].sort-desc .sort-indicator .sort-desc-icon {
  color: var(--accent);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--bg-elevated);
  transition: background-color 150ms ease;
}

.mono,
.table td.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

/* Truncated text with tooltip */
.table td.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.table td.truncate[data-full]:hover::after {
  content: attr(data-full);
  position: absolute;
  left: 8px;
  top: calc(100% + 2px);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-badge);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
  white-space: normal;
  max-width: 320px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Info-hint tooltip (e.g. "?" icon with hover popover) */
.info-hint {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  font-size: 11px;
  cursor: help;
  flex-shrink: 0;
}
.info-hint .info-hint-text {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-badge);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: normal;
  width: 280px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.info-hint:hover .info-hint-text {
  display: block;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid;
}

.status-pending {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.25);
}

.status-running {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
  border-color: rgba(59, 130, 246, 0.25);
}

.status-completed {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.status-failed {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

.status-cancelled {
  background: rgba(102, 102, 102, 0.15);
  color: var(--text-tertiary);
  border-color: rgba(102, 102, 102, 0.25);
}

.status-connected {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.status-disconnected {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-button);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn-danger {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border: 1px solid rgba(229, 72, 77, 0.25);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(229, 72, 77, 0.25);
}

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

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

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

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

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

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

.select option {
  background: #1A1A1A;
  color: #EDEDED;
}

/* Prevent browser autofill from overriding dark theme */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active,
.textarea:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 9999px #0A0A0A inset !important;
  -webkit-text-fill-color: #EDEDED !important;
  border-color: var(--border-default) !important;
  background-color: #0A0A0A !important;
  background-clip: content-box !important;
  transition: background-color 5000s ease-in-out 0s;
  caret-color: #EDEDED;
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 1px var(--accent-border);
}

.textarea {
  resize: vertical;
  min-height: 100px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.input-group .input {
  flex: 1;
}

/* Page Actions */
.page-actions {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.page-actions .select {
  width: auto;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

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

.modal.closing {
  opacity: 0;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  transform: translateY(8px) scale(0.98);
  transition: transform 200ms ease;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal.visible .modal-content {
  transform: translateY(0) scale(1);
}

.modal.closing .modal-content {
  transform: translateY(4px) scale(0.99);
  transition: transform 150ms ease;
}

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

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  border-radius: var(--radius-badge);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

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

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

.modal-footer {
  padding: 16px 24px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: none;
}

.modal-footer:not(:empty) {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Text utilities */
.text-muted {
  color: var(--text-tertiary);
}

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

/* Code blocks */
pre {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-button);
  padding: 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 18px;
}

/* Empty states (base — overridden below with full component styles) */

/* Action buttons in tables */
.actions {
  display: flex;
  gap: 4px;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 24px;
  transition: var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #000;
}

/* Mobile Menu Button (hidden on desktop) */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-button);
  transition: var(--transition);
}

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

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

/* Sidebar backdrop (hidden on desktop, used by mobile drawer) */
.sidebar-backdrop {
  display: none;
}

/* Run Detail Page */
.run-detail {
  max-width: 900px;
  width: 100%;
}

.run-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.run-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.run-id {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.run-times {
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

/* Conversation Thread */
.conversation {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.message-header {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.message-role {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-time {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.message-content {
  padding: 16px;
  font-size: 13px;
  line-height: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-mono);
  max-height: 500px;
  overflow-y: auto;
}

.message-user {
  background: var(--bg-surface);
}

.message-user .message-header {
  background: var(--bg-elevated);
  color: var(--info);
}

.message-user .message-content {
  background: var(--bg-surface);
}

.message-assistant {
  background: var(--bg-surface);
}

.message-assistant .message-header {
  background: var(--accent-muted);
  color: var(--accent);
}

.message-assistant .message-content {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.message-error {
  background: var(--bg-surface);
}

.message-error .message-header {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
}

.message-error .message-content {
  background: var(--bg-surface);
  color: var(--error);
}

.message-pending {
  background: var(--bg-surface);
}

.message-pending .message-header {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
}

.message-pending .message-content {
  color: var(--text-secondary);
  font-style: italic;
}

/* Clickable table rows */
.table tr.clickable {
  cursor: pointer;
}

.table tr.clickable:hover td {
  background: var(--bg-elevated);
}

/* Content Max Width */
#page-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* Empty states — full component */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  color: var(--brand-green);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-muted);
  border-radius: 12px;
  padding: 12px;
}

.empty-state-icon svg {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  font-family: var(--font-brand);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
  max-width: 340px;
}

.empty-state .btn {
  margin-top: 16px;
}

/* Empty state inside table cells */
.table td.empty-state {
  padding: 48px 24px;
}

/* Empty state inside table row — prevent hover effect */
.table tr:has(> td.empty-state):hover td {
  background: transparent;
}

/* Specular Highlight — subtle light catching on card edges */
.stat-card::before,
.section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.04),
    transparent
  );
  pointer-events: none;
}

.stat-card,
.section {
  position: relative;
}

/* Smooth scrollbar styling for dark mode */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

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

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

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-tertiary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 12px;
  height: 12px;
  border-width: 1.5px;
}

.spinner-lg {
  width: 24px;
  height: 24px;
  border-width: 2.5px;
}

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

/* Stat card loading state */
.stat-card.loading .stat-value {
  display: flex;
  align-items: center;
  min-height: 32px;
}

/* Table loading row */
.table-loading-row td {
  text-align: center;
  padding: 24px 16px;
}

.table-loading-row:hover td {
  background: transparent !important;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* Button loading state */
.btn.btn-loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.btn.btn-loading .spinner {
  border-color: currentColor;
  border-top-color: transparent;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  border-left: 3px solid var(--border-default);
  animation: toast-in 200ms ease forwards;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.toast.toast-out {
  animation: toast-out 200ms ease forwards;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--error);
}

.toast-info {
  border-left-color: var(--info);
}

.toast-warning {
  border-left-color: var(--warning);
}

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

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

/* Run Timeline — Resend-style event flow */
.run-timeline {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 24px 28px;
  margin-bottom: 16px;
  position: relative;
}

.timeline-steps {
  display: flex;
  align-items: flex-start;
  position: relative;
}

.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Connecting lines between nodes */
.timeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 15px;
  left: calc(50% + 18px);
  width: calc(100% - 36px);
  height: 2px;
  background: none;
  border-bottom: 2px dotted var(--border-strong);
}

.timeline-step.step-reached:not(:last-child)::after {
  border-bottom-style: solid;
}

.timeline-step.step-reached.step-queued:not(:last-child)::after {
  border-bottom-color: var(--warning);
}

.timeline-step.step-reached.step-running:not(:last-child)::after {
  border-bottom-color: var(--info);
}

.timeline-step.step-reached.step-completed:not(:last-child)::after {
  border-bottom-color: var(--success);
}

.timeline-step.step-reached.step-failed:not(:last-child)::after {
  border-bottom-color: var(--error);
}

/* Node circle */
.timeline-node {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 2px solid var(--border-default);
  background: var(--bg-base);
  color: var(--text-disabled);
  transition: all 200ms ease;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.timeline-node svg {
  width: 16px;
  height: 16px;
}

.timeline-step.step-reached .timeline-node {
  border-color: transparent;
}

.timeline-step.step-reached.step-queued .timeline-node {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.35);
}

.timeline-step.step-reached.step-running .timeline-node {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
  border-color: rgba(59, 130, 246, 0.35);
}

.timeline-step.step-reached.step-completed .timeline-node {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.timeline-step.step-reached.step-failed .timeline-node {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

/* Active node pulse animation */
.timeline-step.step-active .timeline-node {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
  animation: timeline-pulse-blue 2s ease-in-out infinite;
}

.timeline-step.step-active.step-queued .timeline-node {
  box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.1);
  animation: timeline-pulse-amber 2s ease-in-out infinite;
}

@keyframes timeline-pulse-blue {
  0%, 100% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
  50% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.05); }
}

@keyframes timeline-pulse-amber {
  0%, 100% { box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.1); }
  50% { box-shadow: 0 0 0 8px rgba(245, 166, 35, 0.05); }
}

/* Step label */
.timeline-label {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-disabled);
  text-align: center;
}

.timeline-step.step-reached .timeline-label {
  color: var(--text-secondary);
}

.timeline-step.step-active .timeline-label {
  color: var(--text-primary);
}

/* Step timestamp */
.timeline-time {
  margin-top: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  text-align: center;
  min-height: 16px;
}

/* Search Group */
.search-group {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  padding-left: 32px;
}

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

.skill-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.skill-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.skill-card-header {
  margin-bottom: 8px;
}

.skill-card-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 20px;
}

.skill-card-slug {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

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

.skill-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.skill-card-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

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

/* Slug preview in form */
.slug-preview {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.slug-preview code {
  color: var(--accent);
  background: var(--accent-muted);
  padding: 1px 6px;
  border-radius: var(--radius-badge);
}

/* Token count */
.token-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  text-align: right;
}

/* Skills empty state */
.skills-grid .empty-state {
  grid-column: 1 / -1;
}

/* Skill Picker — Prompt Template Integration */
.prompt-template-group {
  position: relative;
}

.prompt-template-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.prompt-template-toolbar label {
  margin-bottom: 0;
}

.skill-picker-wrapper {
  position: relative;
  display: inline-block;
}

.skill-picker-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 320px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
}

.skill-picker-dropdown.visible {
  display: block;
}

.skill-picker-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-overlay);
  z-index: 1;
}

.skill-picker-search input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
}

.skill-picker-search input:focus {
  outline: none;
  border-color: var(--accent-border);
}

.skill-picker-search input::placeholder {
  color: var(--text-tertiary);
}

.skill-picker-list {
  list-style: none;
  padding: 4px;
}

.skill-picker-item {
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-button);
  transition: background var(--transition);
}

.skill-picker-item:hover,
.skill-picker-item.highlighted {
  background: var(--bg-elevated);
}

.skill-picker-item-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.skill-picker-item-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-picker-empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Inline autocomplete dropdown (appears under textarea) */
.skill-autocomplete {
  position: absolute;
  width: 280px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: none;
}

.skill-autocomplete.visible {
  display: block;
}

.skill-autocomplete-list {
  list-style: none;
  padding: 4px;
}

.skill-autocomplete-item {
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius-button);
  transition: background var(--transition);
}

.skill-autocomplete-item:hover,
.skill-autocomplete-item.highlighted {
  background: var(--bg-elevated);
}

.skill-autocomplete-item-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
}

.skill-autocomplete-item-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Referenced skills tags */
.skill-refs-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.skill-ref-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-badge);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

.skill-ref-tag.skill-ref-warning {
  background: rgba(245, 166, 35, 0.15);
  border-color: rgba(245, 166, 35, 0.25);
  color: var(--warning);
}

.skill-ref-tag svg {
  width: 12px;
  height: 12px;
}

.skill-reference {
  display: inline-block;
  padding: 2px 6px;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  transition: all 150ms ease;
}

.skill-reference:hover {
  background: var(--accent-border);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Skill Edit Page */
.skill-edit-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.skill-edit-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.skill-edit-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 20px 24px;
}

.skill-edit-header-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 16px;
}

.skill-name-group {
  margin: 0;
  min-width: 0;
}

.skill-slug-display {
  flex-shrink: 0;
  min-width: 280px;
}

.skill-slug-display label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.skill-slug {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--accent-border);
  display: block;
  font-family: var(--font-mono);
}

.skill-edit-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.skill-editor-container {
  flex: 1;
  display: flex;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  min-height: 600px;
}

.skill-editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.skill-editor-pane {
  display: flex;
  min-width: 0;
  border-right: 1px solid var(--border-subtle);
}

.skill-editor-textarea {
  width: 100%;
  height: 100%;
  padding: 16px;
  background: var(--bg-base);
  color: var(--text-primary);
  border: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  outline: none;
  tab-size: 2;
}

.skill-editor-textarea::placeholder {
  color: var(--text-tertiary);
}

.skill-preview-pane {
  overflow-y: auto;
  min-width: 0;
}

.skill-preview-content {
  padding: 20px;
  font-size: 14px;
  line-height: 22px;
  color: var(--text-primary);
}

/* Markdown preview styles */
.skill-preview-content h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-default);
}

.skill-preview-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 24px 0 12px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.skill-preview-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px 0;
}

.skill-preview-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 8px 0;
}

.skill-preview-content p {
  margin: 0 0 12px 0;
}

.skill-preview-content ul,
.skill-preview-content ol {
  margin: 0 0 12px 0;
  padding-left: 24px;
}

.skill-preview-content li {
  margin-bottom: 4px;
}

.skill-preview-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-badge);
  color: var(--accent);
}

.skill-preview-content pre {
  margin: 0 0 12px 0;
}

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

.skill-preview-content blockquote {
  border-left: 3px solid var(--accent-border);
  margin: 0 0 12px 0;
  padding: 8px 16px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-badge) var(--radius-badge) 0;
}

.skill-preview-content hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 20px 0;
}

.skill-preview-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.skill-preview-content em {
  font-style: italic;
}

.skill-preview-content a {
  color: var(--accent);
  text-decoration: none;
}

.skill-preview-content a:hover {
  text-decoration: underline;
}

/* Skill Editor Header */
.skill-editor-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.skill-editor-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.skill-meta-item {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.skill-meta-item .mono {
  color: var(--text-primary);
}

#skill-ai-edit-toggle.active {
  background: var(--accent-muted);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* AI Edit Panel */
.skill-ai-edit-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  padding: 12px;
  margin-bottom: 8px;
}

.ai-edit-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.ai-edit-instruction {
  flex: 1;
  font-size: 13px;
  min-height: 40px;
  resize: vertical;
}

.ai-edit-status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.ai-edit-result {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-edit-result-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
}

/* Skill Creation Options */
.skill-creation-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms ease;
  text-align: left;
  width: 100%;
}

.option-card:hover {
  background: var(--bg-overlay);
  border-color: var(--border-default);
}

.option-card:active {
  transform: scale(0.99);
}

.option-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-muted);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  color: var(--accent);
}

.option-icon svg,
.option-icon i {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.option-content {
  flex: 1;
  padding-top: 2px;
}

.option-content h4 {
  margin: 0 0 2px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.option-content p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Validation Badges */
.validation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid;
  white-space: nowrap;
  flex-shrink: 0;
}

.validation-badge i,
.validation-badge svg {
  width: 12px;
  height: 12px;
}

.validation-badge-valid {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.validation-badge-invalid {
  background: rgba(229, 72, 77, 0.15);
  color: var(--error);
  border-color: rgba(229, 72, 77, 0.25);
}

.validation-badge-error {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.25);
}

.validation-badge-pending {
  background: rgba(102, 102, 102, 0.15);
  color: var(--text-tertiary);
  border-color: rgba(102, 102, 102, 0.25);
}

/* Skill Card Title Row (name + badge) */
.skill-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Validation Panel (Skill Editor) */
.validation-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.validation-panel:empty {
  display: none;
}

.validation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.validation-panel-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.validation-panel-time {
  font-size: 11px;
  color: var(--text-tertiary);
}

.validation-panel-message {
  margin-top: 8px;
  font-size: 13px;
  line-height: 18px;
  padding: 8px 12px;
  border-radius: var(--radius-button);
  border-left: 3px solid;
}

.validation-panel-valid {
  background: rgba(0, 201, 123, 0.06);
  border-left-color: var(--success);
  color: var(--accent);
}

.validation-panel-pending {
  background: rgba(102, 102, 102, 0.06);
  border-left-color: var(--text-tertiary);
  color: var(--text-secondary);
}

.validation-panel-error {
  background: rgba(245, 166, 35, 0.06);
  border-left-color: var(--warning);
  color: var(--warning);
}

.validation-panel-invalid {
  background: rgba(229, 72, 77, 0.06);
  border-left-color: var(--error);
  color: var(--error);
}

/* Validation Details (expanded issues) */
.validation-panel-details {
  margin-top: 10px;
}

.validation-panel-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.validation-issue {
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-button);
  border-left: 3px solid;
  background: var(--bg-elevated);
}

.validation-issue:last-child {
  margin-bottom: 0;
}

.validation-issue-error {
  border-left-color: var(--error);
}

.validation-issue-warning {
  border-left-color: var(--warning);
}

.validation-issue-info {
  border-left-color: var(--info);
}

.validation-issue-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.validation-issue-severity {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.validation-issue-error .validation-issue-severity {
  color: var(--error);
}

.validation-issue-warning .validation-issue-severity {
  color: var(--warning);
}

.validation-issue-info .validation-issue-severity {
  color: var(--info);
}

.validation-issue-location {
  font-size: 11px;
  color: var(--text-tertiary);
}

.validation-issue-code {
  font-size: 10px;
  color: var(--text-disabled);
  margin-left: auto;
}

.validation-issue-message {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 18px;
}

.validation-issue-suggestion {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

.validation-ai-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(59, 130, 246, 0.06);
  border-radius: var(--radius-button);
  border: 1px solid rgba(59, 130, 246, 0.15);
}

/* Responsive */
@media (max-width: 768px) {
  /* --- 1. Sidebar → Slide-out Drawer --- */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
  }

  .sidebar-backdrop.visible {
    display: block;
  }

  .logo-text,
  .logo-tld,
  .nav-links span {
    display: inline; /* Show labels in drawer */
  }

  .content {
    margin-left: 0; /* Full width */
    min-width: 0;
    width: 100%;
  }

  /* --- 2. Header Adjustments --- */
  .header {
    padding: 12px 16px;
    gap: 8px;
  }

  .header h1 {
    font-size: 16px;
    flex: 1;
    min-width: 0;
  }

  .header-actions {
    flex-shrink: 0;
  }

  .header-actions .status-badge {
    font-size: 10px;
    padding: 2px 6px;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-btn {
    display: flex;
    flex-shrink: 0;
  }

  /* --- 3. Page Content Padding --- */
  #page-content {
    padding: 16px;
    overflow-x: hidden;
  }

  /* --- 4. Stats Grid --- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* --- 5. Page Actions — Wrap --- */
  .page-actions {
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* --- 6. Tables — Card Layout on Mobile --- */
  .table {
    display: block;
    border: none;
  }

  .table thead {
    display: none; /* Hide column headers */
  }

  .table tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .table tbody tr {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    padding: 12px;
    gap: 8px;
  }

  .table tbody tr:hover td {
    background: transparent;
  }

  .table tbody tr:last-child td {
    border-bottom: none;
  }

  .table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    font-size: 13px;
    border-bottom: none;
  }

  .table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    min-width: 70px;
  }

  /* Hide label for action cells */
  .table td[data-label=""]::before,
  .table td.actions::before {
    display: none;
  }

  /* Actions row: full width, evenly spaced */
  .table td.actions {
    justify-content: stretch;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
    margin-top: 2px;
  }

  .table td.actions .btn {
    flex: 1;
    justify-content: center;
  }

  /* First cell (name/title) is prominent */
  .table td:first-child {
    font-weight: 600;
    font-size: 14px;
  }

  .table td:first-child::before {
    display: none; /* Hide label for the title cell */
  }

  /* Empty state & loading rows should not be cards */
  .table td.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: none;
    padding: 48px 24px;
  }

  .table td.empty-state::before {
    display: none;
  }

  .table tr:has(> td.empty-state) {
    border: none;
    background: transparent;
    padding: 0;
  }

  .table tr.table-loading-row {
    border: none;
    background: transparent;
    padding: 0;
  }

  .table tr.table-loading-row td {
    justify-content: center;
  }

  .table tr.table-loading-row td::before {
    display: none;
  }

  /* --- 7. Run Detail Page --- */
  .run-detail {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .run-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
    margin-bottom: 12px;
  }

  .run-meta {
    flex-wrap: wrap;
  }

  /* Timeline — vertical layout */
  .timeline-steps {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .timeline-step {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex: none;
    width: 100%;
    padding: 8px 0;
  }

  /* Vertical connecting lines */
  .timeline-step:not(:last-child)::after {
    top: 40px;
    left: 15px;
    width: 2px;
    height: calc(100% - 32px);
    border-bottom: none;
    border-left: 2px dotted var(--border-strong);
  }

  .timeline-step.step-reached:not(:last-child)::after {
    border-bottom-style: none;
    border-left-style: solid;
  }

  .timeline-step.step-reached.step-queued:not(:last-child)::after {
    border-left-color: var(--warning);
    border-bottom-color: transparent;
  }

  .timeline-step.step-reached.step-running:not(:last-child)::after {
    border-left-color: var(--info);
    border-bottom-color: transparent;
  }

  .timeline-step.step-reached.step-completed:not(:last-child)::after {
    border-left-color: var(--success);
    border-bottom-color: transparent;
  }

  .timeline-step.step-reached.step-failed:not(:last-child)::after {
    border-left-color: var(--error);
    border-bottom-color: transparent;
  }

  .timeline-label {
    margin-top: 0;
    text-align: left;
  }

  .timeline-time {
    margin-top: 0;
    text-align: left;
  }

  .timeline-step-info {
    display: flex;
    flex-direction: column;
  }

  /* Conversation messages */
  .message-content {
    padding: 12px;
    max-height: 300px;
    word-break: break-word;
  }

  .run-timeline {
    padding: 16px;
    margin-bottom: 12px;
  }

  .conversation {
    gap: 12px;
  }

  /* --- 9. Skill Editor --- */
  .skill-edit-header-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .skill-slug-display {
    min-width: 0;
  }

  .skill-editor-meta {
    flex-wrap: wrap;
  }

  .skill-editor-split {
    grid-template-columns: 1fr;
    min-height: 400px;
  }

  .skill-editor-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .skill-editor-textarea {
    min-height: 200px;
  }

  .skill-editor-container {
    min-height: auto;
  }

  .skill-edit-layout {
    grid-template-columns: 1fr;
  }

  .skill-picker-dropdown {
    width: 260px;
  }

  /* --- 10. Settings & Dashboard spacing --- */
  .section {
    padding: 16px;
    margin-bottom: 12px;
  }

  .stats-grid {
    margin-bottom: 12px;
  }

  /* --- Skills Grid --- */
  .skills-grid {
    grid-template-columns: 1fr;
  }

  /* --- Invite card: stack vertically on mobile --- */
  #invite-card {
    flex-direction: column !important;
    align-items: stretch !important;
    margin-bottom: 12px !important;
  }

  #invite-card > div:last-child {
    flex-shrink: 1 !important;
  }

  #invite-card input {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* --- 11. Pagination --- */
  .pagination-container {
    flex-wrap: wrap;
    justify-content: center;
    padding: 12px;
    gap: 8px;
    background: transparent;
    border-top: none;
  }

  .pagination-per-page {
    display: none;
  }

  .pagination-summary {
    width: 100%;
    text-align: center;
  }

  /* Constrain page content width */
  #page-content {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* --- Banner: wrap on mobile --- */
  .banner {
    flex-wrap: wrap;
    gap: 8px;
  }

  .banner-link {
    margin-left: 0;
  }

  /* --- Toasts: full-width on mobile --- */
  #toast-container {
    right: 8px;
    left: 8px;
    bottom: 16px;
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  /* --- Touch targets: enlarge small buttons --- */
  .btn-sm {
    padding: 8px 12px;
    min-height: 36px;
  }

  .modal-close {
    padding: 10px;
  }

  /* --- Tooltips: constrain to viewport --- */
  .info-hint .info-hint-text {
    width: min(280px, calc(100vw - 32px));
    left: auto;
    right: -8px;
    transform: none;
  }

  /* --- Auth container: tighter padding --- */
  .auth-container {
    padding: 24px 20px;
  }

  /* --- Run times: allow wrapping --- */
  .run-times {
    word-break: break-word;
  }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  #app {
    width: 100%;
    max-width: 100vw;
  }
}

/* --- 4b. Small screens refinements --- */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 12px;
  }

  .page-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
    padding: 8px 12px;
    font-size: 13px;
  }
}

/* ──────────────────────────────────────
   Auth Page
   ────────────────────────────────────── */

.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
  padding: 24px;
}

.auth-home-link {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 150ms ease;
}

.auth-home-link:hover {
  color: var(--brand-green);
}

.auth-container {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 40px 32px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 36px;
  height: 56px;
  color: var(--brand-green);
  margin-bottom: 16px;
}

.auth-brand {
  margin-bottom: 8px;
}

.auth-logo-text {
  font-family: var(--font-brand);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--brand-green);
}

.auth-logo-tld {
  font-family: var(--font-brand);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.5px;
  color: var(--text-tertiary);
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  overflow: hidden;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.auth-tab:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.auth-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-submit-btn {
  margin-top: 4px;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  justify-content: center;
  text-align: center;
}

.auth-forgot-btn {
  width: 100%;
  font-size: 12px;
  justify-content: center;
  text-align: center;
  padding: 8px 12px;
}

.auth-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  font-size: 13px;
  line-height: 1.5;
  background: rgba(0, 201, 123, 0.08);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}

.auth-error {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  font-size: 13px;
  line-height: 1.5;
  background: rgba(229, 72, 77, 0.08);
  border: 1px solid rgba(229, 72, 77, 0.25);
  color: var(--error);
}

/* ═══════════════════════════════════════════
   Template Browser
   ═══════════════════════════════════════════ */

.template-browser-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.template-browser-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.template-browser-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.template-browser {
  position: relative;
  width: 94%;
  max-width: 960px;
  max-height: 85vh;
  margin: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform 200ms ease;
}

.template-browser-overlay.visible .template-browser {
  transform: translateY(0) scale(1);
}

.template-browser-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.template-browser-header h2 {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-brand);
  color: var(--text-primary);
  margin: 0;
}

.template-browser-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.template-browser-close:hover {
  color: var(--text-primary);
}

.template-browser-close svg {
  width: 18px;
  height: 18px;
}

#template-browser-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.template-browser-controls {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.template-browser-search {
  position: relative;
}

.template-browser-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.template-browser-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color var(--transition);
}

.template-browser-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.template-browser-search input::placeholder {
  color: var(--text-tertiary);
}

.template-category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.template-category-tab {
  padding: 5px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-badge);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.template-category-tab:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.template-category-tab.active {
  border-color: var(--accent-border);
  background: var(--accent-muted);
  color: var(--accent);
}

.template-browser-grid-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

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

.template-browser-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Template Card */
.template-card {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-card:hover {
  border-color: var(--border-default);
  background: var(--bg-elevated);
}

.template-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.template-card-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

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

.template-card-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-brand);
  line-height: 1.3;
}

.template-card-tagline {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}

.template-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.template-card-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: var(--radius-badge);
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
}

.template-card-badge.popular {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent-border);
}

.template-card-schedule {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.template-card-cost {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* Template Detail (expanded view within browser) */
.template-detail {
  padding: 20px 24px;
  flex: 1;
  overflow-y: auto;
}

.template-detail-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  transition: color var(--transition);
  font-family: var(--font-sans);
}

.template-detail-back:hover {
  color: var(--text-primary);
}

.template-detail-back svg {
  width: 14px;
  height: 14px;
}

.template-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.template-detail-icon {
  font-size: 32px;
  line-height: 1;
}

.template-detail-title {
  flex: 1;
}

.template-detail-title h3 {
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-brand);
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

.template-detail-title p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.template-detail-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.template-detail-meta-item {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.template-detail-meta-item span {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.template-detail-section {
  margin-bottom: 20px;
}

.template-detail-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.template-detail-prompt {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-button);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  max-height: 200px;
  overflow-y: auto;
}

.template-detail-output {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-button);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 240px;
  overflow-y: auto;
}

.template-detail-params {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.template-param-field label {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 500;
}

.template-param-field input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  transition: border-color var(--transition);
}

.template-param-field input:focus {
  outline: none;
  border-color: var(--accent);
}

.template-param-field input::placeholder {
  color: var(--text-tertiary);
}

.template-detail-cta {
  margin-top: 20px;
}

/* Browse templates link inside task form */
.browse-templates-link {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-sans);
  transition: color var(--transition);
}

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

/* Responsive */
@media (max-width: 640px) {
  .template-browser {
    width: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .template-browser-grid {
    grid-template-columns: 1fr;
  }

  .template-category-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* --- 8. Modal — full-screen on small screens --- */
  .modal-content {
    width: 100%;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    box-sizing: border-box;
  }

  #modal-body {
    padding: 16px;
    overflow-x: hidden;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

/* ===== Connections & Vault ===== */

/* Template browser type tabs */
.template-type-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.template-type-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

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

.template-type-tab.active {
  color: var(--brand-green, #00c97b);
  border-bottom-color: var(--brand-green, #00c97b);
}

/* Service badges */
.service-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Difficulty badges */
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.difficulty-badge.beginner {
  background: rgba(0, 201, 123, 0.1);
  color: var(--brand-green, #00c97b);
}

.difficulty-badge.intermediate {
  background: rgba(255, 170, 0, 0.1);
  color: #ffaa00;
}

.difficulty-badge.advanced {
  background: rgba(255, 68, 68, 0.1);
  color: #ff4444;
}

/* Popular badge */
.popular-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: rgba(255, 170, 0, 0.1);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #ffaa00;
}

/* Key-value editor */
.kv-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kv-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.kv-row .input {
  flex: 1;
}

.kv-row .kv-key {
  flex: 0.4;
}

.kv-row .kv-value {
  flex: 0.6;
}

.kv-remove-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kv-remove-btn:hover {
  color: var(--text-error, #ff4444);
  background: rgba(255, 68, 68, 0.1);
}

.kv-add-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: none;
  border: 1px dashed var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
}

.kv-add-btn:hover {
  border-color: var(--brand-green, #00c97b);
  color: var(--brand-green, #00c97b);
}

/* Wizard overlay */
.wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.wizard-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.wizard-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.wizard-container {
  position: relative;
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

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

.wizard-header h2 {
  font-size: 18px;
  margin: 0;
}

/* Step progress bar */
.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  gap: 0;
}

.wizard-step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: all 0.2s;
}

.wizard-step-indicator.active {
  background: var(--brand-green, #00c97b);
  border-color: var(--brand-green, #00c97b);
  color: #000;
}

.wizard-step-indicator.completed {
  background: rgba(0, 201, 123, 0.15);
  border-color: var(--brand-green, #00c97b);
  color: var(--brand-green, #00c97b);
}

.wizard-step-line {
  width: 40px;
  height: 2px;
  background: var(--border-subtle);
  transition: background 0.2s;
}

.wizard-step-line.completed {
  background: var(--brand-green, #00c97b);
}

/* Wizard content */
.wizard-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
}

.wizard-actions-left {
  display: flex;
  gap: 8px;
}

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

/* Connection test result */
.connection-test-result {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-top: 12px;
  font-size: 13px;
}

.connection-test-result.success {
  border-color: var(--brand-green, #00c97b);
  background: rgba(0, 201, 123, 0.05);
}

.connection-test-result.error {
  border-color: var(--text-error, #ff4444);
  background: rgba(255, 68, 68, 0.05);
}

.connection-test-result pre {
  background: var(--bg-elevated);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  overflow-x: auto;
  margin: 8px 0 0 0;
  max-height: 200px;
  overflow-y: auto;
}

/* Form help text */
.form-help {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
  line-height: 1.4;
}

.form-help code {
  font-size: 11px;
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--brand-green, #00c97b);
}

/* Connection status badge */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}

.connection-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.connection-status-dot.success { background: var(--brand-green, #00c97b); }
.connection-status-dot.error { background: var(--text-error, #ff4444); }
.connection-status-dot.unknown { background: var(--text-tertiary); }

/* Vault table */
.vault-preview {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* Connection reference helper */
.connection-ref-helper {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 16px;
}

.connection-ref-helper h4 {
  font-size: 13px;
  margin: 0 0 8px 0;
  color: var(--text-secondary);
}

.connection-ref-helper code {
  display: block;
  font-size: 12px;
  padding: 4px 0;
  color: var(--brand-green, #00c97b);
}

/* Skill template card extras */
.template-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* Docs instructions in wizard */
.docs-instructions {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
}

.docs-instructions ol {
  padding-left: 20px;
  margin: 8px 0;
}

.docs-instructions a {
  color: var(--brand-green, #00c97b);
}

/* Auth type conditional fields */
.auth-conditional {
  display: none;
  margin-top: 12px;
}

.auth-conditional.visible {
  display: block;
}

/* Pagination */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 13px;
  gap: 16px;
}

.pagination-summary {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-button);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0 8px;
}

.pagination-btn:hover:not([disabled]):not(.active) {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.pagination-btn.active {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 500;
}

.pagination-btn[disabled] {
  color: var(--text-disabled);
  cursor: not-allowed;
}

.pagination-ellipsis {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-disabled);
  font-size: 13px;
}

.pagination-per-page {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.pagination-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-sans);
  padding: 4px 8px;
  height: 28px;
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: auto;
}

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

.pagination-select:focus {
  outline: none;
  border-color: var(--accent);
}

.pagination-per-page-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── Onboarding Tour ── */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}

.tour-overlay.hidden { display: none; }

.tour-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

.tour-spotlight {
  position: absolute;
  border-radius: 10px;
  box-shadow: 0 0 15px 4px rgba(0, 201, 123, 0.35), 0 0 40px 8px rgba(0, 201, 123, 0.15);
  animation: tour-pulse 2.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 1201;
}

@keyframes tour-pulse {
  0%, 100% { box-shadow: 0 0 15px 4px rgba(0, 201, 123, 0.35), 0 0 40px 8px rgba(0, 201, 123, 0.15); }
  50% { box-shadow: 0 0 25px 8px rgba(0, 201, 123, 0.5), 0 0 60px 16px rgba(0, 201, 123, 0.2); }
}

.tour-highlight {
  position: relative;
  z-index: 1202 !important;
}

/* Tour panel — fixed bottom-left speech box */
.tour-panel {
  position: fixed;
  bottom: 24px;
  left: 24px;
  right: 24px;
  max-width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  pointer-events: auto;
  z-index: 1203;
  box-shadow: 0 0 20px rgba(0, 201, 123, 0.08), 0 8px 32px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
  .tour-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

.tour-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tour-panel-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.tour-minimize-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-badge);
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition), border-color var(--transition);
}

.tour-minimize-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Minimized pill state */
.tour-panel-minimized {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  max-width: 220px;
}

.tour-pill-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.tour-pill-btn {
  padding: 3px 10px;
  font-size: 11px;
}

.tour-step-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-right: 2px;
}

.tour-crumb-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-green);
}

.tour-panel-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.tour-panel-nav {
  display: flex;
  gap: 8px;
}

.tour-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-button);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  pointer-events: auto;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.tour-nav-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-overlay);
}

.tour-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.tour-nav-next {
  background: var(--accent-muted);
  border-color: var(--accent-border);
  color: var(--brand-green);
}

.tour-nav-next:hover:not(:disabled) {
  background: rgba(0, 201, 123, 0.2);
  border-color: var(--brand-green);
  color: var(--brand-green);
}

.tour-nav-exit {
  margin-left: auto;
}
