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

.btn:disabled { opacity: .45; pointer-events: none; }

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

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

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

.btn-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid transparent;
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-icon {
  padding: 6px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--r-sm);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }

/* ── Form controls ── */
.field { display: flex; flex-direction: column; gap: var(--s-1); }

.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.label-null {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: auto;
  cursor: pointer;
}

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 7px 10px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

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

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

.input-mono { font-family: var(--font-mono); font-size: 12.5px; }

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

.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}

.input-null {
  opacity: .4;
  font-style: italic;
  color: var(--text-muted);
}

/* ── Tags / chips ── */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  padding: 6px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-height: 36px;
  align-items: center;
  cursor: text;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.tag-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  cursor: default;
}

.tag-chip-remove {
  cursor: pointer;
  opacity: .6;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.tag-chip-remove:hover { opacity: 1; }

.tag-input-inner {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-primary);
  min-width: 80px;
  flex: 1;
}

/* Media type colors */
.media-text  { background: rgba(167,139,250,.15); color: var(--media-text); }
.media-image { background: rgba(52,211,153,.15); color: var(--media-image); }
.media-video { background: rgba(248,113,113,.15); color: var(--media-video); }
.media-audio { background: rgba(251,191,36,.15); color: var(--media-audio); }
.media-file  { background: rgba(96,165,250,.15); color: var(--media-file); }

/* ── Status badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all var(--t-fast);
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
}
.status-active   { background: var(--success-light); color: var(--success); }
.status-stopped  { background: var(--danger-light);  color: var(--danger); }

/* ── Cards ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  cursor: pointer;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: var(--s-4) 0; }

/* ── Grid layouts ── */
.form-grid { display: grid; gap: var(--s-4); }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Curl editor ── */
.curl-editor {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
  min-height: 120px;
  outline: none;
  color: var(--text-primary);
}

.curl-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* Syntax highlight spans */
.syn-var     { color: var(--syntax-var); }
.syn-js      { color: var(--syntax-js); }
.syn-bracket { color: var(--syntax-bracket); }
.syn-string  { color: var(--syntax-string); }
.syn-flag    { color: var(--text-muted); }

/* ── JSON viewer ── */
.json-viewer {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  overflow: auto;
  max-height: 400px;
}

.json-key   { color: var(--info); }
.json-str   { color: var(--syntax-string); }
.json-num   { color: var(--warning); }
.json-bool  { color: var(--accent); }
.json-null  { color: var(--text-muted); font-style: italic; }
.json-path-clickable { cursor: pointer; border-bottom: 1px dashed currentColor; }
.json-path-clickable:hover { opacity: .7; }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--s-4); }

.tab {
  padding: var(--s-2) var(--s-4);
  font-size: 13.5px;
  font-weight: 450;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* ── Drag handle ── */
.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  padding: var(--s-1);
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

/* ── Version card ── */
.version-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: box-shadow var(--t-fast);
}
.version-card.dragging { opacity: .4; box-shadow: var(--shadow-lg); }
.version-card-header {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  cursor: pointer;
  user-select: none;
}
.version-card-header:hover { background: var(--bg-hover); }
.version-card-body {
  padding: var(--s-4);
  border-top: 1px solid var(--border);
}

/* ── Endpoint list item ── */
.endpoint-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
}
.endpoint-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn var(--t-fast) ease;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  width: min(640px, 95vw);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp var(--t-base) ease;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-body { flex: 1; overflow-y: auto; padding: var(--s-6); }
.modal-footer {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
}

/* ── Command palette ── */
.cmd-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 200;
}
.cmd-box {
  width: min(560px, 90vw);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideDown var(--t-base) ease;
}
.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.cmd-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-primary);
}
.cmd-results { max-height: 320px; overflow-y: auto; }
.cmd-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  cursor: pointer;
  transition: background var(--t-fast);
}
.cmd-item:hover, .cmd-item.highlighted { background: var(--bg-active); }
.cmd-item-icon { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--bg-base); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cmd-item-text { flex: 1; }
.cmd-item-title { font-size: 13.5px; font-weight: 500; }
.cmd-item-sub   { font-size: 11.5px; color: var(--text-muted); }
.cmd-hint { padding: var(--s-3) var(--s-5); display: flex; justify-content: flex-end; }
.cmd-key { font-family: var(--font-mono); font-size: 11px; background: var(--bg-base); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--text-muted); }

/* ── Misc ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-10);
  color: var(--text-muted);
  text-align: center;
}
.empty-state-icon { font-size: 36px; opacity: .4; }
.empty-state-title { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.empty-state-sub { font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}

.loader {
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

.toast-container {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: slideInRight var(--t-base) ease;
  max-width: 360px;
}

.unsaved-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 1.5s ease infinite;
}
