* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --page: #ffffff;
  --ink: #2f3742;
  --muted: #7c8793;
  --faint: #a8b0ba;
  --line: #edf0f3;
  --control: #f2f3f5;
  --control-strong: #e8eaed;
  --green: #1fa276;
  --green-soft: #dff2eb;
  --shadow: 0 16px 36px rgba(28, 39, 54, 0.16);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.book-shell {
  width: min(1840px, 100%);
  margin: 0 auto;
  padding: 70px clamp(34px, 4.4vw, 92px) 76px;
}

.book-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "title"
    "stats";
  gap: 16px 28px;
  align-items: start;
}

.header-title {
  grid-area: title;
}

.header-title h1 {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  font-size: clamp(31px, 2.3vw, 46px);
  font-weight: 700;
  line-height: 1.1;
}

.header-title p {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 1.35vw, 27px);
  font-weight: 500;
  line-height: 1.25;
}

.manage-link {
  grid-area: manage;
  align-self: center;
  display: inline-flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--control);
  color: var(--ink);
  padding: 0 34px;
  text-decoration: none;
  font-size: clamp(14px, 1.05vw, 21px);
  font-weight: 760;
  white-space: nowrap;
}

.manage-link:hover {
  background: var(--control-strong);
}

.stat-strip {
  grid-area: stats;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 0;
  padding: 0;
}

.stat-strip div {
  display: inline-flex;
  gap: 7px;
  align-items: baseline;
}

.stat-strip dt,
.stat-strip dd {
  margin: 0;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.2;
}

.stat-strip dd {
  color: var(--muted);
  font-weight: 760;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(280px, 440px) auto;
  gap: 16px;
  align-items: center;
  margin: 34px 0 38px;
}

.search-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  outline: none;
}

.search-field input:focus {
  border-color: rgba(31, 162, 118, 0.42);
  box-shadow: 0 0 0 4px rgba(31, 162, 118, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, auto));
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--control);
}

.segment,
.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.segment {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 14px;
}

.segment.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 8px rgba(20, 28, 38, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(176px, 218px) minmax(0, 1fr);
  gap: clamp(36px, 4.2vw, 68px);
  align-items: start;
  margin-top: 44px;
}

.reading-rail {
  display: block;
  min-width: 0;
  position: sticky;
  top: 22px;
}

.progress-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading p,
.panel-heading strong {
  margin: 0;
}

.panel-heading p {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.panel-heading strong {
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
}

.completion-track {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--control);
}

.completion-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--green);
}

.book-index {
  display: grid;
  gap: 2px;
  max-height: min(72vh, 760px);
  min-width: 0;
  overflow: auto;
  padding-right: 5px;
}

.index-button {
  min-width: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 8px 9px;
  text-align: left;
}

.index-button:hover,
.index-button.is-active {
  background: var(--control);
  color: var(--ink);
}

.index-button span,
.index-button small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.index-button span {
  color: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.34;
}

.index-button small {
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
}

.main-stack {
  display: grid;
  gap: 70px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  font-weight: 760;
}

.main-stack > section:first-child .section-head {
  display: none;
}

.eyebrow {
  display: none;
}

.text-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--control);
}

.text-button:hover {
  color: var(--ink);
  background: var(--control-strong);
}

.bookshelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  justify-items: start;
  gap: 50px clamp(24px, 3.6vw, 52px);
}

.book-tile {
  display: block;
  width: min(100%, 170px);
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.cover-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 0.69;
  overflow: hidden;
  background: #f3f4f5;
  box-shadow: var(--shadow);
}

.cover-frame img,
.cover-fallback {
  display: block;
  width: 100%;
  height: 100%;
}

.cover-frame img {
  object-fit: cover;
}

.cover-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 760;
  line-height: 1.35;
  text-align: center;
}

.cover-progress {
  position: absolute;
  inset: auto 0 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.cover-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 220ms ease;
}

.cover-progress.is-empty span {
  background: transparent;
}

.book-tile:hover .cover-frame,
.book-tile.is-active .cover-frame {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(28, 39, 54, 0.22);
}

.book-tile.is-active .cover-frame {
  outline: 3px solid rgba(31, 162, 118, 0.28);
  outline-offset: 5px;
}

.book-copy {
  display: block;
  padding-top: 18px;
}

.book-title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: #4f5a66;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.32;
  -webkit-font-smoothing: subpixel-antialiased;
  text-rendering: optimizeLegibility;
}

.book-meta {
  display: none;
}

.note-head {
  border-top: 1px solid var(--line);
  padding-top: 34px;
}

.note-count,
.note-meta {
  color: var(--muted);
  font-size: 13px;
}

.note-count {
  margin: 0;
  min-width: 0;
  max-width: 52%;
  text-align: right;
  overflow-wrap: anywhere;
}

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

.note-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 18px;
  border-top: 1px solid var(--line);
  padding: 18px 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 140px;
}

.note-number {
  align-self: start;
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.note-text {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.82;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.note-meta span {
  min-width: 0;
}

mark {
  border-radius: 3px;
  background: var(--green-soft);
  color: inherit;
  padding: 0 2px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 24px;
  color: var(--muted);
  background: #fafafa;
}

@media (max-width: 980px) {
  .book-header {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "title"
      "stats";
  }

  .control-band {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 34px;
  }

  .reading-rail {
    position: static;
  }

  .book-index {
    display: flex;
    gap: 8px;
    max-height: none;
    overflow-x: auto;
    padding: 0 0 4px;
  }

  .index-button {
    flex: 0 0 158px;
  }
}

@media (max-width: 720px) {
  .book-shell {
    padding: 34px 15px 46px;
  }

  .header-title p {
    margin-top: 12px;
  }

  .manage-link {
    min-height: 44px;
    padding: 0 18px;
    font-size: 13px;
  }

  .control-band {
    margin: 28px 0 28px;
  }

  .workspace {
    margin-top: 32px;
  }

  .search-field {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .segmented {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .segment {
    padding: 0 8px;
    font-size: 12px;
  }

  .section-head {
    margin-bottom: 18px;
  }

  .bookshelf {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: center;
    gap: 32px 18px;
  }

  .book-tile {
    width: min(100%, 150px);
  }

  .book-copy {
    padding-top: 11px;
  }

  .book-title {
    font-size: 13px;
    line-height: 1.34;
  }

  .note-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .note-head {
    align-items: start;
  }

  .note-count {
    max-width: 54%;
    font-size: 12px;
  }

  .note-text {
    font-size: 15px;
  }
}
