:root {
  --bg: #f2fbfd;
  --surface: #ffffff;
  --surface-alt: #f5fafb;
  --surface-accent: #def4fa;
  --text: #182126;
  --muted: #61717a;
  --line: #cddde2;
  --accent: #46c1e2;
  --accent-strong: #1789ab;
  --accent-soft: #d9f4fb;
  --accent-wash: #effbfe;
  --accent-border: #b6e7f3;
  --warning: #ffe7ad;
  --header-height: 0px;
  --scroll-offset: 96px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-padding-top: var(--scroll-offset);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, #f8fcfd 0%, rgba(248, 252, 253, 0) 24rem),
    linear-gradient(180deg, #f6fbfc 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
}

#app {
  min-height: 100vh;
}

.app-shell {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 0.75rem;
  display: grid;
  gap: 0.75rem;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 80;
  padding: 0.85rem 1rem;
  background: linear-gradient(180deg, #ffffff 0%, #f9fcfc 100%);
  border: 1px solid var(--accent-border);
  border-radius: 1rem;
  box-shadow: 0 12px 30px rgba(70, 193, 226, 0.08);
}

.app-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: space-between;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.app-logo {
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
  flex: 0 0 auto;
}

.app-brand-text {
  min-width: 0;
}

/* Groups version badge + menu button on the right */
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.menu-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  width: 3.2rem;
  min-height: 3.2rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.8rem;
  background: var(--accent-wash);
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.menu-button:active {
  background: var(--accent-soft);
}

.menu-button-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.menu-button-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.app-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--accent-strong);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-version {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.app-subtitle {
  margin: 0.2rem 0 0;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.search-panel {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.45rem;
  position: relative;
}

/* Backdrop overlay injected by JS behind search results */
.search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(3, 10, 14, 0.88);
  animation: backdropFadeIn 0.18s ease forwards;
}

@keyframes backdropFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.search-panel.is-hidden {
  display: none;
}

.search-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.search-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.85rem;
  background: #fbfefe;
  color: var(--text);
  font: inherit;
}

.search-input:focus {
  outline: 2px solid transparent;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(70, 193, 226, 0.1);
}

.search-results {
  display: none;
  gap: 0.5rem;
}

.search-results.is-active {
  display: grid;
  position: fixed;
  top: var(--header-height, 0px);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  padding: 0.65rem;
  border: none;
  border-top: 1px solid var(--accent-border);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 8px 30px rgba(70, 193, 226, 0.16);
  backdrop-filter: blur(12px);
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.search-helper {
  margin: 0;
  color: var(--muted);
}

.search-result-list {
  display: grid;
  gap: 0.55rem;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 0.15rem 0.5rem;
  align-content: start;
}

.search-result {
  width: 100%;
  min-height: 3rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.85rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-alt) 100%);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.search-result:active {
  background: var(--accent-wash);
  border-color: var(--accent);
}

.search-result-title,
.search-result-meta,
.search-result-snippet {
  margin: 0;
}

/* .search-result-title now inline with badges */

.search-result-meta {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.search-result-snippet {
  margin-top: 0.4rem;
  color: var(--text);
}

/* Hide snippet text for "mentioned" results — show title+chapter only */
.search-result.is-mentioned .search-result-snippet {
  display: none;
}

.search-result.is-mentioned {
  opacity: 0.82;
}

.search-results.is-empty .search-helper {
  padding: 0.1rem 0.1rem 0;
}


.search-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.3rem 0.5rem;
  gap: 0.5rem;
}

.search-results-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.search-results-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  flex: 0 0 auto;
}

mark {
  padding: 0 0.15em;
  background: #ffe48f;
}

.app-layout {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.mobile-nav-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.mobile-nav-shell.is-open {
  pointer-events: auto;
}

.mobile-nav-overlay {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(9, 27, 34, 0.38);
  opacity: 0;
  transition: opacity 180ms ease;
  cursor: pointer;
}

.mobile-nav-shell.is-open .mobile-nav-overlay {
  opacity: 1;
}

.mobile-nav-panel {
  position: relative;
  width: min(250px, 82vw);
  height: 100%;
  transform: translateX(-100%);
  transition: transform 220ms ease;
  will-change: transform;
}

.mobile-nav-shell.is-open .mobile-nav-panel {
  transform: translateX(0);
}

.chapter-nav,
.chapter,
.guide-section,
.illustration-card,
.data-block,
.status {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: 1rem;
}

.chapter-nav {
  height: 100%;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border-radius: 0 1rem 1rem 0;
  background: linear-gradient(180deg, #fcfefe 0%, #f1f8f9 100%);
}

.nav-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--accent-strong);
}

.chapter-button-list {
  display: grid;
  gap: 0.5rem;
}

.nav-utility-list {
  margin-bottom: 1rem;
}

.chapter-button {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.chapter-button.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(70, 193, 226, 0.18);
}

.content-pane {
  display: grid;
  gap: 1rem;
  min-width: 0;
  scroll-padding-top: var(--scroll-offset);
}

.active-chapter-label {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.about-page,
.about-section-card,
.about-credits-card {
  padding: 1.25rem;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfd 100%);
}

.about-section-card,
.about-credits-card {
  scroll-margin-top: var(--scroll-offset);
}

.about-back-button {
  margin-top: 1rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.8rem;
  background: #ffffff;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.about-back-button:hover,
.about-back-button:focus-visible,
.about-tab-button:hover,
.about-tab-button:focus-visible,
.about-link:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(70, 193, 226, 0.1);
}

.about-tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.about-tab-button {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.about-credits-grid {
  display: grid;
  gap: 0.9rem;
}

.about-credit-group {
  padding: 1rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-alt) 100%);
}

.about-credit-heading,
.about-subsection-title {
  margin: 0 0 0.6rem;
  color: var(--accent-strong);
  font-size: 1rem;
  line-height: 1.35;
}

.about-credit-lines,
.about-subsections {
  display: grid;
  gap: 0.45rem;
}

.about-part-of {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--accent-border);
}

.about-part-of-label {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.about-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.about-link:hover {
  text-decoration: underline;
}

.about-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
}

.about-list-ordered {
  padding-left: 1.35rem;
}

.about-subsection {
  padding: 1rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-alt) 100%);
}

.about-quote {
  margin: 0;
  padding: 0.95rem 1rem;
  border-left: 4px solid var(--accent);
  border-radius: 0.8rem;
  background: var(--accent-wash);
  color: var(--text);
}

.chapter {
  padding: 1.25rem;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfd 100%);
}

.chapter-meta {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chapter-title {
  margin: 0 0 1.25rem;
  font-size: 1.7rem;
  line-height: 1.25;
  color: var(--accent-strong);
}

.chapter-sections,
.node-children {
  display: grid;
  gap: 0.9rem;
}

.guide-section {
  overflow: hidden;
  scroll-margin-top: var(--scroll-offset);
  background: linear-gradient(180deg, #fcfefe 0%, var(--surface-alt) 100%);
}

.chapter-intro-card {
  border-style: dashed;
  background: linear-gradient(180deg, #fdfefe 0%, var(--accent-wash) 100%);
}

.node-type-child_note {
  border-left: 4px solid var(--accent-border);
}

.node-type-administration_note {
  border-left: 4px solid var(--accent);
}

.node-depth-1 {
  margin-left: 0.45rem;
}

.node-depth-2,
.node-depth-3,
.node-depth-4 {
  margin-left: 0.9rem;
}

.section-summary {
  display: block;
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.1rem;
}

.section-summary::-webkit-details-marker {
  display: none;
}

.section-summary::after {
  content: "+";
  float: right;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.guide-section[open] .section-summary::after {
  content: "-";
}

.section-summary-main {
  display: grid;
  gap: 0.25rem;
  padding-right: 1.5rem;
}

.section-title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--accent-strong);
}

.section-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-content {
  display: grid;
  gap: 0.85rem;
  padding: 0 1.1rem 1.1rem;
}

.text-block {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-subheading {
  margin: 0.15rem 0 0.65rem;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--accent-strong);
}

.illustration-card,
.data-block {
  padding: 1rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-alt) 100%);
}

.illustration-header,
.data-block-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.illustration-badge,
.data-block-label,
.data-block-type {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.illustration-media {
  margin-bottom: 0.85rem;
}

.illustration-image-list {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
}

.illustration-placeholder {
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--accent-border);
  border-radius: 0.9rem;
  background: var(--accent-wash);
}

.illustration-placeholder-type {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.illustration-placeholder-note {
  font-size: 0.92rem;
  color: var(--muted);
}

.illustration-image {
  display: none;
  width: auto;
  max-width: min(100%, 54rem);
  height: auto;
  max-height: min(70vh, 34rem);
  object-fit: contain;
  border: 1px solid var(--accent-border);
  border-radius: 0.9rem;
  background: #ffffff;
}

.illustration-card.has-asset .illustration-placeholder {
  display: none;
}

.illustration-card.has-asset .illustration-image {
  display: block;
}

@media (min-width: 880px) {
  .illustration-image-list {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

.illustration-title {
  margin: 0.75rem 0 0.35rem;
  font-size: 1.05rem;
  line-height: 1.35;
}

.illustration-context,
.illustration-steps-label,
.data-block-helper,
.worksheet-notes-helper {
  margin: 0;
  color: var(--muted);
}

.illustration-status {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.illustration-steps-label {
  margin-top: 0.75rem;
  font-weight: 600;
}

.illustration-steps {
  margin: 0.55rem 0 0;
  padding-left: 1.2rem;
}

.data-card-list {
  display: grid;
  gap: 0.9rem;
}

.data-card {
  padding: 1rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.8rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-alt) 100%);
}

.data-card-title,
.data-block-title,
.worksheet-notes-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--accent-strong);
}

.data-fields {
  margin: 0;
  display: grid;
  gap: 0.55rem 0.9rem;
}

.data-key {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.data-value {
  margin: 0;
  word-break: break-word;
}

.data-bullet-list,
.reference-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.55rem;
}

.worksheet-template {
  gap: 0.8rem;
}

.worksheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.worksheet-toolbar-meta {
  display: grid;
  gap: 0.25rem;
}

.worksheet-storage-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.worksheet-toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.worksheet-reset {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.8rem;
  background: #ffffff;
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.worksheet-reset:hover,
.worksheet-reset:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(70, 193, 226, 0.1);
  outline: none;
}

.data-template-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.data-template-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: #ffffff;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 600;
}

.data-template-slots {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.worksheet-editor {
  display: grid;
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.worksheet-row {
  display: grid;
  gap: 0.75rem;
  padding: 0.95rem;
  border: 1px dashed var(--accent-border);
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, #f9fdfd 100%);
}

.worksheet-row-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.worksheet-grid {
  display: grid;
  gap: 0.75rem;
}

.worksheet-field {
  display: grid;
  gap: 0.35rem;
}

.worksheet-field-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.worksheet-input,
.worksheet-textarea {
  width: 100%;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.8rem;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.worksheet-input:focus,
.worksheet-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(70, 193, 226, 0.1);
}

.worksheet-textarea {
  min-height: 8rem;
  resize: vertical;
}

.data-template-slot {
  display: grid;
  gap: 0.55rem;
  padding: 0.9rem;
  border: 1px dashed var(--accent-border);
  border-radius: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, #f9fdfd 100%);
}

.data-template-slot-field {
  min-height: 2.4rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(184, 214, 220, 0.8);
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 0.9rem;
}

.data-template-more {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.worksheet-notes-box {
  margin-top: 0.9rem;
  padding: 1rem;
  border: 1px dashed var(--accent-border);
  border-radius: 0.9rem;
  background: #ffffff;
}

.unknown-block {
  margin: 0;
  padding: 0.9rem;
  overflow: auto;
  border-radius: 0.8rem;
  background: #111111;
  color: #f5f5f5;
}

.status {
  width: min(100% - 2rem, 36rem);
  margin: 2rem auto;
  padding: 1rem;
}

.status-error {
  border-color: #cf5f5f;
}

.search-active .back-to-top {
  display: none;
}

.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 35;
  padding: 0.8rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(70, 193, 226, 0.24);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (min-width: 768px) {
  html,
  body,
  #app {
    height: 100%;
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    height: 100dvh;
    padding: 0.85rem;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 430px);
    align-items: start;
    gap: 0.8rem 1rem;
    padding: 0.8rem 1rem;
  }

  .app-shell.is-about-mode .app-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-title {
    font-size: 1.15rem;
    -webkit-line-clamp: unset;
    overflow: visible;
    display: block;
  }

  .app-brand {
    gap: 0.7rem;
  }

  .app-logo {
    width: 2.6rem;
    height: 2.6rem;
  }

  .app-subtitle {
    margin: 0;
    font-size: 0.88rem;
  }

  .search-panel {
    margin-top: 0;
  }

  .search-label {
    display: none;
  }

  .search-input {
    padding: 0.68rem 0.85rem;
  }

  .menu-button {
    display: none;
  }

  .search-results.is-active {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    right: 0;
    bottom: auto;
    max-height: min(70vh, 540px);
    overflow-y: auto;
    border: 1px solid var(--accent-border);
    border-radius: 0.95rem;
    grid-template-rows: none;
    padding: 0.75rem;
  }

  .search-result-list {
    max-height: min(26rem, 50vh);
    height: auto;
    padding: 0 0.15rem;
  }

  .search-results-close {
    display: none;
  }


  .app-header-actions {
    gap: 0.75rem;
  }

  .app-layout {
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
  }

  .mobile-nav-shell {
    position: static;
    inset: auto;
    z-index: auto;
    pointer-events: auto;
    min-height: 0;
  }

  .mobile-nav-overlay {
    display: none;
  }

  .mobile-nav-panel {
    width: auto;
    height: auto;
    transform: none;
    min-height: 0;
  }

  .chapter-nav {
    position: sticky;
    top: 0;
    height: auto;
    max-height: calc(100dvh - var(--header-height) - 2rem);
    padding: 1.1rem;
    border-radius: 1rem;
  }

  .content-pane {
    min-height: 0;
    max-height: calc(100dvh - var(--header-height) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding-right: 0.35rem;
  }

  .chapter {
    padding: 1.5rem;
  }

  .about-page,
  .about-section-card,
  .about-credits-card {
    padding: 1.5rem;
  }

  .about-credits-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-content {
    padding: 0 1.25rem 1.25rem;
  }

  .data-fields {
    grid-template-columns: minmax(8rem, 12rem) 1fr;
  }

  .back-to-top {
    right: 1.5rem;
    bottom: 1.5rem;
  }

  .worksheet-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

/* ── UPDATE TOAST ─────────────────────────────────────────── */
.update-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(6rem);
  z-index: 9999;
  min-width: 280px;
  max-width: min(92vw, 480px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  pointer-events: none;
}

.update-toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.update-toast-inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  background: var(--accent-strong);
  border-radius: 1rem;
  box-shadow: 0 8px 28px rgba(10, 81, 89, 0.35);
  cursor: pointer;
  color: #ffffff;
}

.update-toast-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex: 0 0 auto;
}

.update-toast-text {
  font-size: 0.85rem;
  line-height: 1.35;
  flex: 1 1 auto;
  min-width: 0;
}

.update-toast-hint {
  font-size: 0.75rem;
  opacity: 0.75;
  white-space: nowrap;
  flex: 0 0 auto;
}

.update-toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  flex: 0 0 auto;
}

.update-toast-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ── A-Z DRUG & TOPIC INDEX ────────────────────────────────── */
.index-view {
  padding: 0;
}

.index-letterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: 1rem;
  margin-bottom: 0.75rem;
  position: sticky;
  top: 0.5rem;
  z-index: 10;
}

.index-letter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.5rem;
  background: var(--accent-wash);
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.index-letter-btn:hover,
.index-letter-btn.is-active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.index-letter-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.index-group {
  margin-bottom: 1rem;
}

.index-group-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}

.index-group-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
  flex: 0 0 auto;
}

.index-group-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.index-entry-list {
  display: grid;
  gap: 0.35rem;
}

.index-entry {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--accent-border);
  border-radius: 0.75rem;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.index-entry:active,
.index-entry:hover {
  background: var(--accent-wash);
  border-color: var(--accent);
}

.index-entry-title {
  flex: 1 1 auto;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
}

.index-entry-node {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-wash);
  border-radius: 0.4rem;
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
}

.index-entry-chapter {
  display: none;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

@media (min-width: 880px) {
  .index-entry-chapter {
    display: block;
  }
}

.chapter-button-index {
  background: linear-gradient(135deg, var(--accent-wash) 0%, var(--surface-accent) 100%);
}

.chapter-button-index.is-active {
  background: var(--accent);
  color: #ffffff;
}

/* ── SEARCH RELEVANCE BADGES ───────────────────────────────── */
.search-result-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-weight: 700;
}

.search-match-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex: 0 0 auto;
  vertical-align: middle;
}

.search-match-topic {
  background: var(--accent);
  color: #ffffff;
}

.search-match-mentioned {
  background: var(--warning);
  color: #6b4a00;
}

.search-section-divider {
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-top: 1px solid var(--accent-border);
  margin-top: 0.2rem;
}

.search-no-topic-hint {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  border-left: 3px solid var(--accent-border);
  border-radius: 0 0.4rem 0.4rem 0;
  background: var(--accent-wash);
}
