:root {
  --ink: #172525;
  --muted: #6c7b78;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #e5e8e2;
  --teal: #1f5c59;
  --teal-dark: #183b3b;
  --mint: #dceee7;
  --coral: #d87557;
  --gold: #d2a64a;
  --soft-shadow: 0 18px 50px rgba(24, 59, 59, 0.08);
}

* {
  box-sizing: border-box;
}

html.auth-pending #auth-view,
html.auth-pending #app-shell {
  visibility: hidden;
}

html {
  background: var(--paper);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(31, 92, 89, 0.035) 1px, transparent 1px) 0 0 / 40px 40px,
    var(--paper);
  font-family: Vazirmatn, "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.9;
}

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

.auth-card {
  width: min(100%, 430px);
  padding: 38px 34px 32px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  text-align: right;
}

.auth-brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 28px;
  place-items: center;
  border-radius: 12px;
  background: var(--teal-dark);
  color: #fff8e7;
  font-size: 24px;
  font-weight: 800;
}

.auth-card h1 {
  margin: 0;
  color: var(--teal-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  font-weight: 500;
  line-height: 1.25;
}

.auth-description {
  margin: 12px 0 26px;
  color: var(--muted);
  line-height: 1.9;
}

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

.auth-form label {
  color: var(--teal-dark);
  font-size: 0.88rem;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  margin: 0 0 10px;
  padding: 11px 13px;
  border: 1px solid #cfd9d4;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  direction: ltr;
  text-align: left;
}

.auth-form input:focus {
  outline: 2px solid rgba(31, 92, 89, 0.22);
  border-color: var(--teal);
}

.auth-error {
  margin: 2px 0 8px;
  color: #a43f32;
  font-size: 0.86rem;
  line-height: 1.8;
}

.auth-submit {
  margin-top: 4px;
  padding: 11px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--teal-dark);
  color: #fff;
  font-weight: 800;
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.6;
}

.google-auth {
  margin-top: 18px;
}

.google-auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
}

.google-auth-divider::before,
.google-auth-divider::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.google-login {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid #cfd9d4;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.google-login:hover,
.google-login:focus-visible {
  border-color: var(--teal);
  background: #f6faf8;
}

.google-mark {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #dadce0;
  border-radius: 50%;
  color: #4285f4;
  font-family: Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
}

.auth-switch {
  margin-top: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--teal);
  font-size: 0.88rem;
  font-weight: 700;
}

.logout-button {
  margin-right: auto;
  padding: 2px 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: transparent;
  color: #d6e7df;
  font-size: 0.76rem;
}

.logout-button:hover,
.logout-button:focus-visible {
  border-color: #f2ca67;
  color: #fff8e7;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 30px 22px 24px;
  background: var(--teal-dark);
  color: #f8fbf7;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 25px;
  color: inherit;
  text-decoration: none;
}

.brand-lockup:hover .brand-mark,
.brand-lockup:focus-visible .brand-mark {
  border-color: #f2ca67;
  color: #f2ca67;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9px;
  color: #fff8e7;
  font-size: 22px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--coral);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.sidebar .eyebrow {
  color: #9ad0bf;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.book-meta {
  padding: 19px 0 23px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.book-meta p {
  margin: 0 0 4px;
  color: #eef5ee;
  font-family: Georgia, serif;
  font-size: 0.96rem;
  direction: ltr;
  text-align: right;
}

.book-meta span {
  color: #a9bebb;
  font-size: 0.78rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 20px 0 16px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.search-icon {
  color: #a9cfc2;
  font-size: 1.25rem;
  line-height: 1;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: white;
  font-size: 0.84rem;
}

.search-box input::placeholder {
  color: #b4c8c3;
}

.chapter-nav {
  display: grid;
  gap: 3px;
  overflow-y: auto;
}

.part-label {
  margin: 16px 9px 6px;
  color: #7fa69b;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.chapter-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 9px;
  border: 0;
  border-right: 2px solid transparent;
  background: transparent;
  color: #c2d2cd;
  text-align: right;
  transition: 160ms ease;
}

.chapter-link:hover,
.chapter-link.active {
  border-right-color: var(--gold);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.chapter-number {
  min-width: 24px;
  color: #7fa69b;
  font-family: Georgia, serif;
  font-size: 0.9rem;
  direction: ltr;
}

.chapter-link.active .chapter-number {
  color: #f2ca67;
}

.chapter-name {
  flex: 1;
  font-size: 0.82rem;
  line-height: 1.55;
}

.podcast-section-nav {
  display: grid;
  gap: 2px;
  margin: 2px 0 8px;
  padding: 8px 0 7px;
  border-right: 1px solid rgba(154, 208, 191, 0.22);
}

.podcast-section-heading {
  margin: 0 10px 5px 0;
  color: #7fa69b;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.podcast-section-link {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 7px 10px 7px 5px;
  color: #a9c5bd;
  font-size: 0.73rem;
  line-height: 1.5;
  text-decoration: none;
  transition: 160ms ease;
}

.podcast-section-link:hover,
.podcast-section-link:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.podcast-section-index {
  flex: 0 0 18px;
  color: #7fa69b;
  font-family: Georgia, serif;
  direction: ltr;
  text-align: center;
}

.chapter-state {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #67847c;
}

.chapter-state.done {
  background: #b7e0b2;
  box-shadow: 0 0 0 3px rgba(183, 224, 178, 0.12);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 24px;
  color: #a9bebb;
  font-size: 0.72rem;
}

.legend-dot,
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b7e0b2;
}

.workspace {
  min-width: 0;
}

.page-hidden {
  display: none !important;
}

.library-view {
  max-width: 1370px;
  margin: 0 auto;
  padding: clamp(52px, 8vw, 105px) clamp(24px, 4vw, 64px) 90px;
}

.library-heading h2 {
  margin: 0;
  color: var(--teal-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  font-weight: 500;
  line-height: 1.15;
}

.library-heading .hero-subtitle {
  margin-top: 16px;
}

.library-filters {
  display: grid;
  gap: 18px;
  margin-top: 30px;
  max-width: 1050px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filter-label {
  min-width: 86px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.book-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.book-filter {
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.book-filter:hover,
.book-filter:focus-visible,
.book-filter.active {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.library-subsection {
  margin-top: 42px;
}

.library-subsection > .eyebrow {
  color: var(--muted);
  letter-spacing: 0.08em;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 320px));
  gap: 22px;
  max-width: 1050px;
  margin-top: 30px;
}

.book-grid-empty {
  grid-column: 1 / -1;
  margin-top: 20px;
}

.book-card {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.book-card:hover {
  transform: translateY(-3px);
  border-color: #a9c9bf;
  box-shadow: 0 22px 55px rgba(24, 59, 59, 0.13);
}

.book-card.unavailable {
  border-color: #e4e5df;
}

.book-card.unavailable .book-cover img {
  filter: saturate(0.84);
}

.book-cover {
  display: flex;
  align-items: stretch;
  justify-content: center;
  aspect-ratio: 1050 / 1379;
  width: min(100%, 220px);
  margin: 0 auto 21px;
  min-height: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #f8f7f3;
}

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

.book-card-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.book-card h3 {
  margin: 0;
  color: var(--teal-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.book-card .english-title {
  margin: 7px 0 0;
  color: var(--muted);
  direction: ltr;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.87rem;
  text-align: right;
}

.book-card .book-authors {
  margin: 17px 0 0;
  color: #566966;
  font-size: 0.76rem;
}

.book-card .book-description {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.75;
}

.book-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 17px;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
}

.book-card-footer span:last-child {
  color: var(--coral);
  font-size: 1rem;
}

.unavailable-view {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 620px);
  align-items: center;
  gap: clamp(30px, 6vw, 90px);
  max-width: 1050px;
  margin: 0 auto;
  padding: clamp(55px, 9vw, 115px) clamp(24px, 4vw, 64px) 100px;
}

.unavailable-cover-wrap {
  width: min(100%, 260px);
  aspect-ratio: 420 / 620;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8f7f3;
  box-shadow: var(--soft-shadow);
}

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

.unavailable-copy h2 {
  max-width: 680px;
  margin: 0;
  color: var(--teal-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 500;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.unavailable-english-title {
  margin: 14px 0 0;
  color: var(--muted);
  direction: ltr;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  text-align: right;
}

.unavailable-authors {
  margin: 18px 0 0;
  color: #566966;
  font-size: 0.83rem;
}

.unavailable-introduction {
  max-width: 700px;
  margin-top: 30px;
  color: var(--ink);
  font-size: 1rem;
  line-height: 2;
}

.unavailable-introduction p {
  margin: 0 0 18px;
}

.unavailable-introduction p:last-child {
  margin-bottom: 0;
}

.book-introduction {
  margin-bottom: 34px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.book-introduction p:not(.eyebrow) {
  margin: 0 0 18px;
  color: var(--ink);
  line-height: 2;
}

.book-introduction p:last-child {
  margin-bottom: 0;
}

.unavailable-notice {
  margin-top: 24px;
}

.library-back-button {
  margin-top: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1370px;
  margin: 0 auto;
  padding: 19px clamp(24px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.77rem;
}

.breadcrumb strong {
  color: var(--ink);
}

.breadcrumb-separator {
  color: #b7bfbb;
  direction: ltr;
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  color: var(--teal);
  background: transparent;
  font-size: 0.79rem;
  font-weight: 800;
}

.icon-button span:first-child {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid #b8cfca;
  border-radius: 6px;
  font-size: 1rem;
}

.icon-button:hover,
.text-button:hover {
  color: var(--coral);
}

.chapter-hero,
.content-grid {
  max-width: 1370px;
  margin: 0 auto;
  padding-right: clamp(24px, 4vw, 64px);
  padding-left: clamp(24px, 4vw, 64px);
}

.chapter-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  padding-top: clamp(43px, 7vw, 88px);
  padding-bottom: 43px;
}

.chapter-hero h2 {
  max-width: 730px;
  margin: 0;
  color: var(--teal-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.2;
}

.hero-subtitle {
  max-width: 650px;
  margin: 19px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.progress-panel {
  width: 190px;
  padding-bottom: 6px;
}

.progress-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.7rem;
}

.progress-panel strong {
  display: block;
  margin-bottom: 12px;
  color: var(--teal-dark);
  font-family: Georgia, serif;
  font-size: 1.05rem;
  font-weight: 500;
  direction: ltr;
  text-align: right;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 20px;
  background: #dfe6e0;
}

.progress-track span {
  display: block;
  width: 9%;
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  transition: width 240ms ease;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: clamp(34px, 5vw, 88px);
  align-items: start;
  padding-bottom: 80px;
}

.article {
  min-width: 0;
  max-width: 780px;
  padding-top: 7px;
  overflow-wrap: break-word;
}

.translation-guide {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 28px;
  padding: 11px 13px;
  border: 1px solid #d8e3de;
  border-radius: 6px;
  background: #f4f8f4;
  color: #59716b;
  font-size: 0.8rem;
}

.guide-mark {
  display: inline-grid;
  min-width: 27px;
  height: 22px;
  place-items: center;
  border-radius: 4px;
  background: var(--teal);
  color: white;
  direction: ltr;
  font: 0.67rem/1 "SFMono-Regular", Consolas, monospace;
}

.translation-block {
  margin: 0 0 24px;
}

.translation-trigger {
  position: relative;
  display: block;
  width: 100%;
  padding: 0 31px 0 5px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: right;
  transition: background 150ms ease, box-shadow 150ms ease;
}

.translation-trigger:hover,
.translation-block.is-open > .translation-trigger,
.list-translation-item.is-open > .translation-trigger {
  background: rgba(220, 238, 231, 0.35);
  box-shadow: inset -3px 0 0 var(--coral);
}

.translation-trigger:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

.translation-copy {
  margin: 0;
}

.translation-heading .translation-copy {
  margin: 52px 0 17px;
}

.translation-code .translation-copy {
  margin: 0;
}

.translation-quote .translation-copy {
  margin: 0;
  white-space: pre-line;
}

.translation-figure .translation-copy {
  margin: 0;
}

.translation-figure .translation-trigger {
  padding-left: 31px;
}

.translation-note.translation-copy {
  white-space: pre-line;
}

.figure-media {
  margin: 0;
  padding: 0 4px;
  text-align: center;
}

.figure-image {
  display: block;
  width: min(100%, 680px);
  height: auto;
  margin: 0 auto;
  border: 1px solid #cbd9d4;
  background: #fff;
}

.figure-media figcaption {
  margin-top: 9px;
  color: #637a73;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.84rem;
  font-style: italic;
  line-height: 1.7;
  text-align: right;
}

.translation-affordance {
  position: absolute;
  top: 8px;
  left: 7px;
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid #b7ccc5;
  border-radius: 50%;
  color: var(--teal);
  font-size: 0.85rem;
  line-height: 1;
  transition: transform 150ms ease, background 150ms ease;
}

.translation-block.is-open .translation-affordance,
.list-translation-item.is-open .translation-affordance {
  transform: rotate(180deg);
  background: var(--mint);
}

.original-capsule {
  margin: 9px 5px 0 0;
  padding: 13px 15px 15px;
  border: 1px solid #d9e4df;
  border-right: 3px solid var(--teal);
  border-radius: 5px;
  background: #f3f7f5;
  animation: capsule-in 150ms ease-out;
}

.original-capsule-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #658078;
  font-size: 0.7rem;
  font-weight: 800;
}

.original-language {
  direction: ltr;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}

.original-copy {
  color: #3f504d;
  direction: ltr;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.94rem;
  line-height: 1.85;
  text-align: left;
  white-space: pre-line;
}

.original-code {
  margin: 0;
  padding: 0;
  overflow-x: auto;
  background: transparent;
  color: #30403e;
  font: 0.82rem/1.8 "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
}

.original-chapter-content {
  direction: ltr;
  text-align: left;
}

.original-book-html {
  direction: ltr;
  max-width: 100%;
  color: #30403e;
  font-family: Georgia, "Times New Roman", serif;
  text-align: left;
}

.original-book-html h1,
.original-book-html h2,
.original-book-html h3,
.original-book-html h4,
.original-book-html h5,
.original-book-html h6 {
  direction: ltr;
  color: var(--teal-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
}

.original-book-html h1 {
  margin: 8px 0 28px;
  font-size: 2rem;
}

.original-book-html h2 {
  margin: 44px 0 15px;
  font-size: 1.65rem;
}

.original-book-html h3,
.original-book-html h4,
.original-book-html h5,
.original-book-html h6 {
  margin: 34px 0 13px;
  font-size: 1.3rem;
}

.original-book-html p {
  direction: ltr;
  color: #30403e;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.85;
  text-align: left;
}

.original-book-html blockquote {
  margin: 24px 0 30px;
  padding: 3px 20px;
  border-left: 3px solid var(--coral);
  color: #536762;
  font-style: italic;
}

.original-book-html [data-type="attribution"] {
  color: #6a7d77;
  font-size: 0.88rem;
  font-style: normal;
  text-align: right;
}

.original-book-html pre {
  overflow-x: auto;
  margin: 20px 0 25px;
  padding: 14px 16px;
  border: 1px solid #d9e4df;
  border-radius: 5px;
  background: #f3f7f5;
  color: #263b37;
  direction: ltr;
  font: 0.84rem/1.75 "SFMono-Regular", Consolas, monospace;
  text-align: left;
  white-space: pre;
}

.original-book-html code {
  direction: ltr;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

.original-book-html figure {
  margin: 28px auto;
  text-align: center;
}

.original-book-html img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.original-book-html figcaption {
  margin-top: 8px;
  color: #637a73;
  font-size: 0.86rem;
  font-style: italic;
  line-height: 1.7;
}

.original-book-html ul,
.original-book-html ol {
  margin: 0 0 24px;
  padding-left: 28px;
  direction: ltr;
  line-height: 1.8;
}

.original-book-html table {
  width: 100%;
  margin: 24px 0;
  border-collapse: collapse;
  direction: ltr;
  font-size: 0.9rem;
}

.original-book-html th,
.original-book-html td {
  padding: 8px 10px;
  border: 1px solid #d9e4df;
  text-align: left;
}

.original-book-html th {
  background: #f3f7f5;
}

.original-only-copy {
  margin: 0 0 24px;
  color: #3f504d;
  direction: ltr;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.9;
  text-align: left;
  white-space: pre-line;
}

.original-only-heading {
  margin: 48px 0 17px;
  color: var(--teal-dark);
  direction: ltr;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
}

.original-only-note {
  margin: 16px 0 24px;
  padding: 13px 15px;
  border: 1px solid #d9e4df;
  border-left: 3px solid var(--teal);
  border-radius: 5px;
  background: #f3f7f5;
  color: #3f504d;
  direction: ltr;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.85;
  text-align: left;
  white-space: pre-line;
}

.translation-list {
  margin: 0 0 27px;
  padding-right: 29px;
  color: #30403e;
}

.list-translation-item {
  margin-bottom: 11px;
  padding-right: 4px;
}

.list-translation-item .translation-trigger {
  padding-right: 8px;
}

.list-translation-item .translation-affordance {
  top: 1px;
}

.translation-table .translation-trigger {
  padding-right: 5px;
  overflow-x: auto;
}

.translation-table .translation-affordance {
  top: 10px;
}

@keyframes capsule-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article > p,
.article > ul,
.article > ol,
.article > blockquote,
.article > table,
.article > .figure-note,
.article > .translation-note {
  margin-right: 0;
  margin-left: 0;
}

.article p {
  margin-top: 0;
  margin-bottom: 21px;
  color: #30403e;
  font-size: 1rem;
}

.article h3 {
  margin: 52px 0 17px;
  color: var(--teal-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1.35;
}

.article h4 {
  margin: 35px 0 13px;
  color: var(--teal);
  font-size: 1.15rem;
}

.article strong {
  color: var(--teal-dark);
}

.article em {
  color: #586965;
}

.article code,
.note-rail code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #edf1ec;
  color: #a34e38;
  direction: ltr;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
}

.article pre {
  max-width: 100%;
  direction: ltr;
  margin: 19px 0 25px;
  padding: 18px 20px;
  overflow-x: auto;
  border-right: 3px solid var(--coral);
  border-radius: 4px;
  background: #1c2d2c;
  color: #e7f2e9;
  font: 0.86rem/1.85 "SFMono-Regular", Consolas, monospace;
  text-align: left;
  white-space: pre-wrap;
}

.article blockquote {
  margin: 25px 0;
  padding: 17px 22px;
  border-right: 3px solid var(--gold);
  background: #fff8e8;
  color: #5d5137;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
}

.article ol {
  margin-top: 12px;
  margin-bottom: 26px;
  padding-right: 26px;
  color: #30403e;
}

.article li {
  margin-bottom: 8px;
  padding-right: 5px;
}

.figure-note,
.translation-note {
  margin: 25px 0 27px;
  padding: 14px 16px;
  border: 1px solid #d8e3de;
  border-radius: 6px;
  background: #f4f8f4;
  color: #59716b;
  font-size: 0.88rem;
}

.figure-note strong,
.translation-note strong {
  display: block;
  margin-bottom: 3px;
  color: var(--teal);
  font-size: 0.76rem;
}

.article table {
  display: table;
  max-width: 100%;
  overflow-x: auto;
  width: 100%;
  margin: 27px 0 32px;
  border-collapse: collapse;
  font-size: 0.87rem;
}

.article th,
.article td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: right;
}

.article th {
  color: var(--teal-dark);
  background: #edf5f0;
  font-weight: 800;
}

.article td:first-child,
.article th:first-child {
  direction: ltr;
  text-align: left;
}

.chapter-placeholder {
  padding: 30px 0;
}

.chapter-placeholder .placeholder-mark {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 10px;
  background: var(--mint);
  color: var(--teal-dark);
  font-size: 1.45rem;
  font-weight: 800;
}

.chapter-placeholder h3 {
  margin-top: 0;
}

.chapter-placeholder p {
  max-width: 610px;
}

.context-rail {
  position: sticky;
  top: 22px;
  padding-top: 9px;
}

.rail-section {
  padding: 18px 0 22px;
  border-bottom: 1px solid var(--line);
}

.rail-section:first-child {
  padding-top: 0;
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-list {
  display: grid;
  gap: 7px;
  margin: 15px 0 0;
  padding: 0;
  list-style: none;
}

.section-list li {
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.55;
}

.section-list li::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border: 1px solid var(--coral);
  border-radius: 50%;
  content: "";
}

.source-rail p,
.note-rail p {
  margin: 10px 0 15px;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.8;
}

.text-button {
  padding: 0;
}

.empty-state {
  padding: 35px 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.marker-button.is-saved span:first-child {
  border-color: var(--gold);
  background: #fff4cd;
  color: #8d6815;
}

.selection-toolbar {
  position: fixed;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid #cad8d1;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 35px rgba(24, 59, 59, 0.18);
  transform: translate(-50%, -100%);
}

.selection-toolbar-label {
  margin-left: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.highlight-color {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #b6c8c0;
}

.color-yellow { background: #f4d96b; }
.color-green { background: #9cd8a7; }
.color-blue { background: #9ecbf2; }
.color-pink { background: #f3b6cb; }
.color-orange { background: #f3ad70; }
.color-purple { background: #c6a7e8; }
.color-teal { background: #83d5cc; }
.color-red { background: #ef9b9b; }
.color-gray { background: #c6cfce; }

.custom-highlight-color {
  position: relative;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 50%;
  background: conic-gradient(#f44336, #ffeb3b, #4caf50, #2196f3, #9c27b0, #f44336);
  box-shadow: 0 0 0 1px #b6c8c0;
  color: #fff;
  cursor: pointer;
}
.custom-highlight-color span { font-size: 1rem; line-height: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.custom-highlight-color input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.selection-action {
  padding: 2px 8px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
}

.user-highlight {
  border-radius: 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: pointer;
}

.user-highlight.color-yellow { background: #f9e68c; }
.user-highlight.color-green { background: #b8e7be; }
.user-highlight.color-blue { background: #b8daf6; }
.user-highlight.color-pink { background: #f6c8d8; }
.user-highlight.color-orange { background: #f8c18e; }
.user-highlight.color-purple { background: #d7bdef; }
.user-highlight.color-teal { background: #a5e2db; }
.user-highlight.color-red { background: #f3b8b8; }
.user-highlight.color-gray { background: #d9dfde; }
.user-note { border-bottom: 2px dotted var(--coral); cursor: pointer; }

.annotation-count {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--mint);
  color: var(--teal-dark);
  font-size: 0.7rem;
  text-align: center;
}

.annotation-list { display: grid; gap: 9px; margin-top: 13px; }
.annotation-item {
  position: relative;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-right: 3px solid #f4d96b;
  border-radius: 6px;
  background: #fcfdfb;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.75;
}
.annotation-item.color-green { border-right-color: #80c98a; }
.annotation-item.color-blue { border-right-color: #7eb7e9; }
.annotation-item.color-pink { border-right-color: #e79ab5; }
.annotation-item.color-orange { border-right-color: #e49a5e; }
.annotation-item.color-purple { border-right-color: #a77bce; }
.annotation-item.color-teal { border-right-color: #5cbdb2; }
.annotation-item.color-red { border-right-color: #d46b6b; }
.annotation-item.color-gray { border-right-color: #9eaba9; }
.annotation-item blockquote { margin: 0 0 4px; color: var(--ink); font-size: 0.76rem; }
.annotation-item p { margin: 0; }
.annotation-item-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.annotation-delete { padding: 0; border: 0; background: transparent; color: #a43f32; font-size: 0.7rem; }

.note-dialog {
  width: min(92vw, 450px);
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--soft-shadow);
}
.note-dialog::backdrop { background: rgba(24, 59, 59, 0.3); }
.note-dialog h2 { margin: 0 0 15px; color: var(--teal-dark); font-family: Georgia, serif; font-size: 1.5rem; font-weight: 500; }
.note-dialog textarea { width: 100%; padding: 10px; border: 1px solid #cfd9d4; border-radius: 8px; resize: vertical; }
.note-dialog textarea:focus { outline: 2px solid rgba(31, 92, 89, 0.22); border-color: var(--teal); }
.note-dialog-actions { display: flex; justify-content: flex-start; gap: 15px; align-items: center; margin-top: 15px; }
.note-dialog-actions .auth-submit { margin: 0; }

@media (max-width: 780px) {
  .selection-toolbar { max-width: calc(100vw - 20px); transform: translate(-50%, 0); }
  .selection-toolbar-label { display: none; }
  .context-rail { position: static; }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 238px minmax(0, 1fr);
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr) 205px;
    gap: 32px;
  }
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    min-height: auto;
    padding: 18px 18px 14px;
  }

  .brand-lockup {
    padding-bottom: 15px;
  }

  .book-meta {
    display: none;
  }

  .search-box {
    margin: 14px 0 7px;
  }

  .chapter-nav {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .part-label {
    display: none;
  }

  .chapter-link {
    min-width: max-content;
    padding: 8px 9px;
    border-right: 0;
    border-bottom: 2px solid transparent;
  }

  .chapter-link:hover,
  .chapter-link.active {
    border-bottom-color: var(--gold);
  }

  .chapter-state {
    display: none;
  }

  .podcast-section-nav {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    gap: 12px;
    padding: 15px 18px;
  }

  .topbar-actions {
    flex: 0 0 auto;
  }

  .library-view {
    padding: 45px 18px 60px;
  }

  .library-subsection {
  margin-top: 42px;
}

.library-subsection > .eyebrow {
  color: var(--muted);
  letter-spacing: 0.08em;
}

.book-grid {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 40px;
  }

  .book-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 16px;
  }

  .book-cover {
    width: min(100%, 215px);
    margin-bottom: 19px;
  }

  .unavailable-view {
    display: block;
    padding: 45px 18px 70px;
  }

  .unavailable-cover-wrap {
    width: min(100%, 215px);
    margin: 0 auto 32px;
  }

  .breadcrumb span:first-child,
  .breadcrumb-separator {
    display: none;
  }

  .chapter-hero {
    display: block;
    padding: 40px 18px 30px;
  }

  .chapter-hero h2 {
    font-size: 2.2rem;
  }

  .hero-subtitle {
    font-size: 0.94rem;
  }

  .progress-panel {
    width: 100%;
    margin-top: 28px;
  }

  .content-grid {
    display: block;
    padding: 0 18px 60px;
  }

  .article {
    max-width: none;
  }

  .article p {
    font-size: 0.96rem;
  }

  .article h3 {
    font-size: 1.6rem;
  }

  .article h4 {
    font-size: 1.08rem;
  }

  .article pre {
    padding: 14px 15px;
    font-size: 0.76rem;
    line-height: 1.75;
  }

  .article blockquote {
    padding: 14px 16px;
    font-size: 0.96rem;
  }

  .article table {
    display: block;
    font-size: 0.78rem;
  }

  .figure-image {
    width: 100%;
  }

  .figure-media {
    padding: 0;
  }

  .figure-media figcaption {
    padding: 0 4px;
    font-size: 0.78rem;
  }

  .article th,
  .article td {
    min-width: 120px;
  }

  .context-rail {
    position: static;
    margin-top: 50px;
  }
}
