/* Youee's original brand palette and conversation surfaces. */
:root {
  color-scheme: light;
  --paper: #eff9fe;
  --mint: #f0faf7;
  --surface: #ffffff;
  --ink: #0b3540;
  --muted: #3e6470;
  --deep: #035e6c;
  --focus: #248de3;
  --border: #dceaec;
  --strong-border: #b9d6da;
  --assistant: #f1f9fc;
  --learner: #e0f5ef;
  --shadow: 0 2px 6px #035e6c0c, 0 12px 28px #035e6c0b;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: #eff9fe;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--paper), #fff 45%, var(--mint));
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, select, input, textarea { font: inherit; }
button { border: 1px solid transparent; cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.frame { width: min(100% - 40px, 780px); margin-inline: auto; }
.app-shell {
  width: min(1120px, calc(100% - 48px));
  min-height: calc(100dvh - 48px);
  margin: 24px auto;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.top { background: #fff; border-bottom: 1px solid var(--border); border-radius: 28px 28px 0 0; }
.top-inner { width: calc(100% - 44px); min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { display: block; flex: none; object-fit: contain; }
.brand strong { display: block; font-size: 15px; color: var(--deep); }
.brand small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .06em; }
.quiet, .primary { min-height: 42px; padding: .55rem .95rem; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.quiet { color: var(--deep); background: var(--surface); border-color: var(--border); }
.quiet:hover { background: var(--paper); border-color: var(--strong-border); }
.primary { color: white; background: var(--deep); font-weight: 650; }
.primary:hover { background: #094b56; }
.wide { width: 100%; margin-top: 16px; text-align: left; display: flex; justify-content: space-between; }
#welcome { max-width: 720px; margin: clamp(22px, 5vh, 48px) auto 24px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .85fr);
  gap: 12px;
  align-items: center;
  padding: clamp(22px, 4vw, 44px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(130deg, var(--paper), #f9fdff 50%, var(--mint));
  margin-bottom: 20px;
}
.intro p { color: var(--muted); max-width: 26ch; line-height: 1.75; }
.intro h1 { margin-bottom: .7em; font-size: clamp(27px, 4.3vw, 46px); line-height: 1.17; font-weight: 700; letter-spacing: -.04em; }
.welcome-figure { display: grid; align-items: center; background: radial-gradient(ellipse, #ccefeb 0%, transparent 65%); }
.welcome-figure img { width: 100%; height: auto; display: block; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--deep); }
.entry, .question { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.entry h2 { font-size: 18px; margin-bottom: 4px; }
.muted { color: var(--muted); }
.fine { font-size: 11px; margin-top: 12px; line-height: 1.5; }
.selectors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-block: 14px; }
label { display: block; font-size: 13px; }
select, input, textarea { width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; color: var(--ink); background: #fff; font-size: 16px; }
label > :is(select, input, textarea) { display: block; margin-top: 6px; }
summary { cursor: pointer; color: var(--deep); font-size: 13px; }
details label { margin-top: 10px; }
.progress { max-width: 680px; margin: 16px auto 10px; border: 1px solid var(--border); border-radius: 13px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); }
.access-status { max-width: 680px; margin: 0 auto 10px; padding-inline: 3px; color: var(--muted); font-size: 13px; line-height: 1.6; }
#diagnostic-progress { max-width: 640px; margin: 0 auto 10px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
#diagnostic-label { color: var(--deep); font-size: 12px; font-weight: 600; }
#diagnostic-bar { width: 100%; height: 6px; border: 0; border-radius: 8px; overflow: hidden; background: #e1edf0; color: #087e82; appearance: none; }
#diagnostic-bar::-webkit-progress-bar { background: #e1edf0; }
#diagnostic-bar::-webkit-progress-value { background: #087e82; border-radius: 8px; }
#diagnostic-bar::-moz-progress-bar { background: #087e82; border-radius: 8px; }
#scope { font-size: 13px; font-weight: 650; }
.lights { display: flex; gap: 12px; font-size: 11px; align-items: center; flex-wrap: wrap; }
.lights span { white-space: nowrap; }
.lights i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; background: #a9c1ca; }
.lights span:nth-child(2) i { background: #b57600; }
.lights span:nth-child(3) i { background: #008669; }
#learning { max-width: 680px; margin-inline: auto; }
#conversation { padding: 17px 0 20px; }
#last-answer { width: fit-content; max-width: 100%; margin: 0 0 12px auto; padding: 8px 13px; background: var(--learner); border-radius: 12px 12px 4px 12px; overflow-wrap: anywhere; }
.conversation-note { justify-self: start; padding: 9px 12px; border-radius: 12px 12px 12px 4px; background: var(--assistant); font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.contrast { background: var(--assistant); border-radius: 12px; padding: 12px 14px; line-height: 1.7; }
.contrast p + p { margin-top: 6px; }
#prompt { font-size: clamp(17px, 4vw, 22px); line-height: 1.8; overflow-wrap: anywhere; }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#topic { min-width: 0; overflow-wrap: anywhere; }
.question-condition { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 4px 0 8px; }
.question-bank { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 4px 8px; }
.question-given { padding: 1px 8px; border-radius: 8px; background: var(--assistant); font-size: 14px; line-height: 1.7; }
.question-body { overflow-wrap: anywhere; }

.question-teach { flex-shrink: 0; min-height: 40px; padding: 4px 10px; font-size: 12px; }
.word { display: inline; padding: .1em .03em; border: 0; color: var(--deep); background: none; font: inherit; text-decoration: underline dotted #62848c; text-underline-offset: .18em; }
.word:hover { background: #dcf4f2; }
#actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 12px; }
#actions p { width: 100%; font-size: 13px; line-height: 1.6; }
#actions form { width: 100%; }
.composer { position: sticky; bottom: 0; z-index: 1; padding: 7px 0 max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
#accents { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; }
#accents button { min-height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: 7px; color: var(--deep); background: var(--surface); }
.answer-row { display: flex; gap: 8px; margin-top: 6px; }
.error { color: #9d3425; font-size: 13px; }
.error:not(:empty) { margin-block: 8px; }
dialog { width: min(calc(100% - 32px), 420px); max-height: 80dvh; border: 1px solid var(--border); border-radius: 18px; padding: 18px; color: var(--ink); background: var(--surface); box-shadow: 0 16px 70px #035e6c26; }
dialog::backdrop { background: #0b354052; }
.dialog-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.dialog-head button { flex: none; width: 40px; min-height: 40px; border-radius: 10px; background: var(--assistant); color: var(--ink); font-size: 21px; }
.dialog-head h2 { font-size: 20px; overflow-wrap: anywhere; }
#drawer-mix-options > div { padding-block: 8px; }
#drawer-mix-options button { margin: 6px 8px 0 0; }
#word-pos { margin-top: 2px; }
#word-gloss { line-height: 1.6; margin-block: 8px 14px; }
.ratings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.ratings button { min-height: 42px; padding: 5px; border-radius: 8px; border-color: var(--border); color: var(--deep); background: var(--mint); }
.account-block { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 14px; }
.account-block h3 { font-size: 15px; margin-bottom: 9px; }
#recovery-output { margin-block: 7px 12px; overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
.topic-group + .topic-group { margin-top: 6px; }
.topic-group ul { padding-inline-start: 20px; font-size: 13px; line-height: 1.6; }
.word-entry { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.word-entry p { margin-top: 4px; font-size: 13px; color: var(--muted); }
.word-entry.priority strong { color: var(--deep); }
.word-entry span { flex-shrink: 0; align-self: center; font-size: 11px; color: var(--deep); }
.sr-only { position: absolute; height: 1px; width: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 600px) {
  .frame { width: calc(100% - 28px); }
  .top-inner { min-height: 56px; }
  .app-shell { width: 100%; margin: 0; min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .top { border-radius: 0; }
  .brand img { width: 38px; height: 38px; }
  .intro { padding: 18px 13px 18px 16px; border-radius: 20px; margin-bottom: 14px; grid-template-columns: minmax(0, 1.62fr) minmax(0, .9fr); gap: 4px; }
  .intro p { font-size: 13px; }
  .intro h1 { margin-bottom: .65rem; font-size: clamp(22px, 6.25vw, 29px); }
  .progress { margin-block: 10px 8px; padding: 8px 10px; }
  #scope { font-size: 12px; }
  .lights { column-gap: 6px; }
  .lights i { width: 6px; height: 6px; margin-right: 3px; }
  #conversation { padding-top: 3px; }
  .conversation-note { font-size: 15px; }
  .question { padding: 13px; }
  #word-dialog, #account { margin: auto auto 0; width: 100%; border-radius: 16px 16px 0 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

#history { display: grid; gap: 16px; }
#history:not(:empty) { margin-bottom: 14px; }
.history-turn, .history-dialog { display: grid; gap: 7px; min-width: 0; }
.history-dialog { margin: 4px 0; }
.history-prompt, .history-reply, .history-answer {
  overflow-wrap: anywhere;
  line-height: 1.7;
  white-space: pre-wrap;
  min-width: 0;
}
.history-prompt { font-size: 15px; }
.history-answer {
  justify-self: end;
  max-width: 100%;
  padding: 7px 12px;
  background: var(--learner);
  border-radius: 12px 12px 4px 12px;
}
.history-reply {
  padding: 12px 15px;
  background: var(--assistant);
  border-radius: 12px 12px 12px 4px;
}
.history-turn > .quiet { justify-self: start; min-height: 36px; }
.word { text-decoration-color: #8aa8ac; text-decoration-thickness: 1px; }
.choices:not(:empty) { display: grid; gap: 7px; margin-top: 10px; }
.choice-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
}
.choice-row > span { min-width: 0; overflow-wrap: anywhere; }
.choice-row > button { min-height: 38px; flex: none; }
#ai-status:not(:empty) { margin-block: 7px; font-size: 13px; color: var(--muted); }
.choice-row { position: relative; }
.choice-control::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.choice-control:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice-row .word { position: relative; z-index: 1; }
.choice-row:has(.choice-control):hover { background: var(--paper); }
#choices:not(:empty) .choice-row > button { min-height: 42px; min-width: 42px; }

.history-reply p { margin: 0 0 .45em; }
.history-reply p:last-child { margin-bottom: 0; }
.history-reply ul, .history-reply ol { margin: .35em 0; padding-inline-start: 1.35em; }
.history-reply li > ul, .history-reply li > ol { margin-block: .25em; padding-inline-start: 1.1em; }


.placement-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  scroll-margin-block: 12px;
  overflow: hidden;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.62;
  overflow-wrap: anywhere;
}
.placement-header { padding: 15px 17px 12px; background: var(--mint); color: var(--deep); }
.placement-header h2 { font-size: clamp(17px, 4.6vw, 22px); line-height: 1.35; }
.placement-header p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.placement-section { margin-inline: 17px; padding-block: 11px; border-bottom: 1px solid var(--border); }
.placement-section h3 { margin: 0 0 3px; color: var(--deep); font-size: 14px; }
.placement-section.gap h3 { color: #825500; }
.placement-section ul, .placement-section ol { margin: 0; padding-inline-start: 1.2rem; }
.placement-section li + li { margin-top: 3px; }
.placement-section li::marker { color: #087e82; }
.placement-invite { padding: 10px 17px 12px; color: var(--deep); font-size: 13px; font-weight: 650; }

.reading-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(17px, 5vw, 26px);
  scroll-margin-top: 12px;
}
.reading-card h2 { color: var(--deep); font-size: clamp(19px, 5vw, 23px); line-height: 1.3; }
.reading-body { margin-top: 12px; overflow-wrap: anywhere; font-size: 16px; line-height: 1.8; }
.reading-body p + p { margin-top: .7em; }
.reading-card .word { color: inherit; }
.reading-jump {
  display: block;
  width: fit-content;
  margin-bottom: 6px;
  color: var(--deep);
  font-size: .77em;
}

.onboarding-examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#workspace > .composer { width: min(100%, 680px); margin-inline: auto; }
.composer .answer-row { padding: 5px; background: #fff; border: 1px solid var(--strong-border); border-radius: 24px; box-shadow: var(--shadow); }
.composer input { border: 0; border-radius: 18px; padding-inline: .85rem; }
.composer .primary { min-width: 76px; }
.composer .primary span { margin-left: 3px; }
.entry > .muted { line-height: 1.65; }
#workspace > .error { max-width: 680px; margin-inline: auto; }

.admin-page .top { border-radius: 0; }
.admin-page .top-inner, .admin-main { width: min(calc(100% - 40px), 960px); }
.admin-main { padding-block: clamp(24px, 5vw, 56px); }
.admin-main h1 { font-size: clamp(26px, 4vw, 38px); margin-bottom: 20px; letter-spacing: -.035em; }
.admin-login { max-width: 420px; }
.admin-login .primary { margin-top: 14px; }
.admin-issue { display: grid; grid-template-columns: minmax(90px, .35fr) minmax(0, 1fr) auto; gap: 14px; align-items: end; }
.admin-issued { margin-top: 12px; background: var(--mint); }
.admin-issued pre { overflow: auto; line-height: 1.75; letter-spacing: .05em; }
.admin-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 8px; }
.admin-list-head h2 { font-size: 20px; }
.usage-note { font-size: 13px; line-height: 1.65; margin-bottom: 12px; }
.admin-table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
.admin-table th, .admin-table td { padding: 11px 13px; border-bottom: 1px solid var(--border); }
.admin-table th { background: var(--assistant); color: var(--deep); }
.admin-table td { overflow-wrap: anywhere; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table small { display: block; color: var(--muted); margin-top: 3px; }
.voucher-state { display: inline-block; background: var(--assistant); border-radius: 999px; padding: 4px 8px; white-space: nowrap; }
.voucher-state.used { background: var(--learner); color: #075e50; }
.voucher-state.revoked { background: #fff3f0; color: #9d3425; }
.danger { color: #9d3425; }
@media (max-width: 620px) {
  .admin-page .top-inner, .admin-main { width: calc(100% - 28px); }
  .admin-issue { grid-template-columns: 90px minmax(0, 1fr); gap: 10px; padding: 14px; }
  .admin-issue .primary { grid-column: 1 / -1; }
  .admin-table, .admin-table tbody, .admin-table tr { display: block; }
  .admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .admin-table tr { padding: 8px 13px; border-bottom: 1px solid var(--border); }
  .admin-table tr:last-child { border-bottom: 0; }
  .admin-table td { display: block; border: none; padding: 5px 0; }
  .admin-table td::before { content: attr(data-label); display: inline-block; min-width: 108px; margin-right: 8px; color: var(--muted); font-size: 12px; }
  .admin-table small { margin-left: 116px; }
}


@media (min-width: 601px) {
  #account {
    inset: 0 0 0 auto;
    margin: 0 0 0 auto;
    max-height: none;
    height: 100dvh;
    border-radius: 24px 0 0 24px;
    padding: 24px;
  }
}

#live-chat { max-width: 680px; margin-inline: auto; }
#outgoing { display: grid; gap: 5px; padding-bottom: 4px; }
#outgoing:empty, #live-dialog:empty { display: none; }
#outgoing .retry-message { justify-self: end; min-height: 34px; }
.typing-indicator {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 13px 15px;
  border-radius: 15px 15px 15px 4px;
  background: var(--assistant);
}
.typing-indicator i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-indicator i:nth-of-type(2) { animation-delay: .13s; }
.typing-indicator i:nth-of-type(3) { animation-delay: .26s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .55; }
  30% { transform: translateY(-4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .typing-indicator i { animation: none; }
}

#onboarding-sent { width: fit-content; margin: 8px 0 8px auto; }

.usage-overview { margin-bottom: 14px; }
.usage-overview h2, #voucher-detail h3 { margin-bottom: 8px; }
.usage-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-block: 10px; }
.usage-metrics div { padding: 9px 10px; background: var(--assistant); border-radius: 12px; min-width: 0; }
.usage-metrics dt { color: var(--muted); font-size: 12px; }
.usage-metrics dd { margin: 4px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.usage-breakdown { list-style: none; padding: 0; margin: 5px 0 15px; font-size: 13px; line-height: 1.7; }
.usage-breakdown li { padding: 4px 0; border-bottom: 1px solid var(--border); }
#usage-days h3, #usage-hours h3 { margin-top: 12px; font-size: 14px; }
#voucher-note { margin-block: 12px; }
#voucher-note .quiet { margin-top: 8px; }
#learning-metrics ~ h3 { margin-top: 12px; }
@media (min-width: 621px) {
  .usage-overview .usage-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.usage-breakdown small { display: block; }
.usage-breakdown meter { display: block; width: 100%; height: 8px; }

#actions .quick-reply {
  min-height: 40px;
  white-space: normal;
  text-align: left;
  line-height: 1.35;
}

/* A fixed-height shell keeps progress and the composer outside message scrolling. */
.student-page .app-shell {
  height: calc(var(--chat-height, 100dvh) - 48px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.student-page .top { flex: none; }
.top-progress .progress { margin-block: 0 8px; }
#workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
#chat-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
}
#chat-scroll:focus-visible { outline-offset: -3px; }
#answer-form { flex: none; position: static; }
#latest-message {
  position: absolute;
  bottom: calc(var(--latest-offset, 110px));
  right: 10px;
  z-index: 2;
  box-shadow: var(--shadow);
}
@media (max-width: 600px) {
  .student-page .app-shell { height: var(--chat-height, 100dvh); margin-block: 0; }
  .top-progress .progress { margin-block: 0 6px; padding-block: 5px; }
}
.lesson-table-scroll { overflow-x: auto; margin: .55em 0; }
.lesson-table { border-collapse: collapse; width: 100%; text-align: start; font-size: .9em; }
.lesson-table th, .lesson-table td { border: 1px solid var(--border); padding: .28em .42em; text-align: start; vertical-align: top; }
.lesson-table thead th { background: var(--mint); }
.lesson-translation { margin: .15em 0 .32em; }
.lesson-translation p { font-size: .9em; color: var(--muted); }
