:root {
  /* Campaign Manager brand */
  --purple: #3d2260;
  --purple-deep: #2e1a48;
  --purple-soft: #5a3d80;
  --purple-light: #ede8f3;
  --gold: #fbc926;
  --gold-dark: #d4a91e;

  --bg: #f7f5fa;
  --bg-deep: #ede8f3;
  --surface: #fffcf7;
  --ink: #1a1a2e;
  --muted: #6b6b80;
  --warn-bg: #fff8e6;
  --line: rgba(61, 34, 96, 0.12);
  --shadow: 0 10px 30px rgba(61, 34, 96, 0.10);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tab-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #ede8f3 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(251, 201, 38, 0.22) 0%, transparent 45%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.45;
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 12px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.1rem 0.6rem;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(247, 245, 250, 0.88);
}
.topbar-brand { display: flex; gap: 0.7rem; align-items: center; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(145deg, var(--purple-deep), var(--purple));
  box-shadow: 0 4px 12px rgba(61, 34, 96, 0.25), inset 0 -2px 0 var(--gold);
}
.brand-name {
  font-family: var(--display);
  font-size: 1.35rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--purple);
}
.brand-sub, .topbar-user {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.topbar-user { font-weight: 600; color: var(--purple); }

.main { padding: 0.4rem 1.1rem 1.5rem; flex: 1; }

h1, h2, h3 {
  font-family: var(--display);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.4rem;
  color: var(--purple-deep);
}
h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); }
h2 { font-size: 1.2rem; }
.lede { color: var(--muted); margin: 0 0 1rem; font-size: 1.02rem; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.error { color: #a12622; font-weight: 600; }

.stack { display: grid; gap: 0.85rem; }
.card-stack { display: grid; gap: 0.85rem; }

.hero-panel {
  padding: 0.5rem 0 1rem;
  animation: rise 0.45s ease-out;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.panel, .panel-link, .login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.panel-link:active { transform: scale(0.985); }
.panel.warn { background: var(--warn-bg); border-color: rgba(251, 201, 38, 0.45); }

.callout {
  background: var(--purple-light);
  border-left: 4px solid var(--gold);
  padding: 0.75rem 0.9rem;
  border-radius: 0 12px 12px 0;
  margin: 0.8rem 0;
}

.btn, button.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-soft); }
.btn-secondary {
  background: transparent;
  color: var(--purple);
  border: 1.5px solid var(--purple);
}
.btn-secondary:hover {
  background: var(--purple-light);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; }

label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
}
input, select, textarea {
  font: inherit;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  width: 100%;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(61, 34, 96, 0.3);
  border-color: var(--purple);
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.quick {
  background: var(--purple);
  color: #fff;
  text-decoration: none;
  border-radius: 14px;
  padding: 0.95rem 0.8rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
}
.quick:nth-child(2n) {
  background: var(--gold);
  color: var(--purple-deep);
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(720px, 100%);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: rgba(255, 252, 247, 0.96);
  border-top: 1px solid var(--line);
  padding: 0.35rem 0.25rem calc(0.35rem + var(--safe-bottom));
  backdrop-filter: blur(12px);
  z-index: 20;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.2rem;
  border-radius: 12px;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab-icon { font-size: 1.15rem; line-height: 1; }
.tab.active {
  color: var(--purple);
  background: var(--purple-light);
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 0.5rem 1.2rem 0;
  margin: 0;
}

.login-card { margin-top: 1rem; animation: rise 0.4s ease; }

/* Faces */
.measure {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.75rem;
}
.measure h3 { font-size: 1.05rem; margin-bottom: 0.55rem; }
.face-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
}
.face-row.compact {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.face-btn {
  appearance: none;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 16px;
  min-height: 64px;
  font-size: 1.7rem;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.face-btn:active { transform: scale(0.96); }
.face-btn.selected {
  border-color: var(--purple);
  background: var(--purple-light);
  box-shadow: 0 0 0 2px rgba(61, 34, 96, 0.15);
}
.face-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 1.1rem;
}
.face-2, .face-3 { background: var(--warn-bg); }

.week-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  margin: 0.5rem 0 1rem;
}
.day-pill {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 0.55rem 0.6rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  font-size: 0.8rem;
  text-align: center;
}
.day-pill.active {
  border-color: var(--purple);
  background: var(--purple-light);
  box-shadow: inset 0 -2px 0 var(--gold);
}

.diary-date-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
  margin: 0.75rem 0 1.1rem;
}
.diary-picker-label {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted, #6b6570);
  min-width: 11rem;
}
.diary-picker-label input[type="date"] {
  font: inherit;
  font-weight: 500;
  color: inherit;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  min-height: 2.75rem;
}
.diary-date-display {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.diary-history { margin-top: 0.75rem; }
.diary-day-card.is-current {
  border-color: var(--purple);
  box-shadow: inset 0 -2px 0 var(--gold);
}
.diary-day-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.diary-day-link {
  display: grid;
  gap: 0.45rem;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}
.diary-day-link:hover strong { text-decoration: underline; }
.face-row.compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.face-chip.face-empty {
  color: var(--muted, #6b6570);
  background: transparent;
}
.diary-note {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.diary-note-label {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted, #6b6570);
}
.diary-note-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.option-list { display: grid; gap: 0.5rem; }
.option {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  cursor: pointer;
}
.option input { width: auto; margin-top: 0.2rem; }
.option.selected {
  border-color: var(--purple);
  background: var(--purple-light);
}

.assess-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.assess-head .lede { margin-bottom: 0.35rem; }
.choice-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.choice-pill {
  appearance: none;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.choice-pill .pill-meta {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}
.choice-pill.filled {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--gold);
}
.choice-pill.filled .pill-meta { color: rgba(255, 255, 255, 0.8); }
.choice-pill:active { transform: scale(0.98); }
button.linkish {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 700;
  color: var(--purple);
  text-align: left;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 2px;
  cursor: pointer;
}
.incomplete-list { margin-top: 0.55rem; }
.progress-dots span.done { background: var(--purple-soft); opacity: 0.85; }

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.35rem 0 1rem;
}
.filter-pill {
  appearance: none;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.filter-pill.active {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--gold);
}
.question-card .question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.question-status {
  font-weight: 700;
  color: var(--purple);
}
.question-card.is-closed .question-status { color: var(--muted); }
.question-text {
  display: block;
  width: 100%;
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--purple-deep);
  text-align: left;
  line-height: 1.35;
  text-decoration: none;
}
.question-text:hover { text-decoration: underline; text-decoration-color: var(--gold); }
.stamp-answered { margin: 0.35rem 0 0; font-size: 0.82rem; }
.entry-meta {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
}
.care-title {
  display: block;
  width: 100%;
  margin: 0 0 0.35rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--purple-deep);
  text-align: left;
  text-decoration: none;
}
.care-title:hover {
  text-decoration: underline;
  text-decoration-color: var(--gold);
}

.progress-dots {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  margin: 0.5rem 0 1rem;
}
.progress-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #c4b5d4;
  opacity: 0.55;
}
.progress-dots span.on {
  opacity: 1;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--purple);
}

.result-card {
  background: linear-gradient(160deg, var(--purple-deep), var(--purple), var(--purple-soft));
  color: #fff;
  border-radius: var(--radius);
  padding: 1.15rem;
  margin: 1rem 0;
  box-shadow: var(--shadow);
  border-bottom: 4px solid var(--gold);
}
.result-card .big { font-family: var(--display); font-size: 2.4rem; margin: 0.2rem 0; color: var(--gold); }
.result-card p { margin: 0.25rem 0; opacity: 0.95; }

.compare-grid {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .compare-grid { grid-template-columns: repeat(3, 1fr); }
}
.compare-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
}
.compare-card .score {
  font-family: var(--display);
  font-size: 2rem;
  color: var(--purple);
}

.prose { font-size: 1.02rem; }
.prose p { margin: 0.7rem 0; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 0.8rem 0;
}
.prose th, .prose td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.5rem;
  text-align: left;
}
.prose th { background: var(--purple-light); color: var(--purple-deep); }
.section-nav {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  margin: 0 0 1rem;
  padding-bottom: 0.25rem;
}
.chip {
  flex: 0 0 auto;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
}
.chip.active {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
  box-shadow: inset 0 -2px 0 var(--gold);
}

/* E-reader: document locked; only .book-page scrolls; pager below pane */
html.ebook-mode,
body.ebook-mode {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.ebook-mode {
  position: fixed;
  inset: 0;
  min-height: 0;
}
body.ebook-mode .app-shell {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px);
}
body.ebook-mode .topbar {
  position: relative;
  flex: 0 0 auto;
  backdrop-filter: none;
}
body.ebook-mode .disclaimer { display: none; }
body.ebook-mode .main {
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0.35rem 1.1rem 0.5rem;
}

.book {
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow: hidden;
}
.book-top {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.book-kicker {
  margin: 0;
  font-weight: 700;
  color: var(--purple);
  font-size: 0.95rem;
}
.book-progress {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.book-pdf {
  flex: 0 0 auto;
  text-decoration: none;
  font-weight: 700;
  color: var(--purple-deep);
  background: var(--gold);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* Fixed-size reading pane — this is the only scroll container */
.book-page {
  flex: 1 1 0;
  min-height: 0;
  height: 0; /* force flex child to take remaining space, not content height */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.1rem 1.4rem;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}
.book-page > h1:first-child,
.book-page > h2:first-child {
  margin-top: 0;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--gold);
  font-size: clamp(1.3rem, 4.5vw, 1.7rem);
  color: var(--purple-deep);
}

/* Nav sits under the reading pane, never overlaying it */
.book-pager {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.55rem;
  align-items: center;
  position: relative;
  z-index: 2;
  background: var(--bg);
  padding-top: 0.15rem;
}
.book-arrow {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: var(--purple);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, background 0.12s ease;
  padding: 0;
}
a.book-arrow { color: #fff; }
.book-arrow.next { justify-self: end; }
.book-arrow:not(.next) { justify-self: start; }
.book-arrow:active { transform: scale(0.94); }
.book-arrow.disabled,
.book-arrow:disabled {
  background: #d9d3e3;
  color: #8a8496;
  box-shadow: none;
  pointer-events: none;
}
.book-arrow-svg { display: block; }

.book-toc {
  align-self: center;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.35rem 0.55rem;
  max-width: 46vw;
}
.book-toc summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--purple);
  list-style: none;
  text-align: center;
  font-size: 0.85rem;
  padding: 0.35rem 0.4rem;
}
.book-toc summary::-webkit-details-marker { display: none; }
.book-toc[open] {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: min(92vw, 360px);
  max-height: 45vh;
  overflow: auto;
  padding: 0.55rem 0.65rem 0.75rem;
  box-shadow: var(--shadow);
  z-index: 6;
  max-width: none;
}
.book-toc ol {
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}
.book-toc li a {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.45rem 0.35rem;
  text-decoration: none;
  color: var(--ink);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}
.book-toc li a.current,
.book-toc li a:hover {
  background: var(--purple-light);
  color: var(--purple);
  font-weight: 700;
}
.toc-num {
  flex: 0 0 1.4rem;
  color: var(--muted);
  font-weight: 700;
}

.back-bar {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-start;
  background: var(--purple);
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.55rem 0.9rem;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.prose a {
  color: var(--purple);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 2px;
}
.prose a:visited { color: var(--purple-soft); }
.prose h2, .prose h3, .prose [id] { scroll-margin-top: 1rem; }
.prose p { font-size: 1.05rem; line-height: 1.55; }

/* Modern stacked cards (replaces wide tables) */
.info-cards {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0 1.25rem;
}
.info-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  box-shadow: 0 6px 18px rgba(61, 34, 96, 0.06);
}
.info-card.current {
  border-color: var(--purple);
  box-shadow: 0 0 0 2px rgba(61, 34, 96, 0.12), 0 8px 22px rgba(61, 34, 96, 0.1);
  background: linear-gradient(180deg, #fffdf6 0%, #fff 55%);
}
.info-card-title {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
  color: var(--purple-deep);
}
.info-card-row {
  margin: 0.35rem 0 0;
  display: grid;
  gap: 0.15rem;
}
.info-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.info-value {
  display: block;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.4;
}
.info-card.compact {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.95rem 1.1rem;
}
.info-card.compact .info-card-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.3;
}
.info-card.compact .info-value {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.med-card .info-card-title { color: var(--purple); }

/* Inline glossary terms */
button.term-ref {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  color: var(--purple-deep);
  text-decoration: underline;
  text-decoration-color: rgba(251, 201, 38, 0.95);
  text-underline-offset: 2px;
  cursor: pointer;
}
.glossary-entry {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.glossary-entry:last-child { border-bottom: 0; }
.glossary-term {
  display: inline;
  color: var(--purple-deep);
  font-weight: 700;
}
.glossary-def { color: var(--ink); }

.term-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(26, 26, 46, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--tab-h) + var(--safe-bottom));
}
.term-sheet[hidden] { display: none !important; }
.term-sheet-panel {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: 20px;
  padding: 1.15rem 1.2rem 1.35rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: rise 0.2s ease-out;
}
.term-sheet-panel h3 {
  margin: 0 1.5rem 0.55rem 0;
  font-size: 1.2rem;
}
.term-sheet-panel p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
  font-size: 1.02rem;
}
.term-sheet-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  appearance: none;
  border: 0;
  background: var(--purple-light);
  color: var(--purple);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 420px) {
  body.ebook-mode .main { padding: 0.25rem 0.75rem 0.35rem; }
  .book-arrow { width: 48px; height: 48px; }
}

.plain-list { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.plain-list a { color: var(--purple); font-weight: 600; }

.save-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 16px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--purple-deep);
  color: var(--gold);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}
.save-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
