/* ---------------------------------------------------------------------------
   Aleks' Gym App – styles
   Dark "activity rings" look. Every colour and size lives in a variable
   (custom property) at the top, so the look can change in one place.
   --------------------------------------------------------------------------- */

/* The bundled font. One variable-weight file covers every weight from 100 to 1000.
   font-display: swap shows text in a fallback font until the file has loaded. */
@font-face {
  font-family: "DM Sans";
  src: url("../fonts/dm-sans-latin.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}

/* Custom properties: variables for CSS. Defined once on :root (the <html> element),
   used everywhere as var(--name). */
:root {
  --bg: #0f1420;
  --surface: #182033;
  --surface2: #232d46;
  --line: #2c3753;
  --fg: #e8ecf5;
  --muted: #8e98b2;
  --accent: #7b88ff;
  --on-accent: #0f1420;
  --c-steps: #4fd1a5;
  --c-rowing: #5aa9ff;
  --c-strength: #ffa25e;
  --track: #232d46;

  --radius: 18px;
  --radius-sm: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --nav-height: 64px;

  /* Side gutter that also clears a system bar at the screen's edge. */
  --gutter-left: max(16px, env(safe-area-inset-left, 0px));
  --gutter-right: max(16px, env(safe-area-inset-right, 0px));

  /* Dark only: makes built-in controls (scrollbars, inputs) dark as well. */
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win, even over display: flex below. */
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  /* Stops the phone enlarging text by itself when turned sideways. */
  -webkit-text-size-adjust: 100%;
}

h1 { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.1; }
p { margin: 0; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* Visible focus ring for keyboard users; invisible for taps. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Icons: thin-line SVGs that take their colour from the surrounding text. */
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --- Screens ------------------------------------------------------------- */

/* One phone-width column, centred on a PC. Bottom padding keeps content clear of
   the fixed bottom bar and of Android's gesture bar. */
main {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh; /* dvh = the visible screen height, even when browser bars slide */
  display: flex;
  flex-direction: column;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px));
  padding-left: var(--gutter-left);
  padding-right: var(--gutter-right);
}

.screen { flex: 1; display: flex; flex-direction: column; gap: 16px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sub { color: var(--muted); font-size: 14px; }

.iconbtn {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface);
}
.iconbtn svg { width: 24px; height: 24px; }

.back { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; min-height: 44px; color: var(--muted); font-weight: 600; }
.back svg { width: 20px; height: 20px; stroke-width: 2.5; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.note { color: var(--muted); font-size: 14px; }
.card-title { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* Buttons. These are often links (<a>) styled to look like buttons, e.g. Sign in. */
.btn {
  min-height: 52px; padding: 0 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-weight: 800; font-size: 16px;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { border: 1px solid var(--line); }

/* Today's top right: the gear and the account icon. Neither does anything harmful
   when tapped by mistake - Sign out lives inside the account menu. */
.header-actions { display: flex; align-items: center; gap: 10px; }
.avatar-btn { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; }
.avatar {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  font-weight: 800; font-size: 17px;
}
.avatar-lg { width: 48px; height: 48px; font-size: 20px; }
.avatar { overflow: hidden; }
/* object-fit: cover fills the circle without stretching the picture. */
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picture-actions { display: flex; gap: 8px; }
.picture-actions .btn { flex: 1; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 12px; }

/* The account menu. [popover] puts it in the browser's "top layer", above
   everything else; here it is pinned under the account icon in the top right. */
.account-menu {
  position: fixed;
  inset: auto;
  top: calc(max(16px, env(safe-area-inset-top, 0px)) + 56px);
  right: var(--gutter-right);
  margin: 0;
  width: min(330px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.5);
  flex-direction: column;
  gap: 14px;
}
.account-menu:popover-open { display: flex; } /* only laid out while open */
.account { display: flex; align-items: center; gap: 12px; }
.account > div { min-width: 0; }
.account p { font-size: 15px; overflow-wrap: anywhere; } /* long email addresses wrap instead of overflowing */

/* --- Pages outside the app: landing page and access page ------------------ */

/* Sign in: a label and three square icon buttons in a row (Microsoft, Google, email). */
.signin { display: flex; flex-direction: column; align-items: stretch; gap: 10px; text-align: center; }
.signin .card-title { justify-content: center; }
.signin-row { display: flex; gap: 12px; justify-content: center; }
.signin-btn {
  flex: 1; max-width: 120px; min-height: 68px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
}
.signin-btn:active { background: var(--surface2); }
.signin-btn svg { width: 30px; height: 30px; }
.signin-btn[hidden] { display: none; }
/* A button that looks like a link (Register an account, Cancel). */
.link-btn { min-height: 44px; color: var(--accent); font-weight: 700; font-size: 15px; }
/* Holds the shared icon drawings; takes no space on the page. */
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* The Register sheet: a popover pinned to the bottom like the + menu. */
.register-sheet {
  inset: auto 0 0 0;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  color: var(--fg);
  flex-direction: column;
  gap: 14px;
  padding-top: 20px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: var(--gutter-left);
  padding-right: var(--gutter-right);
}
.register-sheet:popover-open { display: flex; }
.register-sheet::backdrop { background: rgb(0 0 0 / 0.55); }
.register-sheet h2 { margin: 0; font-size: 20px; }

/* Access page */
.access-actions { display: flex; flex-direction: column; gap: 10px; }
.pill.bad { color: #ff8f8f; }
.notice .pill { align-self: flex-start; }
.notice { gap: 8px; }
.textarea {
  width: 100%; resize: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--fg);
  font: inherit; font-size: 15px; padding: 10px 12px;
}
details summary { cursor: pointer; }
details code { overflow-wrap: anywhere; font-size: 12px; }

/* No bottom bar here, so no extra space for it; the button sits at thumb height. */
main.standalone {
  justify-content: space-between;
  gap: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; text-align: center; }
.welcome .notice { text-align: left; width: 100%; }
.warn { color: #ffb35c; }
.fix-steps { margin: 0; padding-left: 20px; color: var(--muted); text-align: left; align-self: stretch; display: flex; flex-direction: column; gap: 4px; }

/* The logo: the same rings as Today, plus a dumbbell. */
.logo { width: min(240px, 66vw); height: auto; }
.logo-small { width: 64px; }
.logo circle { stroke-width: 8; }
.logo .track { stroke: var(--track); }
.logo .arc { transform: rotate(-90deg); transform-origin: 54px 54px; }
.logo .dumbbell rect { fill: var(--fg); stroke: none; }

/* Each ring's circumference (2 × π × radius), used by the animation below. */
.logo .arc-steps { --len: 251.33; }
.logo .arc-rowing { --len: 182.21; }
.logo .arc-strength { --len: 113.1; }

/* The rings draw themselves closed once when the landing page opens.
   A dash as long as the whole circle is pushed out of view (dashoffset = length),
   then slides in to 0. The inner rings start slightly later. The reduced-motion
   rule at the end of this file turns it off, leaving the rings closed. */
@keyframes ring-fill {
  from { stroke-dashoffset: var(--len); }
  to { stroke-dashoffset: 0; }
}
.logo-animated .arc {
  stroke-dasharray: var(--len);
  animation: ring-fill 1.8s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}
.logo-animated .arc-rowing { animation-delay: 0.2s; }
.logo-animated .arc-strength { animation-delay: 0.4s; }

/* --- Today: the rings fill the screen ------------------------------------ */

.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; }

/* The activity palette. An activity stores a colour number 0-7; the class
   .color-N sets --c, which rings, dots, bars and swatches use. Classes instead of
   style="…" attributes, because the security policy blocks inline styles. */
.color-0 { --c: #4fd1a5; } /* mint   */
.color-1 { --c: #5aa9ff; } /* blue   */
.color-2 { --c: #ffa25e; } /* orange */
.color-3 { --c: #ff7eb6; } /* pink   */
.color-4 { --c: #ffd25e; } /* yellow */
.color-5 { --c: #b18cff; } /* violet */
.color-6 { --c: #3dd6d0; } /* teal   */
.color-7 { --c: #ff6b6b; } /* red    */

/* Rings: drawn by rings.js, one per activity, thinner when there are more. */
.rings { width: min(270px, 72vw); height: auto; }
.rings .ring-track { stroke: var(--track); }
.rings .ring-arc { stroke: var(--c); }

/* The logo's rings (landing page) keep the three original colours. */
.arc-steps { stroke: var(--c-steps); }
.arc-rowing { stroke: var(--c-rowing); }
.arc-strength { stroke: var(--c-strength); }

/* The legend under the rings wraps into rows when there are 4-5 activities. */
.legend { margin: 0; width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px 8px; text-align: center; }
.legend dt { color: var(--muted); font-size: 14px; display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere; }
.legend dd { margin: 0; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; flex: none; background: var(--c, var(--muted)); }

.hint { color: var(--muted); font-size: 14px; text-align: center; }

/* --- Settings -------------------------------------------------------------- */

.card-title { display: flex; align-items: center; justify-content: space-between; }
.card-count { letter-spacing: 0; text-transform: none; font-weight: 600; }
.dot-accent { --c: var(--accent); }
.note.center { text-align: center; }

/* Activities list */
.activity-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.activity-row:first-child { border-top: 0; }
.activity-bar { width: 12px; height: 42px; border-radius: 6px; background: var(--c); }
.activity-main { text-align: left; min-width: 0; }
.activity-main b { display: block; font-size: 15px; overflow-wrap: anywhere; }
.activity-main span { color: var(--muted); font-size: 13px; }
.activity-tools { display: flex; gap: 4px; }
.mini { width: 36px; height: 36px; border-radius: 10px; background: var(--surface2); color: var(--muted); font-weight: 800; }
.mini:disabled { opacity: 0.3; cursor: default; }
.add-activity { width: 100%; min-height: 48px; margin-top: 6px; border: 1px dashed var(--line); border-radius: var(--radius-sm); font-weight: 800; }
.add-activity:disabled { color: var(--muted); cursor: default; }

/* The activity editor (a <dialog> shaped like the + menu) */
.editor { max-height: 92dvh; overflow-y: auto; gap: 14px; }
.editor h2 { margin: 0; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.text-input { min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface2); color: var(--fg); font: inherit; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 3px solid transparent; }
.swatch[aria-pressed="true"] { border-color: var(--fg); }
.proofs { display: flex; flex-direction: column; gap: 6px; }
.proofs button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface2); border: 2px solid transparent; }
.proofs button[aria-pressed="true"] { border-color: var(--accent); }
.proofs small, .preset small { color: var(--muted); font-size: 12.5px; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface2); }
.preset b { display: flex; align-items: center; }
.editor-buttons { display: flex; gap: 8px; }
.editor-buttons .btn { flex: 1; padding: 0 8px; }
.btn.danger { border: 1px solid rgb(255 107 107 / 0.5); color: #ff8f8f; }
.btn:disabled { opacity: 0.4; cursor: default; }

.settings-banner, .settings-cards { display: flex; flex-direction: column; gap: 16px; }
.settings-banner:empty { display: none; }

/* Notes at the top: purple for information, green after saving. */
.banner { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.banner b { display: block; }
.banner.info { background: rgb(123 136 255 / 0.14); border: 1px solid rgb(123 136 255 / 0.35); }
.banner.ok { background: rgb(79 209 165 / 0.12); border: 1px solid rgb(79 209 165 / 0.35); }
.banner-action { margin-left: auto; color: var(--accent); font-weight: 800; min-height: 32px; }

/* One row per target: label on the left, − value + on the right. */
.setting-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-title + .setting-row { border-top: 0; }
.setting-label { flex: 1; min-width: 0; font-size: 15px; }
.setting-label small { display: block; color: var(--muted); font-size: 13px; }
.setting-label small.pending { color: var(--accent); }

.stepper { display: grid; grid-template-columns: 40px auto 40px; align-items: center; flex: none; min-height: 44px; border-radius: var(--radius-sm); background: var(--surface2); }
.stepper.changed { box-shadow: inset 0 0 0 2px var(--accent); } /* unsaved */
.stepper button { height: 44px; font-size: 20px; font-weight: 800; color: var(--muted); }
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper-value { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
/* The number is a text field you can tap and type into; it looks like plain text. */
.stepper-number {
  width: 6ch; /* "40 000" */
  padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--fg);
  font: inherit; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
}
.stepper-number:focus { background: var(--bg); outline: 2px solid var(--accent); }
.stepper-value small { color: var(--muted); font-size: 11px; }

/* Workouts (card in Settings, and the workout screen). Rows reuse the activity
   list's look, without the colour bar. */
.activity-row.no-bar { grid-template-columns: minmax(0, 1fr) auto; }
/* One line, cut off with "…" if too long (the workout's exercise names). */
.activity-main .one-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#workouts-used-by .dot { display: inline-block; margin-left: 2px; margin-right: 4px; }
#workouts-notice:empty, #workout-remove:empty { display: none; }
/* Quick picks for an exercise's guide ("8–12 reps"). */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface2); border: 2px solid transparent; font-size: 14px; font-weight: 600; }
.chip[aria-pressed="true"] { border-color: var(--accent); }
.chip:disabled { cursor: default; }
.chip:disabled:not([aria-pressed="true"]) { opacity: 0.4; }
.stepper-number#exercise-sets { width: 3ch; }
#screen-workout { padding-bottom: 110px; }

/* --- Steps ------------------------------------------------------------------ */

/* Last week | This week: a two-part switch. */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--radius-sm); background: var(--surface); }
.tabs button { min-height: 48px; border-radius: 9px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.tabs button small { font-size: 11.5px; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--surface2); color: var(--fg); }
.closing { color: #ffb35c; }

.steps-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.steps-stats b { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.steps-stats span { color: var(--muted); font-size: 13px; }
/* <progress> is the browser's own bar; these pseudo-elements style its parts in
   Chrome (::-webkit-…) and Firefox (::-moz-…). */
.steps-bar { width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden; appearance: none; background: var(--surface2); }
.steps-bar::-webkit-progress-bar { background: var(--surface2); }
.steps-bar::-webkit-progress-value { background: var(--c); border-radius: 4px; }
.steps-bar::-moz-progress-bar { background: var(--c); border-radius: 4px; }

/* One row per day: the day on the left, the number field on the right. */
.day-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 26px; align-items: center; gap: 10px; min-height: 58px; border-top: 1px solid var(--line); }
.card-title + .day-row { border-top: 0; }
.day-name b { display: block; font-size: 15px; }
.day-name span { color: var(--muted); font-size: 13px; }
.day-row.today .day-name b::after { content: "Today"; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: rgb(123 136 255 / 0.25); font-size: 11px; font-weight: 800; vertical-align: 2px; }
.day-row.future { opacity: 0.4; }
.steps-input { width: 9ch; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface2); color: var(--fg); font: inherit; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.steps-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.steps-input:disabled { background: none; border-color: transparent; color: var(--fg); }
.steps-input::placeholder { color: var(--muted); font-weight: 400; }
.day-mark { display: grid; place-items: center; color: var(--c); }
.day-mark svg { width: 22px; height: 22px; stroke-width: 3; }

/* Today: the week's step total under the rings, with a thin bar across the full
   width - quiet on purpose, so the rings stay the main thing. */
.today-steps { width: 100%; display: flex; flex-direction: column; gap: 8px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.today-steps .steps-bar { height: 6px; border-radius: 3px; }

/* A short confirmation that floats above the bottom bar for two seconds. */
.toast {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0px));
  /* left: 50% would leave it only half the screen to fill, so it wrapped early:
     size it to its content instead, up to the screen width. */
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 18px; border-radius: 999px;
  background: var(--surface2); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; text-align: center;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.45);
}

/* --- Gym session ------------------------------------------------------------ */

.checkin-body { display: flex; flex-direction: column; gap: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; flex: none; }
.pill svg { width: 15px; height: 15px; }
.week-line { color: var(--muted); font-size: 14px; }
.week-line b { color: var(--fg); }
.center { text-align: center; }

/* Where: two big buttons. */
.place-option { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 84px; padding: 0 16px; border-radius: var(--radius); background: var(--surface); text-align: left; }
.place-option b { display: block; font-size: 18px; }
.place-option small { color: var(--muted); font-size: 14px; }
.place-option .ic { width: 48px; height: 48px; }
.place-option .ic svg { width: 26px; height: 26px; }

/* The check-in result (shown only while checking, or when it didn't pass). */
.checkin-result { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: center; }
.checkin-photo { width: 96px; height: 96px; border-radius: 14px; object-fit: cover; background: var(--surface2); display: block; }
.checkin-status { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.checkin-status b { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.checkin-status span { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.checkin-choices { display: flex; flex-direction: column; gap: 8px; }
.ok-text { color: #4fd1a5; }
/* A passed check-in: the pill turns green with a tick. */
.pill.checked { color: #4fd1a5; }

/* The session: one row per exercise, one big box per set. */
.sets-progress { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.sets-progress b { color: var(--fg); font-variant-numeric: tabular-nums; }
.exercise { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.steps-bar + .exercise { border-top: 0; }
.exercise-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.exercise-top b { font-size: 16px; overflow-wrap: anywhere; }
.exercise-top small { color: var(--muted); font-size: 13px; flex: none; }
.exercise.complete .exercise-top b::after { content: " ✓"; color: var(--c); }
.set-boxes { display: flex; flex-wrap: wrap; gap: 8px; }
.set-box { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; border: 2px solid var(--line); background: var(--surface2); color: var(--muted); font-weight: 800; font-size: 16px; }
.set-box[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: var(--on-accent); }
.set-box svg { width: 24px; height: 24px; stroke-width: 3; }

/* Finish stays within thumb reach: sticks just above the bottom bar. */
.finishbar {
  position: sticky; z-index: 5;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding: 12px 0 8px;
  background: linear-gradient(to top, var(--bg) 80%, transparent);
  display: flex; flex-direction: column; gap: 6px; text-align: center;
}
.text-button { min-height: 40px; color: var(--muted); font-size: 14px; text-decoration: underline; }

/* The rest timer: a panel in the Finish area, within thumb reach. */
.rest-panel { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border: 2px solid var(--c); border-radius: var(--radius); background: var(--surface); text-align: left; }
.rest-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rest-label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.rest-time { font-size: 40px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.rest-awake { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.rest-awake::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.rest-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rest-buttons button { min-height: 48px; border-radius: var(--radius-sm); background: var(--surface2); font-weight: 800; }
/* Time's up: the panel turns the activity's colour and pulses three times. */
.rest-panel.over { background: var(--c); color: var(--on-accent); animation: rest-pulse 0.5s ease-in-out 3; }
.rest-panel.over .rest-label { color: var(--on-accent); }
@keyframes rest-pulse { 50% { transform: scale(1.03); } }
#rest-slot:empty { display: none; }
.rest-awake.refused { color: #ffb35c; }
.rest-awake.refused::before { background: #ffb35c; }
.rest-problem { font-size: 13px; font-weight: 700; }

/* Summary */
.big-check { width: 84px; height: 84px; align-self: center; display: grid; place-items: center; border-radius: 50%; background: var(--c); color: var(--on-accent); }
.big-check svg { width: 44px; height: 44px; stroke-width: 3; }
.summary-title { margin: 0; font-size: 26px; font-weight: 800; text-align: center; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.summary-grid b { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary-grid span { color: var(--muted); font-size: 12.5px; }

/* An on/off switch: a <button role="switch">; aria-checked says which, and screen
   readers announce it as on or off. */
.switch { position: relative; width: 52px; height: 32px; flex: none; border-radius: 999px; border: 1px solid var(--line); background: var(--surface2); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch[aria-checked="true"] { border-color: var(--accent); background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }
.switch:disabled { opacity: 0.4; cursor: default; }
#rest-seconds { width: 5ch; }
#rest-settings .setting-row:first-child { border-top: 0; }

/* --- Display and tick activities ----------------------------------------------- */

/* The display photo keeps its shape, so the digits stay readable. */
.display-photo { width: 100%; max-height: 50vh; object-fit: contain; border-radius: var(--radius-sm); background: #000; display: block; }
.retake { align-self: flex-start; }
.time-input { width: 7ch; min-height: 48px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface2); color: var(--fg); font: inherit; font-size: 20px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }
.time-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.level-value { font-size: 18px; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: center; }
#display-body .card > .setting-row:first-child { border-top: 0; }
.verdict { font-size: 14px; color: var(--muted); }
.verdict.ok { color: #4fd1a5; }
.verdict.short { color: #ffb35c; }
/* Tick: one big button. */
.tick-button { width: 100%; min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 2px dashed var(--c); border-radius: var(--radius); background: var(--surface); }
.tick-button b { font-size: 20px; }
.tick-button small { color: var(--muted); font-size: 14px; }
.tick-button .big-check { width: 64px; height: 64px; }
.tick-button .big-check svg { width: 34px; height: 34px; }
/* A toast with an action (Undo). */
.toast:has(.toast-action) { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 18px; }
.toast-action { min-height: 36px; padding: 0 12px; color: var(--accent); font-weight: 800; }

/* --- Progress --------------------------------------------------------------- */

.streak { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.streak b { display: block; font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.streak span { color: var(--muted); font-size: 13px; }

/* This week: one bar per ring, then the day strip. */
.ring-bars { display: flex; flex-direction: column; gap: 10px; }
.ring-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.ring-bar b { display: flex; align-items: center; font-size: 14px; overflow-wrap: anywhere; }
.ring-bar span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ring-bar .steps-bar { grid-column: 1 / -1; height: 6px; }
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; text-align: center; }
.strip-day { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; border-radius: 10px; }
.strip-day small { color: var(--muted); font-size: 11px; font-weight: 700; }
.strip-day.today { background: var(--surface2); }
.strip-day.future { opacity: 0.35; }
.strip-marks { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 30px; }
.strip-marks .dot { width: 8px; height: 8px; margin: 0; }

/* Weeks: a badge, the week and its result; tap to list what was logged. */
.week-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 12px 0; border-top: 1px solid var(--line); text-align: left; }
#progress-weeks > .week-row:first-child { border-top: 0; }
.week-row b { display: block; font-size: 15px; }
.week-row small { color: var(--muted); font-size: 13px; }
.chev { width: 18px; height: 18px; color: var(--muted); transition: transform 0.15s; }
.week-row[aria-expanded="true"] .chev { transform: rotate(90deg); }
.badge { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-size: 15px; font-weight: 800; }
.badge.green { background: #4fd1a5; color: var(--on-accent); }
.badge.missed { background: rgb(255 179 92 / 0.15); color: #ffb35c; border: 1px solid rgb(255 179 92 / 0.5); }
.badge.open { background: rgb(123 136 255 / 0.15); color: var(--accent); border: 1px solid rgb(123 136 255 / 0.5); }
.badge.practice { background: var(--surface2); color: var(--muted); }
.week-items { display: flex; flex-direction: column; gap: 6px; padding-bottom: 12px; }
.week-item { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface2); text-align: left; }
.item-bar { width: 4px; height: 30px; border-radius: 2px; background: var(--c); }
.week-item b { display: block; font-size: 14px; }
.week-item small { color: var(--muted); font-size: 12.5px; }

/* The session sheet */
.sheet-photo { width: 100%; max-height: 40vh; object-fit: cover; border-radius: var(--radius-sm); background: #000; }
.sheet-photo.display { object-fit: contain; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Gym location */
.gym-card { display: flex; flex-direction: column; }
.gym-status { display: flex; align-items: center; gap: 10px; font-size: 14px; }
/* Places: one row per check-in activity, with its colour bar. */
.place-row { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.place-row:first-child { border-top: 0; }
.place-row .activity-bar { height: auto; min-height: 42px; }
.place-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.place-info b { font-size: 15px; overflow-wrap: anywhere; }
.place-info .btn { align-self: flex-start; }
.spinner { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2px solid var(--muted); border-top-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* The Save bar floats just above the bottom bar while there are unsaved changes. */
.savebar {
  position: fixed; z-index: 9;
  left: 0; right: 0;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-top: 12px; padding-bottom: 10px;
  padding-left: max(var(--gutter-left), calc((100% - 480px) / 2));
  padding-right: max(var(--gutter-right), calc((100% - 480px) / 2));
  background: linear-gradient(to top, var(--bg) 75%, transparent);
  display: flex; flex-direction: column; gap: 4px; text-align: center;
}
/* Room at the end of Settings, so the Save bar never covers the last card. */
#screen-settings { padding-bottom: 110px; }

/* --- Bottom bar ---------------------------------------------------------- */

/* position: fixed pins it to the bottom of the screen while the page scrolls. */
.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* The bar's background spans the whole width, but its buttons stay inside the
     same 480 px column as the content (matters on a PC). */
  padding-left: max(var(--gutter-left), calc((100% - 480px) / 2));
  padding-right: max(var(--gutter-right), calc((100% - 480px) / 2));
}

.tab {
  min-height: var(--nav-height);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--fg); }

.plus {
  width: 64px; height: 64px;
  margin-top: -28px; /* sticks up out of the bar, right under the thumb */
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.45);
}
.plus svg { width: 30px; height: 30px; stroke-width: 3; }

/* --- The + menu (a <dialog>) -------------------------------------------- */

/* Pinned to the bottom like a sheet. ::backdrop is the dimmed layer behind it. */
.sheet {
  margin: auto auto 0;
  width: 100%;
  max-width: 480px;
  border: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  color: var(--fg);
  display: none;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  padding-left: var(--gutter-left);
  padding-right: var(--gutter-right);
}
.sheet[open] { display: flex; }
.sheet::backdrop { background: rgb(0 0 0 / 0.55); }

.opt { display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 0 14px; border-radius: var(--radius-sm); background: var(--surface2); }
.opt b { display: block; font-size: 18px; }
.opt span span { color: var(--muted); font-size: 14px; }
.ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--bg); color: var(--c, var(--fg)); }
.ic svg { width: 22px; height: 22px; }

/* Respect the phone's "reduce motion" setting for any animation added later. */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
