* {
  box-sizing: border-box;
}
.header-actions { display:flex; align-items:center; gap:14px; }
dialog { border:1px solid #d4ddd1; border-radius:24px; padding:26px; color:#243c33; background:#f7f5ee; width:min(620px, calc(100vw - 24px)); max-height:90dvh; overflow-y:auto; overscroll-behavior:contain; box-shadow:0 20px 80px #172e3440; }
dialog::backdrop { background:#132d2670; backdrop-filter:blur(4px); }
.settings-top { display:flex; align-items:center; justify-content:space-between; gap:12px; position:sticky; top:0; padding:12px 0; background:#f7f5ee; z-index:2; }
.settings-top h2 { font:500 32px/1.15 Georgia,serif; margin:0; }
.memory-controls button { margin:4px 3px; }
.actions { flex-wrap:wrap; }
#replay { font-size:14px; }
#returningNote { padding:12px 14px; border-radius:12px; background:#e9eee3; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline:3px solid #9b783c; outline-offset:3px; }
@media (max-width:600px) {
  header { padding-top:max(14px, env(safe-area-inset-top)); }
  .header-actions { gap:8px; }
  .daily { font-size:12px; }
  dialog { padding:20px; max-height:calc(100dvh - 30px); }
  main { padding-bottom:max(24px, env(safe-area-inset-bottom)); }
  .actions #mic { flex:1; }
}
body {
  margin: 0;
  background: #f7f5ee;
  color: #243c33;
  font:
    16px/1.55 "Segoe UI",
    system-ui,
    sans-serif;
}
header,
main {
  max-width: 1080px;
  margin: auto;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid #d6ded2;
}
.brand {
  font:
    600 26px Georgia,
    serif;
  color: inherit;
  text-decoration: none;
}
.brand span {
  display: inline-grid;
  place-items: center;
  background: #254e43;
  color: white;
  padding: 4px 7px;
  border-radius: 9px;
  font: 600 15px system-ui;
  vertical-align: middle;
}
.daily {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
main {
  display: grid;
  grid-template-columns: minmax(240px, 1.09fr) minmax(250px, 1fr);
  gap: clamp(26px, 5vw, 68px);
  align-items: center;
  padding: clamp(24px, 5vw, 58px) clamp(18px, 4vw, 48px);
}
[hidden] {
  display: none !important;
}
.avatar-scene {
  position: absolute;
  inset: 0;
}
.stage {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #e3dfd6 var(--classroom-poster, none) center / cover no-repeat;
  border-radius: 24px;
}
.name {
  position: absolute;
  bottom: 18px;
  left: 18px;
  z-index: 4;
  border-radius: 24px;
  padding: 5px 13px;
  color: white;
  background: #243d36db;
}
.name span {
  opacity: 0.8;
  font-size: 12px;
  margin-left: 5px;
}
.turn-state {
  position: absolute;
  right: 12px;
  bottom: 18px;
  z-index: 4;
  background: #fcfcf5ed;
  color: #254838;
  border-radius: 24px;
  padding: 6px 12px;
  font-size: 14px;
}
#timing {
  margin-top: 14px;
  color: #466050;
  font-size: 14px;
}
#timing summary {
  cursor: pointer;
}
.kicker {
  color: #71664d;
  letter-spacing: 0.12em;
  font-size: 14px;
  margin: 0;
}
h1 {
  font:
    500 clamp(34px, 5.4vw, 63px) / 1.05 Georgia,
    serif;
  letter-spacing: -0.047em;
  margin: 10px 0 20px;
}
.lead,
#caption {
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.5;
}
.small,
.voice p,
.voice a,
#heard,
#status {
  font-size: 14px;
  color: #4d6359;
}
.small {
  max-width: 48ch;
}
.voice {
  padding: 0 0 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
}
#voiceBox {
  border-top: 1px solid #ccd5c9;
  margin-top: 18px;
  color: #435c4e;
}
#voiceBox summary {
  cursor: pointer;
  padding: 12px 0;
  font-size: 15px;
}
.voice p {
  margin: 2px 0;
}
.voice a {
  font-size: 12px;
}
.actions,
.lesson-head,
form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.lesson-head {
  justify-content: space-between;
}
.lesson-head h1 {
  font-size: 34px;
}
button,
input {
  font: inherit;
}
button {
  background: #fdfcf8;
  border: 1px solid #adbdb0;
  border-radius: 12px;
  color: #244638;
  padding: 9px 14px;
  cursor: pointer;
  min-height: 44px;
}
button.primary,
form button {
  background: #245242;
  color: white;
  border-color: #245242;
}
.primary {
  padding: 12px 25px;
  font-weight: 600;
}
.recap {
  border-left: 3px solid #6b9073;
  padding: 0 0 0 14px;
  margin: 22px 0;
}
.recap h2 {
  font-size: 15px;
  margin: 0;
  color: #466050;
}
.recap p {
  margin: 3px 0;
  overflow-wrap: anywhere;
}
#phrase {
  font-size: 21px;
}
.recap button {
  margin-top: 6px;
}
#hint {
  background: #e8efe6;
  border-radius: 10px;
  padding: 9px 13px;
  color: #314d40;
}
#caption {
  overflow-wrap: anywhere;
}
button:disabled {
  cursor: default;
  opacity: 0.55;
}
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid #a87036;
  outline-offset: 3px;
}
form input {
  width: 100%;
  min-width: 0;
  border: 1px solid #aebbb0;
  background: white;
  padding: 12px;
  border-radius: 12px;
}
.language-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 16px;
}
.language-pair label {
  display: grid;
  gap: 3px;
  font-size: 0.88rem;
}
.language-pair select {
  color: inherit;
  font: inherit;
  border: 1px solid #aebbb0;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
}
.actions {
  flex-wrap: wrap;
  margin-top: 12px;
}
.quiet {
  border: 0;
  background: transparent;
  text-decoration: underline;
}
.sr {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
}
#status:empty,
#heard:empty {
  display: none;
}
.gate {
  display: block;
  max-width: 550px;
  margin: 8vh auto;
}
.gate h1 {
  font-size: 40px;
}
@media (max-width: 680px) {
  header {
    padding: 13px 20px;
  }
  .brand {
    font-size: 22px;
  }
  main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px 30px;
  }
  .portrait {
    width: min(100%, 43svh);
  }
  main:has(#session:not([hidden])) .portrait {
    width: min(100%, 30svh);
  }
  .lesson {
    width: 100%;
  }
  h1 {
    font-size: 36px;
    margin: 4px 0 10px;
  }
  .lead,
  #caption {
    margin: 8px 0 15px;
  }
  .voice {
    margin-top: 14px;
  }
  .lesson-head h1 {
    font-size: 28px;
  }
}

#settingsDialog { width:min(480px, calc(100vw - 24px)); }
.memory-controls { display:grid; gap:10px; margin-top:22px; }
.memory-controls > button { margin:0; text-align:left; }
