.shj-page {
  --shj-border: #d9cfc2;
  --shj-surface: #fffcf7;
  --shj-muted: #857a7a;
  --shj-accent: #795548;
  --shj-accent-hover: #6d4c41;
  --shj-accent-soft: #f5efe6;
  --shj-ink: #3e3e3e;
  --shj-shadow: 0 1px 4px rgba(121, 85, 72, 0.1);
  --shj-font: "Microsoft YaHei", "MicrosoftYaHei", sans-serif;
  --shj-scroll-margin-top: 88px;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
  padding-bottom: 2.5rem;
  color: var(--shj-ink);
  font-family: var(--shj-font);
}

html:has(main.shj-reader-page) {
  scroll-padding-top: 88px;
}

.shj-page .page-heading,
.shj-chapter-title {
  margin: 0 0 10px;
  color: var(--shj-accent-hover);
  font-weight: 500;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.shj-hero,
.shj-reader-bar,
.shj-detail-card,
.shj-read-unit,
.shj-search-results {
  border: 1px solid var(--shj-border);
  border-radius: 4px;
  background: var(--shj-surface);
  box-shadow: var(--shj-shadow);
}

.shj-read-unit {
  border-radius: 2px;
}

.shj-hero {
  margin-bottom: 1.25rem;
  padding: 18px 18px 16px;
  overflow: hidden;
}

.shj-hero .page-heading,
.shj-hero .shj-lead,
.shj-hero .shj-meta {
  padding-left: 0;
  padding-right: 0;
  margin: 0;
}

.shj-hero .page-heading {
  margin-bottom: 8px;
}

.shj-lead,
.shj-muted,
.shj-disclaimer {
  margin: 0 0 1.25rem;
  color: var(--shj-muted);
  font-size: 14px;
  line-height: 1.65;
}
.shj-meta-label,
.shj-filter-label {
  margin-right: 6px;
  color: var(--shj-muted);
  font-size: 13px;
}

.shj-section-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--shj-accent-hover);
}

.shj-hub-section {
  margin-bottom: 1.75rem;
}

.shj-hub-grid,
.shj-hub-links {
  display: grid;
  gap: 12px;
}

.shj-hub-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.shj-hub-links {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.shj-card-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shj-entity-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.shj-entity-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--shj-border);
  border-radius: 6px;
  background: var(--shj-surface);
  color: inherit;
  text-decoration: none;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.shj-entity-type {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--shj-accent);
  background: var(--shj-accent-soft);
  white-space: nowrap;
}

.shj-entity-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--shj-accent-hover);
}

.shj-entity-item:hover {
  border-color: var(--shj-accent);
  background: var(--shj-accent-soft);
}

.shj-entity-item:focus-visible {
  outline: 2px solid var(--shj-accent);
  outline-offset: 2px;
}

.shj-hub-card,
.shj-juan-card,
.shj-card {
  display: flex;
  gap: 4px;
  min-height: 44px;
  padding: 16px;
  border: 1px solid var(--shj-border);
  background: var(--shj-surface);
  color: inherit;
  text-decoration: none;
}

.shj-hub-card {
  flex-direction: column;
  border-radius: 8px;
  box-shadow: var(--shj-shadow);
}

.shj-juan-card {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  border-radius: 2px;
}

.shj-card {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  border-radius: 2px;
}

.shj-juan-copy,
.shj-card-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.shj-hub-card:hover,
.shj-juan-card:hover,
.shj-card:hover,
.shj-btn-ghost:hover {
  border-color: var(--shj-accent);
  background: var(--shj-accent-soft);
}

.shj-hub-card:focus-visible,
.shj-juan-card:focus-visible,
.shj-card:focus-visible,
.shj-btn-ghost:focus-visible,
.shj-btn-primary:focus-visible,
.shj-nav-list a:focus-visible,
.shj-search-input:focus-visible,
.shj-filter-input:focus-visible {
  outline: 2px solid var(--shj-accent);
  outline-offset: 2px;
}

.shj-hub-badge {
  display: inline-block;
  width: fit-content;
  margin-bottom: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--shj-accent);
  background: var(--shj-accent-soft);
}

.shj-hub-card-title,
.shj-card-title,
.shj-hub-link-label {
  font-weight: 600;
  color: var(--shj-accent-hover);
}

.shj-hub-card-title {
  margin: 0;
  font-size: 1.15rem;
}

.shj-hub-card-desc,
.shj-hub-link-desc {
  margin: 0;
  font-size: 13px;
  color: var(--shj-muted);
}

.shj-reader-bar {
  position: static;
  width: auto;
  margin-bottom: 14px;
  padding: 14px 16px;
  background-image: none;
}

.shj-reader-bar-row,
.shj-reader-bar-aside,
.shj-toolbar-actions,
.shj-search-row,
.shj-filters,
.shj-actions,
.shj-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.shj-reader-bar-row {
  justify-content: space-between;
  margin-bottom: 10px;
}

.shj-reader-bar .shj-chapter-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  font-family: "SiYuanSongTi", "MicrosoftYaHei", sans-serif;
}

.shj-chapter-face {
  display: block;
  max-width: 40em;
  margin-bottom: 14px;
}

.shj-kicker {
  margin: 8px 0 0;
  font-family: "SiYuanSongTi", "MicrosoftYaHei", sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--shj-accent-hover);
}

.shj-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  font-size: 14px;
}

.shj-layer-toggle {
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(121, 85, 72, 0.06);
}

.shj-btn-ghost,
.shj-btn-primary,
.shj-search-input,
.shj-filter-input {
  min-height: 36px;
}

.shj-btn-ghost,
.shj-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.shj-btn-ghost {
  border: 1px solid var(--shj-border);
  background: var(--shj-surface);
  color: #3d3834;
}

.shj-btn-primary {
  border: none;
  border-radius: 8px;
  background: var(--shj-accent);
  color: #fff;
}

.shj-btn-primary:hover {
  background: var(--shj-accent-hover);
  color: #fff;
}

.shj-search-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 520px;
}

.shj-search-row {
  width: 100%;
}

.shj-search-input,
.shj-filter-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--shj-border);
  border-radius: 6px;
  background: #fff;
  font: inherit;
}

.shj-filters {
  align-items: flex-end;
  margin-bottom: 16px;
}

.shj-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.shj-filter-field--grow {
  flex: 1;
}

.shj-search-results {
  margin-top: 12px;
  padding: 12px;
  scroll-margin-top: var(--shj-scroll-margin-top);
}

.shj-search-results a,
.shj-citation-source a,
.shj-original a {
  color: var(--shj-accent);
}

.shj-search-results a:hover,
.shj-citation-source a:hover {
  color: var(--shj-accent-hover);
}

.shj-reader-layout {
  display: grid;
  grid-template-columns: minmax(168px, 220px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.shj-reader-nav {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 12px 10px;
  border: 1px solid var(--shj-border);
  border-radius: 4px;
  background: var(--shj-surface);
}

.shj-nav-title {
  margin: 4px 8px 8px;
  font-family: "SiYuanSongTi", "MicrosoftYaHei", sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--shj-accent-hover);
}

.shj-nav-title + .shj-nav-list {
  margin-bottom: 14px;
}

.shj-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shj-nav-list--juans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 6px;
}

.shj-nav-list a {
  display: block;
  min-height: 32px;
  padding: 6px 8px;
  border-left: 3px solid transparent;
  border-radius: 0 4px 4px 0;
  color: #333;
  font-size: 13px;
  line-height: 1.45;
  text-decoration: none;
}

.shj-nav-list a.is-active,
.shj-nav-list a:hover {
  background: var(--shj-accent-soft);
  color: var(--shj-accent-hover);
}

.shj-nav-list a.is-active {
  border-left-color: var(--shj-accent);
  font-weight: 600;
}

.shj-reader-workspace {
  min-width: 0;
}

.shj-read-flow {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: none;
}

.shj-read-unit,
.shj-detail-card,
.shj-sentence-pair {
  scroll-margin-top: var(--shj-scroll-margin-top);
}

.shj-read-unit,
.shj-detail-card {
  padding: 16px 14px;
  background: #fff;
}

.shj-original,
.shj-trans,
.shj-summary {
  margin: 0;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.shj-original {
  font-size: 1.06rem;
  text-wrap: pretty;
}

.shj-entry {
  display: block;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--shj-border);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(63, 52, 40, 0.06);
}

.shj-entry--split {
  display: grid;
  grid-template-columns: minmax(200px, 42%) minmax(0, 1fr);
  align-items: stretch;
}

.shj-entry-media {
  min-width: 0;
  min-height: 200px;
}

.shj-entry-body {
  padding: 14px 16px;
  min-width: 0;
}

.shj-entry-body .shj-sentence-pair + .shj-sentence-pair {
  margin-top: 12px;
}

.shj-trans {
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  color: #4a4540;
  background: var(--shj-accent-soft);
  border-left: 3px solid var(--shj-accent);
  border-radius: 0 6px 6px 0;
}

.shj-trans[hidden] {
  display: none;
}

.shj-detail-card {
  margin-bottom: 14px;
}

.shj-citation-list,
.shj-card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shj-citation-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shj-citation-card {
  padding: 12px;
  border: 1px solid var(--shj-border);
  border-radius: 8px;
  background: #fff;
}

.shj-citation-source {
  margin: 8px 0 0;
  font-size: 13px;
}

.shj-actions,
.shj-pager {
  margin: 12px 0 16px;
}

.shj-plate {
  margin: 0 0 14px;
}

.shj-plate img {
  max-width: 100%;
  height: auto;
}

.shj-plate figcaption {
  margin-top: 6px;
  color: var(--shj-muted);
  line-height: 1.5;
}

.shj-map-board {
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
}

.shj-map-wrap {
  position: relative;
  width: 100%;
}

.shj-map-art {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

.shj-map-coord-layer {
  --map-inset: 8.5%;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.shj-map-pins {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

.shj-map-pin {
  --pin-x-num: 50;
  --pin-y-num: 50;
  position: absolute;
  left: calc(var(--map-inset) + (100% - 2 * var(--map-inset)) * var(--pin-x-num) / 100);
  top: calc(var(--map-inset) + (100% - 2 * var(--map-inset)) * var(--pin-y-num) / 100);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 5.8em;
  padding: 4px;
  text-decoration: none;
  color: inherit;
  z-index: 1;
  pointer-events: auto;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.shj-map-pin-dot {
  display: block;
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  border-radius: 50%;
  background: #faf4e8;
  border: 2px solid var(--shj-accent);
  box-shadow: 0 1px 6px rgba(63, 52, 40, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.shj-map-pin-label {
  display: block;
  padding: 3px 7px;
  font-size: clamp(10px, 2.6vw, 12px);
  line-height: 1.35;
  text-align: center;
  color: #3f3428;
  background: rgba(250, 244, 232, 0.92);
  border: 1px solid rgba(121, 85, 72, 0.45);
  border-radius: 6px;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 2px 8px rgba(26, 20, 16, 0.12);
}

.shj-map-pin--core .shj-map-pin-dot {
  border-color: #a67c52;
  background: #fff8ec;
}

.shj-map-pin--dahuang .shj-map-pin-dot {
  border-color: #c9785a;
}

.shj-map-pin--haiwai .shj-map-pin-dot {
  border-color: #6a8aa8;
}

.shj-map-pin--hainei .shj-map-pin-dot {
  border-color: #5a9078;
}

.shj-map-pin--wuzang .shj-map-pin-dot {
  border-color: #a08050;
}

.shj-map-pin:hover,
.shj-map-pin:focus-visible,
.shj-map-pin.is-active {
  z-index: 3;
  transform: translate(-50%, -50%) scale(1.04);
}

.shj-map-pin:hover .shj-map-pin-dot,
.shj-map-pin:focus-visible .shj-map-pin-dot,
.shj-map-pin.is-active .shj-map-pin-dot {
  transform: scale(1.15);
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(121, 85, 72, 0.2), 0 2px 10px rgba(63, 52, 40, 0.25);
}

.shj-map-pin:hover .shj-map-pin-label,
.shj-map-pin:focus-visible .shj-map-pin-label,
.shj-map-pin.is-active .shj-map-pin-label {
  background: #fff8ec;
  border-color: var(--shj-accent);
  font-weight: 600;
}

.shj-map-pin.is-dimmed {
  opacity: 0.42;
}

.shj-map-pin:focus-visible {
  outline: 2px solid var(--shj-accent);
  outline-offset: 3px;
}

.shj-map-legend {
  margin: 14px 0 0;
  padding-left: 0;
  list-style: none;
  color: var(--shj-muted);
  font-size: 13px;
  line-height: 1.7;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.shj-map-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: middle;
  border: 1px solid rgba(63, 52, 40, 0.25);
}

.shj-map-legend-swatch--dahuang {
  background: #d4a088;
}

.shj-map-legend-swatch--haiwai {
  background: #9cb8c8;
}

.shj-map-legend-swatch--hainei {
  background: #8aab96;
}

.shj-map-legend-swatch--wuzang {
  background: #c4a574;
}

.shj-map-legend-swatch--core {
  background: #f3e6cf;
}

.shj-frame {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 2.6 / 1;
  overflow: hidden;
  background: #f3eadc;
}

.shj-frame--hero,
.shj-juan-banner .shj-frame {
  aspect-ratio: 2.8 / 1;
}

.shj-frame--entry {
  height: 100%;
  min-height: 200px;
  aspect-ratio: auto;
}

.shj-citation-media {
  margin-bottom: 10px;
}

.shj-citation-media .shj-frame--citation {
  aspect-ratio: 16 / 10;
  min-height: 0;
}

.shj-frame-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.shj-juan-card {
  padding: 0;
  overflow: hidden;
}

.shj-juan-card .shj-juan-copy {
  padding: 10px 12px 12px;
}

.shj-hero .shj-frame {
  margin-bottom: 14px;
}

.shj-juan-banner {
  margin-bottom: 14px;
}

.shj-hero .shj-frame-img {
  animation: shj-fade 360ms ease-out;
}

@keyframes shj-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .shj-hero .shj-frame-img {
    animation: none;
  }
}

@media (max-width: 800px) {
  html:has(main.shj-reader-page) {
    scroll-padding-top: 84px;
  }

  .shj-page {
    --shj-scroll-margin-top: 84px;
  }

  .shj-hero,
  .shj-reader-bar {
    padding: 12px;
  }

  .shj-reader-layout,
  .shj-hub-links,
  .shj-filters {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .shj-reader-nav {
    position: static;
    top: auto;
    max-height: none;
  }

  .shj-entry--split {
    grid-template-columns: 1fr;
  }

  .shj-entry-media {
    min-height: 0;
  }

  .shj-frame--entry,
  .shj-citation-media .shj-frame--citation {
    height: auto;
    min-height: 0;
    aspect-ratio: auto;
    overflow: visible;
  }

  .shj-frame--entry .shj-frame-img,
  .shj-citation-media .shj-frame-img {
    position: static;
    inset: auto;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    object-position: center;
  }

  .shj-reader-workspace {
    order: 1;
  }

  .shj-reader-nav {
    order: 2;
  }

  .shj-reader-bar-aside,
  .shj-search-form {
    width: 100%;
    max-width: none;
  }

  .shj-filter-input {
    width: 100%;
  }

  .shj-entity-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .shj-map-pin {
    max-width: 4.6em;
    padding: 6px;
  }

  .shj-map-pin-dot {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
  }

  .shj-map-legend {
    flex-direction: column;
    gap: 6px;
  }
}
