:root {
  --page: #f3eee5;
  --page-deep: #e8ddcf;
  --surface: rgba(255, 253, 248, .92);
  --surface-solid: #fffdf8;
  --surface-2: #eee6da;
  --ink: #22211f;
  --muted: #746f68;
  --line: rgba(49, 44, 38, .13);
  --accent: #8f3d32;
  --accent-soft: #f0dfda;
  --gold: #a57b3b;
  --green: #355d48;
  --note: #e6efe9;
  --shadow: 0 18px 60px rgba(68, 50, 30, .10);
  --reader-size: 14px;
  --reader-width: 820px;
}

html[data-theme="green"] {
  --page: #eaf0e7;
  --page-deep: #dce8d8;
  --surface: rgba(249, 253, 247, .92);
  --surface-solid: #f9fdf7;
  --surface-2: #dfe9db;
  --ink: #20251f;
  --muted: #687265;
  --line: rgba(43, 69, 43, .14);
  --accent: #56724f;
  --accent-soft: #dbe8d7;
}

html[data-theme="blue"] {
  --page: #e9f0f3;
  --page-deep: #d9e5eb;
  --surface: rgba(249, 252, 253, .93);
  --surface-solid: #f9fcfd;
  --surface-2: #dce8ed;
  --ink: #202528;
  --muted: #657077;
  --line: rgba(44, 68, 82, .14);
  --accent: #4a7183;
  --accent-soft: #d8e7ed;
}

html[data-theme="pink"] {
  --page: #f4ebeb;
  --page-deep: #eadada;
  --surface: rgba(255, 250, 250, .93);
  --surface-solid: #fffafa;
  --surface-2: #eee0e0;
  --ink: #282122;
  --muted: #76686a;
  --line: rgba(92, 56, 62, .13);
  --accent: #965b63;
  --accent-soft: #eedbdd;
}

html[data-theme="gray"] {
  --page: #e8e8e5;
  --page-deep: #dadad6;
  --surface: rgba(246, 246, 243, .94);
  --surface-solid: #f7f7f4;
  --surface-2: #dfdfdc;
  --ink: #252523;
  --muted: #6d6d69;
  --line: rgba(45, 45, 42, .14);
  --accent: #5f6764;
  --accent-soft: #dedfda;
}

html[data-theme="night"] {
  color-scheme: dark;
  --page: #1b1b19;
  --page-deep: #121211;
  --surface: rgba(39, 38, 35, .94);
  --surface-solid: #282724;
  --surface-2: #34322e;
  --ink: #e9e3d9;
  --muted: #aaa39a;
  --line: rgba(241, 232, 218, .13);
  --accent: #d27c6f;
  --accent-soft: #4a302d;
  --gold: #d0aa69;
  --green: #9bc3aa;
  --note: #263a30;
  --shadow: 0 20px 65px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 2%, color-mix(in srgb, var(--accent), transparent 89%), transparent 29rem),
    radial-gradient(circle at 91% 40%, color-mix(in srgb, var(--gold), transparent 91%), transparent 26rem),
    var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  transition: color .2s ease, background-color .2s ease;
}

button, select, textarea { font: inherit; }
button, select { color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  width: min(390px, 100%);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.login-card .brand-mark { margin-bottom: 25px; }
.login-card h1 { margin: 0 0 30px; font: 500 34px/1.2 Georgia, "Songti SC", serif; }
.login-card label { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.login-card input { height: 46px; margin-bottom: 18px; padding: 0 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; background: var(--page); outline: none; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 84%); }
.login-card .remember-option { display: flex; align-items: center; gap: 8px; margin: -3px 0 19px; color: var(--muted); cursor: pointer; }
.login-card .remember-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.login-card .remember-option span { font-size: 12px; }
.login-error { margin: 14px 0 0; color: #b73f35; font-size: 12px; }

.uploading { opacity: .65; pointer-events: none; }

.reading-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 4px;
  z-index: 80;
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 72px;
  padding: 10px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid), transparent 12%);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff8ef;
  border-radius: 12px 12px 15px 15px;
  background: var(--accent);
  font-family: "Songti SC", serif;
  font-size: 21px;
  box-shadow: 0 9px 22px color-mix(in srgb, var(--accent), transparent 68%);
}

.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font: 700 16px/1.2 Georgia, "Songti SC", serif; }
.brand-copy small { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }

.header-actions,
.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
body.reader-open #libraryThemeButton { display: none; }

.icon-button,
.quiet-button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 999px;
  cursor: pointer;
}

.icon-button {
  min-width: 38px;
  padding: 0 10px;
  border: 1px solid transparent;
  background: transparent;
}

.icon-button:hover,
.icon-button:focus-visible {
  outline: none;
  border-color: var(--line);
  background: var(--accent-soft);
}

.quiet-button {
  padding: 0 13px;
  color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green), transparent 70%);
  background: color-mix(in srgb, var(--note), transparent 25%);
  font-size: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
}

.primary-button,
.secondary-button {
  padding: 9px 17px;
  border: 1px solid var(--accent);
}

.primary-button { color: #fff8ef; background: var(--accent); }
.secondary-button { color: var(--accent); background: transparent; }

.library-view {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0 100px;
}

.library-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 60px;
  align-items: end;
  padding: clamp(36px, 7vw, 74px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.library-hero::after {
  content: "阅";
  position: absolute;
  right: -30px;
  bottom: -90px;
  color: color-mix(in srgb, var(--accent), transparent 94%);
  font: 290px/1 "Songti SC", serif;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.library-hero h1 {
  position: relative;
  z-index: 1;
  max-width: 750px;
  margin: 0;
  font: 500 clamp(38px, 6vw, 68px)/1.18 Georgia, "Songti SC", serif;
  letter-spacing: -.035em;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 25px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.hero-stat {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--page), transparent 25%);
}

.stat-number { color: var(--accent); font: 64px/1 Georgia, serif; }
.stat-label { margin-top: 6px; color: var(--muted); font-size: 12px; }

.section-bar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin: 0 0 24px;
}

.section-bar h2 { margin: 0; font: 500 34px/1.15 Georgia, "Songti SC", serif; }
.section-actions { display: flex; align-items: center; gap: 9px; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 360px));
  gap: 24px;
}

.book-card {
  position: relative;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 13px 40px rgba(48, 37, 25, .06);
}

.book-card-visual {
  position: relative;
  display: grid;
  place-items: center;
  height: 220px;
  color: #fff8ef;
  background:
    radial-gradient(circle at 70% 25%, rgba(255,255,255,.16), transparent 10rem),
    linear-gradient(135deg, color-mix(in srgb, var(--accent), #fff 8%), color-mix(in srgb, var(--accent), #211c1a 58%) 72%, #25211f);
  border-radius: 21px 21px 0 0;
  overflow: hidden;
}

.book-card-visual::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 15px;
}

.book-card-visual span { position: relative; z-index: 1; font: 54px/1 Georgia, serif; }
.book-card-visual small { position: absolute; bottom: 36px; z-index: 1; color: #e8c7bd; letter-spacing: .12em; text-transform: uppercase; }

.book-card-body { padding: 24px; }
.book-card-body h3 { margin: 0; font: 500 23px/1.4 Georgia, "Songti SC", serif; }
.book-card-body > p { margin: 8px 0 20px; color: var(--muted); font-size: 13px; }
.book-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }
.book-meta span { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.book-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.book-actions > .primary-button { min-width: 0; }
.book-more { position: relative; }
.book-more summary {
  display: grid;
  place-items: center;
  min-width: 40px;
  height: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  list-style: none;
}
.book-more summary::-webkit-details-marker { display: none; }
.book-menu-popover {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 24;
  display: grid;
  width: max-content;
  min-width: 155px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
  box-shadow: 0 14px 38px rgba(0,0,0,.18);
}
.book-menu-popover button {
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}
.book-menu-popover button:hover { color: var(--ink); background: var(--surface-2); }
.book-menu-popover .danger-menu { color: #b94b43; }

.library-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 56px;
  padding: 24px;
  border: 1px solid color-mix(in srgb, var(--gold), transparent 64%);
  border-radius: 18px;
  background: color-mix(in srgb, var(--gold), transparent 92%);
}

.note-icon { color: var(--gold); font-size: 24px; }
.library-note h3 { margin: 0 0 7px; font-size: 16px; }
.library-note p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

.reader-view {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.reader-sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  overflow-y: auto;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid), transparent 18%);
  backdrop-filter: blur(12px);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 38px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
}

.drawer-close { display: none; }

.back-link {
  padding: 0;
  color: var(--muted);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.mini-cover {
  display: grid;
  place-items: center;
  width: 64px;
  height: 86px;
  margin: 30px 0 22px;
  color: #fff8ef;
  border-radius: 6px 6px 15px 15px;
  background: linear-gradient(145deg, var(--accent), #512623);
  font: 25px/1 Georgia, serif;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent), transparent 68%);
}

.sidebar-book h2 { margin: 0; font: 500 18px/1.45 Georgia, "Songti SC", serif; }
.sidebar-book > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }

.chapter-nav {
  display: grid;
  gap: 3px;
  margin: 28px 0;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.chapter-nav a {
  display: block;
  padding: 9px 10px;
  color: var(--muted);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
}

.chapter-nav a:hover,
.chapter-nav a.active { color: var(--ink); background: var(--accent-soft); }

.sidebar-tools { display: grid; gap: 6px; }
.sidebar-tools button { display: flex; justify-content: space-between; padding: 10px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; text-align: left; }
.sidebar-tools button:hover { color: var(--ink); background: var(--surface-2); }
.sidebar-tools b { color: var(--accent); }

.library-return {
  width: 100%;
  margin-top: auto;
  padding: 11px 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 12px;
}

.library-return:hover {
  color: var(--ink);
  background: var(--surface-2);
}

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

.reader-toolbar {
  position: sticky;
  top: 72px;
  z-index: 35;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 66px;
  padding: 10px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--page), transparent 10%);
  backdrop-filter: blur(16px);
}

.chapter-label { display: grid; gap: 2px; }
.chapter-label span { font-weight: 700; font-size: 13px; }
.chapter-label small { color: var(--muted); font-size: 10px; }
.toolbar-controls select { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: var(--surface-solid); }
.mobile-menu,
.mobile-back { display: none; border: 0; background: transparent; }
.mobile-menu { font-size: 22px; }
.mobile-back { font: 36px/1 Georgia, serif; }

.chapter-content {
  width: min(100% - 36px, var(--reader-width));
  margin: 0 auto;
  padding: 64px 0 130px;
}

.chapter-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 26px;
  padding: clamp(40px, 8vw, 78px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.chapter-hero::after {
  content: attr(data-number);
  position: absolute;
  right: -18px;
  bottom: -65px;
  color: color-mix(in srgb, var(--accent), transparent 92%);
  font: 250px/1 Georgia, serif;
}

.chapter-hero h1 { position: relative; z-index: 1; margin: 0; }
.chapter-hero .hero-en { display: block; max-width: 670px; font: 500 clamp(38px, 7vw, 67px)/1.05 Georgia, serif; letter-spacing: -.035em; }
.chapter-hero .hero-zh { display: block; margin-top: 17px; color: var(--accent); font: 500 clamp(24px, 4vw, 36px)/1.3 "Songti SC", serif; }
.chapter-pills { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.chapter-pills span { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: color-mix(in srgb, var(--page), transparent 30%); font-size: 11px; }

.disclosure {
  margin-bottom: 26px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--gold), transparent 62%);
  border-radius: 14px;
  color: var(--muted);
  background: color-mix(in srgb, var(--gold), transparent 92%);
  font-size: 13px;
  line-height: 1.7;
}

.reader-section {
  margin-bottom: 26px;
  padding: clamp(24px, 5vw, 46px);
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: 0 12px 38px rgba(54, 42, 28, .055);
}

.reader-section-head {
  display: grid;
  grid-template-columns: 35px 1fr;
  gap: 15px;
  align-items: start;
  margin-bottom: 32px;
}

.reader-section-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-top: 3px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent), transparent 50%);
  border-radius: 50%;
  font: 700 12px/1 Georgia, serif;
}

.reader-section h2 { margin: 0; font-weight: 500; }
.reader-section h2 .heading-en { display: block; font: 500 clamp(26px, 4vw, 37px)/1.2 Georgia, serif; }
.reader-section h2 .heading-zh { display: block; margin-top: 7px; color: var(--muted); font: 500 16px/1.5 "Songti SC", serif; }

.content-block {
  position: relative;
  padding: 7px 0 26px;
  font-size: var(--reader-size);
}

.content-block + .content-block {
  padding-top: 27px;
  border-top: 1px solid var(--line);
}

.block-actions {
  position: absolute;
  top: 8px;
  right: 0;
  z-index: 3;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity .15s ease;
}

.content-block:hover .block-actions,
.block-actions:focus-within { opacity: 1; }

.bookmark-button,
.speak-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-solid);
  cursor: pointer;
}

.bookmark-button.active { color: var(--accent); background: var(--accent-soft); }
.speak-button { color: var(--accent); }

.lane {
  position: relative;
  margin: 0;
  padding-left: 30px;
  text-wrap: pretty;
}

.lane + .lane { margin-top: 13px; }
.lane.en { font: 1em/1.75 Georgia, "Times New Roman", serif; }
.lane.zh { color: color-mix(in srgb, var(--ink), var(--muted) 16%); font: .92em/1.95 "Songti SC", "STSong", serif; letter-spacing: .025em; }
.lane::before { position: absolute; left: 0; top: .55em; width: 21px; color: var(--accent); font: 800 9px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; }
.lane.en::before { content: "EN"; }
.lane.zh::before { content: "中"; color: var(--gold); }

.quote-block {
  padding: 24px 22px 21px 53px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--page), transparent 20%);
}
.quote-block::before { content: "“"; position: absolute; left: 17px; top: 9px; color: var(--accent); font: 50px/1 Georgia, serif; }
.quote-attribution { margin: 13px 0 0 30px; color: var(--accent); font-size: 12px; font-weight: 750; }

.commentary-block {
  padding: 21px 22px;
  border-left: 4px solid var(--green);
  border-radius: 5px 14px 14px 5px;
  color: var(--green);
  background: var(--note);
}
.commentary-speaker { margin: 0 0 12px; font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.commentary-block .lane { color: inherit; }

.memo-block {
  padding: 19px 20px;
  border: 1px dashed color-mix(in srgb, var(--gold), transparent 44%);
  border-radius: 14px;
  background: color-mix(in srgb, var(--gold), transparent 93%);
}
.memo-citation { margin: 0 0 11px; color: var(--gold); font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }

.subheading-block h3 { margin: 0; }
.subheading-block .lane.en { font-size: 1.42em; line-height: 1.35; }
.subheading-block .lane.zh { font-size: 1em; }

.example-block { display: grid; gap: 13px; }
.example-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-solid); }
.thought-row { display: grid; grid-template-columns: 108px 1fr; gap: 14px; padding: 17px 19px; }
.thought-row + .thought-row { border-top: 1px solid var(--line); }
.thought-row.second { background: color-mix(in srgb, var(--accent-soft), transparent 35%); }
.thought-label { padding-top: 4px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.thought-row.second .thought-label { color: var(--accent); }
.thought-row .lane { padding-left: 0; }
.thought-row .lane::before { display: none; }

.question-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; counter-reset: question; }
.question-list li { position: relative; padding: 15px 17px 15px 55px; border: 1px solid var(--line); border-radius: 13px; background: color-mix(in srgb, var(--page), transparent 19%); counter-increment: question; }
.question-list li::before { content: counter(question, decimal-leading-zero); position: absolute; left: 16px; top: 18px; color: var(--accent); font: 700 11px/1 Georgia, serif; }
.question-list .lane { padding-left: 0; }
.question-list .lane::before { display: none; }

.matrix-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-solid); }
.matrix { width: 100%; min-width: 580px; border-collapse: collapse; }
.matrix th, .matrix td { padding: 16px 17px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.matrix tr:last-child th, .matrix tr:last-child td { border-bottom: 0; }
.matrix th:last-child, .matrix td:last-child { border-right: 0; }
.matrix thead th { color: var(--muted); background: var(--surface-2); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.matrix tbody th { color: var(--muted); font-size: 12px; }
.matrix td b { display: block; margin-bottom: 5px; color: var(--accent); font: 16px/1.35 Georgia, serif; }
.matrix td span { color: var(--muted); font-size: 12px; }

.takeaway-block { overflow: hidden; padding: 30px; color: #fff8ef; border-radius: 18px; background: linear-gradient(135deg, #8f382e, #5f2825 70%, #372022); box-shadow: 0 16px 45px rgba(80, 33, 28, .18); }
.takeaway-block::after { content: "II"; position: absolute; right: 16px; bottom: -36px; opacity: .08; font: 140px/1 Georgia, serif; }
.takeaway-block .lane { position: relative; z-index: 1; color: inherit; }

mark.user-highlight { padding: .04em .02em; border-radius: 3px; color: inherit; cursor: pointer; }
mark.user-highlight.yellow { background: rgba(248, 214, 87, .54); }
mark.user-highlight.green { background: rgba(133, 202, 145, .46); }
mark.user-highlight.blue { background: rgba(112, 181, 225, .42); }
mark.user-highlight.pink { background: rgba(226, 137, 168, .40); }
mark.user-highlight.underline { background: transparent; text-decoration: underline 3px var(--accent); text-underline-offset: 4px; }

html[data-language="en"] [data-lane="zh-CN"],
html[data-language="en"] .heading-zh,
html[data-language="en"] .hero-zh { display: none !important; }
html[data-language="zh"] [data-lane="en"],
html[data-language="zh"] .heading-en,
html[data-language="zh"] .hero-en { display: none !important; }

.study-panel {
  position: fixed;
  top: 72px;
  right: 0;
  bottom: 0;
  z-index: 70;
  width: min(390px, 92vw);
  padding: 25px;
  border-left: 1px solid var(--line);
  background: var(--surface-solid);
  box-shadow: -20px 0 55px rgba(35, 27, 20, .14);
  overflow-y: auto;
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 58;
  padding: 0;
  border: 0;
  background: rgba(26, 23, 20, .28);
  backdrop-filter: blur(2px);
  cursor: default;
}

.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel-head h2 { margin: 0; font: 500 26px/1.2 Georgia, "Songti SC", serif; }
.panel-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 24px 0 18px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.panel-tabs button { padding: 8px; color: var(--muted); border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-size: 12px; }
.panel-tabs button.active { color: var(--ink); background: var(--surface-solid); box-shadow: 0 3px 12px rgba(0,0,0,.06); }
.panel-content { display: grid; gap: 10px; }
.study-item { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: color-mix(in srgb, var(--page), transparent 30%); }
.study-item small { color: var(--accent); font-weight: 750; }
.study-item blockquote { margin: 8px 0; color: var(--muted); font: 13px/1.6 Georgia, "Songti SC", serif; }
.study-item p { margin: 7px 0 0; font-size: 13px; line-height: 1.6; }
.study-item-actions { display: flex; gap: 7px; margin-top: 12px; }
.study-item-actions button { padding: 5px 9px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer; font-size: 10px; }
.empty-state { padding: 38px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; text-align: center; font-size: 13px; line-height: 1.7; }

.selection-toolbar {
  position: absolute;
  z-index: 90;
  display: flex;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  box-shadow: 0 12px 35px rgba(0,0,0,.18);
}
.selection-toolbar button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.selection-toolbar button:hover { background: var(--surface-2); }
.color-dot { width: 17px; height: 17px; border-radius: 50%; }
.color-dot.yellow { background: #e4bd37; }
.color-dot.green { background: #72ae7e; }
.color-dot.blue { background: #64a8d2; }
.color-dot.pink { background: #d7819f; }
.underline-icon { text-decoration: underline 3px var(--accent); text-underline-offset: 3px; }

.lookup-card {
  position: absolute;
  z-index: 95;
  width: min(330px, calc(100vw - 28px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-solid);
  box-shadow: 0 18px 55px rgba(0,0,0,.20);
}
.lookup-close { position: absolute; top: 11px; right: 11px; width: 28px; height: 28px; border: 0; border-radius: 50%; color: var(--muted); background: var(--surface-2); cursor: pointer; }
.lookup-word { margin: 0 32px 3px 0; color: var(--accent); font: 700 26px/1.2 Georgia, serif; }
.lookup-speak { position: absolute; top: 49px; right: 14px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); background: var(--surface-solid); cursor: pointer; }
.lookup-pos { margin: 0 0 13px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.lookup-definition { margin: 0; font: 15px/1.65 "Songti SC", serif; }
.lookup-context { margin: 12px 0 16px; padding-top: 12px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; line-height: 1.6; }
.lookup-definition, .lookup-context { white-space: pre-line; }

.annotation-card {
  position: absolute;
  z-index: 96;
  width: min(350px, calc(100vw - 28px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-solid);
  box-shadow: 0 18px 55px rgba(0,0,0,.20);
}
.annotation-kind { margin: 0 34px 12px 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.annotation-card blockquote { margin: 0 0 12px; color: var(--muted); font: 14px/1.65 Georgia, "Songti SC", serif; }
.annotation-note { margin: 0 0 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.7; white-space: pre-line; }
.danger-button { color: var(--accent); }

.audio-control {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 94;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px;
  align-items: center;
  gap: 5px;
  width: min(360px, calc(100vw - 32px));
  min-height: 58px;
  padding: 7px 8px 7px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface-solid), transparent 4%);
  box-shadow: 0 16px 44px rgba(0,0,0,.20);
  backdrop-filter: blur(16px);
}
.audio-control-copy { min-width: 0; }
.audio-control-copy strong,
.audio-control-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.audio-control-copy strong { font-size: 12px; }
.audio-control-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.audio-control button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: var(--accent);
  background: var(--surface-2);
  cursor: pointer;
}
.audio-control button:disabled { opacity: .45; cursor: default; }
.mobile-font-controls { display: none; }

dialog {
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-solid);
  box-shadow: 0 26px 80px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20, 18, 16, .42); backdrop-filter: blur(5px); }
.note-dialog { width: min(560px, calc(100vw - 30px)); padding: 28px; }
.note-dialog h2 { margin: 0; font: 500 27px/1.25 Georgia, "Songti SC", serif; }
.note-dialog blockquote { margin: 18px 0; padding: 14px 16px; color: var(--muted); border-left: 3px solid var(--accent); background: var(--surface-2); font: 14px/1.7 Georgia, "Songti SC", serif; }
.note-dialog textarea { width: 100%; resize: vertical; padding: 14px; color: var(--ink); border: 1px solid var(--line); border-radius: 13px; background: var(--page); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.theme-dialog { width: min(640px, calc(100vw - 30px)); padding: 28px; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 24px; }
.theme-grid button { display: grid; gap: 5px; justify-items: start; padding: 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 14px; background: transparent; cursor: pointer; text-align: left; }
.theme-grid button:hover { border-color: var(--accent); }
.theme-grid small { color: var(--muted); font-size: 10px; }
.theme-swatch { width: 100%; height: 55px; margin-bottom: 5px; border: 1px solid rgba(0,0,0,.08); border-radius: 9px; }
.theme-swatch.paper { background: #f3eee5; }
.theme-swatch.green { background: #eaf0e7; }
.theme-swatch.blue { background: #e9f0f3; }
.theme-swatch.pink { background: #f4ebeb; }
.theme-swatch.gray { background: #e8e8e5; }
.theme-swatch.night { background: #1b1b19; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 120;
  max-width: min(90vw, 460px);
  transform: translateX(-50%);
  padding: 11px 16px;
  color: #fff;
  border-radius: 999px;
  background: rgba(28, 26, 24, .92);
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
  font-size: 12px;
}

.mobile-bottom-nav { display: none; }
html.panel-open,
body.panel-open { overflow: hidden; overscroll-behavior: none; }
.reader-sidebar,
.study-panel { overscroll-behavior: contain; touch-action: pan-y; }

@media (max-width: 940px) {
  .reader-view { grid-template-columns: 1fr; }
  .reader-sidebar { position: fixed; top: 72px; left: 0; bottom: 0; z-index: 70; width: min(310px, 88vw); height: auto; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.18); }
  .reader-sidebar.open { transform: translateX(0); }
  .drawer-close { display: grid; }
  .mobile-menu { display: block; }
  .chapter-label { margin-right: auto; margin-left: 10px; }
}

@media (max-width: 680px) {
  .app-header { min-height: 62px; padding: 8px 14px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-copy small, .quiet-button { display: none; }
  .avatar { width: 34px; height: 34px; }
  .library-view { width: min(100% - 24px, 1180px); padding: 32px 0 90px; }
  .library-hero { grid-template-columns: 1fr; gap: 24px; padding: 34px 25px; border-radius: 22px; }
  .library-hero h1 { font-size: 38px; }
  .hero-stat { display: none; }
  .section-bar { align-items: center; gap: 10px; margin-top: 0; }
  .section-bar h2 { font-size: 26px; }
  .section-actions { gap: 5px; }
  .section-actions button { min-height: 34px; padding: 7px 10px; font-size: 10px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .book-card { border-radius: 15px; }
  .book-card-visual { height: 105px; border-radius: 14px 14px 0 0; }
  .book-card-visual::before { inset: 10px; border-radius: 9px; }
  .book-card-visual span { font-size: 32px; }
  .book-card-visual small { right: 12px; bottom: 16px; left: 12px; overflow: hidden; font-size: 7px; white-space: nowrap; text-overflow: ellipsis; text-align: center; }
  .book-card-body { padding: 11px; }
  .book-card-body h3 { display: -webkit-box; min-height: 38px; overflow: hidden; font-size: 14px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .book-card-body > p { overflow: hidden; margin: 4px 0 11px; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
  .book-meta { display: none; }
  .book-actions { gap: 5px; }
  .book-actions .primary-button { min-height: 32px; padding: 5px 8px; font-size: 10px; }
  .book-more summary { min-width: 34px; min-height: 32px; }
  .book-menu-popover { min-width: 142px; }
  body.reader-open .app-header { display: none; }
  body.reader-open #libraryThemeButton { display: none; }
  .reading-progress { height: 2px; }
  .reader-view { min-height: 100vh; }
  .reader-sidebar { top: 0; }
  .reader-toolbar { top: 0; min-height: 46px; padding: 2px 5px; }
  .mobile-back { display: block; width: 44px; height: 42px; }
  .mobile-menu { width: 44px; height: 42px; }
  .chapter-label { min-width: 0; margin: 0; text-align: center; cursor: pointer; }
  .chapter-label span { overflow: hidden; display: block; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
  .chapter-label small { display: block; font-size: 9px; }
  .toolbar-controls { display: none; }
  .chapter-content { width: min(100% - 30px, var(--reader-width)); padding: 16px 0 74px; }
  .chapter-hero { display: none; }
  .reader-section {
    margin: 0;
    padding: 19px 0 24px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .reader-section + .reader-section { border-top: 1px solid var(--line); }
  .reader-section-head { grid-template-columns: 25px minmax(0, 1fr); gap: 9px; margin-bottom: 22px; }
  .reader-section-index { width: 24px; height: 24px; margin-top: 1px; font-size: 9px; }
  .reader-section h2 .heading-en { font-size: 16px; line-height: 1.3; }
  .reader-section h2 .heading-zh { margin-top: 2px; font-size: 12px; line-height: 1.45; }
  .content-block { font-size: var(--reader-size); }
  .content-block { padding-bottom: 21px; }
  .content-block + .content-block { padding-top: 22px; }
  .lane { padding-left: 0; }
  .lane::before { display: none; }
  .lane + .lane { margin-top: 8px; }
  .block-actions { top: 2px; opacity: 0; pointer-events: none; }
  .content-block.mobile-active .block-actions,
  .block-actions:focus-within { opacity: 1; pointer-events: auto; }
  .thought-row { grid-template-columns: 1fr; gap: 7px; }
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .study-panel { top: 0; bottom: 0; width: 100%; }
  .mobile-bottom-nav.open {
    position: fixed;
    inset: auto 12px calc(12px + env(safe-area-inset-bottom));
    z-index: 65;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-solid), transparent 4%);
    box-shadow: 0 14px 42px rgba(0,0,0,.18);
    backdrop-filter: blur(16px);
  }
  .mobile-bottom-nav button { display: grid; place-items: center; align-content: center; gap: 1px; min-width: 0; color: var(--muted); border: 0; background: transparent; font-size: 9px; }
  .mobile-bottom-nav span { font-size: 16px; }
  .mobile-bottom-nav small { font-size: 9px; }
  .mobile-font-controls {
    position: fixed;
    right: 74px;
    bottom: calc(73px + env(safe-area-inset-bottom));
    z-index: 66;
    grid-template-columns: 44px auto 44px;
    align-items: center;
    gap: 5px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-solid);
    box-shadow: 0 12px 32px rgba(0,0,0,.18);
  }
  .mobile-font-controls:not([hidden]) { display: grid; }
  .mobile-font-controls button { width: 42px; height: 38px; border: 0; border-radius: 50%; background: var(--surface-2); }
  .mobile-font-controls output { min-width: 42px; color: var(--muted); font-size: 11px; text-align: center; }
  .lookup-card,
  .annotation-card {
    position: fixed;
    inset: auto 0 0 !important;
    width: 100%;
    max-height: min(52vh, 440px);
    overflow-y: auto;
    padding: 25px 20px calc(22px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
  }
  .lookup-card::before,
  .annotation-card::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 36px;
    height: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: var(--line);
  }
  .audio-control { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); left: 12px; width: auto; }
  body.mobile-tools-open .audio-control { bottom: calc(77px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(18px + env(safe-area-inset-bottom)); }
  .selection-toolbar { max-width: calc(100vw - 20px); }
}

@media print {
  .app-header, .reader-sidebar, .reader-toolbar, .study-panel, .mobile-bottom-nav, .mobile-font-controls, .audio-control, .block-actions, .reading-progress { display: none !important; }
  .reader-view { display: block; }
  .chapter-content { width: 100%; padding: 0; }
  .chapter-hero, .reader-section { box-shadow: none; break-inside: avoid; }
}
