/* Green Gym — estilos */
:root {
  /* Paleta tomada del logo: fondo negro, hojas de palmera y crema */
  --bg: #030303;
  --surface: #101411;
  --surface-2: #171d18;
  --line: #262f28;
  --text: #ece8dc;
  --muted: #8f9d93;
  --green: #8cbf7a;
  --green-2: #5f8a5a;
  --green-ink: #0d1a0c;
  --warn: #f5c451;
  --danger: #ff6b6b;
  --radius: 16px;
  --nav-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
a { color: var(--green); }
img, video, iframe { max-width: 100%; display: block; }
h1 { font-size: 1.7rem; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .7rem; }
.h3, h2.h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 .5rem; }
p { margin: .4rem 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.upper { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; margin: 0; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.grow { flex: 1; min-width: 0; }
.hidden, [hidden] { display: none !important; }
.row { display: flex; gap: .6rem; align-items: center; }
.stack > * + * { margin-top: .9rem; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(3, 3, 3, .9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; }
.brand img { height: 32px; width: auto; }
.topbar-user { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }

/* Bottom nav */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(16, 20, 17, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: .72rem;
}
.bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav a.active { color: var(--green); }

/* Cards, flashes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: .95rem; border: 1px solid; }
.flash-ok { background: rgba(140, 191, 122, .1); border-color: rgba(140, 191, 122, .35); }
.flash-error { background: rgba(255, 107, 107, .1); border-color: rgba(255, 107, 107, .4); }
.flash-warn { background: rgba(245, 196, 81, .08); border-color: rgba(245, 196, 81, .35); }
.empty { text-align: center; padding: 32px 16px; }
.empty-icon { font-size: 2.4rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: rgba(255, 107, 107, .5); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; border-radius: 10px; }
.btn-icon.danger { color: var(--danger); }
.btn:disabled { opacity: .35; cursor: default; }

/* Forms */
.field { display: block; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
input[type=file] { width: 100%; color: var(--muted); font-size: .9rem; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--green); }
.inline { display: inline-flex; align-items: center; gap: .5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { flex: 1 1 200px; }
.filters select { flex: 0 1 200px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

/* Page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 4px; font-size: .9rem; }

/* Login */
.login { max-width: 380px; margin: 8vh auto 0; }
.login-brand { margin: 0 0 6px; }
.login-brand img { width: 100%; height: auto; }
.login .card { margin-top: 20px; }

/* Day tabs */
.daytabs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0 16px; }
.daytabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 46px; border-radius: 12px; border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600; background: var(--surface);
}
.daytabs a.has { color: var(--text); }
.daytabs a.has::after { content: ""; position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.daytabs a.today { border-color: var(--green-2); }
.daytabs a.active { background: var(--green); color: var(--green-ink); border-color: var(--green); }
.daytabs a.active::after { background: var(--green-ink); }
.daytabs small { font-size: .65rem; opacity: .8; }

/* Progress */
.progress-card { padding: 14px 16px; }
.progress-text { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-2), var(--green)); border-radius: inherit; transition: width .35s ease; }
.bar.full i { background: var(--green); }

/* Exercise cards (alumno) */
.exlist { list-style: none; margin: 0; padding: 0; }
.excard {
  display: flex; align-items: stretch; gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden; transition: border-color .2s, opacity .2s;
}
.excard.done { border-color: rgba(140, 191, 122, .45); }
.excard.done .excard-name { text-decoration: line-through; text-decoration-color: var(--green); color: var(--muted); }
.check {
  flex: 0 0 64px; display: grid; place-items: center;
  background: transparent; border: 0; border-right: 1px solid var(--line); cursor: pointer; padding: 0; color: var(--text);
}
.check svg {
  width: 34px; height: 34px; padding: 5px; border-radius: 50%;
  border: 2px solid var(--muted); fill: none; stroke: transparent; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  transition: all .2s;
}
.excard.done .check svg { background: var(--green); border-color: var(--green); stroke: var(--green-ink); transform: scale(1.06); }
.excard-body { flex: 1; min-width: 0; display: flex; gap: 12px; padding: 12px; color: inherit; text-decoration: none; }
.excard-thumb {
  position: relative; flex: 0 0 64px; height: 64px; border-radius: 12px; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-weight: 700;
}
.excard-thumb img { width: 100%; height: 100%; object-fit: cover; }
.excard-thumb .play {
  position: absolute; right: 4px; bottom: 4px; font-style: normal; font-size: .6rem;
  background: rgba(0, 0, 0, .65); color: #fff; border-radius: 6px; padding: 2px 5px;
}
.excard-info { min-width: 0; }
.excard-name { font-weight: 700; margin-bottom: 2px; }
.excard-dose { font-size: .95rem; }
.excard-dose b { color: var(--green); }
.excard-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.excard-notes { margin-top: 6px; padding: 6px 10px; border-left: 3px solid var(--green-2); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.chip { display: inline-block; min-width: 26px; text-align: center; padding: 0 6px; margin: 0 2px; border-radius: 8px; background: var(--surface-2); color: var(--green); font-weight: 700; }
.exlist.single .excard { border: 0; background: none; }
.check-wide {
  flex: 1; display: flex; gap: .6rem; align-items: center; justify-content: center;
  min-height: 56px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font: inherit; font-weight: 700;
}
.check-wide svg { width: 28px; height: 28px; padding: 3px; }
.excard .when-done { display: none; }
.excard.done .when-done { display: inline; color: var(--green); }
.excard.done .when-todo { display: none; }
.excard.done .check-wide { border-color: var(--green); }

/* Exercise detail */
.media { margin: 12px 0; border-radius: var(--radius); overflow: hidden; background: #000; }
.media video { width: 100%; max-height: 70vh; }
.media-16x9 { position: relative; aspect-ratio: 16 / 9; }
.media-16x9 iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.carousel { margin: 12px 0 16px; }
.carousel-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  border-radius: var(--radius); background: var(--surface); scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel figure { flex: 0 0 100%; margin: 0; scroll-snap-align: center; position: relative; }
.carousel img { width: 100%; max-height: 62vh; object-fit: contain; background: #fff; }
.carousel figcaption { position: absolute; left: 10px; top: 10px; background: rgba(0, 0, 0, .6); color: #fff; font-size: .78rem; padding: 3px 8px; border-radius: 8px; }
.carousel-controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.carousel-controls .dots { flex: 1; display: flex; justify-content: center; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background .2s, transform .2s; }
.dots i.on { background: var(--green); transform: scale(1.25); }
.series { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.series li { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.series li span { font-size: .78rem; color: var(--muted); }
.series li b { color: var(--green); font-size: 1.1rem; }
.kv { display: flex; gap: 24px; }
.kv div { display: flex; flex-direction: column; }
.prose { color: #cfe0d5; }

/* Lists (admin) */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px;
}
.list-item.inactive { opacity: .55; }
.list-item.editing { border-color: var(--green); }
.list-item .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.list-item .actions form { display: flex; gap: 6px; margin: 0; }
.num { flex: 0 0 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--green); font-weight: 700; font-size: .85rem; }
.date { display: flex; flex-direction: column; align-items: center; width: 44px; }
@media (max-width: 560px) {
  .list-item { flex-wrap: wrap; }
  .list-item .actions { width: 100%; justify-content: flex-start; }
}
.avatar { flex: 0 0 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--green-ink); font-weight: 800; font-size: 1.3rem; }
.avatar.sm { flex-basis: 40px; height: 40px; font-size: 1rem; }
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.badge { display: inline-block; font-size: .7rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); vertical-align: middle; margin-left: 4px; }
.badge-admin { border-color: var(--warn); color: var(--warn); }
.badge-profesor { border-color: #6cb8ff; color: #6cb8ff; }
.badge-alumno { border-color: var(--green-2); color: var(--green); }
.stat b { font-size: 1.4rem; color: var(--green); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats .card { display: flex; flex-direction: column; text-align: center; margin: 0; padding: 12px 8px; }
.stats b { font-size: 1.4rem; color: var(--green); }

/* Ejercicios grid (admin) */
.exgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.extile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; color: inherit; text-decoration: none; }
.extile-img { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.extile-img img { width: 100%; height: 100%; object-fit: cover; }
.extile-body { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.imgedit { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.imgedit-item { background: var(--surface-2); border-radius: 12px; padding: 8px; }
.imgedit img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.imgedit .field input { min-height: 36px; padding: 6px 8px; }

details summary { cursor: pointer; font-weight: 600; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; z-index: 20; font-size: .9rem; box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
}

/* Instrucciones de instalación en iPhone */
.ios-steps { margin: 8px 0 0; padding-left: 22px; }
.ios-steps li { margin: 6px 0; }
