/* SIGYM — phone-height screens, no vertical page scroll. */
:root {
  --bg: #0b0d10;
  --panel: #151920;
  --panel2: #1d232c;
  --line: #2a313c;
  --text: #f1f4f8;
  --muted: #8b95a5;
  --accent: #c6ff3d;
  --accent-ink: #0b0d10;
  --danger: #ff3b3b;
  --warn: #ffb020;
  --ok: #3ddc84;
  --radius: 16px;
  --app-h: 100dvh; /* the phone frame on desktop sets it to the frame height */
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6f9; --panel: #ffffff; --panel2: #eef1f5; --line: #d8dee7;
    --text: #10141a; --muted: #5d6878; --accent: #5a8f00; --accent-ink: #ffffff;
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body { font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }

#app {
  height: var(--app-h); max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* header */
header.top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 8px 14px 6px; }
.brand b { font-weight: 900; letter-spacing: .04em; }
.brand span { color: var(--accent); margin-left: 6px; font-weight: 700; font-size: 13px; }
.gymclock { text-align: center; line-height: 1.05; }
.gymclock small { display: block; font-size: 9px; letter-spacing: .12em; color: var(--muted); }
.gymclock span { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; }
button.lang { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
.progress { grid-column: 1 / -1; height: 6px; background: var(--panel2); border-radius: 99px; position: relative; overflow: hidden; }
.progress i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.progress em { position: absolute; right: 4px; top: -15px; font-size: 10px; color: var(--muted); font-style: normal; }

/* screen */
main#screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 6px 14px 10px; overflow: hidden; }
h1 { margin: 0; font-size: 24px; line-height: 1.1; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 4px 0; font-size: 16px; }
p { margin: 0; }
.muted, small.muted { color: var(--muted); }
small { font-size: 12px; }
.label { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.grow { flex: 1; min-height: 0; }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.row > * { flex: 1; }
.row.tight { justify-content: flex-start; flex-wrap: wrap; }
.row.tight > * { flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* controls */
button { cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .45; }
button.primary, button.ghost, button.start, button.finish {
  border-radius: 12px; padding: 12px 14px; font-weight: 700; min-height: 46px;
}
button.primary { background: var(--accent); color: var(--accent-ink); }
button.ghost { background: var(--panel2); border: 1px solid var(--line); }
button.ghost.danger, .chip.danger { color: var(--danger); border-color: var(--danger); }
button.start { background: var(--accent); color: var(--accent-ink); font-size: 20px; font-weight: 900; letter-spacing: .06em; min-height: 58px; width: 100%; }
button.finish { background: var(--text); color: var(--bg); font-weight: 900; letter-spacing: .05em; width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); font-size: 13px; white-space: nowrap;
}
.chip.on { border-color: var(--accent); color: var(--accent); }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.action { color: var(--accent); border-color: var(--accent); font-weight: 700; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 16px;
}
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
input[type="file"] { padding: 7px; font-size: 12px; }
label.toggle { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
label.big input { font-size: 30px; font-weight: 800; text-align: center; padding: 8px; }
.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inputs.three { grid-template-columns: repeat(3, 1fr); }
.inputs input { font-size: 22px; font-weight: 800; text-align: center; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 10px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 0 4px; }

/* today */
.today { gap: 6px; }
.hello h1 { font-size: 21px; }
.hello p { font-size: 13px; }
.row.pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.row.pills .chip { padding: 5px 9px; font-size: 12px; flex: none; }
.rotation { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rotation .label { flex: none; max-width: 92px; line-height: 1.15; font-size: 10px; }
.rotation .chips .chip { gap: 4px; padding: 4px 8px; font-size: 12px; }
.rotation .chip small { font-size: 10px; color: var(--muted); }
.today .start { min-height: 52px; }
.today .hint { margin-top: -4px; }
.deckwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.deckwrap.empty { align-items: center; justify-content: center; }
.deck {
  flex: 1; min-height: 0; display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px;
}
.deck::-webkit-scrollbar { display: none; }
.card {
  flex: 0 0 82%; scroll-snap-align: center; display: flex; flex-direction: column; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; padding: 0; min-height: 0;
}
.card img { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #fff; }
.card .noimg, .noimg {
  flex: 1; min-height: 60px; display: grid; place-items: center; background: var(--panel2);
  color: var(--muted); font-weight: 900; font-size: 28px; text-transform: uppercase;
}
.cardtxt { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.cardtxt b { font-size: 18px; }
.cardtxt small { color: var(--muted); }
.cardtxt small.last { color: var(--accent); }
.stack { position: relative; flex: 1; min-height: 0; touch-action: pan-y; margin-right: 36px; }
.stack .card {
  position: absolute; inset: 0; width: 100%; transition: transform .28s ease, opacity .28s ease;
  box-shadow: 0 10px 24px rgba(0,0,0,.28); will-change: transform; user-select: none; -webkit-user-drag: none;
}
.stack .card:not(.front) .cardtxt { visibility: hidden; }
.stack .card img { pointer-events: none; }
.stack.drag .card.front { transition: none; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dots i { cursor: pointer; width: 6px; height: 6px; border-radius: 9px; background: var(--line); }
.dots i.on { background: var(--accent); width: 18px; }
.hint { text-align: center; color: var(--muted); font-size: 11px; }
.resume { background: var(--panel); border: 1px solid var(--warn); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.resume .row button { min-height: 40px; padding: 8px; font-size: 13px; }
.sponsors { display: flex; gap: 14px; justify-content: center; font-size: 11px; color: var(--muted); padding: 4px 10px; overflow: hidden; white-space: nowrap; }
.sponsors a { color: var(--muted); }

/* workout */
.exhead { display: flex; gap: 12px; align-items: center; }
.exhead img, .exhead .noimg { width: 64px; height: 64px; border-radius: 12px; object-fit: contain; background: #fff; flex: none; font-size: 18px; min-height: 0; }
.exhead .noimg { background: var(--panel2); }
.exhead b { display: block; font-size: 18px; }
.exhead small { color: var(--muted); }
.setchips { display: flex; gap: 6px; flex-wrap: wrap; }
.setchips .chip { flex-direction: column; gap: 0; border-radius: 10px; padding: 4px 10px; position: relative; }
.setchips .chip small { font-size: 10px; color: var(--muted); }
.setchips i { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 9px; }
.f-easy { --f: var(--ok); } .f-effort { --f: var(--accent); } .f-hard { --f: var(--warn); } .f-pain { --f: var(--danger); }
.setchips i { background: var(--f); }
.feelings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1; min-height: 0; }
.feel { border-radius: 14px; border: 2px solid var(--f); background: var(--panel); padding: 10px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.feel span { font-size: 30px; }
.stopbar { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.stopbar button { border-radius: 12px; min-height: 48px; font-weight: 900; }
.stopbar .pause { background: var(--panel2); border: 1px solid var(--line); }
.stopbar .stop { background: var(--danger); color: #fff; letter-spacing: .04em; }
.resthead { text-align: center; }
.resthead small { letter-spacing: .2em; color: var(--muted); font-weight: 700; }
.countdown { font-size: 64px; font-weight: 900; font-variant-numeric: tabular-nums; text-align: center; line-height: 1; }
.note { color: var(--warn); font-size: 13px; }
.cheer { color: var(--accent); font-size: 14px; min-height: 1.2em; }
.water { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.water > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.water small { color: var(--muted); }
.water button { min-height: 40px; width: 52px; padding: 0; }
.bottle { width: 18px; height: 40px; border: 2px solid #4fb3ff; border-radius: 5px 5px 7px 7px; position: relative; overflow: hidden; background: #4fb3ff; }
.bottle i { position: absolute; inset: 0 0 auto 0; background: var(--panel); transition: height .4s; }
.news { display: flex; gap: 6px; }
.phase { text-align: center; font-size: 16px; color: var(--muted); }
.phase.on { color: var(--accent); font-weight: 800; }
.nextcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.deck.mini { flex: 0 0 120px; }
.deck.mini .card { flex: 0 0 110px; }
.deck.mini .cardtxt b { font-size: 12px; }
.deck.mini .cardtxt { padding: 6px 8px; }
.paused { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.paused .big { font-size: 56px; font-weight: 900; font-variant-numeric: tabular-nums; }
.report { flex: 1; min-height: 0; display: grid; grid-template-rows: auto auto; gap: 10px; overflow: hidden; }
.report .line { padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; gap: 6px; align-items: center; }
.report .line small { color: var(--muted); }
.report select { width: auto; padding: 4px 8px; font-size: 13px; margin-left: auto; }
.diff { font-size: 40px; font-weight: 900; text-align: center; color: var(--accent); }

/* history */
.hdeck .hcard { flex: 0 0 88%; scroll-snap-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.hcard header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hlist { display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.hlist .line { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.hlist .line.skipped { opacity: .6; }
.hlist .line small { color: var(--muted); }
.diffsm { color: var(--accent); }
pre.coach { white-space: pre-wrap; font: inherit; max-height: calc(var(--app-h) * .6); overflow: auto; margin: 0; }

/* machines */
.mgrid .card { flex: 0 0 60%; }

/* machine photos: cut-outs sit on the owner's sponsors background */
.card img, .exhead img, .thumb img { background-image: var(--machine-bg, none); background-size: cover; background-position: center; }
.thumb.big { width: 160px; height: 160px; align-self: center; }

/* photo picker & editor */
.photorow { display: flex; gap: 10px; align-items: center; }
.photorow > div:last-child { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.thumb { width: 64px; height: 64px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; flex: none; }
.thumb.round { border-radius: 50%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.picker .row button { min-height: 40px; padding: 8px; }
.stage { display: flex; justify-content: center; touch-action: none; }
.stage canvas { max-width: 100%; border-radius: 12px; cursor: grab; }
.editrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.editrow input[type="range"] { flex: 1; padding: 0; accent-color: var(--accent); }
.chip.replace { flex-direction: row; color: var(--text); cursor: pointer; }
.editstatus { font-size: 12px; }
.editstatus.ok { color: var(--ok); } .editstatus.bad { color: var(--warn); }

/* account */
.profilehead { display: flex; gap: 12px; align-items: center; }
.profilehead img, .profilehead .noimg { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; min-height: 0; }
.profilehead small { display: block; color: var(--muted); }
.activation { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.activation .code { font-size: 34px; font-weight: 900; letter-spacing: .2em; text-align: center; color: var(--accent); }
.ok { color: var(--ok); font-weight: 700; }
.disclaimer { font-size: 12px; color: var(--muted); }

/* nav */
nav.bottom { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: var(--panel); }
nav.bottom button { padding: 6px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--muted); }
nav.bottom button span { font-size: 16px; }
nav.bottom button small { font-size: 10px; }
nav.bottom button.on { color: var(--accent); }

/* sheet & toast */
.sheet-wrap { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; z-index: 20; }
.sheet { width: 100%; background: var(--panel); border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; max-height: calc(var(--app-h) * .9); overflow: auto; }
.toast { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 30; max-width: 90%; text-align: center; }
.tracks { display: flex; flex-direction: column; gap: 4px; max-height: calc(var(--app-h) * .3); overflow: auto; }
.track { display: flex; align-items: center; gap: 8px; }
.track button.link { flex: 1; text-align: left; background: none; border: 0; color: var(--text); padding: 6px 0; font: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Audio only: the YouTube player stays on the page but is invisible and never takes taps. */
#music { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; z-index: -1; }

/* short phones: tighten */
@media (max-height: 700px) {
  .hello h1 { font-size: 21px; }
  .countdown { font-size: 48px; }
  button.start { min-height: 50px; font-size: 18px; }
  main#screen { gap: 7px; }
}

/* Desktop preview: on a wide screen that is not a touch phone or tablet, show the app inside a phone
   frame at the exact size of a phone, so screens look as they do on the phone.
   Phones and tablets (coarse pointer) keep the app full screen. Embedded
   desktop browsers that report no pointer at all still get the frame. */
#device-bar { display: none; }
@media (min-width: 501px) and (not (pointer: coarse)) {
  :root { --fw: 390px; --fh: 844px; --app-h: var(--fh); --scale: 1; }
  html, body { background: #05070a; }
  body { display: flex; align-items: center; justify-content: center; }
  #app {
    width: var(--fw); max-width: none; height: var(--fh); margin: 0; flex: none;
    background: var(--bg); border-radius: 44px; padding: 0;
    box-shadow: 0 0 0 11px #1b1f26, 0 0 0 12px #3a414d, 0 30px 90px rgba(0, 0, 0, .7);
    transform: scale(var(--scale)); transform-origin: center center;
  }
  #device-bar {
    display: flex; gap: 6px; position: fixed; top: 14px; right: 14px; z-index: 50;
    background: #151920; border: 1px solid #2a313c; border-radius: 999px; padding: 4px;
  }
  #device-bar button { background: none; border: 0; color: #8b95a5; padding: 6px 12px; border-radius: 999px; font: 600 12px system-ui, sans-serif; cursor: pointer; }
  #device-bar button.on { background: #c6ff3d; color: #0b0d10; }
}
