:root {
  --gold: #F6B233;
  --gold-80: #F8C15C;
  --gold-40: #FBE0AD;
  --gold-20: #FDF0D6;
  --dark: #181818;
  --dark-80: #464646;
  --dark-60: #747474;
  --dark-40: #A3A3A3;
  --dark-20: #D1D1D1;
  --grey: #D4DADE;
  --grey-20: #F6F7F8;
  --green: #172E27;
  --ink: #0E2934;        /* azul petróleo de platform.motriz.es: cabecera y superficies oscuras */
  --ink-80: #1E4150;
  --ink-20: #E3EAED;
  --ok: #2E7D4F;
  --warn: #C0392B;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --text: #181818;
  --muted: #747474;
  --line: #E5E8EB;
  --font: 'Roboto', system-ui, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--grey-20);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Barra superior */
.topbar {
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 44px; height: 44px; display: block; }
.brand-sub { font-weight: 400; color: #C9D6DC; white-space: nowrap; font-size: 15px; letter-spacing: .02em; }
@media (max-width: 420px) { .brand-sub { display: none; } }
.role-switch { flex: none; display: flex; background: var(--ink-80); border-radius: 999px; padding: 3px; }
.role-switch button {
  border: 0; background: transparent; color: #C9D6DC;
  padding: 6px 14px; border-radius: 999px; font-weight: 500; font-size: 14px;
}
.role-switch button[aria-selected="true"] { background: var(--gold); color: var(--dark); }

/* Pestañas */
.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0 16px;
}
.tabs button {
  border: 0; background: none; padding: 14px 12px; white-space: nowrap;
  color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 16px 24px; }

/* Escala de espacios: 4 · 8 · 12 · 16 · 24 */
h1 { font-size: 24px; margin: 0 0 4px; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 16px; margin-bottom: 16px; }
.page-head h1, .page-head .lead { margin-bottom: 0; }
.page-head > div { min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Tarjetas y rejillas */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid > .card { margin-bottom: 0; }           /* el hueco lo pone el gap, no se suma al margen */
.card { margin-bottom: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* Botones */
.btn {
  border: 1px solid var(--dark-20); background: var(--surface); border-radius: 10px;
  padding: 9px 14px; font-weight: 500; font-size: 14px;
}
.btn:hover { border-color: var(--dark-40); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--dark); }
.btn.primary:hover { background: var(--gold-80); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Etiquetas */
.chip {
  display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 9px;
  border-radius: 999px; background: var(--grey-20); border: 1px solid var(--line); color: var(--dark-80);
}
.chip.gold { background: var(--gold-20); border-color: var(--gold-40); color: #7a5300; }
.chip.ok { background: #E7F3EC; border-color: #BFE0CC; color: var(--ok); }
.chip.warn { background: #FBEAEA; border-color: #F1C4C4; color: var(--warn); }

/* Panel del fisio */
.patient-card { cursor: pointer; transition: border-color .15s; }
.patient-card:hover { border-color: var(--gold); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--grey-20); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.alert {
  border-left: 4px solid var(--warn); background: #FBEAEA; padding: 8px 12px; border-radius: 8px;
  font-size: 14px; margin-top: 8px;
}
.spark { width: 100%; height: auto; display: block; margin-top: 4px; }
.note { border-left: 4px solid var(--gold); background: var(--gold-20); padding: 8px 12px; border-radius: 8px; margin-top: 8px; }
.log-row { border-top: 1px solid var(--line); padding: 10px 0; }
.log-row:first-of-type { border-top: 0; }
.txt-warn { color: var(--warn); }

/* Fases */
.phases { display: flex; gap: 6px; margin: 10px 0 16px; overflow-x: auto; padding-bottom: 4px; }
.phase-pill {
  flex: 1 0 auto; text-align: center; padding: 8px 12px; border-radius: 10px;
  background: var(--grey-20); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.phase-pill.done { background: var(--gold-20); border-color: var(--gold-40); color: #7a5300; }
.phase-pill.current { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 500; }
.phase-pill.view { outline: 2px solid var(--gold); outline-offset: 1px; }
.criteria { margin: 0; padding-left: 18px; }
.criteria li { margin: 4px 0; }

/* Desplegables: flecha propia con aire a la derecha */
select {
  appearance: none; -webkit-appearance: none;
  height: 42px; padding: 0 40px 0 12px;
  border: 1px solid var(--dark-20); border-radius: 10px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23464646' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 8px;
  max-width: 100%; text-overflow: ellipsis; cursor: pointer;
}
select:hover { border-color: var(--dark-40); }
select:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
select.sm { height: 34px; font-size: 14px; padding-right: 34px; background-position: right 11px center; }

/* Biblioteca */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; align-items: center; }
.filters input, .filters select, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--dark-20); border-radius: 10px; background-color: #fff;
}
.filters input, .field input { height: 42px; padding: 0 12px; }
@media (min-width: 600px) { .filters input[type=search] { grid-column: span 2; } }
.field textarea { padding: 9px 12px; }
.field input[type=file] { height: auto; padding: 8px; }
.ex-card { display: flex; flex-direction: column; gap: 8px; }
.ex-card .card-actions { margin-top: auto; padding-top: 4px; }
.video {
  aspect-ratio: 16/9; border-radius: 10px; background: linear-gradient(135deg, #222 0%, #3a3a3a 100%);
  color: #fff; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px;
  font-size: 12px; position: relative;
}
.video .play {
  width: 44px; height: 44px; border-radius: 50%; background: var(--gold);
  display: flex; align-items: center; justify-content: center; color: var(--dark); font-size: 18px;
}

.video.yt { border: 0; width: 100%; background-size: cover; background-position: center; cursor: pointer; padding: 0; }
.video.yt::before { content: ''; position: absolute; inset: 0; background: rgba(24,24,24,.25); border-radius: 10px; }
.video.yt .play, .video.yt .yt-tag { position: relative; }
.yt-tag { position: absolute !important; left: 8px; bottom: 8px; background: rgba(24,24,24,.8); padding: 2px 8px; border-radius: 6px; max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-frame iframe, .video-frame video { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 10px; display: block; margin-bottom: 4px; background: #000; }
.video.none { background: var(--grey-20); color: var(--dark-60); border: 1px dashed var(--dark-20); }
.video.yt.own { background-color: var(--green); }
.video.yt.own .yt-tag { background: var(--gold); color: var(--dark); font-weight: 500; }
.video.yt.still { cursor: default; }
.video.yt.still::before { background: rgba(24,24,24,.1); }

/* Selector segmentado (origen del vídeo) */
.seg { border: 0; padding: 0; margin: 0 0 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 8px 12px; border: 1px solid var(--dark-20); border-radius: 999px; font-size: 14px; font-weight: 500; }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Editor de pautas */
.ex-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start;
  border-top: 1px solid var(--line); padding: 12px 0;
}
.ex-row:first-child { border-top: 0; }
.params { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 8px; }
.params label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.params input { width: 100%; padding: 6px 8px; border: 1px solid var(--dark-20); border-radius: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }

/* Vista del paciente */
.hero {
  background: var(--ink); color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.hero .goal { color: var(--gold); font-weight: 700; }
.hero .who { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; color: var(--dark-20); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: var(--dark);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.check-item { display: grid; grid-template-columns: auto 1fr 132px; gap: 12px; align-items: start; }
.check-body { min-width: 0; }
.check-body .btn { margin-top: 2px; }
.check-media { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.check-media .video { width: 100%; font-size: 11px; text-align: center; padding: 4px; }
.check-media .video .play { width: 34px; height: 34px; font-size: 14px; }
@media (max-width: 420px) { .check-item { grid-template-columns: auto 1fr 104px; gap: 10px; } }
.check-item input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--gold); flex: none; margin-top: 2px; }
.check-item.done h3 { text-decoration: line-through; color: var(--muted); }
.dose { font-weight: 500; color: var(--dark-80); font-size: 14px; }
.scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; margin: 8px 0 4px; }
.scale button {
  border: 1px solid var(--dark-20); background: #fff; border-radius: 8px; padding: 8px 0; font-weight: 500; font-size: 14px;
}
.scale button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.scale-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.day { text-align: center; border-radius: 10px; padding: 6px 0; background: var(--grey-20); border: 1px solid var(--line); font-size: 13px; }
.day b { display: block; }
.day span { display: block; height: 18px; font-weight: 700; }
.day.done { background: var(--gold); border-color: var(--gold); color: var(--dark); }
.day.miss { background: #FBEAEA; border-color: #F1C4C4; color: var(--warn); }
.day.plan { background: #fff; border-color: var(--dark-40); }
.day.rest { color: var(--dark-40); }
.day.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.progress { height: 8px; background: var(--grey-20); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--gold); }

/* Modal y avisos */
.modal {
  position: fixed; inset: 0; background: rgba(14,41,52,.6); display: flex;
  align-items: flex-end; justify-content: center; z-index: 50; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 720px;
  max-height: 88vh; overflow: auto; padding: 18px;
}
@media (min-width: 700px) { .modal { align-items: center; } }
.modal-box > .row.spread:first-child { flex-wrap: nowrap; align-items: flex-start; }
.modal-box > .row.spread:first-child h2 { flex: 1; min-width: 0; }
.modal-box > .row.spread:first-child [data-action="close"] { flex: none; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 60; font-size: 14px;
}
.toast[hidden] { display: none; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Texto grande (pensado para pacientes de 40-70 años) */
body.big main, body.big .modal-box { zoom: 1.18; }

/* Temporizador */
.timer { text-align: center; padding: 10px 0; }
.timer-label { font-size: 26px; font-weight: 700; margin: 10px 0 4px; }
.timer-num { font-size: 96px; font-weight: 900; line-height: 1; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.timer.rest .timer-label, .timer.rest .timer-num { color: var(--dark-60); }

/* Pauta imprimible */
#print { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; display: block; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; font-size: 12pt; color: #181818; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 3px solid #F6B233; padding-bottom: 8px; margin-bottom: 14px; }
  .pr-brand { font-weight: 900; letter-spacing: .08em; font-size: 18pt; }
  .pr-meta { font-size: 10pt; color: #464646; text-align: right; }
  .pr-goal { background: #FDF0D6; padding: 8px 12px; border-radius: 6px; margin: 0 0 12px; }
  .pr-table { width: 100%; border-collapse: collapse; }
  .pr-table th { text-align: left; font-size: 9pt; text-transform: uppercase; color: #747474; border-bottom: 1px solid #D1D1D1; padding: 6px 4px; }
  .pr-table td { border-bottom: 1px solid #E5E8EB; padding: 8px 4px; vertical-align: top; }
  .pr-table tr { break-inside: avoid; }
  .pr-box { width: 14px; height: 14px; border: 1.5px solid #181818; display: inline-block; margin-right: 3px; }
  .pr-foot { margin-top: 16px; font-size: 9pt; color: #464646; border-top: 1px solid #D1D1D1; padding-top: 8px; }
}

/* =====================================================================
   Capa visual "tipo Apple": profundidad suave, materiales y relieve.
   Va al final para sobrescribir los estilos base sin tocarlos.
   ===================================================================== */
:root {
  --bg: #F2F4F6;
  --hairline: rgba(14, 41, 52, .08);
  --shadow-1: 0 1px 1px rgba(14,41,52,.04), 0 2px 6px rgba(14,41,52,.06);
  --shadow-2: 0 1px 2px rgba(14,41,52,.05), 0 6px 20px rgba(14,41,52,.08);
  --shadow-3: 0 2px 6px rgba(14,41,52,.08), 0 20px 48px rgba(14,41,52,.22);
  --gold-grad: linear-gradient(180deg, #FAC860 0%, #F6B233 55%, #EBA21C 100%);
  --ink-grad: linear-gradient(180deg, #17394A 0%, #0E2934 100%);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
body { background: var(--bg); -webkit-font-smoothing: antialiased; }

/* Cabecera translúcida */
.topbar {
  background: rgba(14, 41, 52, .92);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.06), 0 1px 0 rgba(0,0,0,.2);
}
.brand-logo { filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }

/* Control segmentado con selector deslizante en relieve */
.role-switch {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: rgba(0,0,0,.28); padding: 3px; border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.45), 0 1px 0 rgba(255,255,255,.07);
}
.role-switch::before {
  content: ''; position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: 999px; background: var(--gold-grad);
  box-shadow: 0 1px 1px rgba(0,0,0,.25), 0 3px 8px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.55), inset 0 -1px 0 rgba(0,0,0,.08);
  transition: transform .35s var(--ease);
}
.role-switch[data-active="paciente"]::before { transform: translateX(100%); }
.role-switch button { position: relative; z-index: 1; min-width: 92px; padding: 7px 16px; transition: color .25s; }
.role-switch button[aria-selected="true"] { background: none; color: var(--dark); text-shadow: 0 1px 0 rgba(255,255,255,.35); }
.role-switch button[aria-selected="false"]:hover { color: #fff; }

/* Pestañas: barra clara con indicador suave */
.tabs { background: rgba(255,255,255,.8); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--hairline); }
.tabs button { transition: color .2s; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--gold); }

/* Tarjetas: sin borde duro, sombra en capas */
.card { border: 0; border-radius: 18px; box-shadow: var(--shadow-1); }
.patient-card, .ex-card { transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.patient-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: transparent; }
.stat { background: linear-gradient(180deg, #F7F9FA, #EEF2F4); box-shadow: inset 0 1px 0 #fff, inset 0 0 0 1px var(--hairline); border-radius: 12px; }

/* Botones con relieve */
.btn {
  border: 0; border-radius: 11px; color: var(--text);
  background: linear-gradient(180deg, #FFFFFF, #F3F5F6);
  box-shadow: 0 0 0 1px var(--hairline), 0 1px 2px rgba(14,41,52,.08), inset 0 1px 0 #fff;
  transition: transform .12s var(--ease), box-shadow .2s, filter .2s;
}
.btn:hover { box-shadow: 0 0 0 1px rgba(14,41,52,.14), 0 2px 6px rgba(14,41,52,.1), inset 0 1px 0 #fff; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--gold-grad); color: var(--dark); box-shadow: 0 0 0 1px rgba(170,110,10,.25), 0 1px 2px rgba(120,80,0,.2), 0 4px 10px rgba(246,178,51,.28), inset 0 1px 0 rgba(255,255,255,.55); }
.btn.primary:hover { filter: brightness(1.03); background: var(--gold-grad); }
.btn.dark { background: var(--ink-grad); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 4px 10px rgba(14,41,52,.25), inset 0 1px 0 rgba(255,255,255,.12); }
.btn.ghost { background: none; box-shadow: none; }
.btn.ghost:hover { background: rgba(14,41,52,.05); box-shadow: none; }

/* Campos: hundidos, con anillo de foco dorado */
select, .filters input, .field input, .field textarea, .params input {
  border: 0; background-color: #fff;
  box-shadow: inset 0 0 0 1px rgba(14,41,52,.14), inset 0 1px 2px rgba(14,41,52,.06);
  transition: box-shadow .2s;
}
select:hover { box-shadow: inset 0 0 0 1px rgba(14,41,52,.24), inset 0 1px 2px rgba(14,41,52,.06); }
select:focus-visible, .filters input:focus-visible, .field input:focus-visible, .field textarea:focus-visible, .params input:focus-visible {
  outline: none; box-shadow: inset 0 0 0 1px var(--gold), 0 0 0 4px rgba(246,178,51,.22);
}

/* Etiquetas */
.chip { border: 0; background: #EEF2F4; box-shadow: inset 0 0 0 1px var(--hairline); }
.chip.gold { background: #FDF0D6; box-shadow: inset 0 0 0 1px rgba(246,178,51,.35); }

/* Miniaturas de vídeo con profundidad */
.video { border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.video.yt { box-shadow: 0 1px 2px rgba(14,41,52,.15), 0 4px 14px rgba(14,41,52,.14); transition: transform .25s var(--ease), box-shadow .25s; }
.video.yt:not(.still):hover { transform: scale(1.015); box-shadow: 0 2px 6px rgba(14,41,52,.18), 0 10px 24px rgba(14,41,52,.18); }
.video .play { background: rgba(255,255,255,.9); color: var(--ink); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.video.yt.own .play { background: var(--gold-grad); color: var(--dark); }
.yt-tag { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); background: rgba(14,41,52,.65) !important; }
.video.none { border: 0; background: linear-gradient(180deg, #F3F5F6, #E9EDEF); box-shadow: inset 0 0 0 1px var(--hairline), inset 0 1px 3px rgba(14,41,52,.06); }

/* Hero del paciente: material oscuro con brillo */
.hero {
  background: radial-gradient(120% 140% at 0% 0%, #1F4D60 0%, #0E2934 55%, #0A1F28 100%);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.08); border-radius: 22px;
}
.hero .progress { background: rgba(255,255,255,.12); box-shadow: inset 0 1px 2px rgba(0,0,0,.35); }
.progress > div { background: var(--gold-grad); box-shadow: 0 0 8px rgba(246,178,51,.5); transition: width .4s var(--ease); }
.avatar { background: var(--gold-grad); box-shadow: 0 1px 2px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.5); }

/* Check redondo tipo Recordatorios */
.check-item input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; margin: 0; cursor: pointer;
  background: #fff; box-shadow: inset 0 0 0 2px rgba(14,41,52,.22), inset 0 1px 2px rgba(14,41,52,.08);
  display: grid; place-content: center; transition: background .2s, box-shadow .2s, transform .15s;
}
.check-item input[type=checkbox]::after { content: ''; width: 7px; height: 13px; border: solid transparent; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.check-item input[type=checkbox]:checked { background: var(--gold-grad); box-shadow: 0 1px 2px rgba(120,80,0,.3), inset 0 1px 0 rgba(255,255,255,.5); }
.check-item input[type=checkbox]:checked::after { border-color: var(--dark); }
.check-item input[type=checkbox]:active { transform: scale(.92); }
.check-item.done { opacity: .78; }

/* Escalas de dolor y esfuerzo */
.scale button { border: 0; border-radius: 10px; background: linear-gradient(180deg, #fff, #F2F4F6); box-shadow: 0 0 0 1px var(--hairline), 0 1px 2px rgba(14,41,52,.06); transition: transform .12s; }
.scale button:active { transform: scale(.94); }
.scale button[aria-pressed="true"] { background: var(--ink-grad); color: #fff; box-shadow: 0 2px 6px rgba(14,41,52,.35), inset 0 1px 0 rgba(255,255,255,.12); }

/* Semana */
.day { border: 0; box-shadow: inset 0 0 0 1px var(--hairline); border-radius: 12px; }
.day.done { background: var(--gold-grad); box-shadow: 0 1px 2px rgba(120,80,0,.25), inset 0 1px 0 rgba(255,255,255,.5); }
.day.plan { background: #fff; box-shadow: inset 0 0 0 1px rgba(14,41,52,.2); }
.day.today { outline: 0; box-shadow: 0 0 0 2px var(--ink), 0 4px 10px rgba(14,41,52,.15); }

/* Fases */
.phase-pill { border: 0; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--hairline); }
.phase-pill.done { box-shadow: inset 0 0 0 1px rgba(246,178,51,.4); }
.phase-pill.current { background: var(--ink-grad); box-shadow: 0 2px 8px rgba(14,41,52,.3); }

/* Ventanas: fondo desenfocado y entrada suave */
.modal { background: rgba(14,41,52,.35); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal-box { border-radius: 22px; box-shadow: var(--shadow-3); animation: modal-in .32s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.toast { background: rgba(14,41,52,.88); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-radius: 14px; box-shadow: var(--shadow-3); }
/* Notas y avisos: caja tintada sin banda lateral */
.note { border-left: 0; box-shadow: none; border-radius: 12px; padding: 10px 12px; }
.alert { border-left: 0; box-shadow: none; border-radius: 12px; padding: 10px 12px; }

/* Selector segmentado del formulario de vídeo */
.seg span { border: 0; background: linear-gradient(180deg, #fff, #F3F5F6); box-shadow: 0 0 0 1px var(--hairline), 0 1px 2px rgba(14,41,52,.06); }
.seg input:checked + span { background: var(--ink-grad); box-shadow: 0 2px 6px rgba(14,41,52,.3); }

@media (prefers-reduced-motion: reduce) { *, *::before { transition: none !important; animation: none !important; } }
.hero .who { flex-wrap: wrap; }
.btn.wa { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.btn.wa::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #25D366; box-shadow: 0 0 6px #25D366; }
.btn.wa:hover { background: rgba(255,255,255,.2); box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }

/* ---------- Cuenta, sincronización y acceso ---------- */
.top-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account { display: flex; align-items: center; gap: 8px; color: #C9D6DC; font-size: 14px; }
.account:empty { display: none; }
.who-am-i { white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .who-am-i { display: none; } }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #34C759; box-shadow: 0 0 6px rgba(52,199,89,.8); flex: none; }
.sync-dot.pending { background: var(--gold); box-shadow: 0 0 6px rgba(246,178,51,.8); }
.btn.ghost-dark { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.16); }
.btn.ghost-dark:hover { background: rgba(255,255,255,.18); }
.btn.block { width: 100%; padding: 12px; font-size: 16px; }

.login { max-width: 420px; margin: 24px auto 0; text-align: center; }
.login-logo { display: block; margin: 0 auto 16px; padding: 12px; border-radius: 24px; background: var(--ink-grad); box-shadow: var(--shadow-2); width: 96px; height: 96px; }
.login h1 { font-size: 28px; }
.login .lead { margin-bottom: 24px; }
.login-seg { justify-content: center; margin-bottom: 16px; }
.login-card { text-align: left; padding: 20px; }
.code-input { font-size: 22px !important; letter-spacing: .18em; text-transform: uppercase; text-align: center; font-weight: 500; }
.login-error { color: var(--warn); min-height: 1.4em; margin: 12px 0 0; font-weight: 500; }

.access-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 12px 16px; border-radius: 14px; background: linear-gradient(180deg, #F7F9FA, #EEF2F4); box-shadow: inset 0 0 0 1px var(--hairline); }
.access-code { font-size: 22px; font-weight: 700; letter-spacing: .14em; font-variant-numeric: tabular-nums; color: var(--ink); }
.upload-progress { margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.code-input::placeholder { text-transform: none; letter-spacing: normal; font-size: 16px; font-weight: 400; color: var(--dark-40); }
.criteria li { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.criteria li .btn { flex: none; margin-top: -3px; }

/* ---------- Producción: privacidad, contraseña y datos del paciente ---------- */
.foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.check-line { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.45; cursor: pointer; }
.check-line input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ink, #0E2934); }
.login-card a { color: var(--ink, #0E2934); font-weight: 500; }
.danger-zone h2 { margin-top: 0; }
.danger-zone p { margin: 0 0 12px; }
.btn.danger { color: var(--warn); box-shadow: inset 0 0 0 1px #F1C4C4; background: #fff; }
.btn.danger:hover { background: #FBEAEA; }
.login-error:empty { display: none; }

/* La cabecera ocupa todo el ancho: nada puede ensanchar la página en el móvil */
html, body { overflow-x: clip; }
.account { flex-wrap: nowrap; }
.btn.icon { width: 32px; padding: 0; display: inline-grid; place-items: center; }
.btn.icon svg { width: 16px; height: 16px; }
.btn.icon { flex: none; }
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .top-right { gap: 8px; }
  .role-switch button { min-width: 0; padding: 7px 12px; }
  .account { gap: 6px; }
}
.account .btn { height: 32px; } .btn.icon { width: 32px; }

/* Fases: todas visibles (sin desplazamiento ni barra gris). Apagadas por defecto; la que se ve, encendida */
.phases { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; overflow: visible; padding-bottom: 0; }
.phase-pill {
  outline: none; white-space: normal; line-height: 1.3; min-height: 40px; font-weight: 500;
  background: #EEF1F3; color: #8A979D; box-shadow: none;
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease), transform .1s;
}
.phase-pill.done { background: #F8F0DF; color: #A88A4E; box-shadow: none; }
.phase-pill.current { background: #E1EAED; color: #3E5A65; box-shadow: none; }
.phase-pill.current::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
button.phase-pill:hover { color: #3E5A65; }
button.phase-pill:active { transform: scale(.98); }
/* Encendida: la fase que el fisio está viendo, o la fase actual en la vista del paciente */
.phase-pill.view, div.phase-pill.current {
  background: var(--gold-grad, #F6B233); color: var(--dark);
  box-shadow: 0 2px 8px rgba(246,178,51,.35), inset 0 1px 0 rgba(255,255,255,.4);
}
.phase-pill.view.current, div.phase-pill.current { color: var(--dark); }
.tabs { scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }

/* Reproductor de YouTube propio: sin capa de controles de YouTube */
.yt-wrap { position: relative; border-radius: 10px; overflow: hidden; background: #000; margin-bottom: 4px; }
.yt-wrap iframe { margin: 0 !important; border-radius: 0 !important; pointer-events: none; }
.yt-tap { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; padding: 0; }
/* Icono de play: solo en pausa; al reproducir desaparece sin transición */
.yt-wrap[data-yt-state="paused"] .yt-tap { background: rgba(0,0,0,.35); }
.yt-wrap[data-yt-state="paused"] .yt-tap::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%;
  background: rgba(255,255,255,.92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z' fill='%230E2934'/%3E%3C/svg%3E") center/30px no-repeat;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.yt-fs { position: absolute; right: 10px; bottom: 10px; width: 36px; height: 36px; border: 0; border-radius: 10px; display: grid; place-items: center;
  background: rgba(0,0,0,.45); color: #fff; cursor: pointer; opacity: .85; }
.yt-fs svg { width: 18px; height: 18px; }
.yt-wrap:fullscreen { border-radius: 0; display: grid; place-items: center; }
.yt-wrap:fullscreen iframe { width: 100vw; height: 100vh; aspect-ratio: auto; }
.yt-cover { position: absolute; inset: 0; background: #000 center/cover no-repeat; display: none; place-items: center; pointer-events: none; }
.yt-wrap[data-yt-cover] .yt-cover { display: grid; }
.yt-wrap[data-yt-cover] .yt-tap::after { display: none; }
.yt-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; animation: yt-spin .8s linear infinite; }
@keyframes yt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .yt-spin { animation-duration: 2s; } }
.yt-preview { display: flex; align-items: center; gap: 12px; margin: -4px 0 12px; }
.yt-preview:empty { display: none; }
.yt-preview img { width: 160px; height: 90px; object-fit: cover; border-radius: 10px; flex: none; }
/* Vídeos propios (a menudo grabados en vertical): se adaptan a su forma, sin franjas negras */
.video-frame video { aspect-ratio: auto; max-height: 70vh; width: auto; max-width: 100%; margin: 0 auto 4px; }

/* Acceso del paciente: móvil + código de 6 cifras */
.phone-input { font-size: 20px !important; letter-spacing: .04em; text-align: center; font-variant-numeric: tabular-nums; }
.access-box .phone-input { font-size: 16px !important; text-align: left; flex: 1; min-width: 180px; height: 36px; padding: 0 12px; border: 1px solid var(--dark-20); border-radius: 10px; }
.access-box > div:first-child { min-width: 0; }
.access-data { display: flex; flex-wrap: wrap; gap: 8px 32px; }
.access-phone { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; color: var(--ink); }
.access-box a.btn { text-decoration: none; }

/* Elegir vídeo: botón grande en lugar del control de archivo del navegador */
.file-pick { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 12px 16px;
  border-radius: 14px; border: 1.5px dashed var(--dark-20); background: #F6F8F9; color: var(--ink); font-weight: 500; cursor: pointer; margin-bottom: 6px;
  transition: background .15s, border-color .15s; text-align: center; }
.file-pick:hover { background: #EEF2F4; }
.file-pick.chosen { border-style: solid; border-color: var(--gold); background: var(--gold-20); }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-pick svg { width: 22px; height: 22px; flex: none; }
.file-pick-txt { overflow-wrap: anywhere; }
