:root {
  --cfg-bg: var(--bg);
  --cfg-surface: var(--panel);
  --cfg-text: var(--text);
  --cfg-muted: var(--text-secondary);
  --cfg-border: var(--border);
  --cfg-toggle-knob: var(--panel);
  --cfg-toggle-knob-ring: color-mix(in srgb, var(--text) 72%, transparent);
  --cfg-toggle-on: var(
    --color-text-info,
    var(--color-background-info, var(--color-background-success, color-mix(in srgb, var(--accent) 72%, var(--cfg-border))))
  );
}

body {
  margin: 0;
  font-family: var(--font-sans, "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif);
  background: var(--cfg-bg);
  color: var(--cfg-text);
}

.config-shell {
  max-width: none;
  min-height: 0;
  padding: 8px;
  opacity: 0;
  transform: translateY(4px);
  animation: cfg-fade-in 180ms ease-out forwards;
}

@keyframes cfg-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.config-card {
  margin-top: 6px;
  background: var(--cfg-surface);
  border: 1px solid color-mix(in srgb, var(--cfg-border) 50%, transparent);
  border-radius: 16px;
  overflow: hidden;
}

.panel-content-wrapper {
  padding: 10px;
  display: block;
  overflow: hidden;
  min-height: 0;
  background: inherit;
}

.settings-stack {
  display: grid;
  gap: 0;
  overflow: visible;
  background: inherit;
}

.setting-row {
  border-bottom: none;
  background: transparent;
  padding: 10px 4px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.setting-row + .setting-row {
  border-top: 1px solid color-mix(in srgb, var(--cfg-border) 40%, transparent);
}

.setting-info h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.setting-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--cfg-muted);
  line-height: 1.45;
}

.setting-info .setting-summary {
  margin-top: 6px;
  font-size: 11px;
  color: var(--cfg-muted);
  font-weight: 500;
}

.setting-control {
  min-width: 180px;
  justify-self: end;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.setting-inline-input {
  width: 120px;
  box-sizing: border-box;
  border: 1px solid var(--cfg-border);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--cfg-text);
  background: transparent;
}

.setting-inline-action {
  border: 1px solid var(--cfg-border);
  background: transparent;
  color: var(--cfg-text);
  border-radius: 10px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.setting-inline-select {
  width: 120px;
  box-sizing: border-box;
  border: 1px solid var(--cfg-border);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--cfg-text);
  background: transparent;
}

.setting-shell-control {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.setting-shell-custom {
  width: 120px;
}

.hidden {
  display: none;
}

.config-tooltip[hidden] {
  display: none;
}

.config-tooltip {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--cfg-border) 70%, transparent);
  background: color-mix(in srgb, var(--panel) 90%, var(--cfg-border));
  color: var(--cfg-text);
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--cfg-border) 26%, transparent);
}

.config-tooltip--error {
  border-color: color-mix(in srgb, var(--error-text) 55%, var(--cfg-border));
  background: color-mix(in srgb, var(--error-text) 10%, var(--panel));
}

.config-tooltip--success {
  border-color: color-mix(in srgb, var(--success-text) 55%, var(--cfg-border));
  background: color-mix(in srgb, var(--success-text) 8%, var(--panel));
}

.setting-inline-static {
  font-size: 12px;
  color: var(--cfg-muted);
}

.setting-switch {
  display: inline-flex;
  align-items: center;
  position: relative;
  width: 40px;
  height: 24px;
  cursor: pointer;
}

.setting-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
}

.array-modal[hidden] {
  display: none;
}

.array-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.24);
  display: grid;
  place-items: center;
  z-index: 20;
}

.array-modal-card {
  width: min(760px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  background: var(--panel);
  border: 1px solid var(--cfg-border);
  border-radius: 14px;
  padding: 12px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.array-modal-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.array-modal-card header h3 {
  margin: 0;
  font-size: 14px;
}

.array-modal-description {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--cfg-muted);
}

.array-modal-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--cfg-muted);
}

.array-modal-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.array-modal-card header button {
  border: 1px solid var(--cfg-border);
  background: transparent;
  color: var(--cfg-text);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.array-modal-card header button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.array-modal-error {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--error-text);
}

.array-modal-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.array-modal-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.array-modal-row input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--cfg-border);
  border-radius: 9px;
  padding: 8px 10px;
  background: transparent;
  color: var(--cfg-text);
  font: inherit;
  font-size: 13px;
}

.array-modal-item-remove {
  border: 1px solid var(--cfg-border);
  background: transparent;
  color: var(--cfg-text);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.array-modal-item-remove svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.config-boolean-slider {
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cfg-border) 80%, transparent);
  position: relative;
  transition: background 150ms ease;
}

.config-boolean-slider::after {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cfg-toggle-knob);
  border: 1px solid var(--cfg-toggle-knob-ring);
  box-sizing: border-box;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 150ms ease;
}

.setting-switch input:checked + .config-boolean-slider {
  background: var(--cfg-toggle-on);
}

.setting-switch input:checked + .config-boolean-slider::after {
  transform: translateX(16px);
}

.config-shell.host-framed {
  max-width: none;
  min-height: 0;
  padding: 0;
  background: var(--cfg-surface);
  opacity: 1;
  transform: none;
  animation: none;
}

.config-shell.host-framed .config-card {
  margin-top: 0;
  border: none;
  border-radius: 0;
  background: var(--cfg-surface);
  box-shadow: none;
  padding: 0;
}

.config-shell.host-framed .panel-content-wrapper {
  padding: 6px 0;
}

.config-shell.host-framed .compact-row {
  display: none;
}

.config-shell.compact {
  min-height: 0;
}

@media (max-width: 640px) {
  .config-shell {
    padding: 12px;
    min-height: 0;
  }

  .panel-content-wrapper {
    padding: 12px;
  }

  .setting-row {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 8px;
  }

  .setting-control {
    justify-self: stretch;
    justify-content: flex-start;
    min-width: 0;
  }

  .setting-inline-input,
  .setting-inline-select,
  .setting-shell-custom {
    width: 100%;
  }

  .array-modal-card {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }
}
