/* ===== Barvy a základ ===== */
:root {
  --yellow: #fce834;
  --yellow2: #facc15;
  --bg: #09090b;
  --card: #18181b;
  --card2: #27272a;
  --line: #27272a;
  --text: #f4f4f4;
  --muted: #a1a1aa;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ===== Hlavička obrazovky ===== */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  background: var(--bg);
}
.top h1 {
  flex: 1;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top h1 span { color: var(--yellow); }

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn.danger { color: var(--danger); }

/* ===== Karty a seznamy ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
button.card, a.card {
  display: block;
  width: 100%;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
button.card:active, a.card:active { background: var(--card2); }

.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 17px; }
.muted { color: var(--muted); font-size: 14px; }
.chev { color: var(--yellow); font-size: 22px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(to right, var(--yellow), var(--yellow2));
  color: #000;
  font-weight: 800;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

.section {
  margin: 20px 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ===== Tlačítka ===== */
.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--yellow), var(--yellow2));
  box-shadow: 0 8px 20px rgba(252, 232, 52, 0.25);
  color: #000;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn:active { filter: brightness(0.9); }
.btn.ghost {
  background: transparent;
  box-shadow: none;
  color: #fff;
  border: 2px solid var(--yellow);
}
.btn.small {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 14px;
}
.btn.dark { background: var(--card2); box-shadow: none; color: var(--text); }

/* ===== Formuláře ===== */
label.field { display: block; margin-bottom: 12px; }
label.field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--muted);
}

input, textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #111;
  color: var(--text);
  font: inherit;
}
select {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #111;
  color: var(--text);
  font: inherit;
}

/* Sbalení cviku v zápisu tréninku */
.ex-toggle {
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  min-height: 44px;
  cursor: pointer;
}
.ex-toggle .arrow {
  display: inline-block;
  width: 20px;
  color: var(--yellow);
  font-size: 14px;
  text-align: center;
  transform: rotate(180deg);          /* rozbaleno = šipka nahoru */
  transition: transform 0.3s ease;
}
.card.collapsed .arrow { transform: rotate(0deg); }   /* sbaleno = šipka dolů */

/* Plynulé sbalení: výška řádku mřížky se mění z 1fr na 0fr */
.ex-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease;
}
.ex-inner {
  min-height: 0;
  overflow: hidden;
  transition: visibility 0s, opacity 0.3s ease;
}
.card.collapsed .ex-body { grid-template-rows: 0fr; }
.card.collapsed .ex-inner {
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.3s, opacity 0.3s ease;
}

/* Karta tréninku na stránce klienta */
.row.top-align { align-items: flex-start; }
.plain-link { color: inherit; text-decoration: none; }
.badge {
  color: var(--yellow);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.btn.dark[data-action="prepnout-nevyuzito"] { font-weight: 600; }

/* Seznam cviků s odrážkami na kartě tréninku */
.ex-list {
  margin: 4px 0 2px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
}
.ex-list li::marker { color: var(--yellow); }

/* Menší karta (seznam cviků) */
.card.compact { padding: 8px 8px 8px 16px; margin-bottom: 8px; }
.card.compact .title { font-size: 16px; font-weight: 600; }

/* Neprocvičené cviky u klienta */
.untried {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  color: var(--muted);
}
.untried summary {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}
.untried summary::-webkit-details-marker { display: none; }
.untried summary::before { content: '▸'; margin-right: 8px; color: var(--yellow); }
.untried[open] summary::before { content: '▾'; }
.untried summary span { margin-left: auto; color: var(--yellow); font-weight: 700; }
.untried ul {
  max-height: 260px;
  overflow-y: auto;
  padding: 0 14px 8px;
  list-style: none;
}
.untried li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  color: var(--text);
}
.untried li span { color: var(--yellow); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--yellow);
}
textarea { resize: vertical; min-height: 48px; }

/* ===== Zápis tréninku ===== */
.history {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--yellow);
  border-radius: 0 10px 10px 0;
  background: rgba(252, 232, 52, 0.08);
  font-size: 14px;
}
.history b { color: var(--yellow); }
.history .sets-line { margin-top: 4px; }
.history .chip {
  display: inline-block;
  margin: 3px 6px 0 0;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(252, 232, 52, 0.14);
  white-space: nowrap;
}
.history .hnote { margin-top: 6px; color: var(--muted); font-style: italic; }

.sets-head, .set {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
}
.sets-head {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.set { margin-bottom: 8px; }
.set .num {
  color: var(--yellow);
  font-weight: 800;
  text-align: center;
}
.set input {
  padding: 12px 4px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}
.set .del {
  height: 36px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

/* ===== Spodní navigace ===== */
#nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: #000;
  border-top: 1px solid var(--line);
}
#nav a {
  flex: 1;
  max-width: 260px;
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
#nav a.active { color: var(--yellow); }
#nav svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ===== Vysouvací panel ===== */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}
#overlay[hidden] { display: none; }
#sheet {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  border-top: 3px solid var(--yellow);
  background: var(--card);
}
#sheet h2 { margin-bottom: 14px; font-size: 19px; }
#sheet .pick {
  display: block;
  width: 100%;
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
#sheet .pick.new { color: var(--yellow); font-weight: 700; }


/* =========================================================
   ONLINE ČÁST (přihlášení, plány, klientská sekce)
   ========================================================= */
:root { --green: #4ade80; }
#nav[hidden] { display: none; }
#app.wide { max-width: 1500px; }
.badge.ok, .ok { color: var(--green); }
.error { min-height: 22px; margin-bottom: 8px; color: var(--danger); font-size: 14px; }

/* ----- Přihlášení ----- */
.login { padding-top: 14vh; }
.logo { margin-bottom: 28px; font-size: 30px; font-weight: 800; text-align: center; letter-spacing: -0.02em; }
.logo span { color: var(--yellow); }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 18px;
  padding: 4px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
}
.seg button {
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.seg button.active { background: linear-gradient(to right, var(--yellow), var(--yellow2)); color: #000; }

/* ----- Náhled e-mailu s heslem ----- */
.mail {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #111;
  font-size: 15px;
}
.mail p { margin-top: 8px; }
.mail .pass { color: var(--yellow); font-size: 18px; letter-spacing: 0.05em; user-select: all; }

/* ----- Písmeno cviku (A, B, C…) ----- */
.let {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--yellow);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}
.let.big { width: 40px; height: 40px; font-size: 15px; }

/* ----- Plánovací kalendář coache ----- */
.plan-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px 8px; }
.plan-grid {
  display: grid;
  grid-template-columns: 78px repeat(7, minmax(150px, 1fr));
  gap: 6px;
  min-width: 1180px;
}
.pg-head { padding: 6px 0; color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.pg-week { padding-top: 8px; color: var(--muted); font-size: 12px; }
.pg-week b { display: block; color: var(--yellow); font-size: 14px; }
.pg-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 150px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.pg-cell.today { border-color: var(--yellow); }
.pg-date { color: var(--muted); font-size: 12px; }
.pcard {
  display: block;
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--yellow);
  border-radius: 8px;
  background: #111;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
}
.pcard:hover { border-color: var(--yellow); }
.pcard.done { border-left-color: var(--green); }
.pcard b { display: block; margin-bottom: 4px; color: var(--text); font-size: 14px; }
.pcard ol { padding-left: 18px; }
.pcard li { margin-bottom: 3px; }
.pcard li span { color: var(--text); }
.padd {
  height: 32px;
  margin-top: auto;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.padd:hover { border-color: var(--yellow); color: var(--yellow); }

/* ----- Předpis cviku (coach) ----- */
.rx-inputs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.rx-inputs span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.rx-inputs input { padding: 10px 4px; text-align: center; }

/* ----- Klient: týdenní a měsíční kalendář ----- */
.cal-link {
  padding: 8px 0;
  border: 0;
  border-bottom: 2px solid var(--yellow);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.week {
  display: grid;
  grid-template-columns: 22px repeat(7, 1fr) 22px;
  gap: 4px;
  margin: 14px 0 6px;
}
.wk-arrow { height: 44px; border: 0; background: none; color: var(--yellow); font-size: 24px; cursor: pointer; }
.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.day .circle {
  width: 100%;
  max-width: 46px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--card2);
  font-size: 15px;
}
.day.today .circle { box-shadow: 0 0 0 2px var(--yellow); }
.day.sel .circle { background: linear-gradient(to right, var(--yellow), var(--yellow2)); color: #000; }
.day small { color: var(--muted); font-size: 12px; }
.mark { height: 10px; color: var(--yellow); font-size: 9px; line-height: 10px; }
.mark.done { color: var(--green); font-size: 11px; font-weight: 800; }
.sel .mark { color: #000; }
.sel .mark.done { color: #166534; }

.month { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 13px; }
.mday {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.mday.out { opacity: 0.35; }
.mday.today { box-shadow: inset 0 0 0 1.5px var(--yellow); }
.mday.sel { background: var(--yellow); color: #000; font-weight: 700; }

/* ----- Klient: seznam cviků a poznámka trenéra ----- */
.rx { margin: 6px 0 4px; list-style: none; }
.rx li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.coach-note { margin: 8px 0; color: #d4d4d8; font-size: 15px; white-space: pre-wrap; }

/* ----- Klient: trénink po stránkách ----- */
body.player-open #nav { display: none; }
.p-top { display: flex; align-items: center; gap: 12px; padding: 16px 0 10px; }
.exit { color: var(--text); font-size: 14px; font-weight: 700; letter-spacing: 0.06em; text-decoration: none; white-space: nowrap; }
.dashes { display: flex; gap: 6px; margin-bottom: 14px; }
.dash { position: relative; flex: 1; height: 24px; border: 0; background: none; cursor: pointer; }
.dash::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  height: 3px;
  border-radius: 2px;
  background: #3f3f46;
  transition: background 0.2s;
}
.dash.active::after { background: var(--yellow); }
.pages {
  display: flex;
  align-items: flex-start;
  margin: 0 -16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.pages::-webkit-scrollbar { display: none; }
.page { flex: 0 0 100%; padding: 0 16px; scroll-snap-align: start; scroll-snap-stop: always; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 10px; }
.stat { padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); text-align: center; }
.stat small { display: block; color: var(--muted); font-size: 11px; }
.stat b { font-size: 15px; }
.sets-head.two, .set.two { grid-template-columns: 28px 1fr 1fr 36px; }
.p-arrows {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #000;
  color: var(--muted);
  font-weight: 700;
}
.p-arrows button {
  width: 64px;
  height: 44px;
  border: 2px solid var(--yellow);
  border-radius: 999px;
  background: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

/* ----- Plán: více řádků předpisu, supersérie, video ----- */
.rx-row { display: grid; grid-template-columns: repeat(4, 1fr) 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.rx-row input { padding: 10px 4px; text-align: center; }
.rx-row .del { height: 36px; border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.rx-head { margin: 12px 0 4px; color: var(--muted); font-size: 12px; text-align: center; }
.card.ss { margin-top: -6px; border-top: 2px dashed var(--yellow); border-top-left-radius: 0; border-top-right-radius: 0; }
.pline { margin-bottom: 4px; }
.pline span { color: var(--text); }
.video {
  display: inline-block;
  padding: 6px 0;
  color: var(--yellow);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  word-break: break-all;
}
.mail .video { white-space: normal; }
.rx li .video { flex: none; }

/* ----- Klient: více cviků na stránce (supersérie), předpis ve více řádcích ----- */
.pex + .pex { margin-top: 22px; padding-top: 18px; border-top: 2px dashed var(--line); }
.rx-lines { margin: 14px 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.rx-lines div { padding: 9px 12px; font-weight: 600; }
.rx-lines div + div { border-top: 1px solid var(--line); }
.let { font-size: 11px; }
.let.big { font-size: 14px; }

/* ----- Odkaz na video v databázi cviků (šedý = video není přiřazeno) ----- */
.video-link { display: inline-block; padding: 4px 0; color: var(--yellow); font-weight: 600; text-decoration: none; }
.video-link.off { color: #52525b; font-weight: 400; }

/* ----- Mobilita na volné dny ----- */
.pline.mob { color: #71717a; font-size: 12px; font-style: italic; }

/* ----- Štítek „Ukládám…“ (ukazuje se jen při neuložených změnách) ----- */
#stav-ulozeni {
  position: fixed;
  top: 8px;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #000;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}
#stav-ulozeni[hidden] { display: none; }
#stav-ulozeni.chyba { border-color: var(--danger); color: var(--danger); }

/* ----- Osobní údaje (GDPR): text, zaškrtávací políčka ----- */
.legal { font-size: 14.5px; color: #d4d4d8; }
.legal h2 { margin: 16px 0 6px; color: var(--yellow); font-size: 15px; }
.legal h2:first-child { margin-top: 0; }
.legal p { margin-bottom: 8px; }
.legal ul { margin: 0 0 8px; padding-left: 20px; }
.legal li { margin-bottom: 3px; }
.legal.scroll { max-height: 42vh; overflow-y: auto; }
.check { display: flex; gap: 12px; align-items: flex-start; margin: 12px 0; font-size: 15px; cursor: pointer; }
.check input { flex: none; width: 24px; height: 24px; margin-top: 1px; padding: 0; accent-color: var(--yellow); }
.legal-link { display: block; margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; }
