/* =========================================================================
   DnD Calculator — main stylesheet
   Theme: warm parchment + dark leather header, dragon-red accent, gold trim.
   ========================================================================= */

:root {
  --bg: #f3ecdd;
  --bg-deep: #ebe1cc;
  --surface: #fffbf2;
  --surface-2: #f6efe0;
  --surface-3: #efe4cd;
  --ink: #241c15;
  --ink-soft: #3d3228;
  --muted: #6e5f4f;
  --line: #ddceb1;
  --line-strong: #c9b48f;
  --accent: #8e1f22;
  --accent-hover: #a5262a;
  --accent-soft: #f4dcd7;
  --accent-ink: #fff8f0;
  --gold: #a87a1f;
  --gold-soft: #f3e3bd;
  --header: #1d1714;
  --header-ink: #f2e8d5;
  --header-muted: #bfae94;
  --good: #2e6b3c;
  --good-soft: #dcebdc;
  --warn: #9a6200;
  --warn-soft: #f6e6c4;
  --bad: #9b1c1c;
  --bad-soft: #f5d9d6;
  --info: #2d5a7b;
  --info-soft: #dbe7ef;
  --shadow: 0 1px 2px rgba(45, 30, 15, .06), 0 4px 16px rgba(45, 30, 15, .07);
  --radius: 12px;
  --radius-sm: 8px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Cinzel", Georgia, "Times New Roman", serif;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15110e;
    --bg-deep: #100d0b;
    --surface: #1f1915;
    --surface-2: #271f1a;
    --surface-3: #30271f;
    --ink: #efe5d3;
    --ink-soft: #ddd0bb;
    --muted: #b2a189;
    --line: #3a3028;
    --line-strong: #54463a;
    --accent: #d4574b;
    --accent-hover: #e2685c;
    --accent-soft: #3a1f1c;
    --accent-ink: #1a0f0d;
    --gold: #d9b25c;
    --gold-soft: #3a3020;
    --header: #0f0c0a;
    --good: #7cc48a;
    --good-soft: #1d3022;
    --warn: #e2b14f;
    --warn-soft: #3a2e17;
    --bad: #ef7d72;
    --bad-soft: #3d1d1a;
    --info: #86b6d8;
    --info-soft: #1a2a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0;
  font: 16px/1.6 var(--font-body);
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(ellipse at top, var(--surface-2) 0%, transparent 60%);
  background-repeat: no-repeat;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; color: var(--ink); }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.7rem, 3.6vw, 2.5rem); letter-spacing: .01em; }
h2 { font-family: var(--font-serif); font-size: clamp(1.35rem, 2.4vw, 1.6rem); }
h3 { font-family: var(--font-serif); font-size: 1.15rem; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: .5rem; background: var(--surface); padding: .5rem 1rem; z-index: 100; border-radius: var(--radius-sm); }
.skip-link:focus { left: .5rem; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }
.site-main { flex: 1 0 auto; padding-bottom: 3rem; }
.icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.25em; }

/* Edition-specific content: hide what doesn't apply */
html[data-edition="2024"] [data-only="2014"],
html[data-edition="2014"] [data-only="2024"] { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  background: var(--header);
  color: var(--header-ink);
  border-bottom: 3px solid var(--gold);
  position: relative;
  z-index: 20;
}
.site-header__inner { display: flex; align-items: center; gap: 1rem; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; }
.brand:hover { color: var(--gold-soft); }
.brand__icon { width: 34px; height: 34px; color: var(--gold); }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; letter-spacing: .03em; }
.site-nav { margin-left: auto; display: flex; gap: .25rem; align-items: center; }
.site-nav a {
  color: var(--header-ink); text-decoration: none; padding: .45rem .7rem; border-radius: 6px;
  font-size: .95rem; white-space: nowrap;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { background: rgba(255, 255, 255, .08); color: #fff; }
.site-nav__all { border: 1px solid rgba(217, 178, 92, .55); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; color: inherit; width: 44px; height: 44px; cursor: pointer; border-radius: 8px; }
.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
  display: block; width: 22px; height: 2px; background: currentColor; margin: 0 auto; position: relative; transition: transform .2s;
}
.nav-toggle__bars::before, .nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -7px; }
.nav-toggle__bars::after { top: 7px; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after { transform: translateY(-7px) rotate(-45deg); }
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--header); flex-direction: column; align-items: stretch; padding: .5rem 16px 1rem;
    border-bottom: 3px solid var(--gold);
  }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: .75rem .5rem; }
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 1rem 0 .75rem; font-size: .875rem; color: var(--muted); }
.breadcrumbs li + li::before { content: "›"; margin-right: .3rem; color: var(--line-strong); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .95rem/1 var(--font-body); padding: .7rem 1.1rem; min-height: 42px;
  border-radius: var(--radius-sm); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line-strong); }
.btn--sm { padding: .45rem .75rem; min-height: 36px; font-size: .875rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icon {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1.2rem; line-height: 1;
}
.btn-icon:hover { background: var(--surface-3); }
.btn-icon[disabled] { opacity: .35; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > label, .field__label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.field__hint { font-size: .8rem; color: var(--muted); }
input[type="number"], input[type="text"], input[type="email"], input[type="password"], input[type="url"], select, textarea {
  width: 100%; font: 1rem/1.3 var(--font-body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .6rem .7rem; min-height: 42px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input[type="number"] { font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: flex-start; gap: .55rem; cursor: pointer; font-size: .95rem; }
.check input { width: 18px; height: 18px; margin-top: .15rem; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--muted); font-size: .8rem; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button, .seg label {
  border: 0; background: transparent; padding: .5rem .85rem; font: 600 .875rem/1.2 var(--font-body); color: var(--ink-soft); cursor: pointer; min-height: 38px;
  display: inline-flex; align-items: center;
}
.seg button + button, .seg label + label { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"], .seg input:checked + span { background: var(--ink); color: var(--surface); }
.seg label { padding: 0; }
.seg label span { padding: .5rem .85rem; display: block; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: -3px; }

/* ---------- Calculator shell ---------- */
.tool-layout { display: grid; gap: 2rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .tool-layout { grid-template-columns: minmax(0, 1fr) 300px; } }
.tool-head h1 { margin-bottom: .4rem; }
.tool-intro { color: var(--ink-soft); font-size: 1.05rem; max-width: 70ch; }
.tool-intro p:last-child { margin-bottom: 0; }

.calc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin: 1.25rem 0 1.5rem; position: relative;
}
@media (min-width: 640px) { .calc { padding: 1.5rem; } }
.calc::before { /* gold trim */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent));
}
.calc__bar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.calc__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.calc__section + .calc__section { margin-top: 1.4rem; padding-top: 1.4rem; border-top: 1px dashed var(--line); }
.calc__title { font: 700 .8rem/1.2 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.calc__row { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.calc__row + .calc__row { margin-top: .9rem; }
.calc__footer { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.1rem; }

.edition-toggle { display: inline-flex; align-items: center; gap: .5rem; }
.edition-toggle__label { font: 700 .75rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.edition-toggle button {
  font: 700 .875rem/1 var(--font-body); padding: .5rem .8rem; min-height: 36px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
}
.edition-toggle button:first-of-type { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.edition-toggle button:last-of-type { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: 0; }
.edition-toggle button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Results */
.results { margin-top: 1.25rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
@media (min-width: 640px) { .results { padding: 1.25rem; } }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .75rem .85rem; min-width: 0; }
.stat__label { display: block; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat__value { display: block; font: 700 1.6rem/1.2 var(--font-serif); color: var(--ink); font-variant-numeric: tabular-nums; margin-top: .2rem; overflow-wrap: anywhere; }
.stat__sub { display: block; font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.stat--hero { border-color: var(--accent); background: linear-gradient(180deg, var(--surface), var(--accent-soft)); }
.stat--hero .stat__value { color: var(--accent); font-size: 2.1rem; }

.verdict { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; padding: .3rem .7rem; border-radius: 999px; font-size: .95rem; }
.verdict--trivial { background: var(--surface-3); color: var(--muted); }
.verdict--easy, .verdict--low { background: var(--good-soft); color: var(--good); }
.verdict--medium, .verdict--moderate { background: var(--warn-soft); color: var(--warn); }
.verdict--hard, .verdict--high { background: var(--accent-soft); color: var(--accent); }
.verdict--deadly, .verdict--beyond { background: var(--bad); color: #fff; }

.meter { position: relative; height: 14px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: .8rem 0 .4rem; }
.meter__fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--good), var(--warn), var(--accent), var(--bad)); transition: width .3s; }
.meter__ticks { position: relative; height: 1.4rem; font-size: .72rem; color: var(--muted); }
.meter__tick { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.meter__tick::before { content: ""; position: absolute; left: 50%; top: -22px; height: 16px; border-left: 2px solid var(--surface); }

.progress { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress__fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 999px; transition: width .3s; }

.notice { padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .92rem; margin: 0 0 1rem; border: 1px solid transparent; }
.notice--info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice--bad { background: var(--bad-soft); color: var(--bad); }
.notice--good { background: var(--good-soft); color: var(--good); }
.notice:empty { display: none; }

.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: var(--surface-3); color: var(--ink-soft); }
.pill--good { background: var(--good-soft); color: var(--good); }
.pill--bad { background: var(--bad-soft); color: var(--bad); }
.pill--gold { background: var(--gold-soft); color: var(--gold); }

/* Repeating rows (party members, monsters, items) */
.rows { display: flex; flex-direction: column; gap: .6rem; }
.row-item {
  display: grid; gap: .6rem; align-items: end; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .65rem;
}
.row-item .btn-icon { align-self: end; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 1.25rem; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { background: var(--surface-3); font-weight: 700; color: var(--ink-soft); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: var(--surface-2); }
td.num, th.num { text-align: right; }
tr.is-highlight td { background: var(--gold-soft) !important; font-weight: 700; }
caption { caption-side: bottom; text-align: left; padding: .5rem .7rem; font-size: .8rem; color: var(--muted); }

/* ---------- Article / prose ---------- */
.prose { max-width: 75ch; font-size: 1.02rem; }
.prose h2 { margin-top: 2rem; padding-top: .25rem; }
.prose h3 { margin-top: 1.5rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-3); padding: .1em .35em; border-radius: 4px; }
.prose .table-wrap { max-width: 100%; }
.prose blockquote { margin: 1rem 0; padding: .75rem 1rem; border-left: 4px solid var(--gold); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.callout { background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); padding: .9rem 1rem; margin: 1.25rem 0; }
.callout p:last-child { margin: 0; }
.formula { font-family: var(--font-mono); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: .75rem 1rem; margin: 0 0 1rem; overflow-x: auto; }

/* FAQ */
.faq { margin: 2.5rem 0; max-width: 75ch; }
.faq__item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: .6rem; }
.faq__item summary { cursor: pointer; padding: .85rem 1rem; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--accent); flex: none; }
.faq__item[open] summary::after { content: "−"; }
.faq__answer { padding: 0 1rem 1rem; color: var(--ink-soft); }
.faq__answer p:last-child { margin: 0; }

/* ---------- Tool cards / grids ---------- */
.tool-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.tool-card {
  display: flex; gap: .9rem; align-items: flex-start; padding: 1.1rem; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--gold); color: var(--ink); }
.tool-card__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; }
.tool-card__icon .icon { width: 26px; height: 26px; }
.tool-card__body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; flex: 1; }
.tool-card__title { font: 700 1.05rem/1.3 var(--font-serif); }
.tool-card__desc { font-size: .9rem; color: var(--muted); line-height: 1.45; }
.tool-card__arrow { width: 20px; height: 20px; color: var(--line-strong); margin-top: .2rem; transition: color .15s, transform .15s; }
.tool-card:hover .tool-card__arrow { color: var(--accent); transform: translateX(3px); }
.tool-grid--compact .tool-card { padding: .85rem; box-shadow: none; }
.tool-grid--compact .tool-card__desc { display: none; }
.tool-grid--compact .tool-card__icon { width: 38px; height: 38px; }

.related { margin-top: 2.5rem; }

/* Sidebar */
.tool-aside { display: none; }
@media (min-width: 1024px) {
  .tool-aside { display: block; }
  .tool-aside__sticky { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
}
.aside-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.aside-box__title { font: 700 .8rem/1.2 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .6rem; }
.aside-list { list-style: none; margin: 0; padding: 0; }
.aside-list a { display: flex; align-items: center; gap: .55rem; padding: .45rem .5rem; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .93rem; }
.aside-list a:hover { background: var(--surface-2); }
.aside-list a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.aside-list .icon { color: var(--accent); width: 18px; height: 18px; }

/* ---------- Ads (space reserved to avoid layout shift) ---------- */
.ad { margin: 1.5rem auto; text-align: center; min-height: 100px; }
.ad__label { display: block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: .25rem; }
.ad--below_tool, .ad--in_article { min-height: 280px; }
.ad--sidebar { min-height: 600px; margin: 0; }
.ad--footer { max-width: 1200px; padding: 0 16px; min-height: 100px; }
.ad--placeholder { display: grid; place-items: center; border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: .85rem; background: repeating-linear-gradient(45deg, transparent 0 10px, var(--surface-2) 10px 20px); }

/* ---------- Home ---------- */
.hero { padding: 3rem 0 2rem; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); margin-bottom: .5rem; }
.hero__lead { font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--ink-soft); max-width: 60ch; margin: 0 auto 1.5rem; }
.hero__badges { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.hero__badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; padding: .35rem .75rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft); }
.hero__badge .icon { color: var(--accent); width: 16px; height: 16px; }
.section { margin: 2.5rem 0; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.section__head h2 { margin: 0; }
.section__head p { margin: 0; color: var(--muted); }
.page-head { padding: 1.25rem 0 .5rem; }
.page-head p { color: var(--ink-soft); font-size: 1.05rem; max-width: 70ch; }
.content-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
@media (min-width: 640px) { .content-card { padding: 2rem; } }

/* Contact form */
.form-grid { display: grid; gap: 1rem; max-width: 640px; }
.hp-field { position: absolute; left: -5000px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--header); color: var(--header-muted); padding: 2.5rem 0 1.5rem; border-top: 3px solid var(--gold); font-size: .92rem; }
.site-footer a { color: var(--header-ink); text-decoration: none; }
.site-footer a:hover { color: var(--gold); text-decoration: underline; }
.site-footer__grid { display: grid; gap: 2rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .site-footer__grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.brand--footer { color: var(--header-ink); margin-bottom: .6rem; }
.site-footer__title { font: 700 .8rem/1.2 var(--font-body); text-transform: uppercase; letter-spacing: .1em; color: var(--gold); margin: 0 0 .75rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.site-footer__legal { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .8rem; }
.site-footer__legal p { margin: 0 0 .4rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--surface); padding: .7rem 1.1rem; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-size: .92rem; max-width: calc(100% - 32px); text-align: center;
}

/* ---------- Shared calculator widgets ---------- */
.stepper { display: inline-flex; align-items: center; gap: .35rem; }
.stepper input { width: 64px; text-align: center; font-weight: 700; padding-left: .3rem; padding-right: .3rem; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }

/* Bar chart (dice distribution, DPR by AC) */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--font-body); }
.chart .bar { fill: var(--line-strong); }
.chart .bar.is-on { fill: var(--accent); }
.chart .bar:hover { fill: var(--gold); }
.chart .axis { stroke: var(--line-strong); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .line--alt { stroke: var(--gold); stroke-dasharray: 5 4; }
.chart .dot { fill: var(--accent); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: .4rem; }
.legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: .35rem; background: var(--accent); border-radius: 2px; }
.legend i.alt { background: var(--gold); }

@media print {
  .site-header, .site-footer, .tool-aside, .ad, .calc__bar, .related, .nav-toggle { display: none !important; }
  body { background: #fff; }
  .calc { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Share link box */
.share-box { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: -.4rem 0 1.1rem; padding: .6rem .75rem; background: var(--gold-soft); border: 1px solid var(--gold); border-radius: var(--radius-sm); }
.share-box label { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.share-box input { flex: 1; min-width: 200px; min-height: 36px; font-family: var(--font-mono); font-size: .88rem; }

@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat--hero { grid-column: 1 / -1; }
}
