:root {
  color-scheme: light;
  --bg: #f3f8f2;
  --surface: #ffffff;
  --surface-soft: #eef8ef;
  --line: #d8e5da;
  --line-strong: #76ceb3;
  --text: #111827;
  --muted: #6b7280;
  --soft: #374151;
  --current: #17c7d8;
  --correct: #2cc66d;
  --wrong: #ef4444;
  --progress: #16a36b;
  --amber: #b7791f;
  --cyber: #47f0d5;
  --orange: #ff7a1a;
  --shadow: 0 18px 54px rgba(9, 30, 22, 0.12);
  font-family: "Avenir Next", "PingFang SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(71, 240, 213, 0.16), transparent 26%),
    radial-gradient(circle at 92% 8%, rgba(255, 122, 26, 0.12), transparent 25%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(243, 248, 242, 0.94)),
    #f3f8f2;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
.block-main {
  font-family: "Songti SC", "Source Han Serif SC", Georgia, serif;
}

.app-shell {
  width: min(100%, 1280px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 24px 76px;
}

.app-shell.loading {
  display: grid;
  place-items: center;
}

.darkFocus {
  color-scheme: dark;
  --bg: #071110;
  --surface: #0d1a17;
  --surface-soft: #10251f;
  --line: rgba(114, 226, 190, 0.2);
  --line-strong: rgba(71, 240, 213, 0.48);
  --text: #edf4ea;
  --muted: #a7b2a4;
  --soft: #d7e2d3;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
}

.darkFocus.app-shell,
.darkFocus .overlay {
  background: #101612;
}

.loading-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px 26px;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.topbar {
  height: 48px;
  display: grid;
  grid-template-columns: 210px minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.top-left strong {
  font-size: 16px;
}

.top-left span,
.top-center span {
  color: var(--muted);
  font-size: 13px;
}

.top-center {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.top-center span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.source-switch {
  width: 100%;
  min-height: 24px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.top-center::after {
  content: "";
  display: block;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  grid-row: 2;
}

.top-center i {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--progress), var(--current));
  grid-row: 2;
  margin-top: -10px;
  transition: width 0.2s ease;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button,
.ghost,
.action,
.search-row button,
.answer-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  font-weight: 750;
}

.icon-button:hover,
.ghost:hover,
.action:hover {
  border-color: var(--line-strong);
}

.icon-button {
  min-width: 44px;
  color: var(--soft);
  padding: 0 10px;
}

.user-button {
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost {
  color: #087f5b;
  background: color-mix(in srgb, var(--surface-soft) 70%, var(--surface));
}

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

.action-primary {
  border-color: #78c6a3;
  background: #207d61;
  color: #ffffff;
}

.workspace {
  min-height: calc(100vh - 142px);
  display: grid;
  align-items: center;
  padding: 24px 0;
}

.home-panel,
.practice-stage,
.completion-panel {
  width: min(100%, 980px);
  margin: 0 auto;
}

.home-panel {
  display: grid;
  gap: 26px;
  align-content: center;
}

.home-title {
  display: grid;
  gap: 12px;
}

.eyebrow {
  color: #087f5b;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.home-title h1,
.completion-panel h1 {
  font-size: 42px;
  line-height: 1.16;
  letter-spacing: 0;
}

.home-title p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.9;
}

.home-actions,
.step-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric-strip,
.completion-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.metric-strip span,
.completion-grid span {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
  color: var(--muted);
}

.metric-strip b,
.completion-grid strong {
  display: block;
  margin-top: 7px;
  color: #087f5b;
  font-size: 25px;
}

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

.source-card {
  min-height: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 16px;
  text-align: left;
  display: grid;
  gap: 7px;
  align-content: start;
}

.source-card:hover,
.source-card:focus-visible {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--progress) 13%, transparent);
}

.source-card span,
.doc-status {
  color: #087f5b;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.source-card strong {
  font-size: 19px;
  line-height: 1.35;
}

.source-card small {
  color: var(--muted);
  line-height: 1.65;
}

.primary-source {
  background: color-mix(in srgb, var(--surface-soft) 55%, var(--surface));
}

.form-panel {
  width: min(100%, 980px);
  margin: 0 auto;
  display: grid;
  gap: 22px;
}

.stack-form {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stack-form label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-weight: 750;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

.stack-form textarea {
  resize: vertical;
  min-height: 118px;
  line-height: 1.7;
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--progress) 14%, transparent);
}

.split-fields,
.form-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.custom-doc-list {
  display: grid;
  gap: 12px;
}

.custom-doc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 220px;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.custom-doc-row h2 {
  margin: 5px 0 8px;
  font-size: 21px;
  line-height: 1.3;
}

.custom-doc-row p {
  color: var(--muted);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.doc-metrics {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.doc-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.danger {
  color: #b42318;
  background: #fff5f3;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 24px;
  display: grid;
  gap: 12px;
  color: var(--soft);
}

.empty-state h2 {
  font-size: 24px;
}

.source-menu-list,
.info-list {
  display: grid;
  gap: 12px;
}

.info-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  color: var(--soft);
  line-height: 1.85;
}

.admin-panel {
  width: min(100%, 1180px);
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.admin-grid {
  display: grid;
  gap: 16px;
}

.admin-grid section {
  display: grid;
  gap: 10px;
}

.admin-grid h2 {
  font-size: 22px;
}

.admin-table {
  display: grid;
  gap: 8px;
}

.admin-row {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(90px, 0.5fr) minmax(120px, 0.5fr) auto;
  gap: 12px;
  align-items: center;
  color: var(--soft);
}

.admin-row span:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-row b,
.admin-row small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.admin-row small {
  color: var(--muted);
  font-size: 12px;
}

.legal-notice {
  border-left: 3px solid #10b981;
  padding: 10px 14px;
  color: var(--soft);
  line-height: 1.8;
  background: var(--surface-soft);
}

.legal-notice span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.practice-stage {
  display: grid;
  gap: 16px;
}

.stage-kicker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.stage-kicker span:first-child {
  color: #087f5b;
  font-weight: 850;
}

.target-wrap {
  min-height: 280px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
  box-shadow: var(--shadow);
}

.display-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: stretch;
}

.display-block {
  min-width: 112px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 12px 13px;
  display: grid;
  gap: 8px;
  align-content: start;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.darkFocus .display-block {
  background: #121b16;
}

.display-block.current {
  border-color: color-mix(in srgb, var(--current) 62%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--current) 14%, transparent);
}

.display-block.correct {
  border-color: color-mix(in srgb, var(--correct) 70%, var(--line));
  background: color-mix(in srgb, var(--correct) 9%, var(--surface));
}

.display-block.wrong {
  border-color: color-mix(in srgb, var(--wrong) 72%, var(--line));
  background: color-mix(in srgb, var(--wrong) 8%, var(--surface));
}

.display-block.answer {
  border-color: color-mix(in srgb, var(--amber) 45%, var(--line));
}

.block-main {
  min-height: 36px;
  color: var(--text);
  font-size: 25px;
  line-height: 1.35;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.word-stage .block-main {
  font-size: 38px;
}

.char {
  display: inline-flex;
  min-width: 0.62ch;
  min-height: 1.32em;
  align-items: center;
  justify-content: center;
  margin-right: 1px;
  border-bottom: 2px solid transparent;
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  font-size: 22px;
}

.word-stage .char {
  font-size: 34px;
}

.char.pending {
  color: transparent;
  border-bottom-color: var(--line);
}

.char.pending.space {
  min-width: 0.9ch;
  border-bottom-color: transparent;
}

.char.correct {
  color: #15803d;
}

.char.wrong {
  color: var(--wrong);
  background: color-mix(in srgb, var(--wrong) 10%, transparent);
  border-radius: 4px;
}

.full-target {
  white-space: pre-wrap;
}

.segment-line {
  height: 4px;
  display: flex;
  gap: 2px;
}

.segment-line i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--progress) 54%, var(--line));
}

.token-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.token-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  background: color-mix(in srgb, var(--surface-soft) 68%, var(--surface));
}

.extra-input {
  margin-top: 10px;
  color: var(--wrong);
  font-size: 13px;
}

.hint-strip {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px 14px;
}

.hint-strip span {
  color: var(--muted);
  font-size: 13px;
}

.hint-strip strong {
  color: var(--soft);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.hidden-hint {
  grid-template-columns: 1fr;
  justify-items: start;
  border-style: dashed;
}

.input-line {
  min-height: 54px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 9px 12px;
}

.input-line input {
  width: 100%;
  border: 0;
  outline: none;
  color: var(--text);
  background: transparent;
  font-size: 20px;
  line-height: 1.4;
}

.input-line span {
  color: var(--muted);
  font-size: 13px;
}

.input-line.typing,
.input-line.ready {
  border-color: var(--line-strong);
}

.input-line.correct {
  border-color: color-mix(in srgb, var(--correct) 70%, var(--line));
}

.input-line.wrong {
  border-color: color-mix(in srgb, var(--wrong) 70%, var(--line));
}

.feedback {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
}

.feedback b {
  color: var(--soft);
}

.feedback span {
  color: var(--muted);
  line-height: 1.65;
}

.feedback small,
.answer-card {
  grid-column: 1 / -1;
}

.feedback.success {
  border-color: color-mix(in srgb, var(--correct) 50%, var(--line));
}

.feedback.error {
  border-color: color-mix(in srgb, var(--wrong) 55%, var(--line));
}

.feedback.warn {
  border-color: color-mix(in srgb, var(--amber) 55%, var(--line));
}

.answer-button {
  color: #8a5a00;
  background: #fff7db;
  border-color: #ecd18a;
}

.answer-card {
  border: 1px solid #ecd18a;
  border-radius: 8px;
  background: #fff9e8;
  color: #5f4300;
  padding: 10px 12px;
  line-height: 1.7;
}

.word-answer-toast {
  width: fit-content;
  min-width: 180px;
  justify-self: center;
  border: 1px solid #86c8a7;
  border-radius: 8px;
  background: #f3fff8;
  color: #065f46;
  box-shadow: 0 14px 36px rgba(16, 185, 129, 0.16);
  padding: 12px 24px;
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  font-size: 24px;
  font-weight: 850;
  text-align: center;
  animation: answerToastIn 0.14s ease-out;
}

.darkFocus .word-answer-toast {
  background: #12251c;
  color: #bff7d3;
}

@keyframes answerToastIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.completion-panel {
  display: grid;
  gap: 22px;
}

.shortcut-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 9;
  transform: translateX(-50%);
  width: min(920px, calc(100vw - 48px));
  min-height: 40px;
  display: flex;
  justify-content: center;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 12px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  justify-items: end;
  background: rgba(17, 24, 39, 0.22);
}

.drawer {
  width: min(560px, 100vw);
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.drawer-head h2 {
  margin-top: 5px;
  font-size: 26px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 70px;
  gap: 8px;
}

.search-row input,
.settings-panel select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.search-row input:focus,
.settings-panel select:focus,
.input-line:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--progress) 14%, transparent);
}

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

.article-row {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
}

.article-row.active,
.article-row:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.article-row span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.article-row b,
.article-row small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.article-row small,
.article-row i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.settings-panel label {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--soft);
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.reader-note {
  border-left: 3px solid var(--progress);
  padding: 8px 12px;
  background: var(--surface-soft);
  color: var(--soft);
}

.reader-panel article {
  display: grid;
  gap: 12px;
}

.reader-panel h3 {
  margin-top: 8px;
  font-size: 16px;
  color: #087f5b;
}

.reader-panel p {
  line-height: 1.9;
  color: var(--soft);
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 70px;
  z-index: 40;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo img {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(71, 240, 213, 0.25), 0 12px 28px rgba(22, 163, 107, 0.22);
}

.brand-logo span {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.brand-logo b {
  color: var(--text);
  font-size: 17px;
  line-height: 1;
}

.brand-logo small {
  color: var(--muted);
  font-size: 11px;
}

.hero-brand img {
  width: 58px;
  height: 58px;
  border-radius: 16px;
}

.hero-brand b {
  font-size: 20px;
}

.top-left {
  align-items: center;
}

.lobby-panel {
  width: min(100%, 1120px);
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: stretch;
}

.home-title .slogan {
  max-width: 820px;
  color: var(--soft);
  font-weight: 750;
}

.hud-card {
  border: 1px solid color-mix(in srgb, var(--cyber) 34%, var(--line));
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface) 88%, var(--cyber)), var(--surface)),
    var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 10px;
  align-content: center;
}

.hud-card span,
.hud-chip b,
.mistake-row span,
.snapshot-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.hud-card strong {
  font-size: 22px;
  line-height: 1.35;
}

.hud-card small {
  color: var(--muted);
  line-height: 1.65;
}

.lobby-metrics {
  grid-template-columns: repeat(6, 1fr);
}

.battle-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hud-chip,
.combo-badge {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-soft));
  color: var(--text);
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
}

.hud-chip b {
  white-space: nowrap;
}

.hud-chip.danger {
  border-color: color-mix(in srgb, var(--wrong) 30%, var(--line));
}

.combo-badge {
  border-color: color-mix(in srgb, var(--orange) 58%, var(--line));
  background: color-mix(in srgb, var(--orange) 12%, var(--surface));
  color: #9a4200;
  font-weight: 900;
  animation: comboPop 0.42s ease-out;
}

.star-row {
  display: inline-flex;
  gap: 2px;
  color: color-mix(in srgb, var(--muted) 42%, transparent);
  letter-spacing: 0;
}

.star-row i {
  font-style: normal;
}

.star-row i.on {
  color: #ffb020;
  text-shadow: 0 0 12px rgba(255, 176, 32, 0.38);
  animation: starPulse 0.3s ease-out;
}

.level-result {
  border: 1px solid color-mix(in srgb, var(--correct) 48%, var(--line));
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--correct) 12%, var(--surface)), var(--surface));
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 14px;
}

.level-result h2 {
  font-size: 34px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.result-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px;
  color: var(--muted);
}

.result-grid b {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
}

.compact-nav {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.mistakes-panel,
.profile-panel {
  width: min(100%, 1120px);
}

.mistake-metrics {
  grid-template-columns: repeat(4, 1fr);
}

.mistake-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-weight: 850;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: color-mix(in srgb, var(--progress) 13%, var(--surface));
  color: #087f5b;
}

.mistake-toolbar select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

.mistake-list,
.snapshot-list {
  display: grid;
  gap: 10px;
}

.mistake-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px 118px;
  gap: 14px;
  align-items: center;
}

.mistake-row.mastered {
  opacity: 0.82;
  background: color-mix(in srgb, var(--surface-soft) 54%, var(--surface));
}

.mistake-row h2 {
  margin: 4px 0;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.mistake-row p,
.mistake-row small {
  color: var(--muted);
  line-height: 1.6;
}

.mistake-count {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
  text-align: center;
}

.mistake-count b {
  display: block;
  color: var(--wrong);
  font-size: 28px;
}

.mistake-review-panel {
  border: 1px solid color-mix(in srgb, var(--cyber) 38%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--cyber) 7%, var(--surface));
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 13px;
}

.profile-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.snapshot-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.snapshot-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.snapshot-row div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.snapshot-row b,
.snapshot-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recovery-overlay {
  justify-items: center;
  align-items: center;
  padding: 18px;
}

.recovery-panel {
  width: min(860px, 100%);
  height: auto;
  max-height: min(760px, calc(100vh - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.recovery-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 14px;
  text-align: left;
  display: grid;
  gap: 7px;
}

.recovery-card:hover {
  border-color: var(--line-strong);
}

.recovery-card span {
  color: #087f5b;
  font-weight: 900;
}

.recovery-card b {
  font-size: 18px;
}

.recovery-card small {
  color: var(--muted);
  line-height: 1.5;
}

.input-line.wrong {
  animation: shakeX 0.22s ease-in-out;
}

@keyframes comboPop {
  0% {
    transform: scale(0.92);
    opacity: 0.3;
  }
  65% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes starPulse {
  0% {
    transform: translateY(2px) scale(0.8);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes shakeX {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

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

.app-shell.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px 14px 82px;
  }

  .topbar {
    height: auto;
    grid-template-columns: 1fr;
    padding: 8px 0 10px;
  }

  .top-actions {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .home-hero,
  .source-grid,
  .metric-strip,
  .completion-grid,
  .lobby-metrics,
  .mistake-metrics,
  .result-grid,
  .recovery-grid,
  .split-fields,
  .form-actions,
  .profile-actions {
    grid-template-columns: 1fr;
  }

  .home-actions,
  .step-nav,
  .compact-nav {
    grid-template-columns: 1fr;
  }

  .custom-doc-row,
  .mistake-row {
    grid-template-columns: 1fr;
  }

  .workspace {
    align-items: start;
    padding: 16px 0;
  }

  .home-title h1,
  .completion-panel h1 {
    font-size: 34px;
  }

  .target-wrap {
    min-height: 220px;
    padding: 16px;
  }

  .block-main {
    font-size: 21px;
  }

  .word-stage .block-main {
    font-size: 30px;
  }

  .hint-strip,
  .feedback {
    grid-template-columns: 1fr;
  }

  .shortcut-bar {
    display: none;
  }

  .drawer {
    width: 100vw;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 10px;
  }

  .home-title h1,
  .completion-panel h1 {
    font-size: 30px;
  }

  .source-card,
  .metric-strip span,
  .completion-grid span {
    min-height: auto;
  }

  .display-row {
    gap: 8px;
  }

  .display-block {
    min-width: min(100%, 96px);
    padding: 10px;
  }

  .input-line input {
    font-size: 18px;
  }
}
