/* ═══════════════════════════════════════════
   CHARACTER HISTORY (ADR-0043)
   A full-screen pushed layer over the community overlay: list -> version.
   Composed from the sub-screen family (.sub-bar + .glass-chip + .large-title +
   .settings-screen), ledger rows (.settings-row.has-tile), media row tiles
   (.ci-tile), disclosure folds (.fold-pick) and scenario cards (.scenario-pick).
   Only the diff marks and the layer geometry are new. Tokens only.
═══════════════════════════════════════════ */
.chh-layer { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.chh-dim { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.chh-screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); pointer-events: auto; overflow: hidden;
  transform: translate3d(100%, 0, 0); will-change: transform;
}
.chh-screen.chh-in { transform: none; }
.chh-screen .settings-screen { flex: 1; min-height: 0; overflow-y: auto; padding-top: calc(56px + var(--tg-top, 0px)); }
.chh-cap { padding: 0 var(--pad); margin-top: -4px; font-size: 13px; line-height: 1.4; color: var(--text2); }
.chh-cap .text-btn { margin: -12px -8px -12px 0; color: var(--accent-text); }
.chh-cap-act { margin-top: 0; }
.chh-cap-act .text-btn { margin: -8px 0 -8px -8px; min-height: 40px; }
.chh-cap-line + .chh-cap-line { margin-top: 2px; }
.chh-row .settings-label { min-width: 0; }
.chh-row .settings-label-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chh-delta { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--text3); white-space: nowrap; flex: none; }
.chh-delta .p { color: var(--accent-text); font-weight: 600; }
.chh-row.chh-mark { cursor: default; }
.chh-row.chh-mark .icon-tile svg { opacity: 0.36; }
.chh-row.chh-mark .settings-label { color: var(--text2); }
.chh-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chh-skel .settings-row { pointer-events: none; }
.chh-skel .settings-label::before { content: ''; display: block; height: 14px; width: 55%; border-radius: 7px; background: var(--glass-bold); }
.chh-skel .settings-label-sub::before { content: ''; display: block; height: 10px; width: 30%; margin-top: 8px; border-radius: 5px; background: var(--glass-bold); }
.chh-sentinel { height: 1px; }
.chh-end { height: calc(var(--nav-h, 64px) + 96px + var(--safe-bottom, 0px)); }

/* version */
.chh-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 var(--pad); margin-bottom: 14px; }
.chh-photos .ci-tile { background: var(--glass-bold); cursor: pointer; border: none; padding: 0; font: inherit; color: inherit; }
.chh-photos .ci-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chh-photos .ci-tile.gone img { opacity: 0.42; }
.chh-photos .ci-tile img { opacity: 0; transition: opacity 250ms cubic-bezier(0.05, 0.7, 0.1, 1); }
.chh-photos .ci-tile img.chh-loaded { opacity: 1; }
.chh-photos .ci-tile.gone img.chh-loaded { opacity: 0.42; }
.chh-photos .ci-badge { left: auto; right: 6px; }
.chh-photos .ci-badge.acc { background: var(--accent); }
.chh-fields { padding: 0 var(--pad); display: flex; flex-direction: column; gap: 8px; }
.chh-fields .fold-pick { margin: 0; }
.chh-text { font-size: 15px; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.chh-text.empty { color: var(--text3); }
.chh-ins { background: var(--accent-soft); border-radius: 3px; padding: 0 1px; }
.chh-del { color: var(--text3); text-decoration: line-through; text-decoration-thickness: 1px; }
.chh-more { display: inline-flex; margin: 2px 0; min-height: 36px; color: var(--accent-text); }
/* actions on the expanded fold are the card's own prompt-fold row verbatim
   (.post-prompt-actions + .form-btn in community.css): one recipe for the
   character card, the gallery post and the history screen. Spacing comes from
   the shared .fold-pick-body-inner gap, so there is nothing to add here. */
.chh-kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.chh-kv + .chh-kv { border-top: 1px solid var(--sep); }
.chh-kv .k { color: var(--text2); min-width: 0; }
.chh-kv .v { text-align: right; }
.chh-kv .v .was { color: var(--text3); text-decoration: line-through; margin-right: 6px; }
.chh-kv .note { color: var(--text3); font-size: 12px; }
.chh-tags { display: flex; flex-wrap: wrap; }
.chh-tag { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: var(--r-pill); background: var(--glass-bold); color: var(--text2); font-size: 12px; font-weight: 600; margin: 0 6px 6px 0; }
.chh-tag.add { background: var(--accent-soft); color: var(--accent-text); }
.chh-tag.rm { text-decoration: line-through; opacity: 0.6; }
.chh-scen-lbl { font-size: 13px; font-weight: 600; color: var(--text2); margin: 10px 0 4px; }
.chh-scen-lbl:first-child { margin-top: 0; }
.chh-scen-state { font-size: 12px; font-weight: 500; color: var(--text3); white-space: nowrap; }
.chh-scen-state.acc { color: var(--accent-text); }
.chh-fields .scenario-pick.gone { opacity: 0.55; }
.chh-fields .scenario-pick + .scenario-pick { margin-top: 8px; }
.chh-cta { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h, 64px) + 14px + var(--safe-bottom, 0px)); z-index: 3; }
.chh-cta .form-btn { width: 100%; margin: 0; }
.chh-cta.off { display: none; }
body.kb-open .chh-cta { display: none; }
.chh-empty { padding: 48px var(--pad) 0; }

/* restore confirm sheet (char-share family) */
.chh-confirm .modal-sheet { padding-bottom: calc(12px + var(--safe-bottom, 0px)); }
.chh-confirm .modal-title { text-align: center; font-size: 17px; font-weight: 600; padding: 8px 20px 14px; }
.chh-confirm .island { margin: 0 var(--pad); }
.chh-confirm .settings-row { cursor: default; }
.chh-confirm .settings-row.skip { opacity: 0.6; }
.chh-confirm .chh-cap { margin-top: 12px; }
.chh-confirm-acts { display: flex; gap: 8px; padding: 16px var(--pad) 0; }
.chh-confirm-acts .form-btn { flex: 1; margin: 0; }
.chh-confirm .form-btn.is-pending { pointer-events: none; }

/* A photo of a version opens on its archive thumb (charhist, 400 at the top of
   the ladder) and climbs to charhistfull. The viewer's slide only CAPS its size
   (max-width 96% / max-height 90vh on .char-lightbox-side), so an upscale never
   happens and a thumb of a 2000px photo sat as a small frame in the middle of a
   black screen for as long as the full frame took. While the layer drives the
   viewer the slide FILLS the frame and the seed sharpens in place. */
body.chh-lightbox .char-lightbox-side { width: 96%; height: 90vh; object-fit: contain; }

/* desktop: the layer paints the whole viewport under the sidebar (z 4000, it
   stays on top and clickable) and only the CONTENT sits in the free column,
   like .view-content does; a layer starting at the column edge showed the
   dimmed page as a dark strip between the sidebar and the screen */
html.layout-desktop .chh-screen .settings-screen { padding-left: calc(var(--sidebar-w) + var(--sidebar-gap) * 2); }
html.layout-desktop .chh-screen .settings-screen > * { max-width: 720px; margin-left: auto; margin-right: auto; }
html.layout-desktop .chh-screen .sub-bar { left: calc(var(--sidebar-w) + var(--sidebar-gap) * 2); }
html.layout-desktop .chh-cta { left: calc(var(--sidebar-w) + var(--sidebar-gap) * 2 + 16px); right: auto; width: calc(100% - var(--sidebar-w) - var(--sidebar-gap) * 2 - 32px); max-width: 720px; }

@media (prefers-reduced-motion: reduce) {
  .chh-screen, .chh-dim, .chh-photos .ci-tile img { transition: none !important; }
}
