/**
 * Form fields and listing toolbars — design.md §7.8, §7.9 (view toggle), §7.10.
 * Load after palette + typography on pages with fields or filter toolbars.
 */

/* --- Field layout --- */
.input-label, .field legend  {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

fieldset.field {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.inline-link {
  color: var(--text);
  font-weight: 500;
  text-underline-offset: 3px;
}

.field-hint .inline-link,
.card-panel__hint .inline-link,
.notice .inline-link {
  font-size: inherit;
  font-weight: 400;
  color: inherit;
}

.field-error {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--status-danger);
  display: none;
}

.field.is-invalid .field-error {
  display: block;
}

.field-error[hidden] {
  display: none;
}

.field.is-invalid .input-group,
.field.is-invalid .split-input,
.field.is-invalid .input,
.field.is-invalid .textarea,
.field.is-invalid select.input {
  outline: 2px solid var(--status-danger);
  outline-offset: 1px;
}

.field-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

/* --- Toggle switch (checkbox role="switch") ---
 *
 *   <div class="switch-line">
 *     <span class="setting-row__text">
 *       <label class="setting-row__label" for="id">Label</label>
 *     </span>
 *     <span class="switch">
 *       <input type="checkbox" id="id" role="switch" />
 *       <span class="switch-slider" aria-hidden="true"></span>
 *     </span>
 *   </div>
 *
 *   <label class="switch-row" for="id">
 *     <span>Label</span>
 *     <span class="switch">…</span>
 *   </label>
 *
 *   <label class="switch-field" for="id">
 *     <span class="switch">…</span>
 *     <span class="switch-field__text">Label beside control</span>
 *   </label>
 */
.switch-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 20px;
}

label.switch-row {
  cursor: pointer;
}

.switch-row > label:not(.switch) {
  margin: 0;
  font-weight: 400;
  font-size: 15px;
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}

.switch-row > span:first-child:not(.switch) {
  margin: 0;
  font-weight: 400;
  font-size: 15px;
  flex: 1 1 auto;
  min-width: 0;
}

.switch-row label small,
.switch-row > label small {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch-field__text {
  font-size: 14px;
  color: var(--text);
}

.switch {
  position: relative;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch input:disabled {
  cursor: not-allowed;
}

.switch:has(input:disabled) {
  opacity: 0.5;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--divider);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
  pointer-events: none;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Locked on: disabled + checked means "on because something else requires it"
 * (e.g. bundle visibility cascade). Stay readable as ON, muted track, lock glyph on the knob. */
.switch:has(input:disabled:checked) {
  opacity: 1;
}

.switch input:disabled:checked + .switch-slider {
  background: color-mix(in srgb, var(--primary) 45%, var(--divider));
}

.switch input:disabled:checked + .switch-slider::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 30px;
  top: 10px;
  background: var(--primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='4' y='10' width='16' height='12' rx='2.5'/%3E%3Cpath d='M8 10V7a4 4 0 0 1 8 0v3' fill='none' stroke='%23000' stroke-width='2.75'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='4' y='10' width='16' height='12' rx='2.5'/%3E%3Cpath d='M8 10V7a4 4 0 0 1 8 0v3' fill='none' stroke='%23000' stroke-width='2.75'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}

/* --- Text-like controls (pill on the control itself) --- */
.input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: #fff;
  border-radius: 999px;
  padding: 17px 20px;
  min-height: 52px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s ease;
}

.input:focus-visible {
  outline-color: var(--focus);
}

select.input {
  cursor: pointer;
  appearance: none;
  padding-right: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235c5c5c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 20px center;
}

select.input[multiple] { padding-right: 18px; background-image: none; }

.textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: #fff;
  border-radius: 24px;
  padding: 14px 18px;
  min-height: 96px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s ease;
}

.textarea:focus-visible {
  outline-color: var(--focus);
}

.textarea--multi {
  min-height: 120px;
}

.input--file {
  border-radius: 24px;
  min-height: 66px;
  padding: 14px 20px;
  font-size: 14px;
}

select.input.textarea--multi {
  min-height: 120px;
  border-radius: 24px;
  padding: 14px 18px;
  height: auto;
}

/* Pill wrapper when the control shares a row with a trailing action (password reveal, etc.) */
.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px 8px 20px;
  min-height: 66px;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: outline-color 0.15s ease;
}

.input-group:focus-within {
  outline-color: var(--primary);
}

.input-group > .input {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.input-group > .input:focus-visible {
  outline: none;
}

/* Pill field with a bordered leading segment (currency code, unit, …) and a borderless value input. */
.split-input {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: var(--shell-contrast, #fff);
  min-height: 66px;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: outline-color 0.15s ease;
}

.split-input:focus-within {
  outline-color: var(--primary);
}

.split-input__lead {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--panel-soft);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.split-input > .input {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 0;
  padding: 0 4px;
  background: transparent;
  border-radius: 0;
}

.split-input > .input:focus-visible {
  outline: none;
}

.input-group__action {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--panel-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--text);
  flex-shrink: 0;
}

.input-group__action:hover {
  filter: brightness(0.97);
}

/* --- Toolbar listing controls --- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--panel-soft);
  border-radius: 999px;
  padding: 8px;
  margin-bottom: 20px;
}

.toolbar--mb-lg {
  margin-bottom: 24px;
}

.search-field {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 999px;
  padding: 0 18px;
  min-height: 52px;
  color: var(--text-muted);
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: outline-color 0.15s ease;
}

.search-field:focus-within {
  outline-color: var(--primary);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

.search-field input:focus {
  outline: none;
}

.select-pill {
  position: relative;
  background: #fff;
  border-radius: 999px;
  min-height: 52px;
  display: flex;
  align-items: center;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: outline-color 0.15s ease;
}

.select-pill:focus-within {
  outline-color: var(--primary);
}

.select-pill select {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  padding: 0 40px 0 18px;
  min-height: 52px;
  cursor: pointer;
}

.select-pill select:focus {
  outline: none;
}

.select-pill svg {
  position: absolute;
  right: 16px;
  pointer-events: none;
  color: var(--text-secondary);
}

.view-toggle {
  display: flex;
  background: #fff;
  border-radius: 999px;
  padding: 4px;
  margin-left: auto;
}

.view-toggle button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.view-toggle button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
}

/* --- Selectable tags / pills --- */
.selector-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selector-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  box-sizing: border-box;
  border: 1px solid var(--divider);
  border-radius: 999px;
  padding: 0 16px;
  min-height: 44px;
  background: var(--shell-contrast, #fff);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
}

.selector-button:hover:not(:disabled):not(.selector-button-selected) {
  border-color: var(--control-tint);
  background: var(--panel-soft);
}

.selector-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.selector-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.selector-button-selected {
  border-color: var(--info);
  background: var(--info);
  color: var(--on-info-hover);
}

.selector-button-selected:hover:not(:disabled) {
  border-color: var(--info-hover);
  background: var(--info-hover);
  color: var(--on-info-hover);
}

@media (prefers-reduced-motion: reduce) {
  .selector-button {
    transition: none;
  }
}

/* --- Checkbox / radio rows --- */
.check-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 20px;
}

.checkbox,
.check-row input[type="radio"] {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.check-row label {
  margin: 0;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.45;
}

.check-row.is-invalid {
  outline: 2px solid var(--status-danger);
  outline-offset: 1px;
}

.radio-group,
.check-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-group:has(.radio-group-button) {
  gap: 12px;
}

/* Large selectable option (radio-group pattern) — design.md §7.8 */
.radio-group-button {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 18px 20px;
  border: 2px solid var(--divider);
  border-radius: var(--radius-inner);
  background: var(--shell-contrast, #fff);
  font-family: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease;
}

.radio-group-button:hover:not(:disabled) {
  border-color: var(--control-tint);
}

.radio-group-button--selected:hover:not(:disabled) {
  border-color: var(--primary);
}

.radio-group-button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.radio-group-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.radio-group-button:disabled:hover {
  border-color: var(--divider);
}

.radio-group-button--selected {
  border-color: var(--primary);
  background: var(--panel-soft);
}

.radio-group-button__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  color: var(--text);
}

.radio-group-button__icon svg {
  width: 22px;
  height: 22px;
}

.radio-group-button__icon .ph {
  font-size: 22px;
}

.radio-group-button__icon--selected {
  background: var(--primary);
  color: var(--on-primary);
}

.radio-group-button__body {
  flex: 1;
  min-width: 0;
}

.radio-group-button__label {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
}

.radio-group-button__hint {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.radio-group-button__check {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  opacity: 0;
  visibility: hidden;
}

.radio-group-button--selected .radio-group-button__check {
  opacity: 1;
  visibility: visible;
}

.radio-group-button__check svg {
  width: 18px;
  height: 18px;
}

@media (prefers-reduced-motion: reduce) {
  .radio-group-button {
    transition: none;
  }
}

/* --- Switch --- */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 20px;
}

.switch-row label {
  margin: 0;
  font-weight: 400;
  font-size: 15px;
}

.switch {
  position: relative;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--divider);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
  pointer-events: none;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- Range, color --- */
.range-field {
  background: #fff;
  border-radius: 24px;
  padding: 18px 20px;
}

.range-field input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  margin-top: 4px;
}

.range-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  min-height: 66px;
}

.color-field input[type="color"] {
  width: 44px;
  height: 44px;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .input,
  .textarea,
  .input-group,
  .split-input,
  .search-field,
  .select-pill,
  .switch-slider,
  .switch-slider::before {
    transition: none;
  }
}

@media (max-width: 900px) {
  .toolbar {
    border-radius: 32px;
  }

  .view-toggle {
    margin-left: 0;
  }
}

@media (max-width: 767px) {
  .field-grid-2 {
    grid-template-columns: 1fr;
  }

  .toolbar {
    border-radius: 28px;
    padding: 8px;
    gap: 8px;
  }

  .search-field {
    flex-basis: 100%;
  }

  .select-pill {
    flex: 1 1 0;
    min-width: 0;
  }

  .select-pill select {
    width: 100%;
  }

  .view-toggle {
    flex-basis: 100%;
  }

  .view-toggle button {
    flex: 1;
    justify-content: center;
  }
}

/* --- File drop area — design.md §7.8 (File drop area) --- */
.file-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  min-height: 176px;
  padding: 32px 24px;
  border: 2px dashed var(--divider);
  border-radius: var(--radius-inner);
  background: var(--shell-contrast, #fff);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.file-drop:hover {
  border-color: var(--control-tint);
}

.file-drop:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.file-drop.is-dragover {
  border-style: solid;
  border-color: var(--primary);
  background: var(--panel-soft);
}

.file-drop.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.field.is-invalid .file-drop {
  border-color: var(--status-danger);
}

.file-drop__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--panel-soft);
  color: var(--text);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.file-drop.is-dragover .file-drop__icon {
  background: var(--primary);
  color: var(--on-primary);
}

.file-drop__icon svg {
  width: 22px;
  height: 22px;
}

.file-drop__title {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.file-drop__browse {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.file-drop__hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Touch devices cannot drag files in: swap the instruction copy. */
.file-drop__text--touch { display: none; }

@media (hover: none) {
  .file-drop__text--pointer { display: none; }
  .file-drop__text--touch { display: inline; }
}

/* Compact: single row inside dense panels */
.file-drop--compact {
  flex-direction: row;
  justify-content: flex-start;
  gap: 14px;
  min-height: 66px;
  padding: 10px 20px 10px 10px;
  text-align: left;
}

.file-drop--compact .file-drop__icon {
  width: 44px;
  height: 44px;
  margin: 0;
}

.file-drop--compact .file-drop__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.file-drop--compact .file-drop__title {
  font-size: 14px;
}

/* Selected files */
.file-drop__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.file-drop__list:empty {
  display: none;
}

.file-drop__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-inner);
  background: var(--shell-contrast, #fff);
}

.file-drop__item-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--panel-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.file-drop__item-body {
  flex: 1;
  min-width: 0;
}

.file-drop__item-name {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-drop__item-meta {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
}

.file-drop__item.is-error {
  border-color: var(--status-danger-border);
  background: var(--status-danger-bg);
}

.file-drop__item.is-error .file-drop__item-meta {
  color: var(--status-danger);
}

@media (prefers-reduced-motion: reduce) {
  .file-drop,
  .file-drop__icon {
    transition: none;
  }
}

/* --- Native-input variants (design.md §7.8) ---
   A <label> wraps a real radio or checkbox, so the value submits with the form and
   the unsaved changes bar (7.11b) tracks it. Same look as the button versions.
     <label class="selector-button"><input type="checkbox" name="topic" value="x">Label</label>
     <label class="radio-group-button"><input type="radio" name="model" value="x">…</label>
     <div class="segmented-field" role="radiogroup"><label><input type="radio" …>Label</label>…</div> */
.selector-button:has(> input),
.radio-group-button:has(> input),
.segmented-field label { position: relative; }

.selector-button > input,
.radio-group-button > input,
.segmented-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.selector-button:has(> input:checked) {
  border-color: var(--info);
  background: var(--info);
  color: var(--on-info);
}

.selector-button:has(> input:checked):hover { border-color: var(--info-hover); background: var(--info-hover); }

.selector-button:has(> input:focus-visible),
.radio-group-button:has(> input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.radio-group-button:has(> input:checked) { border-color: var(--primary); background: var(--panel-soft); }
.radio-group-button:has(> input:checked) .radio-group-button__icon { background: var(--primary); color: var(--on-primary); }
.radio-group-button:has(> input:checked) .radio-group-button__check { opacity: 1; visibility: visible; }

span.radio-group-button__label,
span.radio-group-button__hint { display: block; }

/* Dense option cards (no icon tile, smaller check) for 2–4 choices in a settings panel.
   Columns fit the width; --2col keeps four choices as a 2 × 2 block. */
.radio-group--grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.radio-group--2col { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 560px) {
  .radio-group--2col { grid-template-columns: minmax(0, 1fr); }
}
.radio-group--grid .radio-group-button { align-items: flex-start; padding: 14px 16px; gap: 12px; }
.radio-group--grid .radio-group-button__check { width: 24px; height: 24px; }
.radio-group--grid .radio-group-button__check svg { width: 14px; height: 14px; }

/* Segmented field: a one-of-few choice as a pill track (7.9 look), backed by radios. */
.segmented-field {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 100%;
  padding: 4px;
  border-radius: 28px;
  background: #fff;
}

.segmented-field label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.segmented-field label:hover { color: var(--text); background: var(--panel-soft); }
.segmented-field label:has(input:checked) { background: var(--primary); color: var(--on-primary); }
.segmented-field label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Fixed text before or after the value inside an .input-group ("$", "eprofessor.com/c/", "days"). */
.input-group__affix { flex: none; font-size: 16px; color: var(--text-muted); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .segmented-field label { transition: none; }
}

/* --- RollDate (vendor popup calendar; bind via js/ep-design/rolldate-bind.js) --- */
@import '../../js/vendor/rolldate/css/rolldate.min.css';

.date-field .date-input {
  max-width: 240px;
}

.date-input {
  position: relative;
  display: inline-block;
  width: 200px;
  max-width: 100%;
  vertical-align: top;
}

.date-input .input--date {
  width: 100%;
  padding-right: 48px;
  cursor: pointer;
}

.date-input .input--date:read-only {
  cursor: pointer;
}

.date-input__icon {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  pointer-events: none;
}

/* RollDate popup — ep-design tokens (design.md palette + radii) */
.RollDate__container {
  z-index: 50;
  font-family: inherit;
  border-radius: var(--radius-inner);
  border: 1px solid var(--divider);
  background: var(--shell-contrast);
  box-shadow: var(--shadow-shell);
  padding: 14px 16px 16px;
  color: var(--text);
}

.RollDate__container.RollDate__theme_light {
  --rd-bg: var(--shell-contrast);
  --rd-border: var(--divider);
  --rd-text-primary: var(--text);
  --rd-text-secondary: var(--text-secondary);
  --rd-text-disabled: #b0b0b0;
  --rd-text-disabled-contrast: var(--text-muted);
  --rd-header-muted: var(--text-muted);
  --rd-weekday: var(--text-muted);
  --rd-hover-bg: var(--panel-soft);
  --rd-hover-border: var(--divider);
  --rd-accent: var(--primary);
  --rd-accent-strong: var(--primary-hover);
  --rd-accent-dark: var(--primary);
  --rd-accent-muted: var(--panel);
  --rd-range: var(--primary);
  --rd-range-strong: var(--primary);
  --rd-range-muted: var(--panel-soft);
  --rd-button-icon: var(--text-secondary);
  --rd-on-accent: var(--on-primary);
  --rd-highlight-dot: var(--primary);
}

.RollDate__header__year,
.RollDate__header__month,
.RollDate__calendar__switcher {
  font-weight: 600;
  color: var(--text);
}

.RollDate__calendar__switcher {
  border-radius: var(--radius-btn);
}

.RollDate__calendar__switcher:hover {
  background: var(--panel-soft);
}

.RollDate__calendar__header__weekday {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.RollDate__calendar__button {
  border-radius: var(--radius-btn);
  transition: background-color 0.15s ease;
}

.RollDate__calendar__button:hover {
  background: var(--panel-soft);
}

.RollDate__calendar__button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  box-shadow: none;
}

.RollDate__calendar__day {
  border-radius: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-color: transparent;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.RollDate__calendar__day:hover:not(:disabled) {
  background: var(--panel-soft);
  border-color: transparent;
}

.RollDate__calendar__day:focus-visible:not(:disabled) {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: transparent;
  box-shadow: none;
}

.RollDate__calendar__day--selected,
.RollDate__calendar__day--selected:hover {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}

.RollDate__calendar__day--today:not(.RollDate__calendar__day--selected) {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--divider);
}

.RollDate__calendar__day--today:not(.RollDate__calendar__day--selected):hover {
  background: var(--panel-soft);
  border-color: var(--divider);
}

.RollDate__calendar__day--range-first,
.RollDate__calendar__day--range-last,
.RollDate__calendar__day--range-first:hover,
.RollDate__calendar__day--range-last:hover {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}

.RollDate__calendar__day--range-selected,
.RollDate__calendar__day--range-selected:hover {
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
}

.RollDate__calendar__month,
.RollDate__calendar__year {
  border-radius: var(--radius-btn);
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.RollDate__calendar__month:hover,
.RollDate__calendar__year:hover {
  background: var(--panel-soft);
  border: 2px solid transparent;
}

.RollDate__calendar__month--current,
.RollDate__calendar__year--current,
.RollDate__calendar__month--current:hover,
.RollDate__calendar__year--current:hover {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
}

.RollDate__presets {
  border-top-color: var(--divider);
}

.RollDate__presets__button {
  border-radius: var(--radius-btn);
  border-color: var(--divider);
  background: var(--panel-soft);
  font-size: 12px;
}

.RollDate__presets__button:hover,
.RollDate__presets__button--active {
  border-color: var(--primary);
  background: var(--panel);
}

.RollDate__footer {
  border-top: 1px solid var(--divider);
}

.RollDate__footer__button {
  border-radius: 999px;
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.RollDate__footer__button--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.RollDate__footer__button--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.RollDate__footer__button--secondary {
  background: var(--button-secondary-bg);
  border-color: var(--divider);
  color: var(--text);
}

.RollDate__footer__button--secondary:hover {
  background: var(--panel);
}

.RollDate__footer__button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
