.learn-language-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 8px 18px 4px;
  padding: 4px;
  border: 1px solid var(--line, #dbe3ea);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface, #fff) 88%, #edf4f7);
}

.learn-language-switch button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted, #667581);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.learn-language-switch button.active {
  background: var(--surface, #fff);
  color: var(--text, #13222b);
  box-shadow: 0 2px 10px rgb(31 55 66 / 10%);
}

.learn-page.chinese-learning-mode > :not(.learn-header):not(.learn-language-switch):not(.chinese-learning-root):not(.bottom-nav) {
  display: none !important;
}

main:not(.learn-page) > .learn-language-switch,
main:not(.learn-page) > .chinese-learning-root,
.learn-page:not(.chinese-learning-mode) > .chinese-learning-root {
  display: none !important;
}

.chinese-learning-root {
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 18px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chinese-learning-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.chinese-learning-intro h2 {
  margin: 0 0 5px;
  font-size: 22px;
}

.chinese-learning-intro p {
  margin: 0;
  color: var(--muted, #6c7b86);
  font-size: 13px;
}

.chinese-refresh-button,
.chinese-retry-button {
  flex: none;
  border: 1px solid var(--line, #d8e0e6);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--surface, #fff);
  color: var(--text, #20313a);
  font: inherit;
  cursor: pointer;
}

.chinese-refresh-button:disabled {
  cursor: default;
  opacity: .58;
}

.chinese-generation-notice {
  margin-bottom: 12px;
  padding: 10px 13px;
  border-radius: 10px;
  background: #fff8df;
  color: #765b00;
  font-size: 13px;
}

.chinese-generation-notice.error {
  background: #fff0f0;
  color: #9b3535;
}

.chinese-pair-list {
  display: grid;
  gap: 12px;
}

.chinese-pair-card {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 18px 14px;
  border: 1px solid var(--line, #dbe3e8);
  border-radius: 16px;
  background: var(--surface, #fff);
  box-shadow: 0 5px 18px rgb(32 54 64 / 5%);
}

.chinese-pair-card:hover,
.chinese-pair-card:focus-visible {
  border-color: #6c9c9b;
  outline: none;
}

.chinese-pair-number {
  padding-top: 3px;
  color: #8b9aa3;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chinese-pair-body {
  min-width: 0;
}

.learning-language-block {
  display: grid;
  gap: 7px;
}

.learning-english-block {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--line, #e4eaee);
}

.learning-sentence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
}

.chinese-pair-chinese {
  margin: 0;
  color: var(--text, #13242c);
  font-size: clamp(18px, 4.5vw, 23px);
  line-height: 1.72;
  letter-spacing: .02em;
}

.chinese-pair-english {
  margin: 0;
  color: var(--muted, #64747d);
  font-size: 14px;
  line-height: 1.6;
}

.learning-word {
  display: inline;
  margin: 0;
  padding: 1px 0;
  border: 0;
  border-bottom: 1px dashed transparent;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: help;
}

.learning-word:hover,
.learning-word:focus-visible {
  border-bottom-color: #3d8581;
  background: #e9f5f2;
  color: #176762;
  outline: none;
}

.sentence-speak-button {
  min-width: 64px;
  min-height: 32px;
  margin-top: 2px;
  padding: 5px 9px;
  border: 1px solid #d7e6e2;
  border-radius: 999px;
  background: #eef6f4;
  color: #286d68;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.sentence-speak-button:hover,
.sentence-speak-button:focus-visible {
  border-color: #74aaa5;
  outline: none;
}

.chinese-state-card {
  margin: 42px auto;
  padding: 42px 26px;
  border: 1px solid var(--line, #dbe3e8);
  border-radius: 18px;
  background: var(--surface, #fff);
  text-align: center;
}

.chinese-state-card h2 { margin: 12px 0 8px; font-size: 20px; }
.chinese-state-card p { margin: 0 auto 16px; max-width: 520px; color: var(--muted, #677681); line-height: 1.6; }
.chinese-state-card.error { border-color: #edc6c6; }

.chinese-spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 3px solid #dceae7;
  border-top-color: #387c78;
  border-radius: 50%;
  animation: chinese-spin .9s linear infinite;
}

@keyframes chinese-spin { to { transform: rotate(360deg); } }

.chinese-word-overlay {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(15 27 33 / 48%);
  backdrop-filter: blur(3px);
}

.chinese-word-card {
  width: min(430px, 100%);
  max-height: min(620px, 82vh);
  overflow: auto;
  border-radius: 18px;
  background: var(--surface, #fff);
  color: var(--text, #15252d);
  box-shadow: 0 22px 60px rgb(0 0 0 / 24%);
}

.chinese-word-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line, #e1e7eb);
}

.chinese-word-header strong { flex: 1; font-size: 25px; }
.chinese-word-header button { border: 0; background: transparent; font: inherit; cursor: pointer; }
.chinese-word-close { font-size: 25px !important; color: var(--muted, #71808a); }
.chinese-word-body { padding: 18px; }
.chinese-word-meta { margin: 0 0 10px; color: #2d7772; }
.chinese-word-english { margin: 6px 0; font-size: 20px; font-weight: 700; }
.chinese-word-detail { margin-top: 16px; }
.chinese-word-detail span { color: var(--muted, #71808a); font-size: 12px; }
.chinese-word-detail p { margin: 4px 0 0; line-height: 1.55; }
.chinese-word-example { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: #f3f7f6; }
.chinese-word-example p { margin: 3px 0; line-height: 1.5; }

@media (max-width: 560px) {
  .learn-language-switch { margin-inline: 14px; }
  .chinese-learning-root { padding-inline: 13px; }
  .chinese-learning-intro { align-items: flex-start; }
  .chinese-pair-card { grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 15px 10px; }
  .learning-sentence-row { gap: 6px; }
  .sentence-speak-button { min-width: 56px; padding-inline: 7px; }
}
