.picker {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
}
.picker[hidden] { display: none; }
.picker__backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  /*
   * No blur. At 2px it did not obscure anything, it only smeared the greeting
   * behind into legible-but-wrong grey haze, which reads as a rendering fault
   * rather than depth. A stronger dim does the actual job of receding.
   */
}
.picker__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 48px));
  max-height: min(70vh, 640px);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  /*
   * Layered short shadows instead of one long one.
   *
   * A single 60px falloff at low alpha spreads ~115 opacity levels across 60px
   * of near-black, so each 8-bit step covers several pixels and reads as
   * concentric rings. Stacking shorter, denser shadows puts the steps close
   * enough together that the eye cannot resolve them.
   */
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.5),
    0 8px 16px rgba(0, 0, 0, 0.36),
    0 18px 32px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}
.picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.picker__header h2 { margin: 0; font-size: 15px; font-weight: 500; }
.picker__body {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}
.picker__group { padding: 12px 8px 4px; }
.picker__group-label {
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.model-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease;
}
.model-row:hover { background: var(--bg-hover-solid); }
.model-row.is-selected { background: var(--accent-soft); }
.model-row__info {
  flex: 1;
  min-width: 0;
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.model-row__name {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-row__detail {
  display: block;
  color: var(--text-faint);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-row__action {
  flex: none;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
}
.model-row__action:hover { background: var(--bg-raised); color: var(--text); }
.model-row__star {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-faint);
  transition: background 120ms ease, color 120ms ease;
}
.model-row__star:hover {
  background: var(--bg-raised);
  color: var(--star);
}
/* Gold, and filled rather than outlined, so the favourite reads at a glance. */
.model-row__star.is-default { color: var(--star); }
.model-row__star.is-default svg { fill: var(--star); }
.picker__empty {
  padding: 26px 16px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  line-height: 1.7;
}
.picker__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
}
.picker__log {
  margin: 8px;
  padding: 10px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
}
/* Settings dialog — the picker shell, widened and split in two ---------- */
/*
 * Ten stacked sections was one long scroll where finding anything meant
 * remembering roughly how far down it lived. The rail turns that into six
 * named places, and the extra width lets a section breathe rather than wrap.
 */
.picker__panel--wide {
  width: min(880px, calc(100vw - 48px));
  max-height: min(78vh, 700px);
}

.settings {
  flex: 1;
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  min-height: 0;
}

.settings__rail {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
}

.settings__tab {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}
.settings__tab:hover { background: var(--bg-hover-solid); color: var(--text); }
.settings__tab.is-active {
  background: var(--accent-soft);
  color: var(--text);
}

.settings__body {
  min-width: 0;
  overflow-y: auto;
}

/* Inside a panel the sections are already separated by the panel itself. */
.settings__panel > .pref:first-child { padding-top: 20px; }
.settings__panel > .pref:last-child { border-bottom: none; }

@media (max-width: 720px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings__rail {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }
}

/* Settings dialog — reuses the picker shell. */
.pref {
  padding: 16px 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.pref:last-child { border-bottom: none; }
.pref__title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.pref__hint {
  margin: 10px 0 0;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.6;
}
.pref__hint code {
  padding: 1px 5px;
  background: var(--bg-deep);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.pref__profile {
  display: flex;
  align-items: center;
  gap: 14px;
}
.field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field__label {
  color: var(--text-faint);
  font-size: 12px;
}
.field__input {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 120ms ease;
}
.field__input:focus { border-color: var(--accent); }
.pref__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.folder-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.folder-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.folder-row__path {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.folder-row__badge {
  flex: none;
  color: var(--text-faint);
  font-size: 11px;
}
.folder-row__remove {
  flex: none;
  color: var(--text-faint);
  font-size: 12px;
}
.folder-row__remove:hover { color: var(--accent); }
/* Theme picker ---------------------------------------------------------- */
.theme-select { position: relative; }
.theme-select__trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 9px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 120ms ease, border-color 120ms ease;
}
.theme-select__trigger:hover { background: var(--bg-hover-solid); }
.theme-select__label {
  flex: 1;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}
.theme-select__trigger [data-icon],
.theme-select__trigger .icon { color: var(--text-faint); }
.theme-select__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  max-height: 244px;
  padding: 4px;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.5),
    0 6px 14px rgba(0, 0, 0, 0.34),
    0 14px 26px rgba(0, 0, 0, 0.22);
}
.theme-select__menu[hidden] { display: none; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 7px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}
.theme-option:hover { background: var(--bg-hover-strong); color: var(--text); }
.theme-option.is-active { background: var(--accent-soft); color: var(--text); }
.theme-option__label { flex: 1; }
.theme-option__check { color: var(--accent); opacity: 0; }
.theme-option.is-active .theme-option__check { opacity: 1; }
/* The preview tile, shared by the trigger and every option. */
.theme-swatch {
  position: relative;
  flex: none;
  width: 46px;
  height: 22px;
  border: 1px solid;
  border-radius: 5px;
  overflow: hidden;
}
.theme-swatch__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 34%;
}
.theme-swatch__dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
/* Slider row ------------------------------------------------------------ */
/*
 * A value you judge by feel, so the track is wide and the readout sits at the
 * end of it: drag, watch the background lean, stop when it looks right.
 */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.slider-row__label {
  flex: none;
  color: var(--text);
  font-size: 13px;
}
.slider-row__value {
  flex: none;
  min-width: 42px;
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.slider {
  flex: 1;
  min-width: 0;
  height: 4px;
  margin: 0;
  appearance: none;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 120ms ease;
}
.slider:hover::-webkit-slider-thumb { transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Switch row ------------------------------------------------------------ */
.switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.switch-row__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.switch-row__label { color: var(--text); font-size: 13px; }
.switch-row__hint { color: var(--text-faint); font-size: 12px; line-height: 1.5; }
.switch {
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  margin: 0;
  appearance: none;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 140ms ease, background 140ms ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); background: var(--on-accent); }
/* Permission modes ------------------------------------------------------ */

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0;
}
.mode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.mode-row:hover { background: var(--bg-hover-solid); }
.mode-row.is-active {
  background: var(--accent-soft);
  border-color: var(--border-focus);
}
.mode-row__text { flex: 1; min-width: 0; }
.mode-row__label {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.mode-row__hint {
  display: block;
  color: var(--text-faint);
  font-size: 12px;
}
.mode-row__count {
  flex: none;
  color: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mode-row__tick {
  flex: none;
  width: 15px;
  color: var(--accent);
}
/* Full system access reads as a warning once it is actually on. */
.switch-row__hint.is-warning { color: hsl(30 85% 66%); }

/* First-run empty state: the next step is choosing a folder. */
.picker__empty-title {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 15px;
}

.picker__empty-action {
  margin-top: 14px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
}

.picker__empty-action:hover { filter: brightness(1.07); }

/* Destructive actions --------------------------------------------------- */

.danger-btn {
  padding: 7px 14px;
  border: 1px solid hsl(5 45% 38%);
  border-radius: 8px;
  color: hsl(5 70% 72%);
  font-size: 13px;
  transition: background 120ms ease, color 120ms ease;
}

.danger-btn:hover { background: hsl(5 55% 42% / 0.18); color: hsl(5 80% 80%); }

.danger-btn--solid {
  border-color: transparent;
  background: hsl(5 62% 44%);
  color: hsl(0 0% 98%);
}

.danger-btn--solid:hover { background: hsl(5 62% 50%); color: hsl(0 0% 100%); }

/* The confirmation replaces the button, so it has to read as a warning. */
.confirm {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid hsl(5 45% 34%);
  border-radius: var(--radius-sm);
  background: hsl(5 40% 20% / 0.28);
}

.confirm__text {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.confirm__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* API keys --------------------------------------------------------------- */
/*
 * The list is ordered, and the order is the point: row 1 pays for the next
 * message. The rank number carries that meaning, so it is the first thing on
 * every row rather than a decoration.
 *
 * Failover never crosses providers, so each provider is its own block with its
 * own numbering — two lists that happen to sit above one another, not one list
 * with headings in it.
 */
.key-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 12px;
}

.key-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.key-group__label {
  margin: 0;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Which provider the form below is for. One choice, always visible. */
.key-provider {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.key-provider__option {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 12px;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.key-provider__option:hover { color: var(--text); }

.key-provider__option.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.key-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  font-size: 12px;
}
.key-row.is-exhausted { border-left-color: hsl(30 85% 66%); }
.key-row.is-invalid { border-left-color: hsl(0 70% 62%); }
.key-row.is-good { border-left-color: hsl(142 55% 38%); }

.key-row__rank {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-sunken, var(--bg-raised));
  border: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.key-row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.key-row__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-row__detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-row.is-exhausted .key-row__detail { color: hsl(30 85% 66%); }
.key-row.is-invalid .key-row__detail { color: hsl(0 70% 62%); }
.key-row.is-good .key-row__detail { color: hsl(142 60% 28%); }
[data-theme="black"] .key-row.is-good .key-row__detail { color: hsl(142 50% 62%); }

.key-row__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
}
.key-row__move,
.key-row__remove {
  color: var(--text-faint);
  padding: 2px;
  line-height: 0;
}
.key-row__move:hover:not(:disabled),
.key-row__remove:hover { color: var(--accent); }
.key-row__move:disabled { opacity: 0.25; cursor: default; }

.key-row__test {
  color: var(--text-faint);
  font-size: 11px;
  padding: 2px 6px;
  margin-left: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.key-row__test:hover:not(:disabled) { color: var(--accent); }
.key-row__test:disabled { opacity: 0.5; cursor: default; }
.key-row__test.is-good {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: hsl(142 60% 28%);
  border-color: hsl(142 45% 62%);
}
[data-theme="black"] .key-row__test.is-good {
  color: hsl(142 50% 62%);
  border-color: hsl(142 40% 38%);
}

.key-summary {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-faint);
}
.key-summary.is-warning { color: hsl(30 85% 66%); }

/* The two fields sit side by side: a name and the secret it belongs to. */
.key-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 10px;
}
@media (max-width: 560px) {
  .key-add { grid-template-columns: minmax(0, 1fr); }
}

#prefKeyProviderHint { margin-top: 10px; }
#prefKeyMessage { margin-top: 10px; }
#prefKeyMessage.is-error { color: hsl(0 70% 45%); }
#prefKeyMessage.is-good { color: hsl(142 60% 28%); }
[data-theme="black"] #prefKeyMessage.is-error { color: hsl(0 70% 62%); }
[data-theme="black"] #prefKeyMessage.is-good { color: hsl(142 50% 62%); }
