.voice-preferences-card {
  container-type: inline-size;
  container-name: voice-preferences;
  color: var(--text-secondary);
  background: var(--primary);
}

.voice-preferences-card > .card-body {
  padding: .9rem .85rem .85rem;
}

.voice-preferences-intro {
  margin: 0 0 .85rem;
  font-size: .82rem;
  line-height: 1.45;
  color: var(--text-third, var(--text-secondary));
}

.voice-preferences-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .55rem;
}

.voice-preference-item {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  width: 100%;
  min-width: 0;
  padding: .7rem .7rem .65rem;
  border: 1px solid var(--border-fourth);
  border-radius: .85rem;
  background: var(--primary);
  background: color-mix(in srgb, var(--theme-color) 6%, var(--primary));
}

.voice-preference-role {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.3;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
}

.voice-preference-role .anticon {
  flex: 0 0 auto;
  font-size: .85rem;
  color: var(--theme-color);
}

.voice-preference-controls {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
}

.voice-preferences-card .voice-preference-select {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: .4rem .7rem .4rem .65rem;
  border: 1px solid var(--border-fourth);
  border-radius: 999px;
  background: var(--primary);
  color: var(--text-secondary);
  font: 600 .86rem/1.2 'Poppins', sans-serif;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(var(--theme-black-rgb, 0, 0, 0), 0.06);
}

.voice-preferences-card .voice-preference-reset {
  flex: 0 0 auto;
}

.voice-preference-select:hover:not(:disabled) {
  border-color: var(--theme-color);
  color: var(--theme-color);
}

.voice-preference-select:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.voice-preference-flag {
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  filter: saturate(1.1);
}

.voice-preference-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-preference-caret {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: .7rem;
  opacity: .7;
}

.voice-preference-reset,
.voice-preference-action {
  margin: 0;
  padding: 0 .15rem;
  border: 0;
  background: transparent;
  color: var(--theme-color);
  font: 600 .75rem/1.2 'Poppins', sans-serif;
  text-decoration: underline;
  text-underline-offset: .15em;
  white-space: nowrap;
}

.voice-preference-reset:hover:not(:disabled),
.voice-preference-action:hover:not(:disabled) {
  color: var(--text-secondary);
}

.voice-preference-reset:disabled,
.voice-preference-action:disabled {
  opacity: .45;
  cursor: not-allowed;
  text-decoration: none;
}

.voice-preferences-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .75rem;
  margin-top: .85rem;
  padding-top: .7rem;
  border-top: 1px solid var(--border-fourth);
}

.voice-preferences-status {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
  min-width: 0;
  flex: 1 1 10rem;
  font-size: .75rem;
  line-height: 1.35;
  color: var(--text-third, var(--text-secondary));
}

.voice-preferences-status::before {
  content: "";
  flex: 0 0 auto;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--theme-color);
}

.voice-preferences-status[data-state="local"]::before,
.voice-preferences-status[data-state="synced"]::before {
  background: #16a34a;
}

.voice-preferences-status[data-state="pending"]::before {
  background: var(--theme-color);
}

.voice-preferences-status[data-state="error"]::before {
  background: #dc2626;
}

.voice-preferences-footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem .65rem;
}

.voice-preferences-card button,
#voicePickerContent button,
#voicePickerSearch {
  min-height: 44px;
  min-width: 44px;
}

.voice-preferences-card button:focus-visible,
#voicePickerContent button:focus-visible,
#voicePickerSearch:focus-visible {
  outline: 3px solid var(--theme-color);
  outline-offset: 3px;
}

#voicePickerContent .vp-description {
  margin: 0;
  padding: .75rem 1rem 0;
}

#voicePickerContent .vp-tools {
  flex-shrink: 0;
}

#voicePickerContent .vp-tabs {
  flex-wrap: wrap;
}

#voicePickerSearch {
  flex: 1 1 12rem;
  width: auto;
  color: var(--text-secondary);
  background: var(--primary);
  border-color: var(--border-fourth);
}

#voicePickerContent .vp-voices-grid {
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

@container voice-preferences (min-width: 28rem) {
  .voice-preferences-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container voice-preferences (max-width: 13.5rem) {
  .voice-preference-controls {
    flex-wrap: wrap;
  }

  .voice-preferences-card .voice-preference-select {
    flex-basis: 100%;
  }

  .voice-preference-reset {
    margin-left: auto;
  }
}

@media (max-width: 600px) {
  #voicePickerOverlay {
    align-items: flex-end;
    padding: 0;
  }
  #voicePickerContent {
    max-height: min(90dvh, 90vh);
    border-radius: 1rem 1rem 0 0;
  }
  #voicePickerContent .vp-voices-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  #voicePickerContent .vp-tabs > button {
    flex: 1;
  }
  #voicePickerContent .vp-tabs,
  #voicePickerSearch {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #voicePickerContent *,
  .voice-preferences-card * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
