:root {
  --paper: #fbf7f1;
  --paper-strong: #f2e7d7;
  --ink: #201915;
  --ink-soft: #5f4f43;
  --line: #d4c1ac;
  --accent: #9f472f;
  --accent-soft: #f3dfd7;
  --green: #4d7f61;
  --shadow: 0 18px 40px rgba(33, 22, 16, 0.1);
  --radius: 20px;
  --sidebar-width: 320px;
  --drawer-width: 380px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at top left, rgba(159, 71, 47, 0.08), transparent 30%),
    linear-gradient(180deg, #f8f0e6 0%, #f7f1e7 100%);
  color: var(--ink);
  font-family: "Songti SC", "STSong", "PingFang SC", serif;
  min-height: 100%;
}

body {
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid rgba(77, 58, 42, 0.12);
  background: rgba(255, 251, 246, 0.84);
  backdrop-filter: blur(18px);
  padding: 24px 18px 28px;
}

.brand-card,
.sidebar-block,
.topbar,
.reading-stage,
.drawer,
.modal-card {
  background: rgba(255, 252, 247, 0.92);
  border: 1px solid rgba(85, 61, 44, 0.12);
  box-shadow: var(--shadow);
}

.brand-card {
  border-radius: 28px;
  padding: 24px;
  margin-bottom: 18px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(251, 241, 229, 0.94)),
    var(--paper);
}

.brand-kicker,
.drawer-kicker,
.pane-label,
.topbar-kicker {
  text-transform: uppercase;
  letter-spacing: 0.26em;
  font-size: 11px;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.brand-card h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
}

.brand-subtitle,
.brand-copy,
.topbar-subtitle {
  color: var(--ink-soft);
}

.brand-subtitle {
  margin: 10px 0 8px;
  font-size: 14px;
}

.brand-copy {
  margin: 0;
  line-height: 1.65;
  font-size: 14px;
}

.sidebar-block {
  border-radius: 24px;
  padding: 18px;
  margin-bottom: 16px;
}

.sidebar-header,
.drawer-header,
.modal-header,
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-header h2,
.drawer-header h3,
.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.sidebar-meta {
  font-size: 12px;
  color: var(--ink-soft);
}

.chapter-nav {
  display: grid;
  gap: 8px;
}

.chapter-link {
  display: block;
  padding: 12px 14px;
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid transparent;
  background: rgba(243, 232, 220, 0.5);
  transition: 140ms ease;
}

.chapter-link:hover,
.chapter-link.active {
  border-color: rgba(159, 71, 47, 0.24);
  background: rgba(159, 71, 47, 0.1);
  transform: translateX(2px);
}

.chapter-link strong {
  display: block;
  font-size: 15px;
}

.chapter-link span {
  display: block;
  color: var(--ink-soft);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.45;
}

.account-panel {
  display: grid;
  gap: 12px;
  font-size: 14px;
}

.account-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(250, 241, 231, 0.7);
  line-height: 1.7;
}

.quick-actions {
  display: grid;
  gap: 10px;
}

.reader-shell {
  padding: 24px 24px 40px;
}

.topbar {
  border-radius: 26px;
  padding: 22px 24px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.topbar-title h2 {
  margin: 0;
  font-size: 28px;
}

.topbar-subtitle {
  margin: 8px 0 0;
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.reading-stage {
  border-radius: 28px;
  padding: 18px;
}

.pane-header {
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(77, 58, 42, 0.12);
  margin-bottom: 18px;
}

.pane-title {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 600;
}

.align-right {
  text-align: right;
}

.reading-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.reader-pane {
  min-height: 72vh;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 253, 250, 0.98), rgba(248, 240, 227, 0.96));
  border: 1px solid rgba(77, 58, 42, 0.1);
  overflow: auto;
}

.reader-pane-en {
  background:
    linear-gradient(180deg, rgba(250, 251, 255, 0.96), rgba(236, 243, 251, 0.96));
}

.chapter-intro {
  margin: 0 0 22px;
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: rgba(243, 232, 220, 0.55);
  color: var(--ink-soft);
  line-height: 1.8;
}

.reader-pane-en .chapter-intro {
  background: rgba(222, 233, 245, 0.68);
}

.section-block {
  margin-bottom: 30px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(77, 58, 42, 0.16);
}

.section-block h3 {
  margin: 0 0 12px;
  font-size: 23px;
}

.reader-segment {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.95;
  text-align: justify;
  position: relative;
}

.reader-segment:target {
  animation: pulseTarget 1.4s ease;
}

@keyframes pulseTarget {
  0% { background: rgba(159, 71, 47, 0.24); }
  100% { background: transparent; }
}

.annotation-highlight {
  background: rgba(255, 226, 137, 0.66);
  border-bottom: 2px solid rgba(159, 71, 47, 0.4);
  padding: 0 2px;
  border-radius: 4px;
  cursor: pointer;
}

.annotation-highlight.has-comment {
  background: rgba(190, 232, 204, 0.78);
  border-bottom-color: rgba(77, 127, 97, 0.52);
}

.vocab-token {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px dotted currentColor;
}

.selection-toolbar {
  position: fixed;
  z-index: 40;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(33, 25, 21, 0.94);
  box-shadow: var(--shadow);
}

.selection-toolbar button,
.primary-button,
.ghost-button,
.icon-button,
.tab-button {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: 150ms ease;
}

.selection-toolbar button {
  padding: 8px 14px;
  color: #fff9f4;
  background: transparent;
}

.selection-toolbar button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.primary-button {
  background: linear-gradient(135deg, #a44b33, #c76f4d);
  color: #fffaf4;
  padding: 12px 18px;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(164, 75, 51, 0.22);
}

.ghost-button,
.icon-button,
.tab-button {
  background: rgba(243, 232, 220, 0.7);
  color: var(--ink);
  padding: 11px 16px;
}

.ghost-button:hover,
.icon-button:hover,
.tab-button:hover {
  background: rgba(159, 71, 47, 0.14);
}

.icon-button {
  padding: 10px 14px;
}

.full-width {
  width: 100%;
}

.hidden {
  display: none !important;
}

.drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(var(--drawer-width), calc(100vw - 36px));
  height: calc(100vh - 36px);
  border-radius: 28px;
  padding: 18px;
  z-index: 50;
  overflow: hidden;
}

.drawer-body {
  height: calc(100% - 72px);
  overflow: auto;
  padding-top: 12px;
}

.comment-card,
.review-card,
.metric-card,
.quote-box,
.vocab-panel {
  border-radius: 18px;
  background: rgba(244, 235, 224, 0.7);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.reader-pane-en ~ .drawer .comment-card,
.review-card {
  background: rgba(235, 241, 248, 0.78);
}

.comment-card .comment-meta,
.review-card .review-meta {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.comment-card blockquote,
.quote-box {
  margin: 0 0 10px;
  padding-left: 12px;
  border-left: 3px solid rgba(159, 71, 47, 0.45);
  color: var(--ink);
}

.review-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric-card {
  margin: 0;
}

.metric-card span {
  display: block;
  color: var(--ink-soft);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  font-size: 30px;
}

.review-actions,
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 22, 18, 0.5);
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-card {
  width: min(760px, calc(100vw - 48px));
  border-radius: 30px;
  padding: 22px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 12px;
}

.tab-button.active {
  background: rgba(159, 71, 47, 0.16);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.auth-form input,
.auth-form textarea {
  width: 100%;
  border: 1px solid rgba(85, 61, 44, 0.16);
  border-radius: 16px;
  padding: 13px 14px;
  background: rgba(255, 253, 250, 0.96);
}

.auth-form textarea {
  resize: vertical;
}

.form-note {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
  margin: 12px 0 0;
}

.share-card-shell {
  width: min(1040px, calc(100vw - 48px));
}

.share-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 20px;
}

.share-preview {
  aspect-ratio: 9 / 16;
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.62), transparent 34%),
    linear-gradient(180deg, #1f1713 0%, #442922 42%, #f1dfc9 100%);
  color: #fff6ed;
  overflow: hidden;
}

.share-tag {
  align-self: flex-start;
  margin: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.share-quote {
  margin: 24px 0;
  font-size: 28px;
  line-height: 1.55;
}

.share-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}

.share-chapter,
.share-url {
  margin: 0;
}

.share-url {
  font-size: 12px;
  opacity: 0.82;
  line-height: 1.5;
}

.share-qr {
  width: 132px;
  height: 132px;
  border-radius: 18px;
  background: #fff;
  padding: 8px;
}

.share-help {
  line-height: 1.75;
  color: var(--ink-soft);
}

.stacked {
  flex-direction: column;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(77, 58, 42, 0.12);
  }

  .reader-shell {
    padding-top: 18px;
  }
}

@media (max-width: 920px) {
  .reading-grid,
  .share-layout,
  .review-summary {
    grid-template-columns: 1fr;
  }

  .pane-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .align-right {
    text-align: left;
  }

  .topbar {
    flex-direction: column;
    align-items: start;
  }
}

@media (max-width: 640px) {
  .sidebar,
  .reader-shell,
  .drawer,
  .modal {
    padding: 14px;
  }

  .reading-stage,
  .topbar,
  .modal-card {
    border-radius: 22px;
    padding: 16px;
  }

  .reader-pane {
    padding: 18px 16px;
  }

  .share-preview {
    padding: 22px;
  }

  .share-quote {
    font-size: 22px;
  }
}
