:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-2: #f7f7f9;
  --line: #d9d9df;
  --line-soft: #ececf0;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --blue: #007aff;
  --blue-soft: #e8f2ff;
  --danger: #ff3b30;
  --ok: #34c759;
  --pending: #c7c7cc;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #f4f4f6;
  color: var(--text);
  border-radius: 12px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.sidebar,
.practice {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 24px;
  overflow: auto;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(145deg, #007aff, #5ac8fa);
  font-size: 24px;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p,
.muted,
.tip,
.result-text,
.stats-box {
  color: var(--muted);
}

.panel {
  padding: 0 0 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line-soft);
}

.panel:last-child {
  border-bottom: 0;
}

.panel h2,
.section-row {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 800;
}

.section-row {
  display: flex;
  justify-content: space-between;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.book-grid button {
  min-height: 44px;
  padding: 0;
}

.book-grid button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

.radio-line,
.check-line,
.slider-row,
.category-controls {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  color: var(--text);
}

.radio-line,
.check-line {
  grid-template-columns: 22px 1fr;
  align-items: center;
  font-weight: 700;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

select {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

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

.stats-box {
  margin-top: 8px;
  padding: 14px;
  border-radius: 14px;
  background: var(--panel-2);
  line-height: 1.7;
  font-size: 14px;
}

.practice {
  padding: 34px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

#progressBar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.25s ease;
}

#progressText {
  min-width: 70px;
  text-align: right;
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
}

.card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 18px;
  padding: 28px 0;
}

.badge {
  min-width: 150px;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 800;
}

#meaningText {
  max-width: min(100%, 960px);
  font-size: clamp(34px, 5vw, 68px);
  line-height: 1.18;
  letter-spacing: 0;
}

#phoneticText {
  min-height: 42px;
  color: var(--blue);
  font-size: clamp(24px, 3vw, 40px);
  font-weight: 800;
}

#noteText {
  max-width: 860px;
  min-height: 24px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 17px;
}

.answer-card {
  position: relative;
  width: min(100%, 980px);
  min-height: 132px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel-2);
  overflow: hidden;
}

.answer-display {
  width: 100%;
  padding: 28px 38px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 15px;
  font-size: clamp(36px, 5.2vw, 76px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
}

.letter {
  min-width: 0.66em;
  color: var(--pending);
}

.letter.typed {
  color: var(--blue);
}

.letter.hint {
  color: var(--danger);
  text-decoration: underline;
  text-underline-offset: 8px;
}

.letter.space {
  min-width: 0.8em;
}

#answerInput {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.01;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}

.tip {
  font-size: 17px;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 14px;
  width: min(100%, 760px);
}

.result-text {
  text-align: center;
  min-height: 24px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .sidebar {
    display: block;
    max-height: none;
  }

  .practice {
    min-height: 620px;
    padding: 20px;
  }
}

@media (max-width: 680px) {
  .brand h1 {
    font-size: 24px;
  }

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

  .button-row {
    grid-template-columns: 1fr;
  }

  .answer-card {
    min-height: 110px;
  }
}
