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

/* Theme and shared elements */
:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --header-bg: #edf0e7;
  --ink: #293d35;
  --muted: #859086;
  --line: #e2e6dc;
  --green: #3c6453;
  --audio-idle: #d4dbce;
  --microphone-active: hsl(12 16% 47%);
  --recording: #a75c49;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --answer-caption-gap: 6px;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.7 'Noto Sans KR',
    sans-serif;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  border: 0;
  background: none;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
a {
  color: inherit;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #91a873;
  outline-offset: 4px;
}
h1,
h2 {
  margin: 0;
  font-weight: 500;
}
h1 {
  font-size: 30px;
  letter-spacing: -1px;
  line-height: 1.6;
}
h2 {
  font-size: 19px;
}
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-weight: 500;
}
.text-button {
  padding: 12px 4px;
  color: var(--muted);
  font-size: 12px;
}
.icon {
  min-width: 44px;
  min-height: 44px;
  font-size: 22px;
  color: var(--muted);
}
.speaker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 34px;
  color: var(--green);
}
.speaker-button svg {
  display: block;
  flex-shrink: 0;
}
.label {
  display: block;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
}
.muted {
  font-size: 12px;
  color: var(--muted);
}
.fine {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.9;
  margin-top: 20px;
}

/* Page layout and brand */
.app {
  --app-inline-padding: 28px;
  --conversation-scroll-inset: 12px;
  display: flex;
  flex-direction: column;
  max-width: 660px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px var(--app-inline-padding) 14px;
}
header {
  gap: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 29.7px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -1px;
  text-decoration: none;
}
#menuButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  padding: 8px;
  color: var(--ink);
}
#menuButton svg {
  display: block;
  width: 35px;
  height: 35px;
}
main {
  display: flex;
  flex: 1;
  flex-direction: column;
}
#talkView {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 20px 0 12px;
}
#welcome {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 12px 0;
}
#welcome h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.45;
  letter-spacing: -0.5px;
}
.welcome-guide {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.welcome-guide span {
  display: block;
}
footer {
  padding-top: 20px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}
.footer-copyright {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.footer-icon {
  display: block;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  padding: 1px;
  background: #fff;
}
.review-copyright {
  margin-top: 20px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}
.footer-contact-label {
  font-size: 0.85em;
}
.service-brand,
#menu[data-view='home'] #menuTitle {
  display: inline-flex;
  align-items: center;
  gap: 0.32em;
  vertical-align: middle;
  line-height: 1.15;
  white-space: nowrap;
}
.service-brand::before,
#menu[data-view='home'] #menuTitle::before {
  content: '';
  display: block;
  flex: none;
  width: 1.8em;
  height: 1.8em;
  background: url('/footer-icon.svg?v=iqua5') center / contain no-repeat;
}
@media print {
  .service-brand::before {
    filter: grayscale(1);
  }
}

/* Conversation, model answer and recording */
.question {
  padding: 12px 0 20px;
}
.question h1 {
  font-size: 20px;
  line-height: 1.45;
  letter-spacing: -0.4px;
  overflow-wrap: anywhere;
}
details {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
summary {
  width: fit-content;
  cursor: pointer;
}
details p {
  margin: 10px 0;
}
.words {
  display: grid;
  gap: 0;
  margin-top: 10px;
}
.word {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 8px;
  font-size: 12px;
  line-height: 1.5;
}
.word b {
  font-weight: 500;
  color: var(--ink);
}
.word span {
  color: var(--muted);
}
.word em {
  font-size: 11px;
  font-style: normal;
  color: #667c69;
}
.model-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#modelBox .label {
  margin: 0;
  color: #a65f59;
  font-size: 13px;
}
.original-answer,
.note .original-answer {
  margin: 0 0 var(--answer-caption-gap);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#originalAnswer {
  color: #6d7a70;
}
#modelAnswer {
  margin: 0;
  font-size: 25px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.answer-hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.recording {
  background: #a75c49;
}
#conversation.paused {
  opacity: 0.55;
}
#answerForm {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Audio state and decorative EQ motion */
.audio-status-group {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}
.voice-status {
  position: relative;
  width: 28px;
  height: 28px;
  min-height: 28px;
  flex: 0 0 28px;
  margin: 0;
  color: #647a6b;
}
.status-ring {
  position: absolute;
  inset: 0;
  /* Cut only the ring behind the microphone; the meter remains unobscured. */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 72% 100%, 72% 68%, 28% 68%, 28% 100%, 0 100%);
}
.status-dot {
  position: absolute;
  inset: 0;
  display: block;
  width: 28px;
  height: 28px;
  border: 2px solid var(--audio-idle);
  border-radius: 50%;
  background: none;
}
.voice-status[data-state='thinking'] .status-dot,
.voice-status[data-state='loading'] .status-dot {
  border-top-color: var(--green);
  animation: spin 1s linear infinite;
}
.level-meter {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  width: 20px;
  height: 10px;
  align-items: center;
  justify-content: center;
  gap: 1.2px;
}
.level-meter i {
  display: block;
  flex: 0 0 1.5px;
  width: 1.5px;
  height: 10px;
  border-radius: 2px;
  background: var(--green);
  transform: scaleY(0.15);
  transform-origin: center;
}
.voice-status:is([data-state='playing'], [data-state='recording']) .level-meter i {
  animation: meter-center 1.3s ease-in-out var(--meter-delay, 0s) infinite;
}
.level-meter i:nth-child(3) {
  --meter-delay: -0.3s;
}
.level-meter i:nth-child(4) {
  --meter-delay: -0.9s;
}
.level-meter i:nth-child(5) {
  --meter-delay: -0.6s;
}
.voice-status:is([data-state='playing'], [data-state='recording'])
  .level-meter
  i:is(:nth-child(1), :nth-child(2), :nth-child(6), :nth-child(7)) {
  animation-name: meter-edge;
  animation-duration: 4.8s;
}
.level-meter i:nth-child(1) {
  --meter-delay: -1.1s;
}
.level-meter i:nth-child(2) {
  --meter-delay: -1.4s;
}
.level-meter i:nth-child(6) {
  --meter-delay: -3.5s;
}
.level-meter i:nth-child(7) {
  --meter-delay: -3.2s;
}
@keyframes meter-center {
  0%,
  100% {
    transform: scaleY(0.3);
  }
  20% {
    transform: scaleY(0.95);
  }
  45% {
    transform: scaleY(0.4);
  }
  70% {
    transform: scaleY(1);
  }
  85% {
    transform: scaleY(0.55);
  }
}
@keyframes meter-edge {
  0%,
  40%,
  70%,
  100% {
    transform: scaleY(0.18);
  }
  48% {
    transform: scaleY(0.65);
  }
  55% {
    transform: scaleY(0.3);
  }
  62% {
    transform: scaleY(0.85);
  }
}
.voice-status:not([data-state='playing']):not([data-state='recording']) .level-meter i {
  transform: scaleY(0.15) !important;
  opacity: 0.4;
}
.voice-status[data-state='recording'] .level-meter i {
  background: var(--recording);
}
.microphone-status {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: calc(100% - 3px);
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(100% / 3 + 4px);
  height: calc(100% / 3 + 2px);
  color: var(--audio-idle);
}
.microphone-status svg {
  display: block;
  width: calc(28px / 3);
  height: calc(28px / 3);
  flex-shrink: 0;
}
.microphone-status[data-permission='granted'] {
  color: var(--microphone-active);
}
.microphone-status[data-permission='denied'] {
  color: hsl(92 25% 57%);
}
.microphone-status[data-permission='granted'] .microphone-slash {
  display: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Direct difficulty/speed controls and equal voice menus */
.quick-controls {
  --settings-title-width: 100px;
  --settings-speaker-width: 34px;
  --settings-column-gap: 6px;
  --settings-options-start: calc(
    var(--settings-title-width) + var(--settings-speaker-width) + var(--settings-column-gap) * 2
  );
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 16px;
  flex-shrink: 0;
  margin-top: 28px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.control-title {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.7;
}
.difficulty-scale {
  display: flex;
  gap: 4px;
  width: 100%;
}
.difficulty-scale button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 4px;
  border-radius: 5px;
  background: #e9eddf;
  color: var(--muted);
  font-size: 11px;
}
.difficulty-scale .selected {
  background: var(--green);
  color: #fff;
}
.voice-picker {
  grid-column: 1/-1;
}
.voice-picker-heading {
  display: grid;
  grid-template-columns: var(--settings-title-width) var(--settings-speaker-width) minmax(0, 1fr);
  align-items: center;
  gap: var(--settings-column-gap);
  margin-bottom: 5px;
}
#previewVoice,
#previewAnswerVoice {
  width: var(--settings-speaker-width);
  min-width: var(--settings-speaker-width);
  min-height: 30px;
  margin-left: 0;
  padding: 5px;
}
.voice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: calc(100% - var(--settings-options-start));
  margin-left: var(--settings-options-start);
  gap: 6px;
}
.voice-grid label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-width: 0;
  margin: 0;
  font-size: 10px;
  color: var(--muted);
}
.voice-grid select {
  flex: 1;
  width: 0;
  min-width: 0;
  min-height: 34px;
  padding: 4px 7px;
  font-size: 12px;
  color: var(--ink);
}
/* Forms, account/settings dialogs and menu */
dialog#menu[data-view='roleplay'][open] {
  display: flex;
  flex-direction: column;
  height: min(740px, 90dvh);
  overflow: hidden;
}
#menu[data-view='roleplay'] > .dialog-heading {
  flex: none;
}
#roleplayView:not([hidden]) {
  display: flex;
  flex: 1;
  min-height: 0;
}
.roleplay-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  gap: 12px;
}
.roleplay-scroll-frame {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}
.roleplay-fields {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  flex: 1;
  min-width: 0;
  min-height: 0;
  gap: 12px;
}
.roleplay-fields > .muted {
  margin: 0;
}
.roleplay-fields > label {
  margin: 0;
}
.roleplay-form textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 180px;
  height: clamp(180px, 24dvh, 220px);
  padding: 12px;
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  color: inherit;
  background: var(--paper, #fff);
  border: 1px solid var(--line, #ddd);
  border-radius: 12px;
  resize: none;
}
.roleplay-form .fine {
  margin: 0;
}
.roleplay-form > .primary {
  flex: none;
  margin: 0;
}
.roleplay-preset-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}
.roleplay-preset-section h3 {
  flex: none;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}
.roleplay-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  padding-right: 12px;
}
.roleplay-presets button {
  /* Keep the hidden accessible label inside its button. */
  position: relative;
  min-height: 40px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 12px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
.roleplay-presets button[aria-pressed='true'] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.roleplay-presets:focus-visible,
.roleplay-presets button:focus-visible {
  outline: 2px solid #91a873;
  outline-offset: 1px;
}
@media (max-height: 640px) {
  dialog#menu[data-view='roleplay'][open] {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 16px;
  }
  .roleplay-form,
  .roleplay-fields {
    gap: 8px;
  }
  .roleplay-fields > .muted {
    font-size: 11px;
    line-height: 1.5;
  }
  .roleplay-form textarea {
    min-height: 68px;
    height: clamp(68px, 18dvh, 128px);
  }
}
form input,
select {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffefb;
  font-size: 16px;
}
form label,
.interests-label {
  display: block;
  margin: 18px 0 7px;
  font-size: 12px;
}
form .primary {
  margin-top: 24px;
}
.check {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  line-height: 1.7;
}
.check input {
  font: inherit;
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  /* Match the first graphic line's centre, including when the label wraps. */
  margin: calc(0.85em - 8px) 0 0;
}
.minor-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
dialog {
  width: calc(100% - 36px);
  max-width: 430px;
  max-height: 90dvh;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
  color: var(--ink);
}
dialog::backdrop {
  background: #233c3555;
  backdrop-filter: blur(4px);
}
/* Reserve content space separately: overlay scrollbars can ignore scrollbar-gutter. */
:where(
  dialog,
  textarea,
  .roleplay-presets,
  .graphic-select-list,
  .question,
  .model-scroll,
  .answer-pane,
  .admin-table-wrap
) {
  scrollbar-width: thin;
  scrollbar-color: #b5bfb5 transparent;
}
:where(
  dialog,
  textarea,
  .roleplay-presets,
  .graphic-select-list,
  .question,
  .model-scroll,
  .answer-pane,
  .admin-table-wrap
)::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
:where(
  dialog,
  textarea,
  .roleplay-presets,
  .graphic-select-list,
  .question,
  .model-scroll,
  .answer-pane,
  .admin-table-wrap
)::-webkit-scrollbar-thumb {
  background: #b5bfb5;
  border-radius: 6px;
}
nav {
  display: grid;
  margin-top: 20px;
}
nav button {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 9px 13px;
  border-radius: 99px;
  background: #e9ecdf;
  font-size: 12px;
}
.chip.on {
  background: var(--green);
  color: white;
}

/* Review notes */
dialog#menu[data-view='admin'] {
  width: min(960px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.admin-stats > div {
  padding: 14px;
  border-radius: 10px;
  background: var(--header-bg);
}
.admin-stats > div > span,
.admin-meta {
  display: block;
  color: #6d7a70;
  font-size: 11px;
}
.admin-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 25px;
  font-weight: 500;
}
.admin-note {
  color: #6d7a70;
  font-size: 11px;
  line-height: 1.6;
}
.admin-search {
  margin: 24px 0 14px;
}
.admin-search label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}
.admin-search > div {
  display: flex;
  gap: 8px;
}
.admin-search input {
  flex: 1;
  width: 0;
  min-width: 0;
  margin: 0;
}
.admin-search button {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--header-bg);
  font-size: 12px;
}
.admin-table-wrap {
  overflow-x: auto;
  padding-bottom: 12px;
}
.admin-scroll-hint {
  display: none;
  color: #6d7a70;
  font-size: 11px;
}
@media screen and (max-width: 900px) {
  .admin-scroll-hint {
    display: block;
  }
}
.admin-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}
.admin-table th,
.admin-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.admin-table th {
  font-weight: 500;
  white-space: nowrap;
}
.admin-email {
  display: block;
  overflow-wrap: anywhere;
  min-width: 180px;
  max-width: 260px;
}
.admin-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.admin-usage-title {
  font-size: 17px;
  overflow-wrap: anywhere;
  margin: 20px 0 8px;
}
.admin-stats.admin-usage-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.admin-usage-stats > div {
  padding: 12px;
}
.admin-usage-stats strong {
  font-size: 22px;
}
.admin-member-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 10px;
}
.admin-usage-link,
.admin-delete-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.admin-delete-link {
  color: #985c4d;
}
.admin-delete-email {
  overflow-wrap: anywhere;
  font-weight: 500;
  margin: 20px 0;
}
.admin-delete-description {
  font-size: 14px;
  line-height: 1.7;
}
.admin-delete-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.admin-delete-actions button {
  flex: 1;
  min-width: 0;
  padding: 14px 10px;
  border-radius: 12px;
}
#adminDeleteConfirm {
  color: #fff;
  background: #985c4d;
}
#withdrawalSubmit {
  background: #985c4d;
}
#openWithdrawal {
  color: #985c4d;
}
.admin-usage-search {
  display: flex;
  align-items: end;
  gap: 10px;
  margin: 24px 0 12px;
}
.admin-usage-search label {
  flex: 1;
  min-width: 0;
  font-size: 12px;
}
.admin-usage-search input {
  width: 100%;
  min-width: 0;
  margin: 6px 0 0;
  font-size: 12px;
}
.admin-usage-search button {
  flex-shrink: 0;
  padding: 12px 2px;
}
@media screen and (max-width: 600px) {
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
#reviewDate {
  margin: 0 0 28px;
}
#reviewView h2 {
  margin: 30px 0 15px;
  font-size: 16px;
}
/* Small screens and motion preference */
@media (max-width: 480px) {
  .app {
    --app-inline-padding: 20px;
    padding: 10px var(--app-inline-padding) 12px;
  }
  .brand {
    font-size: 26px;
  }
  #talkView {
    padding: 16px 0 8px;
  }
  #welcome h1 {
    font-size: 20px;
  }
  .question h1 {
    font-size: 18px;
  }
  .quick-controls {
    margin-top: 24px;
    gap: 16px 12px;
  }
}
@media (max-width: 380px) {
  .brand {
    font-size: 24px;
    gap: 8px;
  }
  #menuButton {
    width: 44px;
    height: 44px;
  }
  #menuButton svg {
    width: 33px;
    height: 33px;
  }
  #welcome h1 {
    font-size: 19px;
  }
  .question h1 {
    font-size: 17px;
  }
  .voice-grid select {
    padding: 4px;
  }
  .control-title {
    font-size: 11px;
  }
}
@media (max-width: 350px) {
  .app {
    --app-inline-padding: 16px;
    padding-left: var(--app-inline-padding);
    padding-right: var(--app-inline-padding);
  }
  .brand {
    font-size: 22px;
    gap: 6px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
  .status-dot {
    animation: none !important;
  }
  .level-meter i {
    animation: none !important;
    transform: scaleY(0.55);
  }
}

.speed-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}
.speed-options button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 34px;
  padding: 4px;
  border-radius: 5px;
  background: #e9eddf;
  color: var(--muted);
  font-size: 10px;
}
.speed-options .selected {
  background: var(--green);
  color: #fff;
}
.note {
  --answer-row: 2;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: baseline;
  column-gap: 10px;
}
.note:has(> .original-answer) {
  --answer-row: 3;
}
.note > .original-answer {
  grid-column: 2;
  grid-row: 2;
}
.note > .speaker-button {
  grid-column: 1;
  grid-row: var(--answer-row);
  display: block;
  min-height: 0;
  height: auto;
  padding: 0;
  font-size: 17px;
}
.note > .speaker-button svg {
  display: inline-block;
  /* Keep the icon centered on the first line's capitals, even when it wraps. */
  vertical-align: -0.2em;
  vertical-align: calc(0.5cap - 10px);
}
.note .speaker-button {
  flex-shrink: 0;
  color: var(--green);
}
.note p {
  margin: 0;
  font-size: 17px;
}

.question {
  position: relative;
}
.answer-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}
.answer-buttons #mic {
  flex: 1;
  min-width: 0;
}
.turn-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.turn-actions .primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #8c7c62;
  color: #fff;
  font-size: 12px;
}
.turn-actions #changeTopic {
  background: #697b77;
}

.word-heading {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}
.word .word-heading {
  color: var(--ink);
}

.translation {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.note > div {
  grid-column: 2;
  grid-row: var(--answer-row);
  min-width: 0;
}
.note .translation {
  font-size: 12px;
  margin-top: 6px;
}

/* Native A4 review document */
.print-only {
  display: none;
}
.review-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
#saveReviewPdf {
  color: var(--green);
  font-weight: 500;
}
@page {
  size: A4 portrait;
  margin: 18mm 17mm;
}
@media print {
  html,
  body {
    margin: 0;
    padding: 0;
    background: #fff;
    color: #202820;
    font-size: 10pt;
    line-height: 1.6;
  }
  .app {
    width: auto;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
  }
  .app > header,
  .app > footer,
  #voiceStatus,
  #talkView,
  dialog,
  #reviewView > .muted,
  #reviewView > label,
  #reviewDate,
  #reviewView button,
  #reviewView svg {
    display: none !important;
  }
  main {
    display: block;
    margin: 0;
    padding: 0;
  }
  #reviewView {
    width: 100%;
    margin: 0;
    padding: 0;
  }
  .print-only {
    display: block;
  }
  .review-print-heading {
    padding-bottom: 5mm;
    margin-bottom: 7mm;
    border-bottom: 1pt solid #45584d;
  }
  .review-print-brand {
    margin: 0 0 2mm;
    font-size: 19pt;
    font-weight: 600;
    color: #253d30;
  }
  #reviewPrintDate {
    margin: 0;
    font-size: 10pt;
    color: #555;
  }
  #reviewContent h2 {
    margin: 7mm 0 3mm;
    padding-bottom: 2mm;
    border-bottom: 0.5pt solid #ccc;
    font-size: 12pt;
    break-after: avoid;
    page-break-after: avoid;
  }
  #reviewContent .note {
    display: block;
    padding: 4mm 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  #reviewContent .note p {
    font-size: 11pt;
    line-height: 1.65;
    overflow-wrap: anywhere;
  }
  #reviewContent .note .translation {
    margin: 1.5mm 0 0;
    font-size: 9pt;
    color: #555;
  }
  #reviewContent p {
    orphans: 3;
    widows: 3;
  }
  .review-print-footer .footer-icon {
    filter: grayscale(1);
  }
  .review-print-footer {
    margin-top: 8mm;
    padding-top: 3mm;
    border-top: 0.5pt solid #ccc;
    font-size: 8pt;
    color: #777;
  }
}

#menuTitle {
  flex: 1;
}
#menu[data-view='review'] {
  max-height: 85dvh;
  overflow-y: auto;
}
#menu[data-view='review'] > .dialog-heading {
  position: sticky;
  top: -24px;
  z-index: 2;
  margin-top: -24px;
  padding-top: 24px;
  padding-bottom: 8px;
  background: var(--bg);
}
#reviewTop,
#menuClose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  line-height: 1;
}
#menu #reviewView .review-actions {
  justify-content: flex-end;
  margin: 0 0 8px;
}
@media print {
  .app {
    display: none !important;
  }
  dialog#menu {
    display: block !important;
    position: static;
    width: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: visible;
    background: #fff;
    box-shadow: none;
  }
  #menu > .dialog-heading,
  #menuHome,
  #menu .review-actions {
    display: none !important;
  }
  #menu::backdrop {
    display: none;
  }
}

/* Compact vertical rhythm on phones; audio indicators keep a constant frame. */
@media screen and (max-width: 600px) {
  .app {
    padding-top: 12px;
    padding-bottom: 10px;
  }
  #talkView {
    padding: 6px 0;
  }
  #welcome {
    padding: 8px 0;
    gap: 10px;
  }
  .question {
    padding: 4px 0 10px;
  }
  .translation {
    margin: 4px 0 7px;
    font-size: 12px;
    line-height: 1.5;
  }
  #modelBox .label {
    font-size: 12px;
  }
  .words {
    margin-top: 6px;
    gap: 0;
  }
  .model-heading {
    gap: 8px;
  }
  #modelAnswer {
    font-size: 23px;
    line-height: 1.45;
  }
  .answer-buttons .primary,
  .turn-actions .primary {
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .turn-actions {
    margin-top: 8px;
    gap: 8px;
  }
  .answer-hint {
    margin-top: 6px;
    line-height: 1.5;
  }
  .quick-controls {
    margin-top: 16px;
    padding: 12px 0;
    gap: 12px;
  }
  footer {
    padding-top: 10px;
  }
}
@media screen and (max-width: 600px) and (max-height: 740px) {
  .app {
    padding-top: 8px;
  }
  #talkView {
    padding-top: 2px;
  }
  .question h1 {
    font-size: 17px;
    line-height: 1.35;
  }
  .question {
    padding-top: 2px;
    padding-bottom: 7px;
  }
  #welcome h1 {
    font-size: 18px;
  }
  #welcome {
    gap: 8px;
    padding-bottom: 6px;
  }
  .welcome-guide {
    font-size: 11px;
    line-height: 1.65;
  }
  .answer-hint {
    font-size: 10px;
  }
}

.answer-buttons #retryAnswer {
  flex: 1;
  min-width: 0;
  width: auto;
}

#conversation .answer-buttons {
  display: grid;
  gap: 12px;
}
#conversation .answer-buttons .primary {
  width: 100%;
  min-height: 48px;
  height: 48px;
  padding: 8px 6px;
}
#retryAnswer.retry-unavailable {
  display: none;
}
@media screen and (max-width: 600px) {
  #conversation .answer-buttons {
    gap: 8px;
  }
  #conversation .answer-buttons .primary {
    height: 44px;
    min-height: 44px;
    font-size: 12px;
  }
}

/* Two independent scrolling panes with stationary answer actions. */
body.in-conversation {
  overflow: hidden;
}
body.in-conversation .app {
  height: 100dvh;
  min-height: 0;
}
body.in-conversation main,
body.in-conversation #talkView {
  min-height: 0;
}
body.in-conversation #talkView {
  padding-top: 0;
  padding-bottom: 0;
}
body.in-conversation .app > footer {
  display: none;
}
#conversation {
  display: grid;
  grid-template-rows: minmax(0, var(--question-pane-height, 1fr)) minmax(0, 1fr);
  height: var(--conversation-height, calc(100dvh - 100px));
  min-height: 0;
  flex: 0 0 auto;
}
.question-frame,
.model-scroll-frame {
  position: relative;
  min-height: 0;
  border-bottom: 0;
}
/* Keep controls, divider and overflow arrow on one shared coordinate system. */
.pane-footer {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: var(--pane-divider-inset);
  display: grid;
  grid-template-rows: var(--pane-audio-height) 1px;
  gap: var(--pane-audio-gap);
  background: var(--bg);
}
.pane-divider {
  position: relative;
  height: 1px;
  background: #bcc8bc;
  pointer-events: none;
}
.has-more-below > .pane-footer > .pane-divider {
  background: linear-gradient(
    to right,
    #bcc8bc calc(50% - 10px),
    transparent calc(50% - 10px),
    transparent calc(50% + 10px),
    #bcc8bc calc(50% + 10px)
  );
}
/* One unrotated frame keeps both chevrons intact at the divider. */
.pane-divider::after,
.answer-fixed-controls.has-more-below::after,
.roleplay-scroll-frame.has-more-below::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: calc(50% - 5px);
  width: 10px;
  height: 10px;
  z-index: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='%23849186' stroke-width='1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 2 3 3 3-3M2 5l3 3 3-3'/%3E%3C/svg%3E")
    center / contain no-repeat;
  pointer-events: none;
}
.pane-divider::after {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  visibility: hidden;
}
.has-more-below > .pane-footer > .pane-divider::after {
  visibility: visible;
}
#conversation .question-frame .question {
  height: 100%;
  padding-bottom: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  overscroll-behavior-y: contain;
}
/* Keep scroll tracks close to the conversation, with clearance beside controls. */
#conversation .question-frame .question,
.model-scroll {
  position: relative;
  z-index: 0;
  width: calc(100% + var(--conversation-scroll-inset));
  padding-right: var(--conversation-scroll-inset);
}
.answer-pane {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  padding-top: 10px;
  margin-right: calc(-1 * var(--conversation-scroll-inset));
  padding-right: var(--conversation-scroll-inset);
}
.model-scroll-frame {
  height: var(--model-pane-height, 160px);
  flex-shrink: 0;
}
.model-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
}
.model-scroll .answer-hint {
  margin: 0;
  padding: 0 12px 12px;
  text-align: center;
  font-size: 12px;
  line-height: 1.9;
}
.model-scroll .answer-hint span {
  display: block;
}
.answer-fixed-controls {
  position: relative;
  z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid #bcc8bc;
  padding-top: 14px;
  padding-bottom: 14px;
}
.answer-fixed-controls .turn-actions {
  margin-top: 0;
  margin-bottom: 8px;
}
.answer-scroll {
  overflow: visible;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.model-frame {
  margin-bottom: 0;
}
#conversation .model-frame #modelBox {
  height: auto;
  min-height: 110px;
  overflow: visible;
  margin: 0;
  padding: 0 0 10px;
  background: transparent;
  border-radius: 0;
}
#conversation .answer-scroll .quick-controls {
  margin-top: 0;
  padding-top: 6px;
  border-top: none;
}
@media screen and (max-width: 600px) {
  .answer-fixed-controls {
    padding-bottom: 14px;
  }
  .answer-pane {
    padding-top: 8px;
  }
}

@media print {
  body.in-conversation {
    overflow: visible !important;
    height: auto !important;
  }
}

/* A gently separated brand row; do not reserve empty model-answer space. */
.app > header {
  position: relative;
  --header-inline-padding: 10px;
  --header-menu-width: 48px;
  --header-menu-glyph: 35.2px;
  --header-control-gap: 8px;
  --header-status-scale: 1.1;
  --header-status-right-margin: 0px;
  /* Menu ink spans x=3..21 of its 24-unit SVG, including rounded stroke caps. */
  --header-ink-inset: calc((var(--header-menu-width) - var(--header-menu-glyph) * 0.75) / 2);
  gap: var(--header-control-gap);
  background: var(--header-bg);
  border-radius: 12px;
  padding: 4px var(--header-inline-padding);
  margin-bottom: 0;
}
.app > header #menuButton {
  flex: 0 0 var(--header-menu-width);
  width: var(--header-menu-width);
  min-width: 0;
  padding: 0;
}
.app > header #menuButton svg {
  flex: none;
  width: var(--header-menu-glyph);
  height: var(--header-menu-glyph);
}
.model-frame:has(> #modelBox[hidden]) {
  display: none;
}
.brand-signature {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  padding: 5px 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  word-spacing: -0.125em;
}
.brand-signature > span {
  display: block;
  white-space: nowrap;
}
.brand-accent {
  color: #a65f59;
  font-weight: 500;
}
.brand-signature + main #talkView,
.brand-signature + main #welcome,
.brand-signature + main #conversation .question-frame .question {
  padding-top: 0;
}

/* Center home between the subtitle and speaker label without moving either line. */
#homeButton {
  position: absolute;
  z-index: 3;
  top: calc(100% + 8px);
  right: calc(var(--header-inline-padding) - 4px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  min-width: 0;
  min-height: 26px;
  height: 26px;
  margin: 0;
  padding: 2px 5px;
  color: #9ca79d;
}
#homeButton svg {
  display: block;
  width: 22px;
  height: 22px;
}
.header-brand {
  flex: 1;
  min-width: 0;
  height: 44px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
  align-items: center;
  padding-right: var(--header-ink-inset);
}
.brand-face {
  grid-area: 1 / 1;
  display: block;
  width: auto;
  max-width: 100%;
  height: 44px;
  object-fit: contain;
  object-position: right center;
  animation: brand-dissolve 10s linear infinite;
}
.brand-face.brand-english {
  animation-name: brand-dissolve-english;
}
@keyframes brand-dissolve {
  0%,
  45%,
  100% {
    opacity: 1;
  }
  50%,
  95% {
    opacity: 0;
  }
}
@keyframes brand-dissolve-english {
  0%,
  45%,
  100% {
    opacity: 0;
  }
  50%,
  95% {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .brand-face {
    animation: none;
  }
  .brand-face.brand-english {
    opacity: 0;
  }
}
.app > header .audio-status-group {
  transform: scale(var(--header-status-scale));
  transform-origin: left center;
  margin-left: -4px;
  margin-right: var(--header-status-right-margin);
}
@media screen and (max-width: 480px) {
  .app > header {
    --header-inline-padding: 6px;
    --header-control-gap: 6px;
  }
}
@media screen and (max-width: 480px) {
  .brand-signature {
    font-size: 10px;
  }
}
@media screen and (max-width: 380px) {
  .app > header {
    --header-menu-width: 28px;
    --header-menu-glyph: 24px;
    --header-control-gap: 4px;
    --header-status-scale: 0.88;
    --header-status-right-margin: -3px;
  }
  .brand-signature {
    font-size: 9px;
  }
}

.start-actions .primary,
.roleplay-form > .primary,
.roleplay-presets button {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.start-actions .primary {
  flex-shrink: 0;
  min-width: 0;
  padding-inline: 6px;
  font-size: clamp(11px, 3.2vw, 14px);
  white-space: nowrap;
}
.start-actions .roleplay-entry {
  background: #85806b;
}

/* Top-layer messages never take space from the conversation or sign-in form. */
dialog.error-popup {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(420px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 28px 24px;
  border: 0;
  border-radius: 14px;
  background: #faeee5;
  color: #945843;
  box-shadow: 0 12px 40px #293d3533;
  font-size: 14px;
  line-height: 1.7;
}
dialog.error-popup::backdrop {
  background: #293d3526;
}
.error-popup p {
  margin: 0;
  overflow-wrap: anywhere;
}

@media print {
  dialog.error-popup {
    display: none !important;
  }
}

.start-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
body.in-conversation .start-actions {
  display: none;
}

/* Keep the introduction, settings and start action together on shorter screens. */
@media screen and (max-height: 800px) {
  body:not(.in-conversation) .app {
    padding-top: 8px;
    padding-bottom: 8px;
  }
  body:not(.in-conversation) #talkView {
    padding-bottom: 6px;
  }
  #welcome {
    gap: 8px;
    padding-bottom: 6px;
  }
  #welcome h1 {
    font-size: 18px;
    line-height: 1.35;
  }
  .welcome-guide {
    font-size: 11px;
    line-height: 1.6;
  }
  body:not(.in-conversation) .quick-controls {
    margin-top: 10px;
    padding: 10px 0;
    gap: 10px 12px;
  }
  .start-actions {
    margin-top: 10px;
  }
  body:not(.in-conversation) footer {
    padding-top: 8px;
  }
}
@media screen and (max-width: 600px) and (max-height: 620px) {
  body:not(.in-conversation) .app {
    padding-block: 4px;
  }
  body:not(.in-conversation) #talkView {
    padding-bottom: 4px;
  }
  body:not(.in-conversation) .brand-signature {
    padding-block: 3px;
  }
  #welcome {
    gap: 6px;
    padding-bottom: 4px;
  }
  #welcome h1 {
    font-size: 16px;
    line-height: 1.25;
  }
  .welcome-guide {
    line-height: 1.5;
  }
  body:not(.in-conversation) .quick-controls {
    margin-top: 6px;
    padding-block: 6px;
    gap: 6px 12px;
  }
  body:not(.in-conversation) .voice-grid {
    row-gap: 3px;
  }
  body:not(.in-conversation) .voice-grid select {
    min-height: 28px;
    padding-block: 2px;
  }
  body:not(.in-conversation) .voice-picker-heading {
    margin-bottom: 3px;
  }
  .start-actions {
    margin-top: 6px;
  }
  .start-actions .primary {
    min-height: 44px;
    padding-block: 8px;
  }
  body:not(.in-conversation) footer {
    padding-top: 4px;
    line-height: 1.5;
  }
}

/* Close icons stay unframed when a dialog assigns initial focus. */
dialog .dialog-heading .icon,
dialog .dialog-heading .icon:focus,
dialog .dialog-heading .icon:focus-visible {
  border: 0;
  outline: none;
  box-shadow: none;
}

.model-scroll .answer-hint {
  width: 100%;
}

/* Shared question and answer playback controls. */
.question-frame,
.model-scroll-frame {
  --pane-divider-inset: 6px;
  --pane-audio-gap: 3px;
  --pane-audio-height: 30px;
  padding-top: 22px;
  padding-bottom: calc(
    var(--pane-audio-height) + 2 * var(--pane-audio-gap) + var(--pane-divider-inset) + 1px
  );
}
.pane-speaker {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  margin: 0;
  height: 18px;
  font-size: 12px;
  line-height: 18px;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pane-speaker-name {
  color: #5e7063;
  font-weight: 500;
}
.note > .pane-speaker {
  position: static;
  grid-column: 2;
  grid-row: 1;
  font-size: 12px;
  margin-bottom: var(--answer-caption-gap);
}
.menu-account {
  margin: 14px 0;
}
.menu-account-contact {
  display: flex;
  align-items: center;
  gap: 6px;
}
#menuNickname {
  margin: 0 0 2px;
  line-height: 24px;
  overflow-wrap: anywhere;
}
#memberLabel {
  flex: 1;
  min-width: 0;
  margin: 0;
  line-height: 24px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.menu-verification {
  flex: none;
  color: #ad4946;
  font-size: 11px;
  white-space: nowrap;
}
#resendVerify {
  flex: none;
  height: 28px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}
#verificationStatus {
  white-space: pre-line;
  line-height: 1.8;
}
#logout {
  flex: none;
  height: 24px;
  padding: 0 4px;
  font-size: 12px;
  line-height: 1;
  color: var(--muted);
}
@media (max-width: 420px) {
  .menu-account {
    position: relative;
  }
  #menuNickname {
    min-height: 24px;
    padding-right: 66px;
  }
  .menu-account #logout {
    position: absolute;
    top: 0;
    right: 0;
  }
}
.ai-credit {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
  text-align: center;
}
.ai-credit strong {
  color: var(--green);
  font-weight: 600;
}
.question-audio-controls,
.answer-audio-controls {
  display: flex;
  align-items: center;
  gap: 0;
  height: var(--pane-audio-height);
  background: var(--bg);
}
/* The automatic flow switch shares the playback row without covering content. */
.question-audio-controls {
  justify-content: flex-end;
}
.auto-advance-button {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
  min-height: 30px;
  padding: 2px 8px 2px 0;
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.auto-advance-button > span:not(.ui-graphic-label) {
  display: inline-flex;
  align-items: center;
  align-self: center;
  line-height: 1;
  margin-left: 3px;
  font-weight: 600;
}
.auto-advance-button[aria-pressed='true'] {
  color: var(--green);
}
.answer-flow-controls {
  --flow-control-gap: clamp(12px, calc(0.8vw + 8px), 16px);
  flex: 1;
  min-width: 0;
  container-type: inline-size;
  display: flex;
  align-items: center;
  gap: var(--flow-control-gap);
  margin-right: 6px;
}
.answer-flow-controls .auto-advance-button {
  flex: 0 1 auto;
  padding-right: 0;
  font-size: clamp(7px, calc(5.4cqw - 0.5px), 11px);
}
#answerAdvance {
  position: relative;
  padding-left: 0;
}
#answerAdvance::before {
  content: '';
  position: absolute;
  left: calc(var(--flow-control-gap) / -2);
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
  height: 12px;
  background: #bdc7bc;
}
.question-audio-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  min-height: 30px;
  padding: 3px 0;
  color: #aab2a8;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  border-radius: 7px;
}
.question-audio-button.selected,
.question-audio-button#listen,
.question-audio-button#listenModel {
  color: var(--ink);
}
.question-audio-button svg {
  width: 18px;
  height: 18px;
}
.repeat-count {
  display: inline-grid;
  position: relative;
  place-items: center;
  width: 20px;
  height: 24px;
}
.repeat-count-current {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.question-audio-button .playback-symbol {
  display: block;
  width: 20px;
  height: 24px;
  overflow: visible;
  font: inherit;
  fill: currentColor;
  stroke: none;
  pointer-events: none;
}
.question-audio-button .repeat-orbit {
  position: absolute;
  inset: 0;
  width: 20px;
  height: 24px;
  color: #aab2a8;
  visibility: hidden;
  pointer-events: none;
}
#questionAuto .playback-symbol,
#answerAuto .playback-symbol {
  width: 26px;
}
/* Equal visible gaps, not equal boxes: Auto is wider than the repeat numbers. */
#questionAuto,
#answerAuto {
  margin-right: 4px;
}
#listen,
#listenModel {
  margin-left: 10.5px;
}
.repeat-orbit-track,
.repeat-orbit-arrow {
  stroke: currentColor;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.question-audio-button.is-playing .repeat-orbit {
  visibility: visible;
}
.question-audio-button.is-playing {
  color: var(--ink);
}

/* Keep the settings hint without a divider below the speaking controls. */
.answer-fixed-controls,
.answer-fixed-controls.has-more-below {
  border-bottom-color: transparent;
  background-image: none;
}

.voice-speed {
  grid-column: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  gap: 5px;
  margin-bottom: 0;
}
.voice-speed button {
  min-width: 0;
  white-space: nowrap;
  min-height: 28px;
  padding: 3px 4px;
  font-size: 11px;
}

.level-picker {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--settings-title-width) var(--settings-speaker-width) minmax(0, 1fr);
  align-items: center;
  gap: var(--settings-column-gap);
  min-width: 0;
}
.level-picker .control-title {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 12px;
}
.level-picker .difficulty-scale {
  grid-column: 3;
  width: 100%;
  min-width: 0;
}
.level-picker .difficulty-scale button {
  white-space: nowrap;
  min-height: 30px;
  padding: 3px;
}

.voice-picker-heading .control-title {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 12px;
}
.voice-picker-heading .speaker-button {
  flex-shrink: 0;
}
@media (max-width: 350px) {
  .quick-controls {
    --settings-title-width: 88px;
    --settings-speaker-width: 28px;
    --settings-column-gap: 4px;
  }
  .voice-picker-heading .control-title {
    font-size: 11px;
  }
  #previewVoice,
  #previewAnswerVoice {
    padding: 4px;
  }
  .voice-speed {
    gap: 3px;
  }
  .voice-speed button {
    padding-inline: 2px;
    font-size: 10px;
  }
}
.level-picker .control-title::before,
.voice-picker-heading .control-title::before {
  content: '';
  display: inline-block;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  vertical-align: middle;
}

.settings-scroll-hint {
  display: none;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
  gap: 5px;
  color: #849186;
  font-size: 10px;
  line-height: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.answer-fixed-controls.has-more-below .settings-scroll-hint {
  display: inline-flex;
}
.answer-fixed-controls.has-more-below::after {
  content: none;
}

/* Compact conversation buttons; reserve a full hint line and bottom safe area. */
#conversation .answer-fixed-controls .primary {
  height: 40px;
  min-height: 40px;
  padding: 6px;
}
#conversation .answer-fixed-controls {
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}
.answer-fixed-controls .settings-scroll-hint {
  bottom: calc(7px + env(safe-area-inset-bottom, 0px));
}

#conversation .answer-buttons:has(#retryAnswer.retry-unavailable) #mic {
  grid-column: auto;
}
.keyboard-button {
  display: flex;
  align-items: center;
  justify-content: center;
}
.text-input-mode #openTextAnswer {
  display: none !important;
}
#conversation .text-input-mode .answer-buttons {
  margin-bottom: 8px;
}
#conversation .text-input-mode .answer-buttons.has-next-turn {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
#conversation .text-input-mode .answer-buttons.has-next-turn:has(#retryAnswer.retry-unavailable) {
  grid-template-columns: minmax(0, 1fr);
}
#answerForm.text-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 0;
  min-height: 40px;
  box-sizing: border-box;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
#answerForm.text-composer[hidden] {
  display: none;
}
#answerForm textarea {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  max-height: 120px;
  box-sizing: border-box;
  resize: none;
  overflow-y: auto;
  border: none;
  background: transparent;
  padding: 6px 2px;
  margin: 0;
  font: inherit;
  font-size: 16px;
  line-height: 20px;
}
#answerForm button {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 20px;
}
#answerForm #closeTextAnswer {
  background: transparent;
  color: var(--muted);
}

/* One joined answer control, with a keyboard segment on the left. */
#conversation .answer-buttons {
  grid-template-columns: minmax(0, 1fr);
}
#conversation
  .answer-fixed-controls:not(.text-input-mode)
  .answer-buttons:not(:has(#retryAnswer.retry-unavailable)) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.answer-input-control {
  --answer-keyboard-width: 48px;
  position: relative;
  display: flex;
  align-items: stretch;
  min-width: 0;
  border-radius: 12px;
  background: var(--green);
  overflow: hidden;
}
#conversation .answer-input-control #mic {
  flex: 1;
  min-width: 0;
  width: 100%;
  border-radius: 0;
  padding-inline: calc(var(--answer-keyboard-width) + 4px);
}
#conversation .answer-input-control #openTextAnswer {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: var(--answer-keyboard-width);
  border-radius: 0;
  padding: 6px 12px;
}
.answer-input-control #openTextAnswer::after {
  content: '';
  position: absolute;
  right: 0;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: rgba(255, 255, 255, 0.4);
}
.retry-input-control {
  --retry-keyboard-width: clamp(28px, 8vw, 42px);
  position: relative;
  display: flex;
  min-width: 0;
  border-radius: 12px;
  background: var(--green);
  overflow: hidden;
}
.retry-input-control:has(.retry-unavailable) {
  display: none;
}
#conversation .retry-input-control #retryAnswer {
  flex: 1;
  width: 100%;
  min-width: 0;
  border-radius: 0;
  /* Equal insets keep the voice action centered across the entire joined button. */
  padding-inline: calc(var(--retry-keyboard-width) + 4px);
  white-space: nowrap;
}
#conversation .retry-input-control #retryTextAnswer {
  display: flex;
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: var(--retry-keyboard-width);
  padding: 0;
  border-radius: 0;
}
#retryTextAnswer svg {
  width: 18px;
  height: 18px;
}
#openTextAnswer svg,
#retryTextAnswer svg {
  opacity: 0.6;
}
#retryTextAnswer::after {
  content: '';
  position: absolute;
  right: 0;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: rgba(255, 255, 255, 0.4);
}

#conversation #mic,
#conversation #retryAnswer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
/* Keep graphic titles independent of the device font's baseline and line box. */
.answer-fixed-controls .primary > span:not(.action-auto-label) {
  display: inline-flex;
  align-items: center;
  align-self: center;
  line-height: 1;
}
.action-symbol {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: middle;
}

#answerForm textarea:focus,
#answerForm textarea:focus-visible {
  outline: none;
  border: none;
  box-shadow: none;
}
#answerForm #send {
  display: flex;
  align-items: center;
  justify-content: center;
}
#answerForm:focus-within {
  border-color: var(--green);
}

.answer-input-control:has(#mic.recording),
.answer-input-control:has(#mic.recording) #openTextAnswer {
  background: #a75c49;
}
.action-auto-label {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
}
#skipPassHint,
#changeVoiceHint {
  flex-direction: column;
  gap: 0.5px;
  align-items: flex-end;
  text-align: right;
}
#skipPassHint > span,
#changeVoiceHint > span {
  display: flex;
  line-height: 1;
}
#skipPassHint small,
#changeVoiceHint small {
  font-size: 6px;
  display: flex;
}
@media (max-width: 600px) {
  #skipPassHint,
  #changeVoiceHint {
    right: 12px;
  }
}
/* Only the longer command shrinks when space is tight; titles and icons stay unchanged. */
@media (max-width: 412px) {
  #changeVoiceHint > span {
    font-size: 8px;
  }
}
#conversation .answer-input-control #mic.recording {
  padding-inline: calc(var(--answer-keyboard-width) + 4px);
  font-size: 13px;
}

.answer-buttons.has-next-turn .answer-input-control #openTextAnswer {
  display: none;
}
#conversation .text-input-mode .answer-input-control #mic,
#conversation .answer-buttons.has-next-turn .answer-input-control #mic {
  padding-inline: 6px;
}
#conversation .answer-input-control #mic.has-auto-label {
  padding-inline: max(38px, var(--answer-keyboard-width));
}
#conversation .answer-buttons.has-next-turn .answer-input-control #mic.has-auto-label,
#conversation .text-input-mode .answer-input-control #mic.has-auto-label {
  padding-inline: 38px;
}
@media (max-width: 360px) {
  /* Reserve the same command space in both modes, so toggling never resizes titles. */
  .turn-actions .primary {
    font-size: clamp(10px, calc(2.5vw + 2px), 11px);
  }
  .turn-actions .action-symbol {
    width: 1.2em;
    height: 1.2em;
  }
  #skipPassHint,
  #changeVoiceHint {
    right: 10px;
  }
  #changeVoiceHint > span {
    font-size: clamp(7px, calc(2.5vw - 1px), 8px);
  }
  #conversation .answer-buttons.has-next-turn #mic.has-auto-label {
    padding-inline: 32px;
    font-size: 11px;
    gap: 4px;
  }
  .action-auto-label {
    right: 10px;
    font-size: 9px;
  }
  #conversation .retry-input-control #retryAnswer {
    font-size: 11px;
    gap: 4px;
  }
  #retryAnswer .action-symbol {
    width: 14px;
    height: 14px;
  }
}

#changeTopic .action-symbol {
  stroke-width: 2.2;
}

/* Menu/control lettering uses shipped paths, never platform glyph metrics. */
.ui-graphic-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
}
.ui-lettering {
  display: block;
  overflow: visible;
  fill: currentColor;
  stroke: none;
  pointer-events: none;
  flex-shrink: 0;
}
.ui-label-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
button .ui-lettering {
  width: auto;
}
.graphic-select {
  display: inline-flex;
  position: relative;
  width: 100%;
  min-width: 0;
}
.graphic-select-native {
  display: none !important;
}
.graphic-select-trigger {
  width: 100%;
  min-height: 48px;
  padding: 11px 28px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffefb;
  text-align: center;
  font-size: 16px;
  position: relative;
}
.graphic-select-trigger::after {
  content: '';
  position: absolute;
  right: 9px;
  top: calc(50% - 4px);
  width: 5px;
  height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
}
.voice-grid .graphic-select {
  flex: 1;
  width: 0;
}
.voice-grid .graphic-select-trigger {
  min-height: 34px;
  padding: 4px 17px;
  font-size: 12px;
  color: var(--ink);
}
.voice-grid .graphic-select-trigger .ui-graphic-label {
  max-width: 100%;
}
.voice-grid .graphic-select-trigger .ui-lettering {
  max-width: 100%;
}
.graphic-select-list {
  position: fixed;
  margin: 0;
  padding: 4px 16px 4px 4px;
  max-width: calc(100vw - 24px);
  max-height: 190px;
  overflow-y: auto;
  background: #fffefb;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 4px 20px #203a2826;
  z-index: 100;
}
.graphic-select-list button {
  display: flex;
  width: 100%;
  text-align: center;
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 13px;
}
.graphic-select-list button[aria-selected='true'] {
  background: var(--header-bg);
}
.graphic-select-list button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.ui-label-wrap {
  display: block;
  min-width: 0;
  flex-shrink: 1;
}
.ui-label-wrap .ui-lettering {
  display: inline-block;
  vertical-align: middle;
}
.check > .ui-graphic-label {
  min-width: 0;
  min-height: 1.7em;
  justify-content: flex-start;
}
.check > .ui-label-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em 0;
  padding-block: 0.35em;
}

/* Nickname help and its accessible pronunciation control share one row. */
.nickname-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 6px;
}
.nickname-help {
  flex: 1;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  min-width: 160px;
}
.nickname-heading .speaker-button {
  flex: none;
}
#nicknameMessage:empty,
#signupNicknameMessage:empty {
  display: none;
}

/* Guest notices share the existing popup geometry, using a calm green palette. */
dialog.trial-notice {
  background: #edf5ee;
  color: #3c6b53;
}
.trial-notice p {
  white-space: pre-line;
}
.trial-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}
.trial-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
.trial-remaining {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  transform: scale(var(--header-status-scale));
  transform-origin: left center;
  /* Match the visible menu-to-status gap, including the menu's internal padding. */
  margin-left: calc(
    var(--header-ink-inset) - 4px + 28px * (var(--header-status-scale) - 1) -
      var(--header-status-right-margin)
  );
  margin-right: calc(28px * (var(--header-status-scale) - 1));
  color: #668675;
}
.trial-ring {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.trial-segment {
  fill: none;
  stroke: var(--green);
  stroke-width: 2;
  stroke-linecap: round;
}
.trial-segment.spent {
  stroke: var(--audio-idle);
}
.trial-count {
  position: absolute;
  left: 50%;
  top: calc(100% - 3px);
  transform: translate(-50%, -50%);
  width: 10px;
  height: 12px;
  background: var(--header-bg);
  color: var(--microphone-active);
  fill: currentColor;
}
.trial-actions .primary {
  width: 100%;
}
