/* Fluent: quiet graphite, one warm accent, operational mobile layout. */
:root {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #151713);
  --surface: var(--tg-theme-secondary-bg-color, #1d201b);
  --surface-raised: #242820;
  --surface-soft: #191c17;
  --text: var(--tg-theme-text-color, #f1f3eb);
  --muted: var(--tg-theme-hint-color, #a3aa9b);
  --line: var(--tg-theme-section-separator-color, #32372e);
  --accent: #c8f36b;
  --accent-control: var(--accent);
  --accent-text: var(--accent);
  --accent-ink: #19200f;
  --accent-soft: #2b3420;
  --accent-line: #526837;
  --danger: #ff9b91;
  --danger-bg: #352321;
  --header-height: 126px;
  --nav-height: 68px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: var(--font-sans);
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

html[data-color-scheme="light"] {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f5f6f0);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --surface-raised: #e7ebdf;
  --surface-soft: #f0f2eb;
  --text: var(--tg-theme-text-color, #1d2319);
  --muted: var(--tg-theme-hint-color, #4e5b45);
  --line: var(--tg-theme-section-separator-color, #cfd6c5);
  --accent-text: #405c0f;
  --accent-control: #405c0f;
  --accent-soft: #edf5d9;
  --accent-line: #91ad5c;
  --danger: #9b3028;
  --danger-bg: #fff0ed;
}

html .editorial-kicker,
html .boot-mark,
html .nav-tab[aria-selected="true"],
html .message-user .message-label,
html .practice-number,
html .word-composer summary svg,
html .word-filter button span,
html .card-status,
html .due-banner strong,
html .due-banner-link,
html .metric-wide dd {
  color: var(--accent-text);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: #0e100d;
}

body {
  min-width: 280px;
  min-height: 100%;
  margin: 0;
  background: #0e100d;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

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

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent-control);
  outline-offset: 3px;
}

button,
a,
summary,
input,
textarea {
  scroll-margin-bottom: 24px;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

h1,
h2 {
  text-wrap: balance;
}

h1 {
  font-size: clamp(25px, 7vw, 32px);
  font-weight: 650;
  letter-spacing: -.045em;
  line-height: 1.12;
}

h2 {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -.025em;
  line-height: 1.25;
}

svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 680px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
}

.app-header {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 13px) 18px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  gap: 12px;
  margin-bottom: 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 9px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.055em;
  line-height: 1;
}

.header-context {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
  letter-spacing: .01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.development-badge {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.mode-button {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.mode-button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.mode-button:not([aria-pressed="true"]):active {
  background: var(--surface-raised);
}

.main-content {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.view {
  height: 100%;
  animation: view-in 180ms ease-out;
}

.scroll-view {
  padding: 23px 18px 36px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  -webkit-overflow-scrolling: touch;
}

.view-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.view-heading h1:focus {
  outline: none;
}

.editorial-kicker {
  margin-bottom: 5px;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: .005em;
  line-height: 1.2;
}

.view-intro {
  max-width: 490px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}

.muted {
  color: var(--muted);
}

.bottom-nav {
  position: relative;
  z-index: 10;
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(4, 1fr);
  padding: 5px 8px calc(env(safe-area-inset-bottom, 0px) + 5px);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.nav-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-width: 0;
  min-height: 58px;
  gap: 4px;
  padding: 5px 2px;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  transition: color 150ms ease, background-color 150ms ease;
}

.nav-tab svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.65;
}

.nav-tab[aria-selected="true"] {
  color: var(--accent);
}

.nav-tab[aria-selected="true"]::before {
  position: absolute;
  top: -6px;
  width: 24px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--accent-control);
  content: "";
}

.nav-tab:active {
  background: var(--surface);
}

/* Boot is the only state visible before authenticated bootstrap succeeds. */
.app[data-ready="false"] > .app-header,
.app[data-ready="false"] > .bottom-nav {
  display: none;
}

.app[data-ready="false"] .view {
  display: none !important;
}

.app[data-ready="true"] .boot-screen {
  display: none;
}

.boot-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  height: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 40px) 28px calc(env(safe-area-inset-bottom, 0px) + 40px);
}

.boot-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 30px;
  border: 1px solid var(--accent-line);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 30px;
  font-style: italic;
  place-items: center;
}

.boot-screen .muted {
  margin-top: 12px;
  font-size: 15px;
}

.boot-screen > .loader {
  margin-top: 26px;
}

.boot-screen > .button {
  margin-top: 24px;
}

/* Shared controls and feedback. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  transition: transform 130ms ease, background-color 150ms ease;
}

.button:active:not(:disabled) {
  transform: scale(.98);
}

.button-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button-primary:active:not(:disabled) {
  background: #b8df5c;
}

.button-quiet {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.full-width {
  width: 100%;
}

.icon-button,
.icon-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
}

.icon-text-button {
  gap: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 650;
}

.icon-text-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button:active,
.icon-text-button:active {
  background: var(--surface);
  color: var(--text);
}

.inline-error {
  padding: 11px 13px;
  border: 1px solid #66413d;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.header-error {
  margin-top: 8px;
}

.retry-button {
  width: 100%;
  margin-top: 10px;
}

.action-status {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.practice-list + .inline-error,
#practice-error {
  margin-top: 14px;
}

.loader {
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent-control);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

/* Chat */
.chat-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-heading {
  min-height: 66px;
  margin: 0;
  padding: 14px 18px 10px;
}

.chat-heading > div:first-child {
  min-width: 0;
}

.chat-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.message-scroll {
  min-height: 0;
  padding: 2px 18px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  -webkit-overflow-scrolling: touch;
}

.messages-loading,
.cards-loading,
.progress-loading,
.sessions-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.chat-empty {
  max-width: 390px;
  padding: clamp(32px, 8vh, 82px) 2px 28px;
}

.empty-rule {
  display: block;
  width: 34px;
  height: 2px;
  margin-bottom: 20px;
  background: var(--accent);
}

.chat-empty h2 {
  margin-bottom: 10px;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 400;
  letter-spacing: -.035em;
}

.chat-empty p {
  max-width: 320px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 91%;
  gap: 5px;
  animation: message-in 170ms ease-out;
}

.message-user {
  align-self: flex-end;
  max-width: 86%;
}

.message-label {
  padding: 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.message-user .message-label {
  align-self: flex-end;
  color: var(--accent);
}

.message-bubble {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 5px 17px 17px 17px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-user .message-bubble {
  border-color: var(--accent-line);
  border-radius: 17px 5px 17px 17px;
  background: var(--accent-soft);
}

.reply-pending {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 4px 2px;
  color: var(--muted);
  font-size: 12px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 900ms ease-in-out infinite alternate;
}

.typing-dots i:nth-child(2) {
  animation-delay: 180ms;
}

.typing-dots i:nth-child(3) {
  animation-delay: 360ms;
}

.composer-wrap {
  padding: 7px 12px 8px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.chat-audio {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.chat-audio audio {
  width: 100%;
  min-height: 44px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  max-height: 126px;
  padding: 13px 14px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  overflow-y: auto;
  transition: border-color 150ms ease;
}

.composer textarea::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
  opacity: .8;
}

.composer textarea:focus {
  border-color: var(--accent-line);
}

.composer textarea:focus-visible {
  outline: 2px solid var(--accent-control);
  outline-offset: 1px;
}

.send-button {
  display: grid;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  place-items: center;
  transition: transform 130ms ease, opacity 150ms ease;
}

.send-button:active:not(:disabled) {
  transform: scale(.95);
}

.send-button:disabled {
  background: var(--surface-raised);
  color: var(--muted);
  opacity: .7;
}

.send-button svg {
  width: 21px;
  height: 21px;
  margin-left: 2px;
}

.composer-hint {
  display: none;
  padding: 5px 3px 0;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.composer-error {
  margin-bottom: 7px;
}

/* Lesson and compact practice modules */
.lesson-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 20px 0 24px;
  padding: 17px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.lesson-copy {
  min-width: 0;
}

.lesson-copy h2 {
  margin-bottom: 7px;
}

.lesson-copy > p:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-wrap: pretty;
}

.section-title {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: -.015em;
}

.practice-module {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.practice-module:last-of-type {
  border-bottom: 1px solid var(--line);
}

.practice-module > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  gap: 16px;
  padding: 12px 2px;
  cursor: pointer;
  list-style: none;
}

.practice-module > summary::-webkit-details-marker {
  display: none;
}

.practice-module > summary > span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.practice-module > summary strong {
  font-size: 15px;
}

.practice-module > summary span span {
  color: var(--muted);
  font-size: 12px;
}

.practice-module > summary svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: var(--muted);
  transition: transform 150ms ease;
}

.practice-module[open] > summary svg {
  transform: rotate(45deg);
}

.practice-module-body {
  padding: 2px 0 14px;
}

.practice-module-body .diagnostic-launch,
.practice-module-body .speech-panel {
  margin-bottom: 12px;
  padding: 15px;
}

.practice-module-body .diagnostic-launch .button {
  margin-top: 0;
}

/* Practice */
.practice-list {
  border-top: 1px solid var(--line);
}

.practice-action {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 22px;
  align-items: center;
  width: 100%;
  min-height: 78px;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background-color 150ms ease, padding 150ms ease;
}

.practice-action:active:not(:disabled) {
  padding-right: 10px;
  padding-left: 10px;
  background: var(--surface);
}

.practice-number {
  align-self: start;
  padding-top: 2px;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
}

.practice-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 5px;
}

.practice-copy strong {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.012em;
}

.practice-copy > span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-wrap: pretty;
}

.practice-action > svg {
  width: 19px;
  height: 19px;
  color: var(--muted);
}

/* Diagnostic */
.diagnostic-launch,
.diagnostic-panel {
  margin-bottom: 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.diagnostic-launch h2 {
  margin-bottom: 8px;
}

.diagnostic-launch p:not(.editorial-kicker) {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.diagnostic-launch .button {
  width: 100%;
  margin-top: 16px;
}

.diagnostic-panel {
  border-color: var(--accent-line);
  scroll-margin-top: 14px;
}

.diagnostic-topline {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.diagnostic-topline p,
.diagnostic-level {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.diagnostic-topline progress,
.mastery-item progress {
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--accent-control);
  overflow: hidden;
  appearance: none;
}

.diagnostic-topline progress::-webkit-progress-bar,
.mastery-item progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-raised);
}

.diagnostic-topline progress::-webkit-progress-value,
.mastery-item progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--accent-control);
}

.diagnostic-topline progress::-moz-progress-bar,
.mastery-item progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--accent-control);
}

.diagnostic-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.diagnostic-panel > .inline-error {
  margin-bottom: 14px;
}

.diagnostic-level {
  margin-bottom: 7px;
  color: var(--accent-text);
  letter-spacing: .04em;
  text-transform: uppercase;
}

#diagnostic-question {
  overflow-wrap: anywhere;
}

.diagnostic-options {
  display: grid;
  gap: 9px;
  margin: 20px 0;
}

.diagnostic-option {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  line-height: 1.4;
  overflow-wrap: anywhere;
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.diagnostic-option[aria-pressed="true"] {
  border-color: var(--accent-control);
  background: var(--accent-soft);
}

.diagnostic-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.diagnostic-restart {
  width: 100%;
  margin-top: 10px;
}

.diagnostic-result-level {
  display: block;
  margin: 16px 0 8px;
  color: var(--accent-text);
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 400;
  letter-spacing: -.04em;
  line-height: 1;
}

.diagnostic-result > p:not(.editorial-kicker) {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Voice practice */
.speech-panel {
  margin-bottom: 28px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.speech-panel h2 {
  margin-bottom: 8px;
}

.speech-panel > p:not(.editorial-kicker),
.speech-limitation {
  color: var(--muted);
  line-height: 1.5;
}

.speech-panel select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.speech-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.speech-result {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.speech-result strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
}

.speech-result p {
  overflow-wrap: anywhere;
  line-height: 1.45;
}

/* Dictionary */
.heading-count {
  display: grid;
  min-width: 40px;
  min-height: 32px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  place-items: center;
}

.word-composer {
  margin: 19px 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  overflow: hidden;
}

.word-composer summary {
  display: flex;
  align-items: center;
  min-height: 52px;
  gap: 10px;
  padding: 12px 14px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  list-style: none;
  user-select: none;
}

.word-composer summary::-webkit-details-marker {
  display: none;
}

.word-composer summary svg {
  width: 19px;
  height: 19px;
  color: var(--accent);
  transition: transform 160ms ease;
}

.word-composer[open] summary {
  border-bottom: 1px solid var(--line);
}

.word-composer[open] summary svg {
  transform: rotate(45deg);
}

.card-form {
  display: grid;
  gap: 16px;
  padding: 17px 14px 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.field label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 450;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

.field textarea {
  min-height: 70px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent-control);
}

.word-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.word-filter button {
  position: relative;
  min-height: 48px;
  padding: 10px 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.word-filter button[aria-selected="true"] {
  color: var(--text);
}

.word-filter button[aria-selected="true"]::after {
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: var(--accent-control);
  content: "";
}

.word-filter button span {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  place-items: center;
}

.words-empty,
.progress-empty {
  padding: 42px 2px 20px;
}

.words-empty h2,
.progress-empty h2 {
  margin-bottom: 10px;
}

.words-empty > p:not(.editorial-kicker),
.progress-empty > p:not(.editorial-kicker) {
  max-width: 380px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.card-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  animation: message-in 160ms ease-out;
}

.card-item.is-due {
  padding-right: 13px;
  padding-left: 13px;
  border-bottom-color: var(--accent-line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.card-item + .card-item.is-due {
  margin-top: 12px;
}

.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.card-status {
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.card-reps {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.card-expression {
  margin: 0 0 5px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.card-meaning {
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.card-example {
  margin-top: 12px;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 18px;
}

.review-button {
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.review-button.good {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.card-error {
  margin-top: 12px;
}

/* Progress */
.learning-overview {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.learning-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.learning-heading h2 {
  max-width: 310px;
}

.learning-level {
  flex: 0 0 auto;
  color: var(--accent-text);
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: -.04em;
  line-height: 1;
}

.learning-confidence {
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

#learning-diagnostic {
  width: 100%;
}

.learning-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.learning-metrics div {
  min-width: 0;
}

.learning-metrics dt {
  color: var(--muted);
  font-size: 12px;
}

.learning-metrics dd {
  margin-top: 5px;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 29px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pronunciation-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 11px;
}

.learning-section {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.learning-details {
  margin-top: 16px;
  padding-top: 0;
}

.learning-details > summary {
  min-height: 48px;
  padding: 12px 2px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 650;
  list-style: none;
}

.learning-details > summary::-webkit-details-marker {
  display: none;
}

.learning-details > summary::after {
  content: "+";
  float: right;
  color: var(--muted);
  font-weight: 400;
}

.learning-details[open] > summary::after {
  content: "−";
}

.learning-details-body {
  padding: 5px 0 12px;
}

.learning-section-intro,
.learning-empty-line {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.mastery-list {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.mastery-topline,
.learning-error-topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.mastery-topline strong {
  min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.mastery-topline span {
  color: var(--accent-text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.mastery-item progress {
  margin: 9px 0 7px;
}

.mastery-item > p,
.learning-error-meta {
  color: var(--muted);
  font-size: 11px;
}

.learning-errors {
  margin-top: 8px;
}

.learning-error {
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.learning-error:last-child {
  border-bottom: 0;
}

.learning-error-topline {
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 11px;
}

.learning-error-status {
  color: var(--danger);
  font-weight: 700;
}

.learning-error.is-resolved .learning-error-status {
  color: var(--accent-text);
}

.learning-error-text {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.learning-error-text.incorrect {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--danger);
}

.learning-error-text.correction {
  margin-top: 3px;
  color: var(--text);
}

.learning-error-explanation {
  margin: 9px 0 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#activity-stats {
  margin-top: 28px;
}

.due-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 86px;
  gap: 16px;
  margin: 4px 0 28px;
  padding: 16px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--text);
  text-align: left;
}

.due-banner > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.due-banner-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.due-banner strong {
  color: var(--accent);
  font-size: 23px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.025em;
}

.due-banner-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.due-clear {
  margin: 3px 0 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
}

.metric {
  display: flex;
  flex-direction: column-reverse;
  min-height: 116px;
  gap: 8px;
  padding: 19px 0;
  border-top: 1px solid var(--line);
}

.metric-wide {
  grid-column: 1 / -1;
  min-height: 105px;
}

.metric dt {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.metric dd {
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 36px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
  line-height: 1;
}

.metric-wide dd {
  color: var(--accent);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 86px);
  left: 18px;
  max-width: 440px;
  margin: 0 auto;
  padding: 13px 16px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: #252d1e;
  box-shadow: 0 10px 30px rgb(0 0 0 / 30%);
  color: #eff7df;
  font-size: 13px;
  font-weight: 650;
  text-align: center;
  animation: toast-in 180ms ease-out;
}

.noscript {
  position: fixed;
  inset: 20px;
  z-index: 100;
  height: fit-content;
  padding: 18px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
}

#speech-next {
  grid-column: 1 / -1;
}

#speech-audio {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
}

.speech-result-expected {
  margin-top: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.message-image {
  display: block;
  width: 100%;
  max-height: 360px;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  object-fit: cover;
}

/* Dialog history */
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.sessions-drawer {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  align-items: end;
  justify-items: center;
}

.sessions-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgb(0 0 0 / 58%);
  cursor: default;
}

.sessions-sheet {
  position: relative;
  width: min(100%, 680px);
  max-height: 78dvh;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  overflow-y: auto;
}

.sessions-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sessions-list {
  display: grid;
  gap: 8px;
}

.session-item {
  display: grid;
  min-height: 64px;
  gap: 6px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.session-item[aria-current="true"] {
  border-color: var(--accent-control);
  background: var(--accent-soft);
}

.session-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item span {
  color: var(--muted);
  font-size: 12px;
}

@media (hover: hover) and (pointer: fine) {
  .mode-button:not([aria-pressed="true"]):hover,
  .nav-tab:hover {
    background: var(--surface);
    color: var(--text);
  }

  .practice-action:hover {
    padding-right: 10px;
    padding-left: 10px;
    background: var(--surface-soft);
  }

  .practice-action:hover > svg {
    color: var(--accent);
  }

  .button-quiet:hover,
  .icon-button:hover,
  .icon-text-button:hover {
    border-color: var(--accent-line);
    color: var(--text);
  }

  .word-composer summary:hover {
    background: var(--surface);
  }

  .composer-hint {
    display: block;
  }
}

@media (min-width: 681px) {
  .app {
    border-right: 1px solid #292d25;
    border-left: 1px solid #292d25;
    box-shadow: 0 0 60px rgb(0 0 0 / 24%);
  }

  .scroll-view {
    padding-right: 26px;
    padding-left: 26px;
  }

  .chat-heading {
    padding-right: 26px;
    padding-left: 26px;
  }

  .message-scroll {
    padding-right: 26px;
    padding-left: 26px;
  }
}

@media (max-width: 480px) {
  .lesson-card {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .lesson-card .button {
    width: 100%;
  }
}

@media (max-width: 350px) {
  .app-header,
  .chat-heading,
  .message-scroll,
  .scroll-view {
    padding-right: 13px;
    padding-left: 13px;
  }

  .header-context {
    max-width: 115px;
  }

  .practice-action {
    grid-template-columns: 24px minmax(0, 1fr) 18px;
    gap: 8px;
  }

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

  .lesson-card .button {
    width: 100%;
  }

  .chat-actions {
    gap: 5px;
  }

  .chat-actions .icon-text-button {
    padding-right: 8px;
    padding-left: 8px;
  }

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

  .due-banner {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-height: 500px) {
  .chat-heading {
    min-height: 0;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .chat-heading > div:first-child,
  .chat-audio > span,
  .composer-hint {
    display: none;
  }

  .chat-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .chat-audio {
    margin-bottom: 4px;
    padding: 5px 8px;
  }

  .composer-wrap {
    padding-top: 4px;
    padding-bottom: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .loader {
    border-color: var(--accent-control);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  from { opacity: .25; transform: translateY(1px); }
  to { opacity: 1; transform: translateY(-1px); }
}

@keyframes view-in {
  from { opacity: .5; }
  to { opacity: 1; }
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
