/* Settings (js/settings.js): the pages in groups down the left under a
 * search, the page on the right, and the Advanced fold every page shares.
 * The pages' own pieces are in overlays.css and setup.css.
 */

.dialog.settings { width: min(900px, 100%); height: min(680px, 90vh); }
.dialog.untitled > .dialog-body.settings-body { padding-top: 0; margin-top: 0; border-top: 0; }
.dialog-body.settings-body {
  flex-direction: row;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ---- the list of pages ----------------------------------------------------- */
.settings-nav {
  display: flex;
  flex-direction: column;
  width: 224px;
  flex: none;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--sidebar) 70%, var(--raised));
}
.settings-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 12px 10px 6px;
  flex: none;
}
.settings-search-glyph {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text3);
  pointer-events: none;
}
.settings-search-input {
  width: 100%;
  height: 32px;
  padding: 0 52px 0 31px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--soft);
  color: var(--text);
  font: inherit;
  font-size: var(--ui-size);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.settings-search-input::placeholder { color: var(--text3); }
.settings-search-input:hover { background: var(--soft-hover); }
.settings-search-input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: var(--input-bg, var(--surface));
}
.settings-search-clear { position: absolute; right: 4px; }
.settings-search-kbd {
  position: absolute;
  right: 8px;
  height: 18px;
  padding: 0 5px;
  font-size: 10.5px;
  color: var(--text3);
  pointer-events: none;
}
.settings-search-input:focus ~ .settings-search-kbd,
.settings-search-clear:not([hidden]) ~ .settings-search-kbd { display: none; }

/* Scrolls on its own when the window is short; the search and the
   assistant stay where they are. */
.settings-nav-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 10px 12px;
}
.settings-group {
  padding: 14px 10px 5px;
  font-size: var(--ui-small);
  font-weight: 600;
  color: var(--text3);
}
.settings-group:first-child { padding-top: 8px; }
.settings-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  padding: 0 8px 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text2);
  font-size: var(--ui-size);
  text-align: left;
  flex: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
/* 16px like every glyph in the app, so a 30px row sets it on whole pixels
   (a 15px glyph sat half a pixel off and blurred the loose tile of Mosaics). */
.settings-tab .icon { width: 16px; height: 16px; flex: none; }
.settings-tab-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-tab:hover { background: var(--soft); color: var(--text); }
.settings-tab.on { background: var(--soft-hover); color: var(--text); font-weight: 550; }
.settings-tab.on .icon { color: var(--text); }
.settings-tab.dim { opacity: 0.42; }
.settings-tab.dim:hover { opacity: 0.8; }
.settings-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 650;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* The assistant that can set everything above, set apart at the foot. */
.settings-nav-foot { flex: none; padding: 8px 10px 10px; border-top: 1px solid var(--border); }
.settings-tab.settings-helper { width: 100%; color: var(--text2); }
.settings-tab.settings-helper .icon { color: var(--accent-ink); }

/* ---- the page ---------------------------------------------------------------- */
.settings-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 32px 32px; scroll-padding: 24px; }
.settings-page { display: flex; flex-direction: column; gap: 18px; max-width: 580px; }
.settings-page.entering { animation: rise-in var(--dur-slow) var(--ease-out) both; }
/* Settings that apply only while the switch above them is on (Message box's
   reading ahead): set in under its words, the switch's width and gap. */
.read-ahead-options { display: flex; flex-direction: column; gap: 18px; padding-left: 44px; margin-top: -4px; }
/* A page placed inside another (Your own models in Models): one more section of it. */
.settings-page .settings-page.settings-nested { max-width: none; padding-top: 18px; border-top: 1px solid var(--border); }
.page-intro { display: flex; flex-direction: column; gap: 6px; padding-bottom: 4px; }
.page-intro h3 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.page-intro .dialog-text { font-size: 13px; color: var(--text2); }
.settings-nested > .page-intro h3 { font-size: 15px; }

/* ---- a section's tabs ----------------------------------------------------------- */
/* A section of more than one page: its name, and its pages as tabs under it.
   The tab names the page, so the page's own heading steps aside. */
.settings-head { display: flex; flex-direction: column; gap: 10px; max-width: 580px; margin-bottom: 18px; }
.settings-head-title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
/* Six tabs fit the 580 px column with room to spare (Models: Smart and
   Manual, Jobs, Saved setups, Privacy, Your own models, Model settings);
   the scrollbar is hidden, so a strip that ran over would cut its last tab. */
.settings-subtabs {
  position: relative;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.settings-subtabs::-webkit-scrollbar { display: none; }
.settings-subtab {
  flex: none;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--text2);
  font-size: var(--ui-size);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.settings-subtab:hover { color: var(--text); background: var(--surface-hover); }
.settings-subtab.on { color: var(--text); font-weight: 600; }
.settings-subtab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* The line under the tab that is on slides, by transform, to the next. */
.settings-subtab-line {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 0;
  pointer-events: none;
  transition: transform var(--dur) var(--ease);
}
.reduced-motion .settings-subtab-line { transition: none; }
.settings-page.settings-tabbed > .page-intro h3 { display: none; }

/* A ? beside a label: what a technical word means. */
.form-label { display: inline-flex; align-items: center; gap: 5px; }
.label-tip { display: inline-flex; color: var(--text3); cursor: help; }
.label-tip .icon { width: 13px; height: 13px; }
.label-tip:hover { color: var(--accent-ink); }

/* Pointed at from a search: a soft wash that fades. */
.settings-found { position: relative; isolation: isolate; }
.settings-found::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -6px -10px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
  pointer-events: none;
  animation: settings-found 3.2s var(--ease) both;
}
@keyframes settings-found { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---- Advanced, and other folds ---------------------------------------------- */
/* One quiet line under a hairline, its count and a chevron; open, its
   settings sit on the page like the rest. */
.settings-advanced, .settings-fold { border-top: 1px solid var(--border); margin-top: 4px; }
.settings-advanced > summary, .settings-fold > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -8px;
  padding: 12px 8px 4px;
  list-style: none;
  cursor: pointer;
  color: var(--text2);
  font-size: var(--ui-size);
  border-radius: var(--radius-sm);
  user-select: none;
  transition: color var(--dur-fast) var(--ease);
}
.settings-advanced > summary::-webkit-details-marker, .settings-fold > summary::-webkit-details-marker { display: none; }
.settings-advanced > summary:hover, .settings-fold > summary:hover { color: var(--text); }
.settings-advanced > summary:focus-visible, .settings-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-advanced .advanced-title, .settings-fold .advanced-title { font-weight: 600; }
.advanced-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--surface-hover);
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.advanced-chev { width: 15px; height: 15px; margin-left: auto; color: var(--text3); transition: transform var(--dur) var(--ease); }
.settings-advanced[open] > summary .advanced-chev, .settings-fold[open] > summary .advanced-chev { transform: rotate(180deg); }
.settings-advanced .advanced-body, .settings-fold .advanced-body { display: flex; flex-direction: column; gap: 18px; padding: 14px 0 2px; }
.settings-page .muted { opacity: 0.5; pointer-events: none; }
/* Inside a dialog's own body (assistants, sharing), not a page: the same line. */
.dialog-body > .settings-advanced { margin-top: 2px; }

/* ---- search results ------------------------------------------------------- */
.settings-results { gap: 14px; }
.results-head { font-size: 12px; color: var(--text3); }
.result-group { display: flex; flex-direction: column; gap: 2px; }
.result-page {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 4px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text2);
}
.result-page .icon { width: 14px; height: 14px; color: var(--accent-ink); }
.result-area { color: var(--text3); font-weight: 500; }
.result-page .icon.result-sep { width: 12px; height: 12px; color: var(--text3); }
.result-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13.5px;
}
.result-row.active { background: var(--surface-hover); }
.result-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.result-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 550; }
.result-text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-tag {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-hover);
  color: var(--text3);
  font-size: 10.5px;
  font-weight: 600;
}
.result-row mark { padding: 0 1px; border-radius: 3px; background: var(--accent-wash); color: var(--accent-ink); }
.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}
.results-empty > .icon { width: 22px; height: 22px; margin-bottom: 4px; }
.results-empty b { color: var(--text); font-size: 14px; }
.results-empty .btn { margin-top: 8px; }

.reduced-motion .settings-found::after { animation-duration: 0s; animation-delay: 3s; }
.reduced-motion .settings-advanced[open] .advanced-body,
.reduced-motion .settings-fold[open] .advanced-body,
.reduced-motion .advanced-chev { animation: none; transition: none; }

/* AI settings, Saving and Chat settings' AI section (js/settings_ai.js). */
.settings-page button.link,
.dialog button.link {
  padding: 0; border: 0; background: none; color: var(--link, var(--accent-ink)); font: inherit; cursor: pointer;
}
.settings-page button.link:hover,
.dialog button.link:hover { text-decoration: underline; }
.param-unsupported .form-control { opacity: 0.55; }
.param-unsupported .form-hint { color: var(--warn, var(--text2)); }
.tuning-list {
  display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: -6px 0 0 44px;
  font-size: 12.5px; color: var(--text3);
}
.tuning-row { display: contents; }
.tuning-row .name { color: var(--text2); }
.tuning-row .values { font-variant-numeric: tabular-nums; }
.saved-card { display: grid; grid-template-columns: minmax(180px, 1fr) 1.4fr; gap: 14px; align-items: start; }
.saved-kinds { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; }
.saved-kinds .spend-row { grid-template-columns: 1fr auto; }
.saving-control { display: flex; flex-direction: column; gap: 4px; }
.saving-control .slider-value { min-width: 72px; font-weight: 600; color: var(--text); }
.saving-ends {
  display: flex; justify-content: space-between; padding-right: 86px; font-size: var(--ui-small); color: var(--text3);
}
.saving-note { margin-top: -10px; }
.saving-custom { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); }
.saving-custom .icon { width: 14px; height: 14px; color: var(--accent); }
.chat-settings-body .form-section { margin-top: 6px; }
.chat-settings-body .form-section:first-of-type { margin-top: 0; }
.chat-settings-body .ai-checking { margin-top: -6px; }
/* A skill's line on when to use it, two lines at most; the rest is in its tip. */
.chat-settings-body .skill-state .form-hint {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- Appearance: the accent, fonts and code (js/looks.js) ------------------ */
.accent-field { display: flex; flex-direction: column; gap: 10px; }
.settings-look, .settings-look-advanced { display: flex; flex-direction: column; gap: 18px; }
.accent-swatches { display: flex; flex-wrap: wrap; gap: 9px; }
/* Each swatch carries its colour for both themes, and shows the one it would
   be in the room it is seen in. */
.accent-swatch {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--swatch-light, var(--surface-hover));
  color: var(--text2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 14%, transparent);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
html.dark .accent-swatch { background: var(--swatch-dark, var(--surface-hover)); }
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch:focus-visible { outline: var(--focus-ring) solid var(--accent); outline-offset: 3px; }
.accent-swatch.on { box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--text2); }
.accent-swatch.custom:not(.set) { background: var(--surface-hover); }
.accent-swatch .icon { width: 15px; height: 15px; }
.accent-swatch.custom.set .icon { color: var(--text); opacity: 0.8; }
.accent-custom-box { display: flex; flex-direction: column; gap: 6px; }
.accent-custom { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.accent-custom input[type="color"] {
  width: 38px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  cursor: pointer;
}
.accent-custom .field { width: 112px; font-family: var(--font-mono); }
.accent-previews { display: flex; gap: 8px; flex-wrap: wrap; }
.accent-preview {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}
.accent-preview .fill { padding: 3px 10px; border-radius: 7px; font-weight: 600; }
.accent-preview .ink { font-weight: 550; text-decoration: underline; text-underline-offset: 2px; }
.accent-preview .said { opacity: 0.65; }
.accent-note.bad { color: var(--danger); }

.font-field .label { font-size: 13px; }
.popover.font-popover { width: 300px; max-width: calc(100vw - 24px); padding: 6px; }
.font-pick { display: flex; flex-direction: column; gap: 6px; }
.font-list { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; }
.font-list .font-item { width: 100%; }
.font-group { padding: 8px 10px 3px; color: var(--text3); font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.font-empty { padding: 10px; color: var(--text3); font-size: 12.5px; }

.code-theme-field { display: flex; flex-direction: column; gap: 8px; }
.code-sample {
  margin: 0;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  overflow: hidden;
}
.code-sample .code-line { display: flex; }
.code-sample .ln { display: none; flex: none; width: 2.2ch; margin-right: 1.4ch; text-align: right; opacity: 0.45; user-select: none; }
.code-sample.numbered .ln { display: block; }
.code-sample .lc { min-width: 0; white-space: pre; }
.code-sample.wrapped .lc { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- Backup and transfer (js/backup.js) ------------------------------------ */
.transfer-progress { display: flex; flex-direction: column; gap: 7px; max-width: 460px; }
.transfer-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 26px; }
.transfer-text { color: var(--text2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.transfer-bar { height: 4px; border-radius: 999px; background: var(--border-strong); overflow: hidden; }
/* The bar fills by scaling, which the compositor does alone. */
.transfer-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--dur) var(--ease);
}

.restore-file { display: flex; align-items: center; gap: 12px; }
.restore-file > .icon { width: 22px; height: 22px; color: var(--text2); flex: none; }
.restore-file div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.restore-file b { overflow-wrap: anywhere; }
.restore-file span { color: var(--text3); font-size: 12.5px; }
.restore-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.restore-choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text2);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.restore-choice b { color: var(--text); font-size: 13.5px; }
.restore-choice:hover { background: var(--card-hover); }
.restore-choice.on { border-color: var(--accent); background: var(--accent-wash); }
.restore-choice:focus-visible { outline: var(--focus-ring) solid var(--accent); outline-offset: 2px; }

.import-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.import-row { flex: none; display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-top: 1px solid var(--border); }
.import-row:first-child { border-top: 0; }
.import-label { font-weight: 600; color: var(--text); font-size: 13px; }
.import-values { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text3); }
.import-values .icon { width: 13px; height: 13px; }
.import-values .after { color: var(--text); }

/* ---- tabs inside a page (Appearance) ---------------------------------------- */
.page-tabs-host { display: flex; flex-direction: column; gap: 18px; }
.page-tabs {
  position: sticky;
  top: -1px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 -4px;
  padding: 4px;
  border-bottom: 1px solid var(--border);
  background: var(--raised);
}
.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text2);
  font-size: var(--ui-size);
  font-weight: 520;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.page-tab .icon { width: 14px; height: 14px; }
.page-tab:hover { background: var(--surface-hover); color: var(--text); }
.page-tab.on { background: var(--selection-strong); color: var(--text); }
.page-tabs-spacer { flex: 1; }
.page-tab-pane { display: flex; flex-direction: column; gap: 18px; }
.page-tab-pane > :is(.motion-page, .settings-tips) { display: flex; flex-direction: column; gap: 18px; }
