/* ============ RESET + BASE ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  position: relative;
}

/* ============ ATMOSPHERIC BACKGROUND LAYERS ============ */
/* Ambient glow — luz suave de una dirección para dar dimensionalidad */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 1400px 800px at 15% -10%, var(--halo-1), transparent 55%),
    radial-gradient(ellipse 1000px 700px at 90% 100%, var(--halo-2), transparent 60%);
}

/* Fine grain — textura invisible que rompe el flat digital */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity, 0.05);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
}

.app { position: relative; z-index: 1; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; }

/* ============ THEME TOKENS — Variación 1: CANCHA ============ */
/* Cancha ahora es LIGHT MODE por defecto — fondo blanco cálido con acentos verdes */
.theme-cancha {
  --font-display: "Barlow Condensed", "Oswald", Impact, sans-serif;
  --font-body: "Barlow", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Fondos claros con matiz cálido, muy legibles */
  --bg: #f7f8f5;
  --bg-panel: #ffffff;
  --bg-elev: #ffffff;
  --bg-hover: #eef1eb;
  --line: rgba(20, 40, 30, 0.08);
  --line-strong: rgba(20, 40, 30, 0.18);
  --scroll: rgba(20, 40, 30, 0.2);

  /* Foreground oscuro con matiz verde muy sutil, alto contraste */
  --fg: #0f1f19;
  --fg-dim: #4a5850;
  --fg-muted: #7a877f;

  /* Verde deporte más profundo para modo claro */
  --accent: #1b8a4a;
  --accent-fg: #ffffff;
  --coral: #e35a3d;
  --azul: #2f74c9;
  --verde: #1b8a4a;
  --amarillo: #d99510;

  /* Halos para body::before — suaves */
  --halo-1: rgba(27, 138, 74, 0.08);    /* verde deporte arriba-izq */
  --halo-2: rgba(47, 116, 201, 0.05);   /* azul frío abajo-der */
  --grain-opacity: 0.025;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
}

/* ============ THEME TOKENS — Variación 2: CUADERNO ============ */
.theme-cuaderno {
  --font-display: "Fraunces", "Playfair Display", Georgia, serif;
  --font-body: "Source Serif Pro", "Lora", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Paleta papel envejecido con más profundidad */
  --bg: #f6efe1;
  --bg-panel: #fdf7ea;
  --bg-elev: #ffffff;
  --bg-hover: #ede4d0;
  --line: rgba(63,44,20,0.1);
  --line-strong: rgba(63,44,20,0.22);
  --scroll: rgba(63,44,20,0.18);

  --fg: #2b1e0e;
  --fg-dim: #6b5a44;
  --fg-muted: #a4937b;

  --accent: #c94d34;
  --accent-fg: #fff;
  --coral: #c94d34;
  --azul: #2f5d8a;
  --verde: #4a7c3a;
  --amarillo: #d4a017;

  --halo-1: rgba(201, 77, 52, 0.05);    /* coral tinta */
  --halo-2: rgba(212, 160, 23, 0.04);   /* ámbar cálido */
  --grain-opacity: 0.08;

  --radius-sm: 2px;
  --radius: 3px;
  --radius-lg: 6px;
}

/* ============ THEME TOKENS — Variación 3: PLAYFUL NEO ============ */
.theme-playful {
  --font-display: "Space Grotesk", "DM Sans", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Blanco puro con acentos violeta muy sutiles */
  --bg: #f6f7ff;
  --bg-panel: #ffffff;
  --bg-elev: #ffffff;
  --bg-hover: #eef0ff;
  --line: rgba(20, 30, 80, 0.08);
  --line-strong: rgba(20, 30, 80, 0.16);
  --scroll: rgba(20, 30, 80, 0.15);

  /* Foreground más contrastado */
  --fg: #0a0d38;
  --fg-dim: #3d4470;
  --fg-muted: #7278a0;

  --accent: #4d4ef0;
  --accent-fg: #fff;
  --coral: #ff5c7a;
  --azul: #4d4ef0;
  --verde: #16a34a;
  --amarillo: #f0b800;

  --halo-1: rgba(91, 92, 245, 0.09);    /* violeta principal */
  --halo-2: rgba(255, 122, 144, 0.05);  /* coral rosa */
  --grain-opacity: 0.03;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
}

/* Density */
.density-comfortable { --pad: 20px; --pad-sm: 14px; --gap: 14px; --row-h: 62px; }
.density-compact     { --pad: 14px; --pad-sm: 10px; --gap: 10px; --row-h: 48px; }

/* ============ APP LAYOUT ============ */
.app {
  display: grid;
  grid-template-columns: 244px 1fr 340px;
  height: 100vh;
  width: 100vw;
  background: transparent;
}

/* -------- SIDEBAR -------- */
.sidebar {
  background: color-mix(in oklab, var(--bg-panel) 88%, transparent);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  gap: 22px;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-fg);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.theme-cancha .brand-mark { border-radius: 4px; }
.theme-cuaderno .brand-mark { border-radius: 50%; font-family: var(--font-display); font-style: italic; }
.theme-playful .brand-mark { border-radius: 12px; transform: rotate(-6deg); }

.brand-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.theme-cancha .brand-name { text-transform: uppercase; letter-spacing: 0.02em; font-weight: 800; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  padding: 8px 10px 4px;
}
.nav-label-row { display: flex; align-items: center; justify-content: space-between; padding-right: 4px; }
.nav-label-row .nav-label { flex: 1; }
.nav-label-action {
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px;
  color: var(--fg-muted); background: transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-label-action:hover { background: var(--bg-hover); color: var(--fg); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--fg-dim);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--fg); }
.nav-item.active { background: var(--bg-hover); color: var(--fg); font-weight: 600; }
.theme-cancha .nav-item.active { background: var(--accent); color: var(--accent-fg); }
.theme-cuaderno .nav-item.active { background: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.theme-playful .nav-item.active { background: var(--accent); color: var(--accent-fg); border-radius: var(--radius); }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-groups { display: flex; flex-direction: column; gap: 4px; }
.group-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--fg-dim);
  border: 1px solid transparent;
  width: 100%;
  text-align: left;
}
.group-chip small { justify-self: end; }
.group-chip:hover { background: var(--bg-hover); color: var(--fg); }
.group-chip.active {
  background: var(--bg-elev);
  color: var(--fg);
  border-color: var(--line-strong);
  font-weight: 600;
}
.group-chip small { color: var(--fg-muted); font-family: var(--font-mono); font-size: 10px; white-space: nowrap; }
.group-chip.locked { opacity: 0.55; cursor: pointer; }
.group-chip.locked:hover { background: var(--bg-hover); opacity: 0.85; }
.group-chip.locked small { color: var(--accent); display: inline-flex; align-items: center; }
.sidebar-groups-upsell {
  display: block;
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.sidebar-groups-upsell:hover { text-decoration: underline; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.teacher-card { display: flex; align-items: center; gap: 10px; padding: 6px; }
.teacher-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-elev); border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.teacher-name { font-size: 13px; font-weight: 600; }
.teacher-role { font-size: 11px; color: var(--fg-muted); }

/* -------- MAIN -------- */
.main {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: transparent;
}
.main-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.header-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
}
.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.theme-cancha .page-title { text-transform: uppercase; letter-spacing: -0.005em; }
.theme-cuaderno .page-title { font-style: italic; font-weight: 500; }
.theme-playful .page-title { letter-spacing: -0.03em; }

.header-right { display: flex; align-items: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  color: var(--fg);
  background: var(--bg-panel);
  white-space: nowrap;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(0.94); }
.theme-cancha .btn-primary { text-transform: uppercase; letter-spacing: 0.04em; font-weight: 800; }
.theme-playful .btn-primary { box-shadow: 0 4px 0 rgba(20,30,80,0.15); }
.btn-danger {
  background: color-mix(in oklab, var(--coral, #c94d34) 90%, black);
  color: #fff;
  border-color: color-mix(in oklab, var(--coral, #c94d34) 90%, black);
}
.btn-danger:hover { filter: brightness(1.08); }
.btn[disabled], .btn-primary[disabled], .btn-danger[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Session summary bar */
.session-meta {
  display: flex; gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg-panel) 60%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  align-items: center;
  flex-wrap: wrap;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
}
.meta-value { font-size: 14px; font-weight: 600; }
.meta-value.big { font-family: var(--font-display); font-size: 22px; }

.goal-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.goal-chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--fg-dim);
}
.theme-cuaderno .goal-chip { border-radius: 3px; font-style: italic; }

/* Timeline area */
.timeline-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 40px;
}
.phase {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 24px;
  margin-bottom: 40px;
  position: relative;
}
/* Línea vertical conectora entre fases */
.phase::before {
  content: "";
  position: absolute;
  left: 34px;
  top: 60px;
  bottom: -32px;
  width: 1px;
  background: linear-gradient(180deg, var(--line-strong) 0%, transparent 100%);
  pointer-events: none;
}
.phase:last-child::before { display: none; }

.phase-marker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-top: 4px;
  position: relative;
  z-index: 1;
}
.phase-number {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.theme-cancha .phase-number { color: var(--accent); }
.theme-cuaderno .phase-number { color: var(--accent); font-style: italic; font-weight: 500; }
.theme-playful .phase-number { color: var(--accent); }

.phase-body { min-width: 0; }
.phase-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.phase-title-wrap { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.phase-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}
.phase-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.theme-cancha .phase-title { text-transform: uppercase; letter-spacing: -0.005em; }
.theme-cuaderno .phase-title { font-style: italic; font-weight: 500; }
.phase-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-dim);
  font-weight: 600;
  white-space: nowrap;
}

.blocks { display: flex; flex-direction: column; gap: 10px; }
.block {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 14px 20px 14px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: all 0.2s;
  min-height: var(--row-h);
  cursor: grab;
  position: relative;
  overflow: hidden;
}
.block::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  transition: width 0.2s;
}
.block.color-coral::before { background: var(--coral); }
.block.color-azul::before { background: var(--azul); }
.block.color-verde::before { background: var(--verde); }
.block.color-amarillo::before { background: var(--amarillo); }
.block:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px -12px rgba(0,0,0,0.15);
}
.theme-cancha .block:hover { box-shadow: 0 8px 24px -12px rgba(0,0,0,0.4); }
.block:hover::before { width: 6px; }

/* Drag & drop states */
.block.dragging {
  opacity: 0.35;
  cursor: grabbing;
  border-style: dashed;
}
.block.drag-over {
  box-shadow: 0 -3px 0 0 var(--accent);
  border-color: var(--accent);
}
.blocks.drag-active .add-slot {
  border-color: var(--accent);
  color: var(--accent);
}
.add-slot.drag-over {
  background: var(--accent);
  color: #fff;
  border-style: solid;
  border-color: var(--accent);
}
.add-slot.drag-over .add-slot-plus {
  border-color: #fff;
  color: #fff;
}
.lib-item.dragging {
  opacity: 0.4;
}
.lib-item[draggable="true"]:active {
  cursor: grabbing;
}

/* stripe deprecated but kept for backward compat with block-stripe class */
.block-stripe { display: none; }

/* Block icon (letter thumbnail) */
.block-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-left: 8px;
  position: relative;
  overflow: hidden;
}
.block-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0.08;
}
.block.color-coral .block-icon { color: var(--coral); }
.block.color-azul .block-icon { color: var(--azul); }
.block.color-verde .block-icon { color: var(--verde); }
.block.color-amarillo .block-icon { color: var(--amarillo); }
.block-icon-letter {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg);
  z-index: 1;
  position: relative;
  opacity: 0.9;
}

.block-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.block-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--fg);
}
.theme-cancha .block-name { font-weight: 700; }
.block-meta {
  display: flex; gap: 10px;
  font-size: 12px;
  color: var(--fg-muted);
  align-items: center;
  flex-wrap: wrap;
}
.block-meta span { display: inline-flex; align-items: center; gap: 5px; }
.block-meta-sep { opacity: 0.5; padding: 0 2px; }

.block-duration {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 0 4px;
}
.block-duration-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--fg);
}
.theme-cancha .block-duration-num { color: var(--accent); }
.block-duration-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.block-actions { display: flex; gap: 2px; opacity: 0.4; transition: opacity 0.2s; }
.block:hover .block-actions { opacity: 1; }
.icon-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  display: grid; place-items: center;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }

/* Intensity as bars (replaces dots for blocks) */
.intensity-bars {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}
.intensity-bar {
  width: 10px;
  height: 3px;
  border-radius: 2px;
  background: var(--fg-muted);
  opacity: 0.25;
  transition: opacity 0.15s;
}
.intensity-bar.on { opacity: 1; background: var(--accent); }
.theme-cuaderno .intensity-bar.on { background: var(--coral); }

/* dots kept for other places */
.intensity-dots { display: inline-flex; gap: 2px; align-items: center; }
.intensity-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--fg-muted);
  opacity: 0.3;
}
.intensity-dot.on { opacity: 1; background: var(--accent); }
.theme-cuaderno .intensity-dot.on { background: var(--coral); }

/* Add slot — más sutil, alineado a la izquierda */
.add-slot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  align-self: flex-start;
  margin-top: 2px;
}
.add-slot:hover {
  color: var(--fg);
  background: var(--bg-hover);
}
.add-slot-plus {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px dashed var(--line-strong);
  display: grid; place-items: center;
  font-size: 14px;
  font-weight: 400;
  color: var(--fg-muted);
  transition: all 0.15s;
}
.add-slot:hover .add-slot-plus {
  border-style: solid;
  border-color: var(--fg-muted);
  background: var(--bg-elev);
  color: var(--fg);
}

/* -------- RIGHT PANEL — LIBRARY -------- */
.library {
  background: color-mix(in oklab, var(--bg-panel) 88%, transparent);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.library-head { padding: 20px 22px 12px; }
.library-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.theme-cancha .library-title { text-transform: uppercase; }
.library-sub { font-size: 12px; color: var(--fg-muted); }

.search-wrap {
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
}
.search-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--fg);
  font-size: 13px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--fg-muted); }

.filter-row {
  display: flex; gap: 6px; padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.filter-chip {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  color: var(--fg-dim);
  background: transparent;
  text-transform: capitalize;
}
.filter-chip:hover { color: var(--fg); border-color: var(--fg-muted); }
.filter-chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.theme-cancha .filter-chip.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.theme-cuaderno .filter-chip { border-radius: 3px; }
.theme-cuaderno .filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.library-list { flex: 1; overflow-y: auto; padding: 8px 12px 20px; }
.lib-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: grab;
  transition: background 0.15s;
}
.lib-item:hover { background: var(--bg-hover); }
.lib-thumb {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  display: grid; place-items: center;
}
.lib-thumb::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent 0 6px, var(--line) 6px 7px);
  opacity: 0.6;
}
.lib-thumb-icon {
  position: relative;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--fg-dim);
}
.theme-playful .lib-thumb { border-radius: 12px; }
.theme-playful .lib-thumb::before { background: var(--accent); opacity: 0.15; }

.lib-body { flex: 1; min-width: 0; }
.lib-name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.lib-meta { font-size: 11px; color: var(--fg-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.lib-add {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  color: var(--fg-dim);
  display: grid; place-items: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.lib-add:hover { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Upcoming list mini */
.mini-list { display: flex; flex-direction: column; gap: 3px; }
.mini-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--fg-dim);
}
.mini-item:hover { background: var(--bg-hover); color: var(--fg); }
.mini-day {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-muted);
  min-width: 44px;
}
.mini-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-group {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-elev);
  color: var(--fg-muted);
}

/* Cancha-specific: pitch lines background on header */
.theme-cancha .main-header {
  background:
    linear-gradient(to bottom, transparent 0%, transparent 100%),
    repeating-linear-gradient(90deg, transparent 0 60px, rgba(212,255,63,0.03) 60px 61px);
}

/* Cuaderno-specific: paper lines on timeline */
.theme-cuaderno .timeline-wrap {
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(63,44,20,0.06) 31px 32px);
}
.theme-cuaderno .block { box-shadow: 1px 2px 0 rgba(63,44,20,0.05); }

/* Playful-specific: pop shadow on blocks */
.theme-playful .block { box-shadow: 0 1px 0 rgba(20,30,80,0.04); }
.theme-playful .block:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(91,92,245,0.12); }
.theme-playful .btn { box-shadow: 0 2px 0 rgba(20,30,80,0.06); }

/* ============================================================ */
/* ============ RESPONSIVE — TABLET (768px – 1279px) ========== */
/* ============================================================ */
/* Spec: colapsar panel derecho (biblioteca), quedarse en 2 columnas */
@media (max-width: 1279px) {
  .app {
    grid-template-columns: 76px 1fr;
  }

  /* Sidebar se convierte en riel de iconos: oculta labels, nombres y textos */
  .sidebar {
    padding: 16px 10px;
    align-items: center;
  }
  .brand-name,
  .nav-label,
  .nav-item-label,
  .group-chip span,
  .group-chip small,
  .teacher-name,
  .teacher-role {
    display: none;
  }
  .brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; padding: 10px; }
  .group-chip { grid-template-columns: 1fr; justify-content: center; padding: 9px; }
  .sidebar-groups { align-items: center; }
  .teacher-card { justify-content: center; padding: 6px 0; }
  .teacher-card > div:last-child { display: none; }

  /* Panel derecho de biblioteca (SessionView) se oculta en tablet */
  .library { display: none; }

  /* Cabecera principal (Biblioteca, Sesiones, etc.): en tablet el hueco
     horizontal se reduce, así que el botón "Nueva actividad"/"Nueva sesión"
     puede necesitar envolver debajo del título en pantallas más estrechas
     dentro de este rango; se permite el wrap en vez de desbordar. */
  .main-header { flex-wrap: wrap; row-gap: 10px; }

  /* Nota: los ajustes de grid-column para .lib-view (library-view.css) y
     .mob-stage (mobile-view.css) viven en sus propios archivos CSS, no aquí,
     porque esas hojas se cargan DESPUÉS de styles.css — una regla sin
     @media en ellas ganaría siempre a esta por orden de cascada. */
}

/* ============================================================ */
/* ============ RESPONSIVE — MOBILE (< 768px) ================== */
/* ============================================================ */
/* Spec: en móvil real solo tiene sentido la vista "En clase" (App.tsx
   fuerza view='mobile' por debajo de 768px vía JS). El sidebar de
   escritorio no cabe ni aporta valor aquí, así que se oculta y el
   stage móvil ocupa toda la pantalla sin el "bisel" de mockup. */
@media (max-width: 767px) {
  html, body { overflow: hidden; height: 100%; }

  .app {
    display: block;
    height: 100vh;
    width: 100%;
  }

  .sidebar { display: none; }

  .main:not(.lib-view),
  .library {
    display: none;
  }

  /* Cabecera principal: en móvil el título va arriba y los botones de
     acción ("Importar"/"Nueva actividad") debajo a ancho completo, en vez
     de intentar caber en una sola fila junto al título. */
  .main-header {
    flex-wrap: wrap;
    padding: 14px 16px;
    row-gap: 10px;
  }
  .header-right {
    width: 100%;
    justify-content: stretch;
  }
  .header-right .btn {
    flex: 1;
    justify-content: center;
  }

  /* Ajustes de .lib-view y .mob-stage (grid-column, tamaño del bisel del
     iPhone, etc.) viven en library-view.css y mobile-view.css respectivamente,
     ya que esas hojas se cargan después de esta y sus reglas base sin
     @media ganarían la cascada si se definieran aquí. */
}

/* ============================================================ */
/* ============ CUENTA: sidebar (invitado / logueado) ========= */
/* ============================================================ */
.acct-guest { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.acct-cta { width: 100%; justify-content: center; }
.acct-login-link {
  font-size: 12px; color: var(--fg-muted); text-align: center;
  text-decoration: underline; text-decoration-color: var(--line-strong);
}
.acct-login-link:hover { color: var(--fg); }

.acct-card { display: flex; flex-direction: column; gap: 6px; }
.acct-plan-row { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.acct-plan-badge {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 20px;
}
.acct-plan-badge.plan-free { background: var(--bg-hover); color: var(--fg-muted); border: 1px solid var(--line-strong); }
.acct-plan-badge.plan-pro { background: var(--accent); color: var(--accent-fg); }
.acct-trial-days { font-size: 11px; color: var(--fg-muted); font-family: var(--font-mono); }
.acct-upgrade-link {
  font-size: 11px; font-weight: 700; color: var(--accent); padding: 0 6px;
  text-decoration: none;
}
.acct-upgrade-link:hover { text-decoration: underline; }
.acct-card .teacher-card { position: relative; padding-right: 28px; }
.acct-logout {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--fg-muted); background: transparent;
}
.acct-logout:hover { background: var(--bg-hover); color: var(--fg); }

@media (max-width: 1279px) {
  .acct-cta, .acct-login-link, .acct-plan-row, .acct-upgrade-link { display: none; }
  .acct-logout { display: none; }
}

/* ============================================================ */
/* ============ AUTENTICACIÓN: modal login/registro =========== */
/* ============================================================ */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 31, 25, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.auth-modal {
  position: relative;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.25);
  width: 100%; max-width: 380px;
  padding: 32px 28px 28px;
}
.auth-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-muted); background: var(--bg-hover);
}
.auth-close:hover { color: var(--fg); }
.auth-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; font-size: 13px; }
.auth-title { font-family: var(--font-display); font-size: 24px; margin-bottom: 4px; }
.auth-sub { font-size: 13px; color: var(--fg-muted); margin-bottom: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-label { font-size: 11px; font-weight: 700; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.auth-error {
  font-size: 12px; color: #b3261e; background: rgba(179,38,30,0.08);
  border: 1px solid rgba(179,38,30,0.25); border-radius: var(--radius); padding: 8px 10px;
}
.auth-success {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--accent);
  background: rgba(27,138,74,0.08); border: 1px solid rgba(27,138,74,0.25);
  border-radius: var(--radius); padding: 12px 14px;
}
.auth-submit { width: 100%; justify-content: center; margin-top: 4px; }
.auth-switch { text-align: center; font-size: 12px; color: var(--fg-muted); margin-top: 4px; }
.auth-link { color: var(--accent); font-weight: 700; text-decoration: underline; }

/* ============================================================ */
/* ============ BIBLIOTECA: aviso de límite plan Gratis ======== */
/* ============================================================ */
.lib-free-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 0 24px 16px;
  padding: 12px 16px;
  background: color-mix(in oklab, var(--amarillo) 14%, var(--bg-panel));
  border: 1px solid color-mix(in oklab, var(--amarillo) 40%, transparent);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--fg-dim);
}
.lib-free-banner b { color: var(--fg); }
.lib-free-banner .btn { white-space: nowrap; }

@media (max-width: 767px) {
  .lib-free-banner { margin: 0 16px 14px; flex-direction: column; align-items: stretch; text-align: center; }
}

/* ============================================================ */
/* ============ AJUSTES: selector de tema y densidad =========== */
/* ============================================================ */
.settings-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 31, 25, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.settings-modal {
  position: relative;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,0.25);
  width: 100%; max-width: 480px;
  padding: 32px 28px 28px;
}
.settings-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-muted); background: var(--bg-hover);
}
.settings-close:hover { color: var(--fg); }
.settings-header { display: flex; align-items: center; gap: 10px; color: var(--accent); margin-bottom: 4px; }
.settings-title { font-family: var(--font-display); font-size: 22px; color: var(--fg); }
.settings-sub { font-size: 13px; color: var(--fg-muted); margin-bottom: 22px; }
.settings-section { margin-bottom: 20px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section-label {
  font-size: 11px; font-weight: 700; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px;
}
.settings-theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.settings-theme-card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 12px 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-hover);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.settings-theme-card:hover { border-color: var(--line-strong); }
.settings-theme-card.active { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 8%, var(--bg-panel)); }
.settings-theme-swatch { display: flex; gap: 4px; }
.settings-swatch-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-strong); }
.settings-theme-name { font-size: 13px; font-weight: 700; color: var(--fg); }
.settings-theme-desc { font-size: 11px; color: var(--fg-muted); line-height: 1.35; }
.settings-theme-check, .settings-density-card .settings-theme-check {
  position: absolute; top: 10px; right: 10px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  display: flex; align-items: center; justify-content: center;
}
.settings-density-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings-density-card {
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 30px 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-hover);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.settings-density-card:hover { border-color: var(--line-strong); }
.settings-density-card.active { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 8%, var(--bg-panel)); }
.settings-density-name { font-size: 13px; font-weight: 700; color: var(--fg); }
.settings-density-desc { font-size: 11px; color: var(--fg-muted); line-height: 1.35; }

@media (max-width: 767px) {
  .settings-theme-grid { grid-template-columns: 1fr; }
  .settings-density-row { grid-template-columns: 1fr; }
}

/* ============================================================ */
/* ================ GESTIÓN DE GRUPOS (CRUD UI) ================ */
/* ============================================================ */
.groups-modal { max-width: 460px; max-height: 82vh; overflow-y: auto; }
.groups-modal-error {
  margin-bottom: 14px; padding: 10px 12px;
  background: color-mix(in oklab, var(--coral) 14%, var(--bg-panel));
  border: 1px solid color-mix(in oklab, var(--coral) 40%, transparent);
  border-radius: var(--radius);
  font-size: 12.5px; color: var(--fg);
}
.groups-modal-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.groups-modal-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-hover);
}
.groups-modal-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.groups-modal-item-name { font-size: 13.5px; font-weight: 700; color: var(--fg); }
.groups-modal-item-meta { font-size: 11.5px; color: var(--fg-muted); }
.groups-modal-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.groups-modal-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  color: var(--fg-muted); background: var(--bg-panel);
  border: 1px solid var(--line);
  transition: color 0.15s, border-color 0.15s;
}
.groups-modal-icon-btn:hover { color: var(--fg); border-color: var(--line-strong); }
.groups-modal-icon-btn.danger:hover { color: var(--coral); border-color: color-mix(in oklab, var(--coral) 50%, var(--line)); }
.groups-modal-confirm {
  display: flex; flex-direction: column; gap: 10px;
  font-size: 12.5px; color: var(--fg-dim); width: 100%;
}
.groups-modal-form { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.groups-modal-form-new {
  margin-top: 4px; padding: 12px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--bg-hover);
}
.groups-modal-input {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-panel); color: var(--fg);
  font-size: 13px; font-family: inherit;
}
.groups-modal-input:focus { outline: none; border-color: var(--accent); }
.groups-modal-input.sm { width: 100%; }
.groups-modal-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.groups-modal-field { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.groups-modal-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.groups-modal-form-actions .btn, .groups-modal-form-actions .btn-primary, .groups-modal-form-actions .btn-danger {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 12.5px;
}
.groups-modal-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  color: var(--fg-muted); background: transparent;
  font-size: 13px; font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.groups-modal-add-btn:hover { color: var(--accent); border-color: var(--accent); background: color-mix(in oklab, var(--accent) 6%, transparent); }

@media (max-width: 767px) {
  .groups-modal-form-row { grid-template-columns: 1fr 1fr; }
}
