/* Minecraft Enchantment Calculator. See DESIGN.md for the reasoning. */

@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("/fonts/rubik-latin.woff2") format("woff2");
}

:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eceef4;
  --line: #d8dbe5;
  --line-strong: #b9bece;
  --ink: #161a29;
  --text: #2b3042;
  --muted: #5a6074;
  --lapis: #2443b0;
  --lapis-hover: #1c3896;
  --lapis-soft: #e6ebfb;
  --on-lapis: #ffffff;
  --glint: #6b35c8;
  --ok: #17704a;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --shadow: 0 1px 2px rgb(22 26 41 / 0.06), 0 8px 24px -12px rgb(22 26 41 / 0.18);
  --radius: 14px;
  --radius-s: 9px;
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111219;
    --surface: #191b25;
    --surface-2: #222533;
    --line: #2d3142;
    --line-strong: #41465b;
    --ink: #eef0f7;
    --text: #d3d6e2;
    --muted: #9aa0b5;
    --lapis: #93a9ff;
    --lapis-hover: #b0c0ff;
    --lapis-soft: #222b4d;
    --on-lapis: #111219;
    --glint: #c7a8ff;
    --ok: #6ad49e;
    --bad: #ff8b7d;
    --bad-soft: #3a1e1e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 28px -14px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111219;
  --surface: #191b25;
  --surface-2: #222533;
  --line: #2d3142;
  --line-strong: #41465b;
  --ink: #eef0f7;
  --text: #d3d6e2;
  --muted: #9aa0b5;
  --lapis: #93a9ff;
  --lapis-hover: #b0c0ff;
  --lapis-soft: #222b4d;
  --on-lapis: #111219;
  --glint: #c7a8ff;
  --ok: #6ad49e;
  --bad: #ff8b7d;
  --bad-soft: #3a1e1e;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 28px -14px rgb(0 0 0 / 0.7);
  color-scheme: dark;
}

/* ---------- base ---------- */
html { scrollbar-color: var(--line-strong) var(--bg); }
@media (max-width: 959px) { html { scroll-padding-bottom: 84px; } }
[id] { scroll-margin-top: 16px; }
button, label, summary, a, select { touch-action: manipulation; }
label, summary, button { -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--lapis-soft); color: var(--ink); }
h1, h2, h3 { color: var(--ink); line-height: 1.2; font-weight: 600; text-wrap: balance; }
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); letter-spacing: -0.025em; }
h2 { font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem); letter-spacing: -0.015em; }
h3 { font-size: 1.15rem; }
a { color: var(--lapis); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--lapis-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2.5px solid var(--lapis); outline-offset: 2px; border-radius: 4px; }
strong { color: var(--ink); font-weight: 600; }
.icon { width: 20px; height: 20px; flex: none; }
.num, .total-num, .cost-num, td.num { font-variant-numeric: tabular-nums; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--lapis); color: var(--on-lapis); padding: 10px 16px; border-radius: var(--radius-s); text-decoration: none; }
.skip-link:focus { top: 12px; }
.skip-link:hover { color: var(--on-lapis); background: var(--lapis-hover); }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1.05rem; white-space: nowrap; }
@media (max-width: 400px) {
  .site-header .wrap { gap: 10px; }
  .site-header .brand { font-size: 0.95rem; gap: 8px; }
  .site-header .brand-mark { width: 28px; height: 28px; }
  .theme-toggle button { width: 32px; height: 32px; }
}
.brand:hover { color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--ink); color: var(--bg); }
.brand-mark .icon { width: 22px; height: 22px; }
.nav { display: none; gap: 22px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.nav a:hover { color: var(--ink); }
@media (min-width: 760px) { .nav { display: flex; } }
.theme-toggle { display: inline-flex; margin-left: auto; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
@media (min-width: 760px) { .theme-toggle { margin-left: 8px; } }
.theme-toggle button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; }
.theme-toggle button:hover { color: var(--ink); }
.theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.theme-toggle .icon { width: 17px; height: 17px; }

/* ---------- hero ---------- */
.hero { padding-top: 28px; padding-bottom: 20px; }
@media (min-width: 960px) { .hero { padding-top: 44px; padding-bottom: 28px; } }
.hero .lede { max-width: 62ch; margin-top: 12px; font-size: 1.08rem; color: var(--text); }
.crumbs { margin-bottom: 10px; font-size: 0.92rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.checked { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 0.9rem; color: var(--muted); }
.checked .icon { width: 18px; height: 18px; margin-top: 2px; color: var(--ok); }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 0.95rem; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink); }
.btn .icon { width: 18px; height: 18px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); border-color: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.seg label { position: relative; }
.seg input, .levels input, .tile input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg span { display: grid; place-items: center; min-height: 40px; padding: 0 16px; border-radius: 8px; font-weight: 500; font-size: 0.95rem; color: var(--muted); cursor: pointer; }
.seg span:hover { color: var(--ink); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.14); }
.seg input:focus-visible + span { outline: 2.5px solid var(--lapis); outline-offset: 1px; }
.seg-wide { display: flex; }
.seg-wide label { flex: 1; }

select {
  min-height: 44px; width: 100%; max-width: 320px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
}

input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 22px; height: 22px; margin: 0;
  border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}
input[type="checkbox"]::after { content: ""; width: 12px; height: 7px; border: 2.5px solid var(--on-lapis); border-top: 0; border-right: 0; transform: translateY(-2px) rotate(-45deg) scale(0); transition: transform .12s ease; }
input[type="checkbox"]:checked { background: var(--lapis); border-color: var(--lapis); }
input[type="checkbox"]:checked::after { transform: translateY(-2px) rotate(-45deg) scale(1); }
input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.5; }

.switch { display: flex; align-items: flex-start; gap: 12px; margin-top: 16px; cursor: pointer; color: var(--ink); font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { flex: none; position: relative; width: 42px; height: 24px; margin-top: 1px; border-radius: 999px; background: var(--line-strong); transition: background-color .15s ease; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s cubic-bezier(.2, .8, .2, 1); }
.switch input:checked + .track { background: var(--lapis); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2.5px solid var(--lapis); outline-offset: 2px; }
.switch small { display: block; font-weight: 400; color: var(--muted); font-size: 0.88rem; }

/* ---------- tool ---------- */
.tool-wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 12px; }
@media (min-width: 640px) { .tool-wrap { padding: 0 24px; } }
.tool:focus:not(:focus-visible) { outline: none; }
.tool-grid { display: grid; gap: 16px; align-items: start; }
@media (min-width: 960px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr) minmax(380px, 440px); gap: 24px; }
  .result { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: thin; padding-bottom: 0 !important; }
  .result-actions { position: sticky; bottom: 0; background: var(--surface); padding-bottom: 18px; }
  .toast { left: auto; right: 24px; transform: translateY(8px); }
  .toast.is-on { transform: none; }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel:focus:not(:focus-visible) { outline: none; }
.panel-title { font-size: 1.2rem; letter-spacing: -0.01em; }
.setup { padding: 18px 16px 20px; }
@media (min-width: 640px) { .setup { padding: 22px 24px 24px; } }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 6px; }

.block { border: 0; padding: 0; margin: 0; padding-top: 18px; margin-top: 16px; border-top: 1px solid var(--line); min-width: 0; }
.block-title { padding: 0; font-weight: 600; color: var(--ink); font-size: 1.02rem; margin-bottom: 10px; }
legend.block-title { float: left; width: 100%; }
legend.block-title + * { clear: both; }
details.block > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; margin-bottom: 0; min-height: 32px; }
details.block > summary::-webkit-details-marker { display: none; }
details.block[open] > summary { margin-bottom: 12px; }
.chev { width: 18px; height: 18px; margin-left: auto; color: var(--muted); transition: transform .2s ease; }
details[open] > summary .chev { transform: rotate(180deg); }
.opt { font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.hint { font-size: 0.88rem; color: var(--muted); margin-top: 6px; }
.label { display: block; font-weight: 500; color: var(--ink); font-size: 0.95rem; margin-bottom: 6px; }
.field + .field, .field + .label { margin-top: 16px; }
.more .label { margin-top: 14px; }

/* item picker */
.item-details > summary { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer; list-style: none; background: var(--surface); }
.item-details > summary::-webkit-details-marker { display: none; }
.item-details > summary:hover { border-color: var(--ink); }
.item-details[open] > summary { border-color: var(--lapis); box-shadow: 0 0 0 1px var(--lapis); }
.item-now { display: flex; flex-direction: column; line-height: 1.25; }
.item-now-name { font-weight: 600; color: var(--ink); font-size: 1.05rem; }
.item-now-hint { font-size: 0.85rem; color: var(--lapis); }
.item-picker { padding-top: 14px; }
.item-group + .item-group { margin-top: 12px; }
.item-group-name { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.tile { position: relative; }
.tile > .icon { width: 26px; height: 26px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 74px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; text-align: center; font-size: 0.8rem; line-height: 1.2; color: var(--text); cursor: pointer; background: var(--surface); transition: border-color .12s ease, background-color .12s ease; }
.tile:hover { border-color: var(--line-strong); background: var(--surface-2); }
.tile:has(input:checked) { border-color: var(--lapis); background: var(--lapis-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--lapis); }
.tile:has(input:checked) .icon { color: var(--lapis); }
.tile:has(input:focus-visible) { outline: 2.5px solid var(--lapis); outline-offset: 2px; }

.slot-icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.slot-icon .icon { width: 24px; height: 24px; }
.slot-icon.is-book { color: var(--glint); }

/* enchantment rows */
.ench-list { list-style: none; padding: 0; margin: 8px 0 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ench { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.ench:first-child { border-top: 0; }
.ench:not(.is-disabled):hover { background: var(--surface-2); }
.ench.is-on { background: color-mix(in srgb, var(--lapis-soft) 55%, var(--surface)); }
.ench-pick { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; min-width: 0; }
.ench-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ench-name { font-weight: 500; color: var(--ink); }
.ench-meta { font-size: 0.8rem; color: var(--muted); }
.ench.is-disabled .ench-pick { cursor: not-allowed; }
.ench.is-disabled .ench-name { color: var(--muted); }
.ench-note { grid-column: 1 / -1; font-size: 0.82rem; color: var(--muted); padding-left: 34px; }
.ench-note:empty { display: none; }
.ench.is-disabled .ench-note { color: var(--bad); }
.levels { display: none; gap: 3px; }
.ench.is-on .levels { display: flex; }
.levels label { position: relative; }
.levels span { display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 4px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 0.85rem; font-weight: 500; color: var(--muted); cursor: pointer; }
.levels span:hover { border-color: var(--line-strong); color: var(--ink); }
.levels input:checked + span { background: var(--glint); border-color: var(--glint); color: var(--on-lapis); }
.levels input:disabled + span { opacity: 0.4; cursor: not-allowed; }
.levels input:focus-visible + span { outline: 2.5px solid var(--lapis); outline-offset: 1px; }
@media (max-width: 420px) {
  .ench { grid-template-columns: 1fr; }
  .levels { padding-left: 34px; }
  .levels span { min-width: 40px; height: 40px; }
}
.ench-list.is-compact .ench { padding: 8px 12px; }

/* ---------- result ---------- */
.result { padding: 18px 16px 20px; }
@media (min-width: 640px) { .result { padding: 22px 24px 24px; } }
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.result-ed { font-size: 0.85rem; color: var(--muted); }
.summary { margin-top: 14px; padding: 16px; border-radius: 12px; background: var(--surface-2); }
.total { display: flex; align-items: baseline; gap: 10px; color: var(--ink); line-height: 1; }
.total-num { font-size: 3.2rem; font-weight: 600; letter-spacing: -0.03em; }
.total-unit { font-size: 1.05rem; color: var(--text); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 0.78rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.facts .of { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.facts .is-bad dd, .facts .is-bad dt, .facts .is-bad .of { color: var(--bad); }
.verdict { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 0.92rem; }
.verdict .icon { width: 18px; height: 18px; margin-top: 3px; color: var(--ok); }
.result-how { margin-top: 14px; font-size: 0.88rem; color: var(--muted); }

.steps { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; counter-reset: none; }
.step { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.step-num { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.anvil-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "a cost" "op cost" "b cost"; column-gap: 12px; }
.anvil-row > .slot:first-child { grid-area: a; }
.anvil-row > .op { grid-area: op; width: 42px; display: grid; place-items: center; height: 20px; color: var(--muted); }
.anvil-row > .op .icon { width: 14px; height: 14px; }
.anvil-row > .slot:nth-of-type(2) { grid-area: b; }
.slot { display: flex; align-items: center; gap: 10px; min-width: 0; }
.slot-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.slot-title { font-weight: 500; color: var(--ink); font-size: 0.95rem; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip { font-size: 0.78rem; line-height: 1.3; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--glint); font-weight: 500; }
.cost { grid-area: cost; align-self: center; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 64px; padding: 8px 6px; border-radius: 10px; background: var(--lapis-soft); color: var(--ink); }
.cost-num { font-size: 1.6rem; font-weight: 600; line-height: 1; }
.cost-unit { font-size: 0.75rem; color: var(--text); margin-top: 3px; }
.step-meta { margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.step.is-bad { border-color: var(--bad); }
.step.is-bad .cost { background: var(--bad-soft); color: var(--bad); }
.step.is-bad .cost-unit, .step.is-bad .step-meta { color: var(--bad); }
.result-done { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 0.92rem; color: var(--ink); }
.result-done .icon { color: var(--ok); width: 18px; height: 18px; }
.result-done.is-bad { color: var(--bad); font-weight: 500; }
.result-done.is-bad .icon { color: var(--bad); }
.side { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 5px; border: 1px solid var(--line-strong); font-size: 0.72rem; font-weight: 600; line-height: 1.5; color: var(--muted); vertical-align: 1px; }
.empty .btn { margin-top: 12px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

.empty { display: flex; gap: 14px; align-items: flex-start; margin-top: 16px; padding: 18px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--text); }
.empty-icon { width: 36px; height: 36px; color: var(--muted); }
.notice { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; padding: 14px; border-radius: 12px; font-size: 0.92rem; }
.notice.is-bad { background: var(--bad-soft); color: var(--ink); border: 1px solid var(--bad); }
.notice.is-bad > .icon { color: var(--bad); margin-top: 2px; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

.jump { position: fixed; left: 50%; bottom: 16px; z-index: 30; transform: translateX(-50%); display: inline-flex; align-items: center; min-height: 46px; padding: 0 20px; border-radius: 999px; background: var(--lapis); color: var(--on-lapis); font-weight: 500; text-decoration: none; box-shadow: 0 8px 24px -8px rgb(0 0 0 / 0.45); white-space: nowrap; }
.jump:hover { color: var(--on-lapis); background: var(--lapis-hover); }
.jump.is-bad, .jump.is-bad:hover { background: var(--bad); color: var(--on-lapis); }
.jump[hidden] { display: none; }
.toast { position: fixed; left: 50%; bottom: 76px; z-index: 40; max-width: min(92vw, 460px); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 0.92rem; box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.5); opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .2s ease, transform .25s cubic-bezier(.2, .8, .2, 1); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }
.toast { display: flex; align-items: center; gap: 14px; }
.toast.is-on { pointer-events: auto; }
.toast button { flex: none; min-height: 36px; padding: 0 12px; border: 1px solid currentColor; border-radius: 8px; background: transparent; color: inherit; font-weight: 600; cursor: pointer; }
.toast button:hover { background: rgb(127 127 127 / 0.2); }

/* ---------- content ---------- */
.content { padding-top: 48px; padding-bottom: 64px; }
.content > * { max-width: 860px; }
.content .table-wrap { margin-top: 16px; }
.content > section + section { margin-top: 48px; }
.content h2 { margin-bottom: 14px; }
.content h3 { margin: 26px 0 8px; }
.content p, .content li { max-width: 64ch; }
p, li { text-wrap: pretty; }
.content p + p, .content p + ul, .content ul + p, .content p + ol, .content ol + p, .content .table-wrap + p, .content p + .table-wrap { margin-top: 14px; }
.content ul, .content ol { padding-left: 22px; }
.content li + li { margin-top: 6px; }
.howto { counter-reset: how; list-style: none; padding-left: 0 !important; }
.howto li { counter-increment: how; position: relative; padding-left: 44px; }
.howto li + li { margin-top: 14px; }
.howto li::before { content: counter(how); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.92rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.table-wrap.is-narrow { max-width: 640px; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
thead th { border-top: 0; background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 0.86rem; white-space: nowrap; }
tbody th { color: var(--ink); font-weight: 500; }
.num { text-align: right; white-space: nowrap; }
.ench-cell { color: var(--glint); font-weight: 500; white-space: nowrap; }

.faq details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.faq details + details { margin-top: 8px; }
.faq summary { display: flex; justify-content: space-between; gap: 16px; padding: 14px 16px; cursor: pointer; list-style: none; font-weight: 500; color: var(--ink); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; flex: none; width: 24px; text-align: center; font-size: 1.3rem; line-height: 1.2; color: var(--muted); transition: transform .2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { padding: 0 16px 16px; }

.related { list-style: none; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 8px; }
.related li + li { margin-top: 0; }
.related a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 0.95rem; }
.related a:hover { border-color: var(--lapis); color: var(--lapis); }
.related .icon { width: 18px; height: 18px; color: var(--muted); }

/* ---------- legal and 404 ---------- */
.legal main, .notfound { max-width: 760px; padding-top: 40px; padding-bottom: 64px; }
.legal h1 { margin-bottom: 8px; }
.legal h2 { font-size: 1.25rem; margin-top: 32px; margin-bottom: 8px; }
.legal p + p, .legal ul { margin-top: 10px; }
.legal ul { padding-left: 22px; }
.notfound p { margin-top: 12px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 32px 0 40px; font-size: 0.92rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 20px 40px; justify-content: space-between; }
.site-footer p { margin-top: 10px; max-width: 60ch; }
.site-footer nav { display: flex; gap: 18px; align-items: flex-start; }
.site-footer nav a { color: var(--muted); }
.site-footer nav a:hover { color: var(--ink); }
.site-footer .brand { font-size: 1rem; }

@media print {
  .site-header, .site-footer, .setup, .result-actions, .jump, .toast, .content { display: none; }
  .tool-grid { display: block; }
  .panel { box-shadow: none; border: 0; }
}
