/* Learning surfaces: study cards, exercises, task builder, student workspace.
   Built only from the shared tokens (--panel, --line, --accent, --r-*) so every
   accent, both modes and both interface styles restyle it for free. */

.study-card {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.study-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.study-card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.study-card-status {
  margin-inline-start: auto;
}
.study-card-body {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.card-text,
.card-translation,
.card-example {
  margin: 0;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.card-translation {
  color: var(--text);
  font-weight: 600;
}
.card-text {
  color: var(--muted);
}
.card-example {
  padding-inline-start: 12px;
  border-inline-start: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.card-formula {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.card-block {
  display: grid;
  gap: 6px;
}
.card-label {
  color: var(--faint);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.card-bullets {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-inline-start: 18px;
  color: var(--muted);
}
.card-bullets.is-mistakes li::marker {
  color: var(--danger);
  content: "✕  ";
}
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chip {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.mistake-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}
.mistake-mark {
  flex: none;
  width: 1.2em;
  font-weight: 700;
  text-align: center;
}
.mistake-line.is-wrong {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent);
}
.mistake-line.is-wrong .mistake-mark {
  color: var(--danger);
  text-decoration: none;
}
.mistake-line.is-right {
  color: var(--text);
  font-weight: 600;
}
.mistake-line.is-right .mistake-mark {
  color: var(--success);
}

.exercise {
  display: grid;
  gap: 10px;
  justify-items: start;
}
.exercise-list {
  display: grid;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding-inline-start: 20px;
}
.exercise-row {
  display: grid;
  gap: 6px;
}
.exercise-prompt {
  color: var(--text);
}
.exercise-input {
  width: 100%;
  max-width: 420px;
}
.exercise-mark {
  min-height: 1.2em;
  font-size: 13px;
}
.exercise-row.is-correct .exercise-mark {
  color: var(--success);
}
.exercise-row.is-wrong .exercise-mark {
  color: var(--danger);
}
.exercise-row.is-correct .exercise-input {
  border-color: var(--success);
}
.exercise-row.is-wrong .exercise-input {
  border-color: var(--danger);
}

.inline-form {
  display: flex;
  gap: 8px;
}
.inline-form input {
  flex: 1;
  min-width: 0;
}
.field-hint {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.4;
}

.study-status-control {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel-soft);
}
.study-status-control .seg {
  min-height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition:
    background-color 160ms var(--ease),
    color 160ms var(--ease);
}
.study-status-control .seg:hover {
  color: var(--text);
}
.study-status-control .seg.is-active {
  background: var(--accent);
  color: var(--on-accent);
}
.study-status {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}
.study-status.is-learning {
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  color: var(--warning);
}
.study-status.is-known {
  background: color-mix(in srgb, var(--success) 16%, transparent);
  color: var(--success);
}

@media (prefers-reduced-motion: reduce) {
  .study-status-control .seg {
    transition: none;
  }
}
:root[data-anim="off"] .study-status-control .seg {
  transition: none;
}

@media (max-width: 767px) {
  .study-card {
    padding: 14px;
  }
  .study-card-status {
    margin-inline-start: 0;
    width: 100%;
  }
  .study-status-control {
    width: 100%;
  }
  .study-status-control .seg {
    flex: 1;
  }
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 24px;
}
.about-item {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.about-value {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.about-value.is-empty {
  color: var(--faint);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

/* Task builder (teacher) */
.task-builder {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel-soft);
}
.task-builder-head {
  display: grid;
  gap: 2px;
}
.task-list {
  display: grid;
  gap: 12px;
}
.task-builder-add {
  display: flex;
  gap: 8px;
}
.task-builder-add select {
  flex: 1;
  min-width: 0;
}
.task-editor {
  position: relative;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.task-editor-legend {
  padding: 0 6px;
}
.task-editor-tools {
  position: absolute;
  top: -14px;
  right: 10px;
  display: flex;
  gap: 4px;
  background: var(--panel);
}
.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
  transition:
    border-color 160ms var(--ease),
    background-color 160ms var(--ease);
}
.check-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.check-chip:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Task answers (student) and review (teacher) */
.task-block {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.task-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-number {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 650;
  font-size: 13px;
}
.task-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-width: 0;
}
.task-title {
  margin: 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}
.task-prompt {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}
.task-answer {
  display: grid;
  gap: 10px;
  padding: 2px;
  border-radius: var(--r-sm);
}
.task-answer.is-correct {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 45%, transparent);
}
.task-answer.is-wrong {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 45%, transparent);
}
.task-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--panel-soft);
}
.task-image {
  max-width: min(100%, 420px);
  max-height: 320px;
  border-radius: var(--r-sm);
  object-fit: contain;
}
.task-reviewed {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}
.choice-list {
  display: grid;
  gap: 8px;
}
.choice-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.choice-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice-option.is-key {
  border-color: var(--success);
}
.fill-line {
  margin: 0;
  line-height: 2.2;
}
.fill-blank {
  width: 9ch;
  margin-inline: 4px;
  padding: 2px 8px;
  text-align: center;
}
.task-review {
  display: grid;
  gap: 12px;
}

@media (max-width: 767px) {
  .task-builder-add {
    flex-direction: column;
  }
  .task-block,
  .task-editor {
    padding: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .check-chip {
    transition: none;
  }
}
:root[data-anim="off"] .check-chip {
  transition: none;
}

/* Progress (TZ section 13) */
.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
/* the weekly chart sits a card-gap below the tiles, as the XP log sits below it */
.progress-stats + .ios-section {
  margin-top: var(--gap, 16px);
}
.progress-stat {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.progress-stat-value {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.progress-stat-total {
  color: var(--faint);
  font-size: 15px;
  font-weight: 500;
}

/* Student workspace (teacher) */
.workspace-tabs {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.workspace-tabs::-webkit-scrollbar {
  display: none;
}
.workspace-tab {
  flex: none;
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition:
    color 160ms var(--ease),
    border-color 160ms var(--ease);
}
.workspace-tab:hover {
  color: var(--text);
}
.workspace-tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}
.workspace-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.workspace-actions:empty {
  display: none;
}
tr.is-clickable {
  cursor: pointer;
}
tr.is-clickable:hover td {
  background: var(--accent-soft);
}
@media (prefers-reduced-motion: reduce) {
  .workspace-tab {
    transition: none;
  }
}
:root[data-anim="off"] .workspace-tab {
  transition: none;
}

/* Student home (TZ section 4) */
.home-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip--xp {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}
.chip--info {
  border-color: var(--accent);
  color: var(--text);
}
.home-focus {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.chip .badge {
  margin-left: 6px;
}
.home-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.home-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.home-card--today {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: linear-gradient(135deg, var(--accent-soft), var(--panel) 70%);
}
.home-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.home-card-head h3 {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.home-card-body {
  display: grid;
  gap: 10px;
  justify-items: start;
  min-width: 0;
}
.home-focus {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.home-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
  width: 100%;
}
.home-row-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.home-row .field-hint {
  grid-column: 1;
}
.home-row .table-action {
  grid-column: 2;
  grid-row: 1 / span 2;
}
.home-progress {
  display: grid;
  gap: 6px;
}

/* My World presets */
.world-presets {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.world-presets:empty {
  display: none;
}
.chip-list--buttons {
  gap: 8px;
}
.chip--button {
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition:
    border-color 160ms var(--ease),
    background-color 160ms var(--ease);
}
.chip--button:hover,
.chip--button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
@media (prefers-reduced-motion: reduce) {
  .chip--button {
    transition: none;
  }
}
:root[data-anim="off"] .chip--button {
  transition: none;
}

/* Card pictures */
.card-image,
.card-image-preview {
  max-width: min(100%, 360px);
  max-height: 240px;
  border-radius: var(--r-sm);
  object-fit: cover;
}
.card-image-field {
  display: grid;
  gap: 8px;
  justify-items: start;
}

/* The roster has the full width of the page, so it keeps its columns until a
   phone: there the last activity and the review count go first, then the level. */
@media (min-width: 641px) and (max-width: 767px) {
  #teacherStudentTable th:nth-child(3),
  #teacherStudentTable td:nth-child(3),
  #teacherStudentTable th:nth-child(2),
  #teacherStudentTable td:nth-child(2) {
    display: none;
  }
}

/* Phone: search takes the whole row, the level filter and its button share the next. */
@media (max-width: 640px) {
  .filter-bar .filter-search {
    flex: 1 1 100%;
  }
  .filter-bar .filter-select {
    flex: 1 1 0;
  }
}

/* Native checkboxes and radios must not inherit the full-width field sizing. */
.check-chip input,
.choice-option input,
.task-editor input[type="checkbox"] {
  flex: none;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
}
.check-chip span {
  white-space: nowrap;
}

/* The brand lockup is a button; strip the browser's default chrome. */
.brand-lockup,
.brand-lockup.is-active,
.brand-lockup:hover {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.check-chip--block {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-radius: var(--r-md);
}
.check-chip--block .check-chip-copy {
  display: grid;
  gap: 2px;
}
.check-chip--block span {
  white-space: normal;
}
.pill--private {
  border-color: var(--line-strong);
  color: var(--muted);
}

/* Layout safety net: grid and flex children may shrink below their content,
   so one wide table or long word can never push a page past the viewport. */
.content,
.view-root,
.app-view,
.grid > *,
.stack > *,
.ios-section,
.view-head > *,
.filter-bar > * {
  min-width: 0;
}
/* the actions are never narrower than their widest button: the heading text
   shrinks instead of sliding under a button that cannot */
.view-head > .view-actions {
  min-width: min-content;
}
.app-view,
.ios-section {
  max-width: 100%;
}
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

/* One size scale for every control, centred the same way: 40 / 32. */
.btn,
.table-action,
.segmented button,
.icon-btn,
.sidebar-collapse,
.view-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  padding-block: 0;
  line-height: 1.1;
  text-align: center;
}
.btn {
  min-height: var(--ctl, 40px);
}
.btn--sm {
  min-height: var(--ctl-sm, 32px);
}
.icon-btn {
  width: var(--ctl, 40px);
  height: var(--ctl, 40px);
  min-height: 0;
  padding: 0;
}
.icon-btn--sm {
  width: var(--ctl-sm, 32px);
  height: var(--ctl-sm, 32px);
}
.table-action {
  min-height: var(--ctl-sm, 32px);
  padding-inline: 12px;
}
.segmented button {
  min-height: var(--ctl-sm, 32px);
  padding-inline: 14px;
}
.sidebar-collapse {
  min-width: 44px;
  min-height: var(--ctl-sm, 32px);
}

/* Phone: the roster is a list of cards, not a scrolling table. */
#teacherStudentTable .table-primary span {
  overflow-wrap: anywhere;
}
/* Tablet: the name column keeps room to read the name instead of "Demo ...". */
@media (min-width: 641px) and (max-width: 1100px) {
  #teacherStudentTable .table-primary {
    min-width: 120px;
  }
  #teacherStudentTable th,
  #teacherStudentTable td {
    padding-inline: 8px;
  }
  #teacherStudentTable th {
    white-space: normal;
    letter-spacing: 0.08em;
  }
  #teacherStudentTable .table-primary strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
@media (max-width: 640px) {
  #teacherStudentTable .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #teacherStudentTable table,
  #teacherStudentTable tbody {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }
  #teacherStudentTable thead {
    display: none;
  }
  #teacherStudentTable tr {
    display: grid;
    grid-template-columns: 0.7fr 0.8fr 1.3fr;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-md, 14px);
    background: var(--panel);
  }
  #teacherStudentTable td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
  }
  #teacherStudentTable td:first-child {
    grid-column: 1 / 3;
    grid-row: 1;
  }
  #teacherStudentTable td:last-child {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }
  #teacherStudentTable td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    color: var(--muted);
    font-size: 11px;
  }
  /* last activity is a quiet footnote under the three figures */
  #teacherStudentTable td[data-field="activity"] {
    grid-column: 1 / -1;
    grid-row: 3;
    color: var(--muted);
    font-size: 12px;
  }
  #teacherStudentTable td[data-field="activity"]::before {
    display: inline;
    margin-inline-end: 6px;
  }
}

/* ---- Accounts (spec section 3): access dialog, notices, account card ---- */
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inline-actions input.mono {
  flex: 1 1 220px;
  min-width: 0;
}

.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  letter-spacing: 0.01em;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.terms-block h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.terms-block p {
  margin: 0;
  color: var(--muted, inherit);
}

.account-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.account-panel h3 {
  margin: 0;
}

.account-panel[data-status="disabled"] {
  border-color: var(--danger, #e5484d);
}

.dialog-body.form-stack > .form-note[hidden] {
  display: none;
}

@media (max-width: 480px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.lesson-block {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.lesson-block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}
.lesson-block-head h3 {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.lesson-block-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}
.lesson-warning {
  margin: 0;
  color: var(--warn, var(--text));
}
.lesson-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.lesson-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.lesson-link-host {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.92;
}
@media (max-width: 767px) {
  .lesson-block-fields {
    grid-template-columns: 1fr;
  }
}

.world-card-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel-2, var(--panel));
  cursor: zoom-in;
}
.world-card-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.world-card-photo:hover img,
.world-card-photo:focus-visible img {
  transform: scale(1.03);
}
.photo-viewer {
  display: grid;
  justify-items: center;
}
.photo-viewer img {
  max-width: 100%;
  max-height: 72vh;
  border-radius: var(--r-md);
  object-fit: contain;
}
@media (prefers-reduced-motion: reduce) {
  .world-card-photo img {
    transition: none;
  }
}
html[data-anim="off"] .world-card-photo img {
  transition: none;
}

/* Lesson view: full screen, built for screen sharing (spec 4.4, L-2) */
body.lv-open {
  overflow: hidden;
}
.lesson-view {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px clamp(16px, 3vw, 40px) 20px;
  background: var(--bg);
  color: var(--text);
  animation: lv-in 0.22s ease-out;
}
@keyframes lv-in {
  from {
    opacity: 0;
    transform: scale(0.992);
  }
}
.lv-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}
.lv-head-copy {
  display: grid;
  gap: 2px;
  margin-right: auto;
}
.lv-student {
  font-size: 20px;
}
.lv-collection {
  min-width: 200px;
  max-width: 320px;
  font-size: 16px;
}
.lv-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.lv-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 14px;
  min-height: 0;
}
.lv-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
  height: 100%;
}
.lv-stage--text,
.lv-stage--note {
  text-align: center;
}
.lv-photo-wrap {
  display: grid;
  flex: 1 1 0;
  place-items: center;
  width: 100%;
  min-height: 0;
}
.lv-photo {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-lg);
  object-fit: contain;
  box-shadow: var(--n-layer-2, 0 18px 50px rgba(0, 0, 0, 0.25));
}
.lv-title {
  margin: 0;
  font-size: clamp(24px, 3.2vw, 40px);
  letter-spacing: -0.03em;
}
.lv-body,
.lv-note {
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(20px, 2.4vw, 30px);
  line-height: 1.4;
}
.lv-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.lv-step {
  font-size: 28px;
  line-height: 1;
}
.lv-counter {
  min-width: 5ch;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.lv-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.lv-prompts li {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: clamp(18px, 2vw, 26px);
}
.lv-foot {
  display: grid;
  gap: 12px;
  justify-items: center;
}
.lv-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.lv-actions .btn {
  min-height: 44px;
  font-size: 16px;
}
.lv-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: center;
  gap: 12px;
  width: min(100%, 860px);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.lv-quick .field {
  flex: 1 1 220px;
}
.lv-quick .input {
  font-size: 18px;
}
.lv-quick-buttons {
  display: flex;
  gap: 8px;
}
@media (max-width: 767px) {
  .lesson-view {
    gap: 10px;
    padding: 12px 12px 14px;
  }
  .lv-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }
  .lv-collection {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .lv-head-actions {
    flex-wrap: nowrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  .lesson-view {
    animation: none;
  }
}
html[data-anim="off"] .lesson-view {
  animation: none;
}

/* Word cards (spec 5.8): badges, Listen, highlighted example, notes */
.badge--new {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.badge--warn {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 11%, transparent);
  border-color: color-mix(in srgb, var(--warning) 27%, var(--line));
}
.badge--ready {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 11%, transparent);
  border-color: color-mix(in srgb, var(--success) 27%, var(--line));
}
.toast--warn {
  border-color: color-mix(in srgb, var(--warning) 45%, var(--line));
}
.study-card.is-new {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.study-card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.listen-btn {
  min-width: 36px;
  min-height: 36px;
  font-size: 15px;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-ipa {
  color: var(--muted);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13px;
}
.card-mark {
  padding: 0 2px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: inherit;
  font-weight: 650;
}
.card-note,
.is-warn {
  color: var(--warning);
}
.list-row.is-archived {
  opacity: 0.62;
}
.study-card.is-resolved {
  opacity: 0.6;
}

/* Word practice (5.9): one card at a time */
.practice-host {
  display: grid;
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
}
.practice-host:empty {
  display: none;
}
.practice-note {
  margin: 0;
  color: var(--muted);
}
.practice-progress {
  position: relative;
  display: flex;
  align-items: center;
  height: 22px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: var(--panel-soft);
}
.practice-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent-soft);
  transition: width 240ms var(--ease);
}
.practice-progress-text {
  position: relative;
  width: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.practice-card {
  display: grid;
  gap: 14px;
}
.practice-card > .btn {
  justify-self: start;
}
.practice-lookword {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.practice-mode {
  justify-self: start;
}
.practice-question {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}
.practice-word,
.practice-lookword {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.practice-image {
  width: 100%;
  max-height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  object-fit: contain;
  background: var(--panel-soft);
}
.practice-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.practice-option {
  min-height: 52px;
  justify-content: center;
  font-size: 17px;
}
.practice-input {
  width: 100%;
  font-size: 18px;
}
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.practice-verdict {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-weight: 650;
}
.practice-verdict.is-right {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
}
.practice-verdict.is-wrong {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}
.practice-verdict.is-warn {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
}
.practice-reveal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel-soft);
}
.practice-summary {
  display: grid;
  gap: 10px;
}
.practice-summary h3 {
  margin: 0;
}
/* ---- Practice start: a ring that fills, a counting number, an orbiting light ---- */
@property --pr-ang {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.practice-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px 32px;
  align-items: center;
  padding: 28px 32px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: var(--r-lg, 22px);
  background:
    radial-gradient(
      90% 140% at 0% 0%,
      color-mix(in srgb, var(--accent) 16%, transparent),
      transparent 62%
    ),
    var(--panel);
  overflow: hidden;
  animation: pr-rise 0.6s var(--ease, ease) both;
}
.practice-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(
    from var(--pr-ang),
    transparent 0 62%,
    color-mix(in srgb, var(--accent) 90%, #fff) 84%,
    transparent 100%
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
  animation: pr-spin 8s linear infinite;
  pointer-events: none;
}
.practice-hero.is-done {
  border-color: color-mix(in srgb, var(--success) 40%, var(--line));
  background:
    radial-gradient(
      90% 140% at 0% 0%,
      color-mix(in srgb, var(--success) 14%, transparent),
      transparent 62%
    ),
    var(--panel);
}
.practice-hero.is-done::before {
  display: none;
}
.practice-hero-copy {
  display: grid;
  gap: 10px;
  justify-items: start;
  min-width: 0;
}
.practice-hero-copy .card-text {
  margin: 0;
}
.practice-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 132px;
  aspect-ratio: 1;
}
.practice-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.practice-ring-svg circle {
  fill: none;
  stroke-width: 7;
}
.practice-ring-track {
  stroke: var(--line);
}
.practice-ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--fill, 0));
  filter: drop-shadow(
    0 0 6px color-mix(in srgb, var(--accent) 70%, transparent)
  );
  animation: pr-fill 1.1s 0.15s var(--ease, ease) both;
}
.is-done .practice-ring-fill {
  stroke: var(--success);
  filter: drop-shadow(
    0 0 6px color-mix(in srgb, var(--success) 70%, transparent)
  );
}
.practice-ring-orbit {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  animation: pr-orbit 7s linear infinite;
  pointer-events: none;
}
.practice-ring-orbit::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px color-mix(in srgb, var(--accent) 80%, transparent);
}
.is-done .practice-ring-orbit {
  display: none;
}
.practice-ring-num {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.practice-ring-check {
  width: 48px;
  height: 48px;
  color: var(--success);
  stroke-width: 2.4;
  animation: pr-pop 0.6s 0.5s var(--spring, ease) both;
}
.practice-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 6px;
  padding: 0;
  list-style: none;
}
.practice-modes li {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(
    in srgb,
    var(--panel-soft, var(--panel)) 70%,
    transparent
  );
  font-size: 12.5px;
  transition:
    transform 0.25s var(--spring, ease),
    border-color 0.25s,
    color 0.25s;
  animation: pr-chip 0.5s calc(0.35s + var(--i, 0) * 70ms) var(--spring, ease)
    both;
}
.practice-modes li:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--text);
}
.practice-go {
  min-height: 48px;
  padding-inline: 34px;
  font-size: 16px;
}
:root[data-style="neon"] .practice-go {
  animation: pr-glow 3.2s ease-in-out infinite;
}
@keyframes pr-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}
@keyframes pr-spin {
  to {
    --pr-ang: 360deg;
  }
}
@keyframes pr-fill {
  from {
    stroke-dashoffset: 100;
  }
}
@keyframes pr-orbit {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pr-pop {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-20deg);
  }
}
@keyframes pr-chip {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
}
@keyframes pr-glow {
  50% {
    transform: scale(1.035);
  }
}
@media (max-width: 560px) {
  .practice-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 24px 20px;
    text-align: center;
  }
  .practice-hero-copy {
    justify-items: center;
  }
  .practice-modes {
    justify-content: center;
  }
  .practice-go {
    width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .practice-hero,
  .practice-hero *,
  .practice-hero::before {
    animation: none !important;
  }
}
:root[data-anim="off"] .practice-hero,
:root[data-anim="off"] .practice-hero *,
:root[data-anim="off"] .practice-hero::before {
  animation: none !important;
}
.practice-page-after {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.practice-score {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
@media (max-width: 520px) {
  .practice-options {
    grid-template-columns: 1fr;
  }
}
.practice-reveal .card-example {
  flex-basis: 100%;
  margin: 0;
}

/* Phone: the class progress table becomes one card per student. */
@media (max-width: 640px) {
  #teacherProgressTable .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #teacherProgressTable table,
  #teacherProgressTable tbody {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }
  #teacherProgressTable thead {
    display: none;
  }
  #teacherProgressTable tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-md, 14px);
    background: var(--panel);
  }
  #teacherProgressTable td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
  }
  #teacherProgressTable td:first-child {
    grid-column: 1 / -1;
  }
  #teacherProgressTable td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    color: var(--muted);
    font-size: 11px;
  }
}

/* Phone and tablet: admin tables are lists of cards (column name above each value);
   next to the sidebar a table of five columns would scroll sideways and hide the actions. */
@media (max-width: 1100px) {
  #adminUsersTable.table-wrap,
  #adminAuditTable.table-wrap,
  #adminPricingTable.table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #adminUsersTable table,
  #adminUsersTable tbody,
  #adminAuditTable table,
  #adminAuditTable tbody,
  #adminPricingTable table,
  #adminPricingTable tbody {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
  }
  #adminUsersTable thead,
  #adminAuditTable thead,
  #adminPricingTable thead {
    display: none;
  }
  #adminUsersTable tr,
  #adminAuditTable tr,
  #adminPricingTable tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r-md, 14px);
    background: var(--panel);
  }
  #adminUsersTable td,
  #adminAuditTable td,
  #adminPricingTable td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent !important;
    overflow-wrap: anywhere;
  }
  #adminUsersTable td:first-child,
  #adminAuditTable td:first-child,
  #adminPricingTable td:first-child,
  #adminUsersTable td:last-child,
  #adminPricingTable td:last-child {
    grid-column: 1 / -1;
  }
  #adminUsersTable td[data-label]:not(:first-child):not(:last-child)::before,
  #adminAuditTable td[data-label]:not(:first-child)::before,
  #adminPricingTable td[data-label]:not(:first-child):not(:last-child)::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 11px;
  }
}

/* The plan cards already carry edit and delete, so the table would repeat them. */
@media (max-width: 1100px) {
  #adminPricingTable.table-wrap {
    display: none;
  }
}
