:root {
  color-scheme: dark;
  --page: #101311;
  --panel: #191e1a;
  --panel-raised: #202720;
  --line: #39433b;
  --green: #9fc777;
  --red: #cb7466;
  --text: #e4e9df;
  --muted: #a5b0a1;
  --field: #111612;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--text); font: 15px/1.5 Georgia, 'Times New Roman', serif; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.sheet-nav { display: flex; align-items: center; gap: 1.25rem; padding: .8rem clamp(1rem, 4vw, 3rem); background: var(--panel); border-bottom: 1px solid var(--line); font: .9rem/1.4 system-ui, sans-serif; }
.sheet-brand { margin-right: auto; color: var(--green); font-weight: 700; }

.guide-page { width: min(1380px, 100%); margin: 0 auto; padding: 1.4rem clamp(1rem, 3vw, 2rem) 3rem; }
.guide-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 2rem; align-items: start; }
.content-container { min-width: 0; }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: 1rem; color: var(--muted); font: .85rem system-ui, sans-serif; }

.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-bottom: 1rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--green); }
.page-head h1 { margin: 0; font-size: 2rem; font-weight: 600; overflow-wrap: anywhere; }
.page-head p { margin: .25rem 0 0; color: var(--muted); font: .9rem system-ui, sans-serif; }
.badge { padding: .2rem .6rem; border: 1px solid var(--green); border-radius: 4px; color: var(--green); font: 600 .78rem system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }

.field-label, .global-search label, .node-search label, .spell-filters label { display: block; margin-bottom: .3rem; color: var(--muted); font: .73rem/1.3 system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; }
input[type="search"], select { width: 100%; min-height: 40px; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 4px; background: var(--field); color: var(--text); font: .95rem system-ui, sans-serif; }
input:focus, select:focus, button:focus-visible, summary:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
button { min-height: 40px; padding: .5rem .85rem; border: 1px solid var(--green); border-radius: 4px; background: transparent; color: var(--green); font: 600 .85rem system-ui, sans-serif; cursor: pointer; }
button:hover { background: color-mix(in srgb, var(--green) 12%, transparent); }

.global-search { margin-bottom: 1.25rem; }
.search-status { min-height: 1.2rem; margin-top: .3rem; color: var(--muted); font: .8rem system-ui, sans-serif; }
.global-results { list-style: none; margin: .4rem 0 0; padding: 0; max-height: 24rem; overflow-y: auto; border: 1px solid var(--green); border-radius: 4px; background: var(--panel); }
.global-results li + li { border-top: 1px solid var(--line); }
.global-results a { display: block; padding: .55rem .8rem .15rem; color: var(--text); text-decoration: none; }
.global-results a:hover, .global-results a:focus { background: color-mix(in srgb, var(--green) 15%, transparent); }
.global-results a strong { display: block; overflow-wrap: anywhere; }
.global-results a small { display: block; color: var(--muted); font: .75rem system-ui, sans-serif; overflow-wrap: anywhere; }
.global-result-snippet { display: block; padding: 0 .8rem .55rem; color: var(--muted); font: .82rem/1.4 system-ui, sans-serif; overflow-wrap: anywhere; }

.category-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem; }
.category-card { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1rem; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 4px; background: var(--panel); color: var(--text); }
.category-card:hover { border-color: var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); text-decoration: none; }
.category-card-title { font-weight: 600; overflow-wrap: anywhere; }
.category-card-count { flex: 0 0 auto; color: var(--muted); font: .78rem system-ui, sans-serif; }

.spell-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; align-items: end; gap: .75rem; margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.spell-filter-status { grid-column: 1 / -1; min-height: 1rem; color: var(--muted); font: .82rem system-ui, sans-serif; }

.guide-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.guide-tools span { margin-left: auto; color: var(--muted); font: .8rem system-ui, sans-serif; }

/* Entries */
.sections-wrapper { display: flex; flex-direction: column; gap: .9rem; }
.root-intro { max-width: 78ch; margin: 0 0 1.25rem; padding: .9rem 1rem; border-left: 3px solid var(--green); border-radius: 0 4px 4px 0; background: var(--panel); color: var(--muted); line-height: 1.7; }
.entry { border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 6px; background: var(--panel); scroll-margin-top: 1rem; box-shadow: 0 3px 12px rgba(0, 0, 0, .14); transition: border-color .15s, background .15s, box-shadow .15s; }
.entry[open] { border-color: color-mix(in srgb, var(--green) 50%, transparent); background: var(--panel-raised); box-shadow: 0 5px 18px rgba(0, 0, 0, .2); }
.entry > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .85rem; padding: 1rem 1.2rem; cursor: pointer; list-style: none; }
.entry > summary::-webkit-details-marker { display: none; }
.entry > summary::before { content: '\25B8'; flex: 0 0 auto; color: var(--green); font-size: 1.2rem; transition: transform .15s; }
.entry[open] > summary::before { transform: rotate(90deg); }
.entry > summary:hover { background: color-mix(in srgb, var(--green) 6%, transparent); }
.entry-body { padding: 1.1rem 1.35rem 1.35rem; border-top: 1px solid var(--line); }
.entry.is-target { border-color: var(--green); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 55%, transparent); animation: target-pulse 2.4s ease-out 1; }
@keyframes target-pulse { from { background: color-mix(in srgb, var(--green) 22%, transparent); } to { background: var(--panel); } }

.entry > summary .node-title { flex: 1 1 0; min-width: 0; }
.entry > summary .node-subtitle { flex: 1 0 100%; padding-left: 1.8rem; }
.node-title { display: flex; align-items: center; gap: .8rem; margin: 0; color: var(--text); font-size: 1.4rem; line-height: 1.3; font-weight: 650; overflow-wrap: anywhere; }
.node-icon { flex: 0 0 auto; width: 3.25rem; height: 3.25rem; border: 1px solid var(--line); border-radius: 6px; background: var(--field); object-fit: cover; }
.node-subtitle { margin: 0; color: var(--muted); font: .9rem/1.5 system-ui, sans-serif; font-weight: 400; }
.node-description, .node-content { max-width: 78ch; margin: .8rem 0 0; font-size: 1rem; line-height: 1.75; white-space: pre-line; overflow-wrap: anywhere; }
.node-description { color: #c8d0c5; }
.node-content { color: var(--text); }
.spell-text { max-width: 78ch; margin-top: 1rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 5px; }
.spell-description { background: rgba(17, 22, 18, .55); }
.spell-mechanics { border-left: 3px solid var(--green); background: var(--field); }
.spell-text-title { margin: 0; color: var(--green); font: 700 .75rem/1.4 system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.spell-text .node-description, .spell-text .node-content { margin-top: .45rem; }
.custom-field { max-width: 78ch; margin-top: 1rem; overflow-wrap: anywhere; white-space: pre-line; }
.custom-field-label { display: block; margin-bottom: .2rem; color: var(--muted); font: 600 .72rem/1.3 system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; }
.custom-field-value { margin: 0; line-height: 1.7; }
.custom-field-size-small .custom-field-value { font-size: .82rem; }
.custom-field-size-normal .custom-field-value { font-size: 1rem; }
.custom-field-size-large .custom-field-value { font-size: 1.25rem; }
.custom-field-bold .custom-field-value { font-weight: 700; }
.custom-field-italic .custom-field-value { font-style: italic; }
.custom-field-heading .custom-field-value { color: var(--green); font-weight: 700; }
.custom-field-quote { padding: .2rem 0 .2rem 1rem; border-left: 3px solid var(--green); color: #c3ccbf; }
.custom-field-callout { padding: .85rem 1rem; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 5px; background: var(--field); }
.custom-field-badge .custom-field-value { display: inline-block; padding: .25rem .7rem; border: 1px solid var(--green); border-radius: 999px; color: var(--green); font: .82rem system-ui, sans-serif; white-space: normal; }
.node-tags { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.tag-chip { padding: .2rem .65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--green); font: .76rem system-ui, sans-serif; text-transform: lowercase; }

.node-attributes { display: grid; grid-template-columns: minmax(140px, 28%) minmax(0, 1fr); gap: .55rem 1rem; margin: 1rem 0 0; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 5px; background: var(--field); font: .9rem/1.55 system-ui, sans-serif; }
.node-attributes dt { color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.node-attributes dd { margin: 0; overflow-wrap: anywhere; }

.sub-node { margin-top: 1rem; padding: 1rem 1.1rem 1.1rem; border: 1px solid var(--line); border-left: 3px solid #657b54; border-radius: 5px; background: rgba(17, 22, 18, .6); scroll-margin-top: 1rem; }
.sub-node > .node-header { padding-bottom: .55rem; border-bottom: 1px solid color-mix(in srgb, var(--green) 18%, transparent); }
.sub-node > .node-header .node-title { color: var(--green); font-size: 1.12rem; }
.sub-node.is-target { border-left-color: var(--green); animation: target-pulse 2.4s ease-out 1; }
.sub-node .sub-node { margin-left: .4rem; background: rgba(25, 30, 26, .72); }
.sub-node .sub-node > .node-header .node-title { color: var(--text); font-size: 1rem; }

/* Table of contents */
.toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.toc > summary { padding: .75rem 1rem; color: var(--green); font: 600 1rem Georgia, serif; cursor: pointer; list-style: none; }
.toc > summary::-webkit-details-marker { display: none; }
.toc-body { padding: 0 1rem 1rem; }
.node-search { position: relative; margin-bottom: .75rem; }
.search-suggestions { position: absolute; z-index: 5; top: 100%; right: 0; left: 0; max-height: 16rem; overflow-y: auto; margin-top: .3rem; padding: .25rem; border: 1px solid var(--green); border-radius: 4px; background: var(--panel); box-shadow: 0 8px 20px rgba(0, 0, 0, .45); }
.search-option { display: block; width: 100%; min-height: 0; padding: .5rem .6rem; border: 0; border-radius: 3px; background: transparent; color: var(--text); font: .9rem system-ui, sans-serif; text-align: left; }
.search-option small { display: block; margin-top: .1rem; color: var(--muted); font-size: .75rem; font-weight: 400; }
.search-option[aria-selected="true"], .search-option:hover { background: color-mix(in srgb, var(--green) 18%, transparent); }
.toc-list, .toc-list ul { list-style: none; margin: 0; padding: 0; }
.toc-list li + li { margin-top: .3rem; }
.toc-list a { display: block; padding: .15rem 0; font: .85rem/1.35 system-ui, sans-serif; overflow-wrap: anywhere; }

footer { padding: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font: .8rem system-ui, sans-serif; text-align: center; }

@media (max-width: 900px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .toc { position: static; max-height: none; order: -1; }
  .toc-body { max-height: 16rem; overflow-y: auto; }
}
@media (max-width: 640px) {
  .sheet-nav { gap: .8rem; flex-wrap: wrap; }
  .guide-page { padding: 1rem .75rem 2rem; }
  .page-head h1 { font-size: 1.6rem; }
  .spell-filters { grid-template-columns: minmax(0, 1fr); }
  .category-menu { grid-template-columns: minmax(0, 1fr); }
  .entry > summary { padding: .8rem .75rem; }
  .entry-body { padding: .8rem .75rem 1rem; }
  .node-title { font-size: 1.2rem; }
  .node-icon { width: 2.75rem; height: 2.75rem; }
  .node-attributes { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .node-attributes dd { margin-bottom: .5rem; }
  .spell-text { padding: .75rem; }
  .sub-node { padding: .8rem .7rem; }
  .sub-node .sub-node { margin-left: .15rem; }
  .guide-tools button { flex: 1 1 auto; }
  .guide-tools span { flex-basis: 100%; margin-left: 0; }
}
@media print {
  .sheet-nav, .toc, .global-search, .guide-tools, .spell-filters, footer { display: none !important; }
  body { background: #fff; color: #111; }
  .entry, .sub-node, .node-attributes, .custom-field-callout, .spell-text { border-color: #999; background: #fff; color: #111; box-shadow: none; }
  .node-title, .node-description, .node-content, .custom-field-quote, .spell-text-title { color: #111; }
}
  .table-scroll { overflow-x: auto; max-width: 100%; margin: 0.75rem 0; -webkit-overflow-scrolling: touch; }
  .node-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
  .node-table caption { text-align: left; padding: 0 0 0.5rem; color: var(--muted, #b7c3ad); font-size: 0.85rem; }
  .node-table th, .node-table td { border: 1px solid color-mix(in srgb, var(--green) 25%, transparent); padding: 0.3rem 0.6rem; text-align: center; white-space: nowrap; }
  .node-table thead th { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green, #9fc777); }
  .link-chips a.tag-chip { text-decoration: none; text-transform: none; font-size: .8rem; }
  .link-chips a.tag-chip:hover { border-color: var(--green, #9fc777); }
