/* ── RunTK Shared Components ── */

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* App-switcher */
.app-switcher { position: relative; display: flex; align-items: center; min-width: 0; }

.app-switcher-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

.app-switcher-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius);
}

.app-switcher-caret {
  margin-left: 4px;
  color: var(--muted2);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}

.app-switcher.open .app-switcher-caret { transform: rotate(180deg); }

/* App menu dropdown */
.app-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 210px;
  max-width: min(260px, 90vw);
  padding: 6px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 12px 26px rgba(0,0,0,0.35);
  display: none;
  z-index: 20;
}

.app-switcher.open .app-menu { display: block; }

.app-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.app-menu a:hover { background: var(--btn); color: var(--text); }

.app-menu a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.app-menu .menu-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.app-menu .menu-icon svg { width: 16px; height: 16px; display: block; }

/* App logo */
.app-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  flex: 0 0 auto;
}

.app-logo svg { display: block; }

.logo-yellow {
  background: rgba(210,153,34,0.12);
  color: var(--warn);
  border-color: rgba(210,153,34,0.3);
}

.logo-blue {
  background: rgba(31,111,235,0.15);
  color: var(--accent);
  border-color: rgba(31,111,235,0.3);
}

.logo-green {
  background: rgba(63,185,80,0.12);
  color: var(--success);
  border-color: rgba(63,185,80,0.3);
}

.logo-purple {
  background: rgba(163,113,247,0.12);
  color: var(--purple);
  border-color: rgba(163,113,247,0.3);
}

.logo-orange {
  background: rgba(240,136,62,0.12);
  color: #f0883e;
  border-color: rgba(240,136,62,0.3);
}

.logo-red {
  background: rgba(248,81,73,0.12);
  color: var(--danger);
  border-color: rgba(248,81,73,0.3);
}

.logo-brand {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

/* App text */
.app-text { min-width: 0; }

.app-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.app-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56vw;
}

/* Spacer */
.spacer { flex: 1; }

/* Help button */
.help-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--btn);
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.help-btn:hover { background: var(--btnHover); color: var(--text); }

.theme-toggle-btn {
  font-size: 11px;
  padding: 2px 7px;
  min-width: 0;
  min-height: 28px;
}

/* Help modal */
.help-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,0.55);
  z-index: 50;
}

.help-modal.open { display: flex; }

.help-dialog {
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radiusXl);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  overflow: hidden;
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.help-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.help-close {
  border: none;
  background: var(--btn);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.help-close:hover { background: var(--btnHover); color: var(--text); }

.help-body {
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-height: 65vh;
  overflow: auto;
}

.help-body h1 { font-size: 16px; margin: 0 0 8px; color: var(--text); }
.help-body h2 { font-size: 14px; margin: 12px 0 6px; color: var(--text); }
.help-body h3 { font-size: 13px; margin: 10px 0 6px; color: var(--text); }
.help-body p { margin: 0 0 8px; }
.help-body ul, .help-body ol { margin: 0 0 8px 18px; padding: 0; }
.help-body li { margin: 0 0 4px; }
.help-body code {
  font-family: var(--mono);
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 2px 4px;
  border-radius: 4px;
}
.help-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  overflow: auto;
  margin: 0 0 10px;
}
.help-body pre code {
  background: none;
  border: 0;
  padding: 0;
}
.help-body a { color: var(--accent); text-decoration: none; }
.help-body a:hover { text-decoration: underline; }

.help-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.help-footer a { color: var(--accent); text-decoration: none; }
.help-footer a:hover { text-decoration: underline; }

/* Header badge (root page) */
.header-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  letter-spacing: 0.02em;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted2);
}

.footer a {
  color: var(--muted);
  text-decoration: none;
}

.footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Shared app primitives */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radiusLg);
  overflow: hidden;
}

.card-body,
.cardBody {
  padding: 12px;
}

/* ── Shared Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.55);
  z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radiusLg);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  width: min(480px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

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

.modal-title {
  font-size: 14px;
  font-weight: 700;
}

.modal-body { padding: 14px; }

.modal-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-close {
  background: var(--btn);
  border: 1px solid var(--border);
  border-radius: var(--radiusMd);
  color: var(--muted);
  font-size: 16px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}

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

.remember-key,
.mwe-remember-key {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.remember-key input,
.mwe-remember-key input {
  accent-color: var(--accentEmph);
}

.remember-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.remember-inline .remember-key,
.remember-inline .mwe-remember-key {
  width: auto;
  margin-top: 0;
}

.remember-privacy-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.remember-privacy-note a {
  color: var(--accent);
  text-decoration: none;
}

.remember-privacy-note a:hover {
  text-decoration: underline;
}

.btn,
.mwe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled),
.mwe-btn:hover:not(:disabled),
.btn:hover,
.mwe-btn:hover {
  background: var(--btnHover);
  border-color: var(--muted2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 10%, transparent);
}

.btn:active:not(:disabled),
.mwe-btn:active:not(:disabled),
.btn:active,
.mwe-btn:active {
  animation: button-pop 0.18s ease-out;
}

.btn:disabled,
.btn-primary:disabled,
.btn.primary:disabled,
.mwe-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary,
.btn.primary,
.mwe-btn-primary {
  background: var(--successEmph);
  color: #fff;
  border-color: rgba(240,246,252,0.1);
}

.btn-primary:hover:not(:disabled),
.btn.primary:hover:not(:disabled),
.mwe-btn-primary:hover:not(:disabled),
.btn-primary:hover,
.btn.primary:hover,
.mwe-btn-primary:hover {
  background: #2ea043;
}

.btn-primary:active:not(:disabled),
.btn.primary:active:not(:disabled),
.mwe-btn-primary:active,
.btn-primary:active,
.btn.primary:active {
  background: #238636;
}

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

.btn-secondary:hover:not(:disabled),
.btn.ghost:hover:not(:disabled),
.btn-secondary:hover,
.btn.ghost:hover {
  background: var(--btnHover);
  border-color: var(--muted2);
  color: var(--text);
}

.btn-danger,
.btn.danger {
  background: var(--danger-soft-bg);
  border-color: var(--danger-soft-border);
  color: var(--danger-soft-text, var(--color-danger-fg, var(--danger)));
}

.btn-danger:hover:not(:disabled),
.btn.danger:hover:not(:disabled),
.btn-danger:hover,
.btn.danger:hover {
  background: var(--danger-soft-bg);
  border-color: var(--danger-soft-border);
  color: var(--danger-soft-text, var(--color-danger-fg, var(--danger)));
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) { filter: brightness(1.1); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text-secondary); border-color: color-mix(in srgb, var(--accent) 38%, transparent); }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.btn-row .spacer { flex: 1; }

.seg,
.unit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-height: 38px;
}

.seg button,
.unit-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-width: 56px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.seg button:hover,
.unit-toggle button:hover {
  color: var(--text);
}

.seg button.active,
.seg button.is-active,
.seg button[aria-selected="true"],
.seg button[aria-pressed="true"],
.unit-toggle button.active,
.unit-toggle button.is-active,
.unit-toggle button[aria-selected="true"],
.unit-toggle button[aria-pressed="true"] {
  background: var(--accentEmph);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  animation: control-shift 0.2s ease-out;
}

.segmented {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 38px;
  overflow: hidden;
}

.segmented button {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  padding: 8px 12px;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active,
.segmented button.is-active,
.segmented button[aria-selected="true"],
.segmented button[aria-pressed="true"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
  animation: control-shift 0.2s ease-out;
}

/* Tabs */
.tabs,
.tabs-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 4px 2px 2px;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.tabs-strip::-webkit-scrollbar { display: none; }

.tabItem,
.tab-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
  min-height: 36px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tabItem:hover,
.tab-btn:hover {
  color: var(--text);
  border-color: var(--muted2);
}

.tabItem.active,
.tab-btn.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent);
}

.tabItem.active::after,
.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--accent);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.tabButton,
.tab-btn > span:first-child {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
}

.tabOptionsBtn,
.tab-btn .kebab {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  min-width: 26px;
  min-height: 26px;
  width: 26px;
  height: 26px;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
}

.tabItem:hover .tabOptionsBtn,
.tab-btn:hover .kebab { opacity: 0.85; }

.tabOptionsBtn:hover,
.tab-btn .kebab:hover {
  opacity: 1;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.tabAdd,
.tab-add {
  border-radius: var(--radius);
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  min-height: 34px;
  min-width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.tabAdd:hover,
.tab-add:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  min-height: 38px;
  min-width: 90px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, border-radius 0.18s ease;
}

.expand-btn::after {
  content: "\25BE";
  width: 16px;
  text-align: center;
  color: var(--muted);
  transition: transform 0.18s ease, color 0.15s ease;
}

.expand-btn:hover {
  color: var(--text);
  border-color: var(--muted2);
}

.expand-btn[aria-expanded="true"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  animation: control-shift 0.2s ease-out;
}

.expand-btn[aria-expanded="true"]::after {
  color: var(--accent);
  transform: rotate(180deg);
}

.expand-btn[aria-expanded="true"] + .expand-panel {
  margin-top: -1px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent);
}

.expand-panel.open {
  animation: panel-expand 0.2s ease-out;
  transform-origin: top center;
}

@keyframes control-shift {
  0% { transform: translateX(3px); opacity: 0.92; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes button-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes panel-expand {
  0% { opacity: 0; transform: scaleY(0.97); }
  100% { opacity: 1; transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .mwe-btn,
  .seg button,
  .unit-toggle button,
  .segmented button,
  .expand-btn,
  .expand-btn::after,
  .expand-panel.open {
    transition: none !important;
    animation: none !important;
  }
}

.seg button:focus-visible,
.unit-toggle button:focus-visible,
.segmented button:focus-visible,
.tabButton:focus-visible,
.tabOptionsBtn:focus-visible,
.tab-btn:focus-visible,
.tab-btn .kebab:focus-visible,
.tabAdd:focus-visible,
.tab-add:focus-visible,
.expand-btn:focus-visible,
.step-pill:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted2);
}

select {
  appearance: auto;
}

/* API token fields: visually masked but not password inputs */
.api-token-input {
  -webkit-text-security: disc;
  text-security: disc;
}

/* ── Callout / Alert Banners ── */
.callout {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radiusMd);
  font-size: 13px;
  line-height: 1.45;
}

.callout svg { flex-shrink: 0; margin-top: 1px; }

.callout-success {
  background: color-mix(in srgb, var(--success) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
  color: var(--success);
}

.callout-warning {
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  color: var(--warn);
}

.callout-danger {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  color: var(--danger);
}

.callout-info {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--accent);
}

.callout a { color: inherit; text-decoration: underline; }

/* ── Alert (inline validation / status) ── */
.alert {
  display: none;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radiusMd);
  font-size: 13px;
  line-height: 1.45;
  border: 1px solid rgba(248,81,73,0.25);
  background: rgba(248,81,73,0.1);
  color: var(--danger);
  margin-bottom: 10px;
}

.alert.show { display: flex; }

.alert-success {
  border-color: color-mix(in srgb, var(--success) 25%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
}

.alert-warning {
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  color: var(--warn);
}

.alert-info {
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

/* ── Field Label ── */
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 6px 2px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ── Toggle Switch ── */
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}

.switch-slider::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  left: 2.5px;
  top: 2.5px;
  border-radius: 50%;
  background: var(--muted2);
  transition: all 0.2s;
}

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

.switch input:checked + .switch-slider::after {
  left: 20.5px;
  background: #fff;
}

/* class-based active state for button-based toggles (no checkbox) */
.switch.on .switch-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.switch.on .switch-slider::after {
  left: 20.5px;
  background: #fff;
}

/* ── Switch Tile ── */
.switch-tile {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.switch-tile.warn {
  border-color: var(--warn);
  background: rgba(210,153,34,.06);
}
.switch-tile b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.switch-tile span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

/* ── Step Pills / Progress ── */
.step-pills {
  --step-pill-gap: 10px;
  display: flex;
  gap: var(--step-pill-gap);
  flex-wrap: wrap;
  align-items: center;
  margin: 10px 0;
}

.step-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  min-height: 34px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.step-pill:hover {
  border-color: var(--muted2);
  color: var(--text);
}

.step-pill:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(100% + 1px);
  width: max(4px, calc(var(--step-pill-gap) - 2px));
  height: 2px;
  border-radius: 999px;
  background: rgba(139,148,158,0.55);
  transform: translateY(-50%);
  pointer-events: none;
}

.step-pill .pill-n {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
  background: var(--surface);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.step-pill.active,
.step-pill.is-active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}

.step-pill.active .pill-n,
.step-pill.is-active .pill-n {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.step-pill.done,
.step-pill.is-done {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 18%, transparent);
}

.step-pill.done .pill-n,
.step-pill.is-done .pill-n {
  border-color: color-mix(in srgb, var(--success) 75%, transparent);
  color: color-mix(in srgb, var(--success) 95%, transparent);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}

.step-pill.done:not(:last-child)::after,
.step-pill.is-done:not(:last-child)::after {
  background: color-mix(in srgb, var(--success) 65%, transparent);
}

.progress-track {
  display: flex;
  gap: 4px;
}

.progress-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.3s ease;
}

.progress-seg.done { background: var(--success); }
.progress-seg.active { background: var(--accent); }

/* ── Spinner ── */
.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Utilities */
.hide { display: none !important; }
.hidden { display: none !important; }
