:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #171820;
  background: #f7f8fc;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --blue: #3949f5;
}

* { box-sizing: border-box; }

body { min-width: 320px; min-height: 100vh; margin: 0; background: #f7f8fc; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(50px, env(safe-area-inset-top)) 24px calc(100px + env(safe-area-inset-bottom));
}

.topbar { display: flex; min-height: 48px; align-items: center; justify-content: space-between; }
.brand { font-size: 20px; font-weight: 850; letter-spacing: -.7px; }
.brand span { color: var(--blue); }
.avatar { display: grid; width: 44px; height: 44px; padding: 11px; place-items: center; border-radius: 50%; color: #fff; background: #171820; }
.avatar svg { width: 22px; fill: currentColor; }

.page-heading { margin: 22px 0 24px; }
.page-heading h1 { margin: 0; font-size: 34px; line-height: 1.12; letter-spacing: -1.2px; }
.page-heading p { margin: 9px 0 0; color: #858ba0; font-size: 16px; font-weight: 550; }

.chapter-list { display: grid; gap: 12px; }
.chapter-card {
  display: flex;
  min-width: 0;
  min-height: 70px;
  align-items: center;
  gap: 15px;
  padding: 13px 19px;
  border: 0;
  border-radius: 22px;
  color: #171820;
  text-align: left;
  background: #fff;
  box-shadow: 0 5px 18px rgb(34 40 70 / 3%);
}

.chapter-card.is-active { width: 100%; cursor: pointer; }
.chapter-card.is-active {
  min-height: 168px;
  padding: 20px 22px;
  color: #fff;
  background: linear-gradient(125deg, #3947f2 0%, #4e60ff 100%);
  box-shadow: 0 14px 28px rgb(54 69 227 / 16%);
}

.chapter-number {
  display: grid;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  place-items: center;
  border-radius: 15px;
  color: #777e98;
  background: #f0f1fb;
  font-size: 20px;
  font-weight: 750;
}

.is-active .chapter-number { color: var(--blue); background: #f7f8ff; }
.chapter-info { min-width: 0; flex: 1; }
.chapter-info h2 { margin: 0; font-size: 17px; line-height: 1.24; letter-spacing: -.35px; }
.chapter-info p { margin: 6px 0 0; color: #858ba0; font-size: 14px; line-height: 1.25; }
.is-active .chapter-info p { color: rgb(255 255 255 / 88%); font-size: 15px; }

.active-content { display: flex; align-items: center; gap: 16px; }
.active-details { min-width: 0; flex: 1; }
.active-details .chapter-info h2 { max-width: 160px; font-size: 20px; line-height: 1.27; }
.active-details .chapter-info p { margin-top: 7px; }
.active-progress { display: flex; max-width: 220px; align-items: center; gap: 12px; margin-top: 15px; }
.progress-track { overflow: hidden; flex: 1; height: 14px; border-radius: 20px; background: rgb(255 255 255 / 34%); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #b9c1ff; }
.progress-label { color: #fff; font-size: 14px; white-space: nowrap; }
.active-arrow { display: grid; flex: 0 0 52px; width: 52px; height: 52px; place-items: center; border-radius: 50%; color: var(--blue); background: #fff; font-size: 27px; line-height: 1; }

.chapter-card.is-locked { min-height: 76px; cursor: not-allowed; }
.is-locked .chapter-number { width: 48px; height: 48px; flex-basis: 48px; border-radius: 14px; }
.lock-icon { width: 24px; height: 24px; flex: 0 0 24px; fill: #969bb1; }
.chapter-notice { margin: 12px 4px 0; color: #73788d; font-size: 14px; }
.chapter-notice[hidden] { display: none; }

.bottom-nav {
  position: fixed;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 520px);
  min-height: calc(82px + env(safe-area-inset-bottom));
  margin: 0 auto;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #f0f1f6;
  background: rgb(255 255 255 / 96%);
  backdrop-filter: blur(12px);
}

.nav-item { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 5px; color: #a2a5b8; font-size: 12px; font-weight: 500; }
.nav-item svg { width: 24px; height: 24px; fill: currentColor; }
.nav-item.is-active { color: var(--blue); }

@media (max-width: 370px) {
  .app-shell { padding-right: 18px; padding-left: 18px; }
  .page-heading h1 { font-size: 31px; }
  .chapter-list { gap: 10px; }
  .chapter-card { gap: 11px; padding-right: 14px; padding-left: 14px; }
  .chapter-card.is-active { padding-right: 15px; padding-left: 15px; }
  .chapter-number { flex-basis: 46px; width: 46px; height: 46px; }
  .active-content { gap: 9px; }
  .active-arrow { flex-basis: 46px; width: 46px; height: 46px; }
  .active-details .chapter-info h2 { font-size: 19px; }
}

@media (min-width: 520px) {
  .app-shell { min-height: calc(100vh - 18px); margin-top: 9px; border-radius: 28px; background: #fafbfe; }
  .bottom-nav { border-right: 1px solid #f0f1f6; border-left: 1px solid #f0f1f6; border-radius: 18px 18px 0 0; }
}
