:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --text: #1d2522;
  --muted: #68736f;
  --line: #dbe4df;
  --primary: #13795b;
  --primary-dark: #0b5f47;
  --accent: #c94836;
  --warn: #b98210;
  --ok-bg: #daf1e5;
  --bad-bg: #ffe2dd;
  --current-bg: #fff1bd;
  --shadow: 0 18px 50px rgba(29, 37, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(231, 180, 71, 0.85);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: #16231f;
  color: #f5fbf8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #e7b447;
  color: #16231f;
  font-size: 25px;
  font-weight: 800;
}

.brand h1,
.brand p,
.panel h2,
.workspace h2,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 24px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: #a7b8b0;
  font-size: 13px;
}

.panel {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 15px;
}

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

.lesson-item,
.primary-button,
.secondary-button,
.file-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.lesson-item {
  width: 100%;
  padding: 11px 12px;
  background: transparent;
  color: #dce9e4;
  text-align: left;
}

.lesson-item:hover,
.lesson-item.active {
  background: rgba(255, 255, 255, 0.12);
}

.lesson-item strong {
  display: block;
  font-size: 14px;
}

.lesson-item span {
  display: block;
  margin-top: 3px;
  color: #a7b8b0;
  font-size: 12px;
}

.file-button {
  display: block;
  margin-bottom: 10px;
  padding: 11px 12px;
  background: #f5fbf8;
  color: #16231f;
  text-align: center;
  font-weight: 700;
}

.file-button input {
  display: none;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
}

#customText {
  margin-bottom: 10px;
  padding: 10px;
  background: #f5fbf8;
  color: var(--text);
}

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

.primary-button {
  width: 100%;
  padding: 11px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #f5fbf8;
  font-weight: 700;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.hint {
  margin: 10px 0 0;
  color: #a7b8b0;
  font-size: 12px;
  line-height: 1.5;
}

.compact {
  display: grid;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dce9e4;
  font-size: 14px;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.workspace h2 {
  margin-top: 4px;
  font-size: 24px;
}

.actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 0 var(--line);
  font-size: 19px;
  font-weight: 800;
}

.icon-button:hover {
  background: var(--surface-2);
}

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

.stat {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(29, 37, 34, 0.04);
}

.stat span,
.stat small {
  display: block;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.stat small {
  margin-top: 8px;
  font-size: 12px;
}

.practice-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.progress-bar {
  height: 8px;
  background: var(--surface-2);
}

.progress-bar div {
  width: 0%;
  height: 100%;
  background: var(--primary);
  transition: width 120ms ease;
}

.text-display {
  min-height: 280px;
  max-height: 42vh;
  overflow: auto;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  font-size: 22px;
  line-height: 1.95;
  white-space: pre-wrap;
  word-break: break-word;
}

.char {
  border-radius: 4px;
  padding: 1px 0;
}

.char.correct {
  background: var(--ok-bg);
  color: var(--primary-dark);
}

.char.incorrect {
  background: var(--bad-bg);
  color: var(--accent);
}

.char.current {
  background: var(--current-bg);
  box-shadow: inset 0 -2px 0 var(--warn);
}

.typing-input {
  display: block;
  min-height: 150px;
  padding: 20px 24px;
  border: 0;
  border-radius: 0;
  background: #fbfdfc;
  color: var(--text);
  font-size: 21px;
  line-height: 1.75;
}

.typing-input:focus {
  box-shadow: inset 0 0 0 3px rgba(19, 121, 91, 0.22);
}

.typing-input.paused {
  background: #eef0ef;
}

.status-line {
  min-height: 40px;
  padding: 10px 24px;
  border-top: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--muted);
  font-size: 13px;
}

.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.result[hidden] {
  display: none;
}

.result-data {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.result-data span {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .topbar,
  .result {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .text-display,
  .typing-input {
    padding: 16px;
    font-size: 18px;
  }

  .status-line {
    padding: 10px 16px;
  }
}
