* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  background: #fdf8ef;
  color: #3a2f22;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- header + tabs ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fdf8efee;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #eadfc9;
  padding: 10px 16px 8px;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-sub {
  margin-left: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #a08c67;
  letter-spacing: 0.04em;
}

.pinyin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: #6b5433;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.pinyin-toggle input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: #2f6f4f;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
}

.tab {
  border: 1.5px solid #d8c7a5;
  background: #fff;
  color: #6b5433;
  font: inherit;
  font-size: 0.95rem;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: #2f6f4f;
  border-color: #2f6f4f;
  color: #fff;
  font-weight: 600;
}

.tab.soon {
  border-style: dashed;
  color: #b7a687;
  cursor: default;
}

/* ---------- lesson ---------- */
.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 45vh; /* room so the bottom panel never hides the text */
}

.lesson-title {
  font-size: 1.5rem;
  margin: 4px 0 2px;
}

.lesson-subtitle {
  margin: 0 0 12px;
  color: #a08c67;
  font-size: 0.9rem;
}

.para {
  margin-bottom: 28px;
}

/* Paragraph illustrations */
.para-art {
  margin: 0 0 14px;
  overflow: hidden;
  border-radius: 16px;
  background: #faf3e3;
  border: 1px solid #e1d4bd;
  text-align: center;
  box-shadow: 0 5px 18px #80683218;
}

.para-art-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.para-art-icon {
  display: block;
  padding: 26px 16px 0;
  font-size: 2rem;
}

.para-art-caption {
  padding: 9px 13px 10px;
  font-weight: 600;
  color: #6b5433;
  background: #fffdf8;
}

.para-art-note {
  padding: 2px 16px 26px;
  font-size: 0.8rem;
  color: #b7a687;
}

/* verses */
.verse {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0;
}

.verse-play {
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px;
  flex: none;
}

.verse-num {
  flex: none;
  min-width: 1.6em;
  text-align: right;
  color: #b7a687;
  font-size: 0.85rem;
  font-weight: 600;
}

.verse-text {
  font-size: 1.55rem;
  line-height: 2.1;
}

.word {
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1.12;
  margin: 0.18em 0;
  padding: 0.03em 0.1em;
  border-radius: 0.3em;
}

.word:hover { background: #f3e7c9; }

.word-pinyin {
  display: none;
  min-height: 1.05em;
  color: #2f6f4f;
  font-size: 0.48em;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}

body.show-pinyin .word-pinyin { display: block; }

.word.highlighted {
  background: #ffe69b;
  box-shadow: inset 0 -0.18em 0 #f4c952;
}

.word.selected {
  background: #ffd977;
  box-shadow: 0 0 0 2px #eab94d;
}

.punct { color: #8f7c5c; }

/* ---------- word panel (bottom sheet) ---------- */
.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 760px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(70, 50, 10, 0.18);
  padding: 18px 20px 26px;
  transform: translateY(110%);
  transition: transform 0.22s ease;
  z-index: 20;
}

.panel.open { transform: translateY(0); }

.panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: #f3ecdd;
  color: #6b5433;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

.panel-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-right: 40px;
}

.panel-word {
  font-size: 2.2rem;
  font-weight: 700;
}

.panel-pinyin {
  font-size: 1.2rem;
  color: #2f6f4f;
  font-weight: 600;
}

.say {
  border: 1.5px solid #2f6f4f;
  background: #eaf4ee;
  color: #2f6f4f;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.say:active { background: #2f6f4f; color: #fff; }

.panel-buttons { display: flex; gap: 8px; }

.mark-action {
  border: 1.5px solid #c98a2e;
  background: #fff4d7;
  color: #835019;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.mark-action:active { background: #f2c65c; }

.panel-meaning {
  margin: 10px 0 4px;
  font-size: 1.05rem;
  font-weight: 600;
}

.panel-usage {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #6b5433;
  line-height: 1.5;
}

.panel-sentence-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-top: 1px solid #f0e8d5;
  padding-top: 10px;
}

.sentence-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: none;
}

.sentence-buttons .say { white-space: nowrap; }

.panel-sentence {
  font-size: 1.15rem;
  line-height: 1.8;
}

.panel-sentence mark {
  background: #ffd977;
  border-radius: 0.25em;
  padding: 0 0.08em;
}

@media (max-width: 480px) {
  .verse-text { font-size: 1.35rem; }
  .panel-word { font-size: 1.9rem; }
}
