/* =====================================================================
   Warhammer Character – stylesheet
   ---------------------------------------------------------------------
   1. Theme      – change colours, fonts and sizes here
      Themes     – the styles in the drop-down (death, forest, ...)
   2. Base       – page and form defaults
   3. Toolbar
   4. Layout     – the grid of panels (mobile first)
   5. Sections   – identity, careers, characteristics, skills, ...
   6. Tables     – the editable lists (talents, weapons, ...)
   7. Print
   ===================================================================== */

/* ---------- 1. Theme ---------- */
:root {
    --paper: #e9e3d0;          /* page background */
    --panel: #f8f5ec;          /* section background */
    --ink: #2a241a;            /* text */
    --ink-soft: #6b604c;       /* labels and hints */
    --line: #3b3427;           /* panel borders */
    --line-soft: #c9bfa6;      /* input underlines */
    --accent: #8a1c16;         /* headings, ticked boxes */
    --accent-ink: #fff8ef;     /* text on accent */
    --field: #fffdf7;          /* input background */
    --calc: #efe8d6;           /* calculated values background */
    --warn: #b3261e;
    --bar: #3b3427;            /* toolbar background */
    --bar-ink: #f8f5ec;        /* toolbar text */
    --bar-error: #ffb4ab;

    --font-head: 'IM Fell English SC', Georgia, serif;
    --font-body: 'EB Garamond', Georgia, 'Times New Roman', serif;
    --font-size: 17px;

    --gap: 12px;               /* space between panels */
    --pad: 12px;               /* space inside panels */
    --radius: 3px;
    --sheet-width: 1400px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #1b1915;
        --panel: #26231d;
        --ink: #e9e1cf;
        --ink-soft: #a89c84;
        --line: #6e624c;
        --line-soft: #4d4537;
        --accent: #d4574c;
        --accent-ink: #1b1915;
        --field: #1f1c17;
        --calc: #312d25;
        --warn: #ff8a80;
        --bar: #12100d;
    }
}

/* ---------- Themes ----------
   Picked with the style drop-down, which sets data-theme on <html>.
   Each one only redefines the colour variables above.
   Without data-theme the sheet follows the system light/dark setting. */
:root[data-theme="death"] {
    --paper: #0c0c0e;
    --panel: #17171a;
    --ink: #d9d9d4;
    --ink-soft: #8b8b86;
    --line: #5a5a5f;
    --line-soft: #34343a;
    --accent: #a3b18a;
    --accent-ink: #0c0c0e;
    --field: #101013;
    --calc: #212126;
    --warn: #e05a4f;
    --bar: #000;
    --bar-ink: #d9d9d4;
    --font-head: 'IM Fell English SC', Georgia, serif;
}
:root[data-theme="forest"] {
    --paper: #d4dcc3;
    --panel: #eef2e2;
    --ink: #1f2d1a;
    --ink-soft: #55684b;
    --line: #2f4a2a;
    --line-soft: #b7c5a3;
    --accent: #3d6b2e;
    --accent-ink: #f2f7e8;
    --field: #f9fbf2;
    --calc: #dfe8cd;
    --warn: #a83225;
    --bar: #2f4a2a;
    --bar-ink: #eef2e2;
}
:root[data-theme="water"] {
    --paper: #cfe3ec;
    --panel: #eaf5fa;
    --ink: #12303f;
    --ink-soft: #4a6b7a;
    --line: #1f4e66;
    --line-soft: #a9cadb;
    --accent: #11708f;
    --accent-ink: #eaf5fa;
    --field: #f7fcfe;
    --calc: #d3e8f1;
    --warn: #b3261e;
    --bar: #1f4e66;
    --bar-ink: #eaf5fa;
}
:root[data-theme="dessert"] {
    --paper: #ecd9b0;
    --panel: #f8ecd0;
    --ink: #3a2a14;
    --ink-soft: #7a6240;
    --line: #8a5a24;
    --line-soft: #dcc28f;
    --accent: #b5651d;
    --accent-ink: #fff4dc;
    --field: #fffaec;
    --calc: #efdcaf;
    --warn: #a3281c;
    --bar: #8a5a24;
    --bar-ink: #fff4dc;
}
:root[data-theme="bubblegum"] {
    --paper: #ffc9e3;
    --panel: #fff0f8;
    --ink: #4a1d3a;
    --ink-soft: #94597d;
    --line: #d94a9a;
    --line-soft: #f5b3d6;
    --accent: #d6267f;
    --accent-ink: #fff0f8;
    --field: #fffafd;
    --calc: #ffdcee;
    --warn: #c0172b;
    --bar: #ff5fb0;
    --bar-ink: #3a0f2b;
    --font-body: 'Comic Neue', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
    --font-head: 'Comic Neue', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
}
:root[data-theme="bubblegum"] h2,
:root[data-theme="bubblegum"] h3 { font-weight: 700; }

/* ---------- 2. Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { font-size: var(--font-size); -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    line-height: 1.3;
}

h2, h3 {
    font-family: var(--font-head);
    font-weight: normal;
    color: var(--accent);
    margin: 0 0 8px;
    text-align: center;
}
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; margin-top: 16px; }

input, select, textarea, button, output {
    font: inherit;
    color: inherit;
}

input[type="text"], input[type="number"], input[type="url"], select, textarea {
    width: 100%;
    min-width: 0;
    padding: 4px 6px;
    background: var(--field);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}
/* Text fields grow downwards with their content (up to 10 lines, see autosize() in sheet.js) */
textarea { resize: none; overflow-y: hidden; display: block; }

input:focus, select:focus, textarea:focus, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 0;
}

/* Number inputs: no spinners, centred */
input[type="number"] { text-align: center; -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Calculated (read-only) values */
output {
    display: block;
    min-height: 2em;
    padding: 4px 6px;
    background: var(--calc);
    border-radius: var(--radius);
    text-align: center;
    font-weight: 600;
}
output.over { color: var(--warn); }

input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    accent-color: var(--accent);
}

button {
    cursor: pointer;
    padding: 6px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
button:hover { background: var(--calc); }
button.danger { color: var(--warn); }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.hint { color: var(--ink-soft); font-size: 0.85rem; margin: 8px 0 0; }

/* A label above its input */
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field > span { color: var(--ink-soft); font-size: 0.85rem; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }

/* ---------- 3. Toolbar ---------- */
.toolbar[hidden] { display: none; }
.toolbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(56px, env(safe-area-inset-right)); /* room for the menu button */
    background: var(--bar);
    color: var(--bar-ink);
}
/* Menu button: always visible in the top right corner.
   The compass button (.nav-btn) is the same, in the bottom right corner. */
.menu-btn,
.nav-btn {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background: var(--bar);
    color: var(--bar-ink);
    border: 1px solid var(--bar-ink);
    border-radius: var(--radius);
    opacity: 0.9;
}
.menu-btn { top: 8px; }
.nav-btn { bottom: max(8px, env(safe-area-inset-bottom)); }
.menu-btn:hover, .nav-btn:hover { background: var(--bar); opacity: 1; }
.menu-btn svg, .nav-btn svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu-btn[aria-expanded="true"], .nav-btn[aria-expanded="true"] { opacity: 1; }
/* While the menu is hidden, keep the button clear of the first panel */
.menu-btn[aria-expanded="false"] ~ .sheet { padding-top: calc(var(--gap) + 2.5rem); }

/* Section navigation: a bar along the bottom with a link to every section */
.section-nav[hidden] { display: none; }
.section-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 45vh;
    overflow-y: auto;
    padding: 10px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(56px, env(safe-area-inset-right)); /* room for the compass button */
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--bar);
    color: var(--bar-ink);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.25);
}
.section-nav a {
    padding: 4px 10px;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    white-space: nowrap;
}
.section-nav a:hover { background: var(--calc); }
.section-nav a:focus-visible { outline: 2px solid var(--accent); }
/* --toolbar-h is the height of the open menu bar (set by sheet.js), so sections stop below it */
[id^="sec-"] { scroll-margin-top: calc(var(--toolbar-h, 0px) + 0.75rem); }

.toolbar-slot { flex: 1 1 200px; max-width: 360px; }
.toolbar-style { flex: 0 1 140px; }
.toolbar select { background: var(--field); color: var(--ink); }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar-actions button { padding: 4px 10px; color: var(--ink); }
.toolbar-actions button.danger { color: var(--warn); }
.toolbar-draw { display: flex; gap: 6px; }
/* Link styled like the menu buttons */
.toolbar-link { display: inline-flex; align-items: center; padding: 4px 10px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.toolbar-link:hover { background: var(--calc); }
.toolbar-draw input { width: 13rem; padding: 4px 8px; background: var(--field); color: var(--ink); }
.toolbar-draw input::placeholder { color: #888; opacity: 1; }
.toolbar-draw input.short { color: var(--warn); } /* fewer than 8 letters */
.toolbar-status { font-size: 0.9rem; color: var(--bar-ink); }
.toolbar-status.error { color: var(--bar-error); }

/* Suggestion drop-down under a text field (see the suggestion drop-down in sheet.js) */
.suggest[hidden] { display: none; }
.suggest {
    position: absolute;
    z-index: 30;
    max-height: 18rem;
    margin: 2px 0 0;
    padding: 4px 0;
    overflow-y: auto;
    list-style: none;
    background: var(--panel);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.suggest li { padding: 4px 10px; line-height: 1.25; cursor: pointer; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--calc); }
.suggest-label { display: block; font-size: 0.8rem; color: var(--ink-soft); }
.suggest li.suggest-more { font-size: 0.8rem; color: var(--ink-soft); cursor: default; }
.suggest li.suggest-more:hover { background: none; }

/* ---------- 4. Layout ---------- */
/* Mobile first: one column. Panels get wider spans as the screen grows.
   span-md-* applies from 700px, span-lg-* from 1100px (12 column grid). */
.sheet {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--gap);
    max-width: var(--sheet-width);
    margin: 0 auto;
    padding: var(--gap);
    padding-left: max(var(--gap), env(safe-area-inset-left));
    padding-right: max(var(--gap), env(safe-area-inset-right));
}
.sheet > * { grid-column: span 12; min-width: 0; }

@media (min-width: 700px) {
    .sheet > .span-md-6 { grid-column: span 6; }
    .sheet > .span-md-12 { grid-column: span 12; }
}
@media (min-width: 1100px) {
    .sheet > .span-lg-2 { grid-column: span 2; }
    .sheet > .span-lg-3 { grid-column: span 3; }
    .sheet > .span-lg-4 { grid-column: span 4; }
    .sheet > .span-lg-6 { grid-column: span 6; }
    .sheet > .span-lg-7 { grid-column: span 7; }
    .sheet > .span-lg-8 { grid-column: span 8; }
    .sheet > .span-lg-12 { grid-column: span 12; }
}

/* Wide windows: the sheet uses nearly the whole window (up to --sheet-width) and the
   panels are spread out so that every row adds up to 12 columns.
   Ids are used so these rules win over the span classes in the HTML. */
@media (min-width: 1500px) {
    :root { --sheet-width: 3200px; --gap: 16px; --pad: 14px; }
    .sheet > #sec-character { grid-column: span 5; }
    .sheet > #sec-xp { grid-column: span 3; }
    .sheet > #sec-fate { grid-column: span 4; }
    .sheet > #sec-talents { grid-column: span 5; }
    .sheet > .stack { grid-column: span 4; }
    .sheet > #sec-armour-points { grid-column: span 3; }
    .sheet > #sec-encumbrance,
    .sheet > #sec-wealth { grid-column: span 3; }
    .sheet > #sec-corruption { grid-column: span 6; }
    .sheet > #sec-weapons,
    .sheet > #sec-armour { grid-column: span 6; }
    .sheet .skills { columns: 4 320px; }
}
@media (min-width: 2000px) {
    .sheet > #sec-character { grid-column: span 3; }
    .sheet > #sec-xp,
    .sheet > #sec-fate { grid-column: span 2; }
    .sheet > #sec-careers { grid-column: span 5; }
    .sheet > #sec-talents { grid-column: span 4; }
    .sheet > .stack { grid-column: span 3; }
    .sheet > #sec-armour-points { grid-column: span 2; }
    .sheet > #sec-encumbrance { grid-column: span 3; }
    .sheet > #sec-wealth { grid-column: span 2; }
    .sheet > #sec-corruption { grid-column: span 4; }
    .sheet > #sec-weapons { grid-column: span 6; }
    .sheet > #sec-armour,
    .sheet > #sec-trappings,
    .sheet > #sec-notes { grid-column: span 4; }
    .sheet > #sec-spells { grid-column: span 12; }
    .sheet .skills { columns: 5 320px; }
}

.panel {
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: var(--radius);
    padding: var(--pad);
    min-width: 0;
}
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack > .panel { flex: 1 1 auto; }

.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.trio:last-child { margin-bottom: 0; }
.fraction { display: flex; align-items: center; gap: 4px; }

.footer {
    max-width: var(--sheet-width);
    margin: 0 auto;
    padding: 8px var(--gap) 4rem;       /* room for the compass button */
    color: var(--ink-soft);
    font-size: 0.8rem;
    text-align: center;
}

/* ---------- 5. Sections ---------- */

/* Identity and portrait */
.identity { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--pad); align-items: start; }
.portrait { margin: 0; }
.portrait img {
    display: block;
    width: 100%;
    aspect-ratio: 5 / 6;
    object-fit: cover;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: var(--calc);
}
.identity-fields { display: grid; gap: 6px; }
@media (min-width: 500px) {
    .identity { grid-template-columns: 160px minmax(0, 1fr); }
}

/* Careers and advancement tracker */
.careers { display: grid; gap: 10px; }
.career-head { display: none; }
.career-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 3.5rem;
    gap: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line-soft);
}
.career-row:last-child { border-bottom: 0; padding-bottom: 0; }
.career-row .tracker { grid-column: 1 / -1; }
.career-row .cell:last-child { grid-column: 1 / -1; }

.tracker { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 2px; }
.tracker-seg {
    display: grid;
    grid-template-columns: repeat(var(--n), 1.1rem);
    gap: 3px;
}
.skull {
    position: relative;
    width: 2rem;
    height: 2rem;
    padding: 2px;
    border: 0;
    background: none;
    color: var(--line-soft);
}
.skull:hover { background: none; color: var(--ink-soft); }
.skull svg { width: 100%; height: 100%; fill: currentColor; }
.skull[aria-pressed="true"] { color: var(--accent); }
.skull.level b {
    position: absolute;
    top: -0.6rem;
    left: 0;
    right: 0;
    font-size: 0.75rem;
    color: var(--ink);
}

@media (min-width: 1100px) {
    /* Header and rows share the columns of .careers through subgrid */
    .careers { grid-template-columns: 1fr 1.3fr 3rem auto 1fr; column-gap: 8px; }
    .career-head, .career-row {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
        align-items: center;
    }
    .career-head { color: var(--ink-soft); font-size: 0.85rem; }
    .career-row .tracker, .career-row .cell:last-child { grid-column: auto; }
    .career-row .cell-label { display: none; }
}

/* Characteristics: 5 per row on phones, all 10 in a row on wider screens */
.characteristics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
}
.char-legend { display: none; }
.char { display: grid; gap: 3px; text-align: center; }
.char-name { font-family: var(--font-head); font-size: 1.1rem; }
.char output { font-size: 1.1rem; }

@media (min-width: 700px) {
    .characteristics { grid-template-columns: auto repeat(10, minmax(0, 1fr)); }
    .char-legend {
        display: grid;
        gap: 3px;
        grid-template-rows: subgrid;
        grid-row: span 4;
        color: var(--ink-soft);
        font-size: 0.85rem;
        text-align: right;
    }
    .char { grid-template-rows: subgrid; grid-row: span 4; }
    .char-legend span { display: flex; align-items: center; justify-content: flex-end; }
    .char input { padding: 4px 2px; }
}

/* Basic skills: flows into 1–3 columns */
.skills { columns: 3 320px; column-gap: 24px; }
.skill {
    display: grid;
    grid-template-columns: 1.4rem minmax(0, 1fr) 2.5rem 3.2rem 3.2rem;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    border-bottom: 1px solid var(--line-soft);
    break-inside: avoid;
}
.skill-name { display: flex; align-items: center; gap: 2px; white-space: nowrap; overflow: hidden; }
.skill-name .spec { padding: 1px 4px; min-width: 3rem; }
.skill-char { color: var(--ink-soft); font-size: 0.9rem; }
.skill output, .skill input[type="number"] { padding: 2px; min-height: 1.6em; }

/* Current wounds */
.wounds-current {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 1.6rem;
}
.wounds-current input { font-size: 1.6rem; }
.wounds-current output { font-size: 1.6rem; }
.wounds-calc { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; text-align: center; }
.wounds-calc input { padding: 4px 2px; }

/* Armour points around a figure */
.armour-points {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-areas:
        "head   fig    larm"
        "rarm   fig    body"
        "rleg   fig    lleg"
        "shield fig    .";
    gap: 8px;
    align-items: center;
}
.ap { display: grid; gap: 2px; text-align: center; font-size: 0.85rem; }
.ap small { color: var(--ink-soft); }
.ap input { font-size: 1.2rem; }
.ap-head { grid-area: head; }
.ap-larm { grid-area: larm; }
.ap-rarm { grid-area: rarm; }
.ap-body { grid-area: body; }
.ap-rleg { grid-area: rleg; }
.ap-lleg { grid-area: lleg; }
.ap-shield { grid-area: shield; }
.ap-figure { grid-area: fig; width: 100%; max-height: 260px; fill: var(--line-soft); }

/* Wealth and encumbrance */
.wealth { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 1100px) {
    .wealth { grid-template-columns: 1fr; }
    .wealth .field { flex-direction: row; align-items: center; gap: 8px; }
    .wealth .field > span { width: 2rem; font-size: 1.1rem; color: var(--ink); }
}
.enc { display: grid; grid-template-columns: 1fr 5rem; gap: 4px 8px; margin: 0; align-items: center; }
.enc dt { color: var(--ink-soft); }
.enc dd { margin: 0; }

/* Corruption track */
.corruption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.corruption-label { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.corruption-label output { min-width: 2.5rem; }
/* Text with a hover tip */
.has-tip { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
/* ⓘ button that opens the same text as a panel, for touch screens */
.info-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.6rem; height: 1.6rem; padding: 0;
    font-size: 1.05rem; line-height: 1; color: var(--accent);
    background: none; border: 1px solid transparent; border-radius: 50%;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { background: var(--calc); border-color: var(--line-soft); }
.info-pop[hidden] { display: none; }
/* Fields with a description: small ⓘ in the bottom right corner of the field */
.cell.has-info, .field.has-info { position: relative; align-self: start; } /* no stretching, so the ⓘ stays in the field */
.cell.has-info textarea, .field.has-info textarea { padding-right: 1.7rem; }
.info-btn.field-info { position: absolute; right: 3px; bottom: 4px; width: 1.35rem; height: 1.35rem; font-size: 0.9rem; }
.info-pop.floating {
    position: absolute;
    z-index: 25;
    margin: 0;
    background: var(--panel);
    border-color: var(--line);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.info-pop {
    margin: 0 0 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
    white-space: pre-line;
    background: var(--field);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}
.corruption-track { display: flex; flex-wrap: wrap; gap: 0; }
.corruption-track .skull { width: 1.9rem; height: 1.9rem; }
.corruption-limits { margin: -4px 0 10px; font-size: 0.85rem; color: var(--ink-soft); }
.corruption-limits.over { color: var(--warn); font-weight: 600; }

.notes { min-height: 12rem; }
.sin { margin-top: 10px; max-width: 10rem; margin-left: auto; }

/* ---------- 6. Tables (editable lists) ---------- */
/* Phones: each row is a small card with labels.
   From 700px: a real table with a header row; columns come from --cols. */
.list { display: grid; gap: 8px; }
.list-head { display: none; }
.list-row {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
    gap: 4px 8px;
    padding: 8px 2.2rem 8px 8px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
}
.list-row .cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.list-row .cell.wide { grid-column: 1 / -1; }
.list-row .cell.check { flex-direction: row; align-items: center; gap: 6px; }
.cell-label { color: var(--ink-soft); font-size: 0.75rem; }

.row-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink-soft);
    font-size: 1.2rem;
    line-height: 1;
}
.row-remove:hover { color: var(--warn); background: none; }
.row-add { justify-self: start; padding: 2px 10px; font-size: 0.9rem; }

@media (min-width: 700px) {
    .list { gap: 0; }
    .list-head, .list-row {
        display: grid;
        grid-template-columns: var(--cols);
        align-items: center;
        gap: 6px;
    }
    .list-head {
        color: var(--ink-soft);
        font-size: 0.85rem;
        padding: 0 0 4px;
        border-bottom: 1px solid var(--line);
    }
    .list-row {
        padding: 3px 0;
        border: 0;
        border-bottom: 1px solid var(--line-soft);
        border-radius: 0;
    }
    .list-row .cell.wide { grid-column: auto; }
    .list-row .cell-label { display: none; }
    .list-row .cell.check { justify-content: center; }
    .row-remove { position: static; }
    .row-add { margin-top: 6px; }

    /* Short lists (trappings, other skills) flow into several columns,
       each column with its own header (.extra-2, .extra-3). */
    .list-columns { column-gap: 24px; }
    .list-columns > .row-add { grid-column: 1 / -1; }
    .list-columns > .list-head.extra { display: none; }
    [data-list="trappings"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    [data-list="trappings"] > .list-head.extra-2 { display: grid; }
}
@media (min-width: 900px) {
    [data-list="customSkills"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    [data-list="customSkills"] > .list-head.extra-2 { display: grid; }
}
@media (min-width: 1300px) {
    [data-list="customSkills"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    [data-list="customSkills"] > .list-head.extra-3 { display: grid; }
}

/* Dialogs (Change picture) */
.dialog {
    width: min(92vw, 28rem);
    padding: var(--pad);
    background: var(--panel);
    color: var(--ink);
    border: 2px solid var(--line);
    border-radius: var(--radius);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog h2 { margin-bottom: 10px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { background: var(--accent); filter: brightness(1.1); }

/* ---------- 7. Print ---------- */
@media print {
    :root { --paper: #fff; --panel: #fff; --field: #fff; --calc: #fff; --font-size: 11px; }
    .toolbar, .menu-btn, .nav-btn, .section-nav, .dialog, .footer, .row-add, .row-remove, .hint, .suggest, .info-btn, .info-pop { display: none !important; }
    .sheet { padding: 0; }
    .panel { break-inside: avoid; }
}
