* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f4f6fb;
  color: #1a1a2e;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

label {
  font-weight: 600;
}

input[type="text"],
input[type="number"] {
  font-size: 1.1rem;
  padding: 0.75rem;
  border: 1px solid #c4c9d6;
  border-radius: 0.5rem;
}

/* Whiteboard (build-order step 2) */

main.lesson {
  max-width: 30rem;
  padding-top: 3rem;
}

.whiteboard {
  background: white;
  border: 1px solid #c4c9d6;
  border-radius: 1rem;
  padding: 2rem 1.5rem;
  text-align: center;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.progress {
  margin: 0;
  color: #5b6472;
  font-weight: 600;
}

.question {
  margin-bottom: 2rem;
}

/* "Bus stop" long division notation. */
.bus-stop {
  display: inline-flex;
  align-items: flex-start;
  font-size: 2.5rem;
  font-variant-numeric: tabular-nums;
}

.bus-stop .divisor {
  padding-right: 0.35rem;
  margin-top: 0.3rem;
}

.bus-stop .bracket {
  border-top: 4px solid #1a1a2e;
  border-left: 4px solid #1a1a2e;
  border-radius: 0 0.5rem 0 0;
  padding: 0.15rem 0.5rem 0 0.6rem;
}

.answer-form {
  align-items: center;
}

.answer-label {
  font-size: 0.95rem;
}

#answer {
  font-size: 1.5rem;
  text-align: center;
  width: 8rem;
}

.feedback {
  min-height: 1.6rem;
  font-weight: 600;
}

.feedback--correct {
  color: #1a7f37;
}

.feedback--retry {
  color: #9a6700;
}

.feedback--error {
  color: #b3261e;
}

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

/* Working-out list (build-order step 3): accumulated whiteboard lines from
   the tutor's guided help. */
.working {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  text-align: left;
  font-size: 1.1rem;
}

.working:empty {
  display: none;
}

.working li {
  padding: 0.35rem 0.6rem;
  border-left: 3px solid #c4c9d6;
  margin-bottom: 0.35rem;
  background: #f4f6fb;
  border-radius: 0 0.4rem 0.4rem 0;
}

/* Tutor dialogue (build-order step 3) */
.dialogue {
  margin-top: 1.5rem;
  text-align: left;
  border-top: 1px solid #e1e4ec;
  padding-top: 1rem;
}

.dialogue-log {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dialogue-message {
  padding: 0.6rem 0.9rem;
  border-radius: 0.9rem;
  max-width: 85%;
  line-height: 1.4;
}

.dialogue-message--tutor {
  background: #eaf0ff;
  align-self: flex-start;
  border-bottom-left-radius: 0.2rem;
}

.dialogue-message--pupil {
  background: #2f5fdb;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 0.2rem;
}

.dialogue-message--pending {
  font-style: italic;
  color: #5b6472;
  animation: fade 1.4s ease-in-out infinite;
}

@keyframes fade {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.reply-form {
  flex-direction: row;
  margin: 0;
}

.reply-form input {
  flex: 1;
}

.mic-status {
  min-height: 1.4rem;
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
  color: #5b6472;
}

/* Hand up button (build-order step 4) */
.hand-up-button {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  background: white;
  color: #2f5fdb;
  border: 2px solid #2f5fdb;
}

.hand-up-button:active {
  background: #eaf0ff;
}

/* Round icon buttons: sound toggle, mic (build-order step 4) */
.icon-button {
  min-height: 3rem;
  min-width: 3rem;
  padding: 0;
  border-radius: 50%;
  background: #eaf0ff;
  color: #1a1a2e;
  font-size: 1.3rem;
  line-height: 1;
  flex: 0 0 auto;
}

.icon-button:active {
  background: #d5e0ff;
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#mic-button.listening {
  background: #b3261e;
  color: white;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(179, 38, 30, 0.4); }
  50% { box-shadow: 0 0 0 0.5rem rgba(179, 38, 30, 0); }
}

/* Large tap target: touch-first, no hover-dependent UI (Android tablet). */
button {
  font-size: 1.1rem;
  padding: 0.9rem 1.5rem;
  min-height: 3rem;
  border: none;
  border-radius: 0.5rem;
  background: #2f5fdb;
  color: white;
  cursor: pointer;
}

button:active {
  background: #24469f;
}

pre {
  white-space: pre-wrap;
  background: white;
  border: 1px solid #c4c9d6;
  border-radius: 0.5rem;
  padding: 1rem;
  min-height: 2rem;
}
