@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url(/fonts/archivo-latin.woff2) format("woff2");
}

:root {
  --a: #ff2d55;
  --b: #00d4c4;
  --m: var(--b);
  --bg: #ffffff;
  --text: #000000;
  --muted: #8e8e93;
  --line: rgba(60, 60, 67, .12);
  --fill: rgba(120, 120, 128, .14);
  --sep: rgba(0, 0, 0, .28);
  --danger: #ff3b30;
  --shadow: 0 12px 40px rgba(0, 0, 0, .16);
  --radius: 30px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Liquid Glass */
  --glass-bg: rgba(255, 255, 255, .62);
  --glass-blur: blur(12px) saturate(200%) brightness(1.04);
  --glass-rim-hi: rgba(255, 255, 255, 1);    /* light catching the top-left and bottom-right edges */
  --glass-rim-lo: rgba(255, 255, 255, .25);
  --glass-edge: rgba(0, 0, 0, .07);          /* hairline so white glass reads on white */
  --glass-shadow: 0 4px 16px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .06);
  --glass-glyph: #1c1c1e;
  --sheet-bg: rgba(255, 255, 255, .72);
  --tabbar-bg: rgba(250, 250, 252, .86);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  /* The floating buttons sit just above the home indicator; the times get everything above them. */
  --fab-size: 52px; /* same as the settings button */
  --fab-b: max(calc(var(--safe-b) - 4px), 14px);
  --bar-h: calc(var(--fab-b) + var(--fab-size) + 12px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #000000;
  --text: #ffffff;
  --muted: #8e8e93;
  --line: rgba(255, 255, 255, .12);
  --fill: rgba(120, 120, 128, .28);
  --sep: rgba(255, 255, 255, .32);
  --danger: #ff453a;
  --shadow: 0 12px 40px rgba(0, 0, 0, .7);

  --glass-bg: rgba(118, 118, 128, .2);
  --glass-blur: blur(12px) saturate(180%) brightness(1.15);
  --glass-rim-hi: rgba(255, 255, 255, .55);
  --glass-rim-lo: rgba(255, 255, 255, .06);
  --glass-edge: rgba(255, 255, 255, .04);
  --glass-shadow: 0 4px 20px rgba(0, 0, 0, .5);
  --glass-glyph: #f2f2f7;
  --sheet-bg: rgba(30, 30, 32, .7);
  --tabbar-bg: rgba(44, 44, 48, .86);
  color-scheme: dark;
}

/* A vivid middle stop for every gradient. */
@supports (color: color-mix(in oklch, red, blue)) {
  :root { --m: color-mix(in oklch, var(--a), var(--b)); }
}
/* Pink and teal are near opposites, so a straight blend goes gray; route Sunset through violet. */
:root:not([data-accent]) { --m: #b04dff; }
[data-accent="ocean"]  { --a: #0a84ff; --b: #32e0ff; }
[data-accent="forest"] { --a: #00d65a; --b: #c6f000; }
[data-accent="grape"]  { --a: #a033ff; --b: #ff2d92; }
[data-accent="ember"]  { --a: #ff4d00; --b: #ffc800; }
[data-accent="mono"]   { --a: var(--text); --b: var(--muted); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}


body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, .about { -webkit-user-select: text; user-select: text; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
/* Solid accents (links, selected tab, focus): the gradient's start color in light mode (pink-red),
   its end color in dark mode (teal), whichever reads better on that background. */
:root { --accent: var(--a); }
[data-theme="dark"] { --accent: var(--b); }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); text-underline-offset: 3px; }

.muted { color: var(--muted); font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.small { font-size: .85rem; }

.gradient-text {
  background: linear-gradient(90deg, var(--a), var(--m), var(--b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ───────── Liquid Glass ─────────
   iOS 26 style: a mostly clear fill that blurs and boosts what's behind it, a thin rim
   that catches light on the top-left and bottom-right edges, a soft floating shadow,
   and a press that swells and glows rather than sinking. */

.icon-btn, .close, .btn, #toast, #hint, #toast button {
  position: relative;
  isolation: isolate;
  border: 0;
  color: var(--glass-glyph);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: 0 0 0 .5px var(--glass-edge), var(--glass-shadow);
  transition: transform .45s cubic-bezier(.25, 1.8, .45, 1), box-shadow .3s, background-color .3s;
}

/* The rim: a 1.5px gradient ring masked to the border. */
.icon-btn::before, .close::before, .btn::before, #toast::before, #hint::before, #toast button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  pointer-events: none;
  background: linear-gradient(135deg,
    var(--glass-rim-hi) 0%, var(--glass-rim-lo) 30%,
    transparent 50%,
    var(--glass-rim-lo) 70%, var(--glass-rim-hi) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

/* Inner light that blooms when pressed. */
.icon-btn::after, .close::after, .btn::after, #toast button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .5), transparent 70%);
  opacity: 0;
  transition: opacity .3s;
}

:is(.icon-btn, .close, .btn, #toast button):active { transform: scale(1.12); }
:is(.btn.wide, .actions .btn):active { transform: scale(1.04); }
:is(.icon-btn, .close, .btn, #toast button):active::after { opacity: 1; }
[data-theme="dark"] :is(.icon-btn, .close, .btn, #toast button):active::after { opacity: .5; }

/* Prominent glass: tinted with the accent, still lit at the rim. */
.icon-btn.fab, .btn.primary, #toast button {
  color: #fff;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--a) 90%, transparent),
    color-mix(in srgb, var(--m) 90%, transparent),
    color-mix(in srgb, var(--b) 90%, transparent));
  box-shadow: 0 6px 20px color-mix(in srgb, var(--a) 35%, transparent), 0 1px 3px rgba(0, 0, 0, .12);
  --glass-rim-hi: rgba(255, 255, 255, .85);
  --glass-rim-lo: rgba(255, 255, 255, .2);
}

/* ───────── calculator surface ───────── */

#calc {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-t) + 20px) calc(var(--safe-r) + 16px) var(--bar-h) calc(var(--safe-l) + 16px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: ew-resize;
  outline: none;
}
#calc.vertical { cursor: ns-resize; }
#calc.dragging { cursor: grabbing; }

#grid {
  display: inline-grid;
  grid-auto-flow: column;
  column-gap: .9em;
  row-gap: .28em;
  font-size: 40px; /* replaced by fit() */
  line-height: 1;
  opacity: 0;
  transition: opacity .2s;
}
#grid.ready { opacity: 1; }

.item {
  padding: .06em .12em;
  margin: -.06em -.12em;
  border-radius: .14em;
  transition: background-color .15s;
}
.item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { #calc:not(.dragging) .item:hover { background: var(--fill); } }

.label {
  display: flex;
  align-items: center;
  gap: .25em;
  font-size: max(.3em, 13px);
  font-weight: 750;
  font-stretch: 110%;
  letter-spacing: .01em;
  margin-bottom: .1em;
  white-space: nowrap;
}

.time {
  display: grid;
  justify-items: start;
  font-weight: 800;
  font-stretch: var(--stretch, 100%);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.025em;
  white-space: nowrap;
}
/* The base distance is the one you're steering: its time glows in the accent gradient. */
.item.base .time {
  background: linear-gradient(90deg, var(--a), var(--m), var(--b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 .12em color-mix(in srgb, var(--a) 35%, transparent));
}
/* The invisible slot text reserves the width; the real time sits on top of it. */
.time > * { grid-area: 1 / 1; }
.time .slot { visibility: hidden; }
.time .sep { color: var(--sep); font-weight: 700; margin: 0 -.01em; position: relative; top: -.04em; }

#pace {
  position: absolute;
  left: calc(var(--safe-l) + 20px);
  right: calc(var(--safe-r) + 84px); /* clear of the settings button */
  bottom: calc(var(--fab-b) + 21px);
  margin: 0;
  line-height: 1.2;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  pointer-events: none;
}
#pace b { color: var(--text); font-weight: 800; }

#hint {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-t) + 18px);
  transform: translateX(-50%);
  margin: 0;
  padding: .65em 1.1em;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  pointer-events: none;
  animation: hint 2.4s ease-in-out infinite;
}
@media (max-width: 480px) { #hint span { display: none; } }
#hint.vertical { animation-name: hint-v; }
@keyframes hint-v {
  0%, 100% { transform: translateX(-50%); }
  50% { transform: translate(-50%, 8px); }
}
/* Mouse/trackpad: no drag, so no resize cursors; times are clickable. */
@media (pointer: fine) {
  #calc, #calc.vertical, #calc.dragging { cursor: default; }
  #calc .item { cursor: pointer; }
  .touch-only { display: none; }
}
@keyframes hint {
  0%, 100% { transform: translateX(-50%); }
  50% { transform: translateX(calc(-50% + 10px)); }
}

/* ───────── floating buttons ───────── */

.fabs {
  position: absolute;
  right: calc(var(--safe-r) + 16px);
  bottom: var(--fab-b);
  display: flex;
  gap: 12px;
  align-items: center;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--text);
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.icon-btn.fab { width: var(--fab-size); height: var(--fab-size); color: #fff; }
.fab svg { width: 24px; height: 24px; stroke-width: 2.6; }

/* ───────── dialogs (glass sheets on phones) ───────── */

dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  color: var(--text);
  box-shadow: inset 0 1px .5px var(--glass-hi), inset 0 0 0 .5px var(--glass-rim), var(--shadow);
}
dialog:focus { outline: none; }
button:focus:not(:focus-visible) { outline: none; }
dialog.tall { width: min(520px, calc(100vw - 32px)); }
/* --sheet-fade dims the backdrop less as a sheet is swiped away (set from JS). */
@property --sheet-fade { syntax: '<number>'; inherits: true; initial-value: 1; }
dialog::backdrop { background: rgba(0, 0, 0, calc(.42 * var(--sheet-fade, 1))); }
dialog[open]::backdrop { animation: fade-in .3s ease-out; }
@keyframes fade-in { from { opacity: 0; } }
dialog[open] { animation: pop .3s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes pop { from { opacity: 0; transform: scale(.92); } }
dialog.closing { animation: pop-out .2s ease-in forwards; }
dialog.closing::backdrop, dialog.swiped::backdrop { animation: fade-out .22s ease-in forwards; }
@keyframes pop-out { to { opacity: 0; transform: scale(.94); } }
@keyframes fade-out { to { opacity: 0; } }

@media (max-width: 599px) {
  /* Phones: sheets rise from the bottom and swipe down to close (Settings / Distances)… */
  dialog, dialog.tall {
    width: calc(100% - 16px);
    max-width: 100%;
    max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 28px);
    margin: auto 8px calc(var(--safe-b) + 8px);
    border-radius: 34px;
  }
  dialog[open] { animation: sheet-up .42s cubic-bezier(.2, .9, .3, 1); }
  dialog.closing { animation: sheet-down .2s cubic-bezier(.4, 0, 1, 1) forwards; }
}

/* Sheets you type into (a distance's time, add/edit a distance) hang from the top and swipe up on
   phones and on every touch-only device (tablets too), so the on-screen keyboard opening underneath
   doesn't push them around. Their grabber is on the bottom edge. */
@media (max-width: 599px), (hover: none) and (pointer: coarse) {
  dialog.from-top { margin: calc(var(--safe-t) + 16px) auto auto; }
  dialog.from-top[open] { animation: sheet-from-top .42s cubic-bezier(.2, .9, .3, 1); }
  dialog.from-top.closing { animation: sheet-to-top .2s cubic-bezier(.4, 0, 1, 1) forwards; }
  dialog.from-top header { padding-top: 22px; }
  dialog.from-top header::before { display: none; }
  dialog.from-top .sheet-body { padding-bottom: 40px; } /* room for the grabber below the last button */
  dialog.from-top::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 13px;
    width: 38px;
    height: 5px;
    margin-left: -19px;
    border-radius: 99px;
    background: var(--muted);
    opacity: .45;
    pointer-events: none;
  }
}
@media (max-width: 599px) {
  dialog.from-top { margin: calc(var(--safe-t) + 10px) 8px auto; }
}
@keyframes sheet-up { from { transform: translateY(105%); } }
@keyframes sheet-down { to { transform: translateY(105%); } }
@keyframes sheet-from-top { from { transform: translateY(-105%); } }
@keyframes sheet-to-top { to { transform: translateY(-105%); } }

/* One glass panel: the header stays fixed and only the body below it scrolls,
   so the header needs no background of its own. */
dialog[open] { display: flex; flex-direction: column; overflow: hidden; }

dialog form {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
}

dialog header {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 12px;
  position: relative;
  touch-action: none; /* the header is the drag handle for swipe-to-dismiss */
  cursor: grab;
}
/* grabber */
dialog header::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 50%;
  width: 38px;
  height: 5px;
  margin-left: -19px;
  border-radius: 99px;
  background: var(--muted);
  opacity: .45;
}
dialog header .close { cursor: pointer; }
.sheet-top { flex: none; padding: 2px 22px 12px; }
.sheet-top[hidden] { display: none; }
.sheet-top .btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.list-note { margin: 4px 0 0; line-height: 1.4; }
/* No touch screen, no swipe: hide the grabber and the grab cursor. */
@media not (any-pointer: coarse) {
  dialog header { cursor: auto; }
  dialog header::before { display: none; }
}
/* Touch-first devices (phones, tablets): the sheet swipes closed and has a grabber, so drop the ×.
   Tapping outside the sheet still closes it too. */
@media (pointer: coarse) {
  dialog header .close { display: none; }
  dialog header { padding-top: 26px; }
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 4px 22px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* Once scrolled, content fades out under the header instead of hitting a hard edge. */
.sheet-body.scrolled {
  -webkit-mask-image: linear-gradient(transparent, #000 18px);
  mask-image: linear-gradient(transparent, #000 18px);
}

dialog h2 { margin: 4px 0 0; font-size: 1.45rem; font-weight: 800; font-stretch: 105%; }
dialog header p { margin: 2px 0 0; }

.close {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: -6px -8px 0 0;
  border-radius: 50%;
}
.close svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.field-label { display: block; font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field-label output { float: right; color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 700; color: var(--muted); flex: 1; }
.row { display: flex; gap: 12px; }

input:not([type]), input[inputmode], select {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1.5px solid transparent;
  border-radius: 16px;
  background: var(--fill);
  color: var(--text);
  font-size: 17px; /* ≥16px keeps iOS from zooming */
  font-weight: 600;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 22px, calc(100% - 17px) 22px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
input:focus, select:focus { border-color: var(--accent); }

.time-input { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 10px; margin-top: -6px; }
.time-input label { position: relative; }
.time-input input { height: 68px; font-size: 32px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; padding: 0 22px 0 8px; border-radius: 18px; }
.time-input span { position: absolute; right: 11px; bottom: 13px; color: var(--muted); font-weight: 700; pointer-events: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 99px;
  color: var(--text);
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
}
.btn.danger { color: var(--danger); }
.icon-btn svg, .close svg { position: relative; }
.btn.wide { width: 100%; min-height: 54px; font-size: 1.05rem; font-weight: 800; }
.btn[hidden] { display: none; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions[hidden] { display: none; }
/* Distance sheet: Edit / Hide / Delete share one row, with room above them after the time fields */
.actions.row3 { flex-wrap: nowrap; }
.base-btn { margin-top: 12px; } /* room between the time fields and the buttons */
.base-btn[hidden] + .actions.row3 { margin-top: 12px; }
.actions.row3 .btn { flex: 1 1 0; padding: 0 8px; }
.title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
.base-pill { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.title-row [hidden] { display: none; }
.actions .btn { flex: 1 1 auto; }
.actions.center { justify-content: center; }
.actions.center .btn { flex: 0 1 auto; }

.error { margin: 0; color: var(--danger); font-weight: 600; }
.error:empty { display: none; }

/* distances list */
.list { list-style: none; margin: 0 -8px; padding: 0; }
.list li { display: flex; align-items: center; gap: 4px; padding: 0 2px 0 8px; }
.list li + li { border-top: 1px solid var(--line); }
.list .name { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 54px; font-weight: 650; cursor: pointer; }
.list .name > span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .meta { color: var(--muted); font-weight: 500; font-size: .85rem; font-variant-numeric: tabular-nums; }
.list .base-tag { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.list .base-tag { background: linear-gradient(90deg, var(--a), var(--m), var(--b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.list .more { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: var(--muted); transition: background-color .2s; }
.list .more:active { background: var(--fill); }
.list .more svg { width: 20px; height: 20px; fill: currentColor; }

/* iOS 26 switch: a wide track with a pill knob that turns to glass while you hold it */
.switch { position: relative; flex: none; display: inline-block; width: 62px; height: 28px; }
.switch input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 99px; background: var(--fill); transition: background-color .25s; }
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 38px;
  height: 24px;
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2), 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform .45s cubic-bezier(.25, 1.6, .45, 1), scale .2s, background-color .2s;
}
.switch input:checked + .track { background: linear-gradient(135deg, var(--a), var(--m), var(--b)); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:active + .track::after { scale: 1.18 1.12; background: rgba(255, 255, 255, .7); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* segmented control: a glass track with a raised glass pill */
.seg { display: flex; padding: 4px; gap: 2px; border-radius: 99px; background: var(--fill); }
.seg button {
  flex: 1;
  min-height: 38px;
  padding: 0 6px;
  border: 0;
  border-radius: 99px;
  background: none;
  font-size: .88rem;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color .2s, color .2s, transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.seg button:active { transform: scale(1.06); }
.seg button.on {
  color: var(--text);
  background: rgba(255, 255, 255, .92);
  box-shadow: inset 0 1px .5px #fff, 0 2px 8px rgba(0, 0, 0, .14);
}
[data-theme="dark"] .seg button.on {
  background: rgba(118, 118, 128, .55);
  box-shadow: inset 0 1px .5px rgba(255, 255, 255, .35), 0 2px 8px rgba(0, 0, 0, .4);
}

.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatches button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--sa), var(--sm), var(--sb));
  box-shadow: inset 0 1px .5px rgba(255, 255, 255, .6), 0 3px 10px rgba(0, 0, 0, .2);
  transition: transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.swatches button:active { transform: scale(1.12); }
.swatches button.on { box-shadow: inset 0 1px .5px rgba(255, 255, 255, .6), 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

/* App icon picker (like Posy's): three tiles, the chosen one ringed */
.icon-picker { display: flex; gap: 6px; padding: 6px; border-radius: 22px; background: var(--fill); }
.icon-picker button { flex: 1; display: grid; place-items: center; padding: 10px 0; border: 0; border-radius: 16px; background: none; transition: background-color .2s, transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.icon-picker button:active { transform: scale(1.06); }
.icon-picker img { display: block; border-radius: 13px; box-shadow: 0 0 0 1px var(--line); }
.icon-picker button.on { background: var(--fill); }
.icon-picker button.on img { box-shadow: 0 0 0 3px var(--surface-ring, var(--bg)), 0 0 0 5.5px var(--accent); }
.icon-note { margin: 8px 2px 0; line-height: 1.4; }

/* Slider: a tall track filled with the accent up to a white pill thumb (iOS 26 style). */
input[type="range"] {
  --track: 12px;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: var(--track);
  border-radius: 99px;
  background: linear-gradient(90deg, var(--a), var(--m)) 0 / var(--pct, 50%) 100% no-repeat, var(--fill);
}
input[type="range"]::-moz-range-track { height: var(--track); border-radius: 99px; background: var(--fill); }
input[type="range"]::-moz-range-progress { height: var(--track); border-radius: 99px; background: linear-gradient(90deg, var(--a), var(--m)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 40px;
  height: 28px;
  margin-top: calc((var(--track) - 28px) / 2);
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(0, 0, 0, .06);
  transition: scale .2s, background-color .2s;
}
input[type="range"]::-moz-range-thumb { width: 40px; height: 28px; border: 0; border-radius: 99px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
input[type="range"]:active::-webkit-slider-thumb { scale: 1.15 1.1; background: rgba(255, 255, 255, .75); }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 99px; }
.range { color: var(--text); }

.mouse-only { display: none; }
@media (hover: hover) and (pointer: fine) { .mouse-only { display: block; } }

.about { text-align: center; line-height: 1.5; }
.about img { align-self: center; border-radius: 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }
.about h3 { margin: 8px 0 0; font-size: 2rem; font-weight: 900; font-stretch: 112%; }
.about p { margin: 10px 0; }
.about details { text-align: left; margin-top: 14px; font-size: .9rem; }
.about summary { cursor: pointer; font-weight: 700; text-align: center; color: var(--muted); }
.about details p { margin: 8px 0; }

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 8px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 18px;
  border-radius: 99px;
  color: var(--text);
  font-weight: 650;
  white-space: nowrap;
  z-index: 10;
}
#toast[hidden] { display: none; }
#toast:not(:has(button)) { padding: 13px 20px; }
#toast button { border-radius: 99px; padding: 9px 16px; font-weight: 800; }

/* Settings / About tabs */
.tab-panel { display: flex; flex-direction: column; gap: 14px; }
.tab-panel[hidden] { display: none; }
.sheet-body.has-tabbar { padding-bottom: 100px; } /* room to scroll the last row clear of the tab bar */

/* iOS 26 floating tab bar: a glass capsule over the content, the current tab sits in a raised lens. */
.tabbar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 4;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 28px)); /* use the sheet's width so labels like Changelog aren't cramped */
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 99px;
  /* denser than button glass: it floats over scrolling rows and its labels must stay readable */
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 0 0 .5px var(--glass-edge), var(--glass-shadow);
}
.tabbar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  pointer-events: none;
  background: linear-gradient(135deg, var(--glass-rim-hi) 0%, var(--glass-rim-lo) 30%, transparent 50%, var(--glass-rim-lo) 70%, var(--glass-rim-hi) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1 1 0;
  min-width: 0;
  height: 56px;
  padding: 0 4px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--glass-glyph);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  transition: background-color .25s, color .25s, transform .45s cubic-bezier(.25, 1.8, .45, 1);
}
.tabbar button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tabbar button:active { transform: scale(1.08); }
.tabbar button[aria-selected="true"] { color: var(--accent); background: var(--fill); }
[data-accent="mono"] .tabbar button[aria-selected="true"] { color: var(--text); }

/* The tabbed Settings sheet keeps one height, so switching tabs doesn't make it jump. */
#dlg-settings[open] { height: min(720px, calc(100dvh - 32px)); }
#dlg-settings form, #dlg-settings .sheet-body { flex: 1 1 auto; }
@media (max-width: 599px) {
  #dlg-settings[open] { height: calc(100dvh - var(--safe-t) - var(--safe-b) - 28px); }
}

/* changelog tab */
.version-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.version-row .muted { font-size: .95rem; }
.refresh-note { margin: -4px 0 6px; }
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; flex-direction: column; gap: 3px; padding: 14px 0; border-top: 1px solid var(--line); line-height: 1.45; }
.log b { font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }

.btn.wide-ish { width: 100%; }

/* install tip */
#install {
  touch-action: none;
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: calc(var(--bar-h) + 4px);
  transform: translateX(-50%);
  width: min(440px, calc(100% - 24px - var(--safe-l) - var(--safe-r)));
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 10px 12px;
  padding: 14px 12px 14px 14px;
  border-radius: 28px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  box-shadow: 0 0 0 .5px var(--glass-edge), var(--shadow);
  animation: rise .5s cubic-bezier(.25, 1.3, .45, 1);
}
#install[hidden] { display: none; }
#install img { border-radius: 12px; }
#install b { font-size: .98rem; }
#install p { margin: 3px 0 0; font-size: .87rem; line-height: 1.4; color: var(--muted); }
#install p b { font-size: inherit; color: var(--text); }
#install .close { grid-column: 3; grid-row: 1; width: 32px; height: 32px; margin: 0; } /* top right, even when the Install button adds a row */
#install .close svg { width: 13px; height: 13px; }
#install [data-f="go"] { grid-column: 2 / 4; justify-self: end; min-height: 40px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 30px); } }
.inline { color: var(--text); width: 1.15em; height: 1.15em; vertical-align: -.22em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Without backdrop-filter, glass would be see-through over the numbers; make it solid. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass-bg: #f2f2f7; --sheet-bg: #fff; }
  [data-theme="dark"] { --glass-bg: #2c2c2e; --sheet-bg: #1c1c1e; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass-bg: #f2f2f7; --sheet-bg: #fff; }
  [data-theme="dark"] { --glass-bg: #2c2c2e; --sheet-bg: #1c1c1e; }
}
