/* The settings screen and its controls: the same rules as the Reset Tracker's settings
   (rows, selects, switch, segmented control, colour swatches), so both feel like one product. */
:root {
  --t-small: 13px; --r-xs: 8px; --r-s: 12px;
  --ease-io: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 160ms; --dur: 240ms;
  --ease-ctl: cubic-bezier(0.25, 0.9, 0.3, 1); --dur-ctl: 230ms;
  --line-strong: rgb(var(--fg-rgb) / 0.22);
  --hover: rgb(var(--fg-rgb) / 0.06); --press: rgb(var(--fg-rgb) / 0.1);
  --red: #ff453a; --cta-rgb: var(--accent-rgb);
  --content-max: 760px;
}
:root[data-theme="light"] { --red: #e5372c; --press: rgb(var(--fg-rgb) / 0.08); --hover: rgb(var(--fg-rgb) / 0.045); }

/* ---- the screen ---- */
.c-set { position: relative; z-index: 2; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: calc(var(--safe-t) + 72px) var(--pad) 96px; animation: screen-in 360ms var(--ease-out) both; overflow-x: clip; font-family: var(--f-sans); }
.c-set[hidden] { display: none; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }
.c-set .title { font-size: 34px; line-height: 1.02; font-weight: 700; letter-spacing: -0.035em; text-wrap: balance; }
.c-set .title:focus-visible { outline: none; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px -6px; padding: 6px 8px 6px 4px; border: 0; background: none; color: var(--muted); font: 500 14px var(--f-sans); border-radius: 10px; cursor: pointer; }
.back-link:hover { color: var(--fg); }
.back-link svg { width: 18px; height: 18px; }
.back-link svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* ---------- sections ---------- */
.st-sec { margin-top: 40px; scroll-margin-top: calc(var(--safe-t) + 72px); border-radius: var(--r-m); }
.st-sec__title { font-size: 20px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; overflow-wrap: anywhere; hyphens: manual; }
.st-lede { margin-top: 6px; font-size: var(--t-small); line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.st-fine { padding: 14px 0; font-size: var(--t-small); line-height: 1.4; color: var(--faint); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
/* ---------- rows (hairlines, no glass) ---------- */
.st-group { margin-top: 10px; border-top: 1px solid var(--line); }
.st-row {
  display: flex; align-items: center; gap: 14px;
  min-height: 56px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.st-row__icon { flex: none; display: grid; place-items: center; width: 20px; height: 20px; color: var(--muted); }
.st-row__icon svg { width: 20px; height: 20px; }
.st-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.st-row__title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; overflow-wrap: anywhere; hyphens: manual; }
.st-row__sub { margin-top: 3px; font-size: var(--t-small); line-height: 1.35; color: var(--muted); overflow-wrap: break-word; hyphens: manual; text-wrap: pretty; }
.st-row__ctl { flex: none; display: flex; align-items: center; max-width: 100%; }

/* the control drops under the label only when both do not fit (Theme, Units in long languages) */
.st-row--wrap { flex-wrap: wrap; row-gap: 10px; }
.st-row--wrap > .st-row__main { flex: 1 0 auto; min-width: 72px; }
.st-row--wrap > .st-row__ctl { margin-left: auto; }

.st-row .segmented button { padding: 0 12px; }

/* rows whose control sits under the label (ring colours, app colour) */
.st-row--stack { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 0 16px; }

/* selects (Language, Font): one width, so the two controls line up in rows that sit next to each other */
.st-select { width: 190px; min-width: 0; max-width: 100%; min-height: 40px; padding: 8px 34px 8px 14px; font-size: 14px; border-radius: var(--r-pill); }

/* action rows (buttons) */
.st-row--btn {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; color: inherit;
  text-align: left; font: inherit; cursor: pointer;
  border-radius: 0; position: relative;
  -webkit-tap-highlight-color: transparent;
}
.st-row--btn::after {
  content: ""; position: absolute; inset: 0 -6px; border-radius: var(--r-s); background: var(--press);
  opacity: 0; transition: opacity var(--dur-fast); pointer-events: none;
}
.st-row--btn:active::after { opacity: 1; }
@media (hover: hover) { .st-row--btn:hover::after { opacity: 0.55; } }
.st-row--btn:focus-visible { outline-offset: -2px; }
.st-row--btn:disabled { cursor: default; opacity: 0.5; }
.st-row__chev { flex: none; color: var(--faint); display: grid; place-items: center; }
.st-accents { display: flex; flex-wrap: wrap; gap: 14px; padding: 2px 4px; }
.st-swatch {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--sw);
  box-shadow: 0 0 0 0 var(--bg), 0 0 0 0 var(--fg);
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.st-swatch:active { transform: scale(0.92); }
.st-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--fg); }
.st-swatch:focus-visible { outline: 2px solid var(--fg); outline-offset: 6px; }
.st-swatch.is-any { background: conic-gradient(#ff5b5b, #ffd66e, #43d6a3, #3fc6ff, #7b7bff, #e86bb6, #ff5b5b); }
.st-quiet { margin-top: 56px; padding-top: 6px; }
.st-quiet__links { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.st-link {
  min-height: 40px; padding: 0; border: 0; background: none; cursor: pointer;
  font: 500 var(--t-small) var(--f-sans); color: var(--muted); text-align: left;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px;
  transition: color var(--dur-fast), text-decoration-color var(--dur-fast);
}
@media (hover: hover) { .st-link:hover { color: var(--fg); text-decoration-color: currentColor; } }
.st-link--danger { color: color-mix(in srgb, var(--red) 55%, var(--muted)); }
@media (hover: hover) { .st-link--danger:hover { color: var(--red); } }
.st-quiet__ver { margin-top: 4px; font-size: 12px; color: var(--faint); }
.st-snds { display: flex; flex-direction: column; gap: 6px; padding-bottom: 4px; }
.st-snd { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 10px 12px; border: 0; border-radius: var(--r-m, 16px); background: rgb(var(--fg-rgb, 255 255 255) / 0.05); color: inherit; font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background var(--dur-fast, .15s), box-shadow var(--dur-fast, .15s); }
.st-snd:focus-visible { outline: 2px solid var(--cta, var(--accent)); outline-offset: -2px; }
.st-snd__name { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.015em; overflow-wrap: anywhere; hyphens: manual; }
.st-snd__dot { flex: none; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line-strong, rgb(127 127 127 / .45)); display: grid; place-items: center; }
.st-snd[aria-checked="true"] { background: rgb(var(--cta-rgb) / 0.14); box-shadow: inset 0 0 0 1px rgb(var(--cta-rgb) / 0.5); }
.st-snd[aria-checked="true"] .st-snd__dot { background: rgb(var(--cta-rgb)); box-shadow: none; }
.st-snd[aria-checked="true"] .st-snd__dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
/* ---- controls ---- */
.select {
  width: 100%; min-height: 48px; padding: 12px 16px;
  border: 0; border-radius: var(--r-m);
  background: rgb(var(--fg-rgb) / 0.06);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 16px; font-weight: 500; letter-spacing: -0.01em; color: var(--fg);
  outline: none;
  transition: box-shadow var(--dur) var(--ease-out), background var(--dur);
}

.select:focus { box-shadow: inset 0 0 0 2px var(--accent); background: rgb(var(--fg-rgb) / 0.08); }
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 5; }
.switch__track { position: absolute; inset: 0; border-radius: var(--r-pill); background: rgb(var(--fg-rgb) / 0.16); transition: background-color var(--dur-ctl) var(--ease-ctl); }
.switch input:checked ~ .switch__track { background: var(--accent); }
.switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: var(--r-pill);
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.18), 0 0 0 0.5px rgb(0 0 0 / 0.06);
  transition: transform var(--dur-ctl) var(--ease-ctl), width var(--dur-ctl) var(--ease-ctl), background-color var(--dur-ctl);
  pointer-events: none; will-change: transform;
}
.switch input:checked ~ .switch__thumb { transform: translateX(20px); }
.switch:active .switch__thumb { width: 34px; }
.switch:active input:checked ~ .switch__thumb { transform: translateX(13px); }
/* focus ring inside the track, in the 2px gap around the knob; white on the coloured (on) track */
.switch input:focus-visible ~ .switch__track { outline: 2px solid var(--accent); outline-offset: -2px; }
.switch input:checked:focus-visible ~ .switch__track { outline-color: rgb(255 255 255 / 0.92); }
.segmented { position: relative; display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: rgb(var(--fg-rgb) / 0.08); gap: 0; }
.segmented button {
  position: relative; z-index: 2; flex: 1;
  min-height: 34px; padding: 0 16px; border: 0; background: none; border-radius: var(--r-pill);
  font: 600 13px/1 var(--f-sans); color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: color var(--dur-ctl) var(--ease-ctl), transform var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.segmented button:active { transform: scale(0.96); }
.segmented button[aria-pressed="true"] { color: var(--fg); }
.segmented__lens {
  position: absolute; z-index: 1; top: 4px; bottom: 4px; left: 0; border-radius: var(--r-pill);
  background: rgb(255 255 255 / 0.1);
  transition: transform var(--dur-ctl) var(--ease-ctl), width var(--dur-ctl) var(--ease-ctl), opacity var(--dur-ctl);
  will-change: transform;
}
.segmented__lens.is-placing { transition: none; }   /* first placement: no slide in from the left */
:root[data-theme="light"] .segmented__lens { background: rgb(255 255 255 / 0.55); }
.switch__thumb, .slider__thumb, .switch input:checked ~ .switch__thumb {
  background: rgb(255 255 255 / 0.10);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.55), inset 0 1px 1px rgb(255 255 255 / 0.5), 0 3px 10px rgb(0 0 0 / 0.28);
}
.switch:active .switch__thumb, .slider.is-dragging .slider__thumb { background: rgb(255 255 255 / 0.05); }
:root[data-theme="light"] .switch__thumb, :root[data-theme="light"] .slider__thumb {
  background: rgb(255 255 255 / 0.35);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.9), 0 0 0 0.5px rgb(0 0 0 / 0.12), 0 3px 10px rgb(0 0 0 / 0.18);
}
.segmented__lens { box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.22), inset 0 1px 1px rgb(255 255 255 / 0.3); }
.st-row__icon svg, .st-row__chev svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.select { appearance: none; -webkit-appearance: none; font-family: var(--f-sans); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; }
.st-row--link { text-decoration: none; }
.st-own { display: flex; align-items: center; gap: 12px; }
.st-own input[type="color"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.st-link--danger { color: color-mix(in srgb, var(--red) 55%, var(--muted)); }
@media (max-width: 520px) { .st-select { width: 160px; } }
:root[dir="rtl"] :is(.st-row--btn, .st-link, .st-snd) { text-align: start; }
:root[dir="rtl"] :is(.back-link, .st-row__chev) svg { transform: scaleX(-1); }
:root[dir="rtl"] .back-link { margin: 0 -6px 6px 0; padding: 6px 4px 6px 8px; }
:root[dir="rtl"] .st-row--wrap > .st-row__ctl { margin-left: 0; margin-inline-start: auto; }
:root[dir="rtl"] .st-select { padding: 8px 14px 8px 34px; background-position: left 12px center; }
:root[dir="rtl"] .switch__thumb { left: auto; right: 2px; }
:root[dir="rtl"] .switch input:checked ~ .switch__thumb { transform: translateX(-20px); }
:root[dir="rtl"] .switch:active input:checked ~ .switch__thumb { transform: translateX(-13px); }
@media (max-width: 380px) {
  :root[dir="rtl"] .st-row .segmented button { white-space: normal; overflow-wrap: anywhere; padding-inline: 8px; }
  :root[dir="rtl"] .st-row--wrap > .st-row__main { flex-basis: 100%; }
  :root[dir="rtl"] .st-select { width: min(140px, 45vw); }
}
@media (prefers-reduced-motion: reduce) { .c-set { animation: none; } .segmented__lens, .switch__thumb { transition-duration: 1ms !important; } }

/* the gear: lit with the app colour while Settings is open */
#c-more-btn svg { width: 20px; height: 20px; }
#c-more-btn[aria-current] { color: var(--accent); }
body.is-settings .c-app, body.is-settings .c-bar, body.is-settings .c-start { display: none !important; }
/* selects (Language, Font): one width, a pill, as in the tracker (after the base .select rule so it wins) */
.select.st-select { width: 190px; min-width: 0; max-width: 100%; min-height: 40px; padding: 8px 34px 8px 14px; font-size: 14px; font-weight: 600; border-radius: var(--r-pill); }
@media (max-width: 520px) { .select.st-select { width: 160px; } }
