.masterToggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;

  input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg-input);
    cursor: pointer;
    position: relative;
    transition: all 150ms ease;

    &:hover {
      border-color: var(--color-border-hover);
      background: var(--color-bg-hover);
    }

    &:checked {
      background: var(--color-dev-accent);
      border-color: var(--color-dev-accent);

      &::after {
        content: "";
        position: absolute;
        left: 4px;
        top: 1px;
        width: 5px;
        height: 9px;
        border: solid white;
        border-width: 0 2px 2px 0;
        transform: rotate(45deg);
      }
    }
  }
}

.masterLabel {
  font-size: var(--font-size-base, 14px);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  white-space: nowrap;
}

.clearAllBtn {
  padding: var(--spacing-1) var(--spacing-2-5);
  background: none;
  border: 1px solid var(--color-error);
  border-radius: var(--radius-md);
  color: var(--color-error);
  font-size: var(--font-size-xs, 12px);
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
  flex-shrink: 0;

  &:hover {
    background: var(--color-error);
    color: white;
  }
}

/* ── Panel Header ─────────────────────────────────────────────── */

.panelHeader {
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  padding: var(--spacing-3) var(--spacing-4);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.headerRight {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  margin-left: auto;
  flex: 1;
  justify-content: flex-end;
}

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--font-size-xs, 12px);
  color: var(--color-text-tertiary);
  margin-bottom: var(--spacing-2);
  font-style: italic;

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

/* ── Search ──────────────────────────────────────────────────────── */

.searchWrap {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-tertiary);
  min-width: 140px;
  max-width: 260px;
  flex: 1;
}

.searchInput {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  outline: none;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm, 13px);
  font-family: inherit;
  min-width: 0;
  padding: var(--spacing-half) 0;

  &::placeholder {
    color: var(--color-text-tertiary);
  }

  &:focus {
    border-bottom-color: var(--color-dev-accent);
  }
}

.searchClear {
  background: none;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: var(--font-size-md);
  padding: 0 var(--spacing-1);
  line-height: 1;

  &:hover {
    color: var(--color-text-primary);
  }
}

.highlight {
  background: color-mix(in srgb, var(--color-dev-accent) 25%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 var(--spacing-half);
}

/* ── Presets ─────────────────────────────────────────────────────── */

.presetsLabel {
  font-size: var(--font-size-xs, 12px);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: var(--spacing-4);
  margin-bottom: var(--spacing-1);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.presetBtn {
  padding: var(--spacing-0-75) var(--spacing-2-5);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs, 12px);
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;

  &:hover {
    border-color: var(--color-dev-accent);
    color: var(--color-dev-accent);
    background: color-mix(in srgb, var(--color-dev-accent) 8%, transparent);
  }
}

.presetBtnActive {
  border-color: var(--color-dev-accent);
  color: var(--color-dev-accent);
  background: color-mix(in srgb, var(--color-dev-accent) 12%, transparent);

  &:hover {
    background: color-mix(in srgb, var(--color-dev-accent) 6%, transparent);
  }
}

/* ── Grid ────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-4);
  margin-top: var(--spacing-4);

  > * {
    /* Override .card + .card { margin-top } which has higher specificity */
    margin-top: 0 !important;
  }
}

.cardOverridden {
  border-color: color-mix(in srgb, var(--color-dev-accent) 35%, var(--color-border));
}

.cardFullWidth {
  grid-column: 1 / -1;
}

.cardHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.restoreBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;

  &:hover {
    border-color: var(--color-dev-accent);
    color: var(--color-dev-accent);
    background: color-mix(in srgb, var(--color-dev-accent) 8%, transparent);
  }
}

/* ── State rows ──────────────────────────────────────────────────── */

.stateRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-1-5) 0;
  font-size: var(--font-size-base, 14px);
  border-bottom: 1px solid var(--color-border);
  min-height: 34px;
  gap: 8px;

  &:last-child {
    border-bottom: none;
  }
}

.overrideDot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-dev-accent);
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
}

.stateLabel {
  color: var(--color-text-secondary);
  flex-shrink: 0;
  margin-right: var(--spacing-2);
  font-size: var(--font-size-sm, 13px);
}

.stateValue {
  color: var(--color-text-primary);
  font-family: var(--font-mono, monospace);
  font-size: var(--font-size-xs, 12px);
  text-align: right;
  word-break: break-all;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.realValue {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  opacity: 0.5;
}

.pathValue {
  font-size: var(--font-size-2xs);
  opacity: 0.7;
  word-break: break-all;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.green { background: var(--color-success); }
.yellow { background: var(--color-status-yellow); }
.red { background: var(--color-error); }
.gray { background: var(--color-status-gray); }

.refreshBtn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--spacing-1) var(--spacing-2);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs, 12px);
  cursor: pointer;

  &:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-border-hover);
  }
}

.headerRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Override Controls ─────────────────────────────────────────── */

.overrideSelect {
  appearance: none;
  padding: var(--spacing-1) calc(var(--spacing-3) + var(--spacing-1-5)) var(--spacing-1) var(--spacing-1-5);
  font-size: var(--font-size-xs);
  font-family: var(--font-mono, monospace);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-input);
  color: var(--color-text-secondary);
  cursor: pointer;
  max-width: 120px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  transition: all 150ms ease;

  &:hover {
    border-color: var(--color-border-hover);
  }

  &:focus {
    outline: 2px solid var(--color-border-hover);
    outline-offset: -1px;
  }
}

.overrideActive {
  border-color: var(--color-dev-accent);
  background-color: color-mix(in srgb, var(--color-dev-accent) 12%, var(--color-bg-input));
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

.rangeRow {
  display: flex;
  align-items: center;
  gap: 6px;
}

.overrideRange {
  width: 80px;
  accent-color: var(--color-dev-accent);
}

.rangeValue {
  font-size: var(--font-size-xs);
  font-family: var(--font-mono, monospace);
  color: var(--color-text-primary);
  min-width: 32px;
  text-align: right;
}

.clearBtn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-tertiary);
  font-size: var(--font-size-2xs);
  padding: 0 var(--spacing-1);
  cursor: pointer;
  line-height: 1.4;

  &:hover {
    border-color: var(--color-error);
    color: var(--color-error);
  }
}

.setBtn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  padding: 1px var(--spacing-2);
  cursor: pointer;

  &:hover {
    border-color: var(--color-border-hover);
    background: var(--color-bg-hover);
  }
}

.inlineToggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: var(--font-size-xs);
  font-family: var(--font-mono, monospace);

  input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    min-width: 14px;
    border: 1.5px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-bg-input);
    cursor: pointer;
    position: relative;
    transition: all 150ms ease;

    &:hover {
      border-color: var(--color-border-hover);
    }

    &:checked {
      background: var(--color-dev-accent);
      border-color: var(--color-dev-accent);

      &::after {
        content: "";
        position: absolute;
        left: 3px;
        top: 0;
        width: 4px;
        height: 7px;
        border: solid white;
        border-width: 0 1.5px 1.5px 0;
        transform: rotate(45deg);
      }
    }
  }
}

/* ── Dev Visuals blur ────────────────────────────────────────────── */

.devBlurred {
  filter: blur(3px);
  opacity: 0.15;
  pointer-events: none;
  user-select: none;
  transition: filter 200ms ease, opacity 200ms ease;
}

.devVisualsBanner {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: var(--spacing-2) var(--spacing-3);
  margin-bottom: var(--spacing-3);
  font-size: var(--font-size-xs, 12px);
  color: var(--color-text-tertiary);
  font-style: italic;
  line-height: 1.5;

  svg {
    flex-shrink: 0;
    margin-top: 2px;
  }

  code {
    font-family: var(--font-mono, monospace);
    font-style: normal;
    background: var(--color-bg-hover);
    padding: 0 var(--spacing-1);
    border-radius: 3px;
  }
}
