/* Prompt Library pane.
 *
 * Sibling to the Automation Chains pane. Two-column layout: prompt list
 * on the left, editor on the right with Edit and Test sub-tabs. Reuses
 * tokens from styles.css and many of the chains.* class patterns —
 * `.cn-list*` / `.cn-field*` are intentionally shared so the two panes
 * feel like one product.
 *
 * Class prefix is `.pl-` to avoid collisions with chains.css internals
 * that bind to `.cn-step*` markup.
 */

.view-pane-prompts {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ----- Header ---------------------------------------------------------- */

.pl-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.pl-header-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}
.pl-header-sub {
  font-size: 12.5px;
  color: var(--text-dim);
}
.pl-header-spacer { flex: 1; }

.pl-scope-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}
.pl-scope-btn {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 140ms ease, color 140ms ease, transform 80ms ease;
  letter-spacing: 0.15px;
}
.pl-scope-btn-icon { flex: 0 0 auto; opacity: 0.85; }
.pl-scope-btn:hover:not(:disabled) {
  color: var(--text);
  background: var(--panel-hover);
}
.pl-scope-btn:active:not(:disabled) { transform: translateY(0.5px); }
.pl-scope-btn.is-active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 4px 12px -6px var(--accent);
}
.pl-scope-btn.is-active .pl-scope-btn-icon { opacity: 1; }
.pl-scope-btn:disabled,
.pl-scope-btn.is-locked {
  opacity: 0.42;
  cursor: not-allowed;
}
.pl-scope-btn.is-locked::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 2px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><rect x='4' y='11' width='16' height='10' rx='2'/><path d='M8 11V7a4 4 0 0 1 8 0v4'/></svg>") no-repeat center / contain;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><rect x='4' y='11' width='16' height='10' rx='2'/><path d='M8 11V7a4 4 0 0 1 8 0v4'/></svg>") no-repeat center / contain;
}

/* Scope badges — used in the prompt list rows and editor meta to
   surface which scope the active prompt belongs to. */
.pl-scope-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  flex: 0 0 auto;
  line-height: 1.6;
}
.pl-scope-badge-icon { display: inline-flex; align-items: center; justify-content: center; opacity: 0.9; }
.pl-scope-badge.is-company {
  color: #ffb774;
  background: color-mix(in srgb, #ffb774 14%, transparent);
  border-color: color-mix(in srgb, #ffb774 28%, transparent);
}
.pl-scope-badge.is-server {
  color: #b29dff;
  background: color-mix(in srgb, #b29dff 14%, transparent);
  border-color: color-mix(in srgb, #b29dff 30%, transparent);
}

/* Category chip — surfaces the active category alongside the scope
   badge. Interactive: a tiny <select> + add/delete actions for company
   and server scopes. */
.pl-category-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px 2px 6px;
  line-height: 1.55;
}
.pl-category-chip-icon { display: inline-flex; align-items: center; opacity: 0.85; }

.pl-category-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 4px 1px 8px;
  line-height: 1.4;
  transition: border-color 120ms ease, background 120ms ease;
}
.pl-category-selector:hover {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  background: color-mix(in srgb, var(--accent) 4%, var(--panel-2));
}
.pl-category-selector .pl-category-chip-icon { opacity: 0.85; }
.pl-category-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 14px 2px 0;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0 center;
  outline: none;
  max-width: 180px;
  text-overflow: ellipsis;
}
.pl-category-select:focus { color: var(--text); }
.pl-category-action {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  padding: 2px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
}
.pl-category-action:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text);
}
.pl-category-action-danger:hover:not(:disabled) {
  background: rgba(255, 110, 110, 0.18);
  color: #ffb4ba;
}
.pl-category-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* List toolbar category bar — wraps under the search input and gives
   users a hop-between-categories affordance without opening a prompt.
   Empty in user scope unless multiple categories exist (Default alone
   is noise). */
.pl-category-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 12px 8px 12px;
  border-bottom: 1px solid var(--border-muted);
}
.pl-category-bar:empty { display: none; padding: 0; border-bottom: 0; }
.pl-category-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  max-width: 100%;
}
.pl-category-pill:hover {
  color: var(--text);
  background: var(--panel);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
}
.pl-category-pill.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.pl-category-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.pl-category-pill-count {
  background: color-mix(in srgb, #fff 24%, transparent);
  color: #fff;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 10px;
  line-height: 1.5;
}
.pl-category-bar-new {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  margin-left: 2px;
}
.pl-category-bar-new:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-2));
  border-color: var(--accent);
}

.pl-list-item-category {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  flex: 0 0 auto;
  margin-left: auto;
}

/* "New category" modal — reused by handleCreateCategory. */
.pl-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 24px;
}
.pl-modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.pl-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pl-modal-title { margin: 0; font-size: 15px; font-weight: 700; }
.pl-modal-desc { margin: 0; font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.pl-modal-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-top: 4px;
}
.pl-modal-input {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}
.pl-modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(107, 123, 255, 0.18); }
.pl-modal-x {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.pl-modal-x:hover { color: var(--text); }
.pl-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 8px;
}
.pl-modal-cancel,
.pl-modal-submit {
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 120ms ease, background 120ms ease;
}
.pl-modal-cancel {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.pl-modal-cancel:hover { background: var(--panel); }
.pl-modal-submit {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.pl-modal-submit:hover { filter: brightness(1.08); }

.pl-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 480px;
  z-index: 9999;
}
.pl-toast.success { border-color: rgba(98, 200, 134, 0.5); }
.pl-toast.error { border-color: rgba(255, 110, 110, 0.55); }

/* ----- Body (two-column layout) ---------------------------------------- */

.pl-body {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.pl-list {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel);
  min-height: 0;
}
.pl-list-toolbar {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border-muted);
}
.pl-search {
  width: 100%;
  padding: 7px 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12.5px;
  box-sizing: border-box;
}
.pl-search:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}
.pl-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}
.pl-list-empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pl-list-empty-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.pl-list-empty-icon svg { width: 18px; height: 18px; }
.pl-list-empty-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.1px;
}
.pl-list-empty-body {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.5;
  max-width: 220px;
}

.pl-list-item-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.pl-list-item-row .pl-list-item-name {
  flex: 1;
  min-width: 0;
}

.pl-list-item {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 11px 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s ease, border-color 0.15s ease, padding-left 0.15s ease;
  position: relative;
}
.pl-list-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 70%;
  background: var(--accent);
  border-radius: 2px;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.pl-list-item:hover {
  background: var(--panel-hover);
  padding-left: 16px;
}
.pl-list-item:hover::before { transform: translateY(-50%) scaleY(0.4); }
.pl-list-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(107, 123, 255, 0.35);
  padding-left: 16px;
}
.pl-list-item.is-active::before { transform: translateY(-50%) scaleY(1); }
.pl-list-item-name {
  display: block;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-list-item-preview {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: var(--mono);
}

/* ----- Editor pane ----------------------------------------------------- */

.pl-editor {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pl-editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  padding: 40px 24px;
  text-align: center;
  gap: 14px;
}
.pl-editor-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 20%, var(--accent-soft) 0%, transparent 65%),
    var(--panel);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.pl-editor-empty-title {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
}
.pl-editor-empty-body { font-size: 13px; max-width: 400px; line-height: 1.55; }

.pl-editor-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-wrap: wrap;
}
.pl-editor-titlewrap { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 6px; }
.pl-editor-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-faint);
}
.pl-editor-empty-titlewrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Shared-prompt warning shown above the textarea when editing a
   company/server prompt. Mirrors the styling used for the auth
   invitation banner so the "shared edit" affordance reads at a glance. */
.pl-shared-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 24px 0 24px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, #ffb774 30%, var(--border));
  background: color-mix(in srgb, #ffb774 10%, var(--panel));
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
}
.pl-shared-notice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: color-mix(in srgb, #ffb774 22%, var(--panel-2));
  color: #ffb774;
  flex: 0 0 auto;
  margin-top: 1px;
}
.pl-shared-notice-body { flex: 1; min-width: 0; }
.pl-shared-notice-body strong { color: var(--text); font-weight: 700; }
.pl-editor-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.pl-editor-title:hover { background: var(--panel-hover); }
.pl-editor-title:focus {
  outline: none;
  background: var(--panel-2);
  border-color: var(--accent);
}
.pl-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----- Tabs ----------------------------------------------------------- */

.pl-tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.pl-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pl-tab:hover { color: var(--text); }
.pl-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.pl-tab-badge {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

/* ----- Edit tab (textarea + variables sidebar) ------------------------ */

.pl-edit-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pl-edit-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--border-muted);
  font-size: 11.5px;
  color: var(--text-dim);
}
.pl-edit-toolbar .pl-modified {
  color: rgba(255, 184, 80, 1);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pl-edit-toolbar .pl-modified::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 184, 80, 1);
  box-shadow: 0 0 0 3px rgba(255, 184, 80, 0.18);
}

.pl-edit-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 0;
  overflow: hidden;
}
.pl-edit-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 16px 16px 16px 24px;
  border-right: 1px solid var(--border-muted);
}
.pl-edit-textarea {
  flex: 1;
  width: 100%;
  min-height: 200px;
  padding: 12px 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  resize: none;
  box-sizing: border-box;
  white-space: pre-wrap;
}
.pl-edit-textarea:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.pl-vars-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 24px 16px 16px;
  background: var(--panel);
  gap: 6px;
}
.pl-vars-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 600;
  margin: 0 0 4px;
}
.pl-vars-blurb {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
  margin: 0 0 8px;
}
.pl-var-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px 4px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(107, 123, 255, 0.28);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
  align-self: flex-start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pl-var-chip::before {
  content: "{ }";
  font-size: 10px;
  opacity: 0.55;
}
.pl-var-chip:hover {
  background: var(--accent);
  color: #fff;
  transform: translateX(2px);
}
.pl-var-empty {
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

/* ----- Test tab ------------------------------------------------------- */

.pl-test-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 24px 24px;
}
.pl-test-section {
  margin-bottom: 16px;
}
.pl-test-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 600;
  margin: 0 0 8px;
}
.pl-test-vars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 12px;
}
.pl-test-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pl-test-field-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  font-weight: 500;
}
.pl-test-input {
  padding: 7px 10px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12.5px;
  box-sizing: border-box;
}
.pl-test-input:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.pl-test-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0 16px;
}

.pl-test-preview {
  background: var(--code-block-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
}
.pl-test-preview-token {
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0 3px;
  border-radius: 3px;
}

.pl-test-response {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.55;
  max-height: 360px;
  overflow-y: auto;
}
.pl-test-response.is-empty {
  font-style: italic;
  color: var(--text-faint);
}

.pl-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pl-spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes pl-spin { to { transform: rotate(360deg); } }

/* ----- New / Import dialog ------------------------------------------- */

.pl-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  padding: 24px;
}
.pl-modal {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pl-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.pl-modal-title { font-size: 15px; font-weight: 600; margin: 0; }
.pl-modal-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}
.pl-modal-close:hover { background: var(--panel-hover); color: var(--text); }
.pl-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pl-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.pl-modal-tabs {
  display: flex;
  gap: 0;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-muted);
}
.pl-modal-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 12px;
  cursor: pointer;
}
.pl-modal-tab:hover { color: var(--text); }
.pl-modal-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ----- Responsive ---------------------------------------------------- */
@media (max-width: 900px) {
  .pl-list { width: 220px; }
  .pl-edit-grid { grid-template-columns: 1fr; }
  .pl-vars-sidebar {
    border-top: 1px solid var(--border-muted);
    border-right: 0;
    flex-direction: row;
    flex-wrap: wrap;
  }
}
@media (max-width: 720px) {
  .pl-body { flex-direction: column; }
  .pl-list {
    width: 100%;
    max-height: 200px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}
