/* ── Settings modal sections ─────────────────────────────────────────────── */

.settings-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: oklch(var(--bc) / 45%);
  margin: 1.1rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid oklch(var(--b3));
}

.settings-section-label:first-of-type { margin-top: 0; }

/* ── Theme swatch grid ───────────────────────────────────────────────────── */

.theme-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 6px;
}

.theme-swatch {
  position: relative;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  background: linear-gradient(
    to right,
    var(--swatch-base)    0%,
    var(--swatch-base)   50%,
    var(--swatch-primary) 50%,
    var(--swatch-primary) 100%
  );
  padding: 0;
}

.theme-swatch:hover  { transform: scale(1.05); border-color: oklch(var(--bc) / 35%); }
.theme-swatch.active { border-color: oklch(var(--bc)); }

.theme-swatch-label {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.58rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.8), 0 0 4px rgba(0,0,0,0.8);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 3px;
}

/* ── Settings modal width ─────────────────────────────────────────────────── */

#settings-modal .modal-box {
  max-width: 42rem;
  width: min(42rem, 95vw);
}

/* ── Model picker (settings modal) ───────────────────────────────────────── */

.model-picker {
  border: 1px solid oklch(var(--b3));
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* Chevron indicator via SVG background on the input */
.model-picker > input {
  display: block;
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  background: oklch(var(--b2));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  border: none;
  border-bottom: 1px solid oklch(var(--b3));
  border-radius: 0;
  color: oklch(var(--bc));
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: background-color 0.1s;
}

.model-picker > input:focus {
  background-color: oklch(var(--b1));
  cursor: text;
}

.model-picker > input::placeholder {
  color: oklch(var(--bc) / 55%);
}

/* Model lists: collapsed by default, expanded when picker is .open */
.model-picker > ul {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  background: oklch(var(--b1));
  padding: 0;
  margin: 0;
  transition: max-height 0.15s ease;
}

.model-picker.open > ul {
  max-height: 14rem;
  overflow-y: auto;
}

/* ID rules kept for specificity — scroll/layout managed by .open state above */
#model-list,
#naming-model-list,
#vision-model-list,
#voice-cleanup-model-list {
  list-style: none;
  background: oklch(var(--b1));
  padding: 0;
  margin: 0;
}

#naming-model-section {
  padding-left: 0.75rem;
  border-left: 2px solid oklch(var(--b3));
}

.naming-sublabel {
  font-size: 0.8rem;
  opacity: 0.7;
}

.model-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.85rem;
  font-size: 0.875rem;
  color: oklch(var(--bc));
  border-bottom: 1px solid oklch(var(--b3) / 40%);
  cursor: pointer;
  transition: background 0.1s;
  gap: 0.5rem;
}

.model-item:last-child {
  border-bottom: none;
}

.model-item:hover {
  background: oklch(var(--b2));
}

.model-item.active {
  color: oklch(var(--p));
  background: oklch(var(--p) / 8%);
  border-left: 3px solid oklch(var(--p));
  padding-left: calc(0.85rem - 3px);
}

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

.model-check {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: oklch(var(--p));
  opacity: 0;
}

.model-item.active .model-check {
  opacity: 1;
}

/* Badge on custom provider model items in the picker */
.model-badge-custom {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  background: oklch(var(--a) / 20%);
  color: oklch(var(--a));
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Custom provider list (settings modal) ────────────────────────────────── */

.custom-providers-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.custom-provider-section {
  border: 1px solid oklch(var(--b3));
  border-radius: 0.5rem;
  overflow: hidden;
}

.custom-provider-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: oklch(var(--b2));
  font-size: 0.8rem;
}

.custom-provider-name {
  font-weight: 600;
  flex-shrink: 0;
}

.custom-provider-url {
  flex: 1;
  opacity: 0.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  min-width: 0;
}

.custom-provider-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.4;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1rem;
  color: inherit;
}
.custom-provider-delete:hover { opacity: 1; color: oklch(var(--er)); }

.custom-provider-models {
  padding: 0.4rem 0.65rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.custom-model-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  padding: 0.2rem 0;
}

.custom-model-name {
  font-weight: 500;
  flex-shrink: 0;
}

.custom-model-hint {
  flex: 1;
  opacity: 0.5;
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.custom-add-model-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.custom-add-model-row .input { min-width: 0; flex: 1; }
.custom-add-model-row .input:first-child { flex: 0 0 7rem; }

/* ── Settings tabs ─────────────────────────────────────────────────────────── */

.settings-modal-box {
  max-height: 85vh;
  overflow-y: auto;
}

#local-models-list {
  min-height: 4rem;
}

.settings-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid oklch(var(--b3));
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.settings-tab {
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  cursor: pointer;
  color: oklch(var(--bc) / 60%);
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.settings-tab:hover {
  color: oklch(var(--bc));
}

.settings-tab.active {
  color: oklch(var(--p));
  border-bottom-color: oklch(var(--p));
  font-weight: 600;
}

.settings-panel {
  /* No extra styling needed — inherits modal layout */
}

/* ── Provider routing UI ─────────────────────────────────────────────────────── */

.routing-blocklist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
  min-height: 1.2rem;
}

.routing-blocklist-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: oklch(var(--b3));
  font-size: 0.7rem;
  color: oklch(var(--bc) / 80%);
}

.routing-blocklist-chip-del {
  background: none;
  border: none;
  cursor: pointer;
  color: oklch(var(--bc) / 50%);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}
.routing-blocklist-chip-del:hover { color: oklch(var(--er)); }

.routing-health-panel {
  margin-top: 0.5rem;
  overflow-x: auto;
}

.routing-health-table {
  width: 100%;
  font-size: 0.68rem;
  border-collapse: collapse;
}
.routing-health-table th,
.routing-health-table td {
  padding: 0.25rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid oklch(var(--b3));
  white-space: nowrap;
}
.routing-health-table th {
  color: oklch(var(--bc) / 55%);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
}
