/* Shell: the frame, the bottom bar's extras, the popup sheet's skin, Dnes / Progres / Ja (v3 pieces, flat in v4).
   Only --f-* tokens; no colour is written here. (app.css's :root maps its old names onto the Forma tokens.)
   The bar itself (.f-nav) and its tokens are in forma.css; progress.css and me.css hold the v4 Progres and Ja. */

/* ====================================================================== frame */
:root[data-screen="start"] :is(.f-nav, .f-nav-fade) { display: none !important; }
.f-app .app { padding-bottom: var(--f-dock-space); }
/* Screens built on .f-screen bring their own header block (it bleeds to the edges and holds the safe area). */
.f-app .app:has(> .view:not([hidden]) .f-screen) { padding-top: 0; }
.app .f-screen { padding: 0; }
.sh-screen > .f-head { margin-bottom: var(--f-s2); }
.sh-screen > .f-head.f-head--tab { margin-bottom: 60px; }
.sh-screen > .f-head--quiet { padding-top: calc(var(--f-s5) + env(safe-area-inset-top, 0px)); }
.sh-ellip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* the popup sheet's skin (the engine and the frame are in app.css): flat page grey, cards on it are #212121 */
.sheet { --surface: var(--f-surface-1); --surface-2: var(--f-surface-2); --fig-bg: var(--f-surface-1); }
.sheet .grabber { background: var(--f-surface-3); opacity: 1; width: 36px; }
.sheet-top h2 { font-family: var(--f-font-display); font-size: var(--f-fs-title); font-weight: 500; letter-spacing: var(--f-track-display); }
.sheet .f-btn--block { margin-top: var(--f-s4); }
/* cards in a sheet are the same glass tiles as on the tabs (forma.css glass skin) */

/* ====================================================================== rows */
button.sh-row { width: 100%; text-align: left; }
.f-row__main > .f-row__title { display: -webkit-box; }
.f-row__meta .f-delta { min-height: 20px; padding: 0 7px; font-size: 12px; }
.sh-thumb { overflow: hidden; display: block; }
.sh-thumb .pic, .sh-thumb > svg, .sh-thumb .fig-ph { width: 100%; height: 100%; }
.sh-thumb svg { width: 100%; height: 100%; }
.sh-row-date { font-size: var(--f-fs-caption); color: var(--f-text-3); font-variant-numeric: tabular-nums; }
.sh-new { font-size: 11px; font-weight: 700; color: var(--f-better); text-transform: lowercase; }
.f-card .f-list { margin: calc(var(--f-s2) * -1) 0; }

.sh-note { font-size: var(--f-fs-sub); color: var(--f-text-2); line-height: var(--f-lh-body); }
.sh-empty-line { font-size: var(--f-fs-sub); color: var(--f-text-2); padding: var(--f-s2) 0; }

/* ====================================================================== Dnes */
/* v4 (docs/v4/design.md): the day and the week on the page grey, flat #212121 tiles, calm numbers (display font,
   weight 500) with a thin flat bar, no rings, no glow, no tinted pills. Začať is the one primary thing. */
.td { position: relative; isolation: isolate; gap: var(--f-s3); min-height: calc(100dvh - var(--f-dock-space)); align-content: start; }
.td-defs { position: absolute; pointer-events: none; }
.td-grad__a, .td-grad__b { stop-color: var(--f-accent); }

.td-head { background: transparent; }
.td-head .f-head__title { font-size: var(--f-fs-display); font-weight: 600; }
.td-week { align-items: center; gap: 14px; margin-top: var(--f-s4); }
.td-week > span:last-child { white-space: nowrap; font-size: var(--f-fs-sub); color: var(--f-text-2); }
.td-week b { font: 500 var(--f-fs-title) var(--f-font-num); letter-spacing: var(--f-track-display); color: var(--f-text); }
.td-segs { flex: 1; min-width: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.td-segs i { height: 6px; border-radius: 3px; background: var(--f-track); }
.td-segs i.is-on { background: var(--f-text); }

.td .f-card { border-radius: var(--f-r-lg); }
.td button.f-card { width: 100%; text-align: left; }
.td .f-card__title { font-size: var(--f-fs-body); font-weight: 500; }
.td-workout { gap: var(--f-s4); }
.td-workout .f-card__title { font-family: var(--f-font-display); font-size: var(--f-fs-title); font-weight: 600; letter-spacing: var(--f-track-display); }
.td-workout .f-btn--block { margin-top: var(--f-s1); }

.td-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--f-s3); }
.td-grid--row > :only-child { grid-column: 1 / -1; }
.td-tile { padding: var(--f-s4); min-height: 120px; container-type: inline-size; }
.td-kcal { grid-row: span 2; padding: var(--f-s4) var(--f-s4) 18px; align-content: space-between; }
.td-kcal .f-card__head { width: 100%; }
.td-protein { align-content: space-between; }
.td-add { width: var(--f-tap); height: var(--f-tap); flex: none; margin-left: auto; border-radius: 50%; display: grid; place-items: center; color: var(--f-text); background: var(--f-quiet); }
.td-add svg { width: 16px; height: 16px; }

/* a calm number and a thin flat bar under it */
.td-meter { display: grid; gap: var(--f-s3); }
.td-big { display: grid; gap: 4px; }
.td-big b { font: 500 var(--f-fs-num) / 1 var(--f-font-num); letter-spacing: var(--f-track-display); font-variant-numeric: tabular-nums; }
.td-big span { font-size: var(--f-fs-caption); color: var(--f-text-2); }
.td-meter--sm .td-big { display: flex; align-items: baseline; gap: 6px; }
.td-meter--sm .td-big b { font-size: 30px; }
@container (max-width: 150px) { .td-big b { font-size: 36px; } .td-meter--sm .td-big b { font-size: 26px; } }
.td-bar { display: block; height: 6px; border-radius: 3px; background: var(--f-track); overflow: hidden; }
.td-bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); border-radius: inherit; background: var(--f-text); transition: width var(--f-dur-ring) var(--f-ease); }
.td-meter--protein .td-bar i { background: var(--f-protein); }

.td-rest { align-content: space-between; gap: var(--f-s3); }
.td-rest__top { display: grid; gap: 2px; min-width: 0; }
.td-pill { width: 100%; min-height: var(--f-tap); border-radius: var(--f-r-pill); font-size: var(--f-fs-caption); font-weight: 500; white-space: nowrap; background: var(--f-quiet); }
@container (max-width: 124px) { .td-pill__more { display: none; } }

.td-next, .td-water { align-content: space-between; min-height: 112px; }
.td-label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--f-s2); font-size: var(--f-fs-body); font-weight: 500; }
.td-label span { font-family: var(--f-font-num); font-variant-numeric: tabular-nums; font-size: var(--f-fs-caption); font-weight: 500; color: var(--f-text-2); white-space: nowrap; }
.td-protein .td-label { font-size: var(--f-fs-sub); color: var(--f-text-2); }
/* the next training's first exercises: pictures big enough to read, side by side (no overlapping circles) */
.td-thumbs { display: flex; gap: 6px; }
.td-thumb { width: 52px; height: 52px; flex: none; border-radius: 14px; overflow: hidden; background: var(--f-thumb-bg); }
.td-thumb .pic, .td-thumb > svg, .td-thumb .fig-ph { width: 100%; height: 100%; }
.td-thumb--more { display: grid; place-items: center; background: var(--f-quiet); color: var(--f-text-2); font-family: var(--f-font-num); font-size: 14px; font-weight: 500; }
@container (max-width: 180px) { .td-thumb:nth-child(3):not(.td-thumb--more) { display: none; } }
@container (max-width: 120px) { .td-thumb:nth-child(2):not(.td-thumb--more) { display: none; } }
.td-drops { display: grid; gap: 6px; }
.td-drops--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.td-drops--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.td-drops--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.td-drops i { height: 20px; border-radius: 6px; background: var(--f-track); }
.td-drops i.is-on { background: var(--f-water); }

/* the duel: last week (grey) over this week (light); the change as plain coloured text, no tinted pill */
.td-duel { grid-template-columns: 96px minmax(0, 1fr) auto; }
.td .f-duel + .f-duel { border-top: 0; }
.td-duel__text { display: grid; min-width: 0; }
.td-duel .f-duel__label { font-size: var(--f-fs-caption); }
.td-duel .f-duel__value { font-size: var(--f-fs-sub); white-space: nowrap; }
.td .f-delta { background: none; padding: 0; min-width: 44px; justify-content: flex-end; color: var(--f-text-3); }
.td .f-delta--better { color: var(--f-better); }
.td .f-delta--worse { color: var(--f-worse); }
.td-bars { display: grid; gap: 5px; }
.td-bars i { display: block; position: relative; height: 6px; border-radius: 3px; background: var(--f-track); }
.td-bars i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); border-radius: inherit; }
.td-bars__prev::after { background: var(--f-bar-prev); }
.td-bars__now::after { background: var(--f-text); }
.td-bars i[style*="--w:0%"]::after { display: none; }

/* check-in: one row of five dots, then "Niečo bolí?" */
.sh-checkin { gap: var(--f-s3); padding-block: var(--f-s4); }
.sh-ci-row { display: flex; align-items: center; gap: var(--f-s3); }
.sh-ci-label { font-size: var(--f-fs-sub); font-weight: 500; flex: 1; }
.sh-ci-scale { display: flex; gap: 6px; }
.sh-ci-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--f-surface-2);
  color: var(--f-text-2);
  font-family: var(--f-font-num);
  font-size: var(--f-fs-sub);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  position: relative;
}
.sh-ci-dot::after { content: ""; position: absolute; inset: -2px; }
.sh-ci-dot.is-on { background: var(--f-text); color: #141414; }
.sh-ci-pain { display: flex; align-items: center; gap: 6px; min-height: 36px; font-size: var(--f-fs-sub); font-weight: 500; color: var(--f-text-2); text-align: left; }
.sh-ci-pain .chev { width: 7px; height: 12px; color: var(--f-text-3); flex: none; }
/* 320 px phones: five 40 px dots plus the label do not fit the card */
@media (max-width: 340px) { .sh-ci-scale { gap: 4px; } .sh-ci-dot { width: 32px; height: 32px; } .sh-ci-dot::after { inset: -6px -2px; } }
.sh-checkin .ci-hint, .sheet .ci-hint { border-top: 1px solid var(--f-sep); color: var(--f-text); }
.sheet .ci-hint { margin-top: var(--f-s4); }

/* ====================================================================== Progres */
/* No screen title: the calendar opens the screen right under the safe area. */
.app .f-screen.sh-screen--bare { padding-top: calc(var(--f-s4) + env(safe-area-inset-top, 0px)); }

/* calendar: big round days; trained = filled accent (ring while not complete), today outlined */
.sh-cal { gap: var(--f-s2); padding: var(--f-s3) var(--f-s2) var(--f-s4); }
.sh-cal .cal-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 var(--f-s1); }
.sh-cal .cal-title { text-align: center; min-width: 0; }
.sh-cal .cal-title h2 { font-family: var(--f-font-display); letter-spacing: var(--f-track-display); font-size: var(--f-fs-title); font-weight: 600; line-height: var(--f-lh-head); }
.sh-cal .cal-sum { font-size: var(--f-fs-caption); color: var(--f-text-2); margin: 2px 0 0; }
.sh-cal .cal-nav { width: var(--f-tap); height: var(--f-tap); border-radius: 50%; display: grid; place-items: center; color: var(--f-text); background: var(--f-surface-2); }
.sh-cal .cal-nav svg { width: 8px; height: 14px; }
.sh-cal .cal-grid { gap: 4px 2px; }
.sh-cal .cal-week span { font-size: 12px; font-weight: 600; padding-bottom: 2px; }
.sh-cal .cal-day { color: var(--f-text-3); font-size: 17px; font-weight: 600; min-height: var(--f-tap); }
.sh-cal .cal-day > span { line-height: 1; }
.sh-cal .cal-day.is-plan { color: var(--f-text); }
.sh-cal .cal-day.has-log { box-shadow: inset 0 0 0 2px var(--f-accent); color: var(--f-text); }
.sh-cal .cal-day.is-complete { background: var(--f-accent); color: var(--f-on-accent); font-weight: 800; }
.sh-cal .cal-day.is-today:not(.has-log, .is-complete) { background: var(--f-surface-3); color: var(--f-text); font-weight: 800; }
.sh-cal .cal-day.is-today.is-complete, .sh-cal .cal-day.is-today.has-log { outline: 2px solid var(--f-text); outline-offset: 2px; }
.sh-cal .cal-day i { bottom: 7%; width: 5px; height: 5px; background: transparent; }
.sh-cal .cal-day.has-photo i { background: var(--f-text); box-shadow: 0 0 0 1.5px var(--f-surface-1); }
.sh-cal .cal-day.is-complete.has-photo i { background: var(--f-on-accent); box-shadow: none; }
.sh-cal .cal-day.is-pr::after {
  content: "";
  position: absolute;
  top: 4%;
  right: 8%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--f-better);
  box-shadow: 0 0 0 2px var(--f-surface-1);
}

/* weight: the latest weight is the card's headline */
.pg-weight__now { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.pg-weight__now b { font-family: var(--f-font-num); font-variant-numeric: tabular-nums; font-size: var(--f-fs-display); font-weight: 500; line-height: 1; }
.pg-weight__now > span:not(.f-delta) { font-size: var(--f-fs-sub); font-weight: 600; color: var(--f-text-2); }
.pg-weight__now .f-delta { align-self: center; margin-left: 4px; }

/* progress photos: thumbnails (card, day sheet), the add buttons, the full-screen viewer */
.ph-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--f-s2); }
.ph-thumb { display: block; aspect-ratio: 3 / 4; border-radius: var(--f-r-md); overflow: hidden; background: var(--f-surface-2); }
.sheet .ph-thumb { background: var(--f-surface-3); }
.ph-thumb > span, .ph-thumb img { display: block; width: 100%; height: 100%; }
.ph-thumb img { object-fit: cover; }
.ph-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--f-s2); margin-top: var(--f-s2); }
.ph-grid + .ph-actions { margin-top: var(--f-s3); }
.ph-add { position: relative; cursor: pointer; }
.ph-add svg { width: 20px; height: 20px; }
.ph-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
.ph-add:focus-within { box-shadow: var(--f-focus); }

.ph-viewer {
  position: fixed;
  inset: 0;
  z-index: var(--f-z-timer);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #000;
  color: var(--f-text);
  padding: calc(var(--f-s2) + env(safe-area-inset-top, 0px)) var(--f-s3) calc(var(--f-s3) + env(safe-area-inset-bottom, 0px));
  animation: ph-in var(--f-dur-2) var(--f-ease-out);
}
@keyframes ph-in { from { opacity: 0; } }
.ph-viewer__top, .ph-viewer__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--f-s3); }
.ph-viewer__meta { display: grid; justify-items: center; min-width: 0; }
.ph-viewer__meta b { font-size: var(--f-fs-sub); font-weight: 700; }
.ph-viewer__meta span { font-size: var(--f-fs-caption); color: var(--f-text-2); font-variant-numeric: tabular-nums; }
.ph-viewer__gap { width: var(--f-tap); flex: none; }
.ph-viewer__stage { display: grid; place-items: center; min-height: 0; padding: var(--f-s3) 0; touch-action: pan-y; user-select: none; }
.ph-viewer__stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--f-r-md); -webkit-user-drag: none; }
.ph-viewer .f-icon-btn svg { width: 9px; height: 15px; }
.ph-viewer [data-phv="close"] svg { width: 13px; height: 13px; }
.ph-viewer .f-icon-btn:disabled { opacity: 0.3; }
.ph-del.is-armed { background: var(--f-accent); color: var(--f-on-accent); }

.sh-day { gap: var(--f-s3); }
.sh-pr-line { display: flex; align-items: center; gap: var(--f-s2); font-size: var(--f-fs-sub); color: var(--f-better); font-weight: 600; }
.sh-pr-badge { width: 8px; height: 8px; border-radius: 50%; background: var(--f-better); flex: none; }
.sheet .note-field { background: var(--f-surface-2); color: var(--f-text); }

/* ====================================================================== Ja (the rows and forms are in me.css) */
/* switch: a 52 × 32 pill; off = bar grey with a grey knob, on = light track with a dark knob */
.sh-switch {
  width: 52px;
  height: 32px;
  flex: none;
  border-radius: var(--f-r-pill);
  background: var(--f-bar);
  position: relative;
  transition: background-color 0.25s var(--f-ease);
}
.sh-switch i { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--f-text-2); transition: transform 0.3s var(--f-ease), background-color 0.25s var(--f-ease); }
[aria-checked="true"] > .sh-switch { background: var(--f-text); }
[aria-checked="true"] > .sh-switch i { transform: translateX(20px); background: var(--f-bg); }
/* a small quiet label over a group of settings (Ja → Navyše) */
.sh-group-label { font-size: var(--f-fs-sub); font-weight: 500; color: var(--f-text-2); padding: var(--f-s3) 0 0 var(--f-s1); }

.sh-label-row { display: flex; align-items: center; justify-content: space-between; }
.sh-label-row .f-info { margin: 12px -6px 0 0; }
.sh-why { background: var(--f-surface-2); border-radius: var(--f-r-md); padding: var(--f-s4); font-size: var(--f-fs-sub); color: var(--f-text-2); display: grid; gap: var(--f-s3); }
.sh-why ul { padding-left: 18px; list-style: disc; display: grid; gap: var(--f-s2); }
.sh-why b { color: var(--f-text); }
.sh-account { margin-top: var(--f-s5); }

/* ====================================================================== QA polish: older pieces on Forma sizes */
/* chips (settings: goal, days, equipment, pains; library categories): Forma chips with a 44 px hit area */
.lib-cat {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--f-r-pill);
  display: inline-flex;
  align-items: center;
  background: var(--f-surface-2);
  color: var(--f-text-2);
  font-size: var(--f-fs-caption);
  font-weight: 600;
  position: relative;
  white-space: nowrap;
}
.lib-cat::after { content: ""; position: absolute; inset: -4px 0; }
.lib-cat.is-on { background: var(--f-accent-soft); color: var(--f-accent-text); }
.sheet .lib-cat { background: var(--f-surface-3); }
.sheet .lib-cat.is-on { background: var(--f-accent-soft); }
/* settings choices (days, goal, equipment, pains): the picked ones must read at a glance */
.sheet .chip-row .lib-cat.is-on { background: var(--f-accent); color: var(--f-on-accent); }

/* small round buttons in sheets: the visible size stays, the hit area grows to 44 px */
.close, .ex-step, .t-bar .f-icon-btn, .q-btn, .d-del, .cmp-send, .cmp-cam { position: relative; }
.close::after, .ex-step::after, .t-bar .f-icon-btn::after, .q-btn::after, .d-del::after, .cmp-send::after, .cmp-cam::after { content: ""; position: absolute; inset: -6px; }
.close { width: 36px; height: 36px; background: var(--f-surface-2); color: var(--f-text-2); }
.ex-step { height: 36px; }
.sh-ci-pain { min-height: var(--f-tap); }

/* secondary text that has to stay readable: text-2, not the ghost text-3 */
.sh-row-date, .src, .size small, .sh-cal .cal-week span { color: var(--f-text-2); }
/* text links in sheets (sore areas under an exercise, "Zapísať" in the chat): 44 px tall */
.sheet .link[data-area] { min-height: var(--f-tap); }
.sheet .link[data-chat-log] { position: relative; }
.sheet .link[data-chat-log]::after { content: ""; position: absolute; inset: -10px -4px; }
.size { min-height: var(--f-tap); align-content: center; border-radius: var(--f-r-sm); }

@media (prefers-reduced-motion: reduce) {
  .sh-switch, .sh-switch i { transition: none; }
  .ph-viewer { animation: none; }
}

/* "Nová verzia" bar: above the dock, above everything except the timer; it stays until tapped. */
.upd-toast { z-index: var(--f-z-toast); bottom: calc(var(--f-dock-h) + var(--f-dock-bottom) + 16px); }

/* Full-screen picture (exercise animation, muscle map). */
.zoom-view { position: fixed; inset: 0; z-index: calc(var(--f-z-toast) + 5); display: grid; place-items: center; background: var(--f-bg); padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); animation: f-toast-in 160ms ease-out; }
.zoom-view img { width: 100vw; max-width: 900px; max-height: 100%; object-fit: contain; }
.zoom-view__close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.t-art .pose.anim img, .t-muscles img { cursor: zoom-in; }

/* after birth (inner-ui.js): air above the check row and the check's save button */
.pp-gap { margin-top: 16px; }
.pp-link { margin-top: 14px; font-size: var(--f-fs-sub); }
