.speaking-main,
.topic-main {
  --sp-ink: #1a1916;
  --sp-text: #2c2a26;
  --sp-muted: #6f6b64;
  --sp-faint: #9a958c;
  --sp-line: #e4dfd6;
  --sp-line-strong: #cfc8bc;
  --sp-surface: #fffcf7;
  --sp-sunken: #f3efe8;
  --sp-accent: #1a1916;
  --sp-accent-soft: #efeae2;
  --sp-paper: #f4f1ec;
  --topic-color: #1a1916;
}
body:has(.speaking-main),
body:has(.topic-main) {
  background: #f4f1ec;
}

/* Speaking topic library index (v3) */

.speaking-main { max-width: 1200px; }

/* Speaking phrase and sentence-pattern curriculum. */
.daily-curriculum { margin: 0 0 40px; }
.daily-curriculum-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 0 16px; }
.daily-curriculum-head h1 { margin: 0; color: #1a1916; font-size: clamp(21px, 2.4vw, 27px); letter-spacing: -.025em; }
.daily-curriculum-head p { max-width: 650px; margin: 6px 0 0; color: #6f6b64; font-size: 13px; line-height: 1.65; }
.daily-curriculum-total { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #e4dfd6; border-radius: 999px; background: #fffcf7; color: #6f6b64; font-size: 12px; font-weight: 650; }
.daily-curriculum-tools { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 280px); gap: 14px; align-items: start; margin-bottom: 10px; }
.daily-topic-filters { display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 7px; scrollbar-width: thin; }
.daily-topic-filter { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 7px; min-height: 35px; padding: 7px 11px; border: 1px solid #e4dfd6; border-radius: 999px; background: #fffcf7; color: #6f6b64; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; transition: background .16s, border-color .16s, color .16s, transform .16s; }
.daily-topic-filter span { color: #9a958c; font-size: 10px; font-variant-numeric: tabular-nums; }
.daily-topic-filter:hover { border-color: #cfc8bc; color: #1a1916; }
.daily-topic-filter:active { transform: scale(.98); }
.daily-topic-filter.is-active { border-color: #cfc8bc; background: #f3efe8; color: #1a1916; }
.daily-topic-filter:focus-visible, .daily-topic-search:focus-within { outline: 3px solid rgba(26,25,22,.15); outline-offset: 2px; }
.daily-topic-search { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 11px; border: 1px solid #e4dfd6; border-radius: 10px; background: #fffcf7; color: #9a958c; }
.daily-topic-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: #1a1916; font: inherit; font-size: 12px; }
.daily-topic-search input::placeholder { color: #9a958c; }
.daily-topic-search input::-webkit-search-cancel-button { cursor: pointer; }
.daily-topic-groups { display: grid; gap: 22px; }
.daily-topic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.daily-topic-card { display: flex; flex-direction: column; min-width: 0; min-height: 164px; padding: 13px 14px 11px; border: 1px solid #e4dfd6; border-radius: 15px; background: #fffcf7; color: inherit; text-decoration: none; box-shadow: 0 2px 7px rgba(26, 25, 22, .04); transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.daily-topic-card:hover { transform: translateY(-2px); border-color: #cfc8bc; box-shadow: 0 9px 21px rgba(26, 25, 22, .06); }
.daily-topic-card:active { transform: translateY(0) scale(.99); }
.daily-topic-card:focus-visible { outline: 3px solid rgba(26,25,22,.22); outline-offset: 2px; }
.daily-topic-card[hidden] { display: none; }
.daily-topic-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.daily-topic-day { color: #1a1916; font-size: 10px; font-weight: 750; letter-spacing: .07em; font-variant-numeric: tabular-nums; }
.daily-topic-category { max-width: 55%; overflow: hidden; padding: 3px 7px; border-radius: 999px; background: #f3efe8; color: #6f6b64; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.daily-topic-card h3 { margin: 11px 0 5px; color: #1a1916; font-size: 15px; line-height: 1.4; }
.daily-topic-focus { display: -webkit-box; overflow: hidden; margin: 0; color: #6f6b64; font-size: 11.5px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.daily-topic-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 12px; color: #9a958c; font-size: 10.5px; }
.daily-topic-arrow { color: #1a1916; font-size: 15px; line-height: 1; }
.daily-topic-empty { margin: 4px 0 12px; padding: 20px; border: 1px dashed #cfc8bc; border-radius: 13px; color: #6f6b64; font-size: 13px; text-align: center; }
.daily-curriculum .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
@media (max-width: 1000px) {
  .daily-topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .daily-curriculum-tools { grid-template-columns: 1fr; gap: 7px; }
  .daily-topic-search { max-width: 460px; }
}
@media (max-width: 600px) {
  .daily-curriculum { margin-bottom: 30px; }
  .daily-curriculum-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .daily-curriculum-head p { font-size: 12px; }
  .daily-topic-grid { grid-template-columns: 1fr; gap: 8px; }
  .daily-topic-card { min-height: 145px; padding: 12px 13px 10px; }
  .daily-topic-card h3 { margin-top: 8px; }
  .daily-topic-filters { margin-right: -4px; }
}
@media (prefers-reduced-motion: reduce) {
  .daily-topic-filter, .daily-topic-card { transition: none; }
}

/* ---------- Search ---------- */
.search-row { margin-bottom: 20px; }
.search-box {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: #fffcf7;
  border: 1.5px solid #e4dfd6;
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 640px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within {
  border-color: #1a1916;
  box-shadow: 0 0 0 3px rgba(26,25,22,0.08);
}
.search-box svg { color: #9a958c; flex-shrink: 0; }
#searchInput {
  flex: 1; border: none; outline: none;
  font-family: inherit; font-size: 14px;
  color: #1a1916; background: transparent;
}
#searchInput::placeholder { color: #9a958c; }
.search-clear {
  background: #f3efe8;
  border: none; width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 14px; font-weight: 700; color: #6f6b64;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
}
.search-clear:hover { background: #e2e8f0; color: #1a1916; }

/* ---------- Global search results ---------- */
.global-search-results {
  background: #fffcf7;
  border-radius: 14px;
  padding: 16px 18px;
  border: 1px solid #f3efe8;
  margin-bottom: 20px;
}
.gsr-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.gsr-title { font-size: 15px; font-weight: 700; color: #1a1916; }
.gsr-count { font-size: 12px; color: #9a958c; font-weight: 500; margin-left: 8px; }
.gsr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.gsr-item {
  display: flex; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: #f3efe8;
  text-decoration: none; color: inherit;
  transition: all 0.15s; border: 1px solid transparent;
}
.gsr-item:hover { background: #fffcf7; border-color: #cfc8bc; transform: translateY(-1px); }
.gsr-emoji {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 18px; flex-shrink: 0;
  background: #f3efe8;
}
.gsr-body { flex: 1; min-width: 0; }
.gsr-en { font-size: 13.5px; font-weight: 600; color: #1a1916; line-height: 1.5; }
.gsr-cn { font-size: 12px; color: #6f6b64; line-height: 1.5; margin-top: 2px; }
.gsr-where { font-size: 10.5px; color: #9a958c; margin-top: 4px; }
.gsr-type {
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  margin-right: 4px;
}
.gsr-type.type-vocab { background: #f3efe8; color: #1a1916; }
.gsr-type.type-phrase { background: #fef3c7; color: #92400e; }
.gsr-type.type-pattern { background: #f0fdf4; color: #15803d; }
.gsr-more { padding: 10px; text-align: center; color: #9a958c; font-size: 12px; grid-column: 1 / -1; }
mark { background: #fef08a; color: #713f12; padding: 0 2px; border-radius: 3px; }

/* ---------- Topics grid ---------- */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.topic-card {
  background: #fffcf7;
  border-radius: 14px;
  padding: 16px 18px;
  border: 1px solid #f3efe8;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.topic-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--topic-color, #1a1916);
  opacity: 0.6;
}
.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(15,23,42,0.08);
  border-color: var(--topic-color, #cfc8bc);
}
.topic-card:hover::before { opacity: 1; height: 5px; }

.tc-head {
  display: flex; align-items: center; gap: 12px;
}
.tc-emoji {
  font-size: 28px;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
  background: #f3efe8;
}
.tc-meta { flex: 1; min-width: 0; }
.tc-name-cn { font-size: 16px; font-weight: 700; color: #1a1916; }
.tc-name-en { font-size: 12px; color: #9a958c; font-weight: 500; margin-top: 2px; letter-spacing: 0.3px; }
.tc-level {
  font-size: 11px; font-weight: 700;
  background: #d1fae5; color: #047857;
  padding: 2px 8px; border-radius: 999px;
  flex-shrink: 0;
}
.tc-desc {
  font-size: 13px; color: #6f6b64; line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tc-progress { margin-top: auto; }
.tc-progress-bar {
  height: 6px; background: #f3efe8;
  border-radius: 999px; overflow: hidden;
  margin-bottom: 4px;
}
.tc-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
  background: #1a1916;
}
.tc-progress-text {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: #6f6b64;
  font-variant-numeric: tabular-nums;
}
.tc-progress-text b { color: #1a1916; font-weight: 700; }
.tc-progress-pct { font-weight: 600; color: var(--topic-color, #1a1916); }

@media (max-width: 600px) {
  .topics-grid { grid-template-columns: 1fr; }
  .gsr-list { grid-template-columns: 1fr; }
}

/* ---------- Toast (shared) ---------- */
.toast-pop {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1916; color: #ffffff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(15,23,42,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s ease;
  z-index: 3000;
}
.toast-pop.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
