/* ==========================================================================
   MCP Builder — Modern Design System & Studio Styling
   ========================================================================== */

@import url('/assets/design-system.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Color Palette - Dark Mode Default (Design System v3.0) */
  --bg: #060b16;
  --bg-gradient: radial-gradient(at 15% 15%, rgba(56, 189, 248, 0.12) 0px, transparent 50%),
                    radial-gradient(at 85% 50%, rgba(129, 140, 248, 0.14) 0px, transparent 50%);
  --panel: rgba(15, 25, 45, 0.80);
  --panel-solid: #0d172a;
  --panel-2: #0a1224;
  --panel-3: #13203b;
  --border: rgba(148, 163, 184, 0.14);
  --border-subtle: rgba(148, 163, 184, 0.08);
  --border-focus: #38bdf8;
  --text: #f8fafc;
  --muted: #94a3b8;
  --faint: #64748b;
  
  /* Brand & Accents */
  --accent: #38bdf8;
  --accent-hover: #818cf8;
  --accent-ink: #041322;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --accent-glow: rgba(56, 189, 248, 0.32);
  
  /* Status */
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  
  /* Code Editor */
  --code-bg: #050914;
  --code-text: #e2e8f0;
  --code-key: #7dd3fc;
  --code-str: #86efac;
  --code-comment: #64748b;
  
  /* Elevation & Shape */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 36px -8px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 60px -12px rgba(2, 6, 23, 0.82);
  --shadow-glow: 0 0 30px -4px rgba(56, 189, 248, 0.25);
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="light"] {
  /* Color Palette - Light Mode */
  --bg: #f8fafc;
  --bg-gradient: radial-gradient(at 0% 0%, rgba(2, 132, 199, 0.06) 0px, transparent 50%),
                    radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.06) 0px, transparent 50%);
  --panel: rgba(255, 255, 255, 0.90);
  --panel-solid: #ffffff;
  --panel-2: #f1f5f9;
  --panel-3: #e2e8f0;
  --border: #e2e8f0;
  --border-subtle: rgba(226, 232, 240, 0.9);
  --border-focus: #0284c7;
  --text: #0f172a;
  --muted: #475569;
  --faint: #94a3b8;
  --accent: #0284c7;
  --accent-hover: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: rgba(2, 132, 199, 0.10);
  --accent-glow: rgba(2, 132, 199, 0.20);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.12);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 8px 28px -6px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.14);
  --shadow-glow: 0 0 24px -2px rgba(2, 132, 199, 0.18);
}

/* ==========================================================================
   Base & Resets
   ========================================================================== */
* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  height: 100%;
}
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent-hover); }
button, input, select { font-family: inherit; }
code, pre, .mono { font-family: var(--font-mono); }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
header {
  position: sticky; top: 42px; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: all .2s ease;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; font-size: 14px; font-weight: 800;
  box-shadow: 0 4px 12px -2px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}
.brand small {
  display: block; font-weight: 450; font-size: 11.5px;
  color: var(--muted); letter-spacing: normal; margin-top: 1px;
}

.appnav {
  display: inline-flex; align-items: center;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 2px; gap: 2px;
}
.appnav a {
  padding: 4px 11px; border-radius: 7px; color: var(--muted);
  font-weight: 600; font-size: 12px; transition: all .15s ease;
}
.appnav a:hover { color: var(--text); }
.appnav a.on {
  background: var(--panel-solid); color: var(--text);
  box-shadow: var(--shadow-sm);
}

.header-spacer { flex: 1; }

.presets {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.presets .chip {
  padding: 4px 10px; font-size: 11.5px; font-weight: 550;
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 999px; transition: all .15s ease;
  color: var(--text);
}
.presets .chip:hover {
  border-color: var(--accent); color: var(--accent);
  transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
.presets .chip svg { color: var(--warn); }

.icon-btn {
  border: 1px solid var(--border); background: var(--panel-solid);
  color: var(--text); border-radius: 8px; width: 32px; height: 32px;
  cursor: pointer; display: inline-grid; place-items: center;
  transition: all .15s ease; padding: 0;
}
.icon-btn:hover {
  border-color: var(--accent); color: var(--accent);
  box-shadow: var(--shadow-sm); transform: translateY(-1px);
}

/* ==========================================================================
   Main Studio Layout (Step 1 -> Step 2 -> Step 3)
   ========================================================================== */
main {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(320px, 0.95fr) minmax(390px, 1.25fr);
  grid-template-areas: "catalog creds output";
  gap: 16px;
  padding: 16px 20px 36px;
  max-width: 1800px; margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-width: 0;
  display: flex; flex-direction: column;
  transition: border-color .2s ease, box-shadow .2s ease;
}

/* CRITICAL: Panel children sizing and scrolling rules */
.panel > * { flex: none; }
.panel > .out-body,
.panel > .creds-body,
.panel > .server-list {
  flex: 1 1 auto;
  min-height: 0;
}
.out-body > *,
.creds-body > * {
  flex-shrink: 0;
  min-width: 0;
}

.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-solid) 75%, transparent);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.panel-head h2 {
  margin: 0; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text); display: flex; align-items: center; gap: 8px;
}
.panel-head .step-num {
  width: 20px; height: 20px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
  display: inline-grid; place-items: center;
  font-size: 11.5px; font-weight: 800;
}
.panel-head .count {
  margin-left: auto; font-size: 12px; font-weight: 600;
  color: var(--muted);
}

/* Sticky column positioning with sitebar and header accounted for */
#catalog {
  grid-area: catalog;
  position: sticky; top: 98px; align-self: start;
  max-height: calc(100vh - 114px);
}
#creds {
  grid-area: creds;
  position: sticky; top: 98px; align-self: start;
  max-height: calc(100vh - 114px);
}
#output {
  grid-area: output;
  position: sticky; top: 98px; align-self: start;
  max-height: calc(100vh - 114px);
}

/* ==========================================================================
   Panel 1: Catalog 3-Column Split Layout
   (Left: Filters | Middle: Search & Results | Right: My Selection)
   ========================================================================== */
.catalog-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 280px;
  height: 100%;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.cat-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.cat-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-solid) 85%, var(--panel-2));
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.cat-col-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.cat-col-title svg { color: var(--accent); }
.cat-col-title .pill {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}

/* --- Left Column: Filters Sidebar --- */
.cat-sidebar {
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-2) 45%, var(--panel-solid));
}
.cat-sidebar-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group-title {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.filter-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cat-sidebar select {
  width: 100%;
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  transition: all .15s ease;
}
.cat-sidebar select:focus {
  border-color: var(--border-focus);
}

/* Vertical Category Groups in Sidebar */
.cat-sidebar .gtabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cat-sidebar .gtab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  width: 100%;
  font-size: 12px;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--panel-solid) 80%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
}
.cat-sidebar .gtab:hover {
  background: var(--panel-solid);
  border-color: var(--border);
  transform: none;
}
.cat-sidebar .gtab.on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px -1px var(--accent-glow);
}
.cat-sidebar .gtab .gi { font-size: 13px; flex-shrink: 0; }
.cat-sidebar .gtab .gl {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-sidebar .gtab .gc {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.cat-sidebar .gtab.on .gc {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Subcategories */
.cat-sidebar #catChips {
  padding: 6px;
  background: var(--panel-solid);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.chip {
  border: 1px solid var(--border); background: var(--panel-solid); border-radius: 999px;
  padding: 4px 9px; font-size: 11.5px; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; flex: none;
  transition: all .15s ease;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip .n { font-size: 10px; color: var(--faint); margin-left: 1px; font-weight: 600; }
.chip.on {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  font-weight: 600;
}
.chip.on .n { color: var(--accent); }
.chip.empty { display: none; }

/* Segmented Buttons in Sidebar */
.cat-sidebar .seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 100%;
  padding: 3px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cat-sidebar .seg button {
  border: 0; background: transparent; padding: 5px 6px; border-radius: 6px;
  cursor: pointer; color: var(--muted); font-size: 11px; font-weight: 550;
  text-align: center; transition: all .15s ease;
}
.cat-sidebar .seg button:hover { color: var(--text); }
.cat-sidebar .seg button.on {
  background: var(--panel-2); color: var(--text);
  box-shadow: var(--shadow-sm); font-weight: 650;
}

.link-reset {
  border: 0; background: none; color: var(--accent); cursor: pointer;
  font-size: 12px; font-weight: 600; padding: 0 4px; transition: opacity .15s;
}
.link-reset:hover { text-decoration: underline; }

/* --- Middle Column: Search & Results --- */
.cat-main {
  background: var(--panel-solid);
}
.cat-main-header {
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-solid) 92%, var(--panel-2));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.cat-main .search-box {
  position: relative;
  width: 100%;
}
.cat-main .search {
  width: 100%;
  padding: 9px 34px 9px 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  color: var(--text);
  font-size: 13px;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
  transition: all .2s ease;
}
.cat-main .search:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cat-main .search::placeholder { color: var(--faint); font-weight: 450; }

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: all .15s ease;
}
.search-clear.has-val {
  opacity: 1;
  pointer-events: auto;
}
.search-clear:hover {
  background: var(--border);
  color: var(--text);
}

.quick-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px 0;
}
.quick-tags::-webkit-scrollbar { display: none; }
.qt-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--faint);
  white-space: nowrap;
  margin-right: 2px;
}
.qt-chip {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.qt-chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cat-toolbar .count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.sel-toggle {
  font-weight: 600; color: var(--text); background: var(--panel-solid);
  margin-left: auto;
}
.sel-toggle .pill {
  background: var(--panel-2); border-radius: 999px; padding: 1px 6px;
  font-size: 10.5px; min-width: 18px; text-align: center; font-weight: 700;
}
.sel-toggle.on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 2px 8px -1px var(--accent-glow);
}
.sel-toggle.on .pill { background: rgba(255, 255, 255, 0.25); color: #fff; }

.cat-main .server-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 24px;
}

/* --- Right Column: My Selection --- */
.cat-selection {
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-2) 35%, var(--panel-solid));
}
.cat-selection .tray {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  background: transparent;
  border-bottom: 0;
}
.tray-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: none;
  overflow-y: visible;
}
.tray-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.tray-item:hover {
  border-color: var(--border-focus);
  background: var(--panel-2);
}
.tray-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tray-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tray-item-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tray-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tray-cat {
  color: var(--muted);
  font-size: 10.5px;
}
.sel-cred-badge {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  line-height: 1.2;
}
.sel-cred-badge.none {
  background: var(--panel-2);
  color: var(--muted);
}
.sel-cred-badge.req {
  background: var(--warn-soft);
  color: var(--warn);
}
.sel-cred-badge.done {
  background: var(--ok-soft);
  color: var(--ok);
}
.tray-item-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 15px;
  flex-shrink: 0;
  transition: all .15s ease;
}
.tray-item-remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Empty selection state */
.tray-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 14px;
  height: 100%;
  min-height: 180px;
  gap: 12px;
  color: var(--muted);
}
.tray-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.tray-empty-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.tray-empty-text span {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* Responsive adjustments for 3-column split */
@media (max-width: 1180px) {
  .catalog-layout {
    grid-template-columns: 220px minmax(0, 1fr) 250px;
  }
}
@media (max-width: 900px) {
  .catalog-layout {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: auto;
  }
  .cat-sidebar, .cat-main, .cat-selection {
    border: 0;
    border-bottom: 1px solid var(--border);
  }
  .cat-sidebar-body {
    max-height: 260px;
  }
  .cat-main .server-list {
    max-height: 480px;
  }
  .cat-selection .tray {
    max-height: 240px;
  }
}

/* Server List */
.server-list {
  overflow-y: auto; padding: 10px 14px 18px; flex: 1 1 auto; min-height: 0;
}
.list-banner {
  display: flex; align-items: center; gap: 8px; margin: 4px 4px 8px;
  font-size: 12px; font-weight: 550; color: var(--muted);
  background: var(--panel-2); padding: 5px 10px; border-radius: 7px;
}
.list-banner .chip { margin-left: auto; }

.cat-sec { margin-bottom: 12px; }
.cat-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 10px 4px 6px;
}
.cat-title .dot { width: 7px; height: 7px; border-radius: 50%; }
.cat-title .cnt { font-weight: 600; color: var(--faint); font-size: 11px; }
.link-btn {
  margin-left: auto; border: 0; background: none; color: var(--accent);
  cursor: pointer; font-size: 11.5px; font-weight: 600; text-transform: none;
}
.link-btn:hover { text-decoration: underline; }

/* Server Cards */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px;
}
.card {
  position: relative; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px 10px 14px; background: var(--panel-solid); cursor: pointer;
  text-align: left; transition: all .16s ease;
  display: flex; flex-direction: column; gap: 6px;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--cat, var(--accent));
  transition: width .15s ease;
}
.card:hover {
  border-color: color-mix(in srgb, var(--cat, var(--accent)) 60%, var(--border));
  transform: translateY(-1.5px); box-shadow: var(--shadow);
}
.card:hover::before { width: 4.5px; }

.card.sel {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 40%, var(--panel-solid));
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-name {
  font-weight: 700; font-size: 13px; flex: 1; color: var(--text);
  overflow-wrap: anywhere; line-height: 1.35;
}
.star { color: #f59e0b; font-size: 12px; }

.check {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--faint);
  flex: none; display: grid; place-items: center; margin-top: 1px;
  background: var(--panel-2); transition: all .15s ease;
}
.card:hover .check { border-color: var(--accent); }
.card.sel .check {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 2px 6px -1px var(--accent-glow);
}
.card.sel .check::after {
  content: ""; width: 8px; height: 5px; border: 2px solid #fff;
  border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px);
}

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

.badges { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.badge {
  font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); background: var(--panel-2);
  white-space: nowrap;
}
.badge.oauth { color: #3b82f6; border-color: rgba(59, 130, 246, 0.3); background: rgba(59, 130, 246, 0.08); }
.badge.token { color: var(--warn); border-color: rgba(245, 158, 11, 0.3); background: var(--warn-soft); }
.badge.none { color: var(--ok); border-color: rgba(16, 185, 129, 0.3); background: var(--ok-soft); }
.badge.official { color: var(--accent); border-color: rgba(99, 102, 241, 0.3); background: var(--accent-soft); }
.badge.cur { color: var(--ok); border-color: rgba(16, 185, 129, 0.3); }
.badge.pop { color: var(--text); border-color: var(--border); }

.card .links { margin-left: auto; display: inline-flex; gap: 7px; flex-wrap: wrap; font-size: 11px; }
.card .links a { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); }
.card .links a:hover { color: var(--accent); }

.more-btn {
  width: 100%; margin-top: 8px; padding: 7px; border-radius: 8px;
  border: 1px dashed var(--border); background: transparent; color: var(--muted);
  cursor: pointer; font-size: 12px; font-weight: 550; transition: all .15s ease;
}
.more-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

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

/* ==========================================================================
   Panel 2: Credentials Hub (Step 2)
   ========================================================================== */
.secure-note {
  font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--ok-soft) 40%, transparent);
}
.secure-note svg { flex: none; color: var(--ok); margin-top: 1px; }

.creds-tools { display: flex; gap: 6px; padding: 8px 14px 0; align-items: center; }
.creds-tools .chip { font-size: 11px; padding: 3px 8px; }

.creds-body {
  overflow-y: auto; padding: 10px 14px 14px; display: flex; flex-direction: column;
  gap: 8px; flex: 1 1 auto; min-height: 0;
}

.cred-group {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: var(--panel-solid); box-shadow: var(--shadow-sm);
  transition: border-color .15s ease;
  flex-shrink: 0;
}
.cred-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; width: 100%;
  background: var(--panel-2); font-weight: 650; font-size: 12.5px;
  border: 0; cursor: pointer; text-align: left; color: var(--text);
  transition: background .15s;
}
.cred-head:hover { background: color-mix(in srgb, var(--panel-2) 75%, var(--accent-soft)); }
.cred-head .chev { display: grid; place-items: center; color: var(--muted); transition: transform .2s ease; }
.cred-group.closed .chev { transform: rotate(-90deg); }
.cred-group.closed .cred-fields, .cred-group.closed .cred-note { display: none; }

.cred-head .dot { width: 7px; height: 7px; border-radius: 50%; }
.cred-head .cname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred-head .status { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); }
.cred-head .status.ok { color: var(--ok); }
.cred-head .status.miss { color: var(--warn); }

.cred-fields { padding: 10px 12px 12px; display: grid; gap: 9px; }
.cred-fields .note { color: var(--faint); font-size: 11px; }

.field label {
  display: flex; gap: 4px; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--text);
}
.field label .req { color: var(--danger); }
.field label .key { margin-left: auto; font-weight: 500; color: var(--faint); font-size: 11px; }

.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; height: 34px; padding: 0 36px 0 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  outline: none; font-size: 12.5px; transition: all .15s ease;
}
.input-wrap input:focus {
  border-color: var(--border-focus); background: var(--panel-solid);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-wrap input.secret:not([type="password"]) {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.02em;
}
.field.missing input {
  border-color: var(--warn); background: color-mix(in srgb, var(--warn-soft) 25%, var(--panel-2));
}

.eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; cursor: pointer; padding: 4px; border-radius: 6px;
  color: var(--faint); display: grid; place-items: center; transition: all .15s;
}
.eye:hover { color: var(--text); background: var(--panel-3); }
.eye svg { width: 16px; height: 16px; }
.field small { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }

.creds-foot {
  padding: 10px 14px 12px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: color-mix(in srgb, var(--panel-solid) 60%, transparent);
}
.toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--muted); cursor: pointer; user-select: none;
}
.toggle input { accent-color: var(--accent); }

/* ==========================================================================
   Panel 3: Config & Output Studio (Step 3)
   ========================================================================== */
.clients {
  display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-solid) 50%, transparent);
}
.client {
  border: 1px solid var(--border); background: var(--panel-solid);
  border-radius: 7px; padding: 5px 8px; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  white-space: nowrap; flex: 1 1 auto; text-align: center;
  transition: all .15s ease;
}
.client:hover { border-color: var(--accent); color: var(--text); }
.client.on {
  background: var(--accent); border-color: var(--accent);
  color: #fff; font-weight: 700; box-shadow: 0 2px 8px -1px var(--accent-glow);
}

.out-body {
  padding: 12px 14px 16px; overflow-y: auto; display: flex; flex-direction: column;
  gap: 10px; flex: 1 1 auto; min-height: 0;
}
.toolbar { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.path { font-size: 12px; color: var(--muted); line-height: 1.45; }
.path code {
  background: var(--panel-2); padding: 1px 6px; border-radius: 5px;
  color: var(--text); border: 1px solid var(--border);
}

.btn {
  border: 1px solid var(--border); background: var(--panel-solid); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  color: var(--text); transition: all .15s ease;
}
.btn:hover {
  border-color: var(--accent); color: var(--accent); transform: translateY(-1px);
  box-shadow: var(--shadow-sm); text-decoration: none;
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-color: transparent; color: #fff;
  box-shadow: 0 3px 12px -2px var(--accent-glow);
}
.btn.primary:hover {
  filter: brightness(1.1); transform: translateY(-1px); color: #fff;
}
.btn svg { width: 14px; height: 14px; }

/* IDE Code Viewer Window */
.code-wrap {
  position: relative; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  background: var(--code-bg); flex-shrink: 0;
}
.code-wrap::before {
  content: ""; display: block; height: 30px;
  background: color-mix(in srgb, var(--code-bg) 80%, #ffffff 5%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background-image: radial-gradient(circle at 14px 15px, #ff5f56 4.5px, transparent 5.5px),
                    radial-gradient(circle at 28px 15px, #ffbd2e 4.5px, transparent 5.5px),
                    radial-gradient(circle at 42px 15px, #27c93f 4.5px, transparent 5.5px);
}
pre.code {
  margin: 0; background: transparent; color: var(--code-text);
  padding: 12px 14px; overflow: auto; font-size: 12px; line-height: 1.55;
  min-height: 100px; max-height: 250px; font-family: var(--font-mono); white-space: pre;
}
pre.code .k { color: var(--code-key); font-weight: 600; }
pre.code .s { color: var(--code-str); }
pre.code .c { color: var(--code-comment); font-style: italic; }

.code-file {
  position: absolute; top: 6px; left: 56px; font-family: var(--font-mono);
  font-size: 11px; font-weight: 600; color: #94a3b8; pointer-events: none;
}
.code-copy { position: absolute; top: 3px; right: 6px; }
.code-copy .btn {
  background: rgba(255, 255, 255, 0.08); color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.14); padding: 3px 8px; font-size: 11px;
  backdrop-filter: blur(8px); border-radius: 6px;
}
.code-copy .btn:hover {
  background: rgba(255, 255, 255, 0.18); color: #fff;
}

/* Alerts */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warn-soft); border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--text); border-radius: 9px; padding: 8px 11px; font-size: 11.5px;
  line-height: 1.45; max-height: 85px; overflow-y: auto;
}
.alert b { color: var(--warn); }
.alert.info {
  background: var(--accent-soft); border-color: rgba(99, 102, 241, 0.35);
}
.alert.info b { color: var(--accent); }

.install {
  border: 1px dashed var(--border); border-radius: 9px; padding: 11px;
  display: grid; gap: 8px; background: color-mix(in srgb, var(--panel-2) 60%, transparent);
}
.install h3 { margin: 0; font-size: 12.5px; font-weight: 700; }
.install p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.45; }
.install-btns {
  display: flex; gap: 5px; flex-wrap: wrap;
  max-height: 140px; overflow-y: auto; padding: 2px;
}
.cursor-btn {
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--border);
  font-size: 11.5px; padding: 5px 9px; border-radius: 7px; font-weight: 550;
  display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
  transition: all .15s ease;
}
.cursor-btn:hover {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  transform: translateY(-1px); text-decoration: none;
}
.cursor-btn svg { color: var(--warn); width: 13px; height: 13px; flex-shrink: 0; }

:root[data-theme="dark"] .cursor-btn {
  background: var(--panel-2); color: var(--text); border-color: var(--border);
}
:root[data-theme="dark"] .cursor-btn:hover {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cursor-btn {
    background: var(--panel-2); color: var(--text); border-color: var(--border);
  }
  :root:not([data-theme="light"]) .cursor-btn:hover {
    background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  }
}
.missing-link { cursor: pointer; text-decoration: underline; font-weight: 600; }

/* Toast Notifications */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: all .2s ease; z-index: 100;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 7px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.flash { animation: flashHighlight 1.2s ease-out; }
@keyframes flashHighlight {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 3px var(--accent), 0 0 16px var(--accent-glow); }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 1380px) {
  main {
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
    grid-template-areas:
      "catalog creds"
      "output output";
  }
  #output { position: static; max-height: none; }
}

@media (max-width: 960px) {
  header { padding: 8px 14px; flex-wrap: wrap; top: 42px; }
  .presets { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; }
  main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "catalog"
      "creds"
      "output";
    padding: 10px 14px 30px;
    gap: 14px;
  }
  #catalog, #creds, #output { position: static; max-height: none; }
  .server-list { max-height: 60vh; }
  .cards { grid-template-columns: 1fr; }
  .gtabs { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  header { padding: 8px 10px; }
  .brand small { display: none; }
  .brand { font-size: 15px; }
  .presets { padding: 4px 0 6px; -webkit-overflow-scrolling: touch; }
  .preset-btn { font-size: 11px; padding: 4px 8px; }
  .cat-main-header { padding: 10px 12px; }
  .server-list { padding: 8px 8px 16px; }
  .card { padding: 10px 12px; }
  .clients { padding: 8px 10px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .client { padding: 6px 10px; font-size: 11px; flex: 0 0 auto; }
  .out-body { padding: 10px 10px 14px; }
  .code-block { font-size: 11.5px; }
}
