/* ============================================================
   Postman Clone — Application Styles
   Uses CSS custom properties from allinkl.css design tokens.
   ============================================================ */

/*
 * Font overrides — only Inter-Regular and Inter-SemiBold exist locally.
 * Map all other weights to the nearest available file so the browser
 * never makes a 404 request for missing font files.
 */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-Regular.ttf') format('truetype');
  font-weight: 200;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-Regular.ttf') format('truetype');
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-SemiBold.ttf') format('truetype');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-SemiBold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-SemiBold.ttf') format('truetype');
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter/Inter-SemiBold.ttf') format('truetype');
  font-weight: 900;
  font-display: swap;
}

/* ============================================================
   CSS Variable Aliases
   Maps app-level variables to the actual design system tokens
   from allinkl.css. Also defines missing utility tokens.
   ============================================================ */

:root {
  /* Font size aliases (design system uses --font-s, not --font-sm etc.) */
  --font-sm: var(--font-s);    /* 14px */
  --font-md: var(--font-m);    /* 16px */
  --font-lg: var(--font-l);    /* 18px */

  /* Surface (background) aliases — light mode */
  --color-surface-primary:   #FFFFFF;
  --color-surface-secondary: #F4F4F4;
  --color-surface-tertiary:  #F9F9F9;
  --color-surface-hover:     #EFEFEF;
  --color-surface-active:    #FFF7F9;
  --color-surface-input:     #FFFFFF;
  --color-surface-code:      #F9F9F9;

  /* Text aliases — light mode */
  --color-text-primary:   #212121;
  --color-text-secondary: #535353;
  --color-text-tertiary:  #848484;

  /* Border */
  --color-border: #EFEFEF;

  /* Brand / accent */
  --color-primary:       #E2013D;
  --color-primary-hover: #D40139;
}

/* Dark-mode overrides */
[data-theme="dark"] {
  --color-surface-primary:   #1C1C1C;
  --color-surface-secondary: #282828;
  --color-surface-tertiary:  #353535;
  --color-surface-hover:     #353535;
  --color-surface-active:    #2d1010;
  --color-surface-input:     #353535;
  --color-surface-code:      #212121;

  --color-text-primary:   #FCFCFC;
  --color-text-secondary: #D9D9D9;
  --color-text-tertiary:  #B1B1B1;

  --color-border: #535353;
}

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

/* layout.css sets margin-left:5rem on <main> for a traditional sidebar layout.
   Our app uses a CSS grid instead, so we reset it. */
main {
  margin-left: 0;
  overflow-y: unset;
  width: unset;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: var(--font-family);
  font-size: var(--font-sm);
  background: var(--color-surface-primary);
  color: var(--color-text-primary);
}

/* ---- Layouts ---- */

.layout-app {
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

/* main-area stays within the grid track; inner content sets the minimum */
.layout-app > .main-area {
  min-width: 0;
  overflow-x: auto;
}

/* Inner content carries the 800px floor — this is what triggers the scrollbar */
.topbar,
.main-tab-bar,
.main-content-area {
  min-width: 800px;
}

/* ---- No-workspace state — hide elements that require an active workspace ---- */

#app.no-workspace .sidebar-quick-actions,
#app.no-workspace .sidebar-collections,
#app.no-workspace .topbar-env {
  display: none;
}

.layout-login {
  display: block;
  background: var(--color-surface-primary);
}

/* Hide sidebar and topbar on the login page */
.layout-login .sidebar,
.layout-login .topbar {
  display: none;
}

/* Main area becomes full-page centering container */
.layout-login .main-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

/* Main content fills that container */
.layout-login #main-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  overflow: auto;
}

/* Hide tab bar on login */
.layout-login #tab-bar { display: none; }

/* ---- Sidebar ---- */

.sidebar {
  width: 280px;
  min-width: 280px;
  height: 100vh;
  background: var(--color-surface-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
  position: relative;
  z-index: 10;
}

.sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}

.sidebar.collapsed .sidebar-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .ws-select,
.sidebar.collapsed .sidebar-collections,
.sidebar.collapsed .sidebar-quick-actions,
.sidebar.collapsed .nav-group-label {
  display: none;
}

/* In collapsed mode the resizable wrapper has no split — just let nav fill it */
.sidebar.collapsed .sidebar-resizable-area {
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed .resize-divider {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  min-height: 56px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  font-size: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-weight: 600;
  font-size: var(--font-sm);
  white-space: nowrap;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover { background: var(--color-surface-hover); }

/* When sidebar is collapsed: hide its own toggle, reveal the topbar toggle */
.sidebar.collapsed .sidebar-toggle-btn         { display: none; }
#btn-sidebar-toggle                            { display: none; }
body:has(.sidebar.collapsed) #btn-sidebar-toggle { display: flex; }

.sidebar-workspace {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}

.ws-select {
  width: 100%;
  padding: 6px 10px;
  background: var(--color-surface-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--font-xs);
  cursor: pointer;
  appearance: none;
  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='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.sidebar-quick-actions {
  padding: 10px 12px;
}

.sidebar-resizable-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar-nav {
  overflow-y: auto;
  padding: 8px 0;
  min-height: 0;
}

.nav-group {
  padding: 4px 0;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  padding: 6px 16px 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: 0;
  font-size: var(--font-xs);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.nav-item.active { background: var(--color-surface-active); color: var(--color-primary); font-weight: 500; }

.nav-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

/* Collection tree section */
.sidebar-collections {
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
}

.sidebar-section-title {}

#collection-tree {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

/* ---- Topbar ---- */

.main-area {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  min-width: 0;   /* belt-and-suspenders alongside the grid fix above */
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 48px;
  background: var(--color-surface-secondary);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: 16px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-btn:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }

.topbar-env {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-env-icon { color: var(--color-text-tertiary); font-size: 14px; }

.topbar-env-select {
  padding: 4px 24px 4px 8px;
  background: var(--color-surface-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--font-xs);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  min-width: 180px;
  cursor: pointer;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---- Main Tab Bar (top-level Postman-style tabs) ---- */

.main-tab-bar {
  display: flex;
  align-items: stretch;
  background: var(--color-surface-secondary);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  height: 36px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}
.main-tab-bar::-webkit-scrollbar { height: 3px; }
.main-tab-bar::-webkit-scrollbar-track { background: transparent; }
.main-tab-bar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }
.main-tab-bar::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }
.main-tab-bar:empty { display: none; }

.main-tab {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px 0 12px;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  cursor: pointer;
  color: var(--color-text-tertiary);
  white-space: nowrap;
  max-width: 220px;
  min-width: 80px;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
  border-bottom: 2px solid transparent;
  position: relative;
}
.main-tab:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.main-tab.active {
  background: var(--color-surface-primary);
  color: var(--color-text-primary);
  border-bottom-color: var(--color-primary);
}

.main-tab-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.main-tab-icon { font-size: 13px; flex-shrink: 0; color: var(--color-text-tertiary); }
.main-tab.active .main-tab-icon { color: var(--color-primary); }

.main-tab-method {
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 28px;
  text-align: center;
  background: var(--color-surface-tertiary);
  padding: 1px 4px;
  border-radius: 3px;
}

.main-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.main-tab-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-tertiary);
  font-size: 11px;
  padding: 2px 3px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0;
  margin-left: 4px;
  transition: opacity 0.1s, background 0.1s;
}
.main-tab:hover .main-tab-close,
.main-tab.active .main-tab-close { opacity: 1; }
.main-tab-close:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }

/* ---- Main Content Area (tab pane host) ---- */

.main-content-area {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--color-surface-primary);
  display: flex;
  flex-direction: column;
}

/* Each top-level tab pane */
.tab-content-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- View Content (used inside tab panes for list/grid views) ---- */

.view-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--color-surface-primary);
  display: flex;
  flex-direction: column;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  flex-shrink: 0;
}

.view-header h2 {
  margin: 0;
  font-size: var(--font-lg);
  font-weight: 600;
}

/* Scrollable body for list/grid views */
.view-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.view-body {
  padding: 20px 24px;
}

/* ---- Form group override ----
   The design system's .input-group is horizontal (label+input inline).
   Our app uses it as a vertical form group (label above, input below).
   Override only in our app contexts. */

.login-form .input-group,
.modal-body .input-group {
  flex-direction: column;
  border: none;
  box-shadow: none;
  border-radius: 0;
  gap: 0;
}

.login-form .input-group label,
.modal-body .input-group label {
  display: block;
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.login-form .input-group input,
.login-form .input-group select,
.login-form .input-group textarea,
.modal-body .input-group input,
.modal-body .input-group select,
.modal-body .input-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-surface-input);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: var(--font-sm);
  font-family: var(--font-family);
  outline: none;
  flex: unset;
}

.login-form .input-group input:focus,
.login-form .input-group select:focus,
.login-form .input-group textarea:focus,
.modal-body .input-group input:focus,
.modal-body .input-group select:focus,
.modal-body .input-group textarea:focus {
  border-color: var(--color-primary);
}

/* ---- Login ---- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  font-size: 40px;
  color: var(--color-primary);
  display: block;
  margin-bottom: 12px;
}

.login-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  margin: 0 0 4px;
}

.login-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--font-sm);
  margin: 0;
}

.login-tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 24px;
}

.login-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.login-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.login-form .input-group {
  margin-bottom: 16px;
}

.login-hint {
  text-align: center;
  font-size: var(--font-xs);
  color: var(--color-text-tertiary);
  margin-top: 16px;
}

/* ---- Request Builder ---- */

.request-builder {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.request-name-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.req-name-input {
  flex: 1;
  min-width: 0;       /* Allows name input to shrink so buttons stay visible */
  background: none;
  border: none;
  font-size: var(--font-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  padding: 4px 0;
  outline: none;
}

.req-name-input:focus {
  border-bottom: 1px solid var(--color-primary);
}

.req-name-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.url-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.method-selector {
  position: relative;
  flex-shrink: 0;
}

.method-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--color-surface-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.method-btn[data-method="GET"] { color: #22c55e; }
.method-btn[data-method="POST"] { color: #f59e0b; }
.method-btn[data-method="PUT"] { color: #3b82f6; }
.method-btn[data-method="PATCH"] { color: #8b5cf6; }
.method-btn[data-method="DELETE"] { color: #ef4444; }
.method-btn[data-method="HEAD"],
.method-btn[data-method="OPTIONS"] { color: #6b7280; }

.method-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  min-width: 120px;
}

.method-option {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: var(--font-sm);
  font-weight: 600;
}

.method-option:hover { background: var(--color-surface-hover); }
.method-option.active { background: var(--color-surface-active); }

.url-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  position: relative;   /* anchor for the highlight overlay */
}

/* ── Highlight overlay — sits behind the URL input ── */
.url-highlight-overlay {
  position: absolute;
  inset: 0;
  padding: 8px 12px;          /* must exactly match .url-input padding */
  font-size: var(--font-sm);
  font-family: var(--font-mono, monospace);
  line-height: normal;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  z-index: 0;
}

#url-highlight-inner {
  display: inline;
  white-space: pre;
}

/* Input becomes transparent when variables are present, overlay shows text */
.url-input.url-vars-active {
  color: transparent;
  caret-color: var(--color-text-primary);
}
/* Ensure placeholder stays visible even when input text is transparent */
.url-input.url-vars-active::placeholder { color: var(--color-text-tertiary); }

/* Variable token colours in the overlay */
.url-var-token {
  border-radius: 3px;
  padding: 1px 0;
}
.url-var-token.var-ok   { color: #f59e0b; background: rgba(245,158,11,0.12); }
.url-var-token.var-miss { color: #ef4444; background: rgba(239, 68,68,0.12); }

/* ── Variable edit popover ── */
.var-popover {
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  padding: 12px 14px;
  display: none;
  z-index: 9500;
  font-size: var(--font-xs);
  min-width: 220px;
}

.var-popover-token {
  font-family: monospace;
  font-size: 12px;
  font-weight: 600;
  color: #f59e0b;
  margin-bottom: 6px;
}

.var-popover-resolved {
  font-size: var(--font-xs);
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-family: monospace;
}
.var-popover-resolved.ok   { color: #22c55e; background: rgba(34,197,94,0.1); }
.var-popover-resolved.miss { color: #ef4444; background: rgba(239,68,68,0.1); font-style: italic; }

.var-popover-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.var-popover-input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  background: var(--color-surface-input);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  color: var(--color-text-primary);
  font-size: var(--font-xs);
  font-family: var(--font-mono, monospace);
  outline: none;
}
.var-popover-input:focus { border-color: var(--color-primary); }

.var-popover-apply {
  padding: 5px 10px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: var(--font-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.var-popover-apply:hover { background: var(--color-primary-hover); }

.var-popover-hint {
  font-size: 11px;
  color: var(--color-text-secondary);
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 5px;
  padding: 5px 8px;
  margin-top: 4px;
  line-height: 1.5;
}
.var-popover-hint code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: #f59e0b;
  background: rgba(245,158,11,0.12);
  padding: 1px 4px;
  border-radius: 3px;
}

.url-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-surface-input);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: var(--font-sm);
  font-family: var(--font-mono, monospace);
  outline: none;
  transition: border-color 0.15s;
}

.url-input:focus { border-color: var(--color-primary); }

.send-btn {
  flex-shrink: 0;
  gap: 6px;
}

/* Request/Response split — display:grid is injected by makeResizable() */
.request-split {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.request-panel,
.response-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The div that createTabs() appends nav+content into must be a flex column */
.request-tabs,
.response-tabs {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tabs */
.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  padding: 0 16px;
  gap: 0;
  flex-shrink: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

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

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-badge {
  background: var(--color-primary);
  color: white;
  border-radius: 10px;
  font-size: 10px;
  padding: 1px 5px;
  font-weight: 600;
  min-width: 16px;
  text-align: center;
}

.tabs-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Each tab panel fills the content area and is independently scrollable */
.tab-panel {
  height: 100%;
  box-sizing: border-box;   /* padding must not add to height, preventing scrollbar clip */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px;
}

.tab-panel.none { display: none; }

/* KV Table (Params / Headers) */
.kv-table-wrap { height: 100%; overflow: auto; }

.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-xs);
}

.kv-table th {
  text-align: left;
  padding: 6px 10px;
  color: var(--color-text-tertiary);
  font-weight: 500;
  border-bottom: 1px solid var(--color-border);
}

.kv-table td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--color-border-light, var(--color-border));
}

.kv-table input[type="text"],
.kv-table input[type="password"] {
  width: 100%;
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: var(--font-xs);
  padding: 4px 4px;
  outline: none;
  font-family: var(--font-family);
}

.kv-table input:focus { background: var(--color-surface-hover); border-radius: 4px; }

.kv-check { width: 32px; }
.kv-del { width: 32px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.btn-icon:disabled { opacity: 0.3; cursor: default; }

/* Body editor */
.body-type-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: var(--font-xs);
  color: var(--color-text-secondary);
}

.body-editor {
  width: 100%;
  min-height: 200px;
  background: var(--color-surface-code, var(--color-surface-tertiary));
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  tab-size: 2;
}

.body-editor:focus { border-color: var(--color-primary); }

.body-none-hint,
.auth-none-hint {
  color: var(--color-text-tertiary);
  font-size: var(--font-xs);
  padding: 16px 0;
}

.body-ct-select {
  padding: 3px 8px;
  background: var(--color-surface-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-primary);
  font-size: var(--font-xs);
}

/* Auth editor */
.auth-editor { padding: 8px 0; }
.auth-type-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-type-row label { font-size: var(--font-xs); color: var(--color-text-secondary); }
.auth-type-row select {
  padding: 5px 10px;
  background: var(--color-surface-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: var(--font-xs);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.auth-field-label {
  font-size: var(--font-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.auth-field-input {
  padding: 8px 12px;
  background: var(--color-surface-input);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: var(--font-sm);
  font-family: var(--font-mono, monospace);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  max-width: 480px;
}

.auth-field-input:focus { border-color: var(--color-primary); }

/* Scripts editor */
.scripts-editor { padding: 8px 0; }
.script-section { margin-bottom: 24px; }
.script-section h4 { margin: 0 0 4px; font-size: var(--font-sm); }
.script-hint { font-size: var(--font-xs); color: var(--color-text-tertiary); margin: 0 0 8px; }
.script-hint code {
  background: var(--color-surface-tertiary);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: monospace;
}

/* Resize divider */
.resize-divider {
  background: var(--color-border);
  cursor: row-resize;
  transition: background 0.1s;
  flex-shrink: 0;
  position: relative;
}

.resize-divider.resize-vertical { height: 4px; cursor: row-resize; }
.resize-divider.resize-horizontal { width: 4px; cursor: col-resize; }
.resize-divider:hover, .resize-divider.dragging { background: var(--color-primary); }

/* Response panel */
.response-status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  font-size: var(--font-xs);
  flex-shrink: 0;
  min-height: 40px;
}

.response-placeholder {
  color: var(--color-text-tertiary);
  font-style: italic;
}

.resp-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.resp-status.success { color: #22c55e; }
.resp-status.info { color: #3b82f6; }
.resp-status.warning { color: #f59e0b; }
.resp-status.danger { color: #ef4444; }

.resp-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--color-text-secondary);
}

.resp-error { color: #ef4444; display: flex; align-items: center; gap: 6px; }

.response-body-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.response-body-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  flex-shrink: 0;
}

.resp-type-pill {
  background: var(--color-surface-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.response-body-pre {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 12px;
  background: var(--color-surface-code, var(--color-surface-tertiary));
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.response-body-pre code { font-family: monospace; }

/* JSON syntax highlight */
.json-key { color: #93c5fd; }
.json-string { color: #86efac; }
.json-number { color: #fbbf24; }
.json-bool { color: #f472b6; }
.json-null { color: #9ca3af; }

.response-preview { max-height: 300px; overflow: auto; }

.response-raw-wrap { height: 100%; overflow: auto; }

/* Response headers table */
.response-headers-table th { padding: 8px 12px; }
.response-headers-table td { padding: 6px 12px; font-size: var(--font-xs); }

/* ---- Collection Tree ---- */

.tree-root, .tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: var(--font-xs);
  color: var(--color-text-secondary);
  border-radius: 0;
  position: relative;
  user-select: none;
  transition: background 0.1s;
}

.tree-row:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.tree-row.active { background: var(--color-surface-active); color: var(--color-primary); font-weight: 500; }

.tree-chevron {
  font-size: 10px;
  flex-shrink: 0;
  color: var(--color-text-tertiary);
  transition: transform 0.15s;
  width: 16px;
  text-align: center;
}

.tree-chevron.expanded { transform: rotate(90deg); }
.tree-chevron.invisible { opacity: 0; pointer-events: none; }

.tree-icon { font-size: 13px; flex-shrink: 0; color: var(--color-text-tertiary); }

.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tree-actions {
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.1s;
}

.tree-row:hover .tree-actions { opacity: 1; }

.tree-empty { padding: 12px 16px; color: var(--color-text-tertiary); font-size: var(--font-xs); }

/* Method badges in tree */
.method-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  min-width: 32px;
  text-align: center;
  background: var(--color-surface-tertiary);
}

.method-get { color: #22c55e; }
.method-post { color: #f59e0b; }
.method-put { color: #3b82f6; }
.method-patch { color: #8b5cf6; }
.method-delete { color: #ef4444; }
.method-head, .method-options { color: #6b7280; }

/* Context menu */
.context-menu {
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  min-width: 160px;
  overflow: hidden;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-size: var(--font-xs);
  color: var(--color-text-primary);
}

.context-menu-item:hover { background: var(--color-surface-hover); }
.context-menu-item.danger { color: #ef4444; }

/* ---- History ---- */

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.1s;
}

.history-row:hover { background: var(--color-surface-hover); }

.history-method { flex-shrink: 0; width: 48px; }
.history-url { flex: 1; overflow: hidden; }
.history-url-text {
  font-size: var(--font-xs);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  font-size: var(--font-xs);
  color: var(--color-text-secondary);
}

.history-actions { flex-shrink: 0; }
.history-time, .history-size, .history-date { color: var(--color-text-tertiary); }

.history-detail {
  padding: 12px 16px;
  background: var(--color-surface-tertiary);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-xs);
}

.history-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 12px;
}

.history-detail pre {
  margin: 4px 0;
  padding: 8px;
  background: var(--color-surface-secondary);
  border-radius: 4px;
  max-height: 200px;
  overflow: auto;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- Environments ---- */

.env-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.env-list {
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 8px;
}

.env-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  margin-bottom: 4px;
}

.env-list-item:hover { background: var(--color-surface-hover); }
.env-list-item.active { background: var(--color-surface-active); }

.env-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.env-icon { font-size: 14px; flex-shrink: 0; }
.env-name { font-size: var(--font-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.env-editor { overflow-y: auto; padding: 16px 24px; min-height: 0; }

.env-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.env-editor-header h3 { margin: 0; font-size: var(--font-md); }

.env-vars-table input[type="text"],
.env-vars-table input[type="password"] {
  width: 100%;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--color-text-primary);
  font-size: var(--font-xs);
  padding: 4px 6px;
  outline: none;
}

.env-vars-table input:focus {
  border-color: var(--color-primary);
  background: var(--color-surface-input);
}

/* ---- Teams / Workspaces ---- */

.teams-grid, .workspaces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 20px 24px;
}

.team-card, .workspace-card {
  padding: 20px;
  border-radius: 8px;
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  transition: border-color 0.15s;
}

.team-card:hover, .workspace-card:hover {
  border-color: var(--color-primary);
}

.team-card-header, .workspace-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.team-avatar, .workspace-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.workspace-icon { background: var(--color-surface-tertiary); color: var(--color-text-secondary); }

.team-card-header h3, .workspace-info h3 {
  margin: 0 0 4px;
  font-size: var(--font-md);
}

.workspace-desc { margin: 0; font-size: var(--font-xs); color: var(--color-text-secondary); }
.workspace-meta { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }

.team-card-actions, .workspace-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-active { border: 2px solid var(--color-primary); }

/* ---- User Management ---- */

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.table-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.input-group-input {
  padding: 7px 12px;
  background: var(--color-surface-input, var(--color-surface-tertiary));
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: var(--font-xs);
  outline: none;
}

.input-group-input:focus { border-color: var(--color-primary); }

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}

.pagination-info { font-size: var(--font-xs); color: var(--color-text-secondary); }

/* ---- Pills ---- */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
}

.pill-xs { padding: 1px 6px; font-size: 10px; }
.pill-default { background: var(--color-surface-tertiary); color: var(--color-text-secondary); }
.pill-primary { background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.15); color: var(--color-primary); }
.pill-success { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.pill-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.pill-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

/* ---- Modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 20px;
}

.modal-overlay.modal-visible { opacity: 1; }

.modal {
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform 0.2s;
}

.modal-overlay.modal-visible .modal { transform: translateY(0); }
.modal.modal-lg { max-width: 740px; }

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

.modal-title { margin: 0; font-size: var(--font-md); font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
}

.modal-close:hover { background: var(--color-surface-hover); }

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

.modal-body .input-group {
  margin-bottom: 16px;
}

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

.modal-body .input-group input,
.modal-body .input-group select,
.modal-body .input-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--color-surface-input, var(--color-surface-tertiary));
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: var(--font-sm);
  font-family: var(--font-family);
  outline: none;
}

.modal-body .input-group input:focus,
.modal-body .input-group select:focus,
.modal-body .input-group textarea:focus {
  border-color: var(--color-primary);
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ---- Toast ---- */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(380px, calc(100vw - 48px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  font-size: var(--font-xs);
  pointer-events: all;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.toast-visible { opacity: 1; transform: translateX(0); }
.toast.toast-hiding { opacity: 0; transform: translateX(20px); }

.toast-success { border-left: 3px solid #22c55e; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-warning { border-left: 3px solid #f59e0b; }
.toast-info { border-left: 3px solid #3b82f6; }

.toast-success .mnh-icon { color: #22c55e; }
.toast-error .mnh-icon { color: #ef4444; }
.toast-warning .mnh-icon { color: #f59e0b; }
.toast-info .mnh-icon { color: #3b82f6; }

.toast-message { flex: 1; }

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-tertiary);
  font-size: 12px;
  padding: 2px;
  flex-shrink: 0;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: 500;
  font-family: var(--font-family);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--color-primary, #6366f1);
  color: white;
  border-color: var(--color-primary, #6366f1);
}

.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover, #4f46e5); }

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

.btn-secondary:hover:not(:disabled) { background: var(--color-surface-hover); }

.btn-danger {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}

.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-sm { padding: 5px 12px; font-size: var(--font-xs); }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.w-full { width: 100%; justify-content: center; }

/* ---- Tables ---- */

.table-parent { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-xs);
}

.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--color-surface-hover); }

.table td.actions {
  text-align: right;
  white-space: nowrap;
}

.table-loading, .table-empty {
  text-align: center;
  padding: 32px;
  color: var(--color-text-tertiary);
}

/* ---- Empty states ---- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--color-text-tertiary);
  text-align: center;
}

.empty-state .mnh-icon { font-size: 40px; }
.empty-state p { margin: 0; font-size: var(--font-sm); }

.empty-state-sm {
  padding: 20px;
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: var(--font-xs);
}

.empty-hint {
  padding: 16px;
  color: var(--color-text-tertiary);
  font-size: var(--font-xs);
}

/* ---- Variable tokens ---- */

.var-token {
  border-radius: 3px;
  padding: 1px 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.var-resolved { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.var-unresolved { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* ---- Misc ---- */

.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.align-center { align-items: center; }
.justify-end { justify-content: flex-end; }
.text-center { text-align: center; }
.none { display: none !important; }
.invisible { visibility: hidden; }
.ff-monospace { font-family: monospace; }

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

/* ---- Variable resolution in URL bar ---- */

.url-input.has-vars { border-color: #22c55e; }

/* ---- WebSocket Console ---- */

.ws-console {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ws-connect-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
}

.ws-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: var(--font-xs);
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
}

.ws-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ws-disconnected { background: #6b7280; }
.ws-connecting { background: #f59e0b; }
.ws-connected { background: #22c55e; animation: ws-pulse 2s infinite; }
.ws-error { background: #ef4444; }

@keyframes ws-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ws-log {
  flex: 1;
  overflow-y: auto;
  background: var(--color-surface-primary);
  padding: 8px;
  font-size: 12px;
}

.ws-log-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-tertiary);
  font-style: italic;
}

.ws-log-entry {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border);
}

.ws-log-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 10px;
  color: var(--color-text-tertiary);
}

.ws-dir-icon.incoming { color: #22c55e; }
.ws-dir-icon.outgoing { color: #3b82f6; }

.ws-log-data {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-primary);
}

.ws-type-status .ws-log-data { color: var(--color-text-tertiary); font-style: italic; }
.ws-type-error .ws-log-data { color: #ef4444; }

.ws-send-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  align-items: flex-end;
}

.ws-message-input {
  flex: 1;
  padding: 8px 12px;
  background: var(--color-surface-input, var(--color-surface-tertiary));
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: var(--font-xs);
  resize: none;
  outline: none;
}

.ws-message-input:focus { border-color: var(--color-primary); }

/* ---- Web Component: empty-state ---- */

empty-state { display: block; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 8px;
  text-align: center;
}
.empty-state-icon {
  font-size: 36px;
  color: var(--color-text-tertiary);
  margin-bottom: 8px;
}
.empty-state-msg {
  font-size: var(--font-sm);
  color: var(--color-text-secondary);
  margin: 0;
}
.empty-state-sub {
  font-size: var(--font-xs);
  color: var(--color-text-tertiary);
  margin: 0;
}

/* ---- Web Component: kv-row (flex-based) ---- */

kv-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
kv-row.kv-disabled .kv-key,
kv-row.kv-disabled .kv-value {
  opacity: 0.4;
}
kv-row .kv-check  { flex-shrink: 0; cursor: pointer; }
kv-row .kv-key    { flex: 1; min-width: 0; }
kv-row .kv-value  { flex: 2; min-width: 0; }
kv-row .kv-delete { flex-shrink: 0; }

/* ---- Web Component: app-button / app-input host elements ---- */

app-button       { display: inline-flex; }
app-input        { display: block; }
app-pill         { display: inline-flex; }
method-badge     { display: inline-flex; }
status-badge     { display: inline-flex; }
sidebar-item     { display: block; }
app-pagination   { display: block; }
app-tabs         { display: contents; } /* transparent to flex layout — children participate in .request-tabs directly */
resizable-panel  { display: grid; }
collection-tree  { display: block; overflow-y: auto; }
app-sidebar      { display: flex; flex-direction: column; overflow: hidden; }
