html { scroll-behavior: smooth; }
.site-nav { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; min-height: 58px; padding: .8rem 1.5rem; border-bottom: 1px solid #554534; background: var(--panel-bg, #1c1a18); }
.site-nav a { color: #cbbda9; text-decoration: none; }
.site-nav a:first-child { color: var(--accent, #c18b52); letter-spacing: .12em; }
.site-nav a[aria-current="page"] { color: var(--accent, #c18b52); }
#app-content { opacity: 1; transition: opacity 180ms ease, transform 180ms ease; }
#app-content.page-leaving { opacity: 0; transform: translateY(6px); }
#app-content.page-entering { opacity: 0; transform: translateY(6px); }
#app-content.page-entering.page-visible { opacity: 1; transform: translateY(0); }
.ambient-player { position: fixed; right: 1rem; bottom: 1rem; z-index: 40; width: min(320px, calc(100% - 2rem)); }
.ambient-player audio { display: block; width: 100%; }
.character-roster { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.character-card { padding: .4rem .8rem; border: 1px solid var(--faction-color, #554534); border-radius: 999px; background: #1c1a18; color: #eee8df; cursor: pointer; }
.character-card:hover, .character-card:focus-visible { outline: 2px solid var(--faction-color, #c18b52); outline-offset: 2px; }
.reader-toolbar { position: sticky; top: 58px; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin: 1.5rem 0; padding: .65rem .8rem; border: 1px solid #554534; border-radius: 6px; background: var(--panel-bg, #1c1a18); color: #cbbda9; font-size: .9rem; }
.reader-toolbar button { padding: .35rem .65rem; border: 1px solid #66543d; border-radius: 4px; background: #211d18; color: #eee8df; cursor: pointer; }
.chapter-content { --reader-font-size: 19px; font-size: var(--reader-font-size); }
.chapter-content.reader-line-compact { line-height: 1.5; }
.codex-term { position: relative; display: inline; padding: 0; border: 0; border-bottom: 1px dotted var(--accent, #c18b52); background: transparent; color: inherit; font: inherit; cursor: help; }
.codex-term:hover, .codex-term:focus-visible { color: var(--accent, #c18b52); outline: none; }
.codex-term::after { position: absolute; z-index: 50; bottom: calc(100% + .55rem); left: 50%; width: max-content; max-width: min(320px, 75vw); padding: .55rem .7rem; border: 1px solid #66543d; border-radius: 5px; background: #1c1a18; color: #eee8df; content: attr(data-tooltip); font: 14px/1.5 Georgia, serif; white-space: normal; opacity: 0; pointer-events: none; transform: translate(-50%, 4px); transition: opacity 120ms ease, transform 120ms ease; }
.codex-term:hover::after, .codex-term:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.codex-dialog { position: fixed; inset: 0; width: min(600px, calc(100% - 2rem)); max-height: min(80vh, 760px); margin: auto; padding: 2rem; overflow: auto; border: 1px solid #66543d; border-radius: 10px; background: #1c1a18; color: #eee8df; box-shadow: 0 24px 80px #000b; }
.codex-dialog::backdrop { background: #050504c9; backdrop-filter: blur(5px); }
.codex-dialog h2, .codex-category { color: var(--accent, #c18b52); }
.codex-dialog-close { position: sticky; float: right; top: 0; width: 2rem; height: 2rem; border: 1px solid #66543d; border-radius: 50%; background: #24201b; color: #eee8df; font-size: 1.4rem; cursor: pointer; }
.codex-dialog-image { display: block; max-width: 100%; max-height: 300px; margin: 1rem 0; object-fit: cover; }
.codex-dialog a { color: #e6bd83; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    #app-content { transition: none; }
    .codex-term::after { transition: none; }
}
