/* Lenguaje visual: "Liquid Glass" estilo iOS — superficies traslúcidas con
   blur sobre un fondo con manchas de color azul, bordes muy redondeados,
   tipografía del sistema (misma familia visual que Finanzas Personales). */
:root {
  --paper: #EAF1FC;
  --paper-raised: rgba(255,255,255,0.66);
  --paper-sunken: rgba(112,146,204,0.12);
  --ink: #10151F;
  --ink-soft: #5B677A;
  --ink-faint: #8C97A8;
  --line: rgba(255,255,255,0.5);

  --accent: #007AFF;
  --accent-ink: #0058C6;
  --accent-soft: rgba(0,122,255,0.12);

  --study: #2660C9;
  --study-soft: #CDE2FF;
  --wellness: #1B8A5A;
  --wellness-soft: #C7F2DA;
  --institute: #7C3AED;
  --institute-soft: #E4D6FA;
  --neutral-chip: #6B7280;
  --neutral-chip-soft: #EEF0F4;

  --danger: #FF3B30;
  --success: #34C759;

  --shadow: 0 8px 32px rgba(10,40,90,0.10), 0 2px 10px rgba(10,40,90,0.06);
  --radius: 24px;
  --radius-sm: 16px;
  --radius-pill: 999px;
  --glass-blur: blur(24px) saturate(180%);

  --bg-blob-1: radial-gradient(1100px 700px at 12% -8%, rgba(0,122,255,0.20), transparent 60%);
  --bg-blob-2: radial-gradient(900px 650px at 105% 0%, rgba(100,210,255,0.18), transparent 55%);
  --bg-blob-3: radial-gradient(900px 800px at 50% 115%, rgba(0,122,255,0.10), transparent 60%);

  /* El riel lateral es vidrio oscuro fijo (no cambia con el tema): es la
     identidad estable del sistema, como la cubierta de una agenda. */
  --rail-bg: rgba(15,18,28,0.6);
  --rail-line: rgba(255,255,255,0.08);
  --rail-ink: #FFFFFF;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #070A12;
    --paper-raised: rgba(255,255,255,0.07);
    --paper-sunken: rgba(0,0,0,0.28);
    --ink: #EDEFF5;
    --ink-soft: #9AA1B4;
    --ink-faint: #5B6175;
    --line: rgba(255,255,255,0.10);

    --accent: #0A84FF;
    --accent-ink: #409CFF;
    --accent-soft: rgba(10,132,255,0.20);

    --study: #7FB0FF;
    --study-soft: #17233D;
    --wellness: #6FE3AE;
    --wellness-soft: #16302A;
    --institute: #B79CFF;
    --institute-soft: #241C3A;
    --neutral-chip: #9AA1B4;
    --neutral-chip-soft: #1B1E28;

    --danger: #FF453A;
    --success: #30D158;

    --shadow: 0 10px 30px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.3);
    --bg-blob-1: radial-gradient(1100px 700px at 12% -8%, rgba(10,132,255,0.30), transparent 60%);
    --bg-blob-2: radial-gradient(900px 650px at 105% 0%, rgba(64,156,255,0.20), transparent 55%);
    --bg-blob-3: radial-gradient(900px 800px at 50% 115%, rgba(10,132,255,0.16), transparent 60%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #070A12;
  --paper-raised: rgba(255,255,255,0.07);
  --paper-sunken: rgba(0,0,0,0.28);
  --ink: #EDEFF5;
  --ink-soft: #9AA1B4;
  --ink-faint: #5B6175;
  --line: rgba(255,255,255,0.10);

  --accent: #0A84FF;
  --accent-ink: #409CFF;
  --accent-soft: rgba(10,132,255,0.20);

  --study: #7FB0FF;
  --study-soft: #17233D;
  --wellness: #6FE3AE;
  --wellness-soft: #16302A;
  --institute: #B79CFF;
  --institute-soft: #241C3A;
  --neutral-chip: #9AA1B4;
  --neutral-chip-soft: #1B1E28;

  --danger: #FF453A;
  --success: #30D158;

  --shadow: 0 10px 30px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.3);
  --bg-blob-1: radial-gradient(1100px 700px at 12% -8%, rgba(10,132,255,0.30), transparent 60%);
  --bg-blob-2: radial-gradient(900px 650px at 105% 0%, rgba(64,156,255,0.20), transparent 55%);
  --bg-blob-3: radial-gradient(900px 800px at 50% 115%, rgba(10,132,255,0.16), transparent 60%);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg-blob-1), var(--bg-blob-2), var(--bg-blob-3), var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  font-size: 15.5px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  display: flex;
  justify-content: center;
  padding: clamp(0px, 2vw, 22px);
}
/* El panel principal (index.php) va de borde a borde, sin la tarjeta
   flotante con margen que usan las pantallas de login/setup. */
body:has(.app) { padding: 0; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

h1, h2, h3 {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  text-wrap: balance;
  margin: 0;
  color: var(--ink);
}

h1 { font-size: clamp(24px, 3.4vw, 32px); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
h3 { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }

.mono { font-variant-numeric: tabular-nums; font-weight: 600; }

a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { color: var(--accent-ink); }

button { font: inherit; }

/* ---------- app shell: sidebar rail + main ---------- */

.app {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 100vh;
  background: transparent;
}

/* Pantallas grandes: más aire y columnas adicionales en vez de solo
   dejar la franja central más ancha. */
@media (min-width: 1400px) {
  .main { padding: 40px 48px; }
  .main-inner { max-width: 1320px; gap: 26px; }
  .grid3 { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .grid2 { grid-template-columns: 1fr 1fr; gap: 20px; }
  .focus-wrap { gap: 24px; }
  h1 { font-size: 36px; }
}

.rail {
  flex: none;
  width: 232px;
  background: var(--rail-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--rail-line);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  align-self: stretch;
  overflow-y: auto;
}
@media (max-width: 900px) {
  .rail { width: 76px; }
  .rail-brand-text, .rail-item span { display: none; }
  .rail-brand { justify-content: center; }
  .rail-item { justify-content: center; }
}

/* Teléfono: el riel pasa de barra lateral a barra inferior fija, como
   una app móvil normal — así el contenido usa todo el ancho. */
@media (max-width: 640px) {
  .app { flex-direction: column; }
  .rail {
    position: fixed;
    top: auto;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding: 6px 4px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--rail-line);
    z-index: 40;
  }
  .rail-top { flex-direction: row; gap: 0; width: 100%; justify-content: space-around; }
  .rail-brand { display: none; }
  .rail-item { flex-direction: column; gap: 2px; padding: 6px 4px; width: auto; border-radius: 10px; }
  .rail-item svg { width: 21px; height: 21px; }
  .rail-logout { margin-top: 0; }
  .main { padding-bottom: 88px; }
}

.rail-top { display: flex; flex-direction: column; gap: 4px; }

.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rail-line);
}
.rail-brand-mark {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.rail-brand-text { display: flex; flex-direction: column; line-height: 1.2; overflow: hidden; }
.rail-brand-text strong { font-size: 14.5px; font-weight: 800; white-space: nowrap; }
.rail-brand-text span { font-size: 11px; color: rgba(255,255,255,0.5); white-space: nowrap; }

.rail-item {
  appearance: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  text-align: left;
}
.rail-item svg {
  flex: none;
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rail-item span { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.rail-item:hover { color: #fff; background: rgba(255,255,255,0.06); }
.rail-item.active { color: #fff; background: rgba(255,255,255,0.12); }
.rail-item.active span { font-weight: 700; }
.rail-logout { margin-top: 10px; }
.rail-logout:hover { color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  padding: clamp(18px, 3vw, 34px);
  background: transparent;
  display: flex;
  justify-content: center;
}

.main-inner {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.crumb {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-faint);
}
.crumb::before { content: "Alameta / "; color: var(--ink-faint); }
.crumb span { color: var(--ink-soft); }

.page-subtitle {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* ---------- header / ticket ---------- */

header.top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
@media (max-width: 560px) {
  header.top { grid-template-columns: 1fr; }
  .header-actions { justify-content: space-between; }
  .ticket { min-width: 0; flex: 1; text-align: left; }
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper-raised);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
  color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-soft); }
.theme-toggle svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.ticket {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 22px;
  min-width: 190px;
  text-align: right;
}
.ticket-days {
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  color: var(--accent);
}
.ticket-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); margin-top: 2px; }
.ticket input[type="date"] {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--paper-sunken);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  width: 100%;
}

/* ---------- view switching ---------- */

.view { display: none; flex-direction: column; gap: 22px; }
.view.active { display: flex; }

.day-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.btn-ghost {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink-soft);
  background: var(--paper-raised);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }

.btn-primary {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 11px 22px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

/* ---------- today timeline ---------- */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block {
  display: grid;
  grid-template-columns: 70px 4px 1fr 22px;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--paper-raised);
  box-shadow: var(--shadow);
}
@media (max-width: 400px) {
  .block { grid-template-columns: 52px 3px 1fr 20px; gap: 8px; padding: 12px 14px; }
}
.block .stripe { align-self: stretch; border-radius: 3px; background: var(--line); }
.block .time { font-size: 12px; font-weight: 700; color: var(--ink-faint); white-space: nowrap; }
.block .title { font-weight: 700; font-size: 15px; }
.block .sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }

.block[data-cat="estudio"] { background: var(--study-soft); }
.block[data-cat="estudio"] .title { color: var(--study); }
.block[data-cat="estudio"] .stripe { background: var(--study); }
.block[data-cat="salud"] { background: var(--wellness-soft); }
.block[data-cat="salud"] .title { color: var(--wellness); }
.block[data-cat="salud"] .stripe { background: var(--wellness); }
.block[data-cat="instituto"] { background: var(--institute-soft); }
.block[data-cat="instituto"] .title { color: var(--institute); }
.block[data-cat="instituto"] .stripe { background: var(--institute); }
.block[data-cat="logistica"] { background: var(--paper-sunken); }
.block[data-cat="logistica"] .title { color: var(--ink); }
.block[data-cat="logistica"] .stripe { background: var(--line); }

.block .check {
  appearance: none;
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  background: var(--paper-raised);
}
.block .check:checked { background: var(--accent); border-color: var(--accent); }
.block .check:checked::after {
  content: "";
  position: absolute; left: 7px; top: 3px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.block.done { opacity: .6; }
.block.done .title, .block.done .sub { text-decoration: line-through; text-decoration-color: var(--ink-faint); }

/* ---------- toolbar (Semana) ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--paper-raised);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
}
.toolbar-group { display: flex; gap: 6px; }
.toolbar .btn-ghost { background: var(--paper-sunken); }

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.date-pill svg {
  flex: none;
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-width: 180px;
  flex: 0 1 240px;
}
.toolbar-search svg {
  flex: none;
  width: 15px; height: 15px;
  fill: none;
  stroke: var(--ink-faint);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.toolbar-search input {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  width: 100%;
}
.toolbar-search input::placeholder { color: var(--ink-faint); }

/* ---------- week calendar grid ---------- */

.week-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--paper-raised);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 10px;
}

.week-grid-header, .week-grid-body { display: grid; grid-template-columns: 52px repeat(7, minmax(96px, 1fr)); min-width: 760px; }

.week-grid-header { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.week-day-head { text-align: center; padding: 4px 2px; border-radius: var(--radius-sm); }
.week-day-head .dow { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.week-day-head .num { font-size: 19px; font-weight: 800; margin-top: 2px; }
.week-day-head.today { background: var(--accent-soft); padding-top: 4px; padding-bottom: 4px; }
.week-day-head.today .num, .week-day-head.today .dow { color: var(--accent-ink); }

.week-grid-body { position: relative; padding-top: 8px; }
.week-hours { position: relative; }
.week-hour-label {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-faint);
}
.week-days { display: contents; }
.week-day-col {
  position: relative;
  border-left: 1px solid var(--line);
  /* el degradado de líneas de hora se fija en JS (depende de PX_PER_MIN) */
}
.week-day-col.today { background-color: var(--accent-soft); }

.week-block {
  position: absolute;
  left: 3px; right: 3px;
  border-radius: 5px;
  padding: 4px 7px;
  overflow: hidden;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: opacity .12s ease;
}
.week-block .wb-time { font-size: 9px; font-weight: 500; opacity: .7; display: block; white-space: nowrap; }
.week-block .wb-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.week-block.compact { padding: 3px 7px; }
.week-block.compact .wb-title { font-size: 9.5px; }
.week-block.sliver { padding: 0; min-height: 4px; }
.week-block.cat-estudio { background: var(--study-soft); color: var(--study); }
.week-block.cat-salud { background: var(--wellness-soft); color: var(--wellness); }
.week-block.cat-instituto { background: var(--institute-soft); color: var(--institute); }
.week-block.cat-logistica { background: var(--neutral-chip-soft); color: var(--neutral-chip); }
.week-block.done { opacity: .45; }
.week-block.dim { opacity: .12; }
.week-block:hover { filter: brightness(0.96); }

.now-line {
  position: absolute;
  left: -1px; right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 5;
}
.now-line::before {
  content: "";
  position: absolute;
  left: -4px; top: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  transform: translateY(-50%);
}

.legend { display: flex; gap: 18px; flex-wrap: wrap; padding-left: 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.estudio { background: var(--study); }
.dot.salud { background: var(--wellness); }
.dot.instituto { background: var(--institute); }
.dot.logistica { background: var(--neutral-chip); }

/* ---------- focus mode ---------- */

.focus-wrap { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 720px) { .focus-wrap { grid-template-columns: 1fr; } }

.focus-card { text-align: center; padding: 36px 26px; }
.focus-title { font-weight: 800; font-size: clamp(24px, 3.4vw, 34px); margin-top: 8px; }
.focus-sub { color: var(--ink-soft); margin-top: 4px; font-size: 14px; font-weight: 600; }
.focus-progress-track { height: 8px; background: var(--paper-sunken); border-radius: 999px; margin-top: 22px; overflow: hidden; }
.focus-progress-fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0%; transition: width 1s linear; }
.focus-time-left { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--ink-faint); }

.timer-card { display: flex; flex-direction: column; align-items: center; }
.timer-display { font-size: 52px; font-weight: 800; color: var(--accent); margin: 10px 0 2px; }
.timer-mode { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.timer-controls { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- progress stats ---------- */

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1024px) { .grid3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid3 { grid-template-columns: 1fr; } }

.stat-card { text-align: left; }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }
.stat-value { font-size: 30px; font-weight: 800; margin-top: 6px; color: var(--accent); }
.stat-hint { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-top: 2px; }
.bar-track { height: 8px; background: var(--paper-sunken); border-radius: 999px; margin-top: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0%; }

/* ---------- shared panels ---------- */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.card {
  background: var(--paper-raised);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.card.health { border-top: 3px solid var(--wellness); }
.card.method { border-top: 3px solid var(--institute); }

.creatine-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--wellness-soft);
  border-radius: var(--radius-sm);
}
.creatine-row input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--wellness); cursor: pointer; flex: none;
}
.creatine-row label { font-weight: 700; cursor: pointer; color: var(--ink); }

.cups { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.cup {
  width: 32px; height: 32px;
  border: 1.5px solid var(--wellness);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: var(--wellness);
  display: flex; align-items: center; justify-content: center;
}
.cup.filled { background: var(--wellness); color: #fff; }

.note { font-size: 13.5px; color: var(--ink-soft); margin-top: 10px; }
.note strong { color: var(--ink); }

.hours-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.hour-row { display: grid; grid-template-columns: 130px 1fr 46px; gap: 10px; align-items: center; }
.hour-row .label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.hour-row .bar-track { height: 9px; background: var(--paper-sunken); border-radius: 999px; overflow: hidden; margin-top: 0; }
.hour-row .bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.hour-row.hue-0 .bar-fill { background: var(--study); }
.hour-row.hue-1 .bar-fill { background: var(--wellness); }
.hour-row.hue-2 .bar-fill { background: var(--institute); }
.hour-row.hue-3 .bar-fill { background: var(--accent); }
.hour-row .val { font-size: 12px; font-weight: 700; text-align: right; color: var(--ink-faint); }

footer.legal { font-size: 12px; font-weight: 600; color: var(--ink-faint); text-align: center; padding-top: 6px; }

/* ---------- auth forms (login.php / setup.php) ---------- */

.wrap { max-width: 980px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

.text-input {
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  background: var(--paper-sunken);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 4px;
}

/* ---------- ajustes: segmented control + settings rows ---------- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 10px;
}
.segmented button {
  border: none;
  background: var(--paper-raised);
  color: var(--ink-soft);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--accent); color: #fff; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.settings-row.col { flex-direction: column; align-items: stretch; }
.settings-row.col label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }

/* ---------- modal (editor de bloques) ---------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 22%, transparent);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(20,25,40,0.22), 0 4px 14px rgba(20,25,40,0.12);
}
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
#blockDeleteBtn { color: var(--danger); border-color: var(--danger); }
#blockDeleteBtn:hover { background: var(--danger); color: #fff; }

.time-range-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.time-arrow { padding-bottom: 11px; color: var(--ink-faint); font-weight: 700; }

.color-swatches { display: flex; gap: 10px; margin-top: 6px; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
}
.swatch.cat-estudio { background: var(--study); }
.swatch.cat-salud { background: var(--wellness); }
.swatch.cat-instituto { background: var(--institute); }
.swatch.cat-logistica { background: var(--neutral-chip); }
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper-raised); }
.swatch.active::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 5px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: translate(-70%, -60%) rotate(45deg);
}

/* ---------- notas del día + pendientes ---------- */

.note-textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
}

.todo-add-row { display: flex; gap: 8px; }
.todo-add-row .text-input { margin-top: 0; }
.todo-add-row button { flex: none; width: 42px; font-size: 18px; line-height: 1; padding: 0; }

.todo-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 260px; overflow-y: auto; }
.todo-empty { font-size: 13px; color: var(--ink-faint); padding: 6px 2px; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
}
.todo-item input[type="checkbox"] {
  appearance: none;
  flex: none;
  width: 19px; height: 19px;
  border: 2px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  position: relative;
  background: var(--paper-raised);
}
.todo-item input[type="checkbox"]:checked { background: var(--institute); border-color: var(--institute); }
.todo-item input[type="checkbox"]:checked::after {
  content: "";
  position: absolute; left: 6px; top: 2px;
  width: 4px; height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.todo-item span { flex: 1; font-size: 13.5px; font-weight: 600; }
.todo-item.done span { opacity: .5; text-decoration: line-through; }
.todo-item .todo-delete {
  flex: none;
  border: none;
  background: none;
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.todo-item .todo-delete:hover { color: var(--danger); }

/* ---------- temporizador flotante (visible en toda la app) ---------- */

.mini-timer {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--paper-raised);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 10px 18px 10px 14px;
  cursor: pointer;
}
.mini-timer:hover { border-color: var(--accent-soft); }
.mini-timer-dot {
  width: 17px; height: 17px;
  border-radius: 50%;
  flex: none;
  position: relative;
  background: conic-gradient(var(--accent) calc(var(--pct, 0) * 1%), var(--line) 0);
}
.mini-timer-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--paper-raised);
}
.mini-timer.running .mini-timer-dot { animation: mini-timer-pulse 1.4s ease-in-out infinite; }
@keyframes mini-timer-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.mini-timer-time { font-size: 15px; font-weight: 800; color: var(--ink); }
.mini-timer-mode { font-size: 11px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.mini-timer.hidden { display: none; }

@media (max-width: 640px) {
  .mini-timer { right: 14px; bottom: 96px; padding: 8px 14px 8px 12px; }
  .mini-timer-mode { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mini-timer.running .mini-timer-dot { animation: none; }
}

/* ---------- resumen del día + día libre + bloques atrasados ---------- */

.excuse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
}
.excuse-toggle input { accent-color: var(--institute); cursor: pointer; }
.excuse-toggle:has(input:checked) { color: var(--institute); border-color: var(--institute); background: var(--institute-soft); }

.today-summary {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 2px 2px 4px;
}
.today-summary strong { color: var(--ink); }
.today-summary.all-done { color: var(--wellness); }

.block.late { box-shadow: 0 0 0 2px var(--danger) inset, var(--shadow); }
.block.late .time { color: var(--danger); }
.block.excused-day { opacity: .55; }

/* ---------- rachas de salud ---------- */

.streak-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.streak-chip {
  font-size: 12px;
  font-weight: 700;
  color: var(--wellness);
  background: var(--wellness-soft);
  padding: 6px 12px;
  border-radius: 999px;
}

/* ---------- aviso de ritmo ---------- */

.advice-banner { display: none; }
.advice-banner.show {
  display: block;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
}
.advice-banner.sobrecarga { display: block; background: color-mix(in srgb, var(--danger) 12%, var(--paper-raised)); color: var(--danger); border: 1px solid var(--danger); }
.advice-banner.descanso { display: block; background: var(--wellness-soft); color: var(--wellness); border: 1px solid var(--wellness); }

/* ---------- logros ---------- */

.badges { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
  min-width: 92px;
  text-align: center;
}
.badge-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--line); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; color: var(--paper-raised); }
.badge-label { font-size: 11px; font-weight: 700; color: var(--ink-faint); }
.badge.earned { background: var(--institute-soft); }
.badge.earned .badge-icon { background: var(--institute); }
.badge.earned .badge-label { color: var(--institute); }

.wb-gallery-empty { font-size: 13px; color: var(--ink-faint); }

/* ---------- cuaderno de errores (texto) ---------- */

.error-log-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.error-log-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
}
.error-log-item.reviewed { opacity: .55; }
.error-log-check { padding: 6px 10px; white-space: nowrap; }
.error-log-subject { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--institute); }
.error-log-question { font-size: 14px; font-weight: 600; color: var(--ink); margin-top: 3px; white-space: pre-wrap; }
.error-log-explanation { font-size: 13px; color: var(--ink-soft); margin-top: 6px; white-space: pre-wrap; }
.error-log-item .todo-delete { margin-top: 2px; }

/* ---------- material (archivos en el servidor) ---------- */

.material-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
@media (max-width: 720px) { .material-layout { grid-template-columns: 1fr; } }

.material-sidebar { padding: 16px; }
.material-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.material-sidebar-head h3 { margin: 0; }

.btn-icon {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper-sunken);
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.material-subject-list { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; max-height: 60vh; overflow-y: auto; }
.material-subject-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
}
.material-subject-item:hover { background: var(--paper-sunken); }
.material-subject-item.active { background: var(--accent-soft); border-color: var(--accent); }
.material-subject-item.active .material-subject-name { color: var(--accent); }
.material-subject-item svg { flex: none; width: 17px; height: 17px; stroke: var(--ink-faint); fill: none; stroke-width: 1.8; }
.material-subject-item.active svg { stroke: var(--accent); }
.material-subject-name { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-subject-meta { font-size: 10.5px; color: var(--ink-faint); flex: none; }
.material-subject-actions { display: none; flex: none; gap: 2px; }
.material-subject-item:hover .material-subject-actions { display: flex; }
.material-subject-actions button {
  border: none;
  background: none;
  color: var(--ink-faint);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 3px;
}
.material-subject-actions button:hover { color: var(--accent); }
.material-subject-actions button.danger:hover { color: var(--danger); }

.material-panel { min-height: 320px; }
.material-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.material-toolbar h3 { margin: 0; flex: none; }
.material-toolbar .text-input, .material-toolbar select.text-input { margin-top: 0; width: auto; flex: 1 1 160px; }
.material-upload-btn { cursor: pointer; display: inline-flex; align-items: center; flex: none; }
.material-upload-btn.disabled { opacity: .5; pointer-events: none; }

.material-dropzone { border-radius: var(--radius-sm); transition: background .15s, outline-color .15s; outline: 2px dashed transparent; outline-offset: -2px; }
.material-dropzone.drag-over { background: var(--accent-soft); outline-color: var(--accent); }

.material-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.material-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
}
.material-item-icon { flex: none; width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--paper-raised); }
.material-item-icon svg { width: 16px; height: 16px; stroke: var(--ink-soft); fill: none; stroke-width: 1.8; }
.material-item-name { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-item-meta { font-size: 11.5px; color: var(--ink-faint); flex: none; }
.material-item a { font-size: 12px; font-weight: 700; flex: none; }

/* ---------- barra de herramientas compartida (Entrenamiento/Hábitos/Proyectos) ---------- */
.entreno-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Temporizador de descanso ---------- */
.rest-timer-card { text-align: center; }
.rest-timer-display { font-size: 44px; font-weight: 800; letter-spacing: -0.02em; margin: 10px 0 16px; color: var(--accent); }
.rest-timer-presets { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.rest-timer-actions { display: flex; justify-content: center; gap: 10px; }

/* ---------- Entrenamiento ---------- */
.entreno-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.entreno-item { background: var(--paper-sunken); border-radius: var(--radius-sm); padding: 14px 16px; }
.entreno-item-head { display: flex; align-items: center; gap: 10px; }
.entreno-done-check { width: 19px; height: 19px; flex: none; accent-color: var(--accent); }
.entreno-item-name { flex: 1; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.entreno-item.done .entreno-item-name { color: var(--ink-soft); text-decoration: line-through; }
.entreno-item-target { font-size: 12px; font-weight: 600; color: var(--ink-faint); }
.entreno-item-row { display: flex; align-items: end; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.entreno-item-row label { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }
.entreno-input { width: 72px; margin-top: 0 !important; }
.entreno-item-row .btn-ghost { align-self: flex-end; }
.entreno-item-last { margin-top: 8px; font-size: 12px; color: var(--ink-faint); }

/* ---------- Hábitos ---------- */
.habit-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.habit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--paper-sunken);
}
.habit-check { width: 19px; height: 19px; flex: none; accent-color: var(--accent); }
.habit-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--ink); }
.habit-item.done .habit-name { color: var(--ink-soft); }

/* ---------- Proyectos ---------- */
.project-list { display: flex; flex-direction: column; gap: 16px; margin-top: 14px; }
.project-item { background: var(--paper-sunken); border-radius: var(--radius); padding: 18px 20px; }
.project-item.completado { opacity: .6; }
.project-item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.project-item-name { flex: 1; font-size: 15.5px; font-weight: 800; color: var(--ink); }
.project-item.completado .project-item-name { text-decoration: line-through; }
.project-priority {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}
.priority-alta { background: rgba(255,59,48,0.14); color: var(--danger); }
.priority-media { background: var(--accent-soft); color: var(--accent); }
.priority-baja { background: var(--neutral-chip-soft); color: var(--neutral-chip); }
.project-due { font-size: 12px; font-weight: 600; color: var(--ink-faint); }
.project-progress-label { font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; }
.project-tasks { margin-top: 12px; max-height: none; }
.project-item .todo-add-row { margin-top: 10px; }

