.status-bar {
  position: relative;
  z-index: 9;
}

.desktop-pager,
.dock {
  transition: none;
}

.screen.settings-open .desktop-pager,
.screen.settings-open .dock {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.settings-page {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  padding:
    max(54px, calc(env(safe-area-inset-top) + 40px))
    max(22px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));
  background: rgba(247, 247, 245, .94);
  transform: translateY(18px) scale(.99);
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: none;
}

.settings-page.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.settings-header {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 34px;
  align-items: start;
  gap: 10px;
}

.settings-header button {
  display: grid;
  place-items: center;
  color: #111;
  background: transparent;
  cursor: pointer;
}

#settingsClose {
  width: 30px;
  height: 30px;
}

#settingsClose > span {
  display: block;
  width: 11px;
  height: 11px;
  border-left: 1.25px solid currentColor;
  border-bottom: 1.25px solid currentColor;
  transform: rotate(45deg) translate(2px, -2px);
}

.settings-title {
  min-width: 0;
}

.settings-title h1 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 27px;
  font-weight: 620;
  line-height: 1.12;
  letter-spacing: 0;
}

.settings-title h1 span {
  font-size: 13px;
}

.settings-title p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  color: rgba(0, 0, 0, .52);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 12px;
  line-height: 1.35;
}

.settings-title p span {
  color: #111;
  font-size: 10px;
}

.settings-moon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.settings-moon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-moon:active {
  transform: translateY(1px);
}

.settings-content {
  display: block;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  contain: layout paint;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 1px 1px 8px;
}

.settings-group {
  display: grid;
  gap: 0;
  padding: 6px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .36);
  box-shadow:
    4px 5px 14px rgba(0, 0, 0, .045),
    -4px -4px 12px rgba(255, 255, 255, .60),
    inset 1px 1px 0 rgba(255, 255, 255, .60),
    inset -1px -1px 0 rgba(0, 0, 0, .025);
}

.settings-group + .settings-group {
  margin-top: 14px;
}

.settings-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 12px;
  padding: 5px 0;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-weight: 400;
  outline: none;
  text-align: left;
  cursor: pointer;
  transition:
    background .18s ease,
    box-shadow .18s ease,
    color .18s ease,
    transform .12s ease;
}

.settings-row + .settings-row {
  border-top: 1px solid rgba(0, 0, 0, .035);
}

.settings-row:active {
  transform: translateY(1px);
}

.settings-row:focus-visible {
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .58),
    inset -1px -1px 0 rgba(0, 0, 0, .05);
}

#apiSettingsToggle,
#imageSettingsToggle,
#imageRecognitionSettingsToggle,
#voiceSettingsToggle {
  border-radius: 14px;
}

#apiSettingsToggle[aria-expanded="true"],
#imageSettingsToggle[aria-expanded="true"],
#imageRecognitionSettingsToggle[aria-expanded="true"],
#voiceSettingsToggle[aria-expanded="true"] {
  background: rgba(0, 0, 0, .065);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .58),
    inset -1px -1px 0 rgba(0, 0, 0, .05);
}

#apiSettingsToggle[aria-expanded="true"] .settings-icon,
#imageSettingsToggle[aria-expanded="true"] .settings-icon,
#imageRecognitionSettingsToggle[aria-expanded="true"] .settings-icon,
#voiceSettingsToggle[aria-expanded="true"] .settings-icon {
  color: #111;
  transform: scale(.96);
}

#apiSettingsToggle[aria-expanded="true"] .settings-copy strong,
#imageSettingsToggle[aria-expanded="true"] .settings-copy strong,
#imageRecognitionSettingsToggle[aria-expanded="true"] .settings-copy strong,
#voiceSettingsToggle[aria-expanded="true"] .settings-copy strong {
  font-weight: 600;
}

.settings-leading {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.settings-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.settings-copy strong {
  overflow-wrap: anywhere;
  color: #111;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.18;
}

.settings-copy small {
  overflow-wrap: anywhere;
  color: rgba(0, 0, 0, .48);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.25;
}

.settings-trailing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.settings-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: rgba(0, 0, 0, .82);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color .18s ease, transform .18s ease;
}

.settings-chevron {
  width: 7px;
  height: 7px;
  border-top: 1.15px solid rgba(0, 0, 0, .34);
  border-right: 1.15px solid rgba(0, 0, 0, .34);
  transform: rotate(45deg);
  transition: border-color .18s ease, transform .18s ease;
}

.settings-toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-switch {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #111;
  box-shadow: inset 1px 1px 2px rgba(255, 255, 255, .12);
  transition: background .18s ease;
}

.settings-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .96);
  box-shadow: 1px 1px 4px rgba(0, 0, 0, .16);
  transition: transform .18s ease;
}

.settings-toggle-row input:not(:checked) + .settings-switch {
  background: rgba(0, 0, 0, .16);
}

.settings-toggle-row input:not(:checked) + .settings-switch::after {
  transform: translateX(-20px);
}

.api-settings-panel,
.image-settings-panel,
.image-recognition-settings-panel,
.voice-settings-panel {
  display: grid;
  gap: 16px;
  min-height: 0;
  overflow-anchor: none;
  padding: 10px 0 8px;
  border-top: 1px solid rgba(0, 0, 0, .04);
}

.api-settings-panel[hidden],
.image-settings-panel[hidden],
.image-recognition-settings-panel[hidden],
.voice-settings-panel[hidden],
.api-load-balance-panel[hidden] {
  display: none;
}

#apiSettingsToggle[aria-expanded="true"] .settings-chevron,
#imageSettingsToggle[aria-expanded="true"] .settings-chevron,
#imageRecognitionSettingsToggle[aria-expanded="true"] .settings-chevron,
#voiceSettingsToggle[aria-expanded="true"] .settings-chevron {
  transform: rotate(135deg);
}

.image-mode-tabs,
.voice-region-tabs {
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(0, 0, 0, .075);
  border-radius: 999px;
  background: rgba(255, 255, 255, .44);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .68),
    inset -1px -1px 0 rgba(0, 0, 0, .025);
}

.voice-region-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.image-mode-tabs {
  display: flex;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.image-mode-tabs::-webkit-scrollbar {
  display: none;
}

.image-mode-tabs button,
.voice-region-tabs button {
  min-width: 0;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: rgba(0, 0, 0, .56);
  background: transparent;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  outline: none;
  cursor: pointer;
  transition:
    color .16s ease,
    background .16s ease,
    box-shadow .16s ease,
    transform .12s ease;
}

.image-mode-tabs button {
  flex: 0 0 auto;
  width: clamp(108px, 39%, 148px);
  min-height: 42px;
  padding: 0 8px;
  font-size: 12px;
  scroll-snap-align: start;
  white-space: normal;
  overflow-wrap: anywhere;
}

.image-mode-tabs button:active,
.voice-region-tabs button:active {
  transform: translateY(1px);
}

.image-mode-tabs button:focus-visible,
.voice-region-tabs button:focus-visible {
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .20),
    inset 1px 1px 0 rgba(255, 255, 255, .70);
}

.image-mode-tabs button[aria-selected="true"],
.voice-region-tabs button[aria-selected="true"] {
  color: var(--ink);
  background: rgba(0, 0, 0, .055);
  box-shadow:
    3px 4px 10px rgba(0, 0, 0, .055),
    inset 1px 1px 0 rgba(255, 255, 255, .74),
    inset -1px -1px 0 rgba(0, 0, 0, .04);
}

.image-app-section {
  gap: 10px;
}

.image-app-heading {
  grid-template-columns: 1fr;
}

.image-recognition-heading {
  grid-template-columns: 1fr;
}

.image-app-list {
  display: grid;
  gap: 8px;
}

.image-app-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 128px);
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, .055);
  border-radius: 8px;
  background: rgba(255, 255, 255, .34);
}

.image-app-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.image-app-copy strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.image-app-copy small {
  color: rgba(0, 0, 0, .50);
  font-size: 11px;
  line-height: 1.25;
}

.image-app-row .api-dropdown {
  justify-self: end;
  width: 128px;
}

.voice-config-form {
  display: grid;
  gap: 12px;
}

.voice-test-audio {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.voice-test-audio[hidden] {
  display: none;
}

.api-section {
  display: grid;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(0, 0, 0, .045);
}

.api-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.api-section-heading,
.api-connections-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, .56fr);
  align-items: end;
  gap: 12px;
}

.api-section-heading h2,
.api-connections-heading h3 {
  margin: 0;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

.api-section-heading p,
.api-connections-heading p,
.api-segment-field p,
.api-range-field small,
.api-field-note,
.api-current-preset span,
.api-connections-heading label > span,
.api-connections-heading > div:last-child > span,
.api-add-preset-control > span {
  margin: 4px 0 0;
  color: rgba(0, 0, 0, .48);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.35;
}

.api-current-preset,
.api-connections-heading label {
  display: grid;
  gap: 6px;
}

.api-current-preset .api-dropdown-button {
  min-height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .52);
}

.api-field {
  display: grid;
  gap: 7px;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 12px;
  line-height: 1.3;
}

.api-field[hidden] {
  display: none;
}

.api-field > span,
.api-segment-field legend {
  color: rgba(0, 0, 0, .62);
  font-size: 12px;
  font-weight: 600;
}

.api-field-note {
  display: block;
  margin: -1px 0 0;
}

.api-inline-field {
  grid-template-columns: minmax(0, 1fr) minmax(86px, 116px);
  align-items: center;
  column-gap: 12px;
}

.api-inline-field > .api-field-note {
  grid-column: 1 / -1;
}

.api-retry-field .api-dropdown {
  justify-self: end;
  width: 112px;
}

.api-field input,
.api-field textarea,
.api-field select,
.api-preset-card input,
.api-preset-card textarea,
.api-dropdown-button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  color: #111;
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, .68);
  font: inherit;
}

.api-field textarea,
.api-preset-card textarea {
  min-height: 88px;
  padding: 10px;
  line-height: 1.45;
  resize: vertical;
}

.api-field input:focus,
.api-field textarea:focus,
.api-field select:focus,
.api-preset-card input:focus,
.api-preset-card textarea:focus,
.api-dropdown-button:focus-visible {
  border-color: rgba(0, 0, 0, .35);
}

.api-dropdown {
  position: relative;
  min-width: 0;
}

.api-combo {
  position: relative;
  min-width: 0;
}

.api-combo input {
  padding-right: 30px;
}

.api-combo::after {
  content: "";
  position: absolute;
  top: 15px;
  right: 12px;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid rgba(0, 0, 0, .46);
  border-bottom: 1.5px solid rgba(0, 0, 0, .46);
  pointer-events: none;
  transform: rotate(45deg);
  transition: transform .16s ease, border-color .16s ease;
}

.api-combo:has(input[aria-expanded="true"])::after {
  transform: translateY(3px) rotate(225deg);
}

.api-dropdown-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px;
  align-items: center;
  gap: 8px;
  text-align: left;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .56);
  transition:
    border-color .16s ease,
    background .16s ease,
    box-shadow .16s ease;
}

.api-dropdown-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.api-dropdown-button i {
  width: 7px;
  height: 7px;
  justify-self: center;
  border-right: 1.15px solid rgba(0, 0, 0, .42);
  border-bottom: 1.15px solid rgba(0, 0, 0, .42);
  transform: rotate(45deg) translateY(-2px);
  transition: border-color .16s ease, transform .16s ease;
}

.api-dropdown-button[aria-expanded="true"] i {
  transform: rotate(225deg) translate(-1px, -1px);
}

.api-dropdown-button[aria-expanded="true"] {
  border-color: rgba(0, 0, 0, .28);
  background: rgba(255, 255, 255, .92);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, .065),
    inset 1px 1px 0 rgba(255, 255, 255, .70);
}

.api-combo input[aria-expanded="true"] {
  border-color: rgba(0, 0, 0, .28);
  background: rgba(255, 255, 255, .92);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, .065),
    inset 1px 1px 0 rgba(255, 255, 255, .70);
}

.api-dropdown-button:disabled {
  color: rgba(0, 0, 0, .38);
  cursor: not-allowed;
}

.api-dropdown-menu,
.api-combo-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 6;
  display: grid;
  max-height: min(238px, 42dvh);
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, .09);
  border-radius: 8px;
  background: rgba(250, 250, 249, .985);
  box-shadow:
    0 18px 38px rgba(0, 0, 0, .12),
    inset 1px 1px 0 rgba(255, 255, 255, .72);
}

.api-current-preset .api-dropdown-menu {
  left: auto;
  right: 0;
  width: min(260px, calc(100vw - 72px));
}

.api-dropdown-menu[hidden],
.api-combo-menu[hidden] {
  display: none;
}

.api-dropdown-option,
.api-combo-option {
  display: grid;
  gap: 3px;
  min-height: 34px;
  padding: 8px;
  border-radius: 7px;
  color: #111;
  text-align: left;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 12px;
  line-height: 1.25;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}

.api-dropdown-option:hover,
.api-dropdown-option:focus-visible,
.api-combo-option:hover,
.api-combo-option:focus-visible {
  background: rgba(0, 0, 0, .055);
  outline: none;
}

.api-dropdown-option small,
.api-combo-option small {
  color: rgba(0, 0, 0, .48);
  font-size: 10.5px;
  line-height: 1.25;
}

.api-dropdown-option[aria-selected="true"],
.api-combo-option[aria-selected="true"] {
  color: var(--ink);
  background: rgba(0, 0, 0, .035);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .68),
    inset -1px -1px 0 rgba(0, 0, 0, .035);
}

.api-dropdown-option[aria-selected="true"] small,
.api-combo-option[aria-selected="true"] small {
  color: rgba(0, 0, 0, .52);
}

.api-dropdown-option[aria-disabled="true"],
.api-combo-option[aria-disabled="true"] {
  color: rgba(0, 0, 0, .42);
  cursor: default;
}

.api-range-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--ink);
}

.api-range-field input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  box-shadow:
    inset 1px 1px 3px rgba(0, 0, 0, .06),
    inset -1px -1px 3px rgba(255, 255, 255, .66);
}

.api-range-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  box-shadow:
    3px 4px 10px rgba(0, 0, 0, .12),
    inset 1px 1px 0 rgba(255, 255, 255, .78),
    inset -1px -1px 0 rgba(0, 0, 0, .045);
}

.api-range-field input[type="range"]::-moz-range-track {
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  box-shadow:
    inset 1px 1px 3px rgba(0, 0, 0, .06),
    inset -1px -1px 3px rgba(255, 255, 255, .66);
}

.api-range-field input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--glass);
  box-shadow:
    3px 4px 10px rgba(0, 0, 0, .12),
    inset 1px 1px 0 rgba(255, 255, 255, .78),
    inset -1px -1px 0 rgba(0, 0, 0, .045);
}

.api-range-field b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.api-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.voice-test-controls {
  grid-template-columns: minmax(104px, .38fr) minmax(0, 1fr);
  align-items: center;
  min-width: 0;
}

.novelai-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.image-inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 112px);
  gap: 8px;
  align-items: stretch;
}

.image-inline-control .api-secondary-button {
  min-height: 38px;
  padding-inline: 8px;
  white-space: nowrap;
}

.image-action-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.image-action-row-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.image-config-form[hidden] {
  display: none;
}

.image-novelai-fields,
.image-openai-fields,
.image-grok-fields {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.image-novelai-fields[hidden],
.image-openai-fields[hidden],
.image-grok-fields[hidden] {
  display: none;
}

.image-novelai-toggle,
.image-openai-toggle,
.image-grok-toggle {
  min-height: 42px;
}

.image-test-preview {
  display: grid;
  margin: 0;
  padding: 8px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  background: rgba(255, 255, 255, .42);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .66),
    inset -1px -1px 0 rgba(0, 0, 0, .03);
}

.image-test-preview[hidden] {
  display: none;
}

.image-test-preview img {
  display: block;
  width: 100%;
  max-height: min(360px, 45dvh);
  object-fit: contain;
  border-radius: 6px;
  background: rgba(0, 0, 0, .06);
}

.image-switch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 8px;
  background: rgba(255, 255, 255, .36);
}

.image-switch-row strong,
.image-switch-row small {
  display: block;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.image-switch-row strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.image-switch-row small {
  margin-top: 4px;
  color: rgba(0, 0, 0, .48);
  font-size: 10.5px;
  line-height: 1.35;
}

.image-switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.image-switch-row i {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .16);
  transition: background .18s ease;
}

.image-switch-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, .16);
  transition: transform .18s ease;
}

.image-switch-row input:checked + i {
  background: rgba(0, 0, 0, .085);
  box-shadow:
    4px 5px 13px rgba(0, 0, 0, .07),
    inset 1px 1px 0 rgba(255, 255, 255, .72),
    inset -1px -1px 0 rgba(0, 0, 0, .04);
}

.image-switch-row input:checked + i::after {
  background: var(--glass);
  transform: translateX(18px);
}

.novelai-preset-card {
  width: min(100%, 420px);
  max-height: min(660px, calc(100% - 24px));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#novelaiPresetDialog {
  place-items: center;
  overflow: hidden;
  padding:
    max(12px, env(safe-area-inset-top))
    14px
    max(12px, env(safe-area-inset-bottom));
}

.novelai-preset-card .api-preset-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: 0 -18px -18px;
  padding: 12px 18px 18px;
  background: rgba(250, 250, 249, .96);
}

.api-primary-button,
.api-secondary-button,
.api-connection-remove,
.api-preset-actions button {
  min-height: 38px;
  padding-inline: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  color: var(--ink);
  background: var(--glass);
  box-shadow:
    4px 5px 13px rgba(0, 0, 0, .055),
    -3px -3px 10px rgba(255, 255, 255, .68),
    inset 1px 1px 0 rgba(255, 255, 255, .70),
    inset -1px -1px 0 rgba(0, 0, 0, .035);
  transition:
    opacity .16s ease,
    background .16s ease,
    border-color .16s ease,
    box-shadow .16s ease,
    transform .12s ease;
}

.api-primary-button {
  color: var(--ink);
  background: var(--soft);
}

.api-primary-button:active,
.api-secondary-button:active,
.api-connection-remove:active,
.api-preset-actions button:active {
  transform: translateY(1px);
  box-shadow:
    inset 2px 2px 5px rgba(0, 0, 0, .10),
    inset -2px -2px 5px rgba(255, 255, 255, .66);
}

.api-primary-button:disabled,
.api-secondary-button:disabled,
.api-connection-remove:disabled,
.api-preset-actions button:disabled {
  opacity: .58;
  cursor: not-allowed;
  transform: none;
}

.api-secondary-button[data-busy="true"] {
  color: var(--ink);
  background: rgba(0, 0, 0, .035);
  box-shadow:
    inset 2px 2px 6px rgba(0, 0, 0, .10),
    inset -2px -2px 6px rgba(255, 255, 255, .72);
}

.api-preset-actions button[type="submit"] {
  color: var(--ink);
  background: var(--soft);
}

.api-segment-field {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.api-segment-field legend,
.api-segment-field p {
  grid-column: 1 / -1;
}

.api-segment-field label {
  position: relative;
  display: grid;
  min-width: 0;
}

.api-segment-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.api-segment-field span {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding-inline: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: rgba(0, 0, 0, .58);
  background: var(--glass);
  font-size: 12px;
  box-shadow:
    3px 4px 10px rgba(0, 0, 0, .035),
    inset 1px 1px 0 rgba(255, 255, 255, .66);
}

.api-segment-field input:checked + span {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(0, 0, 0, .035);
  box-shadow:
    inset 2px 2px 5px rgba(0, 0, 0, .08),
    inset -2px -2px 5px rgba(255, 255, 255, .72);
}

.api-connection-list {
  display: grid;
  gap: 8px;
}

.api-connection-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, .065);
  border-radius: 8px;
  background: rgba(255, 255, 255, .34);
}

.api-connection-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  line-height: 1.28;
}

.api-connection-item small {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: rgba(0, 0, 0, .47);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 10.5px;
  line-height: 1.28;
}

.api-balance-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.api-balance-toggle strong,
.api-balance-toggle small {
  display: block;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.api-balance-toggle strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.api-balance-toggle small {
  margin-top: 4px;
  color: rgba(0, 0, 0, .48);
  font-size: 11px;
  line-height: 1.35;
}

.api-balance-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.api-balance-toggle i {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .16);
  transition: background .18s ease;
}

.api-balance-toggle i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, .16);
  transition: transform .18s ease;
}

.api-balance-toggle input:checked + i {
  background: rgba(0, 0, 0, .085);
  box-shadow:
    4px 5px 13px rgba(0, 0, 0, .07),
    inset 1px 1px 0 rgba(255, 255, 255, .72),
    inset -1px -1px 0 rgba(0, 0, 0, .04);
}

.api-balance-toggle input:checked + i::after {
  background: var(--glass);
  transform: translateX(20px);
}

.api-load-balance-panel {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow-anchor: none;
  padding-top: 12px;
}

.api-add-preset-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  justify-self: stretch;
  min-width: 0;
  text-align: left;
}

.api-add-preset-control > span {
  justify-self: start;
  margin: 0;
}

.api-add-preset-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--glass);
  box-shadow:
    4px 5px 13px rgba(0, 0, 0, .07),
    -3px -3px 10px rgba(255, 255, 255, .70),
    inset 1px 1px 0 rgba(255, 255, 255, .72),
    inset -1px -1px 0 rgba(0, 0, 0, .04);
  cursor: pointer;
  transition:
    opacity .16s ease,
    transform .12s ease,
    box-shadow .16s ease;
}

.api-add-preset-button span {
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  transform: translateY(-1px);
}

.api-add-preset-button:active {
  transform: translateY(1px);
  box-shadow:
    inset 2px 2px 5px rgba(0, 0, 0, .10),
    inset -2px -2px 5px rgba(255, 255, 255, .68);
}

.api-add-preset-button:disabled {
  opacity: .38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.api-connection-item {
  grid-template-columns: 60px minmax(0, 1fr) 84px auto;
  align-items: center;
}

.api-connection-order {
  display: grid;
  grid-template-columns: repeat(2, 28px);
  gap: 4px;
}

.api-connection-move {
  display: grid;
  place-items: center;
  width: 28px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, .54);
  font: 600 15px/1 system-ui, sans-serif;
  cursor: pointer;
}

.api-connection-move:focus-visible {
  outline: 1px solid rgba(0, 0, 0, .34);
  outline-offset: 2px;
}

.api-connection-move:disabled {
  opacity: .28;
  cursor: not-allowed;
}

.api-connection-weight {
  display: grid;
  gap: 4px;
  color: rgba(0, 0, 0, .52);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 10.5px;
}

.api-connection-weight input {
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 8px;
  background: rgba(255, 255, 255, .68);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.api-connection-remove {
  min-width: 34px;
  padding-inline: 8px;
  color: var(--ink);
  background: rgba(0, 0, 0, .055);
}

.api-status {
  min-height: 18px;
  margin: 0;
  color: rgba(0, 0, 0, .58);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.4;
}

.api-status[data-tone="error"] {
  color: #9b1c1c;
}

.api-status[data-tone="success"] {
  color: #166534;
}

.api-preset-dialog,
.api-connection-dialog {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: end center;
  padding: 24px 28px calc(164px + env(safe-area-inset-bottom));
  background: rgba(245, 245, 243, .54);
  opacity: 0;
  pointer-events: none;
  transition: none;
}

.api-preset-dialog.open,
.api-connection-dialog.open {
  opacity: 1;
  pointer-events: auto;
}

.api-preset-card {
  display: grid;
  gap: 12px;
  width: min(100%, 360px);
  padding: 18px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 20px;
  background: rgba(250, 250, 249, .96);
}

.api-preset-card label {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 14px;
  font-weight: 600;
}

.api-connection-card header h2 {
  margin: 0;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.api-connection-card header p {
  margin: 6px 0 0;
  color: rgba(0, 0, 0, .52);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.4;
}

.api-connection-choice-list {
  display: grid;
  gap: 8px;
  max-height: min(288px, 42dvh);
  overflow: auto;
}

.api-connection-choice {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, .075);
  border-radius: 8px;
  background: rgba(255, 255, 255, .46);
  cursor: pointer;
}

.api-connection-choice input {
  position: absolute;
  width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.api-connection-choice-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 6px;
  background: rgba(255, 255, 255, .74);
}

.api-connection-choice-mark::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  opacity: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}

.api-connection-choice input:checked + .api-connection-choice-mark {
  border-color: #111;
  background: #111;
}

.api-connection-choice input:checked + .api-connection-choice-mark::after {
  opacity: 1;
}

.api-connection-choice strong {
  display: block;
  overflow-wrap: anywhere;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  line-height: 1.25;
}

.api-connection-choice small {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: rgba(0, 0, 0, .48);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 10.5px;
  line-height: 1.25;
}

.api-preset-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

.disclaimer-dialog {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding:
    max(22px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(22px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: rgba(245, 245, 243, .70);
  opacity: 0;
  pointer-events: none;
  transition: none;
}

.disclaimer-dialog.open {
  opacity: 1;
  pointer-events: auto;
}

.disclaimer-card {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 12px;
  width: min(100%, 430px);
  max-height: min(86dvh, 720px);
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, .085);
  border-radius: 8px;
  color: #111;
  background: rgba(250, 250, 249, .98);
  box-shadow:
    8px 10px 28px rgba(0, 0, 0, .10),
    inset 1px 1px 0 rgba(255, 255, 255, .78);
  transform: translateY(14px) scale(.985);
  transition: none;
}

.disclaimer-dialog.open .disclaimer-card {
  transform: translateY(0) scale(1);
}

.disclaimer-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.disclaimer-header p,
.disclaimer-header h2,
.disclaimer-summary,
.disclaimer-body h3,
.disclaimer-body p,
.disclaimer-status {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.disclaimer-header p {
  color: rgba(0, 0, 0, .52);
  font-size: 12px;
  line-height: 1.35;
}

.disclaimer-header h2 {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 620;
  line-height: 1.18;
}

.disclaimer-header > span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 28px;
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 8px;
  color: #111;
  background: rgba(0, 0, 0, .035);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.disclaimer-summary,
.disclaimer-status {
  color: rgba(0, 0, 0, .58);
  font-size: 12px;
  line-height: 1.45;
}

.disclaimer-status[data-tone="error"] {
  color: #9b1c1c;
}

.disclaimer-body {
  display: grid;
  gap: 11px;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, .07);
  border-radius: 8px;
  background: rgba(255, 255, 255, .58);
  outline: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.disclaimer-body:focus-visible {
  border-color: rgba(0, 0, 0, .22);
}

.disclaimer-body section {
  display: grid;
  gap: 5px;
}

.disclaimer-body h3 {
  color: #111;
  font-size: 13px;
  font-weight: 620;
  line-height: 1.35;
}

.disclaimer-body p {
  color: rgba(0, 0, 0, .64);
  font-size: 12px;
  line-height: 1.65;
}

.disclaimer-actions {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.38fr);
  gap: 10px;
}

.disclaimer-actions button {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 8px;
  color: #111;
  background: rgba(255, 255, 255, .72);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition:
    opacity .16s ease,
    background .16s ease,
    box-shadow .16s ease,
    transform .12s ease;
}

.disclaimer-actions button:focus-visible {
  outline: 1px solid rgba(0, 0, 0, .32);
  outline-offset: 2px;
}

.disclaimer-actions button:active {
  transform: translateY(1px);
}

.disclaimer-accept {
  background: rgba(0, 0, 0, .055);
  box-shadow:
    4px 5px 13px rgba(0, 0, 0, .055),
    inset 1px 1px 0 rgba(255, 255, 255, .68);
}

.disclaimer-actions button:disabled {
  opacity: .52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (max-width: 460px), (max-height: 700px) {
  .disclaimer-dialog {
    align-items: end;
  }

  .disclaimer-card {
    max-height: min(90dvh, 660px);
  }
}

:root.night-mode {
  color-scheme: dark;
  --ink: #f1eee7;
  --muted: #a8a096;
  --paper: #11100f;
  --soft: #1b1a18;
  --line: rgba(255, 255, 255, .10);
}

html.night-mode,
html.night-mode body {
  background: #11100f;
}

html.night-mode body {
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, .07), transparent 34%),
    linear-gradient(180deg, #181715, #0f0f0e 58%, #151412);
}

html.night-mode .screen {
  background:
    radial-gradient(circle at 24% 8%, rgba(255, 255, 255, .06), transparent 30%),
    linear-gradient(180deg, #1b1a18 0%, #11100f 58%, #171614 100%);
}

html.night-mode .status-right,
html.night-mode .status-left,
html.night-mode .weather-card,
html.night-mode .settings-header button,
html.night-mode .settings-title h1,
html.night-mode .settings-icon {
  color: var(--ink);
}

html.night-mode .signal i,
html.night-mode #batteryFill {
  background: var(--ink);
}

html.night-mode .greeting-button,
html.night-mode .time-card p,
html.night-mode .weather-location-button,
html.night-mode .map-weather-location-button,
html.night-mode .weather-picker-card,
html.night-mode .weather-picker-result,
html.night-mode .weather-picker-field input,
html.night-mode .weather-picker-actions button,
html.night-mode .settings-title p,
html.night-mode .settings-copy small {
  color: rgba(241, 238, 231, .58);
}

html.night-mode .settings-page {
  background:
    radial-gradient(circle at 50% 5%, rgba(255, 255, 255, .07), transparent 32%),
    rgba(17, 16, 15, .94);
}

html.night-mode .settings-group,
html.night-mode .app-panel,
html.night-mode .edit-card {
  background: rgba(255, 255, 255, .055);
  box-shadow:
    4px 5px 16px rgba(0, 0, 0, .22),
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .18);
}

html.night-mode .disclaimer-dialog {
  background: rgba(17, 16, 15, .70);
}

html.night-mode .disclaimer-card {
  color: var(--ink);
  border-color: rgba(255, 255, 255, .10);
  background: rgba(22, 21, 19, .98);
  box-shadow:
    8px 10px 28px rgba(0, 0, 0, .30),
    inset 1px 1px 0 rgba(255, 255, 255, .08);
}

html.night-mode .disclaimer-header p,
html.night-mode .disclaimer-summary,
html.night-mode .disclaimer-status {
  color: rgba(241, 238, 231, .58);
}

html.night-mode .disclaimer-status[data-tone="error"] {
  color: #fca5a5;
}

html.night-mode .disclaimer-header h2,
html.night-mode .disclaimer-header > span,
html.night-mode .disclaimer-body h3,
html.night-mode .disclaimer-actions button {
  color: var(--ink);
}

html.night-mode .disclaimer-header > span,
html.night-mode .disclaimer-body,
html.night-mode .disclaimer-actions button {
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .07);
}

html.night-mode .disclaimer-body p {
  color: rgba(241, 238, 231, .66);
}

html.night-mode .disclaimer-body:focus-visible,
html.night-mode .disclaimer-actions button:focus-visible {
  border-color: rgba(241, 238, 231, .36);
  outline-color: rgba(241, 238, 231, .36);
}

html.night-mode .disclaimer-accept {
  background: rgba(255, 255, 255, .10);
  box-shadow:
    4px 5px 14px rgba(0, 0, 0, .24),
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .22);
}

html.night-mode .settings-row + .settings-row {
  border-top-color: rgba(255, 255, 255, .07);
}

html.night-mode #apiSettingsToggle[aria-expanded="true"],
html.night-mode #imageSettingsToggle[aria-expanded="true"],
html.night-mode #voiceSettingsToggle[aria-expanded="true"] {
  background: rgba(241, 238, 231, .10);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .24);
}

html.night-mode #apiSettingsToggle[aria-expanded="true"] .settings-icon,
html.night-mode #imageSettingsToggle[aria-expanded="true"] .settings-icon,
html.night-mode #voiceSettingsToggle[aria-expanded="true"] .settings-icon {
  color: var(--ink);
}

html.night-mode .settings-copy strong,
html.night-mode .app-panel h1,
html.night-mode .app-panel span {
  color: var(--ink);
}

html.night-mode .settings-chevron {
  border-color: rgba(241, 238, 231, .45);
}

html.night-mode .settings-switch {
  background: #f1eee7;
}

html.night-mode .settings-switch::after {
  background: #11100f;
}

html.night-mode .settings-toggle-row input:not(:checked) + .settings-switch {
  background: rgba(255, 255, 255, .16);
}

html.night-mode .api-settings-panel,
html.night-mode .image-settings-panel,
html.night-mode .image-recognition-settings-panel,
html.night-mode .voice-settings-panel,
html.night-mode .api-section {
  border-top-color: rgba(255, 255, 255, .07);
}

html.night-mode .api-section-heading h2,
html.night-mode .api-connections-heading h3,
html.night-mode .api-field,
html.night-mode .api-field > span,
html.night-mode .api-segment-field legend,
html.night-mode .api-range-field b,
html.night-mode .api-connection-item strong,
html.night-mode .api-balance-toggle strong,
html.night-mode .image-switch-row strong,
html.night-mode .api-connection-remove,
html.night-mode .api-connection-move,
html.night-mode .api-preset-card label {
  color: var(--ink);
}

html.night-mode .api-section-heading p,
html.night-mode .api-connections-heading p,
html.night-mode .api-segment-field p,
html.night-mode .api-range-field small,
html.night-mode .api-field-note,
html.night-mode .api-current-preset span,
html.night-mode .api-connections-heading label > span,
html.night-mode .api-connections-heading > div:last-child > span,
html.night-mode .api-add-preset-control > span,
html.night-mode .api-connection-item small,
html.night-mode .api-connection-card header p,
html.night-mode .api-connection-choice small,
html.night-mode .api-balance-toggle small,
html.night-mode .api-connection-weight,
html.night-mode .api-status {
  color: rgba(241, 238, 231, .58);
}

html.night-mode .api-field input,
html.night-mode .api-field textarea,
html.night-mode .api-field select,
html.night-mode .api-preset-card input,
html.night-mode .api-preset-card textarea,
html.night-mode .api-connection-weight input,
html.night-mode .api-dropdown-button {
  color: var(--ink);
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .06);
}

html.night-mode .api-dropdown-button[aria-expanded="true"],
html.night-mode .api-combo input[aria-expanded="true"] {
  border-color: rgba(241, 238, 231, .36);
  background: rgba(255, 255, 255, .11);
  box-shadow:
    0 12px 26px rgba(0, 0, 0, .22),
    inset 1px 1px 0 rgba(255, 255, 255, .08);
}

html.night-mode .api-field input:focus,
html.night-mode .api-field textarea:focus,
html.night-mode .api-field select:focus,
html.night-mode .api-preset-card input:focus,
html.night-mode .api-preset-card textarea:focus,
html.night-mode .api-connection-weight input:focus,
html.night-mode .api-dropdown-button:focus-visible {
  border-color: rgba(241, 238, 231, .42);
}

html.night-mode .api-dropdown-button i {
  border-color: rgba(241, 238, 231, .62);
}

html.night-mode .api-combo::after {
  border-color: rgba(241, 238, 231, .62);
}

html.night-mode .api-dropdown-button:disabled {
  color: rgba(241, 238, 231, .38);
}

html.night-mode .api-dropdown-menu,
html.night-mode .api-combo-menu {
  border-color: rgba(255, 255, 255, .12);
  background: rgba(26, 25, 23, .98);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .26);
}

html.night-mode .api-dropdown-option,
html.night-mode .api-combo-option {
  color: var(--ink);
}

html.night-mode .api-dropdown-option:hover,
html.night-mode .api-dropdown-option:focus-visible,
html.night-mode .api-combo-option:hover,
html.night-mode .api-combo-option:focus-visible {
  background: rgba(255, 255, 255, .08);
}

html.night-mode .api-dropdown-option small,
html.night-mode .api-combo-option small {
  color: rgba(241, 238, 231, .56);
}

html.night-mode .api-dropdown-option[aria-selected="true"],
html.night-mode .api-combo-option[aria-selected="true"] {
  color: var(--ink);
  background: rgba(241, 238, 231, .13);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .20);
}

html.night-mode .api-dropdown-option[aria-selected="true"] small,
html.night-mode .api-combo-option[aria-selected="true"] small {
  color: rgba(241, 238, 231, .62);
}

html.night-mode .api-dropdown-option[aria-disabled="true"],
html.night-mode .api-combo-option[aria-disabled="true"] {
  color: rgba(241, 238, 231, .40);
}

html.night-mode .image-app-row {
  border-color: rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .045);
}

html.night-mode .image-app-copy strong {
  color: var(--ink);
}

html.night-mode .image-app-copy small {
  color: rgba(241, 238, 231, .56);
}

html.night-mode .image-test-preview {
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .06);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .07),
    inset -1px -1px 0 rgba(0, 0, 0, .14);
}

html.night-mode .image-test-preview img {
  background: rgba(0, 0, 0, .22);
}

html.night-mode .api-primary-button,
html.night-mode .api-segment-field input:checked + span,
html.night-mode .api-preset-actions button[type="submit"] {
  color: var(--ink);
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .095);
  box-shadow:
    4px 5px 14px rgba(0, 0, 0, .22),
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .22);
}

html.night-mode .api-secondary-button,
html.night-mode .api-preset-actions button,
html.night-mode .api-connection-remove {
  color: var(--ink);
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .08);
  box-shadow:
    4px 5px 14px rgba(0, 0, 0, .22),
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .22);
}

html.night-mode .api-secondary-button[data-busy="true"] {
  color: var(--ink);
  background: rgba(255, 255, 255, .12);
  box-shadow:
    inset 2px 2px 6px rgba(0, 0, 0, .28),
    inset -2px -2px 6px rgba(255, 255, 255, .07);
}

html.night-mode .api-add-preset-button {
  color: var(--ink);
  border-color: rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .10);
  box-shadow:
    4px 5px 14px rgba(0, 0, 0, .24),
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .22);
}

html.night-mode .api-segment-field span,
html.night-mode .api-connection-item,
html.night-mode .api-connection-choice,
html.night-mode .image-switch-row {
  color: rgba(241, 238, 231, .62);
  border-color: rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .05);
}

html.night-mode .api-connection-card header h2,
html.night-mode .api-connection-choice strong {
  color: var(--ink);
}

html.night-mode .api-connection-choice-mark {
  border-color: rgba(241, 238, 231, .24);
  background: rgba(255, 255, 255, .08);
}

html.night-mode .api-connection-choice input:checked + .api-connection-choice-mark {
  border-color: var(--ink);
  background: var(--ink);
}

html.night-mode .api-connection-choice input:checked + .api-connection-choice-mark::after {
  border-color: #11100f;
}

html.night-mode .api-balance-toggle i {
  background: rgba(255, 255, 255, .16);
}

html.night-mode .api-balance-toggle input:checked + i {
  background: rgba(255, 255, 255, .18);
}

html.night-mode .api-balance-toggle i::after,
html.night-mode .image-switch-row i::after {
  background: var(--ink);
}

html.night-mode .image-switch-row small {
  color: rgba(241, 238, 231, .58);
}

html.night-mode .image-switch-row i {
  background: rgba(255, 255, 255, .16);
}

html.night-mode .image-switch-row input:checked + i {
  background: rgba(255, 255, 255, .18);
}

html.night-mode .image-mode-tabs,
html.night-mode .voice-region-tabs {
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .055);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .07),
    inset -1px -1px 0 rgba(0, 0, 0, .18);
}

html.night-mode .image-mode-tabs button,
html.night-mode .voice-region-tabs button {
  color: rgba(241, 238, 231, .58);
}

html.night-mode .image-mode-tabs button[aria-selected="true"],
html.night-mode .voice-region-tabs button[aria-selected="true"] {
  color: var(--ink);
  background: rgba(241, 238, 231, .13);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .22);
}

html.night-mode .api-range-field input[type="range"] {
  accent-color: var(--ink);
}

html.night-mode .api-range-field input[type="range"]::-webkit-slider-runnable-track {
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .10);
  box-shadow:
    inset 1px 1px 3px rgba(0, 0, 0, .26),
    inset -1px -1px 3px rgba(255, 255, 255, .06);
}

html.night-mode .api-range-field input[type="range"]::-webkit-slider-thumb {
  border-color: rgba(255, 255, 255, .16);
  background: var(--ink);
  box-shadow:
    3px 4px 10px rgba(0, 0, 0, .32),
    inset 1px 1px 0 rgba(255, 255, 255, .20),
    inset -1px -1px 0 rgba(0, 0, 0, .14);
}

html.night-mode .api-range-field input[type="range"]::-moz-range-track {
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .10);
  box-shadow:
    inset 1px 1px 3px rgba(0, 0, 0, .26),
    inset -1px -1px 3px rgba(255, 255, 255, .06);
}

html.night-mode .api-range-field input[type="range"]::-moz-range-thumb {
  border-color: rgba(255, 255, 255, .16);
  background: var(--ink);
  box-shadow:
    3px 4px 10px rgba(0, 0, 0, .32),
    inset 1px 1px 0 rgba(255, 255, 255, .20),
    inset -1px -1px 0 rgba(0, 0, 0, .14);
}

html.night-mode .api-preset-dialog,
html.night-mode .api-connection-dialog {
  background: rgba(17, 16, 15, .68);
}

html.night-mode .api-preset-card {
  border-color: rgba(255, 255, 255, .10);
  background: rgba(26, 25, 23, .96);
}

html.night-mode .novelai-preset-card .api-preset-actions {
  background: rgba(26, 25, 23, .96);
}

html.night-mode .dock-button.active span {
  color: var(--ink);
}

html.night-mode .app-button span:last-child,
html.night-mode .dock-button span {
  color: rgba(241, 238, 231, .88);
}

@media (max-width: 380px) {
  .settings-page {
    padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right));
  }

  .settings-copy small {
    font-size: 10.5px;
  }

  .api-section-heading,
  .api-connections-heading,
  .api-connection-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .api-action-row {
    grid-template-columns: 1fr;
  }

  .image-action-row,
  .novelai-preset-grid,
  .image-inline-control {
    grid-template-columns: 1fr;
  }

  .api-segment-field {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .api-connection-order {
    justify-content: start;
  }

  .api-connection-remove {
    width: 100%;
  }
}

@media (max-width: 480px), (max-height: 720px) {
  #novelaiPresetDialog {
    place-items: center stretch;
    padding:
      max(8px, env(safe-area-inset-top))
      8px
      max(8px, env(safe-area-inset-bottom));
  }

  .novelai-preset-card {
    align-self: center;
    justify-self: stretch;
    width: 100%;
    max-height: min(calc(100dvh - 16px), calc(100% - 16px));
    padding: 14px;
    border-radius: 12px;
    gap: 10px;
  }

  .novelai-preset-card .api-preset-actions {
    justify-content: stretch;
    margin: 0 -14px -14px;
    padding: 10px 14px 14px;
  }

  .novelai-preset-card .api-preset-actions button {
    flex: 1 1 0;
    min-width: 0;
  }
}
