:root {
  color-scheme: light;
  --ink: #24303f;
  --muted: #647184;
  --line: #dce5ec;
  --panel: #ffffff;
  --paper: #f5f7f4;
  --accent: #2f6f73;
  --accent-dark: #1f5558;
  --accent-soft: #e5f2ef;
  --gold: #f3bd4e;
  --rose: #e8907c;
  --ok: #28775c;
  --warn: #b05d22;
  --shadow: 0 14px 36px rgba(58, 72, 86, 0.09);
}

* {
  box-sizing: border-box;
}

html.teacher-mode {
  overflow: auto;
  height: auto;
}

html.teacher-mode body {
  overflow: auto;
  height: auto;
  min-height: 100dvh;
}

.teacher-mode .shell {
  height: auto;
  min-height: 100dvh;
  align-content: start;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(229, 242, 239, 0.95), rgba(245, 247, 244, 0.6) 320px),
    var(--paper);
  color: var(--ink);
  font-size: 18px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  height: 100dvh;
  padding: 16px 0;
  display: grid;
  align-content: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.intro {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: #ffffff;
  border-color: #cbdedb;
}

.intro::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--rose));
}

.intro > * {
  position: relative;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.25rem, 7vw, 3.5rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.55rem;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.6;
  font-size: 1.08rem;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid #bfd7d4;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-pill.ready {
  border-color: #a9d4c5;
  color: var(--ok);
}

.setup {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
}

.setup h2 {
  grid-column: 1 / -1;
}

.gate {
  display: grid;
  gap: 16px;
  align-self: center;
  border-color: #d8dac9;
  background:
    linear-gradient(90deg, rgba(243, 189, 78, 0.15), transparent 44%),
    #ffffff;
}

.browser-warning {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  border-color: #f0c98c;
  background:
    linear-gradient(90deg, rgba(243, 189, 78, 0.2), transparent 55%),
    #fffdf8;
}

.browser-warning p {
  margin: 8px 0 0;
}

.warning-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#copyPageLink {
  background: #6d7783;
}

#copyPageLink:hover {
  background: #535f6b;
}

.gate p {
  margin: 8px 0 0;
}

.gate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

#gateMessage {
  margin: 0;
  font-weight: 650;
}

[hidden] {
  display: none !important;
}

label {
  display: grid;
  gap: 9px;
  color: #2b3440;
  font-weight: 650;
  font-size: 1.08rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #bdc9d0;
  border-radius: 8px;
  padding: 16px 15px;
  background: #ffffff;
  color: var(--ink);
  font-size: 1.16rem;
}

input:focus,
textarea:focus {
  outline: 3px solid rgba(47, 111, 115, 0.18);
  border-color: var(--accent);
}

select:focus {
  outline: 3px solid rgba(47, 111, 115, 0.18);
  border-color: var(--accent);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #34495e 50%),
    linear-gradient(135deg, #34495e 50%, transparent 50%);
  background-position:
    calc(100% - 22px) 50%,
    calc(100% - 15px) 50%;
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
  padding-right: 42px;
}

textarea {
  resize: vertical;
  min-height: 116px;
}

.help-button {
  position: fixed;
  right: 14px;
  top: 14px;
  z-index: 30;
  width: 52px;
  min-width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 999px;
  background: rgba(55, 78, 122, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.48);
  box-shadow: 0 12px 28px rgba(36, 48, 63, 0.24);
  backdrop-filter: blur(10px);
}

.help-button:hover {
  background: rgba(55, 78, 122, 0.88);
}

.help-icon::before {
  content: "?";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: 1.45rem;
  font-weight: 900;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(24, 32, 42, 0.42);
  backdrop-filter: blur(8px);
}

.success-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 32, 42, 0.36);
  backdrop-filter: blur(8px);
}

.success-card {
  width: min(520px, 92vw);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 70px rgba(23, 32, 42, 0.26);
  text-align: center;
}

.success-card img {
  width: min(100%, 420px);
  max-height: 45dvh;
  object-fit: contain;
  border-radius: 10px;
}

.success-card h2 {
  color: var(--ok);
  font-size: clamp(2rem, 7vw, 3rem);
}

#closeSuccessButton {
  min-width: 140px;
  background: var(--ok);
}

.help-card {
  position: relative;
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(23, 32, 42, 0.24);
}

.help-card p {
  margin: 0;
}

.close-help {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
}

.close-help:hover {
  background: #dfe7ee;
}

.help-actions {
  display: flex;
  justify-content: flex-end;
}

#submitHelpButton {
  background: #374e7a;
}

#helpMessage {
  margin: 0;
  font-weight: 700;
}

input[readonly] {
  background: #eef2f6;
  color: #3d4752;
}

button,
.upload-button,
.image-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
  font-size: 1.12rem;
  cursor: pointer;
}

button:hover,
.upload-button:hover,
.image-loader:hover {
  background: var(--accent-dark);
}

button:active,
.upload-button:active,
.image-loader:active {
  transform: translateY(1px);
}

button:disabled {
  background: #aeb9c4;
  cursor: not-allowed;
}

.assignment-header,
.recorder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

#homeworkArea {
  height: 100%;
  min-height: 0;
}

.assignment {
  height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  margin-bottom: 0;
}

.image-loader,
.upload-button {
  position: relative;
  overflow: hidden;
}

.image-loader input,
.upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.prompt-frame {
  position: relative;
  min-height: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px dashed #aeb9c4;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f7f3ea 25%, transparent 25%),
    linear-gradient(-45deg, #f7f3ea 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f7f3ea 75%),
    linear-gradient(-45deg, transparent 75%, #f7f3ea 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.prompt-frame img {
  --image-zoom: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  transform: scale(var(--image-zoom));
  transform-origin: center center;
  transition: transform 160ms ease;
}

figcaption {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: min(80%, 620px);
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.zoom-controls {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  gap: 8px;
  padding: 7px;
  border-radius: 999px;
  background: rgba(28, 37, 48, 0.24);
  backdrop-filter: blur(10px);
}

.zoom-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
}

.zoom-button:disabled {
  opacity: 0.42;
  background: rgba(36, 48, 63, 0.32);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.recording-stage {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.recorder-overlay {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  justify-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 999px;
  background: rgba(28, 37, 48, 0.28);
  backdrop-filter: blur(10px);
}

.recording-instruction {
  flex-basis: 100%;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.recorder-overlay #message {
  flex-basis: 100%;
  max-width: min(80vw, 680px);
  color: #ffffff;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.recorder-overlay #message:empty {
  display: none;
}

.icon-only,
.mic-button,
.direct-upload,
.listen-button,
.submit-audio-button {
  width: 56px;
  min-width: 56px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 999px;
  background: rgba(36, 48, 63, 0.44);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.icon-only:hover,
.mic-button:hover,
.direct-upload:hover,
.listen-button:hover,
.submit-audio-button:hover {
  background: rgba(36, 48, 63, 0.64);
}

.mic-button.is-recording {
  background: rgba(180, 35, 24, 0.72);
}

.mic-button.is-recording:hover {
  background: rgba(143, 31, 23, 0.84);
}

.audio-result {
  display: flex;
  gap: 10px;
  margin: 0;
}

.listen-button,
.submit-audio-button {
  gap: 12px;
}

.listen-button {
  background: rgba(47, 111, 115, 0.62);
}

.submit-audio-button {
  background: rgba(40, 119, 92, 0.66);
}

.button-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
}

.mic-icon::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 2px;
  width: 12px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 999px;
}

.mic-icon::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 14px;
  width: 20px;
  height: 13px;
  border: solid #ffffff;
  border-width: 0 3px 3px;
  border-radius: 0 0 16px 16px;
  box-shadow: 8px 10px 0 -6px #ffffff, 8px 13px 0 -6px #ffffff;
}

.listen-icon::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 10px;
  height: 14px;
  background: #ffffff;
  clip-path: polygon(0 28%, 42% 28%, 100% 0, 100% 100%, 42% 72%, 0 72%);
}

.listen-icon::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 7px;
  width: 8px;
  height: 16px;
  border: solid #ffffff;
  border-width: 0 3px 0 0;
  border-radius: 50%;
  box-shadow: 5px 0 0 -2px #ffffff;
}

.file-icon::before,
.send-icon::before,
.reset-icon::before {
  content: "";
  position: absolute;
  inset: 4px 6px 3px;
  border: 3px solid #ffffff;
  border-radius: 4px;
}

.file-icon::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 14px;
  width: 10px;
  height: 10px;
  border: solid #ffffff;
  border-width: 3px 3px 0 0;
  transform: rotate(-45deg);
}

.send-icon::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  width: 12px;
  height: 12px;
  border: solid #ffffff;
  border-width: 3px 3px 0 0;
  transform: rotate(-45deg);
}

.plus-icon::before,
.minus-icon::before,
.plus-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 12px;
  width: 16px;
  height: 4px;
  border-radius: 999px;
  background: #ffffff;
}

.plus-icon::after {
  transform: rotate(90deg);
}

.reset-icon::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 9px;
  width: 10px;
  height: 10px;
  border: solid #ffffff;
  border-width: 3px 0 0 3px;
  transform: rotate(-45deg);
}

#recordingTimer {
  min-width: 96px;
  text-align: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.98rem;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

audio {
  display: none;
}

.hint {
  margin-bottom: 0;
}

#enterAssignment {
  justify-self: start;
  min-width: 190px;
  background: #374e7a;
}

#enterAssignment:hover {
  background: #263a62;
}

#message {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
  font-size: 1.08rem;
}

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

#driveUploadFrame {
  position: absolute;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 12px, 1040px);
    padding: 8px 0;
  }

  .panel {
    padding: 16px;
  }

  .intro,
  .assignment-header,
  .setup,
  .browser-warning {
    display: grid;
  }

  .warning-actions {
    display: grid;
  }

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

  .gate-grid,
  .audio-result {
    grid-template-columns: 1fr;
  }

  .status-pill,
  button,
  .upload-button,
  .image-loader {
    width: 100%;
  }

  button,
  .upload-button,
  .image-loader {
    min-height: 54px;
  }

  .assignment {
    height: calc(100dvh - 16px);
  }

  .assignment-header {
    gap: 6px;
    margin-bottom: 8px;
  }

  .assignment-header .eyebrow {
    display: none;
  }

  .assignment-header h2 {
    font-size: 1.12rem;
  }

  .recorder-overlay {
    bottom: 10px;
    border-radius: 22px;
  }

  .recorder-overlay #message,
  #recordingTimer {
    flex-basis: 100%;
  }

  .icon-only,
  .mic-button,
  .direct-upload,
  .listen-button,
  .submit-audio-button {
    width: 50px;
    min-width: 50px;
    height: 50px;
    min-height: 50px;
  }

  figcaption {
    left: 8px;
    top: 8px;
    max-width: calc(100% - 16px);
    font-size: 0.78rem;
    border-radius: 12px;
  }

  .zoom-controls {
    right: 8px;
    top: 8px;
    gap: 6px;
    padding: 6px;
  }

  .zoom-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
  }
}
