/* Opettajan tyylit.
   Käyttää shared/tokens.css:n muuttujia; perusasetukset määritellään tässä.
   Kaikki luokat alkavat etuliitteellä teacher-. */

* {
  box-sizing: border-box;
}

body.teacher-app {
  margin: 0;
  background: var(--gray-100);
  color: var(--gray-800);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

body.teacher-loading #teacher-root {
  visibility: hidden;
}

body.teacher-busy {
  cursor: progress;
}

/* ===== Kehys ===== */

.teacher-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Yläpalkki pysyy ikkunan yläreunassa vieritettäessä. Editorin työkalupalkki
   on sen alla (z-index pienempi), joten se tulee näkyviin palkin alta. */
.teacher-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
  padding: var(--space-lg) var(--space-3xl);
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
}

.teacher-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-decoration: none;
  color: inherit;
}

.teacher-logo {
  height: 28px;
  width: auto;
}

.teacher-brand-name {
  font-weight: var(--font-semibold);
  color: var(--blue-800);
}

.teacher-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  font-size: var(--text-sm);
}

.teacher-link {
  color: var(--blue-700);
  text-decoration: none;
  font-weight: var(--font-medium);
}

.teacher-link:hover {
  text-decoration: underline;
}

.teacher-user {
  color: var(--gray-600);
}

.teacher-main {
  flex: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-xl) var(--space-5xl);
}

/* ===== Yleiset osat ===== */

.teacher-panel {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-2xl);
  margin-bottom: var(--space-2xl);
}

/* Leveä taulukko vierii paneelin sisällä, jottei koko sivu vieri sivusuunnassa. */
.teacher-panel {
  overflow-x: auto;
}

.teacher-panel h1,
.teacher-panel h2 {
  margin: 0 0 var(--space-md);
  color: var(--blue-900);
}

.teacher-panel h2 {
  font-size: var(--text-2xl);
}

.teacher-panel h3 {
  margin: var(--space-xl) 0 var(--space-sm);
  font-size: var(--text-lg);
  color: var(--gray-700);
}

.teacher-muted {
  color: var(--gray-600);
  margin: 0 0 var(--space-lg);
}

.teacher-empty {
  color: var(--gray-600);
  font-style: italic;
}

.teacher-error {
  color: var(--color-error-text);
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin: 0 0 var(--space-lg);
}

.teacher-notice {
  color: var(--color-success-text);
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  margin: 0 0 var(--space-lg);
}

.teacher-pre {
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  overflow-x: auto;
  font-size: var(--text-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

code {
  background: var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-xs);
  font-size: var(--text-sm);
}

.teacher-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== Painikkeet ===== */

.teacher-button {
  background: var(--blue-600);
  color: var(--white);
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-md) var(--space-2xl);
  font: inherit;
  font-weight: var(--font-semibold);
  cursor: pointer;
  box-shadow: var(--shadow-button);
}

.teacher-button:hover:not(:disabled) {
  background: var(--blue-700);
  box-shadow: var(--shadow-button-hover);
}

.teacher-button:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  box-shadow: none;
}

.teacher-link-button {
  background: none;
  border: none;
  color: var(--blue-700);
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.teacher-link-button.teacher-danger {
  color: var(--color-error);
}

/* ===== Keskustelu ===== */

.teacher-chat {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.teacher-chat-head h1 {
  margin: 0 0 var(--space-xs);
  color: var(--blue-900);
  font-size: var(--text-4xl);
}

.teacher-messages {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-2xl);
  min-height: 320px;
  max-height: 58vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.teacher-message {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-width: 46rem;
}

.teacher-message-user {
  align-self: flex-end;
  align-items: flex-end;
  text-align: right;
}

.teacher-message-role {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}

.teacher-message-body {
  background: var(--gray-200);
  border-radius: var(--radius-3xl);
  padding: var(--space-lg) var(--space-xl);
}

.teacher-message-user .teacher-message-body {
  background: var(--blue-100);
}

.teacher-message-body p {
  margin: 0 0 var(--space-md);
}

.teacher-message-body p:last-child {
  margin-bottom: 0;
}

/* Kolme pistettä, jotka kertovat että vastausta odotetaan. */
.teacher-dots {
  display: inline-block;
  width: 2.5rem;
  height: 1rem;
  background:
    radial-gradient(circle 3px at 6px 50%, var(--gray-500) 99%, transparent) 0 0/100% 100% no-repeat,
    radial-gradient(circle 3px at 20px 50%, var(--gray-500) 99%, transparent) 0 0/100% 100% no-repeat,
    radial-gradient(circle 3px at 34px 50%, var(--gray-500) 99%, transparent) 0 0/100% 100% no-repeat;
  animation: teacher-pulse 1.2s ease-in-out infinite;
}

@keyframes teacher-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .teacher-dots { animation: none; }
}

.teacher-composer {
  display: flex;
  gap: var(--space-lg);
  align-items: flex-end;
}

.teacher-composer textarea {
  flex: 1;
  resize: vertical;
  font: inherit;
  padding: var(--space-lg);
  border: 1px solid var(--gray-400);
  border-radius: var(--radius-2xl);
  background: var(--white);
  color: inherit;
}

.teacher-composer textarea:focus,
.teacher-form input:focus,
.teacher-form textarea:focus {
  outline: 2px solid var(--blue-500);
  outline-offset: 1px;
}

/* ===== Hallinta ===== */

.teacher-tabs {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-2xl);
}

.teacher-tab {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-xl);
  font: inherit;
  color: var(--gray-700);
  cursor: pointer;
}

.teacher-tab.is-active {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: var(--white);
  font-weight: var(--font-semibold);
}

.teacher-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.teacher-table th,
.teacher-table td {
  text-align: left;
  padding: var(--space-md);
  border-bottom: 1px solid var(--gray-300);
  vertical-align: top;
}

.teacher-table th {
  color: var(--gray-600);
  font-weight: var(--font-semibold);
}

.teacher-row-actions {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.teacher-badge-on,
.teacher-badge-off {
  border-radius: var(--radius-full);
  padding: 2px var(--space-md);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.teacher-badge-on {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.teacher-badge-off {
  background: var(--gray-200);
  color: var(--gray-600);
}

.teacher-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.teacher-form label {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--gray-700);
}

.teacher-form input[type="text"],
.teacher-form input[type="email"],
.teacher-form input[type="number"],
.teacher-form textarea {
  font: inherit;
  padding: var(--space-md);
  border: 1px solid var(--gray-400);
  border-radius: var(--radius-lg);
  background: var(--white);
  color: var(--gray-800);
}

.teacher-form textarea {
  resize: vertical;
}

.teacher-form-row {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  align-items: flex-end;
}

.teacher-form-row > label {
  flex: 1 1 12rem;
}

.teacher-checkbox {
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
}

.teacher-form-actions {
  display: flex;
  gap: var(--space-lg);
  align-items: center;
}

.teacher-detail {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-xs) var(--space-lg);
  margin: 0 0 var(--space-lg);
  font-size: var(--text-sm);
}

.teacher-detail dt {
  color: var(--gray-600);
}

.teacher-detail dd {
  margin: 0;
}

/* Leveät taulukot vierivät omassa laatikossaan, ei koko sivu. */
@media (max-width: 720px) {
  .teacher-main {
    padding: var(--space-xl) var(--space-lg) var(--space-4xl);
  }

  .teacher-topbar {
    padding: var(--space-lg);
  }

  .teacher-panel {
    padding: var(--space-lg);
  }

  .teacher-composer {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ===== Opettaja ===== */

.teacher-teacher {
  display: grid;
  grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
  gap: var(--space-xl);
  align-items: start;
}

/* Mafynetistä avattuna vain yksi tehtävä, ilman tehtävävalikkoa.
   Sivupalkissa on silloin vain luvun teoriat, jos niitä on. */
.teacher-teacher.is-single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 56rem;
  margin: 0 auto;
}

.teacher-teacher.is-single.has-theories {
  grid-template-columns: minmax(11rem, 15rem) minmax(0, 1fr);
  max-width: 72rem;
}

@media (max-width: 48rem) {
  .teacher-teacher,
  .teacher-teacher.is-single.has-theories {
    grid-template-columns: minmax(0, 1fr);
  }

}

.teacher-outline {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  max-height: 80vh;
  overflow-y: auto;
}

.teacher-outline-title {
  margin: 0 0 var(--space-md);
  font-size: var(--text-lg);
  color: var(--blue-900);
}

.teacher-outline-course {
  display: block;
  margin-bottom: var(--space-md);
  font-size: var(--text-sm);
  color: var(--gray-700);
}

.teacher-outline-course select {
  display: block;
  width: 100%;
  margin-top: var(--space-xs);
  font: inherit;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-lg);
}

.teacher-outline-chapter + .teacher-outline-chapter {
  border-top: 1px solid var(--gray-200);
}

.teacher-outline-chapter-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: var(--font-medium);
  text-align: left;
  color: var(--blue-900);
  cursor: pointer;
}

.teacher-outline-chapter.is-open .teacher-outline-chapter-title {
  color: var(--blue-600);
}

.teacher-outline-count {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

.teacher-outline-exercises {
  list-style: none;
  margin: 0 0 var(--space-sm);
  padding: 0 0 0 var(--space-sm);
}

.teacher-outline-exercise {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 0;
  border-radius: var(--radius-lg);
  background: none;
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  color: var(--gray-800);
  cursor: pointer;
}

.teacher-outline-exercise:hover:not(:disabled) {
  background: var(--gray-100);
}

.teacher-outline-exercise.is-active {
  background: var(--blue-100);
  color: var(--blue-900);
}

.teacher-outline-exercise:disabled {
  color: var(--gray-400);
  cursor: not-allowed;
}

.teacher-outline-difficulty {
  color: var(--gray-400);
  letter-spacing: -0.1em;
}

.teacher-teacher-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.teacher-exercise h1 {
  margin: 0 0 var(--space-xs);
  font-size: var(--text-2xl);
  color: var(--blue-900);
}

.teacher-exercise-chapter {
  margin: 0 0 var(--space-xs);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}

.teacher-teacher .teacher-messages {
  max-height: 48vh;
}

/* Markdown- ja matematiikkasisältö (tehtävänanto ja opettajan vastaukset) */

.teacher-rich p {
  margin: 0 0 var(--space-md);
}

.teacher-rich p:last-child,
.teacher-rich ul:last-child,
.teacher-rich ol:last-child {
  margin-bottom: 0;
}

.teacher-rich h2,
.teacher-rich h3,
.teacher-rich h4 {
  margin: var(--space-md) 0 var(--space-xs);
  font-size: var(--text-base);
  color: var(--blue-900);
}

.teacher-rich ul,
.teacher-rich ol {
  margin: 0 0 var(--space-md);
  padding-left: 1.5rem;
}

.teacher-rich blockquote {
  margin: 0 0 var(--space-md);
  padding-left: var(--space-md);
  border-left: 3px solid var(--gray-300);
  color: var(--gray-700);
}

.teacher-rich figure {
  margin: 0 0 var(--space-md);
}

.teacher-rich figure img {
  max-width: 100%;
  height: auto;
}

.teacher-rich figcaption {
  font-size: var(--text-sm);
  color: var(--gray-600);
  font-style: italic;
}

.teacher-rich code {
  font-size: 0.95em;
}

/* Kaava upotetaan MathJaxin SVG:nä: sen ex-mitat seuraavat tekstin
   fonttikokoa ja oma vertical-align asettaa perusviivan. Paikkamerkki näyttää
   LaTeXin, kunnes SVG on haettu. */
.teacher-math {
  margin: 0 0.1em;
  white-space: nowrap;
}

.teacher-math svg {
  display: inline-block;
  overflow: visible;
}

.teacher-math[data-ready="svg"] code {
  display: none;
}

.teacher-math code {
  font-size: 0.9em;
}

.teacher-math-display {
  display: block;
  text-align: center;
  margin: var(--space-sm) auto;
  overflow-x: auto;
}

.teacher-math-display svg {
  font-size: 1.15em;
}

.teacher-math-block {
  text-align: center;
}

.teacher-pre-plain {
  margin: 0;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre-wrap;
}

.teacher-link-button.is-active {
  font-weight: var(--font-semibold);
  text-decoration: underline;
}

.teacher-pdf {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
}

/* Luvun teoriat: otsikot sivupalkissa, avattu teoria omassa paneelissaan.
   Leveällä näytöllä paneeli on tehtävän ja keskustelun vieressä ja pysyy
   näkyvissä vieritettäessä; kapeammalla se on tehtävän paikalla keskustelun
   yläpuolella. Paneeli vierii itsenäisesti, joten keskustelu jää sen alle tai
   viereen näkyviin. */

.teacher-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.teacher-sidebar .teacher-panel {
  margin-bottom: 0;
}

/* Mafynetistä avattuna sivupalkissa on vain teoriat, joten se pysyy
   näkyvissä vieritettäessä, kun se on sisällön vieressä. Kapealla näytöllä
   se on sisällön yläpuolella ja vierii pois, jottei se peitä teoriaa. */
.teacher-teacher.is-single .teacher-sidebar {
  position: sticky;
  top: calc(var(--teacher-topbar-height, 0px) + var(--space-lg));
}

@media (max-width: 48rem) {
  .teacher-teacher.is-single .teacher-sidebar {
    position: static;
  }
}

.teacher-theory-list {
  padding: var(--space-lg);
}

.teacher-theory-list ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.teacher-theories-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}

.teacher-panel .teacher-theories-title {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

.teacher-theory-link {
  display: block;
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 0;
  border-radius: var(--radius-lg);
  background: none;
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  color: var(--blue-900);
  cursor: pointer;
}

.teacher-theory-link:hover {
  background: var(--gray-100);
}

.teacher-theory-link.is-active {
  background: var(--blue-100);
  font-weight: var(--font-semibold);
}

.teacher-work {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.teacher-exercise,
.teacher-theory-pane {
  scroll-margin-top: calc(var(--teacher-topbar-height, 0px) + var(--space-lg));
}

.teacher-theory-pane {
  max-height: 60vh;
  overflow-y: auto;
  padding-top: 0;
  margin-bottom: 0;
}

.teacher-theory-pane-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg) 0 var(--space-sm);
  background: var(--white);
}

.teacher-panel .teacher-theory-pane-head h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.teacher-theory-close {
  flex: none;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-full);
  background: var(--white);
  font-size: var(--text-lg);
  line-height: 1;
  color: var(--gray-700);
  cursor: pointer;
}

.teacher-theory-close:hover {
  background: var(--gray-100);
}

.teacher-theory-body {
  padding: 0 0 var(--space-md);
}

/* Kun teoria on auki, näkymä täyttää ikkunan korkeuden eikä sivu vieri:
   teoria ja keskustelu (leveällä näytöllä myös tehtävä) vierivät kukin
   omassa alueessaan. */
.teacher-main:has(.teacher-teacher.has-theory-open) {
  display: flex;
  flex: none;
  flex-direction: column;
  height: calc(100dvh - var(--teacher-topbar-height, 0px));
  padding-top: var(--space-lg);
  padding-bottom: var(--space-lg);
}

/* Leveys erikseen, koska flex-sarakkeessa keskittävät automaattiset
   marginaalit kutistaisivat näkymän sisältönsä levyiseksi. */
.teacher-teacher.has-theory-open {
  flex: 1;
  width: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}

.teacher-teacher.has-theory-open .teacher-teacher-main,
.teacher-teacher.has-theory-open .teacher-work,
.teacher-teacher.has-theory-open .teacher-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.teacher-teacher.has-theory-open .teacher-teacher-main {
  height: 100%;
}

.teacher-teacher.has-theory-open .teacher-theory-pane,
.teacher-teacher.has-theory-open .teacher-work {
  flex: 1 1 0;
  max-height: none;
}

.teacher-teacher.has-theory-open .teacher-exercise {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 0;
}

.teacher-teacher.has-theory-open .teacher-chat {
  flex: 1 1 0;
  min-height: 14rem;
}

.teacher-teacher.has-theory-open .teacher-messages {
  flex: 1 1 0;
  min-height: 6rem;
  max-height: none;
}

/* Kapeammalla näytöllä teoria on tehtävän paikalla. */
@media (max-width: 79.99rem) {
  .teacher-teacher.has-theory-open .teacher-exercise {
    display: none;
  }

  .teacher-teacher.has-theory-open .teacher-chat {
    min-height: 0;
  }
}

/* Kapealla näytöllä teoriavalikko on teorian yläpuolella. */
@media (max-width: 48rem) {
  .teacher-teacher.has-theory-open {
    grid-template-rows: auto minmax(0, 1fr);
  }
}

/* Leveällä näytöllä teoria on omassa sarakkeessaan. */
@media (min-width: 80rem) {
  .teacher-main:has(.teacher-teacher.has-theory-open) {
    width: 100%;
  }

  /* Tarkkuus ylittää .is-single.has-theories-säännön leveysrajan. */
  .teacher-teacher.is-single.has-theory-open,
  .teacher-teacher.has-theory-open {
    max-width: none;
  }

  /* Teoriapalsta on teorian levyinen (--teacher-theory-width, ks.
     teacher-view.js), kuitenkin enintään 57 % leveydestä; tehtävä ja
     keskustelu saavat lopun. */
  .teacher-teacher.has-theory-open .teacher-teacher-main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) min(var(--teacher-theory-width, 57%), 57%);
    grid-template-areas: "error error" "work theory";
    gap: 0 var(--space-xl);
    align-items: start;
  }

  .teacher-teacher.has-theory-open .teacher-teacher-main > .teacher-error {
    grid-area: error;
  }

  .teacher-teacher.has-theory-open .teacher-work {
    grid-area: work;
  }

  .teacher-teacher.has-theory-open .teacher-work,
  .teacher-teacher.has-theory-open .teacher-theory-pane {
    height: 100%;
  }

  .teacher-teacher.has-theory-open .teacher-theory-pane {
    grid-area: theory;
  }
}

.teacher-pdf-page {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Sivut pinotaan ilman väliä kuten Mafynetissä, koska linkkien alueet on
   annettu koko dokumentin korkeudelta. */
.teacher-pdf-pages {
  position: relative;
  display: flex;
  flex-direction: column;
  align-self: flex-start;
}

/* Linkki PDF:n päällä: näkymätön alue, joka korostuu osoitettaessa. */
.teacher-pdf-link {
  position: absolute;
  display: block;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--blue-300);
  opacity: 0;
  cursor: pointer;
  mix-blend-mode: multiply;
}

.teacher-pdf-link:hover,
.teacher-pdf-link:focus-visible {
  opacity: 0.45;
  outline: 2px solid var(--blue-500);
  outline-offset: 0;
}

.teacher-outline-section + .teacher-outline-section {
  margin-top: var(--space-md);
  border-top: 2px solid var(--gray-200);
  padding-top: var(--space-sm);
}

.teacher-outline-section-title {
  margin: 0 0 var(--space-xs);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}

.teacher-outline-group {
  margin: var(--space-xs) 0 0 var(--space-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--gray-500);
}

/* Tehtävätyyppi ja monivalinnan vaihtoehdot */

.teacher-answer-format {
  margin: 0 0 var(--space-md);
  font-size: var(--text-sm);
  color: var(--gray-600);
}

.teacher-options {
  margin: var(--space-md) 0 0;
  padding-left: 1.75rem;
}

.teacher-options li {
  margin-bottom: var(--space-xs);
}

.teacher-options li::marker {
  font-weight: var(--font-semibold);
  color: var(--blue-900);
}

/* Kirjoituskenttä: teksti ja kaavat samassa kentässä (teacher-composer.js).
   Käyttötapa seuraa Mafynetin vastauseditoria. */

.teacher-composer-editor {
  flex: 1;
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--gray-400);
  border-radius: var(--radius-2xl);
}

.teacher-composer-editor:focus-within {
  outline: 2px solid var(--blue-500);
  outline-offset: 1px;
}

.teacher-composer-send {
  align-self: flex-end;
}

.teacher-editor {
  min-height: 4.5em;
  max-height: 40vh;
  overflow-y: auto;
  padding: var(--space-lg);
  line-height: 1.6;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.teacher-editor {
  position: relative;
}

/* Kehote kentän päällä, jotta kohdistin pysyy sen alussa. */
.teacher-editor.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  left: var(--space-lg);
  top: var(--space-lg);
  color: var(--gray-500);
  pointer-events: none;
}

.teacher-editor[contenteditable="false"] {
  color: var(--gray-500);
}

/* Kaava tekstin sisällä: pelkkä ladottu kaava, muokattavissa klikkaamalla */
.teacher-editor .teacher-formula {
  display: inline-block;
  min-width: 0.6em;
  min-height: 1em;
  margin: 0 0.1em;
  vertical-align: middle;
  cursor: pointer;
}

.teacher-editor .teacher-formula.is-active {
  opacity: 0.4;
}

.teacher-editor .teacher-formula code {
  font-size: var(--text-sm);
  color: var(--gray-600);
}

/* Avoin kaavalaatikko kaavan alla: vasemmalla ladottu kaava, oikealla LaTeX */
.teacher-math-box {
  position: relative;
  display: flex;
  width: 100%;
  margin: var(--space-sm) 0;
  background: var(--white);
  border-top: 3px solid #caedff;
  box-shadow: 0 3px 7px 0 rgba(0, 0, 0, 0.2);
}

.teacher-math-box-field {
  display: block;
  width: 50%;
  padding: 5px 10px;
  font-size: var(--text-lg);
  background: var(--white);
}

.teacher-math-box-latex {
  width: 50%;
  border: 0;
  border-left: 1px solid var(--gray-200);
  padding: 5px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  resize: none;
  background: var(--gray-50, #fafafa);
}

.teacher-math-box-latex:focus {
  outline: 1px solid var(--blue-500);
}

.teacher-math-box-error {
  position: absolute;
  top: 0;
  left: 0;
  padding: 5px 10px;
  font-size: var(--text-sm);
  color: var(--red-700, #b3261e);
  pointer-events: none;
}

.teacher-math-box .mq-editable-field.mq-focused {
  box-shadow: none;
  outline: 1px solid var(--blue-500);
}

.teacher-math-box .mq-math-mode .mq-root-block {
  white-space: nowrap;
}

/* Työkalupalkki kiinni yläpalkin alareunassa, josta se liukuu esiin kuten
   Mafynetissä. Mitat ja ryhmittely kuten Mafynetin editorissa (digabin
   rich-text-editor): 35 px painikkeet, merkit Symbola-fontilla, ryhmät 13, 3,
   3 ja 6 saraketta, kaavapohjat 17 × 2. */
.teacher-toolbar-bar {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--teacher-topbar-height, 0px);
  z-index: 20;
  animation: teacher-toolbar-slide-in 0.15s ease-out;
  background: #fff;
  border-bottom: 1px solid #dfdfdf;
  box-shadow: 0 1px 10px 1px rgba(0, 0, 0, 0.2);
}

/* Palkki on sisällön päällä kuten Mafynetissä (tilan varaaminen hyppäyttäisi
   sivua kenttää klikattaessa); vieritettäessä kenttä ja kaavalaatikko jäävät
   palkin alapuolelle. */
.teacher-composer,
.teacher-math-box {
  scroll-margin-top: calc(var(--teacher-topbar-height, 0px) + var(--teacher-toolbar-height, 0px) + var(--space-lg));
}

@keyframes teacher-toolbar-slide-in {
  from {
    transform: translateY(-100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .teacher-toolbar-bar {
    animation: none;
  }
}

.teacher-toolbar-bar[hidden],
.teacher-toolbar-bar [hidden] {
  display: none !important;
}

.teacher-toolbar {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0 var(--space-md);
}

.teacher-toolbar-templates {
  background: #fafafa;
  border-top: 1px solid #dfdfdf;
  gap: var(--space-2xl);
}

.teacher-toolbar button {
  border: 0;
  background: none;
  cursor: pointer;
  transition: background-color 75ms;
}

.teacher-toolbar button:hover:not(:disabled) {
  background-color: #f0f0f0;
}

.teacher-toolbar button:active:not(:disabled) {
  background-color: #e0e0e0;
}

.teacher-toolbar-eq {
  flex: none;
  height: 35px;
  padding: 0 var(--space-md);
  font: inherit;
  font-size: var(--text-base);
  color: var(--blue-700);
  white-space: nowrap;
}

.teacher-toolbar-groups {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.teacher-toolbar-group {
  display: inline-grid;
  grid-template-columns: repeat(var(--cols), 35px);
  align-content: start;
  margin: 0 var(--space-md);
}

.teacher-toolbar-char {
  width: 35px;
  height: 35px;
  padding: 0;
  font-family: Symbola, monospace;
  font-size: 16px;
  color: #555;
}

.teacher-toolbar-char.is-extra {
  display: none;
}

.teacher-toolbar-groups.is-expanded .teacher-toolbar-char.is-extra {
  display: inline-block;
}

.teacher-toolbar-toggle {
  flex: none;
  width: 35px;
  height: 35px;
  font-size: var(--text-sm);
  color: var(--blue-700);
}

.teacher-toolbar-template-grid {
  display: grid;
  grid-template-columns: repeat(17, 35px);
  grid-auto-rows: 35px;
}

.teacher-toolbar-template {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  padding: 0;
  overflow: hidden;
}

.teacher-toolbar-template img {
  max-width: 31px;
  max-height: 31px;
}

.teacher-toolbar-history {
  display: flex;
}

.teacher-toolbar-history-button {
  width: 35px;
  height: 35px;
  font-size: 20px;
  color: #555;
}

.teacher-toolbar-history-button:disabled {
  color: #bbb;
  cursor: default;
}

@media (max-width: 48rem) {
  .teacher-toolbar {
    flex-wrap: wrap;
  }

  .teacher-toolbar-template-grid {
    grid-template-columns: repeat(9, 35px);
  }

  .teacher-math-box {
    flex-direction: column;
  }

  .teacher-math-box-field,
  .teacher-math-box-latex {
    width: 100%;
  }

  .teacher-math-box-latex {
    border-left: 0;
    border-top: 1px solid var(--gray-200);
  }
}

/* Valittu kaava korostetaan kuten valittu teksti (SVG ei saa ::selection-
   korostusta). */
.teacher-math.is-selected {
  background-color: Highlight;
  color: HighlightText;
  border-radius: 2px;
}

/* Kysymys opetuksen päätteeksi: pääsetkö jatkamaan */

.teacher-continue {
  margin: var(--space-md) 0 0;
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--color-success-border, var(--gray-300));
  border-radius: var(--radius-xl, 12px);
  background: var(--color-success-bg, var(--gray-100));
  color: var(--color-success-text, inherit);
}

.teacher-continue p {
  margin: 0 0 var(--space-sm);
  font-weight: var(--font-medium);
}

.teacher-continue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.teacher-button-secondary {
  background: var(--white);
  color: var(--blue-900);
  border: 1px solid var(--gray-400);
}

/* Kuvaliite viestissä ja kentässä */

.teacher-message-image {
  display: block;
  max-width: 100%;
  max-height: 420px;
  border-radius: var(--radius-xl, 12px);
  margin: 0 0 var(--space-sm);
  background: var(--white);
}

.teacher-composer-image {
  position: relative;
  padding: var(--space-sm) var(--space-sm) 0;
}

.teacher-composer-thumb {
  display: block;
  max-height: 120px;
  max-width: 100%;
  border-radius: var(--radius-lg, 8px);
  border: 1px solid var(--gray-300);
}

.teacher-composer-remove {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: var(--gray-900);
  color: var(--white);
  font-size: 18px;
  line-height: 28px;
  cursor: pointer;
  opacity: 0.85;
}

.teacher-toolbar-attach {
  cursor: pointer;
}

.teacher-toolbar-attach-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Ylläpitäjän kirjautuminen Google-tunnuksella. */
.teacher-login {
  max-width: 28rem;
  margin: 0 auto;
}

.teacher-login-button {
  min-height: 44px;
  margin-top: var(--space-lg);
}
