/* ==========================================================================
   Gliffer UI ? design tokens + scoped sections
   Scopes: base ? shell ? home ? lists ? document/creation
   ========================================================================== */

@font-face {
    font-family: "MedievalName";
    src: url("MedievalName.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "SheetSans";
    src: url("SheetSans.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --night-0: #0c0a08;
    --night-1: #16110d;
    --night-2: #241c14;
    --ink-sepia: #3a2a1c;
    --leaf-gold: #c4a35a;
    --leaf-gold-bright: #e2c984;
    --parchment: #e8dcc4;
    --parchment-deep: #cbb892;
    --font-manuscript: "MedievalName", "Palatino Linotype", Palatino, serif;
    --font-sheet: "SheetSans", "Palatino Linotype", Palatino, serif;

    --bg-page: var(--night-0);
    --bg-panel: var(--night-1);
    --bg-raised: var(--night-2);
    --bg-cell: #1a1510;
    --bg-deep: #0a0806;
    --fg: var(--parchment);
    --fg-muted: var(--parchment-deep);
    --fg-dim: #8a7a5c;
    --accent: var(--leaf-gold);
    --accent-cool: var(--leaf-gold-bright);
    --border: rgba(196, 163, 90, 0.38);
    --danger: #c45c5c;
    --danger-soft: #e8a0a0;
    --warning-fg: #e2c984;
    --warning-bg: rgba(196, 163, 90, 0.16);
    --radius-sm: 0.2rem;
    --radius-md: 0.35rem;
    --gap: 0.7rem;
    --col-title: 11rem;
    --col-formula: 7rem;
    --col-std: 4.5rem;
    --col-num: 3.25rem;
    --font-display: var(--font-manuscript);
    --font-body: var(--font-sheet);
    --banner-width: 40px;
    --content-inset: clamp(2.75rem, 6vw, 4.5rem);

    /* Magieschule identity colors (vivid RGB; diluted in documents) */
    --school-bann: 168, 92, 220;
    --school-beherrschung: 186, 64, 148;
    --school-bewegung: 48, 196, 186;
    --school-erkenntnis: 110, 118, 220;
    --school-fels: 168, 132, 88;
    --school-feuer: 232, 86, 28;
    --school-heilung: 92, 196, 118;
    --school-illusion: 214, 128, 196;
    --school-kampf: 204, 48, 52;
    --school-licht: 236, 210, 72;
    --school-natur: 72, 158, 64;
    --school-schatten: 98, 78, 148;
    --school-schicksal: 212, 148, 72;
    --school-schutz: 86, 152, 220;
    --school-staerkung: 196, 128, 48;
    --school-tod: 92, 64, 108;
    --school-verwandlung: 158, 186, 64;
    --school-wasser: 48, 128, 212;
    --school-wind: 168, 204, 228;
    --school-tint-alpha: 0.09;
}

/* --------------------------------------------------------------------------
   1. Base
   -------------------------------------------------------------------------- */

body {
    margin: 0;
    min-height: 100vh;
    color: var(--fg);
    font-family: var(--font-body);
    background-color: var(--bg-page);
    background-image:
        radial-gradient(ellipse 90% 45% at 50% 0%, rgba(196, 163, 90, 0.08), transparent 55%),
        linear-gradient(180deg, var(--night-1) 0%, var(--night-0) 55%);
    background-attachment: fixed;
}

main {
    position: relative;
    z-index: 1;
    padding: 0.75rem var(--content-inset) 2.5rem;
    box-sizing: border-box;
}

main:has(.home-hero) {
    padding: 0;
}

h1 {
    text-align: center;
    margin: 0.6em 0 0.85em;
    font-family: var(--font-manuscript);
    font-weight: normal;
    font-size: clamp(1.6rem, 3.5vw, 2.15rem);
    letter-spacing: 0.04em;
    color: var(--leaf-gold-bright);
    text-shadow: 0 1px 0 rgba(12, 10, 8, 0.8);
}

h2 {
    font-family: var(--font-manuscript);
    font-weight: normal;
    color: var(--leaf-gold-bright);
    letter-spacing: 0.03em;
}

a {
    color: var(--accent-cool);
}

a:hover {
    color: var(--parchment);
}

button {
    border: 1px solid var(--accent);
    padding: 0.4em 0.75em;
    border-radius: var(--radius-sm);
    min-width: 5em;
    background:
        linear-gradient(180deg, rgba(36, 28, 20, 0.95) 0%, rgba(22, 17, 13, 0.98) 100%);
    color: var(--fg);
    font-family: var(--font-body);
    cursor: pointer;
}

button:hover {
    background: rgba(196, 163, 90, 0.16);
    border-color: var(--leaf-gold-bright);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

label {
    display: inline-block;
    margin: 0.35em 0 0.25em;
    color: var(--fg-muted);
    font-family: var(--font-body);
}

/* --------------------------------------------------------------------------
   2. Shell (nav, adornments, toast, session reauth)
   -------------------------------------------------------------------------- */

.nav-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    position: relative;
    z-index: 3;
    color: var(--fg);
    background: linear-gradient(
        180deg,
        rgba(12, 10, 8, 0.96) 0%,
        rgba(12, 10, 8, 0.72) 78%,
        transparent 100%
    );
}

.title {
    margin: 0.45rem 0 0.15rem;
    font-family: var(--font-manuscript);
    font-size: clamp(1.55rem, 3vw, 2rem);
    font-weight: normal;
    letter-spacing: 0.06em;
    text-align: center;
    color: var(--leaf-gold-bright);
    text-shadow:
        0 1px 0 rgba(58, 42, 28, 0.85),
        0 0 22px rgba(196, 163, 90, 0.28);
}

nav {
    background: transparent;
    text-align: center;
    font-family: var(--font-body);
    display: block;
    width: 100%;
    height: min-content;
    border-bottom: 1px solid rgba(196, 163, 90, 0.22);
}

nav ul {
    list-style: none;
    margin: 0 1.25rem;
    padding: 0 1.25rem 0 1.125rem;
}

nav li {
    display: inline-flex;
}

nav li:hover,
nav li.active {
    background-color: rgba(196, 163, 90, 0.12);
}

nav a {
    color: var(--parchment-deep);
    text-decoration: none;
    font-size: large;
}

nav a:hover {
    color: var(--leaf-gold-bright);
}

nav.inner__nav ul li a {
    display: block;
    width: 100%;
    height: 100%;
    padding: 15px 20px;
}

nav.inner__nav ul li.nav-lang {
    margin-left: 0.35rem;
}
nav.inner__nav ul li.nav-lang .nav-lang__btn {
    background: transparent;
    border: 1px solid rgba(196, 163, 90, 0.35);
    color: var(--parchment-deep);
    font-family: var(--font-body);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    padding: 0.35rem 0.65rem;
    margin: 0.55rem 0.5rem;
    cursor: pointer;
}
nav.inner__nav ul li.nav-lang .nav-lang__btn:hover {
    color: var(--leaf-gold-bright);
    border-color: rgba(196, 163, 90, 0.7);
    background-color: rgba(196, 163, 90, 0.12);
}

.adornment-left,
.adornment-right {
    background-image: url("side_banner.png");
    background-repeat: repeat-y;
    background-size: var(--banner-width) auto;
    height: 100vh;
    position: fixed;
    top: 0;
    width: var(--banner-width);
    z-index: 2;
    opacity: 0.9;
    pointer-events: none;
    filter: drop-shadow(0 0 14px rgba(196, 163, 90, 0.22));
}

.adornment-left {
    left: 0;
}

.adornment-right {
    right: 0;
}

/* Home: hide duplicate wordmark; hero owns the brand */
body:has(.home-hero) .nav-container > .title {
    display: none;
}

body:has(.home-hero) .adornment-left {
    animation: banner-settle-left 1.1s ease-out both;
}

body:has(.home-hero) .adornment-right {
    animation: banner-settle-right 1.1s ease-out both;
}

@keyframes banner-settle-left {
    from {
        transform: translateX(-12px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 0.9;
    }
}

@keyframes banner-settle-right {
    from {
        transform: translateX(12px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 0.9;
    }
}

.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.toast {
    background-color: var(--bg-raised);
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    animation: toast-show 3s forwards;
}

@keyframes toast-show {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    10%,
    90% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(20px);
    }
}

.session-reauth-overlay,
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 6, 4, 0.78);
    padding: 24px;
}

.session-reauth-modal,
.confirm-modal {
    width: min(420px, 100%);
    background:
        linear-gradient(180deg, rgba(36, 28, 20, 0.98) 0%, rgba(22, 17, 13, 0.98) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    padding: 24px;
    text-align: center;
}

.session-reauth-modal h2,
.confirm-modal h2 {
    margin-top: 0;
}

.session-reauth-modal p,
.confirm-modal p {
    margin-bottom: 16px;
    color: var(--fg-muted);
}

.session-reauth-error,
.confirm-error,
.form-error,
.document-load-error,
.action-error {
    color: var(--danger-soft);
    margin-top: 12px;
}

.document-load-error {
    margin: 1em 0;
}

.document-load-warning {
    color: var(--warning-fg);
    background: var(--warning-bg);
    border: 1px solid var(--border);
    padding: 0.75em 1em;
    margin: 1em 0;
    border-radius: var(--radius-sm);
}

.action-ok {
    color: var(--leaf-gold-bright);
    margin: 0.5em 0;
}

/* --------------------------------------------------------------------------
   3. Marketing / home
   -------------------------------------------------------------------------- */

.home-hero {
    --home-pad-x: clamp(3.5rem, 8vw, 5.5rem);
    position: relative;
    min-height: calc(100dvh - 7.5rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.5rem var(--home-pad-x) 0;
    color: var(--parchment);
    overflow: clip;
    background:
        radial-gradient(ellipse 70% 55% at 50% 38%, rgba(232, 220, 196, 0.16), transparent 62%),
        radial-gradient(ellipse 90% 50% at 50% 0%, rgba(196, 163, 90, 0.12), transparent 55%),
        radial-gradient(ellipse 80% 40% at 50% 100%, rgba(36, 28, 20, 0.95), transparent 70%),
        linear-gradient(180deg, var(--night-1) 0%, var(--night-0) 100%);
}

.home-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.22;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(90, 70, 40, 0.35) 0 1px, transparent 2px),
        radial-gradient(circle at 80% 60%, rgba(90, 70, 40, 0.28) 0 1px, transparent 2px),
        radial-gradient(circle at 45% 80%, rgba(90, 70, 40, 0.22) 0 1px, transparent 2px);
    background-size: 180px 180px, 220px 220px, 160px 160px;
    mix-blend-mode: soft-light;
}

.home-hero__stage {
    position: relative;
    z-index: 1;
    width: min(36rem, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.home-hero__brand {
    margin: 0;
    font-family: var(--font-manuscript);
    font-size: clamp(2.75rem, 8vw, 4.25rem);
    line-height: 1;
    letter-spacing: 0.04em;
    color: var(--leaf-gold-bright);
    text-shadow:
        0 1px 0 rgba(58, 42, 28, 0.85),
        0 0 28px rgba(196, 163, 90, 0.35);
    animation: home-rise 0.85s ease-out both;
}

.home-hero__art {
    display: block;
    width: min(22rem, 72vw);
    height: auto;
    margin: 0.15rem 0 0.35rem;
    border-radius: 0;
    filter:
        drop-shadow(0 18px 28px rgba(0, 0, 0, 0.55))
        drop-shadow(0 0 40px rgba(232, 220, 196, 0.12));
}

.home-hero__line {
    margin: 0;
    max-width: 22rem;
    font-family: var(--font-sheet);
    font-size: clamp(1.05rem, 2.4vw, 1.25rem);
    line-height: 1.45;
    color: var(--parchment);
    animation: home-rise 1s ease-out 0.16s both;
}

.home-hero__welcome {
    margin: 0;
    font-family: var(--font-sheet);
    font-size: 0.95rem;
    color: var(--parchment-deep);
    animation: home-rise 1s ease-out 0.2s both;
}

.home-hero__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.35rem;
    padding: 0.7rem 1.45rem;
    font-family: var(--font-sheet);
    font-size: 1rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    color: var(--ink-sepia);
    background:
        linear-gradient(180deg, var(--leaf-gold-bright) 0%, var(--leaf-gold) 100%);
    border: 1px solid rgba(58, 42, 28, 0.45);
    border-radius: 2px;
    box-shadow:
        0 1px 0 rgba(255, 235, 190, 0.35) inset,
        0 8px 18px rgba(0, 0, 0, 0.35);
    animation: home-rise 1.05s ease-out 0.24s both;
}

.home-hero__cta:hover {
    color: var(--ink-sepia);
    filter: brightness(1.06);
}

.home-hero__footer {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding: 1.75rem 0 1.25rem;
    text-align: center;
}

.home-hero__footer p {
    margin: 0;
    font-family: var(--font-sheet);
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    color: rgba(203, 184, 146, 0.55);
}

/* --- Intentional motion --- */

.zoom-tilt {
    transform-origin: 50% 60%;
    animation: zoom-tilt-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
    transition: transform 0.45s ease, filter 0.45s ease;
}

.zoom-tilt:hover {
    transform: scale(1.045) rotate(-1.5deg);
    filter:
        drop-shadow(0 22px 32px rgba(0, 0, 0, 0.6))
        drop-shadow(0 0 48px rgba(232, 220, 196, 0.18));
}

@keyframes zoom-tilt-in {
    from {
        opacity: 0;
        transform: scale(0.86) rotate(-3.5deg) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg) translateY(0);
    }
}

@keyframes home-rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes page-turn-forward {
    from {
        opacity: 0;
        transform: perspective(960px) rotateY(-14deg) translateX(28px);
        transform-origin: left center;
        filter: blur(1.5px);
    }
    to {
        opacity: 1;
        transform: perspective(960px) rotateY(0deg) translateX(0);
        transform-origin: left center;
        filter: blur(0);
    }
}

@keyframes page-turn-backward {
    from {
        opacity: 0;
        transform: perspective(960px) rotateY(14deg) translateX(-28px);
        transform-origin: right center;
        filter: blur(1.5px);
    }
    to {
        opacity: 1;
        transform: perspective(960px) rotateY(0deg) translateX(0);
        transform-origin: right center;
        filter: blur(0);
    }
}

.creation-stage-layout.page-turn-forward {
    animation: page-turn-forward 0.48s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.creation-stage-layout.page-turn-backward {
    animation: page-turn-backward 0.48s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes ink-fade {
    from {
        opacity: 0;
        transform: translateY(8px);
        filter: blur(2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.ink-reveal,
.creation-stage-layout .document-group,
.creation-stage-layout .document-group-cluster,
.character-sheet > .document-group,
.character-sheet > .document-group-cluster > .document-group,
.character-sheet > .sheet-identity {
    animation: ink-fade 0.55s ease-out both;
}

.creation-stage-layout.page-turn-forward .document-group,
.creation-stage-layout.page-turn-forward .document-group-cluster,
.creation-stage-layout.page-turn-backward .document-group,
.creation-stage-layout.page-turn-backward .document-group-cluster {
    animation-name: ink-fade;
    animation-duration: 0.55s;
    animation-timing-function: ease-out;
    animation-fill-mode: both;
}

.creation-stage-layout > .document-group:nth-child(1),
.creation-stage-layout > .creation-stage-topic-row:nth-child(1),
.creation-stage-layout > .document-group-cluster:nth-child(1) {
    animation-delay: 0.04s;
}

.creation-stage-layout > .document-group:nth-child(2),
.creation-stage-layout > .creation-stage-topic-row:nth-child(2),
.creation-stage-layout > .document-group-cluster:nth-child(2) {
    animation-delay: 0.1s;
}

.creation-stage-layout > .document-group:nth-child(3),
.creation-stage-layout > .creation-stage-topic-row:nth-child(3),
.creation-stage-layout > .document-group-cluster:nth-child(3) {
    animation-delay: 0.16s;
}

.creation-stage-layout > .document-group:nth-child(4),
.creation-stage-layout > .creation-stage-topic-row:nth-child(4),
.creation-stage-layout > .document-group-cluster:nth-child(4),
.creation-stage-layout > #magic_schools_stage {
    animation-delay: 0.22s;
}

.creation-stage-layout > .document-group:nth-child(n + 5),
.creation-stage-layout > .creation-submit-row {
    animation-delay: 0.28s;
}

.seal-press {
    position: relative;
    isolation: isolate;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        filter 0.18s ease;
}

.seal-press::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(139, 42, 42, 0.55);
    box-shadow:
        0 0 0 1px rgba(196, 163, 90, 0.35),
        inset 0 0 10px rgba(139, 42, 42, 0.25);
    opacity: 0;
    pointer-events: none;
    transform: scale(0.7);
    z-index: -1;
}

.seal-press:hover {
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255, 235, 190, 0.45) inset,
        0 12px 22px rgba(0, 0, 0, 0.4);
}

.seal-press:active {
    transform: scale(0.93) translateY(1px);
    filter: brightness(0.94) saturate(1.05);
    box-shadow:
        0 0 0 1px rgba(90, 24, 24, 0.35),
        0 2px 6px rgba(0, 0, 0, 0.45) inset;
}

.seal-press:active::after {
    animation: seal-stamp 0.38s ease-out;
}

@keyframes seal-stamp {
    0% {
        opacity: 0;
        transform: scale(0.65);
    }
    35% {
        opacity: 0.85;
        transform: scale(1.05);
    }
    100% {
        opacity: 0;
        transform: scale(1.2);
    }
}

button.seal-press {
    background:
        linear-gradient(180deg, var(--leaf-gold-bright) 0%, var(--leaf-gold) 72%, #a8883f 100%);
    color: var(--ink-sepia);
    border: 1px solid rgba(58, 42, 28, 0.5);
    font-weight: 600;
    padding: 0.55em 1.1em;
}

button.seal-press:hover {
    background-color: transparent;
    filter: brightness(1.05);
}

@media (prefers-reduced-motion: reduce) {
    .zoom-tilt,
    .home-hero__brand,
    .home-hero__line,
    .home-hero__welcome,
    .home-hero__cta,
    .ink-reveal,
    .creation-stage-layout.page-turn-forward,
    .creation-stage-layout.page-turn-backward,
    .creation-stage-layout .document-group,
    .creation-stage-layout .document-group-cluster,
    .character-sheet > .document-group,
    .character-sheet > .document-group-cluster > .document-group,
    .character-sheet > .sheet-identity,
    .seal-press::after,
    .adornment-left,
    .adornment-right {
        animation: none !important;
        transition: none !important;
    }

    .zoom-tilt:hover,
    .seal-press:hover,
    .seal-press:active {
        transform: none;
    }
}

@media (max-width: 640px) {
    .home-hero {
        --home-pad-x: 2.75rem;
        min-height: calc(100dvh - 9rem);
        padding-top: 1rem;
    }

    :root {
        --banner-width: 28px;
        --content-inset: 2.5rem;
    }
}

/* Legacy marketing hooks (kept for any residual markup) */
.main {
    font-family: var(--font-display);
    display: flex;
    margin: 0 2em;
    padding: 0 1em;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    color: var(--fg);
}

.subcontainer {
    text-align: center;
    padding: 20px;
    background-color: rgba(36, 28, 20, 0.55);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.logo {
    margin-bottom: 20px;
    filter: drop-shadow(5px 5px 5px rgba(0, 0, 0, 0.5));
}

.get-started-btn {
    background: linear-gradient(180deg, var(--leaf-gold-bright) 0%, var(--leaf-gold) 100%);
    color: var(--ink-sepia);
    border: 1px solid rgba(58, 42, 28, 0.45);
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.get-started-btn a {
    text-decoration: none;
    color: var(--ink-sepia);
}

.get-started-btn:hover {
    filter: brightness(1.06);
}

/* --------------------------------------------------------------------------
   4. Entity lists + simple forms (login / add)
   -------------------------------------------------------------------------- */

.page-panel,
.container {
    max-width: 42rem;
    margin: 1.5rem auto;
    padding: 1.35rem 1.5rem 1.6rem;
    background: rgba(36, 28, 20, 0.45);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    box-sizing: border-box;
}

.auth-page {
    width: min(100%, 22rem);
    margin: 2rem auto;
    padding: 1.5rem 1.35rem 1.65rem;
    background: rgba(36, 28, 20, 0.45);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    box-sizing: border-box;
    text-align: left;
}

.auth-page h1 {
    margin-top: 0;
    margin-bottom: 1rem;
}

.auth-page form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
}

.auth-page .text-input[type="text"],
.auth-page .pass-input[type="password"],
.auth-page .num-input[type="number"],
.auth-page input[type="submit"],
.auth-page .seal-press {
    width: 100%;
    max-width: none;
}

.auth-page .seal-press {
    margin-top: 0.35rem;
}

.auth-page .form-error {
    margin-top: 0.85rem;
    text-align: center;
}

.auth-page br {
    display: none;
}

/* Login / register / reauth inputs ? class-scoped, not global form/input */
.text-input[type="text"],
.pass-input[type="password"],
.num-input[type="number"] {
    width: 100%;
    max-width: 28em;
    height: 40px;
    margin-bottom: 1rem;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-cell);
    color: var(--fg);
    font-family: var(--font-body);
    box-sizing: border-box;
    display: block;
}

.text-input[type="text"]:focus,
.pass-input[type="password"]:focus,
.num-input[type="number"]:focus {
    outline: none;
    border-color: var(--leaf-gold-bright);
    box-shadow: 0 0 0 2px rgba(196, 163, 90, 0.2);
}

input[type="submit"] {
    width: 100%;
    max-width: 28em;
    height: 42px;
    margin-top: 0.35rem;
    background: linear-gradient(180deg, var(--leaf-gold-bright) 0%, var(--leaf-gold) 100%);
    color: var(--ink-sepia);
    border: 1px solid rgba(58, 42, 28, 0.45);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
}

input[type="submit"]:hover {
    filter: brightness(1.06);
}

.session-reauth-modal .text-input,
.session-reauth-modal .pass-input,
.session-reauth-modal input[type="submit"] {
    max-width: 100%;
}

.entity-highlight {
    background-color: rgba(36, 28, 20, 0.55);
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--fg);
}

.player-list-container,
.character-list-container {
    margin: 0 auto;
    max-width: 72rem;
    text-align: center;
    background: rgba(36, 28, 20, 0.4);
    padding: 1.25rem 1.35rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.player-list-grid {
    display: inline-flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.character-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.player-list-item,
.character-list-item {
    background-color: rgba(22, 17, 13, 0.72);
    padding: 1.1rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--fg);
    font-size: large;
    margin: 0.85rem;
}

.character-list-item {
    margin-bottom: 1.25em;
    min-width: 0;
    overflow: hidden;
}

.player-list-item a,
.character-list-item a {
    color: var(--accent-cool);
    text-decoration: none;
}

.character-list-item a {
    margin: 1em;
}

.character-list-item-name {
    display: block;
    margin: 0.4em 0.5em !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-manuscript);
    font-weight: normal;
    letter-spacing: 0.03em;
    color: var(--leaf-gold-bright);
}

.player-list-item a:hover,
.character-list-item a:hover {
    color: var(--parchment);
}

/* --- Players roster --- */

.player-roster {
    max-width: 44rem;
    margin: 0 auto;
    padding: 0.5rem 0 2rem;
}

.player-roster__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.player-roster__lede {
    margin: -0.35rem auto 1.1rem;
    max-width: 28rem;
    color: var(--fg-muted);
    font-size: 1.05rem;
    line-height: 1.45;
}

.player-roster__stats {
    display: flex;
    justify-content: center;
    gap: 1.75rem;
    margin-top: 0.35rem;
}

.player-roster__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-width: 5.5rem;
}

.player-roster__stat-value {
    font-family: var(--font-manuscript);
    font-size: 2rem;
    line-height: 1;
    color: var(--leaf-gold-bright);
}

.player-roster__stat-label {
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.player-roster__status {
    text-align: center;
    color: var(--fg-muted);
}

.player-roster__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.player-roster__item {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(22, 17, 13, 0.55);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.player-roster__item:hover {
    border-color: var(--leaf-gold);
    background: rgba(36, 28, 20, 0.72);
}

.player-roster__item--you {
    border-color: rgba(226, 201, 132, 0.55);
    box-shadow: 0 0 0 1px rgba(196, 163, 90, 0.18);
}

.player-roster__link {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 0.5rem 0.95rem 1.15rem;
    text-decoration: none;
    color: inherit;
}

.player-roster__delete {
    align-self: center;
    flex: 0 0 auto;
    margin-right: 0.75rem;
    padding: 0.35em 0.8em;
    border: 1px solid rgba(160, 70, 55, 0.65);
    border-radius: 2px;
    background: transparent;
    color: #c47a68;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
}

.player-roster__delete:hover {
    background: rgba(160, 70, 55, 0.18);
    color: #e8b4a8;
}

.player-roster__identity {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.45rem 0.75rem;
    min-width: 0;
}

.player-roster__nick {
    font-family: var(--font-manuscript);
    font-size: 1.35rem;
    letter-spacing: 0.03em;
    color: var(--leaf-gold-bright);
}

.player-roster__name {
    color: var(--fg-muted);
    font-size: 0.95rem;
}

.player-roster__badge {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-sepia);
    background: linear-gradient(180deg, var(--leaf-gold-bright), var(--leaf-gold));
    border: 1px solid rgba(58, 42, 28, 0.35);
    border-radius: 2px;
    padding: 0.15rem 0.4rem;
}

.player-roster__heroes {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
    flex: 0 0 auto;
}

.player-roster__heroes-count {
    font-family: var(--font-manuscript);
    font-size: 1.75rem;
    line-height: 1;
    color: var(--parchment);
}

.player-roster__heroes-label {
    font-size: 0.78rem;
    color: var(--fg-dim);
    white-space: nowrap;
}

.player-roster__footer {
    display: flex;
    justify-content: center;
    margin-top: 1.75rem;
}

.player-roster__cta {
    color: var(--accent-cool);
    text-decoration: none;
    border-bottom: 1px solid rgba(226, 201, 132, 0.35);
    padding-bottom: 0.1rem;
}

.player-roster__cta:hover {
    color: var(--parchment);
}

.player-profile__header {
    text-align: center;
    margin-bottom: 1.25rem;
}

.player-profile__eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.player-profile__nick {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.player-profile__name {
    margin: 0.35rem 0 0;
    color: var(--fg-muted);
}

.player-profile__heroes {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin: 1.25rem 0 1.5rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(12, 10, 8, 0.35);
}

.player-profile__heroes-count {
    font-family: var(--font-manuscript);
    font-size: 3rem;
    line-height: 1;
    color: var(--leaf-gold-bright);
}

.player-profile__heroes-label {
    color: var(--fg-muted);
    letter-spacing: 0.04em;
}

.player-profile__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.player-profile__delete-hint {
    margin: 0;
    width: 100%;
    text-align: center;
    color: var(--fg-muted);
    font-size: 0.9rem;
}

.player-profile__back {
    text-align: center;
    margin: 0;
}

.player-profile__back a {
    color: var(--fg-muted);
    text-decoration: none;
}

.player-profile__back a:hover {
    color: var(--leaf-gold-bright);
}

/* --- Parties --- */

.party-roster {
    max-width: 44rem;
    margin: 0 auto;
    padding: 0.5rem 0 2rem;
}

.party-roster__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.party-roster__lede {
    margin: -0.35rem auto 1.1rem;
    max-width: 30rem;
    color: var(--fg-muted);
    font-size: 1.05rem;
    line-height: 1.45;
}

.party-roster__found {
    margin-bottom: 1.75rem;
}

.party-roster__found h2 {
    margin: 0 0 0.85rem;
    font-family: var(--font-manuscript);
    font-size: 1.35rem;
    color: var(--leaf-gold-bright);
}

.party-roster__found-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1rem;
}

.party-roster__label {
    flex: 1 1 100%;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.party-roster__input {
    flex: 1 1 12rem;
    min-width: 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(22, 17, 13, 0.65);
    color: var(--parchment);
    font: inherit;
}

.party-roster__input:focus {
    outline: none;
    border-color: var(--leaf-gold);
}

.party-roster__status {
    text-align: center;
    color: var(--fg-muted);
}

.party-roster__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.party-roster__item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(22, 17, 13, 0.55);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.party-roster__item:hover {
    border-color: var(--leaf-gold);
    background: rgba(36, 28, 20, 0.72);
}

.party-roster__item--yours {
    border-color: rgba(226, 201, 132, 0.55);
    box-shadow: 0 0 0 1px rgba(196, 163, 90, 0.18);
}

.party-roster__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1.15rem;
    text-decoration: none;
    color: inherit;
}

.party-roster__identity {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.45rem 0.75rem;
    min-width: 0;
}

.party-roster__name {
    font-family: var(--font-manuscript);
    font-size: 1.35rem;
    letter-spacing: 0.03em;
    color: var(--leaf-gold-bright);
}

.party-roster__founder {
    color: var(--fg-muted);
    font-size: 0.95rem;
}

.party-roster__badge {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-sepia);
    background: linear-gradient(180deg, var(--leaf-gold-bright), var(--leaf-gold));
    border: 1px solid rgba(58, 42, 28, 0.35);
    border-radius: 2px;
    padding: 0.15rem 0.4rem;
}

.party-roster__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    flex: 0 0 auto;
    font-size: 0.85rem;
    color: var(--fg-dim);
    text-align: right;
}

.party-page {
    max-width: 40rem;
    margin: 0 auto;
}

.party-page__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.party-page__eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.party-page__title {
    margin: 0;
    font-family: var(--font-manuscript);
    font-size: 2rem;
    color: var(--leaf-gold-bright);
}

.party-page__founder {
    margin: 0.35rem 0 0;
    color: var(--fg-muted);
}

.party-page__section {
    margin: 1.5rem 0;
}

.party-page__section h2 {
    margin: 0 0 0.75rem;
    font-family: var(--font-manuscript);
    font-size: 1.25rem;
    color: var(--parchment);
}

.party-page__row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.party-page__empty,
.party-page__hint {
    color: var(--fg-muted);
    font-size: 0.95rem;
}

.party-page__members,
.party-page__achievements {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.party-page__achievements {
    list-style: decimal;
    padding-left: 1.25rem;
}

.party-page__member,
.party-page__achievement {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(22, 17, 13, 0.45);
}

.party-page__member-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.party-page__member-name {
    font-family: var(--font-manuscript);
    color: var(--leaf-gold-bright);
}

.party-page__member-player {
    font-size: 0.85rem;
    color: var(--fg-dim);
}

.party-page__remove {
    flex: 0 0 auto;
    padding: 0.3em 0.7em;
    border: 1px solid rgba(160, 70, 55, 0.65);
    border-radius: 2px;
    background: transparent;
    color: #c47a68;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
}

.party-page__remove:hover:not(:disabled) {
    background: rgba(160, 70, 55, 0.18);
    color: #e8b4a8;
}

.party-page__remove:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.party-page__actions {
    display: flex;
    justify-content: center;
    margin: 1.75rem 0 1rem;
}

.party-page__back {
    text-align: center;
    margin: 0;
}

.party-page__back a {
    color: var(--fg-muted);
    text-decoration: none;
}

.party-page__back a:hover {
    color: var(--leaf-gold-bright);
}

.character-list-item p {
    color: var(--fg-muted);
    margin: 0.3em;
    font-size: 0.8em;
}

.character-list-item-system {
    display: flow;
    margin: 0.8em;
    color: var(--fg-dim);
}

.character-list-delete {
    display: block;
    margin: 1em auto 0;
    padding: 0.35em 0.9em;
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    color: var(--danger-soft);
    cursor: pointer;
    font: inherit;
    font-size: 0.85em;
}

.character-list-delete:hover {
    background: rgba(196, 92, 92, 0.18);
    color: #ffd0d0;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.confirm-actions button {
    padding: 0.45em 1.1em;
    border-radius: var(--radius-sm);
    font: inherit;
    cursor: pointer;
}

.confirm-actions button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.confirm-cancel {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    color: var(--fg);
}

.confirm-danger {
    background: rgba(122, 40, 40, 0.85);
    border: 1px solid var(--danger);
    color: #ffe0e0;
}

.confirm-danger:hover:not(:disabled) {
    background: rgba(147, 56, 56, 0.95);
}

.not-found-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem var(--content-inset);
    text-align: center;
}

.json-preview {
    white-space: pre-wrap;
    max-height: 24em;
    overflow: auto;
    margin: 1em 0;
    padding: 0.85em 1em;
    background: var(--bg-cell);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--fg-muted);
    font-size: 0.85em;
    line-height: 1.4;
}

/* --------------------------------------------------------------------------
   5. Document / character creation
   Layout contracts:
     .doc-page              ? content column; children do not size the viewport
     .document-content      ? flex wrap flow
     .document-group        ? form panel (intrinsic controls, capped by parent)
     .document-group-table  ? data table (CSS grid + display:contents rows)
     .document-group-cluster? horizontal row of panels
     .creation-stage-topic-row ? full-width centering wrapper
   -------------------------------------------------------------------------- */

.doc-page {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 0 0 2rem;
    box-sizing: border-box;
}

.doc-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em;
    margin: 0 0 1em;
    align-items: center;
}

.doc-page-actions button.seal-press,
.doc-page-actions .seal-press {
    min-width: 6em;
}

.document-content {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Creation stage: same flow; topic/submit/clusters span full width */
.creation-stage-layout > .creation-stage-topic-row,
.creation-stage-layout > .creation-submit-row,
.creation-stage-layout > .document-group-cluster,
.creation-stage-layout > #magic_schools_stage {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.creation-stage-layout > .creation-stage-topic-row {
    display: flex;
    justify-content: center;
}

.creation-stage-topic-row > .creation-stage-topic {
    flex: 0 1 auto;
    width: auto;
    max-width: min(100%, 32em);
    min-width: min(100%, 16em);
    box-sizing: border-box;
}

.creation-submit-row {
    display: flex;
    justify-content: center;
    margin: 0.6em 0 1em;
}

/* Prefer wrapping over horizontal scroll when the viewport has room */
.document-group-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: var(--gap);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.document-group-cluster > .document-group {
    flex: 0 1 auto;
    margin-top: 0;
}

#magic_schools_stage {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: var(--gap);
}

/* --- Panels --- */

.document-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0.6em;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-sizing: border-box;
    background-color: rgba(22, 17, 13, 0.42);
}

.document-group-wide {
    max-width: 100%;
    /* Scroll only when row content exceeds the available page width */
    overflow-x: auto;
}

.document-group-title {
    margin-bottom: var(--gap);
    font-size: large;
    font-weight: normal;
    font-family: var(--font-manuscript);
    letter-spacing: 0.03em;
    color: var(--leaf-gold-bright);
    text-align: center;
}

.document-header {
    font-size: large;
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
}

.document-header-item {
    min-width: 12em;
    margin-top: 1em;
}

.document-description-textblock {
    min-width: 7em;
    display: inline-block;
    max-width: 40em;
    align-content: center;
}

.document-label,
.document-label-short {
    display: inline-block;
    align-content: center;
}

.document-label {
    min-width: 7em;
}

.document-label-short {
    min-width: 4em;
}

.document-label-collapsed {
    display: none;
}

/* --- Rows (panel contract: fill group width; no max-content) --- */

.document-group-item,
.document-group-header-item {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3em;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}

.document-group-header-item {
    margin-top: 1em;
}

.document-group-item.form-field-row,
.document-group-item.resources-choice-row,
.document-group-item.creation-summary-row {
    flex-wrap: wrap;
    align-self: stretch;
}

.form-field-row {
    align-items: center;
    gap: 0.4em;
}

.form-field-row .document-value-selection,
.form-field-row .document-value-wide {
    flex: 0 1 auto;
    min-width: 10em;
    max-width: 22em;
}

/* --- Flex column tracks (non-grid tabular rows: weapons, armor, ?) --- */

.document-group-item-header-title,
.document-group-item-title {
    flex: 0 0 var(--col-title);
    width: var(--col-title);
    max-width: var(--col-title);
    min-width: var(--col-title);
    box-sizing: border-box;
    text-align: left;
    overflow-wrap: break-word;
    padding: 0.35em 0.45em;
}

.document-group-item-header-title {
    border: none;
    color: var(--fg-dim);
    align-self: flex-end;
}

.document-group-item-title {
    font-size: smaller;
}

.document-group-item-header-formula,
.document-group-item-formula,
.document-group-item-properties,
.document-group-item-damage {
    flex: 0 0 var(--col-formula);
    width: var(--col-formula);
    max-width: var(--col-formula);
    min-width: var(--col-formula);
    box-sizing: border-box;
    text-align: left;
    overflow-wrap: break-word;
    padding: 0.35em 0.45em;
}

.document-group-item-header-formula {
    border: none;
    color: var(--fg-muted);
    align-self: flex-end;
}

.document-group-item-header-base,
.document-group-item-base,
.document-group-item-base-std,
.document-group-item-header-small-std {
    flex: 0 0 var(--col-std);
    width: var(--col-std);
    max-width: var(--col-std);
    min-width: var(--col-std);
    box-sizing: border-box;
    text-align: left;
    padding: 0.35em 0.45em;
}

.document-group-item-header-base,
.document-group-item-header-small-std {
    border: none;
    color: var(--fg-muted);
    align-self: flex-end;
}

.document-group-item-header-small-std {
    font-size: small;
}

.document-group-item-header-bonus,
.document-group-item-bonus,
.document-group-item-header-small,
.document-group-item-header-total,
.document-group-item-total,
.document-value,
.document-group-item-header {
    flex: 0 0 var(--col-num);
    width: var(--col-num);
    max-width: var(--col-num);
    min-width: var(--col-num);
    box-sizing: border-box;
    padding: 0.35em 0.45em;
}

.document-group-item-header-bonus,
.document-group-item-header-small,
.document-group-item-header-total,
.document-group-item-header {
    border: none;
    color: var(--fg-muted);
    align-self: flex-end;
    text-align: left;
}

.document-group-item-header-small {
    font-size: small;
    line-height: 1.15;
}

/* Shared cell chrome */
.document-group-item-base,
.document-group-item-base-std,
.document-group-item-properties,
.document-group-item-formula,
.document-group-item-bonus,
.document-group-item-damage,
.document-group-item-total {
    border: none;
    border-radius: var(--radius-md);
    background-color: var(--bg-cell);
    color: var(--fg-muted);
    align-content: center;
    overflow: hidden;
}

.document-group-item-base,
.document-group-item-base-std,
.document-group-item-properties,
.document-group-item-formula {
    font-size: x-small;
}

.document-group-item-bonus,
.document-group-item-damage {
    font-size: smaller;
}

.document-group-item-total {
    min-height: 1.8em;
    font-weight: bold;
    color: var(--fg);
}

.skill-check-total {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 0.12em;
    line-height: 1.15;
    overflow: visible;
    padding: 0.15em 0.25em;
}

.skill-check-total-value {
    font-weight: bold;
}

.skill-check-mods {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.15em 0.3em;
    max-width: 18em;
}

.skill-check-mod {
    display: inline-flex;
    align-items: baseline;
    gap: 0.18em;
    font-size: 0.68em;
    font-weight: 600;
    opacity: 0.88;
    white-space: nowrap;
    cursor: help;
}

.skill-check-mod-hint {
    font-weight: 500;
    opacity: 0.78;
    max-width: 14em;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Data tables (preferred aligned layout) --- */

.document-group-table {
    display: grid;
    column-gap: 0.5rem;
    row-gap: 0.2rem;
    align-items: center;
    justify-content: start;
    /* Prefer natural column width; wrap to next line instead of shrinking */
    flex: 0 0 auto;
    width: max-content;
    max-width: 100%;
    /* Scroll only when a single table is wider than the page */
    overflow-x: auto;
}

.document-group-cols-attr {
    grid-template-columns: var(--col-title) repeat(4, var(--col-num));
}

.document-group-cols-attr-full {
    grid-template-columns: var(--col-title) repeat(5, var(--col-num));
}

.document-group-cols-derived {
    grid-template-columns: var(--col-title) var(--col-formula) var(--col-std) var(--col-num) var(--col-num);
}

.document-group-cols-skills {
    grid-template-columns: var(--col-title) var(--col-formula) var(--col-std) repeat(5, var(--col-num));
}

.document-group-cols-pair {
    grid-template-columns: var(--col-title) var(--col-num);
}

.document-group-table > .document-group-title,
.document-group-table > .validation-info,
.document-group-table > .validation-error,
.document-group-table > br,
.document-group-table > .document-group-item.form-field-row {
    grid-column: 1 / -1;
}

.document-group-table > .document-group-item:not(.form-field-row) {
    display: contents;
}

.document-group-table > .document-group-item:not(.form-field-row) > * {
    flex: none;
    width: auto;
    max-width: none;
    min-width: 0;
}

.document-group-table input.document-value {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* --- Inputs / values --- */

.document-value {
    margin: 0;
    text-align: left;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background-color: var(--bg-cell);
    color: var(--fg);
    min-height: 1.8em;
    font-size: inherit;
    font-family: var(--font-body);
    -moz-appearance: textfield;
    appearance: textfield;
}

.document-value::-webkit-outer-spin-button,
.document-value::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.document-value-wide,
.document-value-multiline,
.document-value-input {
    min-width: 10em;
    min-height: 1.8em;
    text-align: left;
    padding: 0.35em 0.7em;
    align-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-cell);
    color: var(--fg);
    font-family: var(--font-body);
    box-sizing: border-box;
}

.document-value-multiline {
    min-height: 4em;
    width: min(28em, 100%);
    resize: vertical;
}

.form-field-row .document-value-input {
    flex: 0 1 auto;
    min-width: 10em;
    max-width: 22em;
}

.document-value-narrow {
    width: 3.5em;
    text-align: center;
}

.document-value-selection {
    min-height: 1.8em;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg-cell);
    color: var(--fg);
    font-family: var(--font-body);
    min-width: 13em;
    padding: 0.25em 0.4em;
}

.spacer-1em {
    flex: 0 0 1em;
    width: 1em;
}
.spacer-2em {
    flex: 0 0 2em;
    width: 2em;
}
.spacer-3em {
    flex: 0 0 3em;
    width: 3em;
}
.spacer-4em {
    flex: 0 0 4em;
    width: 4em;
}
.spacer-5em {
    flex: 0 0 5em;
    width: 5em;
}

.validation-error {
    color: var(--danger);
    font-size: small;
    margin-left: 0.3em;
    align-self: center;
}

.validation-info {
    font-size: small;
    margin-left: 0.3em;
    margin-top: 0.6em;
    align-self: center;
}

/* --- Creation chrome --- */

.creation-stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em;
    align-items: center;
    justify-content: center;
    margin: 0.8em 1em 1.2em;
}

.creation-step {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.35em 0.7em;
    border: 1px solid var(--border);
    border-radius: 999px;
    background-color: rgba(22, 17, 13, 0.72);
    color: var(--fg-dim);
    font-size: small;
}

.creation-step-active {
    border-color: var(--leaf-gold);
    background-color: rgba(196, 163, 90, 0.16);
    color: var(--leaf-gold-bright);
    font-weight: bold;
}

.creation-step-done {
    border-color: rgba(196, 163, 90, 0.55);
    color: var(--parchment-deep);
}

.creation-step-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4em;
    height: 1.4em;
    border-radius: 50%;
    background-color: var(--bg-deep);
    color: var(--leaf-gold-bright);
}

.creation-step-actions {
    display: inline-flex;
    gap: 0.5em;
    margin-left: 0.8em;
}

/* Constant stage chrome: description + attribute totals under the stepper */
.creation-stage-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65em;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.8em;
    box-sizing: border-box;
}

.creation-stage-description {
    flex: 0 1 auto;
    width: fit-content;
    max-width: min(100%, 36em);
    margin: 0 auto;
    padding: 0.15em 0.75em 0.25em;
    box-sizing: border-box;
    text-align: center;
}

.creation-stage-description-title {
    margin: 0 0 0.25em;
    font-size: 1.15rem;
    font-weight: normal;
    font-family: var(--font-manuscript);
    letter-spacing: 0.03em;
    color: var(--leaf-gold-bright);
    line-height: 1.25;
}

.creation-stage-description-text {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--fg-muted);
}

.creation-attr-totals {
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    padding: 0.55em 0.85em 0.7em;
    box-sizing: border-box;
}

.creation-attr-totals-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: stretch;
    gap: 0.35em;
    width: 100%;
    overflow-x: auto;
}

.creation-attr-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 3.25em;
    padding: 0.35em 0.4em;
    border: 1px solid var(--border);
    border-radius: 0.35em;
    background-color: var(--bg-raised, var(--bg-panel));
    text-align: center;
}

.creation-attr-total-label {
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fg-muted);
    line-height: 1.2;
}

.creation-attr-total-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
    margin-top: 0.15em;
    font-variant-numeric: tabular-nums;
}

.creation-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85em 1.4em;
    align-items: flex-start;
    justify-content: center;
}

.creation-summary-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25em;
    min-width: 7.5em;
    flex: 0 1 auto;
    max-width: 14em;
}

.creation-summary-item .document-label-short {
    min-width: 0;
    color: var(--fg-muted);
    font-size: smaller;
    line-height: 1.2;
}

.creation-summary-item .document-group-item-total {
    max-width: none;
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
    box-sizing: border-box;
    padding: 0.35em 0.6em;
    font-size: smaller;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}

/* --- Finished character sheet --- */

.character-sheet {
    justify-content: center;
    align-items: flex-start;
    gap: 0.55rem;
}

/* Rows / panels hug content ? do not force full page width */
.character-sheet > .sheet-identity,
.character-sheet > .document-group-cluster,
.character-sheet > #owned-traits-overview,
.character-sheet > #sheet-spells,
.character-sheet > #sheet-weapons,
.character-sheet > #sheet-armor {
    flex: 0 1 auto;
    width: max-content;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    align-self: center;
}

.character-sheet > .document-group-cluster {
    /* Same flex line ? equal height for siblings (groups or stacks) */
    align-items: stretch;
    justify-content: center;
    gap: 0.55rem;
    margin-bottom: 0.15em;
}

.character-sheet .sheet-skills-side-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.55rem;
    flex: 0 1 auto;
    align-self: stretch;
    width: max-content;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Extra vertical space in a stretched stack is shared by its groups */
.character-sheet .sheet-skills-side-stack > .document-group {
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    min-height: 0;
}

.character-sheet .document-group-cluster > .document-group {
    align-self: stretch;
    height: auto;
}

.character-sheet .document-group {
    padding: 0.45em 0.55em;
    flex: 0 1 auto;
    width: max-content;
    max-width: 100%;
    box-sizing: border-box;
}

.character-sheet .document-group-wide {
    width: max-content;
    max-width: 100%;
}

.character-sheet .document-group-title {
    margin-bottom: 0.35em;
}

.character-sheet .document-group-item,
.character-sheet .document-group-item.form-field-row {
    padding: 0.15em 0.25em;
}

.character-sheet .resources-overview {
    /* 2-column list ? never needs horizontal scroll; keep popovers unclipped */
    overflow: visible;
}

.character-sheet .document-group-item-title.has-tooltip {
    overflow: visible;
}

.sheet-identity {
    text-align: left;
    margin-bottom: 0.25em;
    padding: 0.45em 0.75em;
}

.sheet-identity .document-group-title {
    text-align: left;
    font-size: clamp(1.35rem, 2.5vw, 1.75rem);
}

.sheet-identity-meta {
    margin: 0.2em 0 0.35em;
    opacity: 0.85;
    font-size: 0.95em;
}

.sheet-identity .document-description-textblock {
    display: block;
    margin: 0.35em 0 0;
    text-align: left;
    max-width: min(40em, 100%);
}

.sheet-field-value {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
    padding: 0.2em 0.35em;
    text-align: left;
    font-weight: 600;
    color: var(--fg);
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

#sheet-profile {
    flex: 0 1 auto;
    width: max-content;
    min-width: min(100%, 16em);
    max-width: min(100%, 28em);
}

#sheet-profile .document-label {
    flex: 0 0 7.5em;
    min-width: 6.5em;
}

#sheet-profile .form-field-row {
    align-items: flex-start;
    width: 100%;
}

#sheet-profile .sheet-field-value {
    flex: 1 1 10em;
}

.character-sheet #owned-traits-overview {
    margin-top: 0.15em;
}

.character-sheet .owned-traits-columns {
    justify-content: center;
    gap: 0.75em 1.25em;
    padding: 0.15em 0.25em 0.35em;
}

.character-sheet .owned-traits-column {
    flex: 0 1 18em;
    max-width: 24em;
    min-width: 12em;
}

.character-sheet .selection-detail {
    margin: 0.25em 0;
    padding: 0.4em 0.55em;
}

#owned-traits-overview {
    margin-top: 0.4em;
}

.owned-traits-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 1em 2em;
    justify-content: center;
    padding: 0.4em 0.8em 0.8em;
}

.owned-traits-column {
    flex: 1 1 16em;
    max-width: 28em;
    min-width: 12em;
}

.owned-traits-heading {
    font-size: smaller;
    font-weight: 700;
    color: var(--fg-muted);
    margin-bottom: 0.35em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.2em;
}

.owned-traits-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35em;
}

.owned-traits-list .selection-detail {
    margin: 0;
}

.owned-traits-list li {
    font-size: smaller;
    line-height: 1.35;
    padding: 0.25em 0.5em;
    background: var(--bg-cell);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    word-break: break-word;
}

/* --- Resources --- */

.resources-choice-row {
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4em;
}

.resources-choice-label {
    min-width: 10em;
    flex: 1 1 10em;
}

.resources-choice-row .document-value-selection {
    flex: 0 1 auto;
    min-width: 10em;
    max-width: 22em;
}

.resources-allocator-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45em 0.9em;
    margin-top: 0.5em;
}

.resources-allocator-item {
    display: flex;
    align-items: center;
    gap: 0.35em;
    flex: 0 1 9.5em;
    min-width: 8.5em;
    padding: 0.25em 0.35em;
}

.resources-allocator-item .document-label-short {
    min-width: 5.5em;
    flex: 1 1 auto;
}

.resources-mondzeichen .document-value-selection {
    flex: 0 1 auto;
    max-width: 22em;
}

/* --- Tooltips + selection detail --- */

.has-tooltip {
    position: relative;
    /* Sit above siblings while hovered so the popover is not painted under them */
    z-index: 1;
}

.has-tooltip:hover {
    z-index: 40;
}

/*
 * Scroll containers clip absolute ::after popovers. While a tooltip is open, drop the
 * clip so the hover text can extend outside the panel (overflow-x:auto alone also
 * forces overflow-y to compute to auto).
 */
.document-group-table:has(.has-tooltip:hover),
.document-group-wide:has(.has-tooltip:hover),
.document-group:has(.has-tooltip:hover) {
    overflow: visible;
}

.has-tooltip[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    top: calc(100% + 0.35em);
    z-index: 100;
    box-sizing: border-box;
    width: max-content;
    max-width: min(28em, calc(100vw - 2rem));
    padding: 0.55em 0.7em;
    background: var(--bg-deep);
    color: var(--parchment);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    line-height: 1.35;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    box-shadow: 0 0.25em 0.6em rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

/* Prefer opening toward the page center near the right edge of clusters / trait columns */
.owned-traits-column:last-child .has-tooltip[data-tooltip]:hover::after,
.document-group-cluster > .document-group:last-child .has-tooltip[data-tooltip]:hover::after,
.character-sheet .resources-overview .has-tooltip[data-tooltip]:hover::after {
    left: auto;
    right: 0;
}

.selection-detail,
.mondzeichen-detail {
    margin: 0.6em 0.3em 0.2em;
    padding: 0.6em 0.75em;
    border-left: 3px solid var(--accent);
    background: rgba(153, 119, 0, 0.08);
}

.selection-detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35em 0.85em;
    margin-bottom: 0.35em;
}

.selection-detail-title {
    font-weight: 600;
    font-size: 0.95em;
    flex: 1 1 auto;
    min-width: 8em;
}

.selection-detail-effect,
.mondzeichen-effect {
    font-size: 0.95em;
    line-height: 1.4;
}

.selection-detail-meta {
    margin-top: 0.35em;
    font-size: smaller;
    opacity: 0.9;
}

.selection-detail.mastery-selected,
.selection-detail.strength-selected {
    width: auto;
}

.mastery-selected {
    align-items: flex-start;
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
}

.mastery-selected .document-group-item-properties {
    flex: 1 1 12em;
    width: auto;
    max-width: none;
    min-width: 8em;
    overflow: visible;
}

/* --- Magieschulen / spells --- */

.magic-stage-intro {
    margin: 0.5rem 1rem 1rem;
    max-width: 70rem;
    line-height: 1.4;
}

.magic-school-group {
    margin-bottom: 1.5rem;
}

.magic-pick-section {
    margin: 0.75rem 1rem;
}

.magic-pick-heading {
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.magic-pick-hint {
    margin: 0.5rem 1rem;
    opacity: 0.85;
    font-style: italic;
}

.magic-pick-section .document-group-item {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
}

.custom-weapon-editor {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.weapon-mod-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0.5rem 0 1rem;
    max-height: 22rem;
    overflow-y: auto;
}

.weapon-mod-row {
    display: grid;
    grid-template-columns: minmax(12rem, 1.4fr) minmax(8rem, 1fr) auto minmax(8rem, 1fr);
    gap: 0.35rem 0.6rem;
    align-items: start;
    padding: 0.35rem 0.4rem;
    background: rgba(0, 0, 0, 0.12);
    border-radius: var(--radius-sm);
}

.weapon-mod-check {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
    font-size: 0.92rem;
}

.weapon-mod-meta {
    font-size: 0.82rem;
    opacity: 0.8;
    line-height: 1.35;
}

.weapon-mod-rank {
    max-width: 4.5rem;
}

.weapon-quality-tag {
    margin-left: 0.35rem;
    font-size: 0.82rem;
    color: var(--leaf-gold-bright);
    opacity: 0.9;
}

.spell-card {
    margin: 0.5rem 0 1rem;
    overflow-x: auto;
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.45rem;
    box-sizing: border-box;
}

/* Faint Magieschule wash — documents / creation only (simulation uses vivid FX). */
.school-tint {
    background-color: rgba(var(--school-rgb), var(--school-tint-alpha));
}
.school-tint.school-bann { --school-rgb: var(--school-bann); }
.school-tint.school-beherrschung { --school-rgb: var(--school-beherrschung); }
.school-tint.school-bewegung { --school-rgb: var(--school-bewegung); }
.school-tint.school-erkenntnis { --school-rgb: var(--school-erkenntnis); }
.school-tint.school-fels { --school-rgb: var(--school-fels); }
.school-tint.school-feuer { --school-rgb: var(--school-feuer); }
.school-tint.school-heilung { --school-rgb: var(--school-heilung); }
.school-tint.school-illusion { --school-rgb: var(--school-illusion); }
.school-tint.school-kampf { --school-rgb: var(--school-kampf); }
.school-tint.school-licht { --school-rgb: var(--school-licht); }
.school-tint.school-natur { --school-rgb: var(--school-natur); }
.school-tint.school-schatten { --school-rgb: var(--school-schatten); }
.school-tint.school-schicksal { --school-rgb: var(--school-schicksal); }
.school-tint.school-schutz { --school-rgb: var(--school-schutz); }
.school-tint.school-staerkung { --school-rgb: var(--school-staerkung); }
.school-tint.school-tod { --school-rgb: var(--school-tod); }
.school-tint.school-verwandlung { --school-rgb: var(--school-verwandlung); }
.school-tint.school-wasser { --school-rgb: var(--school-wasser); }
.school-tint.school-wind { --school-rgb: var(--school-wind); }

.character-sheet .school-tint {
    --school-tint-alpha: 0.07;
}

.spell-card-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.spell-ep-cost {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-right: auto;
}

.spell-remove-btn {
    font-size: 0.85rem;
}

.spell-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.spell-table th,
.spell-table td {
    border: 1px solid var(--border);
    padding: 0.35rem 0.5rem;
    vertical-align: top;
    text-align: left;
}

.spell-table th {
    background: rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}

.spell-props-row td {
    white-space: nowrap;
}

.spell-page {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.spell-desc-row td {
    background: rgba(0, 0, 0, 0.15);
}

.spell-description {
    white-space: pre-wrap;
    line-height: 1.45;
    max-width: 100%;
}

.spell-description-label {
    font-weight: 600;
    margin-top: 0.35rem;
    margin-bottom: 0.15rem;
}

.spell-description-label:first-child {
    margin-top: 0;
}

.spell-description-text {
    white-space: pre-wrap;
}

/* Steigern panel */
.steigern-panel {
    margin-bottom: 1.25rem;
    border: 1px solid var(--accent);
    background: var(--bg-raised);
    padding: 0.75rem 1rem;
    max-width: 100%;
    overflow: visible;
}

.steigern-section {
    margin-top: 0.85rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

.steigern-kreatur-card {
    margin: 0.75rem 0;
}

.steigern-kreatur-add,
.steigern-kreatur-upgrade,
.steigern-baukasten {
    margin-top: 0.6rem;
    padding-top: 0.4rem;
    border-top: 1px solid color-mix(in srgb, var(--ink, #3a2f24) 18%, transparent);
}

.steigern-section > .document-label {
    margin-bottom: 0.35rem;
}

.steigern-section > .validation-info {
    display: block;
    margin: 0.55rem 0 0.9rem;
    line-height: 1.45;
}

.steigern-section .form-field-row,
.steigern-pick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin: 0.45rem 0;
    max-width: 100%;
}

.steigern-section .document-label {
    min-width: 10rem;
    max-width: none;
    flex: 0 1 auto;
}

.steigern-control,
.steigern-panel select.steigern-control,
.steigern-panel input.steigern-control {
    flex: 1 1 16rem;
    min-width: 12rem;
    max-width: 100%;
    width: auto;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem;
    background: var(--bg-cell);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.steigern-control-narrow {
    flex: 0 1 8rem;
    min-width: 7rem;
}

.steigern-skill-group {
    margin-top: 0.85rem;
}

.steigern-skill-group:first-of-type {
    margin-top: 0.25rem;
}

.steigern-skill-group-title {
    font-weight: 600;
    margin-bottom: 0.45rem;
    color: var(--accent-cool);
}

.steigern-skill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    column-gap: 2.5rem;
    row-gap: 0.4rem;
    max-height: none;
    overflow: visible;
}

.steigern-skill-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    width: 100%;
    min-width: 0;
}

.steigern-skill-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.steigern-skill-controls {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 0.25rem;
    margin-left: auto;
}

.steigern-skill-controls button {
    min-width: 2rem;
    padding: 0.2rem 0.45rem;
}

.steigern-current {
    color: var(--accent-cool);
    font-size: 0.9em;
}

.steigern-pending {
    background: rgba(196, 163, 90, 0.12);
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.steigern-panel button {
    cursor: pointer;
    flex: 0 0 auto;
}

.steigern-spell-school {
    margin-bottom: 0.75rem;
}


/* --- Kreatur companions (BuU) --- */

.kreaturen-overview,
.kreaturen-picker {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.kreatur-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-cell);
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.kreatur-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
}

.kreatur-card-name {
    font-weight: 600;
    color: var(--fg);
}

.kreatur-card-rank {
    font-size: 0.9em;
    color: var(--accent-cool);
}

.kreatur-card-summary,
.kreatur-card-combat {
    font-size: 0.92em;
    color: var(--fg-muted, var(--fg));
}

.kreatur-add-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.kreatur-remove {
    margin-left: auto;
}

.kreatur-tabs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.75rem;
}

.kreatur-tab-panel {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kreatur-badge {
    font-size: 0.75em;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-cool);
    border: 1px solid var(--border);
    padding: 0.1em 0.45em;
    border-radius: var(--radius-sm);
}

.kreatur-badge-warn {
    color: var(--rubric, #8a3a2a);
}

.kreatur-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.kreatur-tag {
    font-size: 0.8em;
    opacity: 0.85;
    border-bottom: 1px dotted var(--border);
}

.kreatur-card-build {
    font-size: 0.9em;
    font-style: italic;
}

.kreatur-werteblock {
    margin-top: 0.45rem;
    padding: 0.4rem 0.5rem;
    border-left: 2px solid color-mix(in srgb, var(--ink, #3a2f24) 35%, transparent);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.kreatur-werte-line {
    font-size: 0.82em;
    line-height: 1.35;
}

.kreatur-werte-label {
    font-weight: 600;
}

.kreatur-abrichtungen {
    margin-top: 0.4rem;
}

.kreatur-ab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
}

.kreatur-baukasten {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.kreatur-verfeinern {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 22rem;
    overflow: auto;
    padding-right: 0.25rem;
}

.kreatur-verfeinern-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    margin: 0;
}

.kreatur-verfeinern-group legend {
    padding: 0 0.35em;
    font-size: 0.9em;
    color: var(--accent-cool);
}

.kreatur-vf-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.92em;
    margin: 0.2rem 0;
    cursor: pointer;
}

/* ?? Fight emulator ?? */
.page-panel.fight-page,
.fight-page {
    max-width: min(88rem, calc(100vw - 2rem));
    width: 100%;
    margin: 1.5rem auto 3rem;
    padding: 1.85rem 1.75rem 2.35rem;
}

.fight-page__header {
    margin-bottom: 1.75rem;
}

.fight-page__eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.92rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.fight-page__title {
    margin: 0;
    font-family: var(--font-manuscript);
    font-size: clamp(2.15rem, 2.5vw + 1.2rem, 2.85rem);
    color: var(--leaf-gold-bright);
}

.fight-page__title-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.fight-page__info {
    flex: 0 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(196, 163, 90, 0.45);
    border-radius: 50%;
    background: transparent;
    color: var(--leaf-gold);
    font-family: var(--font-body);
    font-size: 0.92rem;
    font-weight: 650;
    font-style: italic;
    line-height: 1;
    cursor: help;
}

.fight-page__info:hover,
.fight-page__info:focus-visible {
    color: var(--leaf-gold-bright);
    border-color: rgba(196, 163, 90, 0.85);
    background: rgba(196, 163, 90, 0.12);
    outline: none;
}

.fight-page__info.has-tooltip[data-tooltip]:hover::after,
.fight-page__info.has-tooltip[data-tooltip]:focus-visible::after {
    left: 0;
    right: auto;
    width: min(34rem, calc(100vw - 3rem));
    max-width: min(34rem, calc(100vw - 3rem));
    font-size: 0.95rem;
    line-height: 1.45;
}

.fight-page__lede {
    margin: 0;
    color: var(--fg-muted);
    font-size: 1.05rem;
    line-height: 1.5;
    max-width: 52rem;
}

.fight-page__section {
    margin: 1.85rem 0;
}

.fight-page__section h2 {
    margin: 0 0 0.65rem;
    font-family: var(--font-manuscript);
    font-size: 1.55rem;
    color: var(--leaf-gold);
}

.fight-page__label {
    display: block;
    margin: 0.9rem 0 0.4rem;
    font-size: 1rem;
    color: var(--fg-dim);
}

.fight-page__select,
.fight-page__input {
    width: 100%;
    max-width: 48rem;
    box-sizing: border-box;
    padding: 0.65rem 0.85rem;
    border: 1px solid rgba(180, 150, 90, 0.35);
    border-radius: 2px;
    background: rgba(20, 16, 12, 0.45);
    color: var(--fg);
    font: inherit;
    font-size: 1.05rem;
}

.fight-page__select:focus,
.fight-page__input:focus {
    outline: 1px solid var(--leaf-gold);
}

.fight-page__meta {
    margin: 0.2rem 0 0.5rem;
    font-size: 1.05rem;
    color: var(--fg-muted);
    min-height: 1.4rem;
}

.fight-page__roster {
    margin: 0;
    padding-left: 1.4rem;
    color: var(--fg);
    font-size: 1.05rem;
    line-height: 1.65;
}

.fight-page__warn {
    color: #c47a68;
}

.fight-page__enemy-blurb {
    margin: 0.9rem 0 0;
    font-size: 1.05rem;
    color: var(--fg-muted);
    line-height: 1.45;
    max-width: 52rem;
}

.fight-page__actions {
    margin-top: 1.5rem;
}

.fight-page__actions .seal-press {
    font-size: 1.05rem;
    padding: 0.7rem 1.35rem;
    min-height: 2.85rem;
}

.fight-page__replay {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin: 0 0 1.25rem;
    padding: 1.1rem 0 0.35rem;
    border-top: 1px solid rgba(180, 150, 90, 0.22);
}

.fight-page__replay-actions,
.fight-page__replay-speeds {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

.fight-page__replay-speed-label {
    margin-right: 0.35rem;
    font-size: 0.95rem;
    color: var(--fg-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.fight-page__replay-btn,
.fight-page__replay-speed {
    appearance: none;
    border: 1px solid rgba(180, 150, 90, 0.45);
    background: transparent;
    color: var(--fg);
    font: inherit;
    font-size: 1rem;
    padding: 0.5rem 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.fight-page__replay-btn--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.85rem;
    height: 2.85rem;
    padding: 0;
}

.fight-page__replay-icon {
    display: block;
    width: 1.4rem;
    height: 1.4rem;
}

.fight-page__replay-btn:hover:not(:disabled),
.fight-page__replay-speed:hover {
    border-color: var(--leaf-gold);
    color: var(--leaf-gold-bright);
}

.fight-page__replay-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.fight-page__replay-speed--active {
    border-color: var(--leaf-gold);
    background: rgba(180, 150, 90, 0.16);
    color: var(--leaf-gold-bright);
}

.fight-page__replay-progress {
    margin: 0;
    font-size: 1rem;
    color: var(--fg-muted);
}

.fight-page__arena {
    position: relative;
    margin: 1rem 0 1.35rem;
    width: 100%;
    max-width: none;
    min-height: min(28rem, 52vh);
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border: 1px solid rgba(180, 150, 90, 0.35);
    background:
        radial-gradient(ellipse at 40% 20%, rgba(180, 150, 90, 0.12), transparent 55%),
        linear-gradient(165deg, #2a241c 0%, #1a1612 55%, #12100d 100%);
}

.fight-page__timeline {
    margin: 0 0 1.25rem;
    padding: 0.85rem 1rem 1rem;
    background: linear-gradient(180deg, rgba(36, 42, 34, 0.92), rgba(28, 32, 26, 0.88));
    border: 1px solid rgba(196, 168, 120, 0.28);
    border-radius: 0.25rem;
    /* Reserve full ribbon chrome before INI so the layout does not jump. */
    min-height: 11.5rem;
    box-sizing: border-box;
}

.fight-page__timeline-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
    min-height: 1.5rem;
}

.fight-page__timeline-title {
    margin: 0;
    font-family: "MedievalName", "Palatino Linotype", Palatino, serif;
    font-size: 1.15rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #e8dcc4;
}

.fight-page__timeline-now {
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    color: #c4b896;
}

.fight-page__timeline-viewport {
    position: relative;
    overflow: hidden;
    min-height: 8.25rem;
    padding-top: 1.35rem;
}

.fight-page__timeline-now-indicator {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 0;
    z-index: 3;
    pointer-events: none;
    transform: translateX(-50%);
}

.fight-page__timeline-now-label {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    padding: 0.1rem 0.45rem;
    border-radius: 0.15rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #1a1610;
    background: #d4a84b;
    white-space: nowrap;
}

.fight-page__timeline-now-needle {
    position: absolute;
    left: 50%;
    top: 1.15rem;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: linear-gradient(180deg, #d4a84b 0%, rgba(212, 168, 75, 0.35) 100%);
    box-shadow: 0 0 10px rgba(212, 168, 75, 0.55);
}

.fight-page__timeline-ribbon {
    display: grid;
    gap: 0.28rem;
    align-items: stretch;
    min-height: 6.6rem;
}

.fight-page__timeline-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 6.6rem;
    padding: 0.35rem 0.2rem 0.3rem;
    border-radius: 0.2rem;
    border: 1px solid rgba(196, 168, 120, 0.22);
    background: linear-gradient(180deg, rgba(18, 22, 16, 0.95), rgba(24, 28, 22, 0.78));
    box-sizing: border-box;
}

.fight-page__timeline-slot--past {
    opacity: 0.55;
}

.fight-page__timeline-slot--future {
    opacity: 0.88;
}

.fight-page__timeline-slot--now {
    opacity: 1;
    border-color: rgba(212, 168, 75, 0.85);
    background:
        linear-gradient(180deg, rgba(60, 48, 22, 0.55), rgba(24, 28, 22, 0.9)),
        linear-gradient(180deg, rgba(18, 22, 16, 0.95), rgba(24, 28, 22, 0.78));
    box-shadow: inset 0 0 0 1px rgba(212, 168, 75, 0.25);
    z-index: 2;
}

.fight-page__timeline-slot-num {
    display: block;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    color: #e8d7a8;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

.fight-page__timeline-slot--now .fight-page__timeline-slot-num {
    color: #f3df9a;
    font-size: 0.86rem;
}

.fight-page__timeline-slot-people {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    flex: 1;
    min-height: 4.4rem;
}

.fight-page__timeline-person {
    display: block;
    padding: 0.12rem 0.2rem;
    border-radius: 0.12rem;
    font-size: 0.62rem;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f0e6d2;
    background: rgba(255, 255, 255, 0.04);
}

.fight-page__timeline-person--party {
    color: #c5e2d2;
    background: rgba(70, 120, 95, 0.28);
    border: 1px solid rgba(120, 170, 140, 0.35);
}

.fight-page__timeline-person--enemy {
    color: #f0c8bc;
    background: rgba(140, 70, 55, 0.28);
    border: 1px solid rgba(180, 110, 95, 0.35);
}

.fight-page__timeline-person--ready {
    box-shadow: 0 0 0 1px rgba(212, 168, 75, 0.65);
}

.fight-page__timeline-person--down {
    opacity: 0.4;
    text-decoration: line-through;
}

@media (max-width: 720px) {
    .page-panel.fight-page,
    .fight-page {
        padding: 1.25rem 1rem 1.75rem;
    }

    .fight-page__arena {
        min-height: min(16rem, 42vh);
    }

    .fight-page__title {
        font-size: 1.85rem;
    }

    .fight-page__timeline {
        min-height: 10.5rem;
        padding: 0.7rem 0.65rem 0.8rem;
    }

    .fight-page__timeline-ribbon {
        gap: 0.18rem;
    }

    .fight-page__timeline-slot-num {
        font-size: 0.7rem;
    }

    .fight-page__timeline-person {
        font-size: 0.55rem;
    }

    .fight-page__log {
        height: 24rem;
        max-height: 24rem;
        font-size: 0.95rem;
    }
}

.fight-page__arena-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    touch-action: none;
}

.fight-page__arena-fallback {
    position: absolute;
    inset: auto 1rem 1rem;
    margin: 0;
    padding: 0.5rem 0.7rem;
    font-size: 0.92rem;
    color: #c9b89a;
    background: rgba(18, 16, 13, 0.72);
    pointer-events: none;
}

.fight-page__log li.fight-log--latest {
    animation: fight-log-reveal 0.28s ease-out;
}

.fight-page__log li.fight-log--roster {
    white-space: normal;
    line-height: 1.35;
    padding: 0.55rem 0.65rem;
    border-left: 3px solid rgba(180, 150, 90, 0.55);
}

.fight-page__log .fight-log__roster-title {
    font-weight: 650;
    margin-bottom: 0.35rem;
    color: #e4d3b0;
}

.fight-page__log .fight-log__roster-entry {
    margin: 0.35rem 0 0.15rem;
}

.fight-page__log .fight-log__roster-detail {
    margin-left: 0.85rem;
    opacity: 0.88;
    font-size: 0.92em;
}

@keyframes fight-log-reveal {
    from {
        opacity: 0;
        transform: translateY(0.25rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fight-page__status,
.fight-page__error {
    margin: 1.15rem 0;
    font-size: 1.05rem;
}

.fight-page__error {
    color: #c47a68;
}

.fight-page__outcome {
    font-family: var(--font-manuscript);
    font-size: 1.7rem;
    margin: 0.35rem 0 0.35rem;
    min-height: 2.1rem;
}

.fight-page__report-status {
    min-height: 4.4rem;
    margin: 0.15rem 0 0.35rem;
}

.fight-page__outcome--pending {
    visibility: hidden;
}

.fight-page__outcome--win {
    color: #8fbf7a;
}

.fight-page__outcome--loss {
    color: #c47a68;
}

.fight-page__outcome--draw {
    color: var(--leaf-gold-bright);
}

.fight-page__log {
    margin: 0.9rem 0 0;
    padding-left: 1.5rem;
    /* Fixed frame so the log area does not grow/jump as events appear. */
    height: 36rem;
    max-height: 36rem;
    overflow: auto;
    font-size: 1.02rem;
    line-height: 1.55;
    color: var(--fg-muted);
    border-left: 1px solid rgba(180, 150, 90, 0.25);
    box-sizing: border-box;
}

.fight-page__log li {
    margin: 0.3rem 0;
}

.fight-page__log li.fight-log--patzer {
    color: #c45c4a;
    font-weight: 650;
    background: rgba(180, 60, 40, 0.12);
    border-left: 3px solid #c45c4a;
    padding: 0.25rem 0.55rem;
    margin-left: -0.65rem;
}

.fight-page__log li.fight-log--opportunity {
    color: #d4892a;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: linear-gradient(
        90deg,
        rgba(212, 137, 42, 0.22),
        rgba(212, 137, 42, 0.06) 70%,
        transparent
    );
    border-left: 3px solid #e0a040;
    padding: 0.3rem 0.6rem;
    margin-left: -0.65rem;
    box-shadow: inset 0 0 0 1px rgba(224, 160, 64, 0.18);
}

.fight-page__log li.fight-log--opportunity.fight-log--latest {
    animation: fight-aoo-flash 0.55s ease-out;
}

@keyframes fight-aoo-flash {
    0% {
        opacity: 0;
        transform: translateX(-0.35rem) scale(1.02);
        background-color: rgba(224, 160, 64, 0.35);
    }
    55% {
        opacity: 1;
        transform: translateX(0) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.fight-page__log li.fight-log--critical {
    color: #d4a017;
    font-weight: 650;
    background: rgba(212, 160, 23, 0.14);
    border-left: 3px solid #d4a017;
    padding: 0.25rem 0.55rem;
    margin-left: -0.65rem;
}

.fight-page__log li.fight-log--abwehr {
    color: #6a9e7a;
    font-weight: 600;
    background: rgba(80, 140, 100, 0.12);
    border-left: 3px solid #6a9e7a;
    padding: 0.25rem 0.55rem;
    margin-left: -0.65rem;
}

.fight-page__log li.fight-log--abwehr-thwart {
    color: #5cb88a;
    font-weight: 700;
    background: rgba(70, 170, 120, 0.18);
    border-left: 3px solid #5cb88a;
    padding: 0.25rem 0.55rem;
    margin-left: -0.65rem;
}

.fight-page__log li.fight-log--furcht {
    color: #9a7ab8;
    font-weight: 650;
    background: rgba(120, 80, 160, 0.14);
    border-left: 3px solid #9a7ab8;
    padding: 0.25rem 0.55rem;
    margin-left: -0.65rem;
}

.fight-page__back {
    margin-top: 2.35rem;
    text-align: center;
    font-size: 1.05rem;
}

.fight-page__back a {
    color: var(--fg-muted);
    text-decoration: none;
}

.fight-page__back a:hover {
    color: var(--leaf-gold-bright);
}
