:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #68736d;
  --line: #d8dfdb;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --accent: #116149;
  --accent-2: #c24a35;
  --soft: #e9f2ee;
  --brand-template: url("brand/euskara-eskolak-template.png");
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(247, 248, 245, 0.94), rgba(247, 248, 245, 0.98)), var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image: var(--brand-template);
  background-position: top right;
  background-repeat: no-repeat;
  background-size: min(980px, 82vw) auto;
  opacity: 0.045;
  pointer-events: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar::after {
  position: absolute;
  inset: -95px -120px auto auto;
  width: 560px;
  height: 315px;
  content: "";
  background-image: var(--brand-template);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0.08;
  pointer-events: none;
}

.brand {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}

.nav {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
}

.nav a {
  font-weight: 800;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 34px;
}

h2 {
  margin-bottom: 18px;
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-head h2,
.section-head p {
  margin-bottom: 0;
}

.compact-head {
  align-items: center;
}

.panel,
.login-panel,
.result-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel,
.result-panel {
  width: min(440px, 100%);
  margin: 72px auto;
}

.stack {
  display: grid;
  gap: 14px;
}

.form-note {
  margin: 12px 0 0;
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button.secondary,
.button.secondary {
  color: var(--accent);
  background: var(--soft);
}

.list {
  display: grid;
  gap: 10px;
}

.list.compact {
  gap: 8px;
}

.row,
.row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

.row-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.row.block {
  display: grid;
  align-items: start;
  justify-content: stretch;
  gap: 6px;
}

.row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

small,
.muted {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.message {
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--soft);
}

.message.error {
  color: #7c2417;
  background: #f8e6e2;
}

.drop-zone {
  min-height: 190px;
  padding: 22px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  place-items: center;
  text-align: center;
  background: #fbfcfa;
  transition: border-color 160ms ease, background 160ms ease;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--soft);
}

.drop-zone input {
  width: min(360px, 100%);
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.drop-title {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.selected-file {
  color: var(--accent);
}

.storage-panel p {
  margin: 8px 0 0;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.library-item {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.library-item small {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.library-item p {
  margin: 0;
}

.question {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.question legend {
  padding: 0 8px;
  font-weight: 800;
}

.choice {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--ink);
  font-weight: 500;
}

.choice input {
  width: auto;
  min-height: auto;
}

.score {
  margin: 20px 0 8px;
  font-size: 56px;
  font-weight: 900;
}

.lesson-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.lesson-side {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.language-switcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.language-switcher a.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.slide-viewer {
  display: grid;
  gap: 18px;
}

.slide-frame {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.slide-frame img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.slide-surface {
  position: relative;
}

.branded-slide-frame {
  background: #fff;
}

.branded-slide {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  padding: clamp(22px, 4vw, 62px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: #fff;
  background-image: var(--brand-template);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.branded-slide.is-annotating {
  cursor: crosshair;
}

.branded-slide.is-text-mode {
  cursor: text;
}

.branded-slide > img {
  position: relative;
  z-index: 0;
  width: min(78%, 1320px);
  max-height: 72%;
  object-fit: contain;
  border: 1px solid rgba(17, 97, 73, 0.18);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(20, 28, 23, 0.14);
}

.active-slide .branded-slide {
  padding: clamp(14px, 2.2vw, 38px);
}

.active-slide .branded-slide > img {
  width: min(88%, 1500px);
  max-height: 82%;
}

.annotation-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.slide-annotation-palette {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(520px, calc(100% - 28px));
  padding: 8px;
  border: 1px solid rgba(17, 97, 73, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(20, 28, 23, 0.16);
  opacity: 0.18;
  transition: opacity 120ms ease;
}

.slide-surface:hover .slide-annotation-palette,
.slide-annotation-palette:focus-within {
  opacity: 1;
}

.slide-annotation-palette button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.slide-annotation-palette button.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.slide-text-editor {
  position: absolute;
  z-index: 5;
  width: min(260px, 34%);
  min-height: 38px;
  padding: 6px 10px;
  border: 2px solid #f43f5e;
  border-radius: 6px;
  color: #f43f5e;
  background: rgba(255, 255, 255, 0.96);
  font-size: clamp(18px, 2vw, 28px);
  font-weight: 900;
  transform: translateY(-50%);
}

.annotation-layer path,
.annotation-layer rect,
.annotation-layer ellipse {
  fill: none;
  stroke: #f43f5e;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 0.8;
  vector-effect: non-scaling-stroke;
}

.annotation-layer text {
  fill: #f43f5e;
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 0.35;
  paint-order: stroke;
  font-size: 4px;
  font-weight: 900;
  letter-spacing: 0;
}

.live-pointer {
  position: absolute;
  z-index: 2;
  width: 22px;
  height: 22px;
  border: 3px solid #f43f5e;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.18);
  box-shadow: 0 0 0 5px rgba(244, 63, 94, 0.16), 0 4px 14px rgba(15, 23, 42, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 120ms ease;
}

.live-pointer::before,
.live-pointer::after {
  position: absolute;
  content: "";
  background: #f43f5e;
}

.live-pointer::before {
  top: 50%;
  left: -10px;
  width: 36px;
  height: 2px;
  transform: translateY(-50%);
}

.live-pointer::after {
  top: -10px;
  left: 50%;
  width: 2px;
  height: 36px;
  transform: translateX(-50%);
}

.live-pointer.is-visible {
  opacity: 1;
}

.slide-frame figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.embedded-material {
  min-height: 520px;
}

.lesson-video,
.lesson-document {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #000;
}

.lesson-video {
  max-height: 70vh;
}

.lesson-document {
  min-height: 680px;
  background: #fff;
}

.presenter-live-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.presenter-live-banner.is-live {
  border-color: var(--accent);
  background: var(--soft);
}

.presenter-live-banner strong {
  display: block;
  font-size: 18px;
}

.presenter-live-banner p {
  margin: 6px 0 0;
  color: var(--muted);
}

.presenter-live-banner button {
  min-width: 220px;
}

.presenter-live-banner {
  display: none;
}

.presenter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

.presenter-tools {
  position: fixed;
  top: 96px;
  left: 0;
  z-index: 20;
  display: grid;
  gap: 16px;
  width: min(330px, calc(100vw - 34px));
  max-height: calc(100vh - 118px);
  overflow: auto;
  border-radius: 0 8px 8px 0;
  box-shadow: 0 18px 38px rgba(23, 32, 27, 0.22);
  transform: translateX(calc(-100% + 18px));
  transition: transform 160ms ease;
}

.presenter-tools::after {
  position: absolute;
  top: 18px;
  right: -42px;
  width: 42px;
  min-height: 116px;
  display: grid;
  place-items: center;
  content: "Controls";
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  color: #fff;
  background: var(--accent);
  font-size: 12px;
  font-weight: 900;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  box-shadow: 8px 12px 24px rgba(23, 32, 27, 0.16);
}

.presenter-tools:hover,
.presenter-tools:focus-within {
  transform: translateX(0);
}

.presenter-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.compact-action {
  width: 100%;
}

.annotation-tools {
  display: grid;
  gap: 10px;
}

.annotation-tools strong {
  font-size: 13px;
  text-transform: uppercase;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tool-grid button {
  min-height: 36px;
  padding: 0 8px;
}

.tool-grid button.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.presenter-stage,
.student-live-shell {
  display: grid;
  gap: 14px;
}

.live-classroom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(260px, 24vw, 360px);
  grid-template-areas: "stage video";
  gap: 14px;
  align-items: stretch;
}

.meeting-panel {
  grid-area: video;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: min(680px, calc(100vh - 190px));
}

.meeting-strip {
  min-width: 0;
}

.presenter-stage {
  grid-area: stage;
  align-content: start;
}

.section-head.compact {
  margin-bottom: 0;
}

.section-head.compact h2 {
  margin: 0;
  font-size: 20px;
}

.meeting-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
}

.active-slide {
  padding: 10px;
}

.live-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 900;
}

.live-status.is-live {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.live-note p {
  margin: 8px 0 0;
  font-size: clamp(26px, 3vw, 44px);
  font-weight: 800;
  line-height: 1.18;
  white-space: pre-wrap;
}

.board-workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.board-tools {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 16px;
}

.blackboard {
  min-height: 600px;
  border: 10px solid #8f6a44;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.04)),
    #123d34;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08), 0 18px 38px rgba(23, 32, 27, 0.16);
}

.blackboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  color: #eaf7ef;
  font-size: 18px;
  font-weight: 900;
}

.blackboard-canvas {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  min-height: 500px;
  padding: 22px;
  align-content: start;
}

.board-card {
  padding: 18px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 8px;
  color: #f4fff8;
  background: rgba(255,255,255,0.08);
}

.board-card small {
  display: block;
  margin-bottom: 10px;
  color: #aee3c7;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.board-card p {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
  white-space: pre-wrap;
}

.board-card.word p {
  font-size: 38px;
}

.board-card.sentence p {
  font-size: 32px;
}

.board-card.note {
  background: rgba(216, 166, 66, 0.18);
}

.student-board-shell {
  display: grid;
  gap: 12px;
}

.student-board {
  min-height: 680px;
}

.board-refresh {
  text-align: center;
}

@media (max-width: 760px) {
  .topbar,
  .page-head,
  .row,
  .row-link {
    align-items: stretch;
    flex-direction: column;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .presenter-live-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .presenter-live-banner button {
    width: 100%;
  }

  .library-grid {
    grid-template-columns: 1fr;
  }

  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .board-workspace {
    grid-template-columns: 1fr;
  }

  .presenter-layout {
    grid-template-columns: 1fr;
  }

  .live-classroom-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "stage"
      "video";
  }

  .meeting-panel {
    min-height: 320px;
  }

  .meeting-frame {
    height: 320px;
    min-height: 320px;
  }

  .lesson-side {
    position: static;
  }

  .board-tools {
    position: static;
  }

  .blackboard-canvas {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }
}
