.settings-trigger svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#settingsDialog {
  overflow: visible;
}

.settings-card {
  width: min(92vw, 440px);
  max-height: min(76dvh, 650px);
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.settings-card::-webkit-scrollbar { display: none; }

.settings-card .modal-head {
  position: sticky;
  top: 0;
  z-index: 4;
  margin: 0;
  padding: 16px 16px 12px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--line, rgba(127,127,127,.16));
}

.settings-card .modal-head .eyebrow {
  margin-bottom: 3px;
}

.settings-card .modal-head h3 {
  font-size: 22px;
}

.settings-card .modal-head .icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.settings-card .modal-head .icon-button:focus,
.settings-card .modal-head .icon-button:focus-visible,
.settings-card .modal-head .icon-button:active {
  outline: none;
  box-shadow: none;
}

.settings-section {
  margin-inline: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--line, rgba(127,127,127,.2));
}

/* Keep the app-color preference on a single compact row. */
.settings-section:first-of-type {
  border-top: 0;
  padding-block: 9px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.settings-section:first-of-type h4 {
  margin: 0;
  white-space: nowrap;
}

.settings-section:first-of-type > p {
  display: none;
}

.settings-section[aria-labelledby="settingsCameraTitle"] > p {
  display: none;
}

.settings-section h4 {
  margin: 0 0 4px;
  font-size: 15px;
}

.settings-section > p {
  margin: 0 0 10px;
  color: var(--muted, #8d8d92);
  font-size: 11.5px;
  line-height: 1.5;
}

.settings-theme-row {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.settings-theme-choice {
  min-width: 0;
  min-height: 36px;
  padding: 4px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line, rgba(127,127,127,.25));
  border-radius: 11px;
  background: var(--surface-2, rgba(127,127,127,.08));
  color: inherit;
  font: inherit;
  font-size: 11.5px;
  font-weight: 750;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.settings-theme-choice[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.settings-theme-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22), 0 0 0 1px rgba(0,0,0,.08);
}

.settings-theme-dot.blue { background: #2f6df6; }
.settings-theme-dot.red { background: #e34b4b; }
.settings-theme-dot.green { background: #24a66a; }

.settings-list {
  display: grid;
}

.settings-row {
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line, rgba(127,127,127,.16));
}

.settings-row:last-child { border-bottom: 0; }

.settings-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.settings-copy strong {
  font-size: 13.5px;
  font-weight: 780;
}

.settings-copy small {
  color: var(--muted, #8d8d92);
  font-size: 10.5px;
  line-height: 1.35;
}

.settings-switch {
  position: relative;
  width: 44px;
  height: 27px;
  flex: 0 0 44px;
}

.settings-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(127,127,127,.28);
  transition: background .16s ease;
}

.settings-switch span::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(0,0,0,.24);
  transition: transform .16s ease;
}

.settings-switch input:checked + span {
  background: var(--accent);
}

.settings-switch input:checked + span::after {
  transform: translateX(17px);
}

.settings-switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-footer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  gap: 9px;
  margin: 0;
  padding: 11px 16px 14px;
  background: var(--surface-solid);
  border-top: 1px solid var(--line, rgba(127,127,127,.16));
}

.settings-footer .btn {
  flex: 1;
  min-height: 44px;
}

/* Help dialog: compact content, fixed header and visible action. */
#aboutDialog {
  width: min(92vw, 520px);
  overflow: visible;
}

#aboutDialog .compact-card {
  width: 100%;
  max-height: min(76dvh, 650px);
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#aboutDialog .compact-card::-webkit-scrollbar { display: none; }

#aboutDialog .modal-head {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0;
  padding: 15px 16px 11px;
  background: var(--surface-solid);
  border-bottom: 1px solid var(--line, rgba(127,127,127,.16));
}

#aboutDialog .modal-head .eyebrow {
  margin-bottom: 2px;
}

#aboutDialog .modal-head h3 {
  font-size: 20px;
  line-height: 1.25;
}

#aboutDialog .modal-head .icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  outline: none;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

#aboutDialog .modal-head .icon-button:focus,
#aboutDialog .modal-head .icon-button:focus-visible,
#aboutDialog .modal-head .icon-button:active {
  outline: none;
  box-shadow: none;
}

#aboutDialog .compact-card > p {
  margin: 13px 16px 7px;
  font-size: 12.5px;
  line-height: 1.6;
}

#aboutDialog .about-list {
  margin: 7px 16px 12px;
  padding-right: 18px;
  font-size: 12.5px;
  line-height: 1.6;
}

#aboutDialog .about-list li {
  margin-block: 3px;
}

#settingsHelpSection {
  margin: 0 16px;
  padding-top: 11px;
  border-top: 1px solid var(--line, rgba(127,127,127,.16));
}

#settingsHelpSection h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

#settingsHelpSection .help-settings-list {
  margin: 0 0 9px;
  padding-right: 18px;
}

#settingsHelpSection .help-settings-note {
  margin: 0 0 10px;
  color: var(--muted, #8d8d92);
  font-size: 11px;
  line-height: 1.5;
}

#aboutDialog .about-done {
  position: sticky;
  bottom: 0;
  z-index: 5;
  width: calc(100% - 32px);
  min-height: 44px;
  margin: 4px 16px 14px;
  box-shadow: 0 -10px 24px var(--surface-solid), 0 10px 24px rgba(var(--accent-rgb), .18);
}

/* Camera preferences. Hidden controls keep their layout slots so the header never jumps. */
html[data-camera-grid="off"] .camera-grid {
  display: none !important;
}

html[data-camera-grid="on"] .camera-grid {
  opacity: .38;
}

html[data-camera-flash="off"] #cameraTorchBtn,
html[data-camera-switch="off"] #cameraFlipBtn,
html[data-camera-ratio="off"] #cameraRatioCycleBtn {
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 560px) {
  #settingsDialog,
  #aboutDialog {
    width: calc(100% - 20px);
  }

  .settings-card,
  #aboutDialog .compact-card {
    width: 100%;
    max-height: min(72dvh, 610px);
    border-radius: 22px;
  }

  .settings-card .modal-head {
    padding: 14px 14px 10px;
  }

  .settings-section {
    margin-inline: 14px;
    padding-block: 11px;
  }

  .settings-section:first-of-type {
    padding-block: 8px;
    gap: 8px;
  }

  .settings-section:first-of-type h4 {
    font-size: 14px;
  }

  .settings-theme-choice {
    min-height: 34px;
    padding-inline: 4px;
    font-size: 11px;
  }

  .settings-theme-dot {
    width: 11px;
    height: 11px;
    flex-basis: 11px;
  }

  .settings-row { min-height: 48px; }
  .settings-footer { padding: 10px 14px 12px; }

  #aboutDialog .modal-head {
    padding: 13px 14px 10px;
  }

  #aboutDialog .modal-head h3 {
    font-size: 18px;
  }

  #aboutDialog .compact-card > p {
    margin-inline: 14px;
    font-size: 12px;
  }

  #aboutDialog .about-list {
    margin-inline: 14px;
    font-size: 12px;
    line-height: 1.55;
  }

  #settingsHelpSection {
    margin-inline: 14px;
  }

  #aboutDialog .about-done {
    width: calc(100% - 28px);
    margin-inline: 14px;
    margin-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .settings-switch span,
  .settings-switch span::after { transition: none; }
}
