@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap");

:root {
  font-family: "DM Sans", system-ui, sans-serif;
  color: #e4e7ef;
  background: #0b0d12;
  font-synthesis: none;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  height: 100dvh;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr);
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid #a9b4ff;
  outline-offset: 5px;
}
a {
  color: inherit;
  text-decoration: none;
}
.topbar {
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid #1c2029;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}
.brand b {
  font-weight: 400;
  color: #858c9e;
}
.brand-icon {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -2px;
  color: #b8c3ff;
}
main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 146px;
  padding: 16px 20px 0;
}
.board {
  min-height: 0;
  border: 1px solid #252a36;
  border-radius: 10px;
  background: #0e1119;
  overflow: hidden;
}
.voice-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr);
  align-items: center;
  padding: 0 4%;
  position: relative;
}
.voice-side p {
  font-size: 16px;
  color: #a3abc0;
  margin: 0;
  line-height: 1.5;
}
.voice-meta {
  text-align: right;
  justify-self: end;
}
.voice-meta > span {
  font-size: 12px;
  color: #a6a0c7;
}
.voice-meta p {
  font-size: 12px;
  color: #68738b;
  margin-top: 6px;
}
.orb-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.orb-button {
  width: 94px;
  height: 94px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  isolation: isolate;
}
.orb-halo {
  position: absolute;
  inset: 4px;
  background: radial-gradient(circle, #605ef977, transparent 70%);
  filter: blur(12px);
  transform: scale(1.55);
  opacity: 0.7;
  animation: halo 5s ease-in-out infinite;
}
.orb {
  display: block;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: radial-gradient(
    circle at 30% 22%,
    #f1f5ff 0%,
    #b8caff 12%,
    #717af4 36%,
    #6864d1 57%,
    #23264e 85%
  );
  box-shadow:
    inset -7px -9px 15px #121931bb,
    inset 3px 4px 12px #e6e6ff77,
    0 0 23px #6c64df50;
  border: 1px solid #becbff66;
  transition: transform 0.3s;
}
.orb-flow {
  position: absolute;
  inset: -25%;
  background: conic-gradient(
    from 40deg,
    transparent 5%,
    #a2e3ff88 20%,
    transparent 35%,
    #e4b8ff99 55%,
    transparent 70%,
    #7684ffbb
  );
  filter: blur(8px);
  mix-blend-mode: screen;
  animation: orbit 12s linear infinite;
}
.orb:after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border-top: 1px solid #edf4ff66;
  transform: rotate(-30deg);
}
.orb-button:hover .orb {
  transform: scale(1.08);
}
.orb-button:active .orb {
  transform: scale(0.96);
}
#voice-status {
  font-size: 12px;
  color: #b3bdd5;
  z-index: 1;
}
#notice:empty {
  display: none;
}
#notice {
  position: fixed;
  z-index: 6;
  bottom: 154px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(540px, 90vw);
  padding: 14px 20px;
  border: 1px solid #455075;
  background: #222b42;
  color: #d4def8;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 8px 30px #0006;
}
@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}
@keyframes halo {
  50% {
    opacity: 0.4;
    transform: scale(1.35);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
  }
}
@media (max-width: 760px) {
  body {
    grid-template-rows: 58px minmax(0, 1fr);
  }
  .topbar {
    padding: 0 16px;
  }
  .brand {
    font-size: 14px;
    gap: 8px;
  }
  main {
    padding: 10px 10px 0;
    grid-template-rows: minmax(0, 1fr) 130px;
  }
  .voice-dock {
    padding: 0 6px;
    grid-template-columns: minmax(0, 1fr) 108px minmax(0, 1fr);
  }
  .voice-side > p {
    font-size: 14px;
  }
  .voice-meta p {
    font-size: 12px;
  }
  .orb-button {
    height: 82px;
    width: 82px;
  }
  .orb {
    width: 60px;
    height: 60px;
  }
  #notice {
    bottom: 139px;
  }
}
@media (max-width: 420px) {
  main {
    grid-template-rows: minmax(0, 1fr) 164px;
  }
  .voice-dock {
    grid-template-columns: 1fr;
    grid-template-rows: 32px 1fr;
    justify-items: center;
    padding: 8px;
  }
  .voice-side > p {
    font-size: 16px;
  }
  .voice-meta {
    display: none;
  }
  .orb-button {
    height: 82px;
    width: 82px;
  }
  #notice {
    bottom: 174px;
  }
}
@media (max-height: 600px) and (min-width: 421px) {
  body {
    grid-template-rows: 48px minmax(0, 1fr);
  }
  main {
    grid-template-rows: minmax(0, 1fr) 98px;
    padding-top: 8px;
  }
  .orb-button {
    height: 64px;
    width: 64px;
  }
  .orb {
    height: 49px;
    width: 49px;
  }
  #notice {
    bottom: 108px;
  }
}
.orb-button .orb {
  transform: scale(calc(1 + var(--level, 0) * 0.25));
  transition: transform 80ms linear;
}
body[data-voice="active"] .orb-halo {
  animation: none;
  opacity: calc(0.35 + var(--level, 0) * 0.65);
  transform: scale(calc(1.3 + var(--level, 0) * 0.6));
}
.session-controls {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}
.session-controls button {
  border: 1px solid #455075;
  border-radius: 18px;
  padding: 6px 14px;
  font-size: 12px;
  background: #1a2030;
}
button[hidden],
[hidden] {
  display: none !important;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
#tutor-audio {
  position: fixed;
  bottom: 155px;
  right: 20px;
  max-width: 85vw;
  z-index: 7;
}
@media (max-width: 420px) {
  .voice-meta {
    display: block;
    position: absolute;
    right: 0;
    bottom: 24px;
  }
  .voice-meta > span,
  .voice-meta > p {
    display: none;
  }
  .session-controls {
    flex-direction: column;
    gap: 6px;
  }
  .voice-dock {
    padding-right: 55px;
  }
  .voice-side {
    grid-column: 1/-1;
  }
}

#lesson-panel {
  height: 100%;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 16px 20px;
  gap: 10px;
}
.lesson-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 32px;
}
.lesson-heading h1 {
  font-size: 17px;
  font-weight: 500;
  margin: 0;
  color: #c8d2ee;
}

.lesson-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #0e1119;
  border-radius: 6px;
}
.lesson-film {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.lesson-film.is-visible {
  opacity: 1;
}
#lesson-writing {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 6%;
  transition: opacity 0.35s ease;
  font-size: clamp(20px, 3.5vw, 38px);
  color: #dbd5ff;
  white-space: pre-wrap;
  overflow: auto;
}
#lesson-writing p {
  margin: 0;
  line-height: 1.5;
}
#lesson-writing.is-covered {
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .lesson-film,
  #lesson-writing {
    transition: none;
  }
}

/* Give the teaching surface priority over the surrounding controls. */
body {
  grid-template-rows: 48px minmax(0, 1fr);
}
.topbar {
  padding: 0 20px;
}
main {
  padding: 8px 12px 0;
  grid-template-rows: minmax(0, 1fr) 96px;
}
.voice-dock {
  padding: 0 2%;
}
.orb-button {
  width: 64px;
  height: 64px;
}
.orb {
  width: 50px;
  height: 50px;
}
#lesson-panel {
  padding: 10px 14px;
  gap: 4px;
}
.lesson-heading {
  min-height: 26px;
}
.lesson-heading h1 {
  font-size: 15px;
}
#lesson-writing {
  justify-content: flex-start;
  gap: 20px;
  padding: clamp(16px, 3vh, 32px) clamp(16px, 4vw, 56px);
  font-size: clamp(18px, 2.1vw, 28px);
  white-space: normal;
  scrollbar-width: thin;
}
.board-step {
  flex: none;
  min-width: 0;
  animation: step-arrive 0.35s ease both;
}
#lesson-writing .step-label {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: #9ca9c3;
  margin-bottom: 8px;
}
.step-equation {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 2px 10px;
  scrollbar-width: thin;
}
.step-equation .katex-display {
  margin: 0;
  text-align: left;
}
.step-equation .katex-display > .katex {
  text-align: left;
}
@keyframes step-arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 760px) {
  body {
    grid-template-rows: 44px minmax(0, 1fr);
  }
  main {
    padding: 6px 6px 0;
    grid-template-rows: minmax(0, 1fr) 92px;
  }
  #lesson-panel {
    padding: 8px;
  }
  .voice-side > p {
    font-size: 12px;
  }
  #lesson-writing {
    padding: 16px;
    gap: 18px;
    font-size: 18px;
  }
}
@media (max-width: 420px) {
  main {
    grid-template-rows: minmax(0, 1fr) 112px;
  }
  .voice-dock {
    grid-template-rows: 24px 1fr;
  }
  .voice-meta {
    bottom: 12px;
  }
  .voice-side > p {
    font-size: 13px;
  }
}

/* Keep session actions clear of the hosting badge in the lower-right corner. */
@media (min-width: 761px) {
  .voice-meta { margin-right: 190px; }
}
@media (max-width: 760px) {
  .voice-meta { align-self: start; margin-top: 4px; }
  .voice-meta > span, .voice-meta > p { display: none; }
  .session-controls { margin-top: 0; }
}
@media (max-width: 420px) {
  .voice-meta { top: 8px; bottom: auto; right: 8px; }
  .session-controls { flex-direction: row; }
}
