

.codex-hero { margin-bottom: var(--s-2); }
.codex-hero h1 { font-size: var(--t-3xl); margin: 6px 0 10px; }
.codex-hero .lede { color: var(--ink-2); font-size: var(--t-md); max-width: 64ch; }
.codex-toc { display: flex; flex-wrap: wrap; gap: 2px 0; margin: var(--s-2) 0 0 -8px; }
.codex-toc button {
  padding: 3px 8px; border: 0; border-radius: var(--r-pill); background: transparent; cursor: pointer;
  font-family: var(--f-ui); font-size: 14px; color: var(--ink-2); transition: background var(--dur-1), color var(--dur-1);
}
.codex-toc button .num { color: var(--ink-3); font-size: var(--t-xs); }
.codex-toc button:hover { background: var(--ground-2); color: var(--brass-hi); }

.cw-wrap { margin-top: var(--s-6); }
.faction { scroll-margin-top: calc(var(--bar-h) + 76px); }
.faction + .faction { margin-top: var(--s-8); }
.fac-head { display: grid; gap: 4px; padding-bottom: 12px; margin-bottom: var(--s-5); border-bottom: 1px solid var(--line-strong); }
.fac-head h2 { font-size: var(--t-2xl); }
.fac-head h2 .num { font-size: .58em; color: var(--brass); vertical-align: .38em; margin-left: 2px; }
.fac-head p { color: var(--ink-3); font-style: italic; max-width: 80ch; }

.npc-features { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 10px 18px; margin-bottom: var(--s-5); }
.npc { color: var(--ink); text-decoration: none; border-radius: var(--r-2); transition: background var(--dur-1); }
.npc.feature { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; padding: 12px 14px 12px 16px; }
.npc.feature:hover { background: var(--ground-2); }
.npc-text { display: grid; gap: 2px; min-width: 0; }
.npc.feature .npc-name { font-family: var(--f-display); font-size: 1.4rem; line-height: 1.15; text-wrap: balance; }
.npc-title { font-family: var(--f-ui-sc); font-weight: 700; font-size: 11.5px; letter-spacing: .08em; color: var(--ink-3); }
.npc-role { margin-top: 4px; font-size: var(--t-sm); line-height: 1.45; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.npc-wall { display: flex; flex-wrap: wrap; gap: 22px 8px; }
.npc.t2, .npc.t3 { display: grid; justify-items: center; align-content: start; gap: 8px; width: 118px; padding: 10px 4px 8px; text-align: center; }
.npc.t3 { width: 104px; }
.npc.t2:hover, .npc.t3:hover { background: var(--ground-2); }
.npc.t2 .npc-name, .npc.t3 .npc-name { font-family: var(--f-display); font-size: 1.02rem; line-height: 1.18; text-wrap: balance; overflow-wrap: anywhere; }
.npc.t3 .npc-name { font-size: .96rem; }
.npc.t2 .npc-title { font-size: 10.5px; line-height: 1.3; }
.npc .portrait { transition: transform var(--dur-2) var(--ease); }
.npc:hover .portrait { transform: scale(1.05); }
.npc:hover .npc-name { color: var(--brass-hi); }
.npc:focus-visible { box-shadow: var(--focus); }

.npc.unmet .portrait::after, .cx-key .unmet .portrait::after { box-shadow: none; border: 1.5px dashed var(--line-strong); inset: -3px; }
.npc.unmet .portrait.bezel::before { opacity: .25; }
.npc.unmet .npc-name { color: var(--ink-2); }
.npc.unmet .portrait img { filter: saturate(.7); }

.cx-key { display: none; }
@media (min-width: 1280px) {
  .codex-page { display: grid; grid-template-columns: 196px minmax(0, 1fr); column-gap: var(--s-7); align-items: start; }
  .codex-hero { grid-column: 1 / -1; }
  .codex-page > .cf-wrap { grid-column: 2; grid-row: 2; }
  .codex-page > .cw-wrap { grid-column: 2; grid-row: 3; }
  .codex-page > .cf-wrap { margin-left: 0; padding-left: 0; } 
  .cx-key {
    display: block; grid-column: 1; grid-row: 2 / span 2;
    position: sticky; top: calc(var(--bar-h) + 14px); margin-top: calc(var(--s-6) + 4px);
    max-height: calc(100vh - var(--bar-h) - 28px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
    padding: 12px 0 8px; border-top: 1px solid var(--line-2);
  }
}
.cx-key-sub { margin: 16px 0 10px; font-family: var(--f-ui-sc); font-weight: 700; font-size: 11.5px; letter-spacing: .12em; color: var(--ink-3); }
.cx-key .eyebrow + .cx-key-sub { margin-top: 10px; }
.cx-key-list { display: grid; gap: 10px; }
.cx-key-list li { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; align-items: center; }
.cx-key-face { display: grid; place-items: center; min-height: 36px; }
.cx-key-text { font-family: var(--f-ui); font-size: var(--t-xs); line-height: 1.35; color: var(--ink-2); }
.cx-key-text b { font-weight: 700; color: var(--ink); }

.npc-card { display: grid; gap: var(--s-5); padding: 30px 28px 40px; }
.nc-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; padding-right: 36px; }
.nc-art { margin: 0; width: 148px; padding: 5px; border-radius: var(--r-2); background: var(--ground); box-shadow: 0 0 0 1px var(--line-2), var(--shadow-2); }
.nc-art img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; object-position: 50% 25%; border-radius: 3px; }
.nc-art[data-status="dead"] img, .nc-art[data-status="defeated"] img, .nc-art[data-status="at-rest"] img { filter: grayscale(1) sepia(.2) brightness(.85); }
.nc-art[data-status="erased"] img { filter: grayscale(.6) brightness(1.1) opacity(.55); }
.nc-titles h2 { font-size: clamp(1.65rem, 1.2rem + 1vw, 2.15rem); line-height: 1.08; margin: 4px 0 2px; text-wrap: balance; }
.nc-aka { margin-top: 4px; font-family: var(--f-body); font-style: italic; color: var(--ink-2); }
.nc-sub { font-family: var(--f-ui-sc); font-weight: 700; font-size: 12.5px; letter-spacing: .08em; color: var(--ink-3); }
.nc-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; font-family: var(--f-ui); font-size: var(--t-xs); }
.nc-status { padding: 2px 10px; border-radius: var(--r-pill); border: 1px solid var(--line-2); font-weight: 700; color: var(--ink-2); }
.nc-status.s-alive { border-color: color-mix(in srgb, var(--ok) 60%, transparent); color: var(--ok); }
.nc-status.s-dead, .nc-status.s-defeated, .nc-status.s-at-rest { border-color: color-mix(in srgb, var(--past) 60%, transparent); color: var(--past); }
.nc-status.s-erased { border-color: color-mix(in srgb, var(--ghost) 60%, transparent); color: var(--ghost); }
.nc-role { font-size: var(--t-lg); line-height: 1.45; font-style: italic; color: var(--ink); }

.nc-quote { position: relative; }
.nc-voice {
  position: relative; margin: 0; min-height: calc(1.55em + 8px); padding: 4px 34px 4px 18px; border-left: 2px solid var(--brass); border-radius: 0 var(--r-1) var(--r-1) 0;
  color: var(--ink-2); font-size: var(--t-md); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; transition: background var(--dur-1), box-shadow var(--dur-1);
}
.nc-voice:not(:empty)::before { content: "“"; }
.nc-voice:not(:empty)::after { content: "”"; }
.nc-voice:empty { border-left-style: dashed; border-left-color: var(--line-strong); }
.nc-voice:empty::before { content: attr(data-placeholder); position: absolute; left: 18px; font-style: italic; color: var(--ink-3); pointer-events: none; }
.nc-voice:hover { background: var(--brass-soft); }
.nc-voice:not([contenteditable]):hover { background: none; } 
.nc-voice:focus { background: var(--ground); box-shadow: 0 0 0 1px var(--brass), 0 0 0 4px var(--brass-soft); }
.nc-quote-pen { position: absolute; top: 8px; right: 10px; color: var(--brass); opacity: 0; transition: opacity var(--dur-1); pointer-events: none; }
.nc-quote-pen .ic { display: block; width: 16px; height: 16px; }
.nc-voice:hover + .nc-quote-pen, .nc-voice:focus + .nc-quote-pen { opacity: 1; }
.nc-quote-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; padding-left: 8px; }
.nc-quote-from { margin-left: 12px; } 
.nc-speaks { margin-top: 10px; padding-left: 20px; font-family: var(--f-ui); font-size: var(--t-sm); line-height: 1.5; color: var(--ink-2); }
.nc-speaks-h { margin-right: 6px; font-family: var(--f-ui-sc); font-weight: 700; font-size: 12px; letter-spacing: .1em; color: var(--ink-3); }
.nc-sec h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-family: var(--f-ui-sc); font-weight: 700; font-size: 12.5px; letter-spacing: .12em; color: var(--ink-3); }
.nc-sec h3 .ic { width: 15px; height: 15px; color: var(--brass); }
.nc-sec p { line-height: 1.6; }
.nc-versions h3 .ic { color: var(--future); }
.nc-face-row { display: flex; flex-wrap: wrap; gap: 22px; }
.nc-face-row figure { margin: 0; display: grid; justify-items: center; gap: 8px; width: 140px; text-align: center; }
.nc-face-row figcaption { font-family: var(--f-ui); font-size: var(--t-xs); color: var(--ink-2); line-height: 1.35; }
.nc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.nc-dm { display: grid; gap: 14px; padding-top: var(--s-5); border-top: 1px dashed var(--line-2); }
.nc-dm h3 { margin-bottom: 0; }
.nc-dm .select { width: auto; }

@media (max-width: 640px) {
  .npc-features { grid-template-columns: minmax(0, 1fr); }
  .npc.t2 { width: calc(50% - 4px); }
  .npc.t3 { width: calc(33.3% - 6px); }
  .nc-head { grid-template-columns: minmax(0, 1fr); padding-right: 0; }
  .nc-art { width: 120px; }
  .npc-card { padding: 24px 18px 32px; }
}

.npc-group + .npc-group { margin-top: var(--s-5); }
.npc-subhead { display: flex; align-items: baseline; gap: 8px; margin: var(--s-5) 0 var(--s-3); font-family: var(--f-ui-sc); font-weight: 700; font-size: 13px; letter-spacing: .12em; color: var(--ink-2); }
.npc-subhead .num { font-family: var(--f-ui); letter-spacing: 0; color: var(--brass); }
.npc-subhead::after { content: ""; flex: 1; height: 1px; background: var(--line); transform: translateY(-.3em); }
