:root {
  color-scheme: light;
  --school-ink: #1f2320;
  --school-muted: #62675f;
  --school-line: #d8d2c4;
  --school-paper: #fffdf8;
  --school-panel: #f4f0e7;
  --school-panel-strong: #ebe3d5;
  --school-teal: #0f766e;
  --school-teal-dark: #115e59;
  --school-teal-soft: #e4f6f3;
  --school-blue: #245f8f;
  --school-ember: #b64218;
  --school-gold: #c8922f;
  --school-white: #ffffff;
  --school-shadow: 0 18px 44px rgba(31, 35, 32, 0.1);
  --school-radius: 8px;
  --board-light: #efe4cb;
  --board-dark: #b8ac94;
  --board-line: #6f6251;
}

* {
  box-sizing: border-box;
}

body.school-guided-page {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fffaf0 0%, #f3f0e8 54%, #edf4f2 100%);
  color: var(--school-ink);
  font-family: Montserrat, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
}

.school-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px clamp(14px, 3vw, 30px);
  border-bottom: 1px solid rgba(31, 35, 32, 0.1);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(14px);
}

.school-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
  text-decoration: none;
}

.school-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border: 1px solid rgba(31, 35, 32, 0.08);
  border-radius: var(--school-radius);
  background: var(--school-white);
  padding: 4px;
}

.school-brand strong {
  display: block;
  font-family: Montserrat, sans-serif;
  font-size: 1.05rem;
  line-height: 1.1;
}

.school-brand span span {
  display: block;
  margin-top: 2px;
  color: var(--school-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.school-nav,
.lesson-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.school-nav {
  flex-wrap: wrap;
  justify-content: center;
}

.school-nav a,
.school-practice-link,
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid rgba(31, 35, 32, 0.12);
  border-radius: var(--school-radius);
  background: var(--school-white);
  color: var(--school-ink);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.school-nav a,
.school-practice-link {
  padding: 9px 12px;
}

.school-nav a:hover,
.school-practice-link:hover,
.primary-action:hover,
.secondary-action:hover {
  border-color: rgba(31, 35, 32, 0.24);
  transform: translateY(-1px);
}

.school-nav a[aria-current="page"] {
  border-color: var(--school-teal);
  background: var(--school-teal-soft);
  color: var(--school-teal-dark);
}

.school-practice-link {
  border-color: var(--school-blue);
  background: var(--school-blue);
  color: var(--school-white);
}

.ev2-session {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  max-width: 350px;
}

.ev2-session-summary {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: var(--school-teal-soft);
  color: var(--school-teal-dark);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.ev2-session[data-escuela-session-state="visitor"] .ev2-session-summary,
.ev2-session[data-escuela-session-state="error"] .ev2-session-summary {
  border-color: rgba(31, 35, 32, 0.12);
  background: var(--school-white);
  color: var(--school-muted);
}

.ev2-session-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.ev2-session-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgba(31, 35, 32, 0.12);
  border-radius: var(--school-radius);
  background: var(--school-white);
  color: var(--school-ink);
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.ev2-session-link-primary {
  border-color: var(--school-teal);
  background: var(--school-teal);
  color: var(--school-white);
}

.ev2-session-link.is-disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.ev2-session-note {
  flex-basis: 100%;
  max-width: 340px;
  margin: 0;
  color: var(--school-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: right;
}

.school-access-guard {
  width: min(980px, calc(100% - 32px));
  margin: 18px auto 32px;
}

.school-access-guard-card {
  border: 1px solid var(--school-line);
  border-radius: var(--school-radius);
  background: linear-gradient(180deg, #ffffff 0%, #fff8ee 100%);
  box-shadow: var(--school-shadow);
  padding: clamp(24px, 4vw, 40px);
}

.school-access-guard-kicker {
  margin: 0 0 8px;
  color: var(--school-teal);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.school-access-guard-title {
  margin: 0;
  font-family: Montserrat, sans-serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.school-access-guard-copy {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--school-muted);
  font-size: 1rem;
  font-weight: 700;
}

.school-access-guard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.school-access-guard-primary {
  border-color: var(--school-teal);
  background: var(--school-teal);
  color: var(--school-white);
}

.guided-shell {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) minmax(340px, 420px);
  gap: 18px;
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2vw, 28px) 34px;
}

.lesson-board-area,
.lesson-panel {
  min-width: 0;
}

.board-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.school-kicker {
  margin: 0 0 5px;
  color: var(--school-teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.board-heading h1 {
  margin: 0;
  font-family: Montserrat, sans-serif;
  font-size: 2rem;
  line-height: 1.1;
}

.board-heading p {
  margin: 6px 0 0;
  color: var(--school-muted);
  font-size: 0.98rem;
}

.local-pill,
.answer-state,
.lesson-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--school-line);
  border-radius: 999px;
  background: var(--school-paper);
  color: var(--school-muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.local-pill {
  padding: 6px 10px;
}

.board-stage,
.lesson-panel {
  border: 1px solid var(--school-line);
  border-radius: var(--school-radius);
  background: var(--school-paper);
  box-shadow: var(--school-shadow);
}

.board-stage {
  padding: 16px;
}

.board-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.board-stage-header h2 {
  margin: 0;
  font-size: 1rem;
}

.answer-state {
  padding: 5px 10px;
  border-color: #a7dcd4;
  background: var(--school-teal-soft);
  color: var(--school-teal-dark);
}

.answer-state.is-visible {
  border-color: #edc778;
  background: #fff7dd;
  color: #795b13;
}

.guided-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(12, minmax(0, 1fr));
  width: min(100%, 920px, calc(100vh - 170px));
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border: 2px solid var(--board-line);
  background: var(--board-light);
}

.school-square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid rgba(111, 98, 81, 0.2);
  border-bottom: 1px solid rgba(111, 98, 81, 0.2);
  overflow: hidden;
}

.school-square.is-dark {
  background: var(--board-dark);
}

.school-square.is-light {
  background: var(--board-light);
}

.school-square-coordinate {
  position: absolute;
  top: 3px;
  left: 4px;
  z-index: 1;
  color: rgba(31, 35, 32, 0.54);
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.school-piece {
  position: relative;
  z-index: 2;
  width: 86%;
  height: 86%;
  max-width: 86%;
  max-height: 86%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.school-piece img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(31, 35, 32, 0.18));
}

.school-square.is-focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.82);
  outline-offset: -4px;
}

.school-square.is-focus-visible::after {
  content: attr(data-focus-label);
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 3;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--school-teal);
  color: var(--school-white);
  font-size: 0.72rem;
  font-weight: 800;
}

.lesson-panel {
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  padding: 16px;
}

.lesson-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lesson-tags span {
  padding: 5px 8px;
}

.lesson-tags span:first-child {
  border-color: #a7dcd4;
  background: var(--school-teal-soft);
  color: var(--school-teal-dark);
}

.lesson-block {
  display: grid;
  gap: 5px;
}

.lesson-block h2,
.answer-panel h2,
.answer-panel h3 {
  margin: 0;
  color: var(--school-muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lesson-block p,
.answer-panel p {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.42;
}

.task-block {
  padding: 12px;
  border-left: 4px solid var(--school-teal);
  background: #eef8f6;
}

.lesson-actions {
  flex-wrap: wrap;
  padding-top: 2px;
}

.primary-action,
.secondary-action {
  padding: 10px 14px;
}

.primary-action {
  border-color: var(--school-teal);
  background: var(--school-teal);
  color: var(--school-white);
}

.primary-action:hover {
  border-color: var(--school-teal-dark);
  background: var(--school-teal-dark);
}

.answer-panel {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid #edc778;
  border-radius: var(--school-radius);
  background: #fff8e4;
}

.answer-panel[hidden] {
  display: none;
}

.answer-note {
  color: #795b13;
  font-weight: 700;
}

@media (max-width: 1080px) {
  .school-topbar {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 12px;
  }

  .school-brand {
    min-width: 0;
  }

  .school-nav {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .ev2-session {
    grid-column: 1 / -1;
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
  }

  .ev2-session-actions {
    justify-content: flex-start;
  }

  .ev2-session-note {
    max-width: 100%;
    text-align: left;
  }

  .school-nav a,
  .school-practice-link {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 0.84rem;
  }

  .guided-shell {
    grid-template-columns: 1fr;
    width: min(900px, 100%);
    padding-top: 12px;
  }

  .lesson-panel {
    max-height: none;
  }

  .guided-board {
    width: min(100%, 780px);
  }

  .board-heading {
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
  }

  .board-heading h1 {
    font-size: 1.75rem;
  }

  .board-heading p {
    font-size: 0.92rem;
  }
}

@media (max-width: 720px) {
  .school-topbar {
    grid-template-columns: 1fr;
  }

  .school-practice-link {
    width: 100%;
  }

  .ev2-session,
  .ev2-session-actions {
    align-items: stretch;
    width: 100%;
  }

  .ev2-session-link {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  .lesson-actions {
    align-items: stretch;
    width: 100%;
  }

  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .board-heading {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
  }

  .board-stage-header {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    margin-bottom: 8px;
  }

  .school-kicker {
    margin-bottom: 3px;
    font-size: 0.72rem;
  }

  .board-heading h1 {
    font-size: 1.65rem;
  }

  .board-heading p {
    margin-top: 4px;
    font-size: 0.88rem;
    line-height: 1.28;
  }

  .local-pill {
    display: none;
  }

  .board-stage-header h2 {
    font-size: 0.94rem;
  }

  .answer-state {
    min-height: 24px;
    padding: 4px 8px;
  }

  .board-stage {
    padding: 8px;
  }

  .school-square-coordinate {
    font-size: 0.52rem;
    top: 2px;
    left: 2px;
  }

  .school-square.is-focus-visible::after {
    right: 2px;
    bottom: 2px;
    min-width: 17px;
    height: 17px;
    font-size: 0.62rem;
  }
}

@media (max-width: 520px) {
  .board-heading {
    flex-direction: column;
  }
}
