:root {
  color-scheme: light;
  --brand: #d31145;
  --brand-bg: #fff1f4;
  --brand-line: rgba(211, 17, 69, 0.18);
  --purple: #4c4794;
  --purple-bg: #f3f2fb;
  --blue: #1f78ad;
  --blue-bg: #edf7fc;
  --text: #1f1f1f;
  --sub: #595959;
  --muted: #8c8c8c;
  --line: rgba(5, 5, 5, 0.08);
  --bg: #f5f5f5;
  --card: #fff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 0 1px var(--line);
}

.catalog-page {
  min-height: 100vh;
  background: #fff;
  padding-bottom: 28px;
}

.catalog-header {
  min-height: 64px;
  padding: 12px 16px 10px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.course-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
}

.catalog-header h1 {
  margin: 0;
  text-align: center;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.catalog-back,
.catalog-folder,
.catalog-sort {
  border: 0;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.catalog-back {
  width: 36px;
  height: 36px;
  margin-left: -8px;
}

.catalog-back svg {
  width: 22px;
  height: 22px;
  stroke-width: 3;
  transform: rotate(180deg);
}

.catalog-folder {
  gap: 5px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.catalog-folder svg {
  width: 18px;
  height: 18px;
}

.catalog-search-row {
  padding: 18px 16px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
}

.catalog-search {
  height: 42px;
  min-width: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: #f7f7f7;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.catalog-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.catalog-search input::placeholder {
  color: #bfbfbf;
}

.catalog-sort {
  width: 36px;
  height: 36px;
  color: var(--brand);
  font-size: 24px;
  line-height: 1;
}

.catalog-tabs {
  padding: 0 16px 20px;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.catalog-tabs::-webkit-scrollbar {
  display: none;
}

.catalog-tabs button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  min-height: 38px;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.catalog-tabs button.active {
  color: #fff;
  background: var(--brand);
}

.catalog-list {
  padding: 6px 16px 0;
  display: grid;
  gap: 22px;
}

.catalog-item {
  width: 100%;
  display: grid;
  gap: 10px;
}

.catalog-main {
  width: 100%;
  border: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  text-align: left;
  background: transparent;
}

.catalog-cover {
  width: 108px;
  height: 108px;
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 14px;
  background: var(--brand-bg);
  box-shadow: inset 0 0 0 1px var(--line);
}

.catalog-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.catalog-cover em {
  position: absolute;
  top: 0;
  left: 0;
  padding: 3px 7px 4px;
  border-radius: 0 0 9px 0;
  background: rgba(255, 241, 244, 0.94);
  color: rgba(211, 17, 69, 0.68);
  font-size: 13px;
  line-height: 1.2;
  font-style: normal;
  font-weight: 600;
}

.catalog-copy {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.catalog-copy strong {
  min-width: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
}

.catalog-copy span {
  color: #707070;
  font-size: 16px;
  line-height: 1.2;
}

.catalog-item.active .catalog-cover {
  box-shadow: 0 0 0 2px rgba(211, 17, 69, 0.16);
}

.catalog-progress {
  margin-left: 132px;
  display: grid;
  gap: 8px;
}

.catalog-progress-btn {
  width: 100%;
  border: 0;
  padding: 0;
  display: grid;
  gap: 5px;
  text-align: left;
  background: transparent;
}

.progress-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.progress-title strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
}

.progress-title em {
  color: var(--brand);
  font-size: 13px;
  line-height: 1.2;
  font-style: normal;
  font-weight: 800;
}

.progress-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0f0f0;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #f06286);
}

.progress-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.progress-detail {
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 1px solid var(--brand-line);
  border-radius: 10px;
  background: var(--brand-bg);
}

.progress-detail div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.progress-detail strong {
  color: var(--brand);
  font-size: 12px;
  line-height: 1.2;
}

.progress-detail span {
  color: var(--sub);
  font-size: 11px;
  line-height: 1.35;
}

.progress-detail span.done {
  color: var(--text);
  font-weight: 600;
}

.topbar {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  min-width: 0;
}

.topbar-title span,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.topbar-title strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-action {
  border: 0;
  background: transparent;
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.segmented {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.segmented button {
  border: 0;
  border-radius: 8px;
  min-height: 34px;
  background: transparent;
  color: var(--sub);
  font-size: 14px;
  font-weight: 600;
}

.segmented button.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 2px 10px rgba(211, 17, 69, 0.14);
  border: 1px solid var(--brand-line);
}

.study-backbar {
  padding: 10px 12px 0;
}

.study-backbar .text-action svg {
  transform: rotate(180deg);
}

.content {
  padding: 12px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.course-brief,
.chapter-summary,
.audio-block,
.chapter-card,
.slide-section,
.term-card {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.course-brief,
.chapter-summary,
.slide-section {
  padding: 14px;
}

.course-brief {
  padding-bottom: 12px;
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.course-brief::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.82)),
    linear-gradient(135deg, rgba(211, 17, 69, 0.16), rgba(255, 255, 255, 0.7));
}

.course-brief > * {
  position: relative;
  z-index: 1;
}

.course-source-link {
  padding-top: 2px;
}

.section-head,
.slide-head,
.chapter-card-head,
.audio-title-row,
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

h1 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.35;
}

h3 {
  font-size: 15px;
  line-height: 1.4;
}

p {
  color: var(--sub);
  font-size: 13px;
  line-height: 1.65;
}

.course-brief p,
.chapter-summary p {
  margin-top: 10px;
}

.course-brief p {
  margin-top: 8px;
}

.chapter-summary p {
  margin-top: 8px;
}

.course-meta-line {
  margin-top: 10px;
}

.goal {
  color: var(--text);
  font-weight: 600;
  margin-top: 6px;
  display: block;
}

.tag-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag,
.checkable-tag {
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  color: var(--sub);
  background: #fafafa;
}

.tag-red {
  color: var(--brand);
  border-color: var(--brand-line);
  background: var(--brand-bg);
}

.tag-purple {
  color: var(--purple);
  border-color: rgba(76, 71, 148, 0.18);
  background: var(--purple-bg);
}

.tag-blue {
  color: var(--blue);
  border-color: rgba(31, 120, 173, 0.18);
  background: var(--blue-bg);
}

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

.chapter-list {
  display: grid;
  gap: 10px;
}

.chapter-card {
  padding: 12px;
}

.chapter-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: flex-start;
  justify-content: stretch;
}

.chapter-title-block {
  min-width: 0;
}

.chapter-index {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--brand-bg);
  border: 1px solid var(--brand-line);
  font-size: 13px;
  font-weight: 700;
}

.chapter-card p {
  margin-top: 10px;
}

.key-page-details {
  margin-top: 10px;
}

.key-page-details summary {
  width: fit-content;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.key-page-details summary span {
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--blue);
  background: var(--blue-bg);
  border: 1px solid rgba(31, 120, 173, 0.18);
  font-size: 12px;
  font-weight: 700;
}

.key-page-details summary::-webkit-details-marker {
  display: none;
}

.key-page-details summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.16s ease;
}

.key-page-details[open] summary::after {
  transform: rotate(225deg) translateY(-1px);
}

.key-page-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.key-page {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafafa;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  text-align: left;
  align-items: center;
}

.key-page span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.key-page strong {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.primary-btn,
.secondary-btn {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

.primary-btn {
  color: #fff;
  background: var(--brand);
}

.secondary-btn {
  margin-top: 0;
  width: 100%;
  color: var(--brand);
  background: var(--brand-bg);
  border: 1px solid var(--brand-line);
}

.chapter-enter-btn {
  border: 1px solid var(--brand-line);
  border-radius: 8px;
  min-height: 30px;
  padding: 5px 9px;
  background: var(--brand-bg);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chapter-enter-btn svg {
  width: 14px;
  height: 14px;
}

.audio-block {
  padding: 12px;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
}

.audio-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--brand-bg);
  border: 1px solid var(--brand-line);
}

.audio-main {
  min-width: 0;
}

.audio-duration {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.audio-block h3 {
  margin-top: 8px;
  font-size: 17px;
}

.audio-block p {
  margin-top: 4px;
}

.audio-actions {
  margin-top: 10px;
}

.audio-block audio {
  width: 100%;
  height: 36px;
  margin-top: 8px;
  accent-color: var(--brand);
}

.audio-block-compact {
  padding: 10px 12px;
}

.overview-audio-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.overview-audio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.overview-audio-head h3 {
  font-size: 15px;
  line-height: 1.35;
}

.overview-audio-head span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--brand);
  background: var(--brand-bg);
  border: 1px solid var(--brand-line);
  font-size: 12px;
  font-weight: 700;
}

.overview-audio-panel audio {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 34px;
  margin-top: 8px;
  accent-color: var(--brand);
}

.chapter-tabs {
  position: sticky;
  top: 51px;
  z-index: 4;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: rgba(245, 245, 245, 0.94);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.chapter-tabs::-webkit-scrollbar,
.slide-strip::-webkit-scrollbar {
  display: none;
}

.checkable-tag {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
}

.checkable-tag.active {
  color: var(--brand);
  border-color: var(--brand-line);
  background: var(--brand-bg);
}

.slide-head {
  align-items: center;
  min-width: 0;
}

.slide-head > div {
  min-width: 0;
}

.term-panel {
  margin: 12px 0;
  width: 100%;
  border: 1px solid var(--brand-line);
  border-radius: 10px;
  background: var(--brand-bg);
  color: var(--brand);
  padding: 10px;
}

.term-panel-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.term-panel-head strong {
  font-size: 14px;
}

.term-chip-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.term-chip {
  min-height: 26px;
  border: 1px solid var(--brand-line);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

.slide-image {
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fafafa;
}

.slide-image img {
  display: block;
  width: 100%;
  max-width: 100%;
}

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

.slide-thumb {
  flex: 0 0 92px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  text-align: left;
}

.slide-thumb.active {
  border-color: var(--brand);
  background: var(--brand-bg);
}

.slide-thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.slide-thumb span {
  display: block;
  margin-top: 5px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 600;
}

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.38);
}

.bottom-sheet {
  position: relative;
  width: min(100%, 430px);
  max-height: 72vh;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 14px 12px 18px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
}

.term-list {
  margin-top: 12px;
  max-height: calc(72vh - 82px);
  overflow-y: auto;
  display: grid;
  gap: 10px;
}

.term-card {
  padding: 12px;
  box-shadow: none;
}

.term-card.focused {
  border-color: var(--brand-line);
  background: var(--brand-bg);
}

.term-card p {
  margin-top: 6px;
}

.source-list {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-pill {
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--blue);
  border: 1px solid rgba(31, 120, 173, 0.18);
  background: var(--blue-bg);
  font-size: 11px;
  line-height: 1.5;
}

.loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

@media (min-width: 700px) {
  body {
    padding: 18px 0;
  }

  .app-shell {
    min-height: calc(100vh - 36px);
    border-radius: 18px;
    overflow: hidden;
  }
}
