/* FAHAD — settings dialog (assets/js/settings.js). Uses the tokens and shared components from base.css.
   Layout: desktop = centered panel [tabs | content], providers = [list | detail];
   < 900px = providers master/detail; < 720px = full-screen sheet with horizontal tabs. RTL via logical properties. */

/* ---------- Dialog & shell ---------- */
.st-dialog {
  width: min(1080px, calc(100vw - 48px));
  height: min(800px, calc(100dvh - 48px));
  max-width: none;
  max-height: none;
  margin: auto;
  overflow: visible;
}
.st-dialog[open] .st-shell { animation: st-in var(--dur-slow) var(--ease) both; }
.st-dialog[open]::backdrop { animation: st-fade var(--dur) ease both; }
.st-dialog.is-closing .st-shell { animation: st-out 170ms var(--ease) both; }
.st-dialog.is-closing::backdrop { animation: st-fade 170ms ease reverse both; }

@keyframes st-in { from { opacity: 0; transform: translateY(14px) scale(0.975); } }
@keyframes st-out { to { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes st-fade { from { opacity: 0; } }
@keyframes st-sheet-in { from { opacity: 0.4; transform: translateY(32px); } }
@keyframes st-panel-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes st-shimmer { to { background-position: -200% 0; } }
@keyframes st-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes st-pop { 40% { transform: scale(1.06); } }
@keyframes st-pulse { 50% { box-shadow: 0 0 0 6px var(--warn-soft); } }

.st-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  background:
    radial-gradient(600px 300px at 0% 0%, var(--bg-glow-1), transparent 70%),
    radial-gradient(520px 320px at 100% 100%, var(--bg-glow-2), transparent 70%),
    var(--surface-solid);
  box-shadow: var(--shadow-2);
}

/* ---------- Header ---------- */
.st-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 14px 22px;
  border-bottom: 1px solid var(--border);
}
.st-head-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: var(--on-primary, #fff);
  background: var(--gradient-accent);
  box-shadow: var(--glow);
}
.st-head-badge-sm { width: 38px; height: 38px; border-radius: 11px; }
.st-head-text { flex: 1; min-width: 0; }
.st-title { margin: 0; font-size: 19px; font-weight: 700; }
.st-subtitle { margin: 0; font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-close { flex: none; color: var(--text-2); }

/* ---------- Tabs ---------- */
.st-main { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 0; }
.st-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px;
  border-inline-end: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
}
.st-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 14.5px;
  text-align: start;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.st-tab:hover { background: var(--surface-hover); color: var(--text); }
.st-tab:focus-visible { outline-offset: -2px; }
.st-tab[aria-selected='true'] { background: var(--accent-soft); color: var(--accent); }
.st-tab[aria-selected='true']::before {
  content: '';
  position: absolute;
  inset-block: 10px;
  inset-inline-start: -12px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--gradient-accent);
}
[dir='rtl'] .st-tab[aria-selected='true']::before { border-radius: 4px 0 0 4px; }
.st-tab-icon { display: inline-flex; }
.st-tab-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.st-tab-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

/* ---------- Content & panels ---------- */
.st-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 26px 28px;
}
.st-content[data-tab='providers'] { overflow: hidden; padding: 0; }
.st-panel { outline: none; }
.st-panel[data-tab='providers'] { height: 100%; }
.st-panel.st-enter { animation: st-panel-in 260ms var(--ease) both; }
.st-ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.st-spin { animation: fahad-spin 0.9s linear infinite; }
.st-stack { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }
.st-fieldset { display: contents; }
.st-panel :is(.input, .select, .textarea):disabled { opacity: 0.6; cursor: not-allowed; }
.st-panel .switch:has(input:disabled),
.st-fieldset:disabled :is(.st-radio-card, .st-seg, .st-chip, .st-adv-summary) { opacity: 0.6; cursor: not-allowed; }

.st-card {
  container-type: inline-size;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.st-card-head { margin-bottom: 14px; }
.st-card-title { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
.st-card-desc { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.65; }
.st-card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.st-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.st-field-full { grid-column: 1 / -1; }
.st-field-center { justify-content: center; }
.st-field .field-label > span:first-child { min-width: 0; }
.st-field .field-label > .badge,
.st-field .field-label > output,
.st-field .field-label > .st-counter { margin-inline-start: auto; }
.field-error:empty { display: none; }
.st-panel .field-error { font-weight: 500; }

@container (max-width: 440px) {
  .st-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Callouts */
.st-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.65;
}
.st-callout > .st-ico { margin-top: 2px; }
.st-callout p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-2); }
.st-callout .btn { margin-inline-start: auto; flex: none; }
.st-callout-success { background: var(--success-soft); border-color: transparent; }
.st-callout-success > .st-ico { color: var(--success); }
.st-callout-accent { background: var(--accent-soft); border-color: transparent; }
.st-callout-accent > .st-ico { color: var(--accent); }
.st-callout-warn { background: var(--warn-soft); border-color: transparent; }
.st-callout-warn > .st-ico { color: var(--warn); }
.st-callout-danger { background: var(--danger-soft); border-color: transparent; }
.st-callout-danger > .st-ico { color: var(--danger); }
.st-callout-muted { margin: 0; color: var(--text-2); }
.st-callout-muted > .st-ico { color: var(--success); }

/* Chips */
.st-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.st-chip {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.st-chip.ltr { font-family: var(--font-mono); font-weight: 500; font-size: 12px; }
.st-chip:hover { border-color: var(--border-strong); color: var(--text); }
.st-chip[aria-pressed='true'] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* Switch alignment inside fields */
.st-switch { align-self: flex-start; min-height: 32px; }
.st-danger-text { color: var(--danger); }
.st-danger-text:hover:not(:disabled) { background: var(--danger-soft); }

/* ---------- Providers ---------- */
.st-providers { display: grid; grid-template-columns: 304px minmax(0, 1fr); height: 100%; min-height: 0; }
.st-readonly { display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.st-content[data-tab='providers'] .st-readonly { height: 100%; gap: 0; }
.st-content[data-tab='providers'] .st-ro-banner { margin: 12px 14px; }
.st-readonly > .st-providers { flex: 1; min-height: 0; }
.st-ro-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13.5px;
}
.st-ro-banner > .st-ico { color: var(--accent); }
.st-ro-banner > span:not(.st-ico) { flex: 1; }

.st-plist {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-inline-end: 1px solid var(--border);
  background: var(--surface);
}
.st-plist-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 8px; }
.st-search { position: relative; flex: 1; min-width: 0; }
.st-search-icon { position: absolute; inset-block: 0; inset-inline-start: 10px; color: var(--text-3); pointer-events: none; }
.st-search-input { height: 36px; min-height: 36px; padding-inline-start: 34px; font-size: 13.5px; }
.st-add-provider { flex: none; }
.st-plist-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 8px 12px; }
.st-pgroup-title {
  padding: 12px 10px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-3);
}
[dir='ltr'] .st-pgroup-title { text-transform: uppercase; }
.st-plist-empty { margin: 0; padding: 32px 16px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.st-plist-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.st-prow {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 2px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: start;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.st-prow:hover { background: var(--surface-hover); }
.st-prow[aria-current='true'] { background: var(--surface-3); border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.st-prow[data-error='true'] { border-color: var(--danger); }
.st-prow-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.st-prow-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-prow[data-dirty='true'] .st-prow-name::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-start: 6px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--warn);
}
.st-prow-model {
  display: block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[dir='rtl'] .st-prow-model { text-align: right; }
.st-prow-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 118px; }
.st-prow .badge { height: 19px; padding: 0 6px; font-size: 10.5px; }

.st-mono {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.st-prow[data-active='true'] .st-mono,
.st-mono-lg { background: var(--gradient-accent); border-color: transparent; color: var(--on-primary, #fff); }
.st-mono-lg { width: 52px; height: 52px; border-radius: 15px; font-size: 18px; box-shadow: var(--glow); }

.st-pdetail {
  container-type: inline-size;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 26px 28px;
}
.st-pd-back { display: none; margin-bottom: 12px; }
.st-pd-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin-bottom: 14px; }
.st-pd-title { flex: 1; min-width: 180px; }
.st-pd-name { margin: 0; font-size: 21px; font-weight: 700; }
.st-pd-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: var(--text-3); }
.st-dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--text-3); }
.st-pd-links { display: flex; flex-wrap: wrap; gap: 8px; }
.st-pd-links .btn { text-decoration: none; }
.st-ext { opacity: 0.7; }
.st-pd-notes {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.7;
}
.st-pd-notes > .st-ico { margin-top: 3px; color: var(--info); }
.st-pdetail > .st-grid { margin-top: 14px; }

.st-key-row, .st-model-row { display: flex; gap: 8px; align-items: stretch; }
.st-key-row > .input, .st-model-row > .input, .st-model-row > .select { flex: 1; min-width: 0; }
.st-key-eye, .st-key-clear { flex: none; color: var(--text-2); }
.st-key-clear:hover:not(:disabled) { color: var(--danger); }
.st-key-input::placeholder { font-family: var(--font); }
/* Keys are typed left-to-right, but the (localized) placeholder follows the interface direction. */
[dir='rtl'] .st-key-input:placeholder-shown { direction: rtl; text-align: right; }
.st-fetch { flex: none; }
.st-field > .st-chips { margin-top: 8px; }

.st-adv { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.st-adv-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--text-2);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius);
  user-select: none;
}
.st-adv-summary::-webkit-details-marker { display: none; }
.st-adv-summary:hover { color: var(--text); background: var(--surface-hover); }
.st-adv-chevron { margin-inline-start: auto; transition: transform var(--dur) var(--ease); }
.st-adv[open] .st-adv-chevron { transform: rotate(180deg); }
.st-adv-body { padding: 4px 14px 10px; }
.st-json { min-height: 74px; font-size: 12.5px; }

.st-pd-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-strong);
}
.st-spacer { flex: 1; }
.st-active-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--success-soft);
  color: var(--success);
  font-size: 14px;
  font-weight: 700;
}
.st-active-pill.is-queued { background: var(--accent-soft); color: var(--accent); }
.st-pop { animation: st-pop 360ms var(--ease-spring); }

.st-test {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13.5px;
}
.st-test[data-status='idle'] { padding: 8px 2px 0; background: none; }
.st-test[data-status='ok'] { background: var(--success-soft); }
.st-test[data-status='error'] { background: var(--danger-soft); }
.st-test-note { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; color: var(--text-3); }
.st-test-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.st-test[data-status='ok'] .st-test-head > .st-ico { color: var(--success); }
.st-test[data-status='error'] .st-test-head > .st-ico { color: var(--danger); }
.st-test[data-status='running'] .st-test-head > .st-ico { color: var(--accent); }
.st-test-model { font-size: 12.5px; color: var(--text-2); }
.st-test-caption { margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.st-test-sample {
  margin: 4px 0 0;
  padding: 10px 12px;
  border-inline-start: 3px solid var(--success);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
}
.st-test-error { margin: 6px 0 0; color: var(--text); line-height: 1.65; }

/* ---------- Radio cards & segmented controls ---------- */
.st-radio-input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.st-radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.st-radio-cards[data-name='theme'] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-radio-cards[data-name='outfit'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.st-radio-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.st-radio-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.st-radio-card:has(.st-radio-input:checked) {
  border-color: var(--accent);
  background: linear-gradient(160deg, var(--accent-soft), transparent 75%), var(--surface-2);
  box-shadow: var(--glow);
}
.st-radio-card:has(.st-radio-input:focus-visible) { box-shadow: var(--ring); }
.st-radio-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--accent);
}
.st-radio-text { display: flex; flex-direction: column; gap: 3px; padding-inline-end: 22px; }
.st-radio-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; font-size: 14.5px; }
.st-radio-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.6; }
.st-radio-check {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  color: transparent;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.st-radio-card:has(.st-radio-input:checked) .st-radio-check { background: var(--accent); border-color: transparent; color: var(--accent-contrast); }
.st-radio-art { display: block; overflow: hidden; border-radius: 10px; }

.st-segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
}
.st-seg {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border-radius: 9px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.st-seg:hover { color: var(--text); background: var(--surface-hover); }
.st-seg:has(.st-radio-input:checked) { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.st-seg:has(.st-radio-input:focus-visible) { box-shadow: var(--ring); }

/* Theme previews (swatches mirror the base.css themes regardless of the current one) */
.st-theme-art {
  --ta-bg: #060913; --ta-side: #0f1630; --ta-bubble: #1a2242; --ta-line: #26305a;
  display: flex;
  height: 84px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--ta-bg);
}
.st-theme-art[data-preview='gray'] { --ta-bg: #121316; --ta-side: #1b1c20; --ta-bubble: #2c2f35; --ta-line: #3c4048; }
.st-theme-art[data-preview='black'] { --ta-bg: #000000; --ta-side: #0d0d10; --ta-bubble: #1c1c21; --ta-line: #2a2a31; }
.st-ta-side { width: 26%; background: var(--ta-side); }
.st-ta-main { flex: 1; display: flex; flex-direction: column; gap: 7px; padding: 11px 10px; }
.st-ta-line { width: 45%; height: 6px; border-radius: 4px; background: var(--ta-line); }
.st-ta-bubble { width: 72%; height: 15px; border-radius: 8px; background: var(--ta-bubble); }
.st-ta-user { align-self: flex-end; width: 46%; background: var(--gradient-user); }

/* Teacher portraits (rendered from the realistic 3D models) */
.st-radio-cards[data-name='teacher'] .st-radio-art {
  height: 168px; display: flex; align-items: flex-end; justify-content: center;
  background: radial-gradient(circle at 50% 75%, var(--accent-soft), transparent 70%), var(--surface-3);
}
.st-teacher-img { width: auto; height: 100%; max-width: 100%; object-fit: contain; display: block; }

/* Outfit illustrations */
.st-radio-cards[data-name='outfit'] .st-radio-art {
  --st-art-skin: #c58c5f; --st-art-hair: #2a1c14; --st-art-eye: #1b1f2a; --st-art-cloth: #f8fafc; --st-art-red: #d42a2a;
  --st-art-agal: #111318; --st-art-thobe: #eef2f7; --st-art-top: #0d474d; --st-art-crew: #0a3a3f; --st-art-emblem: #5ff5da;
  height: 120px;
  background: radial-gradient(circle at 50% 70%, var(--accent-soft), transparent 70%), var(--surface-3);
}
.st-radio-art svg { width: 100%; height: 100%; }
.st-art-skin { fill: var(--st-art-skin); }
.st-art-hair { fill: var(--st-art-hair); }
.st-art-eye { fill: var(--st-art-eye); }
.st-art-cloth { fill: var(--st-art-cloth); }
.st-art-red { fill: var(--st-art-red); }
.st-art-thobe { fill: var(--st-art-thobe); }
.st-art-top { fill: var(--st-art-top); }
.st-art-crew { fill: none; stroke: var(--st-art-crew); stroke-width: 3; stroke-linecap: round; }
.st-art-emblem { fill: none; stroke: var(--st-art-emblem); stroke-width: 1.6; stroke-linejoin: round; }
.st-art-agal { fill: none; stroke: var(--st-art-agal); stroke-width: 3.2; }
.st-art-line { fill: none; stroke: var(--st-art-hair); stroke-width: 1.6; stroke-linecap: round; opacity: 0.55; }

/* ---------- Sliders ---------- */
.st-slider-field .field-label { align-items: center; }
.st-value {
  min-width: 56px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.st-slider { padding-top: 4px; }
.st-range {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  margin: 8px 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill));
  cursor: pointer;
}
[dir='rtl'] .st-range { background: linear-gradient(to left, var(--accent) var(--fill), var(--surface-3) var(--fill)); }
.st-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform var(--dur-fast) var(--ease);
}
.st-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.st-range:hover::-webkit-slider-thumb, .st-range:active::-webkit-slider-thumb { transform: scale(1.12); }
.st-range:focus-visible { outline: none; }
.st-range:focus-visible::-webkit-slider-thumb { box-shadow: var(--ring); }
.st-range:focus-visible::-moz-range-thumb { box-shadow: var(--ring); }
.st-slider-ends { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); }

.st-inline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.st-inline-row > .input { flex: 0 1 170px; min-width: 120px; }

/* ---------- Persona ---------- */
.st-today { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 12.5px; }
.st-preview {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface-2);
}
.st-preview-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.st-preview-line { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 14px; line-height: 1.75; text-align: start; }
.st-preview-lang {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 28px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
}
.st-counter { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-3); }
.st-counter[data-level='near'] { color: var(--warn); }
.st-counter[data-level='max'] { color: var(--danger); }
.st-extra-field { margin-bottom: 0; }

/* ---------- Voice ---------- */
.st-voice-control { display: flex; flex-direction: column; gap: 8px; }
.st-voice-test { flex: none; }
.st-voice-missing { margin: 0; }

/* ---------- About ---------- */
.st-about-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: radial-gradient(420px 160px at 0% 50%, var(--bg-glow-1), transparent 70%), var(--surface);
}
[dir='rtl'] .st-about-hero { background: radial-gradient(420px 160px at 100% 50%, var(--bg-glow-1), transparent 70%), var(--surface); }
.st-about-logo { flex: none; width: 64px; height: 64px; filter: drop-shadow(0 6px 18px rgba(46, 230, 197, 0.25)); }
.st-about-name {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.st-about-tagline { margin: 2px 0 8px; color: var(--text-2); font-size: 14px; }
.st-about-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; }
.st-status { display: grid; }
.st-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.st-status-row:last-child { border-bottom: 0; }
.st-status-label { color: var(--text-2); }
.st-status-value { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-align: end; }
.st-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.st-status-value.is-ok .st-status-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.st-status-value.is-danger { color: var(--danger); }
.st-status-value.is-danger .st-status-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.st-list { display: grid; gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.st-list li { display: flex; gap: 10px; color: var(--text-2); font-size: 13.5px; line-height: 1.65; }
.st-list li > .st-ico { margin-top: 3px; color: var(--accent); }
.st-shortcuts { display: grid; margin: 0; }
.st-shortcut {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.st-shortcut:last-child { border-bottom: 0; }
.st-shortcut dt { color: var(--text-2); font-size: 13.5px; }
.st-shortcut dd { margin: 0; flex: none; }
.st-keys { display: inline-flex; gap: 4px; }
.st-keys kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 25px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ---------- Lock screen ---------- */
.st-lock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 440px;
  margin: 48px auto;
  padding: 30px 26px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  text-align: center;
}
.st-content[data-tab='providers'] .st-panel { overflow-y: auto; }
.st-lock.st-shake { animation: st-shake 380ms var(--ease); }
.st-lock-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  color: var(--on-primary, #fff);
  background: var(--gradient-accent);
  box-shadow: var(--glow);
}
.st-lock-title { margin: 6px 0 0; font-size: 18px; }
.st-lock-desc { margin: 0 0 6px; color: var(--text-2); font-size: 13.5px; line-height: 1.7; }
.st-pin-form { display: flex; gap: 8px; width: 100%; }
.st-pin-input { flex: 1; min-width: 0; direction: ltr; text-align: center; letter-spacing: 0.3em; font-size: 18px; font-family: var(--font-mono); }
.st-pin-submit { flex: none; }
.st-pin-error { min-height: 1em; margin: 0; }

/* ---------- Skeleton, empty ---------- */
.st-skel {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: st-shimmer 1.3s linear infinite;
}
.st-skeleton .w-40 { width: 40%; }
.st-skeleton .w-60 { width: 60%; }
.st-skeleton .w-80 { width: 80%; margin: 10px 0; }
.st-skel-input { height: 38px; margin: 12px 0; border-radius: var(--radius-sm); }
.st-skel-block { height: 64px; margin: 14px 0; border-radius: var(--radius-sm); }
.st-skel-mono { flex: none; width: 36px; height: 36px; border-radius: 10px; }
.st-skel-lg { width: 52px; height: 52px; border-radius: 15px; }
.st-skel-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.st-skel-lines { flex: 1; display: grid; gap: 7px; }
.st-skeleton .st-plist { padding: 12px 8px; }
.st-skeleton .st-plist > .st-skel-input { margin: 2px 4px 10px; }

.st-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 56px 20px; text-align: center; }
.st-empty h3 { margin: 6px 0 0; font-size: 17px; }
.st-empty p { margin: 0 0 8px; color: var(--text-2); }
.st-empty-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }

/* ---------- Footer ---------- */
.st-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  transition: background var(--dur) var(--ease);
}
.st-foot[data-state='dirty'] { background: linear-gradient(0deg, var(--warn-soft), transparent 140%), var(--surface); }
.st-foot { min-width: 0; }
.st-foot-status { display: flex; flex: 1 1 auto; align-items: center; gap: 9px; min-width: 0; font-size: 13px; color: var(--text-3); }
.st-foot-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.st-foot[data-state='dirty'] .st-foot-text { color: var(--text); font-weight: 600; }
.st-foot-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.st-foot[data-state='dirty'] .st-foot-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); animation: st-pulse 1.6s ease-in-out infinite; }
.st-foot[data-state='error'] { background: linear-gradient(0deg, var(--danger-soft), transparent 140%), var(--surface); }
.st-foot[data-state='error'] .st-foot-text { color: var(--danger); font-weight: 600; }
.st-foot[data-state='error'] .st-foot-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.st-foot-actions { display: flex; flex: none; gap: 8px; }
.st-save { min-width: 132px; }

/* ---------- Add-provider sub dialog ---------- */
.st-subdialog { width: min(520px, calc(100vw - 32px)); }
.st-subdialog[open] .st-sub-body { animation: st-in var(--dur) var(--ease) both; }
.st-sub-body {
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-2);
}
.st-sub-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.st-sub-title { margin: 0; font-size: 17px; }
.st-sub-hint { margin: 2px 0 0; font-size: 13px; color: var(--text-3); }
.st-sub-body .switch { margin: 2px 0 4px; }
.st-sub-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .st-main { grid-template-columns: 196px minmax(0, 1fr); }
  .st-providers { grid-template-columns: 268px minmax(0, 1fr); }
}

/* Providers become master/detail. */
@media (max-width: 899px) {
  .st-providers { grid-template-columns: minmax(0, 1fr); }
  .st-providers[data-view='list'] .st-pdetail { display: none; }
  .st-providers[data-view='detail'] .st-plist { display: none; }
  .st-plist { border-inline-end: 0; background: none; }
  .st-pd-back { display: inline-flex; }
  .st-prow-badges { max-width: 160px; }
}

/* Full-screen sheet with horizontal tabs. */
@media (max-width: 719px) {
  .st-dialog { width: 100vw; height: 100dvh; margin: 0; inset: 0; }
  .st-dialog[open] .st-shell { animation: st-sheet-in var(--dur-slow) var(--ease) both; }
  .st-shell { border-radius: 0; border: 0; }
  .st-head { padding: calc(10px + var(--safe-top)) 10px 10px 14px; gap: 12px; }
  .st-head-badge { width: 36px; height: 36px; border-radius: 11px; }
  .st-title { font-size: 17px; }
  .st-subtitle { font-size: 12px; }
  .st-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .st-tabs {
    flex-direction: row;
    gap: 6px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .st-tabs::-webkit-scrollbar { display: none; }
  .st-tab { flex: none; height: 38px; padding: 0 13px; gap: 7px; border-radius: 999px; font-size: 13.5px; }
  .st-tab-label { overflow: visible; }
  .st-tab[aria-selected='true']::before { display: none; }
  .st-tab[aria-selected='true'] { box-shadow: inset 0 0 0 1px var(--accent-soft); }
  .st-content { padding: 16px 14px 24px; }
  .st-pdetail { padding: 14px 14px 24px; }
  .st-card { padding: 16px 14px; border-radius: var(--radius); }
  .st-radio-cards { grid-template-columns: minmax(0, 1fr); }
  .st-radio-cards[data-name='theme'] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .st-radio-cards[data-name='theme'] .st-radio-card { padding: 8px 8px 10px; }
  .st-radio-cards[data-name='theme'] .st-radio-check { top: 6px; inset-inline-end: 6px; }
  .st-radio-cards[data-name='theme'] .st-radio-text { padding-inline-end: 0; }
  .st-theme-art { height: 64px; }
  .st-radio-cards[data-name='outfit'] .st-radio-art { height: 104px; }
  .st-radio-cards[data-name='teacher'] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .st-radio-cards[data-name='teacher'] .st-radio-card { padding: 8px 8px 10px; }
  .st-radio-cards[data-name='teacher'] .st-radio-check { top: 6px; inset-inline-end: 6px; }
  .st-radio-cards[data-name='teacher'] .st-radio-text { padding-inline-end: 0; }
  .st-radio-cards[data-name='teacher'] .st-radio-art { height: 120px; }
  .st-segmented { display: flex; }
  .st-seg { flex: 1 1 auto; justify-content: center; padding: 0 10px; }
  .st-pd-links { width: 100%; }
  .st-pd-actions > .btn, .st-pd-actions > .st-active-pill { flex: 1 1 auto; justify-content: center; }
  .st-pd-actions > .st-spacer { display: none; }
  .st-foot { padding: 10px 12px calc(10px + var(--safe-bottom)); gap: 8px; }
  .st-foot-status { font-size: 12px; }
  /* Two lines on a phone, so "what is unsaved" or a save error stays readable beside the buttons. */
  .st-foot-text { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.35; }
  .st-foot .btn { height: 38px; padding: 0 12px; }
  .st-save { min-width: 0; }
  .st-lock { margin: 20px auto; padding: 24px 18px 18px; }
  .st-about-hero { flex-direction: column; text-align: center; }
  .st-about-meta { justify-content: center; }
  .st-model-row { flex-wrap: wrap; }
  .st-model-row > .input, .st-model-row > .select { flex: 1 1 100%; }
  .st-model-row > .btn { flex: 1 1 auto; }
}

@media (max-width: 400px) {
  .st-subtitle { display: none; }
  .st-foot-dot { display: none; }
}

/* Touch screens: every control is at least 44 × 44 px (buttons, fields and selects follow app.css). */
@media (pointer: coarse) {
  .st-tab, .st-chip, .st-seg, .st-search-input, .st-dialog .switch { min-height: 44px; }
  /* The slider keeps its 6 px track but takes touches across a 44 px band. */
  [dir] .st-range { height: 44px; margin: 0; padding: 19px 0; background-clip: content-box; }
}

/* ---------- Built-in neural voice ---------- */
.st-neural { display: flex; flex-direction: column; gap: 10px; }
.st-neural-status { font-size: 13.5px; color: var(--text-2); }
.st-neural-status[data-state='ready'] { color: var(--success); font-weight: 600; }
.st-neural-status[data-state='error'] { color: var(--danger); }
.st-neural-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.st-neural-fill { display: block; height: 100%; width: 0; background: var(--gradient-accent); transition: width var(--dur) var(--ease); }
.st-neural-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.st-neural-actions .btn[hidden] { display: none; }

/* ------------------------------------------------------------------------------------------- per-setting reset */
.st-reset {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 3px 9px;
  border-radius: 999px; border: 1px dashed var(--border-strong); background: transparent; color: var(--text-2);
  font-size: 12px; font-weight: 600; transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.st-reset:hover { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 45%, transparent); background: var(--accent-soft); }
.st-reset[hidden] { display: none; }
.st-card > .st-reset { margin-top: 10px; }

/* ------------------------------------------------------------------------------------------- learning & memory */
.st-memory-details { margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.st-memory-details > summary { display: flex; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); list-style: none; }
.st-memory-details > summary::-webkit-details-marker { display: none; }
.st-memory-details[open] > summary { border-bottom: 1px solid var(--border); }
.st-memory-preview {
  margin: 0; padding: 10px 12px; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.6 var(--font-sans, inherit); color: var(--text-2);
}

/* ---------- Plans tab ---------- */
.st-plan { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 12px 14px; margin-top: 10px; }
.st-plan-name { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 14.5px; }
.st-plan-name .st-ico { color: var(--accent); }
.st-plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 12px; align-items: start; }
.st-plan-grid .field-label { min-height: 2.8em; align-items: flex-end; }
.st-plan-summary { margin: 2px 0 0; color: var(--text-3); font-size: 12.5px; }
@media (max-width: 719px) {
  .st-plan-grid { grid-template-columns: 1fr; }
  .st-plan-grid .field-label { min-height: 0; }
}

/* ---------- My account tab ---------- */
.st-account { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.st-account-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.st-account-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.st-account-info strong { overflow-wrap: anywhere; }
.st-account-label, .st-account-name { color: var(--text-3); font-size: 12.5px; }
.st-google { width: 100%; justify-content: center; gap: 8px; height: 44px; }
.st-or { margin: 12px 0 4px; text-align: center; color: var(--text-3); font-size: 12.5px; }
.st-start { justify-content: flex-start; }
.st-acc-error { margin: 4px 0 0; }
.st-subhead { margin: 18px 0 8px; font-size: 14px; }
.st-ok-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.st-ok-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.st-ok-item.is-active { border-color: var(--success); }
.st-ok-info { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.st-ok-meta { color: var(--text-3); font-size: 12.5px; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.st-ok-actions { display: flex; align-items: center; gap: 4px; flex: none; }
@media (pointer: coarse) {
  .st-ok-actions .btn { min-height: 44px; min-width: 44px; }
}
.st-hint-line { margin: 0 0 8px; color: var(--text-3); font-size: 12.5px; line-height: 1.6; }
.st-link { margin-inline-start: auto; font-size: 12.5px; font-weight: 500; color: var(--accent); }
