/* Печатная форма листа (/print, /print/{id}). Подключается только на этой странице. */

@page { size: A4; margin: 8mm; }

body { margin: 0; background: #77736a; color: #1c1a17; }

.ps-root {
    --ink: #1c1a17; --blue: #5470ad; --blue-ink: #455f9a; --amber: #e6b422; --rule: #9a927f; --tint: #eef0f6;
    font: 400 8.6pt/1.25 "IBM Plex Sans", Arial, sans-serif;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

.ps-root *, .ps-root *::before { box-sizing: border-box; }

/* ---------- Панель над листом (на бумагу не попадает) ---------- */
.ps-toolbar {
    position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center;
    padding: .6rem 1rem; background: #fff; border-bottom: 3px solid var(--amber); font-size: 11pt;
}
.ps-toolbar button {
    padding: .35rem .9rem; border: 0; border-radius: 3px; background: var(--blue); color: #fff; font: inherit; cursor: pointer;
}
.ps-toolbar a { color: var(--blue-ink); }
.ps-toolbar .ps-warn { color: #8c3b1e; }

/* ---------- Лист бумаги ---------- */
.ps-page {
    width: 210mm; min-height: 297mm; margin: 6mm auto; padding: 8mm; background: #fff;
    box-shadow: 0 1px 8px rgba(0, 0, 0, .45);
}

@media print {
    body { background: #fff; }
    .ps-toolbar, #components-reconnect-modal, #blazor-error-ui { display: none !important; }
    .ps-page { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; break-after: page; }
    .ps-page:last-child { break-after: auto; }
}

@media screen and (max-width: 800px) {
    .ps-page { zoom: .45; }
}

/* ---------- Заголовки ---------- */
.ps-head { display: grid; grid-template-columns: 38mm 1fr 34mm; gap: 2mm; margin-bottom: 2mm; }
.ps-brand {
    display: flex; flex-direction: column; justify-content: center; padding: 1.5mm 2.5mm;
    background: var(--blue); border-bottom: 1.2mm solid var(--amber); color: #fff;
}
.ps-brand b { font: 700 14pt/1 "PT Sans Narrow", Arial, sans-serif; }
.ps-brand span { margin-top: 1mm; font-size: 7.5pt; }

.ps-page-title {
    display: flex; align-items: center; justify-content: space-between; gap: 4mm; margin-bottom: 3mm; padding: 1.5mm 2.5mm;
    background: var(--blue); border-bottom: 1.2mm solid var(--amber); color: #fff;
    font: 700 15pt/1 "PT Sans Narrow", Arial, sans-serif;
}
.ps-page-title small { font: 400 9pt "IBM Plex Sans", Arial, sans-serif; }

.ps-title {
    margin: 0 0 1mm; padding-bottom: .4mm; border-bottom: .5mm solid var(--blue); color: var(--blue-ink);
    font: 700 10.5pt/1.1 "PT Sans Narrow", Arial, sans-serif; text-transform: uppercase; letter-spacing: .03em;
}

.ps-box { padding: 1.3mm 1.8mm; border: .3mm solid var(--rule); break-inside: avoid; }

/* ---------- Поля ---------- */
.ps-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1mm 3mm; padding: 1.3mm 1.8mm; border: .3mm solid var(--rule); }
.ps-field { display: flex; align-items: baseline; gap: 1.2mm; min-width: 0; }
.ps-field > span:first-child { flex: none; color: #5d584d; font-size: 7.4pt; }
.ps-line { flex: 1; min-width: 6mm; min-height: 4.2mm; border-bottom: .2mm solid var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.ps-wide { grid-column: 1 / -1; }
.ps-name { grid-column: span 2; }
.ps-num { font-family: "IBM Plex Mono", Consolas, monospace; font-weight: 600; }

/* ---------- Первая страница ---------- */
.ps-main { display: grid; grid-template-columns: 52mm 1fr 58mm; gap: 2mm; margin-bottom: 2mm; }
.ps-col { display: flex; flex-direction: column; gap: 2mm; min-width: 0; }
.ps-grow { flex: 1; }

.ps-table { width: 100%; border-collapse: collapse; }
.ps-table th { color: #5d584d; font-size: 6.8pt; font-weight: 500; text-align: left; }
.ps-table td, .ps-table th { padding: .28mm .8mm; }
.ps-table .n { text-align: center; width: 10mm; }
.ps-table td.n { font-family: "IBM Plex Mono", Consolas, monospace; font-weight: 600; }
.ps-table tbody tr + tr td { border-top: .1mm solid #d5d0c3; }

.ps-special td { padding-top: .75mm; padding-bottom: .75mm; }
.ps-special .ps-abbr { display: inline-block; width: 8mm; font: 700 11pt "PT Sans Narrow", Arial, sans-serif; color: var(--blue-ink); }
.ps-special .ps-vit { display: block; color: #5d584d; font-size: 6.8pt; line-height: 1.1; }
.ps-special td.n { font-size: 11pt; }

.ps-skills tr.group th {
    padding-top: .9mm; color: var(--blue-ink); font: 700 8.6pt "PT Sans Narrow", Arial, sans-serif; text-transform: uppercase;
}
.ps-skills td { padding-top: .3mm; padding-bottom: .3mm; }
.ps-skills tr.tagged td { background: var(--tint); font-weight: 600; }
.ps-tag { display: inline-block; width: 2.5mm; height: 2.5mm; margin-right: 1mm; border: .2mm solid var(--ink); vertical-align: -.2mm; }
.ps-tag.on { background: var(--blue); }

.ps-vitals { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5mm; }
.ps-vital { padding: .8mm 1.5mm; border: .4mm solid var(--blue); }
.ps-vital b { display: block; color: var(--blue-ink); font: 700 9pt/1.1 "PT Sans Narrow", Arial, sans-serif; }
.ps-of { display: flex; align-items: baseline; gap: 1mm; font-size: 12pt; }
.ps-of i { flex: 1; min-height: 6mm; border-bottom: .2mm solid var(--ink); }

.ps-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .7mm 2.5mm; }
.ps-stat { display: flex; align-items: baseline; gap: 1mm; }
.ps-stat > span:first-child { flex: none; width: 8mm; font-weight: 600; }
.ps-stat .ps-line { text-align: center; }

.ps-reaper { display: flex; justify-content: space-between; align-items: center; margin: .4mm 0; }
.ps-circle { display: inline-block; width: 3.6mm; height: 3.6mm; margin-left: 1mm; border: .3mm solid var(--ink); border-radius: 50%; }

.ps-effects { display: grid; grid-template-columns: 1fr 9mm; gap: .35mm 1mm; align-items: baseline; }
.ps-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm; }

.ps-fatigue { display: grid; grid-template-columns: 3.4mm 1fr; gap: .25mm 1mm; align-items: center; font-size: 7.2pt; line-height: 1.12; }
.ps-box-mark { width: 2.8mm; height: 2.8mm; border: .2mm solid var(--ink); }

/* ---------- Таблицы с сеткой ---------- */
.ps-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ps-grid th, .ps-grid td { padding: .35mm .8mm; border: .2mm solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
.ps-grid th { background: var(--tint); font-size: 7pt; font-weight: 600; text-align: center; }
.ps-grid td.n { font-family: "IBM Plex Mono", Consolas, monospace; font-size: 8pt; font-weight: 600; text-align: center; }
.ps-grid td.label { background: var(--tint); font-weight: 600; font-size: 7.6pt; }
.ps-grid .ps-small { color: #3d3a33; font-size: 6.9pt; line-height: 1.15; }
.ps-grid tr.total td { border-top: .45mm solid var(--blue); font-weight: 700; }
.ps-attack-row td { height: 8mm; }
.ps-armor-row td { height: 6mm; }

/* ---------- Перки: карточки в две колонки ---------- */
.ps-columns { columns: 2; column-gap: 5mm; }
.ps-group { margin: 0 0 1mm; color: var(--blue-ink); font: 700 11pt "PT Sans Narrow", Arial, sans-serif; text-transform: uppercase; break-after: avoid; }
.ps-card { margin-bottom: 2mm; padding-bottom: 1.2mm; border-bottom: .2mm solid var(--rule); break-inside: avoid; }
.ps-card h3 { margin: 0; font-size: 9pt; font-weight: 600; }
.ps-card .ps-meta { color: #5d584d; font-size: 7.3pt; }
.ps-card p { margin: .5mm 0 0; font-size: 7.6pt; line-height: 1.22; white-space: pre-line; }
.ps-card .ps-off { color: #8c3b1e; }
.ps-charges { display: flex; gap: 1.5mm; margin-top: .7mm; font-size: 7.3pt; }
.ps-charges .ps-line { flex: 0 0 22mm; min-height: 3.6mm; }

.ps-blank-card { margin-bottom: 4mm; break-inside: avoid; }
.ps-blank-card .ps-fields { grid-template-columns: 1.6fr 1fr; border: 0; padding: 0; }
.ps-rule { height: 5.4mm; border-bottom: .2mm solid var(--ink); }

/* ---------- Инвентарь ---------- */
.ps-inv td { height: 7mm; }
.ps-inv thead { display: table-header-group; }
.ps-inv tr { break-inside: avoid; }

/* ---------- Личность ---------- */
.ps-persona { display: grid; grid-template-columns: 1fr 52mm; gap: 3mm; margin-bottom: 3mm; }
.ps-portrait { height: 52mm; display: flex; align-items: center; justify-content: center; border: .3mm solid var(--rule); color: #a5a092; }
.ps-portrait img { max-width: 100%; max-height: 100%; }
.ps-long { margin-bottom: 3mm; break-inside: avoid; }
.ps-long p { margin: 0 0 1mm; white-space: pre-line; font-size: 8.6pt; }
.ps-long ul { margin: 0 0 1mm; padding-left: 4mm; }

/* ---------- Карточки действий: 63×88 мм, как игральные карты; линии между ними — линии разреза ---------- */
.ps-option { display: flex; align-items: center; gap: .35rem; cursor: pointer; }
.ps-action-cards { display: grid; grid-template-columns: repeat(3, 63mm); grid-auto-rows: 88mm; justify-content: center; }
.ps-action {
    display: flex; flex-direction: column; min-width: 0; overflow: hidden; margin: 0 -.13mm -.13mm 0;
    border: .25mm solid #6d685c; break-inside: avoid;
}
.ps-action header { display: flex; align-items: center; gap: 1.5mm; padding: 1.5mm 2mm 1mm; }
.ps-action-cost {
    flex: none; min-width: 7mm; padding: .3mm 1mm; border: .4mm solid var(--blue); border-radius: 1mm;
    color: var(--blue-ink); font: 700 10.5pt/1.25 "IBM Plex Mono", Consolas, monospace; text-align: center; white-space: nowrap;
}
.ps-action h3 { margin: 0; font: 700 12pt/1.02 "PT Sans Narrow", Arial, sans-serif; }
.ps-action-tags { display: flex; flex-wrap: wrap; gap: .7mm; padding: 0 2mm 1mm; }
.ps-action-tags span { padding: .1mm 1.2mm; border-radius: .8mm; background: var(--tint); font-size: 6.6pt; line-height: 1.3; }
.ps-action p { flex: 1; min-height: 0; margin: 0; padding: 0 2mm; font-size: 7.3pt; line-height: 1.2; white-space: pre-line; }
.ps-action footer {
    display: flex; justify-content: space-between; gap: 2mm; padding: .5mm 2mm;
    background: var(--tint); color: #3d3a33; font-size: 6.4pt;
}

/* ---------- Поправки вёрстки ---------- */
.ps-root p { max-width: none; }
.ps-title-row { display: flex; justify-content: space-between; align-items: baseline; }
.ps-title-row span { display: flex; align-items: baseline; gap: 1.5mm; color: var(--ink); font-size: 8.5pt; text-transform: none; }
.ps-title-row i { display: inline-block; width: 22mm; border-bottom: .2mm solid var(--ink); }
.ps-special td:first-child { font-size: 8pt; white-space: nowrap; }
.ps-effects .ps-line { min-height: 3.4mm; }
