:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f4ef;
  color: #172029;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f6f4ef; }
button { cursor: pointer; font: inherit; }
p, h1, h2 { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px clamp(14px, 4vw, 38px);
  border-bottom: 1px solid rgba(23, 32, 41, 0.1);
  background: rgba(252, 250, 246, 0.94);
  backdrop-filter: blur(14px);
}

.home-button {
  width: 42px;
  height: 42px;
  border: 1px solid #c5d8d5;
  border-radius: 999px;
  color: #21504d;
  background: #eef8f6;
  font-size: 24px;
}

.eyebrow { color: #59706f; font-size: 13px; font-weight: 750; }
h1 { margin-top: 4px; font-size: clamp(22px, 4vw, 34px); line-height: 1.12; }
h2 { margin-top: 4px; font-size: clamp(25px, 4.8vw, 42px); line-height: 1.08; }

.count {
  border: 1px solid #c5d8d5;
  border-radius: 999px;
  padding: 8px 12px;
  color: #21504d;
  background: #eef8f6;
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
}

main { width: min(1160px, 100%); margin: 0 auto; padding: 18px clamp(14px, 3vw, 28px) 44px; }

.home-summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid rgba(23, 32, 41, 0.1);
  border-radius: 8px;
  background: #fffdf8;
}

#summaryText { max-width: 420px; color: #59646d; font-size: 15px; line-height: 1.5; }
.unit-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.unit-card {
  display: grid;
  gap: 8px;
  min-height: 108px;
  border: 1px solid rgba(23, 32, 41, 0.1);
  border-radius: 8px;
  padding: 16px;
  color: #172029;
  background: #fff;
  text-align: left;
  box-shadow: 0 8px 24px rgba(23, 32, 41, 0.06);
}
.unit-card:hover { border-color: #216b64; box-shadow: 0 10px 28px rgba(33, 107, 100, 0.16); }
.unit-title { font-size: 24px; font-weight: 850; line-height: 1.1; }
.unit-meta { color: #6b5b47; font-size: 14px; font-weight: 700; }

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(23, 32, 41, 0.1);
  border-radius: 8px;
  background: #fffdf8;
}

.search-box { display: grid; gap: 6px; color: #5b6670; font-size: 13px; font-weight: 750; }
input[type="search"] {
  width: 100%;
  height: 42px;
  border: 1px solid #d9d5cb;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #172029;
  font-size: 16px;
}

.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.button-row button {
  height: 42px;
  border: 1px solid #c7c1b6;
  border-radius: 8px;
  padding: 0 13px;
  color: #172029;
  background: #fff;
  font-weight: 750;
}
.button-row button:hover, .button-row button[aria-pressed="true"] {
  border-color: #216b64;
  color: #0f4f49;
  background: #eef8f6;
}

.button-row button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.blind-test {
  margin-bottom: 16px;
  border: 1px solid rgba(23, 32, 41, 0.1);
  border-radius: 8px;
  background: #fffdf8;
  box-shadow: 0 8px 24px rgba(23, 32, 41, 0.06);
  overflow: hidden;
}

.blind-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid rgba(23, 32, 41, 0.08);
}

.blind-head h2 { font-size: clamp(22px, 4vw, 32px); }
.blind-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.blind-actions button,
.blind-buttons button {
  min-height: 42px;
  border: 1px solid #c7c1b6;
  border-radius: 8px;
  padding: 0 14px;
  color: #172029;
  background: #fff;
  font-weight: 800;
}

.blind-actions button:hover,
.blind-buttons button:hover {
  border-color: #216b64;
  color: #0f4f49;
  background: #eef8f6;
}

.blind-card {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: clamp(18px, 4vw, 34px);
  text-align: center;
}

.blind-progress {
  color: #6b5b47;
  font-size: 15px;
  font-weight: 850;
}

.blind-play {
  min-width: min(100%, 280px);
  min-height: 68px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #216b64;
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(33, 107, 100, 0.22);
}

.blind-play:hover { background: #185a54; }

.blind-answer {
  width: min(100%, 580px);
  border: 1px solid #c5d8d5;
  border-radius: 8px;
  padding: 16px;
  background: #eef8f6;
  text-align: left;
}

.blind-word {
  color: #172029;
  font-size: clamp(28px, 7vw, 46px);
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.blind-phonetic { margin-top: 6px; color: #607078; font-size: 16px; }
.blind-meaning { margin-top: 12px; color: #21302f; font-size: 18px; font-weight: 800; line-height: 1.45; }
.blind-expansion { margin-top: 8px; color: #4e6b5f; font-size: 15px; line-height: 1.45; }
.blind-hint { max-width: 560px; color: #6b5b47; font-size: 15px; line-height: 1.55; }
.blind-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.blind-buttons button:first-child {
  border-color: #216b64;
  color: #0f4f49;
  background: #eef8f6;
}

.word-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.word-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  min-height: 190px;
  padding: 14px;
  border: 1px solid rgba(23, 32, 41, 0.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 32, 41, 0.06);
}
.word-card.is-playing { border-color: #216b64; box-shadow: 0 10px 28px rgba(33, 107, 100, 0.18); }
.play-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #216b64;
  font-size: 16px;
}

.word-main { min-width: 0; }
.word-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.word-no { color: #7c6f5d; font-size: 13px; font-weight: 800; }
.word-text {
  min-width: 0;
  border: 0;
  padding: 0;
  color: #172029;
  background: transparent;
  font-size: 25px;
  font-weight: 850;
  line-height: 1.1;
  text-align: left;
  overflow-wrap: anywhere;
}
.phonetic { margin-top: 5px; color: #6b7780; font-size: 15px; }
.meaning { margin-top: 10px; color: #21302f; font-size: 16px; font-weight: 720; line-height: 1.45; }
.example { margin-top: 12px; color: #34404a; font-size: 15px; line-height: 1.45; }
.translation, .expansion {
  margin-top: 5px;
  color: #6b5b47;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
}
.expansion { color: #4e6b5f; }
.audio-status { min-height: 18px; margin-top: 8px; color: #9b3d2f; font-size: 13px; font-weight: 750; }
body.hide-chinese .chinese { display: none; }
.empty-state {
  grid-column: 1 / -1;
  padding: 38px 18px;
  border: 1px dashed #c7c1b6;
  border-radius: 8px;
  color: #6b5b47;
  background: #fffdf8;
  text-align: center;
}

@media (max-width: 900px) { .unit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .topbar { grid-template-columns: 42px minmax(0, 1fr); }
  .count { grid-column: 2; width: fit-content; }
  .home-summary { display: grid; align-items: start; }
  .controls { grid-template-columns: 1fr; }
  .blind-head { display: grid; align-items: start; }
  .blind-actions { justify-content: flex-start; }
  .unit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-grid { grid-template-columns: 1fr; }
  .word-card { min-height: 0; }
  .word-text { font-size: 23px; }
}
@media (max-width: 430px) { .unit-grid { grid-template-columns: 1fr; } }
