.settings-button { flex: 0 0 auto; cursor: pointer; }
.settings-button[aria-expanded="true"] { color: var(--orange-dark); background: #f7e2da; border-color: #d8ab97; }
html.settings-open { overflow: hidden; }
.settings-dialog {
  width: min(440px, calc(100% - 24px));
  max-height: calc(100vh - 100px);
  max-height: calc(100dvh - 100px);
  margin: 0;
  position: fixed;
  inset: 88px max(12px, calc((100vw - 1420px) / 2)) auto auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 26px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 20px 70px rgba(25, 31, 28, .2);
}
.settings-dialog::backdrop { background: rgba(22, 27, 24, .35); }
.settings-content { padding: 24px; }
.settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.settings-heading h2 { margin: 0; font-size: 1.65rem; }
.settings-close { flex: 0 0 auto; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 1.5rem; cursor: pointer; }
.settings-close:hover { background: var(--cream); }
.settings-content h3 { margin: 0 0 8px; font-family: var(--sans); font-size: .95rem; line-height: 1.4; }
.settings-intro, .settings-footnote { margin: 0; color: #5b645e; font-size: .82rem; line-height: 1.6; }
.settings-summary { margin: 12px 0; font-size: .76rem; font-weight: 700; }
.settings-footnote { margin-top: 16px; font-size: .73rem; }
.backup-health { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 16px; background: #f1eee7; }
.backup-health-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #80877b; }
.backup-health[data-state="fresh"] .backup-health-dot { background: var(--moss); }
.backup-health[data-state="changed"] .backup-health-dot,
.backup-health[data-state="stale"] .backup-health-dot { background: #aa731e; }
.backup-health[data-state="error"] .backup-health-dot { background: var(--red); }
.backup-health strong, .backup-health small { display: block; }
.backup-health strong { font-size: .79rem; }
.backup-health small { margin-top: 2px; font-size: .72rem; color: #5b645e; }
.settings-actions { display: grid; gap: 10px; margin-top: 18px; }
.settings-action { width: 100%; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 16px; text-align: left; border: 1px solid var(--line); border-radius: 18px; background: transparent; cursor: pointer; }
.settings-action:hover { border-color: #b59d88; background: #f8f4ec; }
.settings-action strong, .settings-action small { display: block; }
.settings-action strong { font-size: .87rem; }
.settings-action small { color: #5b645e; font-size: .72rem; font-weight: 400; }
.settings-action svg { width: 22px; height: 22px; color: var(--orange-dark); }
.settings-content button:disabled { opacity: .55; cursor: not-allowed; }
.backup-message { margin: 16px 0 0; padding: 12px; border-radius: 14px; color: #3f5138; background: #edf1e5; font-size: .79rem; overflow-wrap: anywhere; }
.backup-message.is-error { color: #822e24; background: #fbeae4; }
.restore-file { display: grid; gap: 3px; margin-top: 14px; overflow-wrap: anywhere; }
.restore-file strong { font-size: .79rem; }
.restore-file span { color: #5b645e; font-size: .73rem; }
.restore-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.restore-counts div { display: flex; flex-direction: column-reverse; gap: 2px; padding: 12px; background: #f1eee7; border-radius: 14px; }
.restore-counts dt { color: #5b645e; font-size: .7rem; }
.restore-counts dd { margin: 0; font-weight: 800; font-size: 1.2rem; }
.restore-options { min-width: 0; display: grid; gap: 8px; padding: 0; margin: 0; border: 0; }
.restore-options legend { padding: 0 0 10px; font-size: .82rem; font-weight: 800; }
.restore-options label { display: flex; align-items: start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; cursor: pointer; }
.restore-options label:has(input:checked) { border-color: var(--moss); background: #f1f3e9; }
.restore-options strong, .restore-options small { display: block; }
.restore-options strong { font-size: .8rem; }
.restore-options small { margin-top: 3px; font-size: .74rem; color: #5b645e; }
.restore-options input, .replace-confirmation input { flex: 0 0 auto; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--moss); }
.replace-confirmation { display: flex; align-items: start; gap: 10px; margin-top: 12px; padding: 13px; border-radius: 14px; color: #822e24; background: #fbeae4; font-size: .77rem; cursor: pointer; }
.settings-text-button { min-height: 44px; padding: 8px 0; color: var(--orange-dark); border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; font-size: .78rem; cursor: pointer; }
.restore-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.restore-footer .button { flex: 1; }
.restore-footer .primary { background: var(--orange-dark); box-shadow: none; }
.restore-footer .danger { background: var(--red); }
#download-recovery { margin-top: 12px; }
@media (max-width: 780px) {
  .settings-dialog { inset: 78px 12px auto auto; max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); }
}
@media (max-width: 430px) {
  .settings-content { padding: 20px; }
}
@media print { .settings-dialog { display: none !important; } }
