:root {
    --bg: #f3f7fb;
    --surface: #ffffff;
    --text: #131a2b;
    --muted: #5b677e;
    --faint: #8b95a8;
    --accent: #0689dc;
    --accent-strong: #056aa8;
    --accent-weak: #e2f2fc;
    --border: #e1e7f1;
    --border-strong: #cdd6e6;
    --shadow: 0 1px 2px rgba(19,26,43,.04), 0 8px 24px -16px rgba(19,26,43,.18);
    --good: #1a8f4c;   /* success / healthy (e.g. crit, HP ok) */
    --bad: #d23b3b;    /* danger / hostile (e.g. fumble, monster, damage) */
}
[data-theme="dark"] {
    --bg: #0b1020;
    --surface: #121a31;
    --text: #e7ecf7;
    --muted: #9aa6c2;
    --faint: #6b7896;
    --accent: #3eaaf2;
    --accent-strong: #8fcef9;
    --accent-weak: #0f2940;
    --border: #1e2942;
    --border-strong: #2a395c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 28px -18px rgba(0,0,0,.7);
    --good: #4ade80;
    --bad: #f87171;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Hanken Grotesk", system-ui, sans-serif;
    line-height: 1.6;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    transition: background .3s ease, color .3s ease;
}
.wrap { max-width: 840px; margin: 0 auto; padding: 0 24px; }
main.wrap { padding-top: 28px; }

/* Keyboard accessibility */
.skip {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    background: var(--surface); color: var(--accent);
    border: 1px solid var(--accent); border-radius: 0 0 10px 10px;
    padding: 10px 16px; font-weight: 500; text-decoration: none;
    transition: top .2s ease;
}
.skip:focus { top: 0; }
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px;
}
.tool:focus-visible { outline-offset: 4px; }

/* Header */
header {
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    position: sticky; top: 0; z-index: 10;
    backdrop-filter: saturate(160%) blur(8px);
}
.bar { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); }
.brand .mark { display: block; color: var(--accent); transition: color .3s ease; }
.brand .name {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600; font-size: 23px; letter-spacing: -.01em;
}
.brand .name b { color: var(--accent); font-weight: 600; }
.theme-btn {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; border-radius: 11px;
    border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--muted); cursor: pointer;
    transition: color .2s, border-color .2s, background .2s, transform .15s;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }
.theme-btn:active { transform: scale(.94); }
.theme-btn svg { width: 19px; height: 19px; }
.theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: block; }

/* Footer */
footer { margin-top: 72px; border-top: 1px solid var(--border); }
.foot { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; justify-content: space-between; padding: 26px 0 40px; }
.foot small { color: var(--faint); font-size: 14px; }
.foot a { color: var(--muted); text-decoration: none; font-size: 14px; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
.foot a:hover { color: var(--accent); border-color: var(--accent); }
.foot a { display: inline-flex; align-items: center; gap: 6px; }
.foot a .mark { width: auto; height: 1.05em; }

/* Inline icons - sprite in templates/components/icon-sprite.html.twig. Sized to the current
   font, inherit color via currentColor (so they track the theme like text and the logo mark). */
.icon { width: 1em; height: 1em; fill: currentColor; flex: 0 0 auto; vertical-align: -0.125em; }

/* Shared page elements */
.crumb-back {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--muted);
    text-decoration: none; margin-bottom: 10px;
    transition: color .2s;
}
.crumb-back:hover { color: var(--text); }
.crumb-back .arrow { transition: transform .2s; }
.crumb-back:hover .arrow { transform: translateX(-3px); }
.eyebrow {
    font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 14px;
}

/* Entrance */
@media (prefers-reduced-motion: no-preference) {
    .reveal { opacity: 0; transform: translateY(10px); animation: rise .6s cubic-bezier(.2,.7,.2,1) forwards; }
    @keyframes rise { to { opacity: 1; transform: none; } }
}

/* Screen-reader-only (visually hidden, still announced). */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Shared form controls - rem-scale inputs/buttons used across the tool pages.
   Pages add only their deltas (widths, flex, placement). */
.field {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem;
}
.field:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* Primary (accent-filled) button. */
.btn {
    font: inherit; cursor: pointer; border: 1px solid var(--accent); border-radius: 8px;
    background: var(--accent); color: var(--bg); padding: 0.5rem 1rem;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:focus-visible { outline-color: var(--bg); }

/* Secondary (outlined) button. */
.btn-outline {
    font: inherit; cursor: pointer; border: 1px solid var(--border-strong); border-radius: 8px;
    background: transparent; color: var(--text); padding: 0.4rem 0.8rem;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4em;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-strong); }

/* Native <select> with a custom chevron (so the arrow has breathing room). */
.select {
    font: inherit; color: var(--text); background-color: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 2rem 0.5rem 0.7rem; cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238b95a8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.65rem center; background-size: 0.7rem;
}
.select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* Segmented toggle - a row of buttons sharing one pill; the chosen one uses aria-pressed. */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; }
.seg button {
    font: inherit; font-size: 14px; padding: 8px 14px; border: 0; cursor: pointer;
    background: var(--surface); color: var(--muted); transition: background .2s, color .2s;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-weak); color: var(--accent-strong); font-weight: 600; }
