/* Pathfinder 2e Character Sheet — оформление в стиле Baldur's Gate 3 */

:root {
    /* Палитра baldursgate3.game */
    --bg3-gold: #fbcea0;
    --bg3-gold-hover: #c19976;
    --bg3-bronze: #b78f6d;
    --bg3-cream: #f5efe6;
    --bg3-muted: hsla(0, 0%, 100%, 0.55);
    --bg3-panel: #161310;
    --bg3-panel-deep: #0c0a08;
    --bg3-crimson: #5e0000;
    --bg3-crimson-light: #910000;

    --palette-indigo-deep: var(--bg3-panel);
    --palette-indigo-mid: #2a2218;
    --palette-indigo-shadow: var(--bg3-panel-deep);

    --plum-anchor: var(--bg3-panel);
    --plum-anchor-hsl: 30 18% 10%;

    --accent-hsl: 32 42% 42%;
    --highlight-hsl: 35 92% 80%;

    --accent: var(--bg3-bronze);
    --accent-deep: hsl(var(--plum-anchor-hsl));
    --accent-soft: var(--bg3-gold-hover);
    --trait-accent-hsl: 25 48% 36%;
    --trait-accent: hsl(var(--trait-accent-hsl));

    --gold: var(--bg3-gold);

    --bg-app: #060504;
    --bg-frame: #100e0c;
    --bg-sidebar: #14110e;
    --bg-sidebar-dark: #0a0907;
    --bg-main: #11100d;
    --bg-main-2: #1a1612;

    --text-readable: var(--bg3-cream);
    --text-readable-muted: var(--bg3-muted);
    --text-accent: var(--bg3-gold);
    /* Крупные числа статов (как «102» в Макс ОЗ) */
    --stat-value-color: var(--text-readable);
    --stat-value-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
    --ink: var(--text-readable);
    --ink-soft: var(--text-readable-muted);

    --line: rgba(183, 143, 109, 0.22);
    --shadow: rgba(0, 0, 0, 0.88);
    --shadow2: rgba(8, 6, 4, 0.65);

    --header-shade-top: #221c16;
    --header-shade-bottom: #0e0c0a;
    --text-brand: var(--bg3-gold);
    --pill-bg: rgba(94, 0, 0, 0.45);
    --pill-text: var(--bg3-gold);
    --pill-border: rgba(251, 206, 160, 0.28);
    --quest-title: var(--bg3-gold);

    /* Pathfinder (оригинальные токены — теги, ссылки, элементы как в Foundry) */
    --color-pf-primary: #5e0000;
    --color-pf-primary-dark: rgb(68.5, 0, 0);
    --color-pf-primary-darker: #2b0000;
    --color-pf-primary-light: rgb(119.5, 0, 0);
    --color-pf-primary-lighter: #910000;
    --color-pf-alternate: #786452;
    --color-pf-alternate-dark: #443730;
    --color-pf-alternate-darker: rgb(38.1034482759, 30.8189655172, 26.8965517241);
    --color-pf-alternate-light: rgb(150.297029703, 125.2475247525, 102.702970297);
    --color-pf-secondary: #171f69;
    --color-pf-secondary-dark: rgb(13.8359375, 18.6484375, 63.1640625);
    --color-pf-secondary-light: rgb(32.1640625, 43.3515625, 146.8359375);
    --color-pf-tertiary: #b7a6ff;
    --color-pf-tertiary-dark: #a08eff;
    --color-pf-tertiary-darker: #8a76ff;
    --color-pf-tertiary-light: #cebeff;

    /* Backgrounds */
    --bg: var(--bg-main);
    --bg-dark: var(--bg-sidebar-dark);

    /* Text */
    --text-dark: var(--ink);
    --text-light: var(--text-readable);
    --color-text-dark-input: var(--ink);
    --color-text-secondary: var(--text-readable-muted);

    /* Borders */
    --color-border: var(--line);
    --color-border-dark-input: rgba(251, 206, 160, 0.18);
    --primary-background: var(--accent);

    /* Sidebar */
    --sidebar-label: var(--gold);
    --sidebar-title: var(--gold);
    --gold-muted: var(--gold);
    /* Акцентный текст — тот же цвет, что «Восприятие» и др. заголовки сайдбара */
    --accent-text: var(--sidebar-title);

    /* Traits: заливка — Foundry; обводка — в тон индиго-якорю */
    --color-bg-size: #3a7b59;
    --color-bg-trait: var(--trait-accent);
    --color-border-trait: rgba(183, 143, 109, 0.45);
    --color-text-trait: var(--ink);

    /* Мастерство: кружки pf-rank — исходная шкала Foundry */
    --color-proficiency-untrained: #424242;
    --color-proficiency-trained: #171f69;
    --color-proficiency-expert: #7e46c8;
    --color-proficiency-master: #dca040;
    --color-proficiency-legendary: #5e0000;
    
    /* Типографика baldursgate3.game: Quadraat + Gilam + Gothic A1 */
    --font-display: "QuadraatOffcPro Demibold", Georgia, serif;
    --font-primary: "QuadraatOffcPro Regular", Georgia, serif;
    --font-body: "Gothic A1", "Segoe UI", system-ui, sans-serif;
    --font-ui: "Gilam Book", "Segoe UI", system-ui, sans-serif;
    --font-ui-strong: "Gilam SemiBold", var(--font-ui);
    --font-sans: var(--font-ui);
    --font-serif: var(--font-primary);
    --sheet-font: var(--font-primary);
    --sans-serif: var(--font-ui);
    --serif: var(--font-primary);
    --serif-condensed: var(--font-display);
    --ui-font: var(--font-ui);
    --font-size-9: 0.5625rem;
    --font-size-10: 0.625rem;
    --font-size-11: 0.6875rem;
    --font-size-12: 0.75rem;
    --font-size-13: 0.8125rem;
    --font-size-14: 0.875rem;
    --font-size-16: 1rem;
    --font-size-18: 1.125rem;
    --font-size-19: 1.1875rem;
    --font-size-20: 1.25rem;
    --font-size-24: 1.5rem;
    --font-size-26: 1.625rem;
    --font-size-28: 1.75rem;
    --font-size-32: 2rem;
    --font-size-36: 2.25rem;

    /* Бейджи тегов — как «Эксперт» / «Мастер» у спасбросков */
    --sheet-tag-font-size: var(--font-size-11);
    --sheet-tag-padding: 2px 6px;
    --sheet-tag-radius: 3px;
    --sheet-tag-font-weight: 700;
    --sheet-tag-letter-spacing: 0.04em;
    --sheet-tag-line-height: 1.2;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-14: 3.5rem;
    --space-17: 4.25rem;
    --space-19: 4.75rem;
    --space-28: 7rem;
    --space-32: 8rem;
    
    /* Additional Foundry variables */
    --color-text-light-0: var(--gold);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: var(--bg-app);
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: transparent;
    position: relative;
    font-family: var(--font-primary);
    color: var(--ink);
    font-size: var(--font-size-13);
    line-height: 1.5;
    padding: var(--space-8) var(--space-4);
}

.foundry-app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    border-radius: 0;
    box-shadow: 0 24px 80px var(--shadow);
    border: none;
    background: linear-gradient(180deg, rgba(251, 206, 160, 0.04), transparent 120px), var(--bg-frame);
    overflow: hidden;
    min-height: calc(100vh - 8rem);
    color: var(--ink);
    font-family: var(--font-primary);
    font-size: var(--font-size-13);
    font-weight: 400;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Рамка BG3 задаёт фон и отступы в bg3-frames.css */
.foundry-app.bg3-frame-host {
    background: transparent;
    box-shadow: 0 24px 80px var(--shadow);
}

/* Header */
.foundry-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    row-gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--header-shade-top), var(--header-shade-bottom));
    border-bottom: 1px solid rgba(183, 143, 109, 0.35);
    box-shadow: inset 0 -1px 0 rgba(251, 206, 160, 0.08);
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    flex: 1;
    min-width: 0;
}

/* Шапка: Pathfinder + версия + название квеста (см. script.js — объект SHEET_BRANDING) */
.sheet-header-branding {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px 14px;
    width: 100%;
    min-width: 0;
}

.sheet-brand-game {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-brand);
    text-shadow: 0 0 24px rgba(251, 206, 160, 0.35);
    line-height: 1.1;
}

.sheet-version-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 11px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--sans-serif);
    color: var(--pill-text);
    background: var(--pill-bg);
    border-radius: 999px;
    border: 1px solid var(--pill-border);
    line-height: 1.2;
    flex-shrink: 0;
}

.sheet-quest-title {
    font-family: var(--font-display);
    font-size: calc(1.75rem - 2px);
    font-weight: 400;
    letter-spacing: calc(0.12em - 2px);
    text-transform: none;
    color: var(--text-brand);
    text-shadow: 0 0 24px rgba(251, 206, 160, 0.35);
    line-height: 1.1;
    flex: 1 1 200px;
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    box-shadow: none;
    cursor: text;
}

.foundry-header .sheet-quest-title:hover {
    border-bottom-color: rgba(183, 143, 109, 0.35);
}

.foundry-header .sheet-quest-title:focus {
    outline: none;
    border-bottom-color: rgba(251, 206, 160, 0.55);
    box-shadow: none;
}

.foundry-header .sheet-quest-title::placeholder {
    color: rgba(251, 206, 160, 0.35);
}

.character-name-header {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink);
}

.hero-points {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.hero-points-label {
    font-size: var(--font-size-11);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    font-weight: 500;
}

.hero-points-circles {
    display: flex;
    gap: var(--space-1);
}

.hero-circle {
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: transparent;
}

.hero-circle.filled {
    background: var(--bg3-gold);
    border-color: var(--bg3-bronze);
}

.header-right {
    display: flex;
    gap: var(--space-2);
}

.header-btn {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--text-dark);
    cursor: pointer;
    font-size: var(--font-size-12);
    border-radius: 3px;
    font-family: var(--sans-serif);
}

.header-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.header-level {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    opacity: .95;
    margin-left: auto;
}

.level-display {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-shield {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.18), transparent 55%), rgba(0,0,0,.25);
    border: 1px solid rgba(183, 143, 109, 0.5);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5), 0 0 8px rgba(251, 206, 160, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-primary);
    color: var(--gold);
    gap: 2px;
}

.level-label {
    font-family: inherit;
    font-weight: 700;
    font-size: 10px;
    line-height: 1;
    letter-spacing: .06em;
    opacity: .95;
}

.level-number {
    font-weight: 800;
    font-size: 25px;
    line-height: 1;
    color: var(--gold);
}

/* Body Layout */
.foundry-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, var(--bg-sidebar), var(--bg-sidebar-dark));
    border-right: 1px solid rgba(183, 143, 109, 0.28);
    box-shadow: inset -1px 0 0 rgba(251, 206, 160, 0.05);
    padding: 12px;
    overflow-y: auto;
    overflow-x: visible;
    scrollbar-gutter: stable;
    width: 16rem;
    min-width: 256px;
    max-width: 16rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sidebar * {
    box-sizing: border-box;
    max-width: 100%;
}

.sidebar > * {
    min-width: 0;
}

/* Ensure all input and select elements respect boundaries */
.sidebar input,
.sidebar select,
.sidebar button {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure numeric values and modifiers don't overflow (except in HP section) */
.sidebar .data-value,
.sidebar .data-value h2,
.sidebar .data-value input,
.sidebar .modifier,
.sidebar .modifier span,
.sidebar .pf-rank {
    box-sizing: border-box;
}

/* Apply overflow rules only where needed, not in HP section */
.sidebar .modifier:not(.sidebar .hitpoints .modifier),
.sidebar .modifier:not(.sidebar .hitpoints .modifier) span,
.sidebar .pf-rank {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar h2,
.sidebar h3,
.sidebar h4 {
    margin: 0;
    line-height: 1;
}

.sidebar header {
    align-items: end;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    margin: 0.8em 0 0.5em;
    min-width: 0;
    max-width: 100%;
}

.sidebar header:first-of-type {
    margin-bottom: 0.5em;
    margin-top: 0.5em;
}

.sidebar header h2 {
    color: var(--sidebar-title);
    flex: 1;
    min-width: 0;
    max-width: 100%;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 400;
    font-variant: normal;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.25;
    text-align: left;
    display: block;
    visibility: visible;
    overflow-wrap: break-word;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar header button {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px 2px 0 0;
    border: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    color: var(--sidebar-title);
    opacity: 0.85;
    flex: 0;
    font: 600 var(--font-size-9) var(--sans-serif);
    letter-spacing: 0.05em;
    line-height: 1;
    margin: 0;
    padding: var(--space-2) var(--space-3);
    text-rendering: optimizeLegibility;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
}

.sidebar header button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    color: var(--sidebar-title);
    opacity: 1;
}

.sidebar header button,
.sidebar header h2 {
    border-bottom: 1px solid var(--sidebar-title);
}

.sidebar_label {
    font-family: var(--font-ui);
    font-size: var(--font-size-12);
    font-weight: 400;
    line-height: 1.35;
    text-transform: none;
    letter-spacing: 0.01em;
    text-rendering: optimizeLegibility;
    color: var(--text-readable-muted);
    white-space: normal;
    display: block;
    visibility: visible;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    overflow: visible;
    text-overflow: unset;
}

/* HP Section */
.sidebar .hitpoints {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    min-width: 0;
    max-width: 100%;
}

.sidebar .hitpoints:not(.bg3-frame-host) {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 12px;
}

.sidebar .hitpoints .hp-big {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 0;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
}

.sidebar .hitpoints .hp-big .container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    padding: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.sidebar .hitpoints .hp-big input {
    font-size: var(--font-size-28);
    max-width: 100%;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    box-sizing: border-box;
}

.sidebar .hitpoints .hp-big .container {
    text-align: center;
}

.sidebar .hitpoints .hp-big .container.current-hp {
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
    min-height: auto;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.sidebar .hitpoints .hp-big .container.current-hp .sidebar_label {
    display: none;
}

.sidebar .hitpoints .hp-big .container.current-hp .data-value {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar .hitpoints .hp-big .container.current-hp .data-value input[type=text] {
    font-size: calc(var(--font-size-32) - 7px);
    letter-spacing: 1px;
    height: auto;
    border: none;
    background: transparent;
    color: var(--ink);
    text-align: center;
    width: 100%;
    font-family: var(--font-primary);
    font-weight: 400;
    padding: 0;
}

.sidebar .hitpoints .hp-big .container.current-hp .data-value input[type=text]::placeholder {
    color: var(--ink-soft);
}

.sidebar .hitpoints .hp-big .container.temp-hp,
.sidebar .hitpoints .hp-big .container.max-hp {
    display: none;
}

.sidebar .hitpoints .hp-big .container.temp-hp .sidebar_label,
.sidebar .hitpoints .hp-big .container.max-hp .sidebar_label {
    display: none;
}

.sidebar .hitpoints .hp-big .container.temp-hp input {
    margin-top: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    text-align: left;
    width: 100%;
    font-family: var(--font-primary);
    font-size: var(--font-size-24);
    font-weight: 400;
    padding: 0;
}

.sidebar .hitpoints .hp-big .container.max-hp .data-value h2 {
    color: var(--ink);
    font-size: var(--font-size-24);
    font-family: var(--font-primary);
    font-weight: 400;
    text-shadow: 0 2px 0 rgba(0,0,0,.35);
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    max-width: none;
    width: auto;
    margin: 0;
    letter-spacing: 1px;
}

.sidebar .hitpoints .hp-small {
    display: none;
}

.sidebar .hitpoints .hp-small h4,
.sidebar .hitpoints .hp-small label,
.sidebar .hitpoints .hp-small .sidebar_label {
    font-family: var(--sans-serif);
    font-size: var(--font-size-10);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-rendering: optimizeLegibility;
    color: var(--sidebar-label);
}

.sidebar a.condition-pips {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.sidebar a.condition-pips .pips {
    display: flex;
    gap: var(--space-1);
    justify-content: center;
}

.sidebar a.condition-pips .pips i {
    color: var(--text-light);
    font-size: var(--font-size-19);
}

.sidebar .data-value {
    align-items: center;
    display: flex;
    font-size: 0;
    justify-content: center;
    overflow: visible;
    min-width: 0;
}

.sidebar .data-value h2 {
    border: none;
    color: var(--stat-value-color);
    font: 400 var(--font-size-28)/1.1 var(--font-primary);
    font-variant-numeric: tabular-nums;
    text-align: center;
    margin: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}

/* Specific override for HP section data-values */
.sidebar .hitpoints .data-value h2 {
    max-width: none;
    width: auto;
}

.sidebar .data-value input {
    border: none;
    background: transparent;
    color: var(--stat-value-color);
    font-family: var(--font-primary);
    font-weight: 400;
    font-size: var(--font-size-28);
    font-variant-numeric: tabular-nums;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    text-align: center;
    padding: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.sidebar .data-value input[type="text"] {
    max-width: 4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* AC Section */
.sidebar .armor-class {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    min-width: 0;
    max-width: 100%;
    color: var(--sidebar-title);
}

.sidebar .armor-class-body {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.sidebar .armor-class-shield-group[hidden] {
    display: none !important;
}

.sidebar .armor-class-shield-group:not([hidden]) {
    display: contents;
}

/* Три колонки: фиксированные строки «подпись» + «цифра» */
.sidebar .armor-class-col {
    flex: 1 1 0;
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(3.35em, auto) 2.5em;
    row-gap: 4px;
    align-content: start;
    padding: 8px 6px 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    box-sizing: border-box;
    overflow: visible;
}

.sidebar .armor-class-body:has(.armor-class-shield-group:not([hidden])) > .armor-class-col,
.sidebar .armor-class-body:has(.armor-class-shield-group:not([hidden])) .armor-class-col {
    flex: 1 1 0;
}

.sidebar .armor-class-body:has(.armor-class-shield-group:not([hidden])) .shield-stats {
    flex: 1 1 100%;
    width: 100%;
}

.sidebar .armor-class-stat-label {
    grid-row: 1;
    align-self: start;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 3.35em;
    height: auto;
    width: 100%;
    margin: 0;
    padding: 0 2px;
    font-family: var(--font-primary);
    font-size: var(--font-size-12);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0.01em;
    text-align: center;
    line-height: 1.3;
    color: var(--text-readable-muted);
    overflow: visible;
    text-overflow: unset;
    box-sizing: border-box;
}

.sidebar .armor-class-stat-value {
    grid-row: 2;
    align-self: center;
    justify-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.5em;
    width: 100%;
    margin: 0;
    padding: 0;
    font-size: calc(var(--font-size-24) - 2px);
    line-height: 1;
    box-sizing: border-box;
}

.sidebar .armor-class .armor-class-stat-value.data-value h2,
.sidebar .armor-class .armor-class-stat-value.data-value input,
.sidebar .armor-class .armor-class-stat-value .shield-max-value {
    display: block;
    margin: 0;
    padding: 0;
    font: 400 calc(var(--font-size-24) - 2px) / 1.1 var(--font-primary);
    font-variant-numeric: tabular-nums;
    color: var(--stat-value-color);
    text-shadow: var(--stat-value-shadow);
    text-align: center;
    line-height: 1;
    border: none;
    background: transparent;
}

/* Только КБ, без щита */
.sidebar .armor-class-body:not(:has(.armor-class-shield-group:not([hidden]))) > .armor-class-col {
    flex: 1 1 100%;
    max-width: 100%;
}

.sidebar .armor-class .shield.hp {
    margin-top: 0;
    border-top: none;
}

.sidebar .armor-class .shield.hp label {
    white-space: normal;
}

.sidebar .armor-class .shield-stats {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex: 1 1 100%;
    width: 100%;
    margin-top: 0;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,.10);
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    flex-wrap: nowrap;
    box-sizing: border-box;
}

.sidebar .armor-class .shield-stat-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    padding: 5px 6px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
    box-sizing: border-box;
}

.sidebar .armor-class .shield-stat-label {
    font-family: var(--font-primary);
    font-size: var(--font-size-12);
    font-weight: 400;
    letter-spacing: 0.01em;
    text-transform: none;
    line-height: 1.3;
    color: var(--text-readable-muted);
    flex-shrink: 0;
}

.sidebar .armor-class .shield-value-box {
    min-width: 24px;
    max-width: 100%;
    width: auto;
    height: 22px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid hsl(var(--highlight-hsl) / 0.3);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 400;
    color: var(--sidebar-title);
    padding: 0 6px;
    flex: 1 1 auto;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .armor-class .armor-class-stat-value.data-value h2,
.sidebar .armor-class .armor-class-stat-value.data-value input,
.sidebar .armor-class .armor-class-stat-value .shield-max-value {
    width: 100%;
    max-width: 3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.sidebar .armor-class .shield .sidebar_label {
    color: var(--sidebar-title);
}

.sidebar .armor-class .armor-class-stat-value.data-value input:disabled {
    color: var(--sidebar-title);
    opacity: 0.85;
}

.sidebar .armor-class .ac label,
.sidebar .armor-class .shield label {
    white-space: normal;
}

.sidebar .armor-class .shield.hp.disabled,
.sidebar .armor-class .shield-max.disabled {
    opacity: 0.75;
}

/* Perception and Initiative */
.sidebar .roll-data {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    justify-content: left;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
}

.sidebar .roll-data .modifier,
.sidebar .roll-data h3 {
    color: var(--stat-value-color);
    font-size: calc(var(--font-size-18) + 2px);
    font-weight: 400;
    line-height: 1.1;
    white-space: nowrap;
    font-family: var(--font-primary);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0,0,0,.35);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

.sidebar .roll-data .modifier,
.sidebar .roll-data .modifier span {
    cursor: default;
    pointer-events: none;
    text-decoration: none;
    color: var(--stat-value-color);
    text-shadow: var(--stat-value-shadow);
}

.sidebar .perception .modifier,
.sidebar .initiative .modifier {
    margin-right: 1rem;
}

.sidebar .perception select,
.sidebar .initiative select {
    flex: 0 0 8.25rem;
    max-width: 8.25rem;
    min-width: 0;
    margin-left: auto;
    padding: var(--space-1) var(--space-2);
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    color: var(--ink);
    font-size: var(--font-size-11);
    border-radius: 10px;
    font-family: var(--sans-serif);
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.sidebar .initiative .tags {
    margin-top: var(--space-4);
    border-top: none;
    padding-top: 0;
}

/* Зрение — между блоком «Восприятие» и «Спасброски», вне рамки */
.sidebar ol.tags.perception-senses {
    margin: 8px 0 12px;
    padding: 0;
}

.sidebar ol.tags.perception-senses:empty {
    display: none;
    margin: 0;
}

.sidebar .perception.bg3-frame-host .roll-data {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Восприятие: число по центру между левой границей и бейджем; центры цифры и бейджа на одной линии */
.sidebar .perception .roll-data {
    justify-content: flex-start;
    align-items: center;
}

.sidebar .perception .roll-data .modifier {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 0;
    text-align: center;
    line-height: 1;
}

.sidebar .perception .roll-data .modifier span {
    line-height: 1;
}

.sidebar .perception .roll-data .pf-rank {
    flex: 0 0 auto;
    margin-left: 0;
    align-self: center;
}

.sidebar .perception .pf-rank,
.sidebar .initiative .pf-rank {
    padding: var(--sheet-tag-padding);
    border-radius: var(--sheet-tag-radius);
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    text-transform: uppercase;
    font-family: var(--sans-serif);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar .initiative .pf-rank {
    margin-left: auto;
}

.sidebar ul.saves li .save-roll .pf-rank {
    padding: var(--sheet-tag-padding);
    border-radius: var(--sheet-tag-radius);
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    text-transform: uppercase;
    font-family: var(--sans-serif);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar .pf-rank[data-rank="0"],
.sidebar .pf-rank.untrained {
    background: var(--color-proficiency-untrained);
    color: var(--ink);
}

.sidebar .pf-rank[data-rank="1"],
.sidebar .pf-rank.trained {
    background: var(--color-proficiency-trained);
    color: var(--ink);
}

.sidebar .pf-rank[data-rank="2"],
.sidebar .pf-rank.expert {
    background: var(--color-proficiency-expert);
    color: var(--ink);
}

.sidebar .pf-rank[data-rank="3"],
.sidebar .pf-rank.master {
    background: var(--color-proficiency-master);
    color: var(--ink);
}

.sidebar .pf-rank[data-rank="4"],
.sidebar .pf-rank.legendary {
    background: var(--color-proficiency-legendary);
    color: var(--ink);
}

/* Initiative Section */
.sidebar .initiative {
    margin-bottom: 12px;
}

.sidebar .initiative .roll-data {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 4px;
    padding: 10px 12px;
}

/* Speed Section in Sidebar */
.sidebar .speed-section {
    margin-bottom: 12px;
}

.sidebar .speed-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 4px;
    padding: 10px 12px;
}

.sidebar .speed-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.sidebar .speed-item .speed-label {
    font-size: var(--font-size-11);
    color: var(--sidebar-label);
    text-transform: uppercase;
    flex-shrink: 0;
}

.sidebar .speed-item .speed-value {
    font-family: var(--font-primary);
    font-size: var(--font-size-13);
    color: var(--ink);
    font-weight: 400;
    text-align: right;
    flex-shrink: 0;
}

/* Attributes Section in Sidebar */
.sidebar .attributes-section {
    margin-bottom: 12px;
}

.sidebar .attributes-container-sidebar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 4px;
    padding: 10px 12px;
}

.sidebar .attribute-item-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 0;
}

.sidebar .attribute-item-sidebar .attribute-abbr {
    font-family: var(--font-display);
    font-size: var(--font-size-11);
    color: #c45a4a;
    margin-bottom: 3px;
    line-height: 1.1;
}

.sidebar .attribute-item-sidebar .attribute-mod-frame {
    min-width: 2.5rem;
    max-width: 100%;
    min-height: 2rem;
    padding: 6px 8px 5px;
    margin-bottom: 0;
}

.sidebar .attribute-item-sidebar .attribute-mod-frame::before,
.sidebar .attribute-item-sidebar .attribute-mod-frame::after {
    width: 7px;
    height: 7px;
}

.sidebar .attribute-item-sidebar .attribute-mod {
    font-family: var(--font-primary);
    font-size: var(--font-size-16);
    font-weight: 700;
    color: var(--stat-value-color);
    text-shadow: var(--stat-value-shadow);
    line-height: 1;
}

.sidebar .attribute-item-sidebar .attribute-name {
    display: none;
}

.sidebar .attributes-section .details-btn {
    background: transparent;
    border: 1px solid hsl(var(--highlight-hsl) / 0.3);
    color: var(--gold);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: var(--font-size-10);
    cursor: pointer;
    font-family: var(--sans-serif);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar .attributes-section .details-btn:hover {
    background: hsl(var(--highlight-hsl) / 0.1);
    border-color: hsl(var(--highlight-hsl) / 0.5);
}

/* Tags */
.sidebar ol.tags {
    display: flex;
    flex-direction: row;
    list-style: none;
    margin: var(--space-6) 0 0 0;
    padding: 0;
    flex-wrap: wrap;
    gap: var(--space-1);
}

/* Иммунитеты / слабости / сопротивления — ближе к линии заголовка */
.sidebar header + ol.tags {
    margin-top: var(--space-2);
    margin-bottom: var(--space-4);
}

.sidebar ol.tags li {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    padding: var(--sheet-tag-padding);
    border-radius: 10px;
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    font-family: var(--sans-serif);
    color: var(--ink);
    background: rgba(0, 0, 0, 0.25);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar ol.tags li.tag_secondary {
    background: var(--color-pf-secondary);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255,255,255,.10);
}

/* Saves */
.sidebar ul.saves {
    display: flex;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Колонки спасбросков — не наследовать горизонтальный .roll-data */
.sidebar ul.saves > li.roll-data {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2);
    width: 100%;
}

.sidebar ul.saves li {
    border-left: none;
    flex-direction: column;
    gap: 0;
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.sidebar ul.saves li:first-child {
    border-left: none;
}

.sidebar ul.saves li .sidebar_label {
    border: none;
    font-size: var(--font-size-12);
    font-weight: initial;
    margin-bottom: var(--space-2);
    text-transform: capitalize;
    color: var(--sidebar-label);
    width: 100%;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.sidebar ul.saves li .save-roll .modifier {
    color: var(--stat-value-color);
    text-shadow: var(--stat-value-shadow);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    display: inline-block;
}

.sidebar ul.saves li .save-roll .modifier span {
    color: var(--stat-value-color);
    font-size: calc(var(--font-size-18) + 3px);
    font-family: var(--font-primary);
    font-weight: 400;
    text-shadow: var(--stat-value-shadow);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    display: inline-block;
}

.sidebar ul.saves li .save-roll {
    display: flex;
    gap: var(--space-4);
    margin-top: var(--space-4);
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    flex-wrap: wrap;
}

.sidebar ul.saves li .save-roll .modifier {
    text-align: center;
}

.sidebar ul.saves li .save-roll .pf-rank {
    flex-shrink: 0;
}


/* Main Content */
.foundry-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(ellipse at 40% 0%, rgba(251, 206, 160, 0.06), transparent 55%),
                linear-gradient(180deg, var(--bg-main), var(--bg-main-2));
    color: var(--sidebar-title);
    font-family: var(--sans-serif);
    padding: 12px 14px 16px;
    overflow: hidden;
}

/* Tabs */
.foundry-tabs-container {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, rgba(34, 28, 22, 0.98), rgba(14, 12, 10, 0.95));
    backdrop-filter: blur(6px);
    z-index: 20;
}

.foundry-tabs-wrapper {
    flex: 1;
    overflow: visible;
    position: relative;
    min-width: 0;
}

.foundry-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 10px 8px;
    overflow-x: visible;
    overflow-y: visible;
    scroll-behavior: auto;
}

/* Прокрутка вкладок отключена — вкладки переносятся; стрелки скрыты */
.tab-scroll-btn {
    display: none !important;
}

.foundry-tab {
    border: 0;
    background: transparent;
    padding: 11px 15px;
    border-radius: 10px;
    font-family: var(--font-ui);
    font-weight: 400;
    color: var(--text-readable);
    opacity: 0.85;
    cursor: pointer;
    font-variant: normal;
    letter-spacing: 0.01em;
    font-size: var(--font-size-14);
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.foundry-tab:hover {
    background: rgba(183, 143, 109, 0.12);
    color: var(--text-readable);
    opacity: 1;
}

.foundry-tab.active {
    background: rgba(94, 0, 0, 0.22);
    color: var(--text-accent);
    opacity: 1;
    box-shadow: inset 0 -3px 0 var(--bg3-gold);
}

.tab-icon {
    font-size: var(--font-size-12);
}

/* Panels */
.foundry-panels {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px 8px;
    background: transparent;
}

.foundry-panel {
    display: none;
}

.foundry-panel.active {
    display: block;
}

/* Character Tab */
.character-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.character-header-panel {
    margin-bottom: 10px;
    margin-top: 0;
    padding: 0;
}

.character-name-large {
    font-family: var(--font-primary);
    font-size: 1.75rem;
    font-weight: 400;
    line-height: 1.2;
    color: var(--text-accent);
    margin-bottom: 8px;
    margin-top: 0;
    padding: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,.4);
    letter-spacing: 0.01em;
}

.character-tags-panel {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    margin-top: 0;
    padding: 0;
}

.tag {
    padding: var(--sheet-tag-padding);
    border-radius: 999px;
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    text-transform: uppercase;
    font-family: var(--sans-serif);
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(0,0,0,.25);
    color: var(--ink);
    display: inline-block;
}

.tag-medium {
    background: var(--color-bg-size);
    color: var(--ink);
    border-color: var(--color-bg-size);
}

.tag-humanoid,
.tag-elf {
    background: var(--accent);
    color: var(--ink);
    border-color: hsl(var(--highlight-hsl) / 0.3);
}

.character-profile {
    display: flex;
    gap: 18px;
    margin-bottom: 10px;
    margin-top: 0;
    padding-bottom: 10px;
    padding-top: 0;
    border-bottom: 1px solid var(--line);
    align-items: flex-start;
}

.character-portrait-container {
    flex-shrink: 0;
    position: relative;
}

.avatar-upload-label {
    display: block;
    width: 240px;
    height: 240px;
    cursor: pointer;
    position: relative;
    border-radius: 4px;
    border: 2px solid rgba(183, 143, 109, 0.45);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 26px var(--shadow2), inset 0 0 24px rgba(0, 0, 0, 0.45);
}

.character-portrait-container.positioning-mode .avatar-upload-label {
    cursor: default;
    pointer-events: none;
}

.avatar-upload-label:hover {
    border-color: var(--bg3-gold);
    box-shadow: 0 10px 26px var(--shadow2), 0 0 14px rgba(251, 206, 160, 0.25);
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-sidebar-dark);
    color: var(--ink-soft);
    text-align: center;
    padding: var(--space-4);
}

.avatar-placeholder-text {
    font-size: var(--font-size-12);
    color: var(--ink-soft);
    user-select: none;
}

.character-portrait-img {
    width: 240px;
    height: 240px;
    object-fit: cover;
    border-radius: 4px;
    border: none;
    box-shadow: 0 10px 26px var(--shadow2);
    display: none;
    transition: none;
}

.character-portrait-container.positioning-mode {
    overflow: hidden;
    position: relative;
}

.character-portrait-container.positioning-mode .character-portrait-img {
    z-index: 10;
}

.avatar-change-button {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 20;
    background: rgba(94, 0, 0, 0.9);
    color: var(--ink);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-family: var(--font-primary);
    font-size: var(--font-size-12);
    font-weight: 600;
    transition: all 0.2s;
}

.avatar-change-button:hover {
    background: rgba(94, 0, 0, 1);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Avatar editor modal */
.avatar-editor-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.65);
    padding: 16px;
}

.avatar-editor-modal[hidden] {
    display: none !important;
}

body.avatar-editor-open {
    overflow: hidden;
}

.avatar-editor-dialog {
    width: min(560px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 2px solid #c19976;
    border-radius: 4px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    color: var(--text-dark);
    font-family: var(--sans-serif);
}

.avatar-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--bg-dark);
}

.avatar-editor-header h2 {
    margin: 0;
    font-size: var(--font-size-16);
    font-weight: 600;
    color: var(--text-dark);
}

.avatar-editor-close {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.avatar-editor-close:hover {
    color: var(--text-dark);
}

.avatar-editor-body {
    padding: 16px;
    overflow-y: auto;
}

.avatar-editor-main-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.avatar-editor-viewport {
    position: relative;
    flex: 0 0 200px;
    width: 200px;
    height: 200px;
    overflow: hidden;
    border: 1px solid rgba(183, 143, 109, 0.5);
    border-radius: 4px;
    background: #1a1a1a;
    touch-action: none;
    cursor: grab;
}

.avatar-editor-viewport.is-dragging {
    cursor: grabbing;
}

.avatar-editor-viewport-empty {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    text-align: center;
    font-size: var(--font-size-12);
    color: var(--color-text-secondary);
    pointer-events: none;
}

.avatar-editor-viewport.has-image .avatar-editor-viewport-empty {
    display: none;
}

.avatar-editor-preview-img {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    max-width: none;
    max-height: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.avatar-editor-viewport.has-image {
    cursor: grab;
}

.avatar-editor-viewport.has-image.is-dragging {
    cursor: grabbing;
}

.avatar-editor-side {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.avatar-editor-hint,
.avatar-editor-size-hint {
    margin: 0;
    font-size: var(--font-size-12);
    color: var(--color-text-secondary);
    line-height: 1.45;
}

.avatar-editor-upload-label {
    display: block;
    font-size: var(--font-size-13);
    font-weight: 600;
    margin: 0;
}

.avatar-editor-file {
    width: 100%;
    font-size: var(--font-size-12);
    color: var(--text-dark);
}

.avatar-editor-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--color-border);
}

.avatar-editor-btn {
    min-width: 88px;
    padding: 8px 20px;
    border-radius: 4px;
    font-family: var(--font-primary);
    font-size: var(--font-size-13);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.avatar-editor-btn-ok {
    background: rgba(60, 60, 60, 0.95);
    color: var(--ink);
}

.avatar-editor-btn-ok:hover {
    background: rgba(80, 80, 80, 1);
}

.avatar-editor-btn-delete {
    background: rgba(94, 0, 0, 0.85);
    color: var(--ink);
}

.avatar-editor-btn-delete:hover {
    background: rgba(94, 0, 0, 1);
}

.character-info-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 10px;
    margin-top: 0;
    padding: 0;
}

.info-row:first-child {
    margin-top: 0;
}

.info-row:last-of-type {
    margin-bottom: 0;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.info-item label,
.info-item .info-label {
    font-size: calc(var(--font-size-12) + 3px);
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    margin-bottom: 4px;
    margin-top: 0;
    padding: 0;
    white-space: nowrap;
    overflow: visible;
    line-height: 1.3;
}

.info-value {
    font-size: calc(var(--font-size-14) + 4px);
    color: var(--ink);
    font-weight: 500;
    line-height: 1.35;
    min-height: 1.3em;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.info-value-text {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.info-menu-btn {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    font-size: var(--font-size-18);
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
    opacity: 0.6;
}

.info-menu-btn:hover {
    color: var(--gold);
    opacity: 1;
}

.personal-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 10px;
    margin-bottom: 0;
    padding-top: 10px;
    padding-bottom: 0;
    border-top: 1px solid var(--line);
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-item label {
    font-size: calc(var(--font-size-12) + 5px);
    color: var(--ink-soft);
    text-transform: lowercase;
    font-weight: 500;
    margin-bottom: 2px;
    margin-top: 0;
    line-height: 1.3;
}

.detail-input {
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    color: var(--ink);
    font-size: calc(var(--font-size-13) + 4px);
    line-height: 1.35;
    border-radius: 10px;
    font-family: var(--sans-serif);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    width: 100%;
    box-sizing: border-box;
}

.detail-input:hover:not(:disabled),
.detail-input:focus {
    border: 1px solid var(--accent);
    box-shadow: 0 0 10px hsl(var(--accent-hsl) / 0.35);
    outline: none;
}

.character-section {
    margin-top: 14px;
    margin-bottom: 14px;
    padding-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.character-section:first-child {
    margin-top: 0;
}

.character-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 0;
    padding: 0;
}

.section-title {
    font-family: var(--font-primary);
    font-size: var(--font-size-18);
    font-weight: 400;
    line-height: 1.3;
    color: var(--text-accent);
    letter-spacing: 0.02em;
    margin: 0;
}

.section-edit-btn {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: var(--font-size-11);
    cursor: pointer;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 500;
    font-family: var(--sans-serif);
}

.section-edit-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.languages-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Теги языков — только отображение, не кликабельны (детали — кнопка «Детально») */
.language-tag {
    display: inline-block;
    padding: 5px 6px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    color: var(--ink);
    font-size: var(--sheet-tag-font-size);
    cursor: default;
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
    font-family: var(--sans-serif);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    text-transform: uppercase;
    user-select: text;
    pointer-events: none;
}

.speeds-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-4);
}

.speed-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.speed-item label {
    font-size: calc(var(--font-size-12) + 3px);
    color: var(--ink-soft);
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1.3;
}

.speed-value {
    font-size: calc(var(--font-size-14) + 2px);
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 500;
}

.speed-value-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
}

.speed-value-wrap .skill-tooltip {
    white-space: normal;
    max-width: min(90vw, 420px);
    line-height: 1.45;
    text-align: left;
}

.sidebar .speed-item .speed-value-wrap {
    flex-shrink: 0;
}

.attributes-table-container {
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.attributes-table-container.bg3-frame-host {
    overflow: hidden;
}

.attributes-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
}

.attributes-table tbody {
    background: transparent;
}

.attributes-table td {
    padding: 6px 4px 8px;
    text-align: center;
    border: none;
    vertical-align: top;
}

/* Блок атрибута — как в Foundry: аббревиатура → рамка с модом → полное имя */
.attribute-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 0;
    width: 100%;
}

.attribute-abbr {
    font-family: var(--font-display);
    font-size: calc(var(--font-size-16) + 2px);
    font-weight: 400;
    line-height: 1.15;
    color: #c45a4a;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

.attribute-mod-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 3.25rem;
    width: 100%;
    max-width: 5.5rem;
    min-height: 2.65rem;
    padding: 10px 12px 8px;
    margin: 0 0 5px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(191, 152, 117, 0.45);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.55),
                inset 0 0 0 1px rgba(251, 206, 160, 0.08);
}

/* Уголки рамки модификатора (как у секций сайдбара) */
.attribute-mod-frame::before,
.attribute-mod-frame::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 9px;
    background: url("assets/bg3/svg/corner.svg") center / contain no-repeat;
    pointer-events: none;
    opacity: 0.85;
}

.attribute-mod-frame::before {
    left: -4px;
    top: -4px;
}

.attribute-mod-frame::after {
    right: -4px;
    top: -4px;
    transform: scaleX(-1);
}

.attribute-mod-frame .attribute-mod {
    position: relative;
    z-index: 1;
}

.attribute-mod {
    font-family: var(--font-primary);
    font-size: var(--font-size-24);
    font-weight: 700;
    color: var(--stat-value-color);
    text-shadow: var(--stat-value-shadow);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.attribute-full {
    font-family: var(--font-ui);
    font-size: calc(var(--font-size-11) + 1px);
    font-weight: 500;
    color: var(--bg3-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    line-height: 1.2;
    margin-top: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Совместимость со старыми классами */
.attribute-name {
    display: none;
}

.attribute-full-name {
    display: none;
}

/* Inventory Styles — как на вкладке «Ремесло» */
.inventory-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-4);
}

.inventory-header h2 {
    font-family: var(--font-primary);
    font-size: var(--font-size-24);
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: var(--space-4);
}

.currency-section {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.currency-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.currency-display label {
    font-size: var(--font-size-12);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.currency-inputs {
    display: flex;
    gap: var(--space-2);
    margin: var(--space-2) 0;
}

.currency-input {
    width: 60px;
    padding: var(--space-1) var(--space-2);
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    color: var(--ink);
    font-size: var(--font-size-12);
    text-align: center;
    font-family: var(--sans-serif);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.currency-input:hover:not(:disabled),
.currency-input:focus {
    border: 1px solid var(--accent);
    box-shadow: 0 0 10px hsl(var(--accent-hsl) / 0.35);
}

.total-wealth {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.total-wealth label {
    font-size: var(--font-size-12);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.inventory-search {
    margin-bottom: var(--space-4);
}

.search-input {
    width: 100%;
    padding: var(--space-2) var(--space-4);
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    color: var(--ink);
    font-size: var(--font-size-12);
    border-radius: 10px;
    font-family: var(--sans-serif);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.search-input:hover:not(:disabled),
.search-input:focus {
    border: 1px solid var(--accent);
    box-shadow: 0 0 10px hsl(var(--accent-hsl) / 0.35);
}

.inventory-categories {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Блок категории / блок заклинаний — recessed panel */
.inventory-category,
.spellcasting-entry-block {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    box-shadow: none;
}

/* Плашка-шапка — тёмная полоса как у «Продвинутая алхимия» / «7-й уровень» */
.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--ink);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.category-header:hover {
    background: rgba(0, 0, 0, 0.55);
}

.category-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.category-collapse-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--ink-soft);
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.inventory-category.collapsed .category-items,
.spellcasting-entry-block.collapsed .spellcasting-entry-body {
    display: none;
}

.inventory-category.collapsed .category-header,
.spellcasting-entry-block.collapsed .spellcasting-entry-header {
    border-bottom: none;
}

.inventory-category:first-child .category-header,
.spellcasting-entries-wrap > .spellcasting-entry-block:first-child .spellcasting-entry-header {
    border-radius: 6px 6px 0 0;
}

.category-header h3,
.proficiencies-section-header h3,
.abilities-header h3 {
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--ink);
    margin: 0;
    background: none;
    padding: 0;
    border-radius: 0;
}

/* Контент категории / тело блока заклинаний */
.category-items,
.spellcasting-entry-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Строки предметов — как crafting-formula-row */
.inventory-item-entry {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.inventory-item-entry.expanded {
    background: rgba(255, 248, 235, 0.04);
}

.inventory-item-row {
    display: grid;
    grid-template-columns: 28px minmax(140px, 1fr) 48px;
    align-items: center;
    gap: 0 10px;
    padding: 0 14px;
    min-height: 44px;
    height: auto;
    font-size: var(--font-size-14);
    background: transparent;
    transition: background-color 0.15s ease;
}

.inventory-item-row.expanded {
    max-height: none;
    border-bottom: none;
}

.inventory-item-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.inventory-item-row.has-value {
    grid-template-columns: 28px minmax(140px, 1fr) max-content 48px;
}

.inventory-item-row.container-row {
    cursor: pointer;
}

.inventory-expand-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.inventory-expand-btn,
.container-contents-expand-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--ink-soft);
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.inventory-expand-btn:hover,
.container-contents-expand-btn:hover {
    background: hsl(var(--accent-hsl) / 0.25);
    border-color: hsl(var(--accent-hsl) / 0.45);
    color: var(--gold);
}

.inventory-item-entry.expanded .inventory-expand-btn {
    background: hsl(var(--accent-hsl) / 0.35);
    border-color: var(--accent-text);
    color: var(--ink);
}

.category-header-cols {
    display: flex;
    gap: 8px;
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    text-transform: uppercase;
    padding-right: 8px;
}

.category-header-invest {
    min-width: 48px;
    text-align: center;
}

.category-items .inventory-item-entry:last-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.inventory-item-name {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    font-size: var(--font-size-13);
    font-weight: 500;
    color: var(--ink);
}

.inventory-item-name-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.inventory-item-name .item-name-clickable {
    color: var(--accent-text);
    cursor: pointer;
    text-decoration: none;
    font-size: var(--font-size-13);
    font-weight: 500;
    display: block;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s ease;
}

.inventory-item-name .item-name-clickable:hover {
    color: var(--gold);
    text-decoration: underline;
}

.inventory-item-value {
    text-align: right;
    font-size: var(--font-size-14);
    color: var(--ink);
    white-space: nowrap;
    min-width: 0;
}

.inventory-item-invest {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
}

.inventory-invest-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--gold);
}

.inventory-item-details {
    padding: 12px 16px 16px 42px;
    background: linear-gradient(180deg, rgba(245, 235, 210, 0.12) 0%, rgba(245, 235, 210, 0.06) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: var(--font-size-13);
    color: var(--ink);
    line-height: 1.5;
}

.inventory-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.inventory-detail-trait {
    display: inline-block;
    padding: var(--sheet-tag-padding);
    border-radius: var(--sheet-tag-radius);
    background: #8b2942;
    color: var(--ink);
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    text-transform: uppercase;
    font-family: var(--sans-serif);
}

.inventory-detail-meta {
    margin-bottom: 10px;
    font-size: var(--font-size-12);
    color: var(--ink-soft);
}

.inventory-detail-description {
    margin-bottom: 12px;
}

.inventory-detail-description p {
    margin: 0 0 8px;
}

.inventory-detail-mechanics {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 10px;
}

.inventory-detail-mechanics-top {
    border-top: none;
    padding-top: 0;
    padding-bottom: 8px;
    margin-bottom: 0;
}

.inventory-detail-mechanics-top + .inventory-detail-description {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 10px;
}

.inventory-detail-mechanics-bottom {
    margin-top: 8px;
}

.inventory-detail-weapon-block {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.inventory-detail-weapon-subhead {
    margin: 10px 0 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold);
}

.inventory-detail-weapon-block > .inventory-detail-weapon-subhead:first-child {
    margin-top: 0;
}

.inventory-detail-weapon-runes .inventory-detail-mechanic {
    margin: 4px 0;
}

.inventory-detail-weapon-damage {
    margin-top: 8px;
}

.inventory-detail-armor-stats {
    margin-top: 8px;
}

.inventory-detail-armor-stats .inventory-detail-mechanic {
    margin: 4px 0;
}

.inventory-detail-activation-title {
    margin-bottom: 8px;
    font-size: var(--font-size-13);
}

.inventory-detail-activation-title .action-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin: 0 4px;
    border: 1px solid var(--gold);
    transform: rotate(45deg);
    font-size: 11px;
    font-weight: 700;
    color: var(--gold);
    vertical-align: middle;
}

/* @Glyph[БРАВАДА] — полное слово, не ромб с одной буквой */
.action-glyph.bravado-inline {
    width: auto;
    height: auto;
    min-height: 20px;
    padding: 2px 8px;
    line-height: 1.2;
    white-space: nowrap;
    transform: none;
    border-radius: 3px;
    background: var(--color-pf-primary);
    color: var(--ink);
    border: none;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.inventory-detail-activation-title .action-glyph.bravado-inline {
    min-height: 18px;
    margin: 0 4px;
    vertical-align: middle;
}

.actions-item-row .action-glyph.bravado-inline {
    transform: none;
}

.inventory-detail-mechanic {
    margin: 6px 0;
}

.inventory-detail-mechanic strong {
    color: var(--ink);
}

.inventory-item-actions {
    display: flex;
    gap: var(--space-1);
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.inventory-item-row:hover .inventory-item-actions {
    opacity: 1;
}

.item-edit-btn,
.item-delete-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--ink-soft);
    padding: 4px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: var(--font-size-12);
    transition: all 0.15s ease;
    line-height: 1;
}

.item-edit-btn:hover,
.item-delete-btn:hover {
    background: hsl(var(--accent-hsl) / 0.2);
    border-color: hsl(var(--accent-hsl) / 0.4);
    color: var(--gold);
}

.category-add-btn {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: var(--font-size-11);
    cursor: pointer;
    border-radius: 3px;
    font-weight: 500;
}

.category-add-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Container Styles — в том же стиле, что блоки ремесла */
.container-wrapper {
    margin-bottom: 0;
}

.container-row {
    /* основная строка контейнера — .inventory-item-row */
}

.container-expand-btn {
    display: inline-block;
    transition: transform 0.2s ease;
    user-select: none;
    width: 14px;
    text-align: center;
}

.container-contents .inventory-item-entry.container-item {
    margin-left: 0;
}

.container-contents {
    margin-left: 24px;
    margin-top: 0;
    padding: 8px 0 0 12px;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.08);
}

.container-item {
    margin-left: 0;
    background: transparent !important;
    border-left: none;
}

.container-capacity-info {
    padding: 8px 12px 8px 0;
    margin-bottom: 4px;
    font-size: var(--font-size-12);
    color: var(--ink);
    font-weight: 500;
}

.container-capacity {
    display: inline;
}

.container-empty {
    padding: 8px 12px 8px 0;
    color: var(--ink-soft);
    font-style: italic;
    font-size: var(--font-size-12);
}

.inventory-table {
    width: 100%;
    border-collapse: collapse;
}

.inventory-table thead {
    background: hsl(var(--accent-hsl) / 0.12);
}

.inventory-table th {
    padding: var(--space-2);
    text-align: left;
    font-size: var(--font-size-11);
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,.14);
    font-family: var(--sans-serif);
}

.inventory-table td {
    padding: var(--space-2);
    font-size: var(--font-size-12);
    color: var(--ink);
    border-bottom: 1px solid rgba(255,255,255,.14);
}

.item-icon {
    vertical-align: middle;
    margin-right: var(--space-2);
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.item-name-clickable {
    cursor: pointer;
    color: var(--gold);
    font-weight: 500;
}

.item-name-clickable:hover {
    text-decoration: underline;
}

.item-edit-btn,
.item-delete-btn {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: 3px;
    margin-left: var(--space-1);
    font-size: var(--font-size-11);
}

.item-edit-btn:hover,
.item-delete-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Футер инвентаря — recessed блок как «Продвинутая алхимия» */
.inventory-footer {
    margin-top: var(--space-4);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.bulk-info {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: 12px 14px;
    font-size: var(--font-size-14);
    color: var(--ink);
}

/* Proficiencies Styles — как на вкладке «Инвентарь» */
#panel-proficiencies {
    --proficiencies-text-plus: 2px;
    --proficiencies-name-plus: 4px;
}

#panel-proficiencies .proficiencies-content h2 {
    font-size: calc(1.15rem + var(--proficiencies-name-plus));
}

#panel-proficiencies .skill-item,
#panel-proficiencies .skill-value {
    font-size: calc(var(--font-size-14) + var(--proficiencies-text-plus));
}

#panel-proficiencies .skill-name {
    font-size: calc(var(--font-size-14) + var(--proficiencies-name-plus));
}

#panel-proficiencies .skill-icon {
    font-size: calc(16px + var(--proficiencies-text-plus));
}

#panel-proficiencies .skill-tooltip {
    font-size: calc(var(--font-size-12) + var(--proficiencies-text-plus));
}

#panel-proficiencies .skill-item.skill-item-class-dc .skill-value {
    font-size: calc(1.1rem + var(--proficiencies-text-plus));
}

#panel-proficiencies .proficiency-add-btn {
    font-size: calc(var(--font-size-12) + var(--proficiencies-text-plus));
}

.proficiencies-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-4);
    overflow: visible;
}

.proficiencies-content h2 {
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 var(--space-4);
    letter-spacing: 0.02em;
    text-align: left;
}

.proficiencies-sections {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    overflow: visible;
}

/* Блок секции — recessed panel как .inventory-category */
.proficiencies-section {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
}

.proficiencies-section:first-child .proficiencies-section-header {
    border-radius: 10px 10px 0 0;
}

/* Плашка-шапка — тёмная полоса как .category-header */
.proficiencies-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--ink);
}

/* Контент секции — как .category-items */
.proficiencies-section-content {
    padding: 0;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    overflow: visible;
}

.skill-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: visible;
}

/* Двухколоночная сетка для базовых навыков */
.skill-list-two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

@media (max-width: 800px) {
    .skill-list-two-columns {
        grid-template-columns: 1fr;
    }
}

/* Строка навыка — как .inventory-item-row */
.skill-item {
    display: grid;
    grid-template-columns: 32px 48px 1fr auto;
    align-items: center;
    gap: 0 12px;
    padding: 0 14px;
    min-height: 48px;
    height: 48px;
    max-height: 48px;
    font-size: var(--font-size-14);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    transition: background-color 0.15s ease;
    overflow: visible;
}

.skill-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.skill-list .skill-item:last-of-type {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.skill-list-two-columns .skill-item:nth-last-of-type(-n+2) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.skill-list-two-columns .skill-item:nth-child(odd) {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.skill-item.skill-item-lore {
    grid-template-columns: 32px 48px 1fr auto;
}

.skill-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    color: var(--ink-soft);
}

.skill-icon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.skill-value-wrap {
    position: relative;
    display: inline-block;
    min-width: 40px;
    flex-shrink: 0;
    text-align: right;
    cursor: help;
}

.skill-tooltip {
    position: fixed;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    white-space: nowrap;
    font-size: var(--font-size-12);
    font-family: var(--sans-serif);
    color: var(--ink);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    text-align: left;
    min-width: max-content;
    transform: translateX(-50%);
}

.skill-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.25);
    margin-top: -1px;
}

.skill-value {
    font-family: var(--font-primary);
    font-size: var(--font-size-14);
    font-weight: 700;
    color: var(--ink);
    text-align: right;
}

.skill-name {
    flex: 1;
    font-size: var(--font-size-14);
    color: var(--ink);
    font-weight: 500;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Теги ранга мастерства — «Мастерство», «Колдовство» (как в сайдбаре) */
#panel-proficiencies .skill-item .pf-rank,
#panel-spellcasting .pf-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.2;
    text-transform: uppercase;
    font-family: var(--sans-serif);
    flex-shrink: 0;
    white-space: nowrap;
    min-width: 4.75rem;
    box-sizing: border-box;
    border: none;
    color: #f5f0e8;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

#panel-proficiencies .skill-item .pf-rank {
    font-size: calc(10px + var(--proficiencies-text-plus, 2px));
}

#panel-spellcasting .pf-rank {
    font-size: 10px;
}

#panel-proficiencies .skill-item .pf-rank[data-rank="0"],
#panel-proficiencies .skill-item .pf-rank.untrained,
#panel-spellcasting .pf-rank[data-rank="0"],
#panel-spellcasting .pf-rank.untrained {
    background: var(--color-proficiency-untrained);
}

#panel-proficiencies .skill-item .pf-rank[data-rank="1"],
#panel-proficiencies .skill-item .pf-rank.trained,
#panel-spellcasting .pf-rank[data-rank="1"],
#panel-spellcasting .pf-rank.trained {
    background: var(--color-proficiency-trained);
}

#panel-proficiencies .skill-item .pf-rank[data-rank="2"],
#panel-proficiencies .skill-item .pf-rank.expert,
#panel-spellcasting .pf-rank[data-rank="2"],
#panel-spellcasting .pf-rank.expert {
    background: var(--color-proficiency-expert);
}

#panel-proficiencies .skill-item .pf-rank[data-rank="3"],
#panel-proficiencies .skill-item .pf-rank.master,
#panel-spellcasting .pf-rank[data-rank="3"],
#panel-spellcasting .pf-rank.master {
    background: var(--color-proficiency-master);
    color: #1a1208;
    text-shadow: none;
}

#panel-proficiencies .skill-item .pf-rank[data-rank="4"],
#panel-proficiencies .skill-item .pf-rank.legendary,
#panel-spellcasting .pf-rank[data-rank="4"],
#panel-spellcasting .pf-rank.legendary {
    background: var(--color-proficiency-legendary);
}

.skill-delete-btn {
    background: transparent;
    border: none;
    color: var(--gold);
    cursor: pointer;
    padding: 2px 6px;
    font-size: var(--font-size-12);
    opacity: 0.75;
    transition: opacity 0.2s;
    flex-shrink: 0;
    margin-left: 4px;
}

.skill-delete-btn:hover {
    opacity: 1;
    color: var(--gold);
}

.proficiency-add-btn {
    background: hsl(var(--accent-hsl) / 0.35);
    border: 1px solid rgba(167, 139, 250, 0.4);
    color: var(--ink);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: var(--font-size-12);
    font-weight: 600;
    font-family: var(--sans-serif);
    cursor: pointer;
    transition: all 0.2s;
}

.proficiency-add-btn:hover {
    background: hsl(var(--accent-hsl) / 0.5);
    border-color: rgba(167, 139, 250, 0.6);
}

/* КС классов: большое число без + */
.skill-item.skill-item-class-dc {
    grid-template-columns: 32px 52px 1fr auto;
}

.skill-item.skill-item-class-dc .skill-value {
    font-size: 1.1rem;
}

/* Abilities Styles */
.abilities-content {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: var(--space-4);
    overflow-x: hidden;
    min-width: 0;
}

.abilities-sections {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    width: 100%;
    min-width: 0;
}

/* Блок секции — recessed panel как .inventory-category */
.abilities-section {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    width: 100%;
    min-width: 0;
}

.abilities-section:first-child .abilities-header {
    border-radius: 6px 6px 0 0;
}

/* Плашка-шапка — тёмная полоса как .category-header */
.abilities-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--ink);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.abilities-header:hover {
    background: rgba(0, 0, 0, 0.55);
}

.abilities-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.abilities-section.collapsed .abilities-list {
    display: none;
}

.abilities-section.collapsed .abilities-header {
    border-bottom: none;
}

/* Запись способности — как .inventory-item-entry */
.ability-item-entry {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.ability-item-entry.expanded {
    background: rgba(255, 248, 235, 0.04);
}

.ability-item-entry .ability-item {
    cursor: pointer;
}

.ability-item.expanded {
    border-bottom: none;
}

.ability-item-details {
    padding: 12px 16px 16px 42px;
    background: linear-gradient(180deg, rgba(245, 235, 210, 0.12) 0%, rgba(245, 235, 210, 0.06) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: var(--font-size-13);
    color: var(--ink);
    line-height: 1.45;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.ability-item-details .inventory-item-details-inner,
.ability-item-details .inventory-detail-meta,
.ability-item-details .inventory-detail-description,
.ability-item-details .inventory-detail-mechanics,
.ability-item-details .item-description-content {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.ability-item-details .item-description-content p strong {
    white-space: normal;
}

/* Контент секции — как .category-items */
.abilities-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    width: 100%;
    min-width: 0;
}

/* Строка способности — как .inventory-item-row */
.ability-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    min-height: 48px;
    height: auto;
    max-height: none;
    font-size: var(--font-size-14);
    background: transparent;
    transition: background-color 0.15s ease;
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.ability-item-entry .ability-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.abilities-list .ability-item-entry:last-of-type,
.ability-children .ability-item-entry:last-of-type {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ability-item.ability-child {
    margin-left: 0;
    padding-left: calc(24px + 12px + 14px);
    position: relative;
    overflow: visible !important;
    width: 100%;
    min-width: 0;
}

.ability-item.ability-child::before {
    content: '';
    position: absolute;
    left: 20px;
    top: -8px;
    bottom: 8px;
    width: 2px;
    border-left: 2px dotted rgba(255, 255, 255, 0.3);
}

/* Ensure child ability names are fully visible */
.ability-item.ability-child .ability-name-container {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
}

.ability-item.ability-child .ability-name {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-wrap: break-word !important;
    word-break: normal !important;
}

.ability-item.ability-child .ability-name-english {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-wrap: break-word !important;
}

.ability-level {
    font-size: var(--font-size-12);
    font-weight: 700;
    color: var(--ink);
    min-width: 24px;
    width: 24px;
    height: 24px;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    font-family: var(--sans-serif);
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    flex-basis: 24px;
    visibility: visible !important;
    opacity: 1 !important;
}

.ability-level-unknown {
    color: var(--ink-soft);
    font-style: italic;
}

.ability-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    flex-basis: 36px;
    border-radius: 4px;
}

.ability-icon-placeholder {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    flex-basis: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Name container for bilingual display */
.ability-name-container {
    display: flex !important;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: none;
    gap: 4px;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    white-space: normal !important;
    text-overflow: clip !important;
}

.ability-name {
    font-size: var(--font-size-13);
    color: var(--ink);
    font-weight: 500;
    font-family: var(--font-primary);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    transition: color 0.15s ease;
    flex-shrink: 0;
    display: inline-block !important;
    line-height: 1.4;
    word-wrap: break-word;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 0;
}

.ability-name-english {
    font-size: var(--font-size-13);
    color: var(--ink);
    font-weight: 500;
    font-family: var(--font-primary);
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-wrap: break-word !important;
    word-break: normal !important;
    line-height: 1.4;
    flex-shrink: 0;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.sheet-privacy-note {
    flex: 1 1 100%;
    margin: 0;
    padding: 8px 10px;
    font-size: var(--font-size-11);
    line-height: 1.4;
    color: var(--color-text-secondary);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(183, 143, 109, 0.25);
    border-radius: 6px;
}

html[data-sheet-deploy="public"] .sheet-privacy-note {
    display: block;
}

/* Import Button */
.import-container {
  position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    justify-content: flex-end;
    align-items: center;
    max-width: min(96vw, 520px);
}

.import-label {
    display: inline-block;
    padding: var(--space-4) var(--space-8);
    background: linear-gradient(180deg, rgba(94, 0, 0, 0.75), rgba(43, 0, 0, 0.9));
    border: 1px solid rgba(251, 206, 160, 0.45);
    color: var(--bg3-gold);
    border-radius: 10px;
    cursor: pointer;
    font-size: var(--font-size-13);
    font-weight: 600;
    font-family: var(--font-ui);
    letter-spacing: .3px;
    box-shadow: 0 0 12px rgba(94, 0, 0, 0.5),
                inset 0 1px 0 rgba(251, 206, 160, 0.15);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all 0.2s;
}

.import-label:hover {
    background: linear-gradient(180deg, rgba(145, 0, 0, 0.85), rgba(94, 0, 0, 0.95));
    border-color: var(--bg3-gold-hover);
    color: #fff;
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 12px hsl(var(--highlight-hsl) / 0.5), 
                0 0 20px hsl(var(--highlight-hsl) / 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

button.import-label.export-sheet-btn {
    font: inherit;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.10);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.15);
}

/* Modifiers Modal */
.modifiers-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modifiers-modal-content {
    background: var(--bg);
    border: 2px solid #c19976;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modifiers-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    background: var(--bg-dark);
}

.modifiers-modal-header h3 {
    margin: 0;
    font-size: var(--font-size-16);
    font-weight: 600;
    color: var(--text-dark);
    font-family: var(--sans-serif);
}

.modifiers-modal-close {
    background: transparent;
    border: none;
    font-size: var(--font-size-24);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modifiers-modal-close:hover {
    color: var(--text-dark);
}

.modifiers-modal-body {
    padding: var(--space-4);
    overflow-y: auto;
    flex: 1;
}

.modifiers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modifier-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 4px;
    font-size: var(--font-size-13);
    margin-bottom: 8px;
}

.modifier-item:last-child {
    margin-bottom: 0;
}

.modifier-value {
    font-weight: 700;
    color: var(--ink);
    font-size: var(--font-size-16);
    font-family: var(--font-primary);
    margin-bottom: 2px;
}

.modifier-label {
    color: var(--ink);
    font-weight: 500;
    font-size: var(--font-size-13);
}

.modifier-type {
    font-size: var(--font-size-11);
    color: var(--ink-soft);
    text-transform: uppercase;
    margin-top: 2px;
}

.modifiers-total {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    text-align: right;
    font-size: var(--font-size-16);
    color: var(--text-dark);
    font-family: var(--serif-condensed);
}

/* «Детально» в секциях персонажа — как в сайдбаре */
.character-section .section-header {
    align-items: flex-end;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 0.5em;
}

.character-section .section-header .section-title {
    flex: 1;
    min-width: 0;
    border-bottom: 1px solid var(--sidebar-title);
    padding-bottom: 0;
    margin-bottom: 0;
}

.character-section .section-header .details-btn {
    flex: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px 2px 0 0;
    border: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    color: var(--sidebar-title);
    opacity: 0.85;
    font: 600 var(--font-size-9) var(--font-ui);
    letter-spacing: 0.05em;
    line-height: 1;
    margin: 0;
    padding: var(--space-2) var(--space-3);
    text-rendering: optimizeLegibility;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s, color 0.2s, opacity 0.2s;
    border-bottom: 1px solid var(--sidebar-title);
}

.character-section .section-header .details-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
    color: var(--sidebar-title);
    opacity: 1;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Attributes Details Modal */
.attributes-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 5, 4, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--space-4);
}

.attributes-details-modal-content {
    background: radial-gradient(ellipse at 30% 15%, rgba(251, 206, 160, 0.08), transparent 55%),
                linear-gradient(180deg, var(--bg-main), var(--bg-main-2));
    border: 2px solid #c19976;
    border-radius: 4px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px var(--shadow);
    overflow: hidden;
    position: relative;
}

.attributes-details-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid rgba(183, 143, 109, 0.35);
    background: linear-gradient(180deg, var(--header-shade-top), var(--header-shade-bottom));
}

.attributes-details-modal-header h3 {
    margin: 0;
    font-size: var(--font-size-16);
    font-weight: 600;
    color: var(--gold);
    font-family: var(--sans-serif);
}

.attributes-details-modal-close {
    background: transparent;
    border: none;
    font-size: var(--font-size-24);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.attributes-details-modal-close:hover {
    color: var(--gold);
}

.attributes-details-modal-body {
    padding: var(--space-4);
    overflow-y: auto;
    flex: 1;
    background: transparent;
}

.attributes-details-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 10px;
    overflow: hidden;
}

.attributes-details-table thead {
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.attributes-details-table th,
.attributes-details-table td.source-label {
    padding: 12px 10px;
    text-align: center;
    font-family: var(--sans-serif);
    font-size: calc(var(--font-size-12) + 1px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gold);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.attributes-details-table th:first-child,
.attributes-details-table td.source-label {
    text-align: left;
    padding-left: 12px;
}

.attributes-details-table thead th {
    background: rgba(0, 0, 0, 0.25);
}

.attributes-details-table tbody td.source-label {
    background: transparent;
    font-weight: 700;
    vertical-align: middle;
}

.attributes-details-table th:last-child {
    border-right: none;
}

.attributes-details-table tbody {
    background: transparent;
}

.attributes-details-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.attributes-details-table tbody tr:last-child {
    border-bottom: none;
}

.attributes-details-table tbody tr.total-row {
    border-top: 1px solid rgba(255,255,255,.10);
    background: hsl(var(--accent-hsl) / 0.1);
    font-weight: 600;
}

.attributes-details-table td {
    padding: 10px;
    text-align: center;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    vertical-align: middle;
    font-size: calc(var(--font-size-13) + 1px);
}

.attributes-details-table td:last-child,
.attributes-details-table th:last-child {
    border-right: none;
}

.attributes-details-table td.mod-value {
    font-family: var(--font-primary);
    font-size: calc(var(--font-size-14) + 1px);
    font-weight: 600;
    color: var(--stat-value-color);
    text-shadow: var(--stat-value-shadow);
}

.attributes-details-table .mod-value strong {
    font-weight: 700;
    color: inherit;
}

.attributes-details-table tbody tr.total-row td.mod-value {
    font-size: calc(var(--font-size-15) + 1px);
    font-weight: 700;
}

/* Таблица «Детали: Языки» */
.languages-details-table th,
.languages-details-table td.languages-name-cell,
.languages-details-table td.languages-group-cell {
    font-weight: 400;
}

.languages-details-table th:first-child,
.languages-details-table td.languages-name-cell {
    text-align: left;
    padding-left: 14px;
}

.languages-details-table td.languages-group-cell {
    font-family: var(--font-primary);
    font-size: calc(var(--font-size-14) + 3px);
    color: var(--ink-soft);
    text-shadow: none;
    text-transform: none;
    vertical-align: top;
}

.languages-details-table td.languages-group-cell--plain {
    vertical-align: middle;
}

.languages-details-table th:nth-child(2),
.languages-details-table td.languages-group-cell {
    min-width: 160px;
}

/* Свернутый список языков FoundryVTT в группе */
.languages-group-collapse {
    margin: 0;
}

.languages-group-collapse > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.languages-group-collapse > summary::-webkit-details-marker {
    display: none;
}

.languages-group-collapse > summary::marker {
    content: '';
}

.languages-group-caret {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 6px solid var(--ink-soft);
    transition: transform 0.15s ease;
}

.languages-group-collapse[open] .languages-group-caret {
    transform: rotate(90deg);
}

.languages-group-title {
    font-weight: 400;
    color: var(--ink-soft);
}

.languages-group-foundry-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0 0 0 14px;
}

.languages-group-foundry-list li {
    font-family: var(--font-primary);
    font-size: calc(var(--font-size-14) + 3px);
    font-weight: 400;
    color: var(--ink-soft);
    line-height: 1.45;
    padding: 1px 0;
}

.languages-details-table th:nth-child(3),
.languages-details-table td.languages-acquisition-cell {
    min-width: 200px;
    text-align: left;
    padding: 8px 12px;
}

.languages-details-table .languages-acquisition-input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    font-family: var(--font-primary);
    font-size: calc(var(--font-size-13) + 2px);
    font-weight: 400;
    color: var(--ink);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(183, 143, 109, 0.35);
    border-radius: 4px;
}

.languages-details-table .languages-acquisition-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 1px rgba(251, 206, 160, 0.2);
}

.languages-details-table .languages-acquisition-input::placeholder {
    color: var(--ink-soft);
    opacity: 0.7;
}

/* Item Details Modal */
.item-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--space-4);
}

.item-details-modal-content {
    background: var(--bg-dark);
    border: 2px solid #c19976;
    border-radius: 4px;
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

/* Изменение размера модальных окон (угол справа снизу) */
.modal-resizable-content {
    position: relative;
    flex-shrink: 0;
    box-sizing: border-box;
    min-height: 0;
    overflow: hidden;
    width: auto;
    max-width: 95vw;
    max-height: 95vh;
}

/* Тело окна заполняет высоту при ресайзе; прокрутка в .modal-scroll-fill / списках */
.modal-resizable-content .item-details-modal-body,
.modal-resizable-content .attributes-details-modal-body,
.modal-resizable-content .modifiers-modal-body,
.modal-resizable-content .ability-details-tab-content {
    flex: 1 1 auto;
    min-height: 0;
}

.modal-resizable-content .item-details-modal-body:not(.deity-modal-body),
.modal-resizable-content .attributes-details-modal-body,
.modal-resizable-content .modifiers-modal-body,
.modal-resizable-content .spell-preparation-modal-body:not(.spell-prep-layout) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-resizable-content .spell-preparation-modal-body.spell-prep-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
    gap: 0;
    min-height: 0;
}

.modal-resizable-content .modal-scroll-fill,
.modal-resizable-content .spell-prep-repertoire {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-resizable-content .spell-prep-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-resizable-content .spell-prep-main .spell-prep-repertoire {
    flex: 1 1 auto;
    min-height: 0;
}

.modal-resizable-content .deity-modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.modal-resizable-content .deity-tab-panel {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-resizable-content .deity-tab-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.modal-resize-handle {
    position: fixed;
    width: 20px;
    height: 20px;
    z-index: 10001;
    cursor: nwse-resize;
    touch-action: none;
    pointer-events: auto;
    margin: 0;
    flex: none;
}

.modal-resize-handle::before {
    content: '';
    position: absolute;
    top: auto;
    left: auto;
    right: 3px;
    bottom: 3px;
    width: 10px;
    height: 10px;
    border-right: 2px solid color-mix(in srgb, var(--gold) 78%, transparent);
    border-bottom: 2px solid color-mix(in srgb, var(--gold) 78%, transparent);
    border-top: none;
    border-left: none;
    box-sizing: border-box;
    pointer-events: none;
    transition: border-color 0.15s ease, opacity 0.15s ease;
    opacity: 1;
}

.modal-resize-handle:hover::before,
.modal-resize-handle:active::before {
    border-color: var(--gold);
    opacity: 1;
}

.item-details-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--bg-dark);
}

.item-details-modal-header h3 {
    margin: 0;
    font-size: var(--font-size-16);
    font-weight: 600;
    color: var(--ink);
    font-family: var(--sans-serif);
    text-transform: none;
    letter-spacing: 0;
}

.item-details-modal-close {
    background: transparent;
    border: none;
    font-size: var(--font-size-24);
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.item-details-modal-close:hover {
    color: var(--gold);
}

.item-details-modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-width: 0;
}

.item-details-modal-body::-webkit-scrollbar {
    width: 8px;
}

.item-details-modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.item-details-modal-body::-webkit-scrollbar-thumb {
    background: hsl(var(--highlight-hsl) / 0.3);
    border-radius: 4px;
}

.item-details-modal-body::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--highlight-hsl) / 0.5);
}

.item-detail-row {
    margin-bottom: 16px;
    padding: 12px 16px;
    padding-bottom: 16px;
    background: rgba(0, 0, 0, 0.15);
    border-left: 3px solid hsl(var(--highlight-hsl) / 0.4);
    border-radius: 4px;
    font-size: var(--font-size-13);
    color: var(--ink);
    transition: all 0.2s;
}

.item-detail-row:hover {
    background: rgba(0, 0, 0, 0.2);
    border-left-color: hsl(var(--highlight-hsl) / 0.6);
}

.item-detail-row:last-child {
    margin-bottom: 0;
}

.item-detail-row strong {
    color: var(--gold);
    margin-right: 10px;
    font-weight: 600;
    font-size: var(--font-size-13);
}

.item-detail-activation {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--gold);
    font-size: var(--font-size-13);
    color: var(--ink);
    line-height: 1.6;
}

.item-detail-activation strong {
    color: var(--gold);
    font-weight: 600;
}

.item-detail-activation .action-glyph {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background: var(--color-pf-primary);
    color: var(--ink);
    border-radius: 3px;
    font-weight: 700;
    font-size: var(--font-size-11);
    margin: 0 4px;
}

.item-detail-activation .action-glyph.bravado-inline {
    width: auto;
    height: auto;
    min-height: 20px;
    line-height: 1.2;
    padding: 2px 8px;
    white-space: nowrap;
}

.item-detail-activation .trait-link {
    color: var(--accent-text);
    font-weight: 500;
}

.item-detail-stages {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--gold);
}

.item-detail-stages .item-stage {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: var(--font-size-13);
    line-height: 1.6;
    color: var(--ink);
}

.item-detail-stages .item-stage:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.item-detail-stages .item-stage strong {
    color: var(--gold);
    font-weight: 600;
    margin-right: 8px;
}

.item-detail-description:not(.bg3-frame-host) {
    margin-top: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}

.item-detail-description.bg3-frame-host {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}

.item-detail-description strong {
    display: block;
    color: var(--gold);
    margin-bottom: 12px;
    font-size: var(--font-size-13);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: var(--sans-serif);
}

.item-description-content {
    color: var(--ink);
    font-size: var(--font-size-13);
    line-height: 1.6;
    font-family: var(--sans-serif);
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.item-description-content a,
.item-description-content a strong {
    text-decoration: none !important;
}

.item-description-content p {
    margin: 0 0 12px 0;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.item-description-content p strong {
    white-space: normal;
}

.item-description-content p:last-child {
    margin-bottom: 0;
}

.item-description-content em {
    font-style: italic;
    color: var(--ink);
}

.item-description-content strong,
.item-description-content p strong,
.item-description-content span strong {
    color: var(--gold) !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: calc(var(--font-size-13) - 1px) !important;
    display: inline;
    white-space: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
    text-decoration: none !important;
    border-bottom: none !important;
    text-decoration-line: none !important;
    text-underline-offset: 0 !important;
    text-decoration-thickness: 0 !important;
    text-decoration-style: none !important;
    text-decoration-color: transparent !important;
}

.item-description-content ul,
.item-description-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.item-description-content li {
    margin-bottom: 4px;
    color: var(--ink);
}

.item-description-content .action-glyph {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background: var(--color-pf-primary);
    color: var(--ink);
    border-radius: 3px;
    font-weight: 700;
    font-size: var(--font-size-11);
    margin: 0 4px;
}

.item-description-content .action-glyph.bravado-inline {
    width: auto;
    height: auto;
    min-height: 20px;
    line-height: 1.2;
    padding: 2px 8px;
    white-space: nowrap;
}

.item-description-content .trait-link {
    color: var(--accent-text);
    font-weight: 500;
    font-style: italic;
    text-decoration: underline;
    text-decoration-color: var(--accent-text);
    text-underline-offset: 0.125em;
    cursor: pointer;
    transition: color 0.15s ease;
}

.item-description-content .trait-link:hover {
    color: var(--gold);
    text-decoration-color: var(--gold);
}

.item-description-content .action-link {
    display: inline;
    padding: 0;
    background: transparent;
    border: none;
    text-decoration: underline;
    text-decoration-color: var(--accent-text);
    text-underline-offset: 0.125em;
    font-style: normal;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s ease;
}

.item-description-content .action-link:hover {
    color: var(--gold);
    text-decoration-color: var(--gold);
}

.item-description-content .ability-link {
    display: inline;
    padding: 0;
    background: transparent;
    border: none;
    text-decoration: underline;
    text-decoration-color: var(--accent-text);
    text-underline-offset: 0.125em;
    font-style: normal;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s ease;
}

.item-description-content .ability-link:hover {
    color: var(--gold);
    text-decoration-color: var(--gold);
}

.compendium-link-tooltip {
    position: fixed;
    z-index: 10060;
    max-width: min(28rem, 92vw);
    max-height: min(70vh, 26rem);
    overflow: auto;
    padding: 0.75rem 0.875rem;
    background: linear-gradient(180deg, hsl(30 18% 14%) 0%, hsl(28 16% 10%) 100%);
    border: 1px solid var(--accent-text);
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
}

.compendium-link-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* Alt: окно закреплено — можно навести курсор и прокрутить колёсиком */
.compendium-link-tooltip--alt-pinned {
    outline: 1px solid rgba(193, 153, 118, 0.5);
    outline-offset: 2px;
    overscroll-behavior: contain;
}

.compendium-link-tooltip-title {
    font-family: var(--serif);
    font-size: calc(var(--font-size-13) + 2px);
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 0.35rem;
    line-height: 1.25;
}

.compendium-link-tooltip-meta {
    font-size: var(--font-size-11);
    color: var(--accent-text);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.compendium-link-tooltip-body {
    font-size: var(--font-size-13);
    line-height: 1.45;
    color: var(--ink);
}

/* Внутри подсказки — обычный текст, без вложенных всплывашек */
.compendium-link-tooltip-body .compendium-tooltip-plain-text,
.compendium-link-tooltip-body .ability-link,
.compendium-link-tooltip-body .action-link {
    color: inherit;
    text-decoration: none;
    cursor: text;
    pointer-events: none;
}

.compendium-link-tooltip-body p {
    margin: 0.4em 0;
}

.compendium-link-tooltip-body p:first-child {
    margin-top: 0;
}

.compendium-link-tooltip-body p:last-child {
    margin-bottom: 0;
}

.compendium-link-tooltip-empty {
    color: var(--accent-text);
    font-style: italic;
}

.compendium-link-tooltip-body .journal-domain-index {
    margin: 0.5em 0 0;
    padding: 0 0 0 1.1em;
    columns: 2;
    column-gap: 1.25em;
}

.compendium-link-tooltip-body .journal-domain-index li {
    margin: 0.15em 0;
    break-inside: avoid;
}

.ability-tags-container {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.ability-tag {
    padding: var(--sheet-tag-padding);
    border-radius: var(--sheet-tag-radius);
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    text-transform: uppercase;
    font-family: var(--sans-serif);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: hsl(var(--accent-hsl) / 0.2);
    color: var(--accent-text);
    display: inline-block;
    transition: all 0.15s ease;
}

.ability-tag:hover {
    background: hsl(var(--accent-hsl) / 0.3);
    border-color: var(--accent-text);
    color: var(--gold);
}

.item-description-content .action-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--ink);
    flex-shrink: 0;
    opacity: 0.7;
}

.item-description-content .damage-roll,
.item-description-content .inline-roll,
.inventory-detail-description .damage-roll,
.inventory-detail-description .inline-roll,
.inventory-detail-mechanics .damage-roll,
.inventory-detail-mechanics .inline-roll,
.ability-item-details .damage-roll,
.ability-item-details .inline-roll,
.actions-item-details .damage-roll,
.actions-item-details .inline-roll,
.item-details-modal .damage-roll,
.item-details-modal .inline-roll {
    display: inline-block;
    padding: 2px 6px;
    background: hsl(var(--highlight-hsl) / 0.2);
    border: 1px solid var(--accent);
    border-radius: 3px;
    color: var(--ink);
    font-weight: 400;
    font-family: var(--monospace);
    margin: 0 2px;
    cursor: help;
}

.item-description-content .check-notation {
    color: var(--gold);
    font-weight: 500;
}

.item-detail-class-info {
    margin-bottom: 16px;
    padding: 12px 0;
}

.item-detail-class-info-header {
    font-size: var(--font-size-13);
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}

.item-detail-class-info-header strong {
    font-size: var(--font-size-13);
    font-weight: 600;
    color: var(--ink);
}

.item-detail-class-info-text {
    font-size: var(--font-size-13);
    color: var(--ink-soft);
    line-height: 1.6;
    margin-bottom: 0;
}

.item-detail-ancestry-mechanics:not(.bg3-frame-host) {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.item-detail-ancestry-mechanics p {
    margin: 8px 0;
    font-size: var(--font-size-13);
    line-height: 1.6;
}

.item-detail-ancestry-mechanics p strong {
    font-size: var(--font-size-13);
    font-weight: 600;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 8px;
}

.item-detail-ancestry-mechanics .item-detail-mechanics-value {
    color: var(--ink-soft);
    font-weight: 400;
    text-transform: none;
}

.item-detail-rules {
    margin-top: 12px;
}

.item-detail-rules strong {
    display: block;
    color: var(--gold);
    margin-bottom: 8px;
    font-size: var(--font-size-14);
}

.item-rules-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item-rules-list li {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-left: 3px solid hsl(var(--highlight-hsl) / 0.5);
    border-radius: 4px;
    font-size: var(--font-size-13);
    color: var(--ink);
    font-family: var(--sans-serif);
    transition: all 0.2s;
}

.item-rules-list li:hover {
    background: rgba(0, 0, 0, 0.35);
    border-left-color: hsl(var(--highlight-hsl) / 0.7);
    transform: translateX(2px);
}

/* Окна «⋮» на вкладке Персонаж (родословная, наследие, класс, божество…) — весь текст +2px */
.item-details-modal {
    --item-details-fs-extra: 2px;
    /* Серый текст описания светлее базового --ink-soft (55% → 82%) */
    --ink-soft: hsla(0, 0%, 100%, 0.82);
}

.item-details-modal .item-details-modal-header h3,
.item-details-modal .deity-modal-header-main h3 {
    font-size: calc(var(--font-size-16) + var(--item-details-fs-extra));
}

.item-details-modal .item-details-modal-close {
    font-size: calc(var(--font-size-24) + var(--item-details-fs-extra));
}

.item-details-modal .item-detail-row,
.item-details-modal .item-detail-row strong,
.item-details-modal .item-detail-activation,
.item-details-modal .item-detail-stages .item-stage,
.item-details-modal .item-detail-description strong,
.item-details-modal .item-detail-ancestry-mechanics p strong,
.item-details-modal .item-detail-rules strong,
.item-details-modal .item-rules-list li,
.item-details-modal .deity-lore-banner p,
.item-details-modal .deity-lore-body h2,
.item-details-modal .deity-lore-body h3,
.item-details-modal .deity-detail-label,
.item-details-modal .deity-detail-value,
.item-details-modal .deity-section-title,
.item-details-modal .deity-spell-rank,
.item-details-modal .deity-spell-name {
    font-size: calc(var(--font-size-13) + var(--item-details-fs-extra));
}

.item-details-modal .deity-chip {
    font-size: var(--sheet-tag-font-size) !important;
    padding: var(--sheet-tag-padding);
    font-family: var(--sans-serif) !important;
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
}

.item-details-modal .item-detail-activation .action-glyph,
.item-details-modal .item-description-content .action-glyph {
    font-size: calc(var(--font-size-11) + var(--item-details-fs-extra));
}

.item-details-modal .item-description-content .action-icon {
    font-size: calc(12px + var(--item-details-fs-extra));
}

.item-details-modal .item-detail-rules strong {
    font-size: calc(var(--font-size-14) + var(--item-details-fs-extra));
}

.item-details-modal .item-description-content strong,
.item-details-modal .item-description-content p strong,
.item-details-modal .item-description-content span strong {
    font-size: calc(var(--font-size-13) - 1px + var(--item-details-fs-extra)) !important;
}

.item-details-modal .deity-modal-tab {
    font-size: calc(var(--font-size-12) + var(--item-details-fs-extra));
}

/* Механика родословной: подписи золотые, значения как текст «Описание» */
.item-details-modal .item-detail-ancestry-mechanics p strong {
    font-size: calc(var(--font-size-13) + var(--item-details-fs-extra));
    color: var(--gold);
}

.item-details-modal .item-detail-ancestry-mechanics .item-detail-mechanics-value {
    font-size: calc(var(--font-size-13) + var(--item-details-fs-extra) - 1px);
    color: var(--ink-soft);
}

/* Класс: ключевой атрибут и ОЗ — +1px к остальному тексту модалки */
.item-details-modal .item-detail-class-info-header,
.item-details-modal .item-detail-class-info-header strong {
    font-size: calc(var(--font-size-13) + var(--item-details-fs-extra) + 1px);
}

.item-details-modal .item-detail-class-info-text {
    font-size: calc(var(--font-size-13) + var(--item-details-fs-extra) + 2px);
    color: var(--ink-soft);
}

/* Основной текст «Описание» в модалках — на 1px меньше прочего текста окна */
.item-details-modal .item-description-content,
.item-details-modal .deity-lore-body {
    font-size: calc(var(--font-size-13) + var(--item-details-fs-extra) - 1px);
    color: var(--ink-soft);
}

/* Текст в блоках «Описание» модалок — без курсива, цвет как у пояснений */
.item-details-modal .item-description-content,
.item-details-modal .item-description-content p,
.item-details-modal .item-description-content em,
.item-details-modal .item-description-content i,
.item-details-modal .item-description-content li,
.item-details-modal .deity-lore-body,
.item-details-modal .deity-lore-body p,
.item-details-modal .deity-lore-body em,
.item-details-modal .deity-lore-body i,
.item-details-modal .deity-lore-body li {
    font-style: normal;
    color: var(--ink-soft);
}

/* Божество, вкладка «Описание»: подпись золотая, значение после двоеточия — как основной текст */
.item-details-modal .deity-lore-body .deity-lore-value,
.item-details-modal .deity-lore-body .deity-lore-value .ability-link,
.item-details-modal .deity-lore-body .deity-lore-value .trait-link,
.item-details-modal .deity-lore-body .deity-lore-value .action-link,
.item-details-modal .deity-lore-body .deity-lore-value a {
    color: var(--ink-soft) !important;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    font-size: inherit !important;
}

.item-details-modal .deity-lore-body .deity-lore-value .ability-link,
.item-details-modal .deity-lore-body .deity-lore-value .trait-link,
.item-details-modal .deity-lore-body .deity-lore-value .action-link,
.item-details-modal .deity-lore-body .deity-lore-value a {
    text-decoration: underline;
    text-decoration-color: hsl(var(--highlight-hsl) / 0.45);
    text-underline-offset: 0.125em;
}

.item-details-modal .deity-lore-body .deity-lore-value .ability-link:hover,
.item-details-modal .deity-lore-body .deity-lore-value .trait-link:hover,
.item-details-modal .deity-lore-body .deity-lore-value .action-link:hover,
.item-details-modal .deity-lore-body .deity-lore-value a:hover {
    color: var(--ink) !important;
    text-decoration-color: var(--ink-soft);
}

/* Божество: абзац — серый текст, только подпись в strong — золотая */
.item-details-modal .deity-lore-body.item-description-content p.deity-lore-field,
.item-details-modal .deity-lore-body.item-description-content p {
    color: var(--ink-soft) !important;
}

.item-details-modal .deity-lore-body.item-description-content p.deity-lore-field > strong,
.item-details-modal .deity-lore-body.item-description-content p > strong:first-child {
    color: var(--gold) !important;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
}

.item-details-modal .deity-lore-stats {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.item-details-modal .deity-lore-field-heading {
    margin-bottom: 4px;
}

/* Crafting Styles — Foundry VTT (ремесло, алхимия) */
.crafting-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Колдовство — та же ширина, что Инвентарь / Мастерство */
.spellcasting-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-4);
    box-sizing: border-box;
}

/* Блок «Продвинутая алхимия» — как в Foundry: шапка + слоты */
.crafting-advanced-alchemy {
    margin-bottom: var(--space-4);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Тёмно-красная шапка: название слева, уровень справа */
.crafting-alchemy-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--ink);
}

.crafting-alchemy-title {
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
}

.crafting-alchemy-level {
    font-size: var(--font-size-14);
    font-weight: 600;
    color: var(--ink);
}

.crafting-alchemy-content {
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.crafting-slots {
    font-size: var(--font-size-14);
    color: var(--ink);
}

.crafting-formulas-section {
    margin-top: var(--space-4);
}

.crafting-formulas-title {
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 var(--space-3);
    letter-spacing: 0.02em;
}

/* Таблица «Известные формулы» — Foundry */
.crafting-formulas {
    min-height: 300px;
    max-height: 60vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.crafting-level-group {
    margin-bottom: 0;
}

/* Шапка уровня — тёмная полоса */
.crafting-level-header {
    font-family: var(--font-primary);
    font-size: var(--font-size-12);
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 14px;
    margin: 0;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.crafting-level-group:first-child .crafting-level-header {
    border-radius: 6px 6px 0 0;
}

/* Строки таблицы: иконка | название | КС | Стоимость | Количество — единая высота */
.crafting-formula-row {
    display: grid;
    grid-template-columns: 40px 1fr 52px 80px 110px;
    align-items: center;
    gap: 0 12px;
    padding: 0 14px;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    font-size: var(--font-size-14);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
}

.crafting-formula-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.crafting-level-group .crafting-formula-row:last-of-type {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Заголовки колонок КС, Стоимость, Количество — без uppercase */
.crafting-formula-thead {
    display: grid;
    grid-template-columns: 40px 1fr 52px 80px 110px;
    align-items: center;
    gap: 0 12px;
    padding: 0 14px;
    height: 40px;
    min-height: 40px;
    font-size: var(--font-size-11);
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.02em;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.crafting-formula-thead span:nth-child(1),
.crafting-formula-thead span:nth-child(2) {
    text-align: left;
}

.crafting-formula-thead span:nth-child(3),
.crafting-formula-thead span:nth-child(4),
.crafting-formula-thead span:nth-child(5) {
    text-align: right;
}

.crafting-formula-icon-wrap {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crafting-formula-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
}

/* Пустой квадрат при отсутствующей иконке — как в Инвентаре */
.crafting-formula-icon-placeholder {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.crafting-formula-name {
    color: var(--ink);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crafting-formula-kc,
.crafting-formula-cost {
    color: var(--ink);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.crafting-formula-qty {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

/* Кнопки ± — металлик/серые как в Foundry */
.crafting-formula-qty button {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(0,0,0,0.3) 100%);
    color: var(--ink);
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crafting-formula-qty button:hover {
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(0,0,0,0.4) 100%);
    border-color: rgba(255, 255, 255, 0.18);
}

.crafting-formula-qty .crafting-qty-num {
    width: 36px;
    min-width: 36px;
    padding: 2px 4px;
    text-align: center;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    font-size: var(--font-size-14);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}

.crafting-formula-qty .crafting-qty-num::-webkit-inner-spin-button,
.crafting-formula-qty .crafting-qty-num::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.crafting-formula-qty .crafting-qty-num[type="number"] {
    -moz-appearance: textfield;
}

#panel-crafting.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#panel-spellcasting.active {
    display: block;
}

.crafting-panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    justify-content: flex-start;
    align-items: stretch;
    padding-top: var(--space-6);
    overflow-y: auto;
}

.spellcasting-panel-content {
    width: 100%;
    box-sizing: border-box;
}

.spellcasting-entries-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    width: 100%;
}

.spellcasting-entry-block {
    width: 100%;
    box-sizing: border-box;
}

.spellcasting-entry-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding: 10px 14px;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: var(--font-size-13);
    color: var(--ink);
}

.spellcasting-stat-dc {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    font-weight: 600;
}

.spellcasting-stat-dc .skill-value-wrap {
    min-width: 0;
}

.spellcasting-stat-attack {
    display: inline-flex;
    align-items: center;
}

.spellcasting-stat-attack .skill-value {
    color: var(--ink-soft);
    font-weight: 500;
}

#panel-spellcasting .spellcasting-entry-stats .skill-value-wrap {
    cursor: help;
}

#panel-spellcasting .spellcasting-entry-stats .skill-tooltip {
    font-size: var(--font-size-12);
}

.spellcasting-stat-tradition {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spellcasting-rank-section {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    --spell-row-grid-cols: minmax(160px, 2fr) minmax(88px, auto) minmax(100px, 1fr) minmax(120px, 1fr);
}

.spellcasting-prep-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid rgba(90, 120, 180, 0.55);
    border-radius: 4px;
    background: linear-gradient(180deg, rgba(35, 55, 95, 0.95) 0%, rgba(22, 38, 68, 0.98) 100%);
    color: #e8eef8;
    font-family: var(--font-primary);
    font-size: var(--font-size-12);
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.spellcasting-prep-btn:hover {
    background: linear-gradient(180deg, rgba(48, 72, 118, 0.98) 0%, rgba(30, 50, 88, 1) 100%);
    border-color: rgba(120, 150, 210, 0.7);
}

.spellcasting-prep-btn::before {
    content: '📖';
    font-size: 12px;
    line-height: 1;
}

.spell-preparation-modal .attributes-details-modal-content {
    max-width: 1100px;
}

.spell-preparation-modal-body {
    min-height: 0;
    font-family: var(--font-primary);
    color: var(--ink);
    line-height: 1.45;
}

.spell-preparation-modal .attributes-details-modal-header h3 {
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--ink);
}

/* Боковая панель фильтров (навигатор библиотеки) */
.spell-prep-sidebar {
    flex: 0 0 220px;
    width: 220px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 12px 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.spell-prep-filter-search-wrap {
    display: block;
    margin-bottom: 10px;
}

.spell-prep-filter-search {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
    color: var(--ink);
    font-family: var(--font-primary);
    font-size: var(--font-size-13);
}

.spell-prep-filters-clear-all {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--ink-soft);
    font-family: var(--font-primary);
    font-size: var(--font-size-12);
    cursor: pointer;
    text-align: center;
}

.spell-prep-filters-clear-all:hover {
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.35);
}

.spell-prep-filter-group {
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.spell-prep-filter-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    list-style: none;
    font-size: var(--inventory-row-font-size, var(--font-size-13));
    font-family: var(--font-primary);
    font-weight: 500;
    color: var(--ink);
}

.spell-prep-filter-summary::-webkit-details-marker {
    display: none;
}

.spell-prep-filter-summary::before {
    content: '▾';
    margin-right: 6px;
    font-size: 10px;
    color: var(--ink-soft);
    transition: transform 0.15s ease;
}

.spell-prep-filter-group:not([open]) .spell-prep-filter-summary::before {
    transform: rotate(-90deg);
}

.spell-prep-filter-title {
    flex: 1 1 auto;
    font-weight: 500;
}

.spell-prep-filter-clear {
    flex-shrink: 0;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: transparent;
    color: var(--ink-soft);
    font-family: var(--font-primary);
    font-size: 10px;
    cursor: pointer;
}

.spell-prep-filter-clear:hover {
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.35);
}

.spell-prep-filter-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 10px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.spell-prep-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-size-12);
    color: var(--ink);
    cursor: pointer;
    line-height: 1.35;
}

.spell-prep-filter-option input[type="checkbox"] {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #c87830;
}

.spell-prep-filter-ranks .spell-prep-filter-option {
    font-size: 11px;
}

.spell-prep-repertoire {
    border: none;
    border-radius: 0;
    background: transparent;
}

.spell-prep-empty {
    padding: 14px;
    margin: 0;
    color: var(--ink-soft);
    flex-shrink: 0;
}

/* Окно подготовки: та же сетка и типографика, что на вкладке «Колдовство» + колонки «Редкость» и «Ранг» */
.spell-preparation-modal .spell-prep-main {
    --spell-row-grid-cols: minmax(160px, 2fr) minmax(88px, auto) minmax(100px, 1fr) minmax(120px, 1fr) minmax(88px, auto) 40px;
}

.spell-preparation-modal .spell-prep-loading {
    flex-shrink: 0;
    text-align: center;
    color: var(--ink-soft);
}

.spell-preparation-modal .spell-prep-list-header {
    flex-shrink: 0;
    pointer-events: none;
}

.spell-preparation-modal .spell-prep-list-header .spellcasting-rank-title {
    text-transform: none;
    font-size: var(--font-size-12);
    font-weight: 700;
    color: var(--ink-soft);
}

.spell-preparation-modal .spell-prep-repertoire .spell-entry {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.spell-preparation-modal .spell-prep-repertoire .spell-row {
    grid-template-columns: var(--spell-row-grid-cols);
}

.spell-preparation-modal .spell-row-rarity-col {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.spell-preparation-modal .spell-row-rarity {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--sans-serif);
    font-size: var(--sheet-tag-font-size, var(--font-size-11));
    font-weight: var(--sheet-tag-font-weight, 600);
    letter-spacing: var(--sheet-tag-letter-spacing, 0.04em);
    line-height: var(--sheet-tag-line-height, 1.2);
    text-transform: uppercase;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spell-preparation-modal .spell-prep-rarity-common {
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--ink-soft);
    background: rgba(0, 0, 0, 0.2);
}

.spell-preparation-modal .spell-prep-rarity-uncommon {
    border: 1px solid rgba(200, 160, 60, 0.65);
    color: #e8c86a;
    background: rgba(80, 60, 20, 0.35);
}

.spell-preparation-modal .spell-prep-rarity-rare {
    border: 1px solid rgba(120, 180, 255, 0.6);
    color: #9ec8ff;
    background: rgba(30, 50, 90, 0.4);
}

.spell-preparation-modal .spell-prep-rarity-unique {
    border: 1px solid rgba(200, 120, 255, 0.65);
    color: #ddb8ff;
    background: rgba(60, 30, 80, 0.4);
}

.spell-preparation-modal .spell-row-rank {
    text-align: center;
    justify-self: stretch;
    font-size: var(--inventory-row-font-size);
    font-family: var(--font-primary);
    font-weight: 600;
    color: var(--ink-soft);
}

.spell-preparation-modal .spellcasting-rank-col-rarity {
    line-height: 1.2;
    max-width: 6.5rem;
}

.spell-preparation-modal .spellcasting-rank-col-rank {
    max-width: 3rem;
}

.spell-preparation-modal .spell-prep-repertoire-entry .spell-item-details {
    padding: 12px 16px 16px 14px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.spellcasting-rank-header {
    display: grid;
    grid-template-columns: var(--spell-row-grid-cols);
    align-items: center;
    gap: 8px 12px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.35);
    font-size: var(--font-size-12);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
}

.spellcasting-rank-title-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.spellcasting-rank-title {
    color: var(--ink);
    text-transform: none;
    font-size: var(--font-size-13);
    letter-spacing: 0;
    white-space: nowrap;
}

.spellcasting-rank-title-group .spellcasting-rank-badge {
    flex-shrink: 0;
}

.spellcasting-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
    font-size: 11px;
    font-weight: 700;
    color: var(--ink);
    cursor: help;
}

.spellcasting-rank-badge.skill-value-wrap {
    min-width: 22px;
    text-align: center;
}

.spellcasting-rank-badge .skill-value {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink);
    text-align: center;
}

#panel-spellcasting .spellcasting-rank-badge .skill-tooltip {
    font-size: var(--font-size-12);
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}

.spellcasting-rank-col {
    text-align: center;
    font-size: 10px;
    justify-self: stretch;
    width: 100%;
    box-sizing: border-box;
}

.spellcasting-rank-col-actions,
.spellcasting-rank-col-casting-time {
    line-height: 1.2;
    max-width: 7.5rem;
    justify-self: center;
}

.spellcasting-rank-col-defense,
.spellcasting-rank-col-range {
    justify-self: stretch;
}

.spellcasting-spell-list {
    background: transparent;
}

.spell-entry {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.spell-entry.expanded {
    background: rgba(255, 248, 235, 0.04);
}

.spell-row {
    display: grid;
    grid-template-columns: var(--spell-row-grid-cols);
    align-items: center;
    gap: 8px 12px;
    padding: 0 14px;
    min-height: 44px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.spell-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.spell-row.expanded {
    background: rgba(255, 255, 255, 0.03);
}

.spell-row-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-13);
    font-weight: 500;
    font-family: var(--font-primary);
    color: var(--ink);
}

.spell-row-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.spell-row-casting-time {
    text-align: center;
    font-size: var(--inventory-row-font-size, var(--font-size-13));
    font-weight: 500;
    font-family: var(--font-primary);
    line-height: 1.25;
    color: var(--ink);
    justify-self: center;
    max-width: 10rem;
}

.spell-action-glyphs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.spell-action-sep {
    color: var(--ink-soft);
    font-size: 11px;
    padding: 0 2px;
}

.spell-row-defense,
.spell-row-range {
    text-align: center;
    justify-self: stretch;
    width: 100%;
    box-sizing: border-box;
    font-size: var(--font-size-13);
    color: var(--ink-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Deity details modal (Foundry-style tabs) */
.deity-modal-content {
    max-width: 820px;
}

.deity-modal-header {
    gap: 12px;
}

.deity-modal-header-main {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.deity-modal-header-main h3 {
    margin: 0;
    min-width: 0;
}

.deity-modal-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
}

.deity-modal-icon-placeholder {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.deity-modal-tabs {
    display: flex;
    gap: 0;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.deity-modal-tab {
    border: 0;
    background: transparent;
    padding: 12px 20px;
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: var(--font-size-12);
    letter-spacing: 0.3px;
    color: var(--ink-soft);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.deity-modal-tab:hover {
    color: var(--gold);
}

.deity-modal-tab.active {
    color: var(--accent-text);
    border-bottom-color: var(--accent-text);
}

.deity-modal-body {
    padding: 0;
}

.deity-tab-panel {
    display: none;
    padding: 20px 24px 24px;
    max-height: min(70vh, 640px);
    overflow-y: auto;
    overflow-x: hidden;
}

.deity-tab-panel.active {
    display: block;
}

.deity-empty-tab {
    margin: 0;
    text-align: center;
    color: var(--ink-soft);
    font-style: italic;
    padding: 24px 0;
}

.deity-lore-banner,
.deity-lore-body {
    text-transform: none;
}

.deity-lore-banner.item-description-content strong,
.deity-lore-body.item-description-content strong,
.deity-lore-banner.item-description-content p strong,
.deity-lore-body.item-description-content p strong,
.deity-lore-banner.item-description-content span strong,
.deity-lore-body.item-description-content span strong {
    text-transform: none !important;
}

.deity-lore-banner:not(.bg3-frame-host) {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: rgba(30, 58, 95, 0.55);
    border: 1px solid rgba(100, 140, 200, 0.35);
    border-radius: 6px;
}

.item-details-modal .deity-lore-banner.bg3-frame-host p {
    color: var(--ink-soft);
}

.deity-lore-banner p {
    margin: 0;
    color: var(--gold);
    font-size: var(--font-size-13);
    line-height: 1.55;
    text-transform: none;
}

.deity-lore-body h2,
.deity-lore-body h3 {
    text-transform: none;
    font-family: var(--font-primary);
    font-size: var(--font-size-16);
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-accent);
    margin: 20px 0 10px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.deity-lore-body h2:first-child,
.deity-lore-body h3:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.deity-lore-body p,
.deity-lore-body li,
.deity-lore-body td,
.deity-lore-body th {
    text-transform: none;
}

.deity-details-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deity-detail-row {
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(140px, 38%) 1fr;
    gap: 10px 16px;
    align-items: start;
}

.deity-detail-label {
    margin: 0;
    font-weight: 700;
    color: var(--gold);
    font-size: var(--font-size-13);
    line-height: 1.5;
}

.deity-detail-value {
    margin: 0;
    color: var(--ink-soft);
    font-family: var(--font-primary);
    font-size: var(--font-size-13);
    font-weight: 400;
    font-style: normal;
    line-height: 1.5;
    text-transform: none;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.deity-detail-value strong,
.deity-detail-value em,
.deity-detail-value i {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-style: normal;
    color: inherit;
    text-transform: none;
}

.item-details-modal .deity-detail-value,
.item-details-modal .deity-detail-value strong,
.item-details-modal .deity-detail-value em,
.item-details-modal .deity-detail-value i {
    color: var(--ink-soft);
}

.deity-detail-section:not(.bg3-frame-host) {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.deity-section-title {
    margin: 0 0 10px;
    font-family: var(--font-primary);
    font-size: var(--font-size-13);
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.deity-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.deity-chip {
    display: inline-flex;
    align-items: center;
    padding: var(--sheet-tag-padding);
    border-radius: var(--sheet-tag-radius);
    border: 1px solid hsl(var(--highlight-hsl) / 0.35);
    background: hsl(var(--accent-hsl) / 0.15);
    color: #fff;
    font-family: var(--sans-serif);
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    text-transform: uppercase;
}

.deity-weapon-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 8px;
}

.deity-weapon-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.deity-weapon-chip-label {
    line-height: 1.35;
}

.deity-weapon-chips {
    margin-top: 0;
}

.deity-spells-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.deity-spell-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.2);
}

.deity-spell-rank {
    flex-shrink: 0;
    min-width: 64px;
    font-size: var(--font-size-11);
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
}

.deity-spell-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 3px;
    flex-shrink: 0;
}

.deity-spell-icon-placeholder {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
}

.deity-spell-name {
    color: #fff;
    font-family: var(--font-primary);
    font-size: var(--font-size-13);
    font-weight: 400;
    line-height: 1.4;
    overflow-wrap: break-word;
}

@media (max-width: 560px) {
    .deity-detail-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* Foundry-style Ability Details Modal */
.ability-details-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: var(--space-4);
}

.ability-details-modal-content {
    background: var(--bg-dark);
    border: 2px solid #c19976;
    border-radius: 4px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    font-family: var(--font-primary);
}

.ability-details-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--color-border);
}

.ability-details-modal-header-title {
    font-size: var(--font-size-12);
    color: var(--ink-soft);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--sans-serif);
}

.ability-details-modal-header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ability-details-modal-header-btn {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 4px;
    font-size: var(--font-size-16);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 2px;
    transition: all 0.2s;
}

.ability-details-modal-header-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--gold);
}

.ability-details-modal-main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: transparent;
    border-bottom: 1px solid var(--color-border);
}

.ability-details-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}

.ability-details-icon-placeholder {
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    flex-shrink: 0;
}

.ability-details-title-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ability-details-title {
    font-family: var(--font-primary);
    font-size: var(--font-size-20);
    font-weight: 700;
    color: var(--ink);
    margin: 0;
    line-height: 1.2;
}

.ability-details-level {
    font-size: var(--font-size-12);
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ability-details-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ability-details-rarity {
    padding: 4px 10px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.18);
    font-size: var(--font-size-11);
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    font-family: var(--sans-serif);
    text-transform: uppercase;
    position: relative;
}

.ability-details-rarity:hover {
    background: rgba(0, 0, 0, 0.25);
    border-color: var(--accent-text);
}

.ability-details-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.ability-details-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--sheet-tag-padding);
    border: 1px solid rgba(94, 0, 0, 0.4);
    border-radius: var(--sheet-tag-radius);
    background: rgba(94, 0, 0, 0.2);
    font-size: var(--sheet-tag-font-size);
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
    color: var(--ink);
    font-family: var(--sans-serif);
    text-transform: uppercase;
}

.ability-details-tag-remove {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    cursor: pointer;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-12);
    line-height: 1;
    border-radius: 2px;
    transition: all 0.2s;
}

.ability-details-tag-remove:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--gold);
}

.ability-details-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    padding: 0 20px;
}

.ability-details-tab {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--ink-soft);
    font-size: var(--font-size-12);
    font-weight: 600;
    cursor: pointer;
    font-family: var(--sans-serif);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.ability-details-tab:hover {
    color: var(--gold);
    background: rgba(255, 255, 255, 0.05);
}

.ability-details-tab.active {
    color: var(--accent-text);
    border-bottom-color: var(--accent-text);
    background: transparent;
}

.ability-details-tab-content {
    display: none;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    background: var(--bg-dark);
    min-height: 200px;
}

.ability-details-tab-content::-webkit-scrollbar {
    width: 8px;
}

.ability-details-tab-content::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

.ability-details-tab-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.ability-details-tab-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.ability-details-tab-content.active {
    display: block;
}

.ability-details-summary {
    margin-bottom: 16px;
}

.ability-details-summary-label {
    font-size: var(--font-size-11);
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    font-family: var(--sans-serif);
}

.ability-details-category {
    margin-bottom: 16px;
}

.ability-details-category-label {
    font-size: var(--font-size-11);
    font-weight: 600;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    font-family: var(--sans-serif);
    display: block;
}

.ability-details-category-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.18);
    font-size: var(--font-size-13);
    color: var(--ink);
    font-family: var(--sans-serif);
    cursor: pointer;
}

.ability-details-category-select:hover {
    border-color: var(--accent-text);
}

.ability-details-category-select:focus {
    outline: none;
    border-color: var(--accent-text);
    box-shadow: 0 0 10px hsl(var(--accent-hsl) / 0.35);
}

.ability-details-description {
    margin-top: 16px;
}

.ability-details-description-content {
    font-size: var(--font-size-13);
    line-height: 1.6;
    color: var(--ink);
    font-family: var(--sans-serif);
}

.ability-details-description-content a {
    color: var(--accent-text);
    text-decoration: underline;
    cursor: pointer;
    font-style: italic;
}

.ability-details-description-content a:hover {
    color: var(--gold);
    text-decoration: underline;
}

.ability-details-description-content .action-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    text-decoration: none;
    font-style: normal;
    color: var(--ink);
}

.ability-details-description-content .action-link:hover {
    background: rgba(0, 0, 0, 0.25);
    border-color: var(--accent-text);
}

.ability-details-description-content strong {
    color: var(--gold);
    font-weight: 600;
}

.ability-details-close {
    background: transparent;
    border: none;
    font-size: var(--font-size-20);
    color: var(--ink-soft);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 2px;
    transition: all 0.2s;
}

.ability-details-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--gold);
}

/* Responsive adjustments for ability details modal */
@media (max-width: 768px) {
    .ability-details-modal-content {
        max-width: 95%;
        max-height: 95vh;
    }
    
    .ability-details-modal-main-header {
        flex-wrap: wrap;
    }
    
    .ability-details-header-controls {
        width: 100%;
        margin-top: 8px;
    }
    
    .ability-details-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .ability-details-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Actions tab */
.actions-content {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: var(--space-4);
    overflow-x: hidden;
    min-width: 0;
}

.actions-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--space-3);
}

.action-tab {
    flex: 1 1 auto;
    min-width: min(120px, 100%);
    padding: 11px 15px;
    background: transparent;
    border: 0;
    border-radius: 10px;
    color: var(--ink-soft);
    font-family: var(--font-primary);
    font-size: var(--font-size-12);
    font-weight: 800;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.action-tab:hover {
    background: hsl(var(--accent-hsl) / 0.10);
    color: var(--gold);
}

.action-tab.active {
    background: hsl(var(--accent-hsl) / 0.14);
    color: var(--gold);
    box-shadow: inset 0 -3px 0 var(--accent);
}

.actions-panel-inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
}

.actions-empty {
    margin: 0;
    padding: 20px;
    text-align: left;
    font-family: var(--font-primary);
    font-size: var(--font-size-14);
    font-weight: 400;
    font-style: italic;
    letter-spacing: normal;
    color: var(--ink-soft);
    line-height: 1.45;
}

.actions-section {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 0;
}

.actions-section.bg3-frame-host {
    border: none;
    border-radius: 0;
    overflow: hidden;
}

.actions-section-header {
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.actions-section-header h3 {
    margin: 0;
    font-family: var(--font-primary);
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--ink);
}

.actions-toggles-inner {
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.actions-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: var(--font-size-13);
    color: var(--ink);
    min-width: 0;
}

/* Подписи опций без чекбокса — обычный текст, не кликабельный */
.actions-toggle-row.actions-toggle-row-text {
    cursor: default;
    color: var(--ink-soft);
}

.actions-toggle-row.actions-toggle-row-text .actions-toggle-label {
    cursor: default;
    font-weight: 400;
}

.actions-toggle-label {
    overflow-wrap: break-word;
    word-wrap: break-word;
    min-width: 0;
}

.actions-toggle-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--gold);
}

.actions-toggle-finisher {
    flex-wrap: wrap;
}

.actions-finisher-select {
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.35);
    color: var(--ink);
    font-size: var(--font-size-12);
    max-width: 100%;
}

.actions-ev-status {
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: var(--font-size-12);
}

.actions-ev-title {
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}

.actions-ev-value {
    color: var(--ink-soft);
}

.actions-list {
    background: rgba(0, 0, 0, 0.2);
    min-width: 0;
}

.actions-list-empty {
    min-height: 4px;
}

.actions-item-entry {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-width: 0;
}

.actions-item-entry:last-child {
    border-bottom: none;
}

.actions-item-entry.expanded {
    background: rgba(255, 248, 235, 0.04);
}

.actions-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    min-width: 0;
    flex-wrap: wrap;
}

.actions-item-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.actions-item-row .action-glyph {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid var(--gold);
    transform: rotate(45deg);
    font-size: 11px;
    font-weight: 700;
    color: var(--gold);
}

.actions-item-row .action-glyph.reaction,
.actions-item-row .action-glyph.free {
    transform: none;
    border-radius: 3px;
    font-size: 10px;
}

.actions-item-name {
    flex: 1;
    min-width: 0;
    font-size: var(--font-size-14);
    color: var(--accent-text);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.actions-item-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.actions-frequency {
    font-size: var(--font-size-11);
    color: var(--ink-soft);
    white-space: nowrap;
}

.actions-use-btn {
    padding: 2px 8px;
    font-size: var(--font-size-11);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--ink-soft);
    cursor: default;
}

.actions-item-details {
    padding: 12px 16px 16px 48px;
    background: linear-gradient(180deg, rgba(245, 235, 210, 0.12) 0%, rgba(245, 235, 210, 0.06) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: var(--font-size-14);
    color: var(--ink);
    line-height: 1.45;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.actions-attack-entry {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-width: 0;
}

.actions-attack-entry:last-child {
    border-bottom: none;
}

.actions-attack-name {
    font-size: var(--font-size-14);
    font-weight: 400;
    color: var(--accent-text);
    margin-bottom: 8px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.actions-attack-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.actions-roll-btn,
.actions-damage-btn,
.actions-utility-btn {
    padding: 5px 10px;
    font-size: var(--font-size-11);
    font-weight: 400;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: default;
    font-family: var(--sans-serif);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.actions-roll-btn {
    background: rgba(139, 0, 0, 0.45);
    color: var(--ink);
}

.actions-roll-btn.actions-map-btn {
    background: rgba(0, 0, 0, 0.35);
    color: var(--ink);
}

/* Кнопки «Удар» / «ШМА» — как названия в блоке «Действия», текст по центру */
.actions-roll-btn:not(.actions-utility-btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: var(--font-primary);
    text-transform: none;
    letter-spacing: normal;
}

/* Текст кнопок удара/ШМА (подписи и бонусы) — на 2px меньше, белый */
.actions-roll-btn:not(.actions-utility-btn) .actions-btn-word {
    font-size: calc(1em - 2px);
    font-family: inherit;
    color: #fff;
    line-height: 1.2;
}

.foundry-app .actions-roll-btn:not(.actions-utility-btn) .actions-btn-word {
    color: #fff;
}

.actions-damage-btn {
    background: hsl(var(--accent-hsl) / 0.35);
    color: var(--ink);
    font-weight: 700;
}

.actions-damage-btn.actions-crit-btn {
    background: rgba(180, 120, 0, 0.45);
}

.actions-utility-btn {
    background: rgba(0, 0, 0, 0.3);
    color: var(--ink-soft);
    font-weight: 600;
}

.actions-attack-utility {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

/* Вкладка «Действия»: все тексты блоков +4px (два шага по +2px) */
#panel-actions,
#panel-crafting,
#panel-spellcasting {
    --actions-fs-extra: 4px;
}

#panel-actions {
    --actions-row-font-size: calc(var(--font-size-14) + var(--actions-fs-extra));
}

#panel-actions .action-tab {
    font-size: calc(var(--font-size-12) + var(--actions-fs-extra));
}

#panel-actions .actions-empty,
#panel-crafting .actions-empty,
#panel-spellcasting .actions-empty {
    font-size: calc(1em + var(--actions-fs-extra));
}

#panel-actions .actions-section-header h3 {
    font-size: calc(1.15rem + var(--actions-fs-extra));
}

#panel-actions .actions-toggle-row {
    font-size: calc(var(--font-size-13) + var(--actions-fs-extra));
}

#panel-actions .actions-finisher-select {
    font-size: calc(var(--font-size-12) + var(--actions-fs-extra));
}

#panel-actions .actions-ev-status {
    font-size: calc(var(--font-size-12) + var(--actions-fs-extra));
}

#panel-actions .actions-item-row .action-glyph {
    font-size: calc(11px + var(--actions-fs-extra));
}

#panel-actions .actions-item-row .action-glyph.reaction,
#panel-actions .actions-item-row .action-glyph.free {
    font-size: calc(10px + var(--actions-fs-extra));
}

#panel-actions .actions-item-name {
    font-size: var(--actions-row-font-size);
}

#panel-actions .actions-frequency,
#panel-actions .actions-use-btn {
    font-size: calc(var(--font-size-11) + var(--actions-fs-extra));
}

#panel-actions .actions-item-details {
    font-size: var(--actions-row-font-size);
    font-family: var(--font-primary);
    line-height: 1.45;
}

/* Развёрнутое описание — тот же кегль и гарнитура, что у .actions-item-name */
#panel-actions .actions-item-details .inventory-item-details-inner,
#panel-actions .actions-item-details .inventory-detail-meta,
#panel-actions .actions-item-details .inventory-detail-description,
#panel-actions .actions-item-details .inventory-detail-mechanics,
#panel-actions .actions-item-details .item-description-content,
#panel-actions .actions-item-details .item-description-content p,
#panel-actions .actions-item-details .item-description-content li,
#panel-actions .actions-item-details .item-description-content em,
#panel-actions .actions-item-details .item-description-content a {
    font-size: var(--actions-row-font-size) !important;
    font-family: var(--font-primary);
    line-height: 1.45;
}

.foundry-app #panel-actions .actions-item-details p,
.foundry-app #panel-actions .actions-item-details .item-description-content,
.foundry-app #panel-actions .actions-item-details .item-description-content p {
    font-family: var(--font-primary);
}

#panel-actions .actions-item-details .item-description-content strong,
#panel-actions .actions-item-details .item-description-content p strong,
#panel-actions .actions-item-details .item-description-content span strong {
    font-size: var(--actions-row-font-size) !important;
}

#panel-actions .actions-item-details .action-glyph {
    font-size: calc(11px + var(--actions-fs-extra)) !important;
    line-height: 1.2;
}

/* Черты в развёрнутых блоках — стандартный кегль тега, не наследуют крупный текст строки */
#panel-actions .actions-item-details .inventory-detail-trait,
#panel-inventory .inventory-item-details .inventory-detail-trait,
#panel-spellcasting .inventory-item-details .inventory-detail-trait,
.spell-preparation-modal .inventory-item-details .inventory-detail-trait,
.item-details-modal .inventory-detail-trait,
.item-details-modal .ability-tag {
    font-size: var(--sheet-tag-font-size) !important;
    padding: var(--sheet-tag-padding);
    font-family: var(--sans-serif) !important;
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
}

/* Вкладки «Инвентарь», «Колдовство» и окно подготовки: единый кегль строк */
#panel-inventory,
#panel-spellcasting,
.spell-preparation-modal {
    --inventory-fs-extra: 4px;
    --inventory-row-font-size: calc(var(--font-size-13) + var(--inventory-fs-extra));
}

#panel-inventory .inventory-item-name,
#panel-inventory .inventory-item-name .item-name-clickable,
#panel-spellcasting .spell-row-name,
#panel-spellcasting .spell-row-casting-time,
#panel-spellcasting .spell-row-defense,
#panel-spellcasting .spell-row-range,
#panel-spellcasting .spellcasting-entry-stats,
#panel-spellcasting .spellcasting-stat-dc,
#panel-spellcasting .spellcasting-stat-attack,
#panel-spellcasting .spellcasting-stat-tradition,
#panel-spellcasting .spellcasting-rank-title,
.spell-preparation-modal .spell-prep-repertoire .spell-row-name,
.spell-preparation-modal .spell-prep-repertoire .spell-row-casting-time,
.spell-preparation-modal .spell-prep-repertoire .spell-row-defense,
.spell-preparation-modal .spell-prep-repertoire .spell-row-range,
.spell-preparation-modal .spell-prep-repertoire .spell-row-rank,
.spell-preparation-modal .spellcasting-rank-title,
.spell-preparation-modal .spell-prep-filter-search,
.spell-preparation-modal .spell-prep-filter-summary,
.spell-preparation-modal .spell-prep-filter-title,
.spell-preparation-modal .spell-prep-filter-option,
.spell-preparation-modal .spell-prep-filters-clear-all,
.spell-preparation-modal .spell-prep-empty {
    font-size: var(--inventory-row-font-size);
    font-family: var(--font-primary);
}

#panel-spellcasting .spell-row-name,
#panel-spellcasting .spell-row-casting-time,
.spell-preparation-modal .spell-prep-repertoire .spell-row-name,
.spell-preparation-modal .spell-prep-repertoire .spell-row-casting-time {
    font-weight: 500;
}

.spell-preparation-modal .spell-prep-filter-summary,
.spell-preparation-modal .spell-prep-filter-title {
    font-weight: 500;
}

#panel-spellcasting .spellcasting-rank-header,
.spell-preparation-modal .spellcasting-rank-header {
    font-size: var(--font-size-12);
    font-family: var(--font-primary);
}

#panel-spellcasting .spellcasting-rank-col,
.spell-preparation-modal .spellcasting-rank-col {
    font-size: 10px;
    font-family: var(--font-primary);
}

#panel-spellcasting .spell-row-actions .action-glyph,
.spell-preparation-modal .spell-row-actions .action-glyph {
    font-size: calc(11px + var(--inventory-fs-extra)) !important;
    line-height: 1.2;
}

#panel-inventory .inventory-item-details,
#panel-spellcasting .inventory-item-details,
.spell-preparation-modal .inventory-item-details {
    font-size: var(--inventory-row-font-size);
    font-family: var(--font-primary);
    line-height: 1.45;
}

#panel-inventory .inventory-item-details .inventory-item-details-inner,
#panel-inventory .inventory-item-details .inventory-detail-meta,
#panel-inventory .inventory-item-details .inventory-detail-description,
#panel-inventory .inventory-item-details .inventory-detail-mechanics,
#panel-inventory .inventory-item-details .inventory-detail-mechanic,
#panel-inventory .inventory-item-details .inventory-detail-weapon-subhead,
#panel-inventory .inventory-item-details .inventory-detail-activation-title,
#panel-inventory .inventory-item-details .item-detail-row,
#panel-inventory .inventory-item-details .item-description-content,
#panel-inventory .inventory-item-details .item-description-content p,
#panel-inventory .inventory-item-details .item-description-content li,
#panel-inventory .inventory-item-details .item-description-content em,
#panel-inventory .inventory-item-details .item-description-content a,
#panel-spellcasting .inventory-item-details .inventory-item-details-inner,
#panel-spellcasting .inventory-item-details .inventory-detail-meta,
#panel-spellcasting .inventory-item-details .inventory-detail-description,
#panel-spellcasting .inventory-item-details .inventory-detail-mechanics,
#panel-spellcasting .inventory-item-details .inventory-detail-mechanic,
#panel-spellcasting .inventory-item-details .inventory-detail-weapon-subhead,
#panel-spellcasting .inventory-item-details .inventory-detail-activation-title,
#panel-spellcasting .inventory-item-details .item-detail-row,
#panel-spellcasting .inventory-item-details .item-description-content,
#panel-spellcasting .inventory-item-details .item-description-content p,
#panel-spellcasting .inventory-item-details .item-description-content li,
#panel-spellcasting .inventory-item-details .item-description-content em,
#panel-spellcasting .inventory-item-details .item-description-content a,
.spell-preparation-modal .inventory-item-details .inventory-item-details-inner,
.spell-preparation-modal .inventory-item-details .inventory-detail-meta,
.spell-preparation-modal .inventory-item-details .inventory-detail-description,
.spell-preparation-modal .inventory-item-details .inventory-detail-mechanics,
.spell-preparation-modal .inventory-item-details .inventory-detail-mechanic,
.spell-preparation-modal .inventory-item-details .inventory-detail-activation-title,
.spell-preparation-modal .inventory-item-details .item-detail-row,
.spell-preparation-modal .inventory-item-details .item-description-content,
.spell-preparation-modal .inventory-item-details .item-description-content p,
.spell-preparation-modal .inventory-item-details .item-description-content li,
.spell-preparation-modal .inventory-item-details .item-description-content em,
.spell-preparation-modal .inventory-item-details .item-description-content a {
    font-size: var(--inventory-row-font-size) !important;
    font-family: var(--font-primary);
    line-height: 1.45;
}

.foundry-app #panel-inventory .inventory-item-details p,
.foundry-app #panel-inventory .inventory-item-details .item-description-content,
.foundry-app #panel-inventory .inventory-item-details .item-description-content p,
.foundry-app #panel-spellcasting .inventory-item-details p,
.foundry-app #panel-spellcasting .inventory-item-details .item-description-content,
.foundry-app #panel-spellcasting .inventory-item-details .item-description-content p,
.foundry-app .spell-preparation-modal .inventory-item-details p,
.foundry-app .spell-preparation-modal .inventory-item-details .item-description-content,
.foundry-app .spell-preparation-modal .inventory-item-details .item-description-content p {
    font-family: var(--font-primary);
}

#panel-inventory .inventory-item-details .item-description-content strong,
#panel-inventory .inventory-item-details .item-description-content p strong,
#panel-inventory .inventory-item-details .item-description-content span strong,
#panel-inventory .inventory-item-details .inventory-detail-mechanic strong,
#panel-inventory .inventory-item-details .item-detail-row strong,
#panel-spellcasting .inventory-item-details .item-description-content strong,
#panel-spellcasting .inventory-item-details .item-description-content p strong,
#panel-spellcasting .inventory-item-details .item-description-content span strong,
#panel-spellcasting .inventory-item-details .inventory-detail-mechanic strong,
#panel-spellcasting .inventory-item-details .item-detail-row strong,
.spell-preparation-modal .inventory-item-details .item-description-content strong,
.spell-preparation-modal .inventory-item-details .item-description-content p strong,
.spell-preparation-modal .inventory-item-details .inventory-detail-mechanic strong {
    font-size: var(--inventory-row-font-size) !important;
}

.spell-preparation-modal .spell-entry .inventory-item-details {
    padding: 12px 16px 16px 14px;
}

#panel-inventory .inventory-item-details .action-glyph,
#panel-spellcasting .inventory-item-details .action-glyph {
    font-size: calc(11px + var(--inventory-fs-extra)) !important;
    line-height: 1.2;
}

/* Вкладка «Способности»: кегль и гарнитура как на «Инвентарь» */
#panel-abilities {
    --abilities-fs-extra: 4px;
    --abilities-row-font-size: calc(var(--font-size-13) + var(--abilities-fs-extra));
}

#panel-abilities .ability-item {
    font-size: var(--font-size-14);
    min-height: 44px;
}

#panel-abilities .ability-name,
#panel-abilities .ability-name-english {
    font-size: var(--abilities-row-font-size);
    font-family: var(--font-primary);
    font-weight: 500;
    color: var(--ink);
    line-height: 1.45;
}

#panel-abilities .ability-level {
    font-size: calc(var(--font-size-12) + var(--abilities-fs-extra));
    font-family: var(--sans-serif);
}

#panel-abilities .ability-item-details {
    font-size: var(--abilities-row-font-size);
    font-family: var(--font-primary);
    line-height: 1.45;
}

#panel-abilities .ability-item-details .inventory-item-details-inner,
#panel-abilities .ability-item-details .inventory-detail-meta,
#panel-abilities .ability-item-details .inventory-detail-description,
#panel-abilities .ability-item-details .inventory-detail-mechanics,
#panel-abilities .ability-item-details .inventory-detail-mechanic,
#panel-abilities .ability-item-details .inventory-detail-weapon-subhead,
#panel-abilities .ability-item-details .inventory-detail-activation-title,
#panel-abilities .ability-item-details .item-detail-row,
#panel-abilities .ability-item-details .item-description-content,
#panel-abilities .ability-item-details .item-description-content p,
#panel-abilities .ability-item-details .item-description-content li,
#panel-abilities .ability-item-details .item-description-content em,
#panel-abilities .ability-item-details .item-description-content a {
    font-size: var(--abilities-row-font-size) !important;
    font-family: var(--font-primary);
    line-height: 1.45;
}

.foundry-app #panel-abilities .ability-item-details p,
.foundry-app #panel-abilities .ability-item-details .item-description-content,
.foundry-app #panel-abilities .ability-item-details .item-description-content p {
    font-family: var(--font-primary);
}

#panel-abilities .ability-item-details .item-description-content strong,
#panel-abilities .ability-item-details .item-description-content p strong,
#panel-abilities .ability-item-details .item-description-content span strong,
#panel-abilities .ability-item-details .inventory-detail-mechanic strong,
#panel-abilities .ability-item-details .item-detail-row strong {
    font-size: var(--abilities-row-font-size) !important;
}

#panel-abilities .ability-item-details .action-glyph {
    font-size: calc(11px + var(--abilities-fs-extra)) !important;
    line-height: 1.2;
}

#panel-abilities .ability-item-details .inventory-detail-trait,
#panel-abilities .ability-item-details .ability-tag {
    font-size: var(--sheet-tag-font-size) !important;
    padding: var(--sheet-tag-padding);
    font-family: var(--sans-serif) !important;
    font-weight: var(--sheet-tag-font-weight);
    letter-spacing: var(--sheet-tag-letter-spacing);
    line-height: var(--sheet-tag-line-height);
}

#panel-actions .actions-attack-name {
    font-size: calc(var(--font-size-14) + var(--actions-fs-extra));
}

#panel-actions .actions-roll-btn,
#panel-actions .actions-damage-btn,
#panel-actions .actions-utility-btn {
    font-size: calc(var(--font-size-11) + var(--actions-fs-extra));
}

/* --------------------------------------------------------------------------
   Сформированный лист (JSON в index): скрываем только импорт/экспорт и правку портрета.
   Кнопки «Мод.», ссылки-модификаторы (ОЗ/КБ/спасброски/восприятие) и «Детально» у атрибутов
   остаются — по ним открывается то же инфо-окно, что и локально (клик, не hover).
   Нельзя задавать html.sheet-static-export button { display:none } — ломается grid инвентаря.
   -------------------------------------------------------------------------- */
html.sheet-static-export .import-container,
html.sheet-static-export .avatar-change-button,
html.sheet-static-export .avatar-editor-modal {
    display: none !important;
}

html.sheet-static-export .condition-pips,
html.sheet-static-export .condition-pips .pips {
    pointer-events: none;
    cursor: default;
}

html.sheet-static-export .avatar-upload-label {
    pointer-events: none;
    cursor: default;
}

/* Читаемый текст во вкладках и модалках */
.foundry-app .foundry-panels,
.foundry-app .foundry-panel,
.foundry-app .character-content,
.foundry-app .actions-content,
.foundry-app .inventory-content,
.foundry-app .deity-lore-body,
.foundry-app .deity-tab-panel,
.foundry-app .modal-content,
.foundry-app .detail-modal-body {
    color: var(--ink);
    font-family: var(--font-primary);
    line-height: 1.45;
}

.foundry-app .section-title,
.foundry-app .actions-section-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 400;
    font-variant: normal;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    line-height: 1.3;
    color: var(--text-accent);
}

/* Кнопки, вкладки, бейджи, мелкие подписи — Inter */
.foundry-app button,
.foundry-app .foundry-tab,
.foundry-app .import-label,
.foundry-app .sheet-version-pill,
.foundry-app .avatar-change-button,
.foundry-app .language-tag,
.foundry-app .actions-utility-btn,
.foundry-app .actions-roll-btn,
.foundry-app .actions-damage-btn,
.foundry-app .detail-modal-close,
.foundry-app .ability-details-modal-close,
.sidebar button,
.sidebar header button {
    font-family: var(--font-ui);
}

.foundry-app .sidebar .sidebar_label,
.foundry-app .sidebar .hp-small label,
.foundry-app .sidebar .hp-small h4,
.foundry-app .armor-class .sidebar_label {
    font-family: var(--font-ui);
}

.foundry-app p,
.foundry-app li,
.foundry-app .item-description-content,
.foundry-app .detail-modal-body,
.foundry-app .deity-lore-body {
    font-family: var(--font-body);
    line-height: 1.4;
}

.foundry-app td,
.foundry-app th,
.foundry-app label {
    line-height: 1.45;
}

.foundry-app .data-value h2,
.foundry-app .armor-class-stat-value h2,
.foundry-app .armor-class-stat-value input,
.foundry-app .armor-class-stat-value .shield-max-value,
.foundry-app .roll-data .modifier,
.foundry-app .roll-data .modifier span,
.foundry-app .roll-data h3 {
    font-family: var(--font-primary);
    font-weight: 400;
}

.foundry-app .sidebar header h2 {
    font-family: var(--font-display);
    color: var(--text-accent);
}

.foundry-app .modal-content h2,
.foundry-app .modal-content h3,
.foundry-app .detail-modal-header h2,
.foundry-app .ability-details-modal-header h2 {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.foundry-app .import-label,
.foundry-app .sheet-version-pill,
.foundry-app .actions-utility-btn {
    font-family: var(--font-ui);
}

.foundry-app .actions-roll-btn:not(.actions-utility-btn),
.foundry-app .actions-roll-btn.actions-map-btn:not(.actions-utility-btn) {
    font-family: var(--font-primary);
    font-weight: 400;
}

.foundry-app .actions-damage-btn,
.foundry-app .foundry-tab.active {
    font-family: var(--font-ui-strong);
}
