/* Dračí Hlídka – deník postavy.
   Paper sheets on a dark table; the look follows the printed "Pokročilý deník". */

:root {
  --table: #26292d;
  --paper: #f5f3ee;
  --panel: #ffffff;
  --ink: #232528;
  --ink-soft: #5c6167;
  --line: #34373b;
  --rule: rgba(52, 55, 59, .6);
  --ribbon: #4b4f55;
  --ribbon-deep: #2f3236;
  --tail: #b9bdc2;
  --accent: #a3392b;
  --accent-soft: rgba(163, 57, 43, .09);
  --row-h: 2rem;
  --col-gap: 2.2rem;
  --toolbar-h: 3.5rem;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --text: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--toolbar-h) + 1rem);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--table);
  background-image:
    radial-gradient(ellipse at 15% -10%, rgba(255, 255, 255, .07), transparent 55%),
    radial-gradient(ellipse at 90% 110%, rgba(0, 0, 0, .35), transparent 60%);
  color: var(--ink);
  font-family: var(--text);
  font-size: 16px;
  line-height: 1.35;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

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

.ico {
  width: 1em; height: 1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

:focus-visible { outline: 3px solid rgba(163, 57, 43, .45); outline-offset: 2px; }

/* ─────────── toolbar ─────────── */

.toolbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(24, 26, 29, .93);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #eceae4;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}
.toolbar__inner {
  max-width: 1120px; margin: 0 auto;
  min-height: var(--toolbar-h);
  padding: .45rem 1rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  color: inherit; text-decoration: none; white-space: nowrap;
}
.brand__text { font-family: var(--display); font-weight: 700; letter-spacing: .03em; line-height: 1.05; }
.brand__text small {
  display: block; margin-top: .1rem;
  font-family: var(--text); font-weight: 500; font-size: .7rem;
  letter-spacing: .1em; text-transform: uppercase; opacity: .6;
}
.picker { display: flex; align-items: center; gap: .4rem; flex: 1 1 13rem; min-width: 0; max-width: 23rem; }
.picker select {
  flex: 1; min-width: 0; height: 2.3rem;
  padding: 0 2rem 0 .75rem;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: .5rem;
  background: rgba(255, 255, 255, .07) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f3f1ea' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right .65rem center / .85rem;
  color: #f3f1ea; font-weight: 500;
  -webkit-appearance: none; appearance: none;
  text-overflow: ellipsis;
}
.picker select option { color: #1c1e21; background: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  height: 2.3rem; padding: 0 .85rem;
  border: 1px solid rgba(255, 255, 255, .18); border-radius: .5rem;
  background: rgba(255, 255, 255, .07);
  color: #f3f1ea; font-weight: 500; white-space: nowrap;
  user-select: none;
}
.btn:hover { background: rgba(255, 255, 255, .15); }
.btn--icon { width: 2.3rem; padding: 0; }
.btn .ico { width: 1.25rem; height: 1.25rem; }
#btn-new span[aria-hidden] { font-size: 1.2rem; line-height: 1; }

.pagenav { display: flex; gap: .2rem; padding: .2rem; border-radius: .55rem; background: rgba(255, 255, 255, .06); }
.pagenav a {
  padding: .32rem .75rem; border-radius: .4rem;
  color: #d9d6cf; text-decoration: none; font-size: .92rem; font-weight: 500;
}
.pagenav a:hover { color: #fff; background: rgba(255, 255, 255, .09); }
.pagenav a.is-active { color: var(--ink); background: var(--paper); }

.status { margin-left: auto; font-size: .8rem; opacity: .6; white-space: nowrap; transition: opacity .2s; }
.status::before { content: "✓ "; }
.status.is-saving { opacity: .85; }
.status.is-saving::before { content: "● "; }
.status.is-error { opacity: 1; color: #ffb4a8; font-weight: 700; }
.status.is-error::before { content: "⚠ "; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + .45rem); z-index: 60;
  min-width: 15.5rem; padding: .35rem;
  display: flex; flex-direction: column;
  background: #fbfaf7; color: var(--ink);
  border-radius: .65rem; box-shadow: 0 14px 34px rgba(0, 0, 0, .4);
}
.menu__panel button {
  padding: .6rem .8rem; border: 0; border-radius: .45rem;
  background: none; text-align: left; font-size: .95rem;
}
.menu__panel button:hover, .menu__panel button:focus-visible { background: #ecebe6; outline: none; }
.menu__panel hr { margin: .3rem .45rem; border: 0; border-top: 1px solid #e2e0da; }
.menu__panel .danger { color: var(--accent); }

.warn {
  max-width: 1120px; margin: .8rem auto 0; padding: .75rem 1rem;
  background: #fff3cd; color: #5c4400; border-radius: .5rem;
}

/* ─────────── sheets ─────────── */

main { padding: 1.25rem .75rem 1rem; }

.page {
  position: relative;
  max-width: 1120px; margin: 0 auto 2rem;
  padding: 2.6rem 2.1rem 2.2rem;
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .2 0 0 0 0 .2 0 0 0 0 .2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 0 0, rgba(110, 115, 122, .26), transparent 38%),
    radial-gradient(ellipse at 100% 100%, rgba(110, 115, 122, .26), transparent 42%),
    radial-gradient(ellipse at 100% 0, rgba(110, 115, 122, .14), transparent 30%),
    radial-gradient(ellipse at 0 100%, rgba(110, 115, 122, .16), transparent 32%);
  border-radius: 2px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
}

/* ─────────── panels & ribbons ─────────── */

.panel {
  position: relative;
  padding: 2.15rem 1.1rem 1.1rem;
  background: var(--panel);
  border: 2px solid var(--line); border-radius: 3px;
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 5px rgba(52, 55, 59, .17),
    0 0 18px 4px rgba(90, 95, 102, .18),
    inset 0 0 30px rgba(52, 55, 59, .07);
}
.panel--list { padding-right: 2rem; }

.ribbon {
  position: absolute; top: -1.35rem; left: -1.05rem; z-index: 2;
  display: flex; align-items: center;
  margin: 0; font-size: 1rem; font-weight: 400;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3));
  pointer-events: none;
}
.ribbon__badge {
  position: relative; z-index: 1;
  display: grid; place-items: center; flex: none;
  width: 2.85rem; height: 2.85rem;
  border-radius: 50%; border: 3px solid #fff;
  background: radial-gradient(circle at 35% 30%, #5d6168, var(--ribbon-deep) 70%);
  box-shadow: 0 0 0 2px var(--ribbon-deep);
  color: #fff;
}
.ribbon__badge .ico { width: 1.4rem; height: 1.4rem; }
.ribbon__title {
  margin-left: -1rem;
  padding: .34rem 1.85rem .34rem 1.6rem;
  background: linear-gradient(180deg, #62666c 0%, var(--ribbon) 45%, var(--ribbon-deep) 100%);
  color: #fff;
  font-family: var(--display); font-weight: 700; font-size: 1.12rem;
  letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  clip-path: polygon(0 0, 100% 0, calc(100% - .8rem) 50%, 100% 100%, 0 100%);
  transform: rotate(-1.5deg);
}

/* ─────────── typography helpers ─────────── */

.lbl {
  font-family: var(--display); font-weight: 700; font-size: .74rem;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink);
}
.lbl--soft { font-family: var(--text); font-weight: 500; letter-spacing: .06em; color: var(--ink-soft); }

.hint {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem 1rem;
  margin: .75rem 0 0;
  font-family: var(--display); font-weight: 700; font-size: .7rem;
  letter-spacing: .03em; text-transform: uppercase;
}
.hint--rate {
  justify-content: center; margin-top: .6rem;
  font-family: var(--hand); font-size: 1.2rem; font-weight: 700;
  letter-spacing: 0; text-transform: none; color: var(--ink-soft);
}

/* ─────────── fields ─────────── */

.box {
  width: 3.3rem; height: 2.55rem; margin: 0; padding: 0 .15rem;
  border: 2px solid var(--line); border-radius: 3px;
  background: #fff;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .13);
  font-family: var(--hand); font-weight: 700; font-size: 1.5rem; line-height: 1;
  text-align: center; color: var(--ink);
}
.box--lg { width: 4.4rem; height: 3rem; font-size: 1.85rem; }
.box--sm { width: 2.9rem; height: var(--row-h); font-size: 1.3rem; }
.box--wide { width: 6.2rem; }
.box--dark { border-color: var(--ribbon-deep); background: #eef0f1; }
.box:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(163, 57, 43, .2), inset 0 1px 3px rgba(0, 0, 0, .13);
}

.line {
  display: block; width: 100%; min-width: 0;
  height: var(--row-h); margin: 0; padding: 0 .3rem;
  border: 0; border-radius: 0;
  background: transparent linear-gradient(to top, var(--rule) 0, var(--rule) 1px, transparent 1px) no-repeat;
  font-family: var(--hand); font-weight: 500; font-size: 1.38rem;
  line-height: var(--row-h); color: var(--ink);
}
.line:focus {
  outline: none;
  background-color: var(--accent-soft);
  background-image: linear-gradient(to top, var(--accent) 0, var(--accent) 2px, transparent 2px);
}
.line::placeholder, .box::placeholder { color: #b2b5b9; opacity: 1; }
textarea.line {
  resize: none; overflow: hidden;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--row-h) - 1px), var(--rule) calc(var(--row-h) - 1px), var(--rule) var(--row-h));
  background-repeat: repeat;
}
textarea.line:focus {
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--row-h) - 2px), var(--accent) calc(var(--row-h) - 2px), var(--accent) var(--row-h));
}
.line--bare, .line--bare:focus { background-image: none; }
.line--bare { text-align: center; border-radius: 3px; }
.center { text-align: center; }

/* ─────────── row lists ─────────── */

.rows { display: grid; gap: .15rem; }
/* multi-column lists fill each column top to bottom, as on paper */
.rows--cols { display: block; columns: var(--cols, 2); column-gap: var(--col-gap); }
.rows--cols > .row { break-inside: avoid; margin-bottom: .3rem; }
.rows--skills { --cols: 2; }
.rows--magic { --cols: 4; --col-gap: 1.6rem; }
.rows--gear { --cols: 2; --col-gap: 1.6rem; }

.row { position: relative; }
.row-del {
  position: absolute; right: -1.7rem; top: calc(100% - var(--row-h) / 2);
  transform: translateY(-50%);
  display: grid; place-items: center;
  width: 1.4rem; height: 1.4rem; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-soft);
  font-size: 1.05rem; line-height: 1;
  visibility: hidden;
}
.row:hover .row-del, .row:focus-within .row-del { visibility: visible; }
.row-del:hover { background: var(--accent); color: #fff; }
.prow .row-del, .arow .row-del { top: calc(var(--row-h) / 2); }

/* ─────────── page 1: identity ─────────── */

.p1-top {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem 2.6rem; align-items: start;
}

.identity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr) minmax(0, 1fr);
  grid-template-areas:
    "name name name"
    "left portrait right"
    "class class class"
    "race race race";
  gap: .6rem .75rem;
  padding: 0 1.4rem;
}
.banner--name { grid-area: name; margin: 0 9% .15rem; }
.tags--left { grid-area: left; }
.portrait { grid-area: portrait; }
.tags--right { grid-area: right; }
.banner--class { grid-area: class; margin: .2rem 3% 0; }
.banner--race { grid-area: race; margin: 0 11%; }

.banner, .tag { position: relative; display: block; isolation: isolate; }
.banner__body, .tag__body {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: .22rem .8rem .12rem;
  background: linear-gradient(180deg, #fff 0%, #fff 55%, #efefed 100%);
  border: 2px solid var(--line); border-radius: 4px;
  box-shadow: inset 0 -6px 8px -6px rgba(0, 0, 0, .2);
}
.banner::before, .banner::after,
.tag--l::before, .tag--r::after {
  content: ""; position: absolute; z-index: -1;
  top: .6rem; bottom: -.5rem; width: 1.9rem;
  background: linear-gradient(180deg, #dcdee1, var(--tail));
}
.banner::before { left: -1.3rem; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, .55rem 50%); }
.banner::after { right: -1.3rem; clip-path: polygon(0 0, 100% 0, calc(100% - .55rem) 50%, 100% 100%, 0 100%); }
.banner .lbl { font-size: .8rem; }
.banner .line { font-size: 1.6rem; }
.banner--name .lbl { font-size: .95rem; }
.banner--name .line { height: 2.7rem; font-size: 2.2rem; line-height: 2.7rem; font-weight: 700; }

.tags { display: flex; flex-direction: column; justify-content: space-around; gap: .6rem; }
.tag__body { padding: .15rem .45rem 0; }
.tag .lbl { font-size: .64rem; letter-spacing: .03em; }
.tag .line { height: 1.95rem; font-size: 1.4rem; line-height: 1.95rem; font-weight: 700; }
.tag--l { transform: rotate(-2.5deg); }
.tag--r { transform: rotate(2.5deg); }
.tag--l::before, .tag--r::after { top: .45rem; bottom: -.4rem; width: 1.4rem; }
.tag--l::before { left: -.95rem; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, .45rem 50%); }
.tag--r::after { right: -.95rem; clip-path: polygon(0 0, 100% 0, calc(100% - .45rem) 50%, 100% 100%, 0 100%); }

.portrait {
  position: relative; overflow: hidden;
  aspect-ratio: 3 / 4; min-height: 9rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 48% 48% 6px 6px / 24% 24% 6px 6px;
  box-shadow: 0 0 0 4px #fff, 0 0 0 6px #c5c8cc, inset 0 0 26px rgba(0, 0, 0, .09);
}
.portrait.is-drop { box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--accent); }
.portrait__img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.portrait__empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  padding: 1rem .6rem; border: 0;
  background: repeating-linear-gradient(135deg, #fff 0 10px, #f5f5f3 10px 20px);
  color: var(--ink-soft); text-align: center;
  font-family: var(--display); font-weight: 700; font-size: .78rem;
  letter-spacing: .06em; text-transform: uppercase;
}
.portrait__empty small { font-family: var(--text); font-weight: 400; font-size: .74rem; letter-spacing: 0; text-transform: none; }
.portrait__empty .ico { width: 2rem; height: 2rem; opacity: .55; }
.portrait__empty:hover { color: var(--ink); }
.portrait__actions {
  position: absolute; left: 0; right: 0; bottom: .45rem;
  display: flex; justify-content: center; gap: .35rem;
  opacity: 0; transition: opacity .15s;
}
.portrait:hover .portrait__actions, .portrait:focus-within .portrait__actions { opacity: 1; }
@media (hover: none) { .portrait__actions { opacity: 1; } }
.chip {
  padding: .28rem .7rem; border: 0; border-radius: 999px;
  background: rgba(28, 30, 33, .82); color: #fff; font-size: .78rem;
}
.chip:hover { background: var(--accent); }

/* ─────────── page 1: vitals ─────────── */

.vitals { display: grid; gap: 2.4rem; padding-top: 1.2rem; }
.vital { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .9rem 1.4rem; }
.stat { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.stat .lbl { font-size: .76rem; }
.stat--death { margin-left: auto; }
.stepper { display: flex; align-items: center; gap: .3rem; }
.stepper__btn {
  display: grid; place-items: center;
  width: 2.05rem; height: 2.05rem; padding: 0;
  border: 2px solid var(--line); border-radius: 50%;
  background: #fff; color: var(--ink);
  font-size: 1.15rem; font-weight: 700; line-height: 1;
  user-select: none; touch-action: manipulation;
}
.stepper__btn:hover { background: var(--ink); color: #fff; }
.stepper__btn:active { transform: scale(.94); }
.death { display: flex; align-items: center; gap: .3rem; }
.death__minus { font-size: 2.1rem; font-weight: 700; line-height: 1; }
.death__skull { width: 2rem; height: 2rem; color: var(--ink-soft); }

.daily { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-left: auto; }
.daily__checks { display: flex; gap: 1rem; }
.check { display: flex; flex-direction: column; align-items: center; gap: .25rem; cursor: pointer; }
.check .lbl { font-size: .7rem; }
.check input {
  width: 1.7rem; height: 1.7rem; margin: 0;
  border: 2px solid var(--line); border-radius: 3px;
  background: #fff center / 88% no-repeat;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .13);
  -webkit-appearance: none; appearance: none; cursor: pointer;
}
.check input:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3392b' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M5 5.5c4 4.2 9.5 9.6 14 13.5M18.5 4.8C14 9.5 9.6 14.2 5.4 19.2'/%3E%3C/svg%3E");
}
.check input:focus-visible { outline: 3px solid rgba(163, 57, 43, .35); outline-offset: 1px; border-color: var(--accent); }

/* ─────────── page 1: body ─────────── */

.p1-body {
  display: grid; grid-template-columns: 17.5rem minmax(0, 1fr);
  gap: 2.4rem 1.9rem; align-items: start;
  margin-top: 2.9rem;
}
.p1-left, .p1-right { display: grid; gap: 2.6rem; min-width: 0; }

.attrs__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr)); gap: .95rem; }
.attr {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name mod" "score mod";
  align-items: center; column-gap: .5rem;
  padding: 0 .55rem .5rem 0;
  background: linear-gradient(90deg, #ebeced, #fff 75%);
  border: 2px solid var(--line); border-radius: 3px;
}
.attr__name {
  grid-area: name; justify-self: start;
  margin-bottom: .45rem; padding: .16rem .65rem .1rem;
  background: linear-gradient(90deg, #858a90, #c4c7cb);
  font-family: var(--display); font-weight: 800; font-size: .95rem;
  letter-spacing: .03em; text-transform: uppercase; color: #1c1e21;
}
.attr__score { grid-area: score; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.attr__score .lbl { font-size: .66rem; }
.attr__mod { grid-area: mod; display: flex; flex-direction: column; align-items: center; padding-top: .35rem; cursor: text; }
.attr__oprava {
  margin-bottom: .15rem;
  font-family: var(--display); font-weight: 700; font-size: .56rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft);
}
.shield {
  display: grid; place-items: center;
  width: 4.1rem; height: 4.6rem;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: .55rem .55rem 50% 50% / .55rem .55rem 42% 42%;
  box-shadow: 0 0 0 3px #cdd0d4, inset 0 2px 5px rgba(0, 0, 0, .12);
}
.shield:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(163, 57, 43, .3), inset 0 2px 5px rgba(0, 0, 0, .12); }
.shield input {
  width: 100%; height: 100%; padding: 0 0 .35rem;
  border: 0; border-radius: inherit; background: transparent;
  font-family: var(--hand); font-weight: 700; font-size: 2.05rem;
  text-align: center; color: var(--ink);
}
.shield input:focus { outline: none; }
.attr__abbr {
  position: relative; margin-top: -.8rem;
  padding: .06rem .5rem;
  background: var(--ribbon-deep); color: #fff; border-radius: 2px;
  font-family: var(--display); font-weight: 800; font-size: .8rem; letter-spacing: .03em;
}

.money__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: .65rem 1.6rem; }
.coin { display: grid; grid-template-columns: 1.3rem minmax(0, 1fr) auto; align-items: center; gap: .6rem; }
.coin .lbl { font-size: .8rem; }
.coin__dot { width: 1.3rem; height: 1.3rem; border: 2px solid var(--line); border-radius: 50%; }
.coin__dot--gold { background: radial-gradient(circle at 35% 35%, #fff4bf, #d9a92b 60%, #8f6810); }
.coin__dot--silver { background: radial-gradient(circle at 35% 35%, #fff, #c4c8cd 60%, #80858c); }
.coin__dot--copper { background: radial-gradient(circle at 35% 35%, #ffd8bd, #c46f3c 60%, #84411d); }

/* weapons */
.wrow {
  display: grid; grid-template-columns: minmax(0, 1fr) repeat(5, 4.1rem);
  gap: .45rem .6rem; align-items: end;
}
.wrow .box { width: 100%; }
.wrow--head { margin-bottom: .45rem; }
.wrow--head .lbl { font-size: .62rem; letter-spacing: .02em; text-align: center; }
.wrow--head .wrow__name { text-align: left; padding-left: .3rem; }
.rows--weapons { display: grid; gap: .5rem; }
.numhead {
  display: flex; flex-direction: column; align-items: center;
  padding: .25rem 0 .2rem;
  background: var(--ribbon-deep); color: #fff; border-radius: 3px 3px 0 0;
}
.numhead b { font-family: var(--display); font-weight: 800; font-size: 1.2rem; line-height: 1; }
.numhead small { font-size: .52rem; letter-spacing: .03em; text-transform: uppercase; opacity: .85; white-space: nowrap; }
.short { display: none; }

/* armor + rules */
.armor-row { display: grid; grid-template-columns: minmax(0, 1fr) 15.5rem; gap: 2.6rem 1.5rem; align-items: start; }
.armor__wrap { display: flex; align-items: center; gap: 1.3rem; }
.armor__items { flex: 1; min-width: 0; display: grid; gap: .55rem; }
.arm { display: grid; grid-template-columns: 2rem minmax(0, 1fr) 3.3rem; gap: .55rem; align-items: end; }
.arm--head .lbl { font-size: .68rem; text-align: center; }
.arm--head .lbl--soft { text-align: left; padding-left: .3rem; }
.arm__ico { width: 1.9rem; height: 1.9rem; color: var(--ink-soft); }
.zo {
  flex: none; display: flex; flex-direction: column; align-items: center;
  width: 8.4rem; padding: .7rem .5rem 1.5rem;
  background: linear-gradient(#fff, #f1f1f0);
  border: 3px solid var(--line);
  border-radius: .7rem .7rem 50% 50% / .7rem .7rem 32% 32%;
  box-shadow: 0 0 0 4px #d3d6d9;
  text-align: center; cursor: text;
}
.zo__title { font-family: var(--display); font-weight: 800; font-size: 1.7rem; line-height: 1; }
.zo__sub {
  margin: .2rem 0 .5rem;
  font-family: var(--display); font-weight: 700; font-size: .55rem;
  line-height: 1.3; text-transform: uppercase;
}
.rules {
  padding: .75rem .9rem .8rem;
  background: #fff;
  border: 2px solid var(--line); border-radius: 3px;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px rgba(52, 55, 59, .17);
  font-family: var(--display); font-weight: 700; font-size: .68rem;
  line-height: 1.6; letter-spacing: .01em; text-transform: uppercase;
}
.rules p { margin: 0; }
.rules h3 { margin: .5rem 0 .15rem; font-size: .9rem; font-weight: 800; text-align: center; }
.rules__lead { font-size: .74rem; }
/* dice keep their lowercase "k", which Cinzel does not have */
.dice { font-family: var(--text); font-weight: 700; font-size: 1.2em; letter-spacing: 0; text-transform: none; }

/* skills */
.skills__top { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .8rem; margin: -.55rem 0 1.1rem; }
.rulebox {
  margin: 0; padding: .45rem .85rem;
  background: #fff; border: 2px solid var(--line);
  font-family: var(--display); font-weight: 700; font-size: .64rem;
  line-height: 1.55; text-align: center; text-transform: uppercase;
}
.skillpts { display: flex; align-items: center; gap: .6rem; padding: .3rem .7rem; background: #fff; border: 2px solid var(--line); }
.skillpts .lbl { max-width: 6.5rem; font-size: .64rem; text-align: center; }
.skills__head { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--col-gap); margin-bottom: .2rem; }
.skills__head .lbl { font-size: .6rem; text-align: center; }
.srow { display: grid; grid-template-columns: minmax(0, 1fr) 2.9rem 2.9rem; gap: .4rem; align-items: end; }

/* ─────────── page 2 ─────────── */

.prow {
  display: grid; grid-template-columns: minmax(0, 2.3fr) 4.8rem 6.2rem minmax(0, 4fr);
  gap: 0 .9rem; align-items: start;
}
.prow--head { margin-bottom: .1rem; }
.prow--head .lbl { padding: 0 .3rem; font-size: .76rem; }
.prow--head .lbl:nth-child(2), .prow--head .lbl:nth-child(3) { text-align: center; }
.prow .line::placeholder { color: transparent; }

.notes { margin-top: 2.9rem; }
.notes__area { min-height: calc(var(--row-h) * 14); }

/* ─────────── page 3 ─────────── */

.p3-cols {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.9rem 1.8rem; align-items: start;
  margin-top: 2.9rem;
}
.arow { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 0 .8rem; align-items: start; }

/* ─────────── footer & toast ─────────── */

.footer {
  max-width: 46rem; margin: 0 auto; padding: 0 1rem 2.6rem;
  color: rgba(236, 234, 228, .6); font-size: .85rem; text-align: center;
}
.footer b { color: rgba(236, 234, 228, .85); }

.toast {
  position: fixed; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); z-index: 80;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: .9rem;
  max-width: calc(100vw - 2rem);
  padding: .65rem .75rem .65rem 1.05rem;
  background: #1d1f22; color: #f3f1ea;
  border-radius: .65rem; box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.toast button { padding: .25rem .45rem; border: 0; border-radius: .35rem; background: none; color: #ffb4a8; font-weight: 700; }
.toast button:hover { background: rgba(255, 255, 255, .08); }

/* ─────────── responsive ─────────── */

/* Tables adapt to the width of their own panel, which depends on the page layout. */
.weapons, .armor, .skills, .prosby, .magic, .abilities, .gear { container-type: inline-size; }

@container (max-width: 30rem) {
  .armor__wrap { flex-direction: column; align-items: stretch; }
  .zo { align-self: center; }
}

@container (max-width: 33rem) {
  /* weapon name on its own line, the five numbers below it */
  .wrow { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem .45rem; }
  .wrow > .wrow__name { grid-column: 1 / -1; }
  .wrow--head > .wrow__name { display: none; }
  .rows--weapons { gap: .9rem; }
}
@container (max-width: 24rem) {
  .long { display: none; }
  .short { display: inline; }
}
@container (max-width: 34rem) {
  .skills__top { justify-content: stretch; margin-top: 0; }
  .rulebox { flex: 1 1 100%; }
  .skills__head { grid-template-columns: minmax(0, 1fr); }
  .srow--second { display: none; }
  .rows--skills { --cols: 1; }
}
@container (max-width: 36rem) {
  .prow { grid-template-columns: minmax(0, 1fr) 3.4rem 4.4rem; gap: 0 .5rem; }
  .prow > :nth-child(4) { grid-column: 1 / -1; }
  .prow--head > :nth-child(4) { display: none; }
  .rows--prosby { gap: .7rem; }
  .prow .line::placeholder { color: #c9cbce; }
}
@container (max-width: 40rem) {
  .rows--magic { --cols: 2; }
}
@container (max-width: 22rem) {
  .rows--magic, .rows--gear { --cols: 1; }
  .arow { grid-template-columns: minmax(0, 1fr); }
  .rows--abilities { gap: .7rem; }
}

@media (max-width: 979px) {
  .p1-top { grid-template-columns: minmax(0, 1fr); }
  .identity { width: 100%; max-width: 36rem; margin: 0 auto; }
  .vitals { grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 2.4rem 1.8rem; padding-top: 1rem; }
  .p1-body { grid-template-columns: minmax(0, 1fr); }
  .armor-row { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 899px) {
  .p3-cols { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 699px) {
  :root { --col-gap: 1.6rem; }

  .toolbar__inner { padding: .45rem .6rem; gap: .45rem .5rem; }
  .brand__text, .btn__text { display: none; }
  #btn-new { width: 2.3rem; padding: 0; }
  .status { font-size: .74rem; }
  .pagenav { order: 10; flex: 1 1 100%; }
  .pagenav a { flex: 1; text-align: center; }
  html { scroll-padding-top: 6.3rem; }

  main { padding: .7rem .35rem .5rem; }
  .page { margin-bottom: 1.1rem; padding: 2rem .8rem 1.3rem; }
  .panel { padding: 2.1rem .8rem .9rem; }
  .panel--list { padding-right: 1.75rem; }
  .row-del { right: -1.55rem; }
  .ribbon { left: -.6rem; }
  .ribbon__title { font-size: 1rem; }

  .identity {
    grid-template-columns: 6.6rem minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "name name name"
      "portrait left right"
      "class class class"
      "race race race";
    padding: 0 .9rem; gap: .55rem .5rem;
  }
  .banner--name { margin: 0 0 .1rem; }
  .banner--class, .banner--race { margin: 0; }
  .tag--l, .tag--r { transform: none; }
  .tag--l::before, .tag--r::after { display: none; }
  .tag .lbl { font-size: .56rem; letter-spacing: .01em; }
  .portrait { min-height: 0; align-self: center; }

  .vitals { grid-template-columns: minmax(0, 1fr); }
  .vital { gap: .8rem 1rem; }
  .stat--death, .daily { margin-left: 0; }

  .p1-body { margin-top: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ─────────── print ─────────── */

/* Each sheet prints on one A4 page: the desktop layout, scaled down through the root
   font size (everything is sized in rem). */
@media print {
  @page { size: A4; margin: 8mm; }
  html { font-size: 9.4px; scroll-padding-top: 0; }
  html, body { background: #fff; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .toolbar, .footer, .toast, .warn, .row-del, .stepper__btn,
  .portrait__actions, .portrait__empty small { display: none !important; }
  main { padding: 0; }
  .page {
    max-width: none; margin: 0; padding: 1.6rem 1.2rem 0;
    box-shadow: none; background: #fff;
    break-after: page;
  }
  .page:last-child { break-after: auto; }
  .panel, .attr, .rules, .zo { break-inside: avoid; }
  .panel { box-shadow: 0 0 0 3px #fff, 0 0 0 5px rgba(52, 55, 59, .17); }
  .line::placeholder, .box::placeholder { color: transparent; }

  .p1-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6rem 2.2rem; }
  .identity { max-width: none; }
  .vitals { grid-template-columns: minmax(0, 1fr); gap: 2.2rem; padding-top: 1.2rem; }
  .p1-body { grid-template-columns: 17.5rem minmax(0, 1fr); gap: 2rem 1.6rem; margin-top: 2rem; }
  .p1-left, .p1-right { gap: 2rem; }
  .armor-row { grid-template-columns: minmax(0, 1fr) 15.5rem; }
  .p3-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .notes { margin-top: 2.2rem; }
  .notes__area { min-height: calc(var(--row-h) * 11); }
}
