/* Text fields and choices keep native behavior; switches live in switch.css. */
input:not([type=checkbox], [type=radio], [type=range], .mc-source-url),
select,
textarea {
  background: var(--surface-3);
  border: 1px solid var(--field-line,var(--hairline));
  border-radius: var(--r-input);
  padding: 0 12px;
  min-height: var(--ctl-m);
  min-width: 0;
  color: var(--text);
  font-family: inherit;
  font-size: var(--form-control-size,var(--control-font-size,14px));
  font-weight: var(--form-control-weight,400);
  line-height: 1.5;
  transition: background-color .18s,border-color .18s;
}

textarea { padding: 10px 12px; min-height: 80px; resize: vertical; }

:is(label,legend,p,h3,h4,summary,span).mc-field-label {
  gap: var(--form-field-gap,8px);
  color: var(--form-label-color,var(--text));
  font-size: var(--form-label-size,14px);
  font-weight: var(--form-label-weight,500);
  line-height: 1.5;
}

legend.mc-field-label { margin: 0 0 var(--form-field-gap,8px); padding: 0; }

/* A group of fields without card or dialog chrome. */
.mc-field-stack { display: grid; align-content: start; gap: var(--form-row-gap,16px); min-width: 0; }
.mc-field-stack > label { margin: 0; }

.mc-field-label > output,
.mc-field-label > span > output { margin-left: auto; color: var(--text-2); font-size: var(--form-control-size,14px); font-weight: 400; font-variant-numeric: tabular-nums; }

.mc-field-hint { color: var(--form-help-color,var(--muted)); font-size: var(--form-help-size,12px); font-weight: 400; line-height: 1.5; }

input:where(:not(.mc-source-url)):hover:not(:disabled):not([type=checkbox]):not([type=radio]):not([type=range]),
textarea:hover:not(:disabled) {
  background-color: var(--field-hover);
  border-color: var(--line-strong);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

input:disabled,select:disabled,textarea:disabled { cursor: not-allowed; }

select {
  cursor: pointer;
  color-scheme: dark;
  appearance: var(--select-appearance,none);
  -webkit-appearance: var(--select-appearance,none);
  padding-right: 34px;
  background-image: var(--select-indicator,url("/vendor/tabler/chevron-down.svg?v=b7ae84b0abd3f085"));
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
:root[data-panel-theme='light'] select { color-scheme: light; }

select:hover:not(:disabled) {
  background-color: var(--field-hover);
}

option {
  background-color: var(--window-solid, var(--surface));
  color: var(--text);
  color-scheme: inherit;
}

/* Chromium paints group labels white unless the group has its own colors. */
optgroup {
  background-color: var(--window-solid, var(--surface));
  color: var(--text-secondary);
  font-weight: 600;
}

option:checked,
option:is(:hover, :focus) {
  background-color: color-mix(in srgb, var(--brand) 24%, var(--window-solid, var(--surface)));
  color: var(--option-active-text, var(--text));
}

/* Native controls keep their keyboard/checked behavior and never size as fields. */
input:where([type=checkbox], [type=radio]):not([role=switch]) {
  flex: none;
  width: var(--choice-size,16px);
  min-width: var(--choice-size,16px);
  height: var(--choice-size,16px);
  min-height: var(--choice-size,16px);
  margin: 0;
  padding: 0;
  accent-color: var(--choice-accent,var(--brand));
  vertical-align: middle;
  cursor: pointer;
}

input:where([type=checkbox], [type=radio]):not([role=switch]):disabled {
  cursor: not-allowed;
}

/* One checkbox treatment for static forms and controls created by features. */
input[type=checkbox]:not([role=switch]) {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  box-sizing: border-box;
  width: var(--choice-size,18px);
  min-width: var(--choice-size,18px);
  height: var(--choice-size,18px);
  min-height: var(--choice-size,18px);
  border: 1px solid var(--line-strong);
  border-radius: var(--choice-radius,var(--panel-radius,7px));
  background: var(--surface);
  color: var(--choice-accent,var(--brand));
  touch-action: manipulation;
  transition: background-color .18s ease, border-color .18s ease, opacity .18s ease;
}

input[type=checkbox]:not([role=switch])::before {
  content: '';
  width: calc(var(--choice-size,18px) * .55);
  height: calc(var(--choice-size,18px) * .28);
  margin-top: -2px;
  border: solid currentColor;
  border-width: 0 0 1.8px 1.8px;
  opacity: 0;
  transform: rotate(-45deg);
}

input[type=checkbox]:not([role=switch]):is(:checked,:indeterminate) {
  border-color: var(--choice-accent,var(--brand));
  background: color-mix(in srgb,var(--choice-accent,var(--brand)) 16%,var(--surface));
}

input[type=checkbox]:not([role=switch]):is(:checked,:indeterminate)::before { opacity: 1; }

input[type=checkbox]:not([role=switch]):indeterminate::before {
  height: 0;
  margin-top: 0;
  border-width: 0 0 1.8px;
  transform: none;
}

input[type=checkbox]:not([role=switch]):hover:not(:disabled) {
  border-color: var(--choice-accent,var(--brand));
  background: color-mix(in srgb,var(--choice-accent,var(--brand)) 16%,var(--surface));
}

input[type=checkbox]:not([role=switch]):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input[type=checkbox]:not([role=switch]):disabled { opacity: .42; }
input[type=checkbox]:not([role=switch]):checked:disabled { opacity: .8; }

.checkbox-field {
  /* Form labels use grid by default; this explicit variant stays a row. */
  display: flex!important;
  align-items: center;
  gap: 9px;
  color: var(--form-label-color,var(--text));
  font-size: var(--form-label-size,14px);
  font-weight: var(--form-label-weight,500);
  cursor: pointer;
}

.checkbox-field:has(> input:disabled) { cursor: not-allowed; }

.checkbox-group {
  display: grid;
  gap: 8px;
}

.checkbox-group > .checkbox-field { margin: 0; }

@media (pointer: coarse) {
  .checkbox-field { min-height: 44px; }
  input:not([type=checkbox], [type=radio], [type=range], .mc-source-url), select { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  input[type=checkbox]:not([role=switch]) { transition: none; }
}

@media (forced-colors: active) {
  input[type=checkbox]:not([role=switch]) {
    forced-color-adjust: none;
    border-color: ButtonText;
    background: Canvas;
    color: HighlightText;
  }
  input[type=checkbox]:not([role=switch]):is(:checked,:indeterminate) { border-color: Highlight; background: Highlight; }
  input[type=checkbox]:not([role=switch]):hover:not(:disabled) { border-color: Highlight; background: Canvas; }
  input[type=checkbox]:not([role=switch]):is(:checked,:indeterminate):hover:not(:disabled) { border-color: Highlight; background: Highlight; }
  input[type=checkbox]:not([role=switch]):focus-visible { outline-color: Highlight; }
  input[type=checkbox]:not([role=switch]):disabled { border-color: GrayText; color: GrayText; opacity: 1; }
  input[type=checkbox]:not([role=switch]):is(:checked,:indeterminate):disabled { background: Canvas; }
}

/* One search control for static and dynamically rendered panel lists.
   mc-search remains a compatible alias; sections own only its placement. */
.relay-panel .mc-search-input,
.relay-panel .mc-search {
  display:flex;
  align-items:center;
  flex:1;
  gap:6px;
  min-width:0;
  height:var(--ctl-s,32px);
  margin:0;
  padding:0 10px;
  border:1px solid var(--search-line);
  border-bottom-color:var(--search-line-bottom);
  border-radius:5px;
  background:var(--search-bg);
  color:var(--text);
  font-size:12.5px;
  font-weight:400;
  line-height:20px;
  cursor:text;
  transition:border-color .15s,box-shadow .15s;
}
.relay-panel :is(.mc-search-input,.mc-search) > .icon {
  position:static;
  flex:none;
  width:13px;
  height:13px;
  color:var(--search-muted);
  pointer-events:none;
}
.relay-panel :is(.mc-search-input,.mc-search) > input[type=search] {
  appearance:none;
  flex:1 1 0;
  width:100%;
  min-width:0;
  height:100%;
  min-height:0;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  color:inherit;
  font:inherit;
  outline:none;
  box-shadow:none;
}
.relay-panel :is(.mc-search-input,.mc-search) > input[type=search]:is(:hover,:focus,:focus-visible):not(:disabled) {
  background:transparent;
  outline:none;
  box-shadow:none;
}
.relay-panel :is(.mc-search-input,.mc-search) > input[type=search]::-webkit-search-decoration { appearance:none; }
.relay-panel :is(.mc-search-input,.mc-search) > input[type=search]::-webkit-search-cancel-button { margin-left:8px; cursor:pointer; }
.relay-panel :is(.mc-search-input,.mc-search) > input[type=search]::placeholder { color:var(--search-muted); }
.relay-panel :is(.mc-search-input,.mc-search):focus-within {
  border-bottom-color:var(--accent);
  box-shadow:inset 0 -1.5px 0 var(--accent);
  background:var(--search-focus-bg);
}
.relay-panel :is(.mc-search-input,.mc-search):has(> input:disabled) {
  background:var(--surface);
  color:var(--text-muted);
  opacity:.6;
  cursor:not-allowed;
}
@media(pointer:coarse) {
  .relay-panel :is(.mc-search-input,.mc-search) { font-size:var(--form-control-size,16px); }
}
@media(prefers-reduced-motion:reduce) {
  .relay-panel :is(.mc-search-input,.mc-search) { transition:none; }
}
@media(forced-colors:active) {
  .relay-panel :is(.mc-search-input,.mc-search):focus-within { outline:2px solid Highlight; outline-offset:2px; }
}

.relay-panel .mc-select-filter select {
  background-color: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 7px 28px 7px 9px;
  height: var(--ctl-s,32px);
  min-height: 0;
  font-size: 11px;
  max-width: 150px;
  cursor: pointer;
  padding-left: 27px;
  background-size: 12px;
  background-position: right 9px center;
}
.relay-panel .mc-select-filter select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.relay-panel .mc-select-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  flex-shrink: 0;
}
.relay-panel .mc-select-filter > :is(i, .icon) {
  position: absolute;
  top: 50%;
  left: 9px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}
.relay-panel .mc-select-filter > i svg,
.relay-panel .mc-select-filter > .icon {
  width: 12px;
  height: 12px;
  flex: none;
}
.relay-panel .mc-select-filter.has-filter select {
  color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.relay-panel .mc-select-filter.has-filter > :is(i, .icon) {
  color: var(--accent);
}
.relay-panel .mc-select-filter select:hover {
  border-color: color-mix(in srgb, var(--text-secondary) 32%, transparent);
}
@media (max-width: 1380px) {
  .relay-panel .mc-select-filter select {
    font-size: 11px;
    max-width: 150px;
    padding-left: 27px;
    padding-right: 28px;
    border-radius: 5px;
  }
}
@media (max-width: 850px) {
  .relay-panel .mc-select-filter select {
    font-size: 11px;
    max-width: 150px;
    padding-left: 27px;
    border-radius: 5px;
  }
}
@media (max-width: 640px) {
  .relay-panel .mc-select-filter select {
    font-size: 11px;
    max-width: 150px;
    padding-left: 27px;
    border-radius: 5px;
  }
}
@media (max-width: 390px) {
  .relay-panel .mc-select-filter select {
    max-width: 150px;
    font-size: 11px;
    padding-left: 27px;
    padding-right: 28px;
    border-radius: 5px;
  }
}
@media (max-width: 640px) {
  .relay-panel .mc-select-filter > :is(i, .icon) {
    display: none;
  }
  .relay-panel .mc-select-filter select {
    padding-left: 7px;
  }
}


