/* ==========================================================================
   Tools — the calculator bench
   ==========================================================================
   The index is a working bench: three task bays on one field, with the planner
   as the rail under them. A calculator is a worksheet: a masthead, an input
   column, the answer, and the reference figures, divided by rules instead of
   wrapped in a card. The app's existing palette and type do the rest. */

/* The old tools sheet locked the document to one screen. The index may scroll
   once the bays stack; the desktop calculator remains one worksheet. */
html:has(.toolview-hub),
body:has(.toolview-hub) { overflow: auto; overscroll-behavior: auto; }

.shell[data-screen="tools"] .workspace,
.shell[data-screen="tools"] .list-card,
.shell[data-screen="tools"] #board { overflow: visible; }

/* The tool colour is the one piece of identity a row carries. */
.tool-high-alch-calculator { --tool-tone: #f6bd3a; }
.tool-ge-tax-calculator { --tool-tone: #f6bd3a; }
.tool-flip-optimizer { --tool-tone: #9cb3ff; }

.toolview { min-width: 0; min-height: 0; }
/* A calculator card is its content, not the board's leftover height: a short
   answer (seven levels and their routes) used to leave a hand's width of empty
   paper under the last row. The card sits in a row flex, so its height is the
   cross axis' to give: `align-self` is what stops the stretch. The board keeps
   the page's own ground below it. */
@media (min-width: 901px) {
  .shell[data-screen="tools"] #board .toolview-calc {
    flex: 0 1 auto;
    align-self: flex-start;
    /* A long sheet still takes the window and scrolls inside its table; a
       short one stops where it ends. */
    max-height: 100%;
  }
}

/* ---------------------------------------------------------------- index ---- */

.toolview-hub {
  flex: 1 1 auto; display: flex; flex-direction: column;
  min-height: 0; padding: 0;
  border: 0; border-radius: 0; background: transparent;
  overflow: visible;
}

.bench-head {
  flex: 0 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: end; gap: 28px;
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
}
.bench-head h2 {
  max-width: 20em; margin: 0;
  color: var(--ink); font-family: var(--sans); font-size: var(--text-title);
  font-weight: var(--fw-display); letter-spacing: var(--track-display); line-height: var(--leading-display);
  text-wrap: balance;
}
.bench-head .page-mast-lede {
  max-width: 54ch; margin: 7px 0 0;
  color: var(--ink-3); font-size: var(--text-body); line-height: 1.45;
}

.bench-body {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: start;
  margin: 0;
}
.bench-group {
  min-width: 0; display: flex; flex-direction: column;
  padding: 22px 26px 24px;
  border-left: 1px solid var(--line);
}
.bench-group:first-child { padding-left: 0; border-left: 0; }
.bench-group:last-of-type { padding-right: 0; }
.bench-group-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
}
.bench-group-head h3 {
  margin: 0; color: var(--ink);
  font-size: var(--text-body); font-weight: var(--fw-medium); letter-spacing: 0; line-height: var(--leading-heading);
}
.bench-list {
  display: flex; flex: 1 1 auto; flex-direction: column;
  margin-top: 12px;
}
.bench-tool {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 15px;
  flex: 1 1 0; align-items: center; gap: 12px;
  min-width: 0; min-height: 56px; padding: 15px 0;
  border-top: 1px solid var(--line-soft);
  color: var(--ink); text-decoration: none;
  transition: background var(--t-quick) var(--ease),
              border-color var(--t-quick) var(--ease);
}
.bench-tool:hover {
  background: color-mix(in srgb, var(--tool-tone) 5%, transparent);
  border-color: color-mix(in srgb, var(--tool-tone) 32%, var(--line-soft));
}
.bench-tool-icon,
.bench-plan-icon {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 1px solid color-mix(in srgb, var(--tool-tone) 32%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--tool-tone) 10%, var(--field-2));
  color: var(--tool-tone);
}
.bench-tool-icon .tool-icon,
.bench-plan-icon .tool-icon { width: 17px; height: 17px; }
.bench-tool-img, .bench-plan-img, .calc-tool-img {
  display: block; object-fit: contain;
  image-rendering: pixelated;
}
.bench-tool-img { width: 24px; height: 24px; }
.bench-plan-img { width: 25px; height: 25px; }
.bench-tool-copy { min-width: 0; }
.bench-tool-copy b {
  display: block; overflow: hidden;
  color: var(--ink); font-size: var(--text-body); font-weight: var(--fw-medium);
  letter-spacing: 0; line-height: var(--leading-heading); text-overflow: ellipsis;
  white-space: nowrap;
}
.bench-tool-copy small {
  display: block; margin-top: 3px;
  color: var(--ink-4); font-size: var(--text-label); line-height: var(--leading-label);
}
.bench-tool-go {
  display: flex; align-items: center; justify-content: flex-end;
  color: var(--tool-tone);
}
.bench-tool-go .tool-icon { width: 15px; height: 15px; transition: transform var(--t-quick); }
.bench-tool:hover .bench-tool-go .tool-icon { transform: translateX(2px); }

.bench-plan {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center; gap: 14px;
  min-width: 0; margin-top: 22px; padding: 17px 0 19px;
  border-top: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.bench-plan:hover { border-color: var(--accent-line); }
.bench-plan-icon {
  width: 38px; height: 38px;
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.bench-plan-copy b {
  display: block; color: var(--ink);
  font-size: var(--text-body); font-weight: var(--fw-medium); letter-spacing: 0;
}
.bench-plan-copy small {
  display: block; margin-top: 2px;
  color: var(--ink-4); font-size: var(--text-label); line-height: var(--leading-label);
}
.bench-plan-go {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent); font-size: var(--text-label); white-space: nowrap;
}
.bench-plan-go .tool-icon { width: 15px; height: 15px; transition: transform var(--t-quick); }
.bench-plan:hover .bench-plan-go .tool-icon { transform: translateX(2px); }

/* ------------------------------------------------------------ calculator ---- */

.shell[data-screen="tools"] .toolview-calc {
  flex: 1 1 auto; display: flex; flex-direction: column;
  min-height: 0; padding: 0;
  border: 0; border-radius: 0; background: transparent;
  overflow: hidden;
}
.calc-mast .hb-crumbs {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin: 0 0 14px;
  color: var(--ink-4); font-size: var(--text-label);
}
.calc-mast .hb-crumbs a { color: var(--ink-3); text-decoration: none; }
.calc-mast .hb-crumbs a:hover { color: var(--accent); }
.calc-icon .tool-icon { width: 19px; height: 19px; }
.calc-mast .tool-more > summary .tool-icon { width: 14px; height: 14px; }

.calc-desk {
  flex: 1 1 auto; display: flex;
  min-height: 0; overflow: hidden;
}
.calc-desk > * { min-width: 0; min-height: 0; flex: 1 1 auto; }
.calc-hiscore-note {
  flex: 1 1 240px; margin: 0; color: var(--ink-4);
  font-size: var(--text-label); line-height: var(--leading-label);
}
.calc-hiscore-note.ok { color: var(--ink-3); }
.calc-hiscore-note.bad { color: var(--down); }

.calcview .tool-surface {
  padding: 22px 24px;
  border: 0; border-radius: 0; background: transparent;
}
.calcview .tool-head {
  padding: 0 0 14px; margin: 0;
  border: 0; align-items: flex-start;
}
.calcview .tool-head h2,
.calcview .tool-head h3 {
  color: var(--ink-2); font-size: var(--text-label); font-weight: var(--fw-medium);
  letter-spacing: 0; line-height: var(--leading-label);
}
.calcview .tool-head-icon { display: none; }
.calcview .tool-field-head { margin-bottom: 5px; }
.calcview .tool-field-head label,
.calcview .tool-field-label {
  color: var(--ink-3); font-size: var(--text-label); font-weight: var(--fw-regular);
}
.calcview .tool-input input,
.calcview .tool-select {
  height: 40px; padding-left: 10px;
  border-radius: 6px; border-color: var(--line);
  background: var(--bg-2); font-size: var(--text-body);
}
.calcview .tool-input em { right: 10px; color: var(--ink-4); }
.calcview .tool-check { min-height: 40px; border-radius: 6px; font-size: var(--text-label); }
.calcview .tool-check b { font-size: var(--text-label); }
.calcview .tool-actions { margin-top: 16px; }
.calcview .tool-run { height: 42px; border-radius: 6px; font-size: var(--text-label); }
.calcview .tool-reset { height: 32px; border-radius: 6px; font-size: var(--text-label); }
.calcview .tool-hero-label { color: var(--ink-4); font-size: var(--text-label); }
.calcview .tool-footnote { color: var(--ink-4); font-size: var(--text-label); }
.calcview .tool-item-img {
  width: 16px; height: 16px; flex: 0 0 auto;
  object-fit: contain; image-rendering: pixelated;
}

.calcview .data-answer > b,
.calcview .tax-profit b,
.calcview .alch-profit > b,
.calcview .limit-hero b {
  color: var(--ink); font-size: var(--text-title);
  line-height: var(--leading-tight); letter-spacing: 0;
}

/* ------------------------------------------------------------- tax / alch --- */

.calcview .tax-desk,
.calcview .alch-desk,
.calcview .limit-desk {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}
.calcview .tax-ticket,
.calcview .alch-setup,
.calcview .limit-setup {
  padding: 22px 26px;
  border-right: 1px solid var(--line);
}
.calcview .tax-receipt,
.calcview .alch-result,
.calcview .limit-result { padding: 22px 28px 18px; }
.calcview .tax-fields { max-width: 320px; }
.calcview .tax-submit .tool-actions,
.calcview .alch-submit .tool-actions,
.calcview .limit-submit .tool-actions { margin: 0; }
.calcview .tax-receipt-body {
  grid-template-columns: minmax(0, 1.15fr) minmax(240px, .85fr);
}
.calcview .tax-profit { padding-right: 26px; }
.calcview .tax-key { padding-left: 26px; }
.calcview .tax-equation { padding-right: 26px; }
.calcview .tax-audit { padding-left: 26px; }
.calcview .tax-equation,
.calcview .tax-audit { display: flex; flex-direction: column; justify-content: flex-start; }
.calcview .tax-equation > div,
.calcview .tax-audit > div { min-height: 38px; }
.calcview .tax-key dt,
.calcview .tax-audit dt { font-size: var(--text-label); }
.calcview .tax-profit b { margin-top: 8px; }
.calcview .alch-profit { padding-right: 26px; }
.calcview .alch-batch-sheet { padding-left: 26px; }
.calcview .alch-scale > div { padding-left: 16px; }
.calcview .alch-scale > div:first-child { padding-left: 0; }
.calcview .limit-cycle { padding-right: 24px; }
.calcview .limit-unit { padding-left: 24px; }

/* ---------------------------------------------------------------- data ----- */

/* A data tool has two columns: the form owns the left rail all the way down;
   the answer and its reference table share the right. The old third column left
   a tall empty strip whenever a table was short. */
.calcview .data-desk {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}
.calcview .data-form {
  grid-column: 1; grid-row: 1 / -1;
  align-self: stretch;
  padding: 22px 24px;
  border-right: 1px solid var(--line);
  overflow: auto;
}
.calcview .data-result {
  grid-column: 2; grid-row: 1;
  padding: 22px 28px 18px;
  border-right: 0; border-bottom: 1px solid var(--line-soft);
}
.calcview .data-table {
  grid-column: 2; grid-row: 2;
  align-self: stretch; min-height: 0;
  padding: 18px 28px 20px;
  border: 0; overflow: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.calcview .data-table .tool-head { padding-bottom: 10px; }
.calcview .data-scroll { min-height: 0; }
.calcview .data-grid td { padding-top: 5px; padding-bottom: 5px; }
.calcview .data-result .tool-footnote { margin-top: 12px; }
.calcview .data-form .tool-actions { margin-top: 16px; }
.calcview .data-form .tool-run { height: 42px; }
.calcview .data-note,
.calcview .data-warning { border-radius: 6px; }

/* ------------------------------------------------------------- plan sheet --- */

/* The goal and its switches own the left rail. The answer is the bill of
   materials, not a price; the ledger underneath compares the methods that
   share the same goal. One surface, three rules, no nested cards. */
.calcview .plan-desk {
  display: grid;
  grid-template-columns: minmax(286px, 330px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}
.calcview .plan-form {
  grid-column: 1; grid-row: 1 / -1;
  min-width: 0; min-height: 0; max-width: 100%; padding: 16px 20px;
  border-right: 1px solid var(--line);
  overflow: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.calcview .plan-toggle {
  display: flex; align-items: flex-start; gap: 7px;
  min-width: 0; min-height: 36px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-2); cursor: pointer;
  transition: border-color var(--t-quick) var(--ease),
              background var(--t-quick) var(--ease);
}
.calcview .plan-toggle:hover { border-color: var(--line-strong); }
.calcview .plan-toggle:not(:has(small)) { align-items: center; }
.calcview .plan-toggle:not(:has(small)) input { margin-top: 0; }
.calcview .plan-form .tool-actions { margin-top: 12px; }

.calcview .plan-answer {
  grid-column: 2; grid-row: 1;
  min-width: 0; padding: 20px 26px 16px;
  border: 0; border-bottom: 1px solid var(--line-soft);
}
/* A third material has no partner in a two-column bill. Spanning the row
   finishes its rule instead of leaving it under a half-empty line. */
.plan-mat-icon .tool-item-img {
  width: 24px; height: 24px;
  object-fit: contain; image-rendering: pixelated;
}
.plan-mat.primary strong { color: var(--accent); font-size: var(--text-heading); }
/* The live answer dims while its GET is in flight; the live region carries the
   same news for a screen reader when it lands. */
/* Six facts are two ruled rows, not six cells that run together: without the
   rule the second row reads as another line inside the first row's cells. */
@media (min-width: 761px) {
}
.plan-facts dd.up { color: var(--up); }
.plan-facts dd.down { color: var(--down); }

.calcview .plan-ledger {
  grid-column: 2; grid-row: 2;
  min-width: 0; min-height: 0;
  padding: 16px 26px 18px;
  border: 0; overflow: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
/* Auto layout keeps "1,076,653 gp" whole; a fixed table clipped it to
   "1,076,6…" at laptop widths. The wrapper scrolls instead. */
.calcview .plan-table th {
  padding: 0 6px 6px;
  color: var(--ink-4); font: var(--fw-regular) var(--text-micro) var(--sans); font-weight: var(--fw-regular);
  text-align: right; text-transform: none; white-space: nowrap;
}
.calcview .plan-table th:first-child { text-align: left; }
.calcview .plan-table th:first-child,
.calcview .plan-table td:first-child { width: 32%; min-width: 190px; }
.calcview .plan-table td {
  padding: 5px 6px;
  border-color: var(--line-soft);
  font-size: var(--text-label); text-align: right;
}
.calcview .plan-table td:first-child { text-align: left; font-family: var(--sans); font-weight: var(--fw-regular); }
.calcview .plan-table .data-name { font-size: var(--text-label); }
.calcview .plan-table .data-sub { font-size: var(--text-label); }
.calcview .plan-table .data-item { gap: 6px; }
/* The chosen bar is one of eight rows; without this the reader has to find it
   again in the comparison table. */
.calcview .plan-table tbody tr.is-current td {
  background: color-mix(in srgb, var(--tool-tone) 7%, transparent);
}
/* Six money columns do not fit the answer's 515px at 1024. Tightening the
   gutters and the name column keeps every figure visible without a scroll. */
@media (min-width: 901px) and (max-width: 1200px) {
  .calcview .plan-table th:first-child,
  .calcview .plan-table td:first-child { width: 25%; min-width: 132px; }
  .calcview .plan-table th,
  .calcview .plan-table td { padding-left: 3px; padding-right: 3px; }
}

/* ---------------------------------------------------------------- foot ------ */

/* Related calculators are a quiet band under the mast, not a second menu: one
   hairline, an inline label, and the shelf's names as plain links. */
.calc-related {
  flex: 0 0 auto;
  padding: 10px 24px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.calc-related-line {
  margin: 0;
  color: var(--ink-3);
  font-size: var(--text-label);
  line-height: 1.7;
}
.calc-related-kicker {
  margin-right: 10px;
  color: var(--ink-2);
  font-weight: 500;
}
.shell[data-screen="tools"] .calc-related-line a {
  color: var(--ink-3);
  text-decoration: none;
}
.shell[data-screen="tools"] .calc-related-line a:hover,
.shell[data-screen="tools"] .calc-related-line a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.calc-related-line .sep {
  margin: 0 8px;
  color: var(--line);
}
@media (max-width: 760px) {
  .calc-related { padding: 10px 16px 12px; }
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 1100px) {
  .bench-group { padding-left: 20px; padding-right: 20px; }
  .bench-group:first-child { padding-left: 0; }
  .bench-group:last-of-type { padding-right: 0; }
  .calcview .tax-desk,
  .calcview .alch-desk,
  .calcview .limit-desk { grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); }
  .calcview .data-desk { grid-template-columns: minmax(260px, 310px) minmax(0, 1fr); }
}

@media (max-width: 1000px) {
  /* At tablet width the receipt's fixed 240px audit column squeezed the big
     profit figure below its own width. Stack the receipt before it gets tight. */
  .calcview .tax-receipt-body { display: block; }
  .calcview .tax-profit { padding-right: 0; border-right: 0; padding-bottom: 16px; }
  .calcview .tax-key {
    padding-left: 0; padding-top: 12px;
    border-left: 0; border-top: 1px solid var(--line-soft);
  }
  .calcview .tax-equation { padding-right: 0; border-right: 0; }
  .calcview .tax-audit {
    padding-left: 0; margin-top: 10px;
    border-left: 0; border-top: 1px solid var(--line-soft);
  }
}

@media (max-width: 900px) {
  html:has(.toolview-hub),
  body:has(.toolview-hub),
  html:has(.toolview-calc),
  body:has(.toolview-calc) { overflow: auto; overscroll-behavior: auto; }

  /* The app shell is a fixed one-screen frame on desktop. The tools index and
     the stacked worksheets need to grow instead: let the shell, board and
     article be their content height, and clear the fixed tab bar. */
  #shell[data-screen="tools"] { height: auto; min-height: 100dvh; overflow: visible; }
  #shell[data-screen="tools"] .workspace {
    height: auto; min-height: 0; overflow: visible;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
  #shell[data-screen="tools"] .list-card,
  #shell[data-screen="tools"] #board {
    height: auto; min-height: 0; overflow: visible;
  }
  #shell[data-screen="tools"] .toolview-hub,
  #shell[data-screen="tools"] .toolview-calc {
    height: auto; min-height: 0; flex: 0 0 auto; overflow: visible;
  }
  .bench-tool { flex: 0 0 auto; min-height: 0; }
  .calc-desk { flex: 0 0 auto; }

  .bench-head { grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 14px; }
  .bench-body { display: flex; flex-direction: column; }
  .bench-group {
    padding: 18px 0 20px;
    border-top: 1px solid var(--line); border-left: 0;
  }
  .bench-group:first-child { border-top: 0; padding-top: 20px; }
  .bench-plan { margin-top: 10px; }
  .bench-plan-copy { min-width: 0; }
  .bench-plan-go { grid-column: 2 / -1; justify-self: start; }
  .bench-plan { grid-template-columns: 38px minmax(0, 1fr); row-gap: 4px; }

  .calcview .data-desk { grid-template-columns: minmax(250px, 290px) minmax(0, 1fr); }
  .calcview .data-table { display: none; }
  .calcview .data-result { border-bottom: 0; }
}

@media (max-width: 760px) {
  .calcview { flex: 0 0 auto; min-height: calc(100dvh - 60px); overflow: visible; }
  .calc-mast .hb-crumbs { margin-bottom: 12px; }
  .calc-icon .tool-icon { width: 17px; height: 17px; }
  .calc-desk { display: block; overflow: visible; }
  .calcview .tax-desk,
  .calcview .alch-desk,
  .calcview .limit-desk,
  .calcview .data-desk { display: flex; flex-direction: column; }
  .calcview .tax-ticket,
  .calcview .alch-setup,
  .calcview .limit-setup,
  .calcview .data-form {
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 16px;
  }
  .calcview .tax-receipt,
  .calcview .alch-result,
  .calcview .limit-result,
  .calcview .data-result,
  .calcview .data-table { padding: 16px; }
  .calcview .data-form { overflow: visible; }
  .calcview .data-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calcview .alch-fields,
  .calcview .limit-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calcview .alch-answer { grid-template-columns: minmax(0, 1fr); }
  .calcview .alch-profit { padding-right: 0; border-right: 0; padding-bottom: 14px; }
  .calcview .alch-batch-sheet { padding-left: 0; border-top: 1px solid var(--line-soft); padding-top: 12px; }
  .calcview .tax-receipt-body { display: block; }
  .calcview .tax-profit { padding-right: 0; border-right: 0; padding-bottom: 14px; }
  .calcview .tax-key { padding-left: 0; border-top: 1px solid var(--line-soft); padding-top: 10px; }
  .calcview .tax-equation,
  .calcview .tax-audit { padding: 10px 0 0; border-right: 0; }
  .calcview .tax-audit { border-top: 1px solid var(--line-soft); margin-top: 8px; }
  .calcview .limit-board { display: block; }
  .calcview .limit-hero { padding-bottom: 14px; }
  .calcview .limit-cycle { padding: 14px 0; border-top: 1px solid var(--line-soft); }
  .calcview .limit-unit { padding: 14px 0 0; border-left: 0; border-top: 1px solid var(--line-soft); }
}

@media (max-width: 440px) {
  .bench-head h2 { font-size: var(--text-title); }
  .bench-plan { grid-template-columns: 34px minmax(0, 1fr); }
  .bench-plan-icon { width: 34px; height: 34px; }
  .bench-plan-copy b { font-size: var(--text-body); }
  .bench-plan-go { grid-column: 1 / -1; padding-left: 48px; }
  .calcview .data-field-grid { grid-template-columns: minmax(0, 1fr); }
  .calcview .alch-scale { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calcview .alch-scale > div:nth-child(3) { border-left: 0; padding-left: 0; }
}

/* The plan sheet stacks before its rail gets too narrow. The ledger leaves
   first, matching the old reference tables; the goal and the bill stay. */
@media (max-width: 900px) {
  .calcview .plan-desk {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
  }
  .calcview .plan-form {
    grid-column: 1; grid-row: 1;
    border-right: 0; border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .calcview .plan-answer {
    grid-column: 1; grid-row: 2;
    border-bottom: 0;
  }
  .calcview .plan-ledger { display: none; }
  .calcview .plan-desk[data-goal] .plan-answer,
  .calcview .plan-desk[data-error] .plan-answer {
    grid-row: 1;
    border-bottom: 1px solid var(--line-soft);
  }
  .calcview .plan-desk[data-goal] .plan-form,
  .calcview .plan-desk[data-error] .plan-form {
    grid-row: 2;
    border-bottom: 0;
  }
}

@media (max-width: 760px) {
  .calcview .plan-form,
  .calcview .plan-answer { padding: 16px; }
  .calc-desk,
  .plan-desk,
  .plan-form,
  .plan-answer { width: 100%; min-width: 0; max-width: 100%; }
}

@media (max-width: 440px) {
  .plan-mat.primary strong { font-size: var(--text-title); }
}

@media (min-width: 901px) and (max-height: 950px) {
  .calcview .plan-form { padding: 12px 18px; }
  .calcview .plan-form .tool-actions { margin-top: 10px; }
}

@media (min-width: 901px) and (max-height: 820px) {
  .calcview .plan-form { padding: 12px 16px; }
  .calcview .plan-form .tool-input input,
  .calcview .plan-form .tool-select { height: 36px; }
  .calcview .plan-toggle { min-height: 28px; padding: 4px 8px; }
  .calcview .plan-form .tool-actions { margin-top: 6px; }
  .calcview .plan-answer { padding: 14px 20px 12px; }
  .calcview .plan-ledger { padding: 10px 20px 12px; }
  .plan-mat.primary strong { font-size: var(--text-heading); }
  .calcview .plan-table td { padding: 3px 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .bench-tool,
  .bench-tool-go .tool-icon,
  .bench-plan,
  .bench-plan-go .tool-icon { animation: none; transition: none; }
}
/* --------------------------------------------------------------- alchemy --- */
/* The finder is the market ledger in alchemy clothes: the same near-black
   ground, compact rows, hairline group divisions, and highlighter-amber
   selection as the board beside it. The rune quote reads as a tape, not a
   card; profit is the only loud figure in the table. */

.alchview {
  --alch-accent: var(--accent);


  flex: 1 1 auto; display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}

.alch-mast {
  flex: 0 0 auto; padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
}
.alch-mast-side {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 12px;
}

.alch-rune {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; padding: 0;
  border: 0; background: transparent;
}
.alch-rune-icon { display: grid; place-items: center; width: 26px; height: 26px; }
.alch-rune-icon img {
  display: block; width: 24px; height: 24px;
  object-fit: contain; image-rendering: pixelated;
}
.alch-rune-icon .tool-icon { width: 20px; height: 20px; color: var(--alch-accent); }
.alch-rune-copy { min-width: 0; }
.alch-rune-label {
  display: block; color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  letter-spacing: 0; white-space: nowrap;
}
.alch-rune-copy b {
  display: block; margin-top: 3px;
  color: var(--ink-2);
  font: var(--fw-medium) var(--text-body)/1.2 var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.alch-pulse {
  display: inline-block; width: 5px; height: 5px; margin-right: 5px;
  border-radius: 999px; background: var(--alch-accent);
  animation: alch-pulse 2.8s var(--ease) infinite;
}
@keyframes alch-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.alch-desk { flex-direction: column; }
.alch-desk > .alch-filters { flex: 0 0 auto; }
.alch-desk > .alch-board { flex: 1 1 auto; }
.alch-filters {
  flex: 0 0 auto; display: flex; align-items: flex-end; flex-wrap: wrap;
  gap: 10px 22px; padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.alch-set { min-width: 0; margin: 0; padding: 0; border: 0; }
.alch-seg {
  display: inline-flex; overflow: hidden;
  border: 1px solid var(--line); border-radius: 4px;
  background: transparent;
}
.alch-choice { position: relative; display: block; min-width: 0; }
.alch-choice input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
}
.alch-choice span {
  display: flex; align-items: center; justify-content: center;
  min-height: 28px; padding: 0 9px;
  border-left: 1px solid var(--line);
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/var(--leading-heading) var(--mono);
  letter-spacing: 0; text-align: center;
  white-space: nowrap;
  transition: color var(--t-quick) var(--ease),
              background var(--t-quick) var(--ease);
}
.alch-choice:first-child span { border-left: 0; }
.alch-choice span:hover { color: var(--ink); background: var(--hover); }
/* The chosen segment is a neutral plate: the calculator's controls should not
   compete with the ledger's amber, and the state still reads from the fill. */
.alch-choice:has(input:checked) span {
  background: var(--field); color: var(--ink);
}
.alch-choice:has(input:focus-visible) span {
  outline: 2px solid var(--alch-accent); outline-offset: -2px;
}
.alch-query {
  flex: 0 1 auto; display: flex; align-items: flex-end; gap: 16px;
  min-width: 0; margin: 0 0 0 auto; padding: 0; border: 0;
}
.alch-field {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center; gap: 8px;
  height: 38px; min-width: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-4);
}
.alch-min { width: 188px; }
.alch-search { width: 300px; }
.alch-field-label {
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  white-space: nowrap;
}
.alch-field input {
  min-width: 0; height: 36px; padding: 0;
  border: 0; outline: 0; background: transparent;
  color: var(--ink);
  font: var(--fw-medium) var(--text-label)/1.2 var(--mono);
  font-variant-numeric: tabular-nums;
}
.alch-search input {
  font-family: var(--sans); font-weight: var(--fw-regular);
}
.alch-min input {
  text-align: left; -moz-appearance: textfield; appearance: textfield;
}
.alch-min input::-webkit-outer-spin-button,
.alch-min input::-webkit-inner-spin-button {
  margin: 0; -webkit-appearance: none;
}
/* The filter fields are underlines on the strip, not boxed fields. The shell's
   generic text-field rule outranks .alch-field input, so it drew a rounded box
   around the value with the gp unit sitting on the box's edge. */
#shell .alchview .alch-field input {
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
.alch-field input::placeholder { color: var(--ink-4); }
.alch-field input:focus-visible { outline: 0; }
.alch-field:focus-within { border-bottom-color: var(--alch-accent); }
.alch-field-unit {
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
}
.alch-search button {
  display: grid; place-items: center;
  width: 26px; height: 34px; padding: 0;
  border: 0; border-radius: 2px; background: transparent;
  color: var(--ink-3); cursor: pointer;
}
.alch-search button:hover { color: var(--alch-accent); }
.alch-search button:focus-visible {
  outline: 2px solid var(--alch-accent); outline-offset: -2px;
}

.alch-board {
  flex: 1 1 auto; display: flex; flex-direction: column;
  min-height: 0; padding-top: 0; scroll-margin-top: 72px;
}

.alch-scroll {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  border-top: 0;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.alch-scroll:focus-visible { outline: 2px solid var(--alch-accent); outline-offset: -2px; }

/* The market's foot: a window of ten numbers and the count, ruled off the
   ledger. The links are the server's, so paging survives with scripts off. */
.alch-board .pager {
  flex: 0 0 auto;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.alch-board .pg {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; font-size: var(--text-micro); text-decoration: none;
}
.alch-board .pg.on {
  border-color: var(--accent); background: var(--accent);
  color: var(--on-accent); font-weight: var(--fw-semibold);
}
.alch-board .pg[aria-disabled="true"] { opacity: .35; cursor: default; }
.alch-board .pg-info {
  color: var(--ink-4); font-size: var(--text-micro);
  letter-spacing: .08em; text-transform: uppercase;
}
/* The table is the market ledger with alchemy's six readings: the same header
   box, row height, first-cell inset and auto column rhythm. */
.alch-table {
  width: 100%; table-layout: auto; border-collapse: separate; border-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.alch-scroll .alch-table th,
.alch-scroll .alch-table td {
  padding: 7px 10px; text-align: right; white-space: nowrap;
}
.alch-scroll .alch-table thead th {
  position: sticky; top: 0; z-index: 3;
  height: 39px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/var(--leading-body) var(--mono);
  letter-spacing: .1em; text-transform: uppercase;
}
.alch-scroll .alch-table th:first-child,
.alch-scroll .alch-table td:first-child { width: 40px; text-align: center; }
.alch-scroll .alch-table th:nth-child(2),
.alch-scroll .alch-table td:nth-child(2) { width: 35%; text-align: left; }
.alch-scroll .alch-table tbody td {
  height: 40px; border-bottom: 1px solid var(--line-soft);
  color: var(--ink-3);
  font: var(--fw-medium) var(--text-label)/var(--leading-body) var(--mono);
}
.alch-scroll .alch-table tbody td.alch-item { padding-top: 6px; padding-bottom: 6px; }
.alch-table tbody tr:last-child td { border-bottom: 0; }
.alch-table tbody tr { transition: background var(--t-quick) var(--ease); }
.alch-table tbody tr:hover { background: var(--hover); }
.alch-rank { color: var(--ink-4); font-size: var(--text-micro) !important; }
.alch-row[data-alch-top] .alch-rank { color: var(--accent); }
.alch-item { text-align: left !important; white-space: normal !important; }
.alch-link {
  display: flex; align-items: center; gap: 9px; min-width: 0;
  color: var(--ink); text-decoration: none;
}
.alch-link img {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 2px;
  border-radius: 4px; background: var(--field);
  object-fit: contain; image-rendering: pixelated;
}
.alch-row-fallback { width: 26px; height: 26px; color: var(--ink-4); }
.alch-name {
  overflow: hidden; color: var(--ink);
  font: var(--fw-medium) var(--text-label)/var(--leading-body) var(--sans);
  text-overflow: ellipsis; white-space: nowrap;
}
.alch-link:hover .alch-name { color: var(--accent-2); }
.alch-badge {
  flex: 0 0 auto; padding: 1px 4px;
  border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/var(--leading-body) var(--mono);
  letter-spacing: var(--track-label); text-transform: uppercase;
}
.alch-table tbody td:nth-child(3),
.alch-table tbody td:nth-child(4) { color: var(--ink); }
.alch-scroll .alch-table tbody td.alch-profit { color: var(--up); font-size: var(--text-label); font-weight: var(--fw-medium); }
.alch-scroll .alch-table tbody td.alch-roi { color: var(--up); }
.alch-table .alch-limit { color: var(--ink-4); }
.alch-table .alch-vol { color: var(--ink-3); }
.alch-table :is(thead th, tbody td):nth-child(3),
.alch-table :is(thead th, tbody td):nth-child(5),
.alch-table :is(thead th, tbody td):nth-child(7) {
  border-left: 1px solid var(--line-soft);
}
.alch-scroll .alch-table .alch-empty-row td {
  padding: 0; border-bottom: 0; text-align: left;
}
.alch-empty {
  max-width: 52ch; margin: 0; padding: 34px 0 5px;
  color: var(--ink-3); font: var(--fw-regular) var(--text-body)/var(--leading-body) var(--sans);
  white-space: normal;
}
.alch-empty-link {
  display: inline-block; margin: 10px 0 34px;
  color: var(--alch-accent); font-size: var(--text-label);
  text-underline-offset: 3px;
}


@media (max-width: 960px) {
  .alch-mast { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .alch-mast-side { width: 100%; justify-content: flex-start; }
  .alch-rune { min-width: 0; }
  .alch-query {
    display: grid; grid-template-columns: minmax(188px, .8fr) minmax(260px, 1.2fr);
    gap: 16px; flex: 1 1 100%; margin-left: 0;
  }
  .alch-min, .alch-search { width: auto; }
}

@media (max-width: 900px) {
  .alchview { overflow: visible; }
  .alch-board { flex: 0 0 auto; }
  .alch-scroll { flex: 0 0 auto; max-height: 62vh; }
}

@media (max-width: 620px) {
  .alch-mast { padding: 10px 0 14px; }
  .alch-mast-side {
    flex-direction: column; align-items: stretch; gap: 0;
    padding-top: 11px; border-top: 1px solid var(--line-soft);
  }
  .alch-rune { width: 100%; }
  .alch-filters { gap: 9px 10px; padding: 10px 0; }
  .alch-set { flex: 1 1 100%; }
  .alch-seg { display: flex; width: 100%; }
  .alch-choice { flex: 1 1 0; }
  .alch-choice span { min-height: 30px; padding: 0 6px; }
  .alch-query {
    display: grid; grid-template-columns: minmax(0, 1fr);
    gap: 6px; flex: 1 1 100%;
  }
  .alch-field { height: 44px; }
  .alchview .alch-filters .alch-field input { height: 42px; }
  .alch-search button { width: 44px; height: 44px; }
  .alch-min, .alch-search { width: auto; flex: none; }
  .alch-scroll { max-height: none; overflow: visible; border-top: 0; }
  .alch-table, .alch-table tbody { display: block; width: 100%; }
  .alch-table thead { display: none; }
  .alch-row {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 8px; padding: 8px 10px 9px;
    border-bottom: 1px solid var(--line-soft);
  }
  .alch-row:last-child { border-bottom: 0; }
  .alch-row .alch-rank { display: none; }
  /* The market's card carries no rank, but the calculator's numbering is part
     of its ledger. The count comes back on the name line, before the sprite. */
  .alch-table tbody { counter-reset: alch-rank; }
  .board-body .alch-row { counter-increment: alch-rank; }
  .board-body .alch-row .alch-link::before {
    content: counter(alch-rank, decimal-leading-zero);
    flex: 0 0 auto;
    color: var(--ink-4);
    font: var(--fw-medium) var(--text-micro)/1 var(--mono);
    font-variant-numeric: tabular-nums;
  }
  .board-body .alch-row[data-alch-top] .alch-link::before {
    color: var(--accent);
  }
  .alch-row .alch-item { grid-column: 1 / -1; height: auto; padding: 0; }
  .alch-table tbody .alch-row .alch-num { border-left: 0; }
  /* The market's own phone cards are scoped under `.board-body`, so their
     `grid-area` names and four-track template also reach this table. These
     later, more specific rules give the alchemy card back its own six readings
     and three equal tracks. */
  .board-body .alch-row {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: none; gap: 4px 8px;
    padding: 8px 10px 9px; border-bottom: 1px solid var(--line-soft);
  }
  .board-body .alch-row .alch-item { grid-column: 1 / -1; width: auto; padding: 0; }
  /* The desk caps the item cell at 35%; a card owns the whole line. */
  .alch-scroll .alch-table tbody td.alch-item { width: auto; }
  .board-body .alch-row .alch-link { min-height: 44px; }
  .board-body .alch-row .alch-link img { width: 28px; height: 28px; }
  .board-body .alch-row .alch-num {
    grid-area: auto;
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    height: auto; padding: 0; border: 0; text-align: left; white-space: normal;
  }
  /* The market's card labels are static strings on the same cells. The
     alchemy card names its own readings, including High alch and Profit. */
  .board-body .alch-row .alch-num::before {
    content: attr(data-label);
    color: var(--ink-4);
    font: var(--fw-medium) var(--text-micro)/var(--leading-tight) var(--mono);
    letter-spacing: .08em; text-transform: uppercase;
    margin-bottom: 1px;
  }
  /* The card's readings are divided like the desk's: a hairline between each,
     and the last reading of a line closes on the card's right edge. */
  .board-body .alch-row .alch-num:nth-child(4),
  .board-body .alch-row .alch-num:nth-child(5),
  .board-body .alch-row .alch-num:nth-child(7),
  .board-body .alch-row .alch-num:nth-child(8) {
    padding-left: 8px; border-left: 1px solid var(--line-soft);
  }
  .board-body .alch-row .alch-num:nth-child(3),
  .board-body .alch-row .alch-num:nth-child(6) { padding-right: 0; }
  .board-body .alch-row .alch-num:nth-child(5),
  .board-body .alch-row .alch-num:nth-child(8) {
    align-items: flex-end; text-align: right;
  }
  .board-body .alch-row .alch-limit { color: var(--ink-3); }
  .board-body .alch-row .alch-vol { color: var(--ink-4); }
  .alch-table .alch-profit { font-size: var(--text-label); }
  .alch-name { font-size: var(--text-label); }
  .alch-scroll .alch-table .alch-empty-row { display: block; }
  .alch-scroll .alch-table .alch-empty-row td {
    display: block; width: auto; padding: 0 10px;
  }
  .alch-empty { max-width: 42ch; padding: 26px 0 6px; }
  .alch-empty-link { margin: 8px 0 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .alch-pulse { animation: none; }
}

/* The table is the board: every priced item is in it, and the headers are the
   sort controls. The market uses a button per header; here the same control is
   a link, so it still sorts when scripts are off. The phone gets the strip the
   market board uses because the header is hidden at that width. */
.alch-sort {
  display: inline-flex; align-items: center; gap: 4px;
  color: inherit; text-decoration: none;
  /* The market's header control is a button, and the browser leaves button
     text un-transformed; the th says uppercase while the label reads title
     case. This header is a link, so it says so itself. */
  text-transform: none;
}
.alch-sort:hover, .alch-sort:focus-visible { color: var(--ink); }
.alch-scroll .alch-table thead th[aria-sort] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.alch-table thead th[aria-sort] .alch-sort { color: var(--ink); }
.alch-caret {
  display: inline-block; min-width: 7px;
  color: var(--alch-accent); font-size: var(--text-label); line-height: 1;
}
.alch-caret:empty { display: none; }
.alch-scroll .alch-table tbody td.alch-loss { color: var(--down); }
.alch-sortbar { display: none; }
.alch-sort-chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  height: 40px; min-width: 44px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 5px;
  background: transparent; color: var(--ink-3);
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap;
}
.alch-sort-chip:hover, .alch-sort-chip:focus-visible { color: var(--ink); }
.alch-sort-chip[aria-current="true"] {
  border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent);
}
.alch-sort-chip .alch-caret { color: inherit; }
@media (max-width: 620px) {
  .alch-sortbar {
    display: flex; align-items: center; gap: 6px;
    width: 100%; max-width: 100%; padding: 10px 0 6px;
    overflow-x: auto; scrollbar-width: none;
  }
  .alch-sortbar::-webkit-scrollbar { display: none; }
  /* The market swaps its pager for a Load more row on a phone. This board
     pages the same list server-side, so the pager stays - compact enough for
     a ten-page window and its arrows to hold one line. */
  .alch-board .pager { display: flex; padding: 12px 10px; }
  .alch-board .pg { min-width: 24px; height: 26px; padding: 0 4px; }
}

/* ---------------------------------------------------------- blast furnace --- */
/* The bar board is the calculator: the goal band sets the target, the eight-row
   board compares every bar, and the selected row settles into the bill. No
   second column and no nested cards; the table is the surface. */

.calcview .bf-desk {
  flex: 1 1 auto; display: flex; flex-direction: column;
  min-height: 0; overflow: hidden;
}
.bf-hiscore .calc-hiscore-note {
  flex-basis: 100%; min-height: 0; margin: 0; text-align: right;
}
.bf-hiscore .calc-hiscore-note:empty { display: none; }
.bf-plan .tool-icon {
  width: 15px; height: 15px;
  transition: transform var(--t-quick) var(--ease);
}
.bf-plan:hover .tool-icon { transform: translateX(2px); }
.bf-plan:disabled .tool-icon { opacity: .55; }
.bf-plan:disabled:hover .tool-icon { transform: none; }
.bf-reset .tool-icon { width: 14px; height: 14px; }
.calcview .bf-switches .plan-toggle {
  min-height: 30px; padding: 3px 0; gap: 7px;
  border: 0; border-radius: 0; background: transparent;
  align-items: center;
}
.calcview .bf-switches .plan-toggle input { width: 14px; height: 14px; margin: 0; }
.calcview .bf-switches .plan-toggle:hover { border-color: transparent; }
.calcview .bf-switches .plan-toggle:hover b,
.calcview .bf-switches .plan-toggle:has(input:checked) b { color: var(--ink); }
.calcview .bf-switches .plan-toggle:has(input:checked) {
  border-color: transparent; background: transparent;
}
.calcview .bf-switches .plan-toggle b { font-size: var(--text-label); }
.bf-bar-link .data-item {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  flex: 1 1 auto;
}
.bf-bar-link .data-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--text-body);
}
.bf-bar-link.is-locked { color: var(--ink-3); cursor: default; }
.bf-desk .bf-table tr.is-locked th,
.bf-desk .bf-table tr.is-locked td { color: var(--ink-4); }
.bf-desk .bf-table tr.is-locked .data-name { color: var(--ink-3); }
.bf-desk .bf-table tr.is-locked .tool-item-img {
  opacity: .55; filter: grayscale(1);
}
.bf-desk .bf-table tr.is-selected .data-name { font-weight: var(--fw-medium); }
.bf-desk .bf-table .tool-item-img { width: 16px; height: 16px; }
.bf-net-signed.up { color: var(--up); }
.bf-net-signed.down { color: var(--down); }
.bf-bill dd b.up { color: var(--up); }
.bf-bill dd b.down { color: var(--down); }

/* Motion: the bill prints into place after a selection or the first valid
   goal. Live recalculations reprice the result without replaying the entrance. */
@media (prefers-reduced-motion: reduce) {
}

/* The same board on a short desktop: keep the strip and the plan button, trim
   the goal band and the row rhythm. The page still fits one screen at 1024. */
@media (min-width: 901px) and (max-height: 860px) {
  .tool-blast-furnace-calculator .calc-mast .hb-crumbs { margin-bottom: 9px; }
}

/* A 900px-tall desk still has to show all eight bars and the settled bill:
   trim the goal and bill rhythm rather than let the footer cover the last row. */
@media (min-width: 1201px) and (max-height: 950px) {
}

@media (max-width: 900px) {
  .calcview .bf-desk {
    display: flex; flex-direction: column; overflow: visible;
  }
}

@media (max-width: 760px) {
  .calcview .bf-switches .plan-toggle { min-height: 34px; padding: 3px 0; }
  .bf-hiscore .calc-hiscore-note { text-align: left; }
}

@media (max-width: 440px) {
}

/* The app's market board turns every table row into a Buy/Sell/Margin card
   below 900px. The calculator shares the board wrapper but not those columns:
   keep its native table model, its three mobile columns and its own net cell. */
@media (max-width: 900px) {
  .board-body .bf-table { display: table; }
  .board-body .bf-table thead { display: table-header-group; }
  .board-body .bf-table tbody { display: table-row-group; }
  .board-body .bf-table tr { display: table-row; }
  .board-body .bf-table th,
  .board-body .bf-table td {
    display: table-cell; float: none; align-items: initial;
  }
  .board-body .bf-table tbody tr > th,
  .board-body .bf-table tbody tr > td { display: table-cell; }
  .board-body .bf-table tbody tr > *::before { content: none; display: none; }
  .board-body .bf-table thead th:first-child,
  .board-body .bf-table tbody tr > th:first-child { width: 52%; }
  .board-body .bf-table .bf-bill-row > td { width: auto; }
  .board-body .bf-table tbody tr > td[data-col="rate"],
  .board-body .bf-table tbody tr > td[data-col="xph"],
  .board-body .bf-table tbody tr > td[data-col="time"] { display: none; }
  .board-body .bf-table thead th[data-col="rate"],
  .board-body .bf-table thead th[data-col="xph"],
  .board-body .bf-table thead th[data-col="time"] { display: none; }
  .board-body .bf-table:not(.is-reference) tbody tr > td[data-col="cost"] { display: none; }
}

/* The short desktop also inherits the market board's row rules; let every bar
   and the bill row lay out as table rows so the whole board is one screen. */
@media (min-width: 901px) and (max-height: 860px) {
  .board-body .bf-table tbody tr { display: table-row; }
  .board-body .bf-table th,
  .board-body .bf-table td { display: table-cell; }
}
/* ==========================================================================
   Workbench v2 — market folio, order ticket
   ==========================================================================
   The market and item pages already teach the composition: one ruled main
   surface, one narrow rail on the right, and a mast that names the page. Every
   calculator now uses it. The answer or board is the product; the ticket holds
   the hiscore, the goal, the method and the setup. */

/* ---- the mast ------------------------------------------------------------ */

.calcview .calc-mast { padding: 16px 0 14px; }
.calc-mast .hb-crumbs {
  margin-bottom: 11px;
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1.2 var(--mono);
  letter-spacing: var(--track-label);
}
.calc-mast .hb-crumbs a { color: var(--ink-3); }
.calc-icon .tool-icon { width: 21px; height: 21px; }
.calc-hiscore-note {
  flex: 1 1 230px; margin: 0;
  color: var(--ink-4); font-size: var(--text-label);
}
.calc-hiscore-note.ok { color: var(--ink-3); }
.calc-hiscore-note.bad { color: var(--down); }

/* ---- the shared plan sheet ---------------------------------------------- */

/* Base: the ticket comes first because that is how the page is used on a
   phone. The wide layout below restores the market's main-surface + rail. */
.calcview .plan-desk {
  display: flex; flex-direction: column;
  min-height: 0; overflow: visible;
}
.calcview .plan-form {
  order: 1; width: 100%; max-width: 100%;
  padding: 16px 0; border: 0; border-bottom: 1px solid var(--line);
  overflow: visible;
}
.calcview .plan-answer {
  order: 2; width: 100%;
  padding: 16px 0; border: 0; border-bottom: 1px solid var(--line-soft);
}
.calcview .plan-ledger {
  display: block; order: 3; width: 100%;
  padding: 14px 0 16px; border: 0; overflow: visible;
}
.calcview .plan-form .tool-field { margin-bottom: 9px; }
.calcview .plan-form .tool-input input,
.calcview .plan-form .tool-select { height: 36px; font-size: var(--text-label); }
.calcview .plan-form .tool-actions {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  justify-content: space-between;
}
.calcview .plan-toggle {
  min-height: 30px; padding: 5px 0;
  border: 0; border-radius: 0; background: transparent;
  border-bottom: 1px solid var(--line-soft);
  align-items: center;
}
.calcview .plan-toggle:last-child { border-bottom: 0; }
.calcview .plan-toggle:hover { border-color: var(--line-soft); }
.calcview .plan-toggle:has(input:checked) {
  border-color: var(--line-soft); background: transparent;
}
.calcview .plan-toggle input { width: 14px; height: 14px; margin: 0; }
.calcview .plan-toggle:has(input:checked) b { color: var(--ink); }
.plan-mat.primary strong { font-size: var(--text-heading); }
.calcview .plan-table { min-width: 560px; }
.calcview .plan-table th {
  padding: 0 6px 7px;
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1.2 var(--mono);
  letter-spacing: 0;
}
.calcview .plan-table td { padding: 6px; font-size: var(--text-label); }
.calcview .plan-table tbody tr:hover td {
  background: color-mix(in srgb, var(--tool-tone) 4%, transparent);
}
.calcview .plan-table tbody tr.is-current td {
  background: color-mix(in srgb, var(--tool-tone) 7%, transparent);
}

/* ---- the tax, alch and limit desks -------------------------------------- */

.calcview .tax-desk,
.calcview .alch-desk,
.calcview .limit-desk {
  display: flex; flex-direction: column;
  min-height: 0; overflow: visible;
}
.calcview .tax-ticket,
.calcview .alch-setup,
.calcview .limit-setup {
  order: 1; width: 100%;
  padding: 16px 0;
  border: 0; border-bottom: 1px solid var(--line);
}
.calcview .tax-receipt,
.calcview .alch-result,
.calcview .limit-result {
  order: 2; width: 100%;
  padding: 16px 0 18px;
}
.calcview .tax-ticket .tool-head,
.calcview .limit-setup .tool-head {
  margin: 0 0 12px; padding: 0 0 10px;
  border-bottom: 1px solid var(--line-soft);
}
.calcview .tax-ticket .tool-head h2,
.calcview .limit-setup .tool-head h2 {
  color: var(--ink); font-size: var(--text-body); font-weight: var(--fw-medium);
}
.calcview .tax-ticket-body,
.calcview .limit-setup-body {
  display: flex; flex-direction: column;
}
.calcview .tax-fields,
.calcview .limit-fields {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 8px; max-width: none;
}
.calcview .tax-fields .tool-field,
.calcview .limit-fields .tool-field { margin: 0; }
.calcview .tax-fields .tool-input input,
.calcview .tax-fields .tool-select,
.calcview .limit-fields .tool-input input,
.calcview .limit-fields .tool-select { height: 36px; font-size: var(--text-label); }
.calcview .tax-ticket .tool-check {
  min-height: 28px; padding: 0; border: 0; background: transparent;
}
.calcview .tax-submit,
.calcview .limit-submit {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.calcview .tax-submit .tool-actions,
.calcview .limit-submit .tool-actions { margin: 0; justify-content: space-between; }
.calcview .tax-receipt .tool-head,
.calcview .limit-result .tool-head {
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.calcview .tax-receipt .tool-head h3,
.calcview .limit-result .tool-head h3 {
  color: var(--ink); font-size: var(--text-heading); font-weight: var(--fw-medium);
}
.calcview .tax-profit b,
.calcview .limit-hero b { font-size: clamp(2rem, 3vw, 2.75rem); }
.calcview .tax-key dt,
.calcview .tax-audit dt,
.calcview .tax-equation dt { font-size: var(--text-label); }
.calcview .tax-key dd,
.calcview .tax-audit dd,
.calcview .tax-equation dd { font-size: var(--text-label); }
.calcview .limit-board .tool-facts dd { font-size: var(--text-label); }

/* ---- wide: the order ticket leads on the left, answer on the right -------- */

@media (min-width: 901px) {
  .calcview .plan-desk {
    display: grid;
    grid-template-columns: minmax(300px, 330px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%; min-height: 0;
    overflow: hidden;
  }
  .calcview .plan-form {
    order: 0; grid-column: 1; grid-row: 1 / -1;
    height: 100%; min-height: 0;
    padding: 16px 22px 14px 0;
    border-bottom: 0; border-right: 1px solid var(--line);
    overflow: auto;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .calcview .plan-answer {
    order: 0; grid-column: 2; grid-row: 1;
    padding: 18px 0 16px 26px;
    border-bottom: 1px solid var(--line-soft);
    overflow: visible;
  }
  .calcview .plan-ledger {
    order: 0; display: block; grid-column: 2; grid-row: 2;
    padding: 14px 0 16px 26px;
    overflow: auto;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }

  .calcview .tax-desk,
  .calcview .alch-desk,
  .calcview .limit-desk {
    display: grid;
    grid-template-columns: minmax(300px, 330px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100%; min-height: 0;
    overflow: hidden;
  }
  .calcview .tax-ticket,
  .calcview .alch-setup,
  .calcview .limit-setup {
    order: 0; grid-column: 1; grid-row: 1;
    height: 100%; min-height: 0;
    padding: 16px 22px 14px 0;
    border-bottom: 0; border-right: 1px solid var(--line);
    overflow: auto;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .calcview .tax-receipt,
  .calcview .alch-result,
  .calcview .limit-result {
    order: 0; grid-column: 2; grid-row: 1;
    padding: 18px 0 18px 26px;
    overflow: auto;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
}

@media (min-width: 1081px) {
  .calcview .plan-desk,
  .calcview .tax-desk,
  .calcview .alch-desk,
  .calcview .limit-desk {
    grid-template-columns: var(--side-col) minmax(0, 1fr);
  }
}
/* ---- the blast furnace: same board, same ticket ------------------------- */

@media (min-width: 1181px) {
  .calcview .bf-desk {
    display: grid;
    grid-template-columns: var(--side-col) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100%; min-height: 0; overflow: hidden;
  }
  .calcview .bf-switches .plan-toggle {
    min-height: 30px; padding: 5px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .calcview .bf-switches .plan-toggle:last-of-type { border-bottom: 0; }
}

/* ---- the index reads at the market mast's scale ------------------------- */

.bench-head { padding: 16px 0 18px; }
.bench-head h2 {
  max-width: none;
  font-size: var(--text-title);
  line-height: var(--leading-display);
}
.bench-head .page-mast-lede { max-width: 54ch; margin-top: 7px; font-size: var(--text-body); }
.bench-group-head h3 {
  color: var(--ink-3);
  font: var(--fw-medium) var(--text-micro)/1.2 var(--mono);
  letter-spacing: var(--track-label);
}
.bench-plan { margin-top: 20px; padding: 15px 0 17px; }

/* ---- narrow: the ticket is the first thing, the answer follows ---------- */

@media (max-width: 900px) {
  .calcview .plan-desk[data-goal] .plan-form,
  .calcview .plan-desk[data-error] .plan-form {
    border-bottom: 1px solid var(--line);
  }
  .calcview .plan-desk[data-goal] .plan-answer,
  .calcview .plan-desk[data-error] .plan-answer {
    border-top: 0;
    border-bottom: 1px solid var(--line-soft);
  }
}

@media (max-width: 760px) {
  .calcview .calc-mast { padding: 14px 0 12px; }
  .calc-mast .hb-crumbs { margin-bottom: 9px; }
  .calc-icon .tool-icon { width: 18px; height: 18px; }
  .calc-hiscore-note { flex-basis: auto; grid-column: 1 / -1; }

  .calcview .plan-bill { grid-template-columns: minmax(0, 1fr); }
  .calcview .plan-bill > .plan-mat {
    padding: 9px 0; border-left: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .calcview .plan-bill > .plan-mat:last-child { border-bottom: 0; }
  .calcview .plan-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calcview .plan-facts > div { padding-left: 0; border-left: 0; }
  .calcview .plan-facts > div:nth-child(even) {
    padding-left: 12px; border-left: 1px solid var(--line-soft);
  }
  .calcview .plan-table th:first-child,
  .calcview .plan-table td:first-child { min-width: 130px; }

  .calcview .tax-profit b,
  .calcview .limit-hero b { font-size: var(--text-title); }
  .calcview .tax-receipt-body { display: block; }
  .calcview .tax-profit { padding-right: 0; border-right: 0; padding-bottom: 14px; }
  .calcview .tax-key {
    padding-left: 0; padding-top: 10px;
    border-left: 0; border-top: 1px solid var(--line-soft);
  }
  .calcview .tax-equation,
  .calcview .tax-audit { padding: 10px 0 0; border-right: 0; }
  .calcview .tax-audit { border-top: 1px solid var(--line-soft); margin-top: 8px; }
  .calcview .limit-board { display: block; }
  .calcview .limit-cycle { padding: 14px 0; border-top: 1px solid var(--line-soft); }
  .calcview .limit-unit {
    padding: 14px 0 0; border-left: 0; border-top: 1px solid var(--line-soft);
  }
  .calcview .calc-foot { min-height: 52px; padding-top: 14px; }
}

@media (max-width: 440px) {
  .calcview .plan-field-grid { grid-template-columns: minmax(0, 1fr); }
  .calcview .plan-worker-grid { grid-template-columns: minmax(0, 1fr); }
  .calcview .plan-toggle small { display: none; }
  .bench-head h2 { font-size: var(--text-title); }
  .bench-plan { margin-top: 16px; }
}

/* The receipt is a list, not a ladder. Inherited flex:1 rows stretched the
   arithmetic down the full column; keep each line at its own height. */
.calcview .tax-receipt-body { align-content: start; }
.calcview .tax-equation > div,
.calcview .tax-audit > div { flex: 0 0 auto; }
.calcview .tax-profit b.up,
.calcview .limit-hero b.up { color: var(--up); }
.calcview .tax-profit b.down,
.calcview .limit-hero b.down { color: var(--down); }

/* The index is a register, not three columns of air. */
.bench-tool { flex: 0 0 auto; min-height: 58px; }

/* An empty bill still owns the full rule, not half of it. */
.calcview .plan-bill > .plan-empty {
  grid-column: 1 / -1;
  margin: 0; padding: 11px 0;
  border: 0;
}

/* The limit result is a list of figures, not a ladder. */
.calcview .limit-board { align-content: start; }
.calcview .limit-cycle,
.calcview .limit-unit { display: block; }
.calcview .limit-board .tool-facts > div { flex: 0 0 auto; }

/* At 1024 the seven-column ledger is tight; give the cells back their
   gutters so every figure stays inside the main surface. */
@media (min-width: 901px) and (max-width: 1200px) {
  .calcview .plan-table { min-width: 100%; }
  .calcview .plan-table th,
  .calcview .plan-table td { padding-left: 3px; padding-right: 3px; }
}

/* The BF shares the .plan-desk class. Below its own split, it is still the
   full-width goal band over the board, not the plan's answer/ticket grid. */
@media (min-width: 901px) and (max-width: 1180px) {
  .calcview .bf-desk { display: flex; flex-direction: column; }
}

/* On a phone the answer comes first, then the ticket, then the reference. An
   empty plan keeps the ticket first so there is something to act on. */
@media (max-width: 900px) {
  .calcview .plan-answer { order: 1; }
  .calcview .plan-form { order: 2; }
  .calcview .plan-ledger { order: 3; }
  .calcview .plan-desk:has(.plan-empty) .plan-form { order: 1; }
  .calcview .plan-desk:has(.plan-empty) .plan-answer { order: 2; }
  .calcview .tax-receipt,
  .calcview .alch-result,
  .calcview .limit-result { order: 1; }
  .calcview .tax-ticket,
  .calcview .alch-setup,
  .calcview .limit-setup {
    order: 2;
    border-top: 1px solid var(--line); border-bottom: 0;
  }
}
/* The v2 wide rules reset the old short-window compression. Reassert it after
   the new left-ticket layout so the ticket still ends inside the first view. */
@media (min-width: 901px) and (max-height: 950px) {
  .calcview .plan-form { padding: 12px 18px 10px 16px; }
  .calcview .plan-groups { margin-top: 10px; }
  .calcview .plan-group { padding-bottom: 10px; }
  .calcview .plan-group + .plan-group { padding-top: 10px; }
  .calcview .plan-group legend { margin-bottom: 6px; }
  .calcview .plan-form .tool-field { margin-bottom: 7px; }
  .calcview .plan-form .tool-input input,
  .calcview .plan-form .tool-select { height: 34px; }
  .calcview .plan-toggle { min-height: 28px; padding: 4px 0; }
  .calcview .plan-form .tool-actions { margin-top: 10px; padding-top: 9px; }
}

@media (min-width: 901px) and (max-height: 820px) {
  .calcview .plan-form { padding: 10px 14px 9px 14px; }
  .calcview .plan-groups { margin-top: 8px; }
  .calcview .plan-group { padding-bottom: 8px; }
  .calcview .plan-group + .plan-group { padding-top: 8px; }
  .calcview .plan-group legend { margin-bottom: 5px; }
  .calcview .plan-pair-grid { gap: 6px; }
  .calcview .plan-form .tool-field { margin-bottom: 6px; }
  .calcview .plan-form .tool-input input,
  .calcview .plan-form .tool-select { height: 34px; }
  .calcview .plan-toggle { min-height: 26px; padding: 3px 0; }
  .calcview .plan-form .tool-actions { margin-top: 8px; padding-top: 8px; }
}

/* The hub is a register, not a ruled cage. Let each group's rule end with its
   list instead of stretching through the empty space to the plan strip. */
@media (min-width: 901px) {
  .bench-group { align-self: start; }
}

/* At 13px the mono equals glyph reads as another minus. Draw the two bars. */
.calcview .tax-eq-keeps .tax-op {
  position: relative; color: transparent;
}
.calcview .tax-eq-keeps .tax-op::before,
.calcview .tax-eq-keeps .tax-op::after {
  content: ""; position: absolute; left: 0; right: 0;
  height: 1px; background: var(--ink-3);
}
.calcview .tax-eq-keeps .tax-op::before { top: 5px; }
.calcview .tax-eq-keeps .tax-op::after { top: 8px; }

/* Seven worker rows do not fit two-up in a short wide ticket. Three columns
   only when the side rail is at its full width; the tablet stack keeps two. */
@media (min-width: 1081px) {
  .calcview .plan-form .plan-worker-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* One inner edge for every left-hand ticket. The plan forms get this from
   their compact padding; the tax, limit and wide BF panels match it. */
@media (min-width: 901px) and (max-height: 950px) {
  .calcview .tax-ticket,
  .calcview .alch-setup,
  .calcview .limit-setup { padding-left: 16px; }
}
@media (min-width: 901px) and (max-height: 820px) {
  .calcview .tax-ticket,
  .calcview .alch-setup,
  .calcview .limit-setup { padding-left: 14px; }
}
@media (min-width: 1181px) {
}

/* ---- GE tax: the receipt beside its ticket ------------------------------- */

/* The order line is the left ticket; the receipt it produces is the surface
   on the right. This follows the combat and skill desks instead of opening a
   full-width control strip above the answer. */
@media (min-width: 901px) {
  .calcview .tax-desk {
    display: grid;
    grid-template-columns: 276px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100%; min-height: 0; overflow: hidden;
  }
  .calcview .tax-desk > .tax-bar {
    grid-column: 1; grid-row: 1;
    display: flex; flex-direction: column; flex-wrap: nowrap;
    align-items: stretch; gap: 0;
    height: 100%; min-height: 0; padding: 20px 24px 20px 0;
    border: 0; border-right: 1px solid var(--line);
    background: transparent; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
  .calcview .tax-desk > .tax-bar .calc-bar-fields {
    flex: 0 0 auto; display: flex; flex-direction: column;
    align-items: stretch; gap: 12px; width: 100%;
  }
  .calcview .tax-desk > .tax-bar .calc-input { width: 100%; }
  .calcview .tax-desk > .tax-bar .tax-source {
    flex: 0 0 auto; width: 100%;
    margin: 14px 0 0; padding-top: 12px;
    border-top: 1px solid var(--line-soft);
  }
  .calcview .tax-desk > .tax-bar .calc-bar-actions {
    width: 100%; margin: auto 0 0; padding-top: 14px;
    border-top: 1px solid var(--line-soft);
    justify-content: flex-start;
  }
  .calcview .tax-desk > .tax-receipt {
    grid-column: 2; grid-row: 1;
    min-width: 0; min-height: 0;
    padding: 20px 0 20px 28px;
    overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
  }
}

/* The mast names the tool; the rail opens on its first control. The form
   heading and intro stay in the accessibility tree, not the visual stack. */
.calcview .plan-form-head,
.calcview .tax-ticket > .tool-head,
.calcview .limit-setup > .tool-head {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap;
}

/* One family everywhere; the title is the boldest thing on the plate. */
.bench-head h2,
.calc-title h2,
.bf-goal-figure > b {
  font-family: var(--sans);
  font-weight: var(--fw-display);
  letter-spacing: var(--track-display);
  line-height: 1.08;
}

/* The finder reuses the shared desk element, so the legacy tax/alch grid rules
   must not claim it. This is the later word on the same element: one column at
   every width, with the table taking the remaining height at a desk. */
.calcview .alch-desk {
  display: flex; flex-direction: column;
  height: 100%; min-height: 0; overflow: hidden;
}
@media (max-width: 900px) {
  .calcview .alch-desk {
    height: auto; min-height: 0; overflow: visible;
  }
}

/* ---- the tax receipt's source line and state ---------------------------- */

/* The live price is optional, so the ticket says where the figure came from
   without turning the lookup into a second card. Missing is a warning, not a
   silent zero. */
.tax-source {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px;
  margin: 10px 0 0;
  color: var(--ink-3); font-size: var(--text-label); line-height: 1.35;
}
.tax-source .tool-item-img { width: 18px; height: 18px; }
.tax-source a {
  color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
}
.tax-source a:hover { color: var(--accent); border-color: var(--accent); }
.tax-source-note { color: var(--ink-4); }
.tax-source.is-missing,
.tax-source.is-missing .tax-source-note { color: var(--down); }
.tax-state {
  margin-left: auto; color: var(--accent);
  font: var(--fw-medium) var(--text-label)/1.2 var(--sans);
  letter-spacing: 0; text-transform: uppercase; white-space: nowrap;
}
.tax-state.is-exempt { color: var(--up); }

@media (max-width: 760px) {
  .calcview .tax-equation > .tax-eq-keeps {
    grid-column: 1 / -1;
    padding-left: 0; border-left: 0;
  }
}

/* ---------------------------------------------------------- combat sheet --- */

/* The combat calculator is one stat ticket and one character readout. The
   answer fills the right side; base and the three styles are ruled columns,
   not another row of cards. The leading style is the only coloured figure. */

.calcview .combat-desk { grid-template-rows: minmax(0, 1fr); }
.calcview .combat-form {
  display: flex; flex-direction: column; height: 100%;
  padding: 20px 22px 22px; overflow: auto;
}
.combat-fields {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0;
}
.combat-field {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 66px;
  grid-template-areas: "icon head input";
  align-items: center; gap: 8px;
  min-width: 0; margin: 0; padding: 7px 0;
  border-bottom: 1px solid var(--line-soft); text-align: left;
}
.combat-field:first-child { border-top: 1px solid var(--line-soft); }
.combat-field-icon {
  grid-area: icon; display: block; width: 20px; height: 20px;
  margin: 0; object-fit: contain;
}
.combat-field .tool-field-head {
  grid-area: head; margin: 0; justify-content: flex-start;
}
.combat-field .tool-field-label {
  color: var(--ink-3); font-size: var(--text-body); line-height: 1.2;
  text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.combat-field:focus-within .tool-field-label { color: var(--ink); }
.combat-field .tool-input { grid-area: input; min-width: 0; }
.combat-field .tool-input input {
  width: 100%; height: 32px; padding: 0 6px;
  border-color: var(--line); border-radius: 4px;
  background: var(--field);
  font-family: var(--mono); font-size: var(--text-body);
  font-variant-numeric: tabular-nums; text-align: right;
  appearance: textfield;
}
.combat-field .tool-input input:hover { border-color: var(--line-strong); }
.combat-field .tool-input input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
.combat-field .tool-input input::-webkit-inner-spin-button,
.combat-field .tool-input input::-webkit-outer-spin-button {
  appearance: none; margin: 0;
}

.calcview .combat-result {
  grid-row: 1 / -1;
  display: flex; flex-direction: column;
  min-height: 0; padding: 22px 28px 20px;
  border-bottom: 0; overflow: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.combat-level {
  display: flex; align-items: baseline;
  color: var(--ink);
  font: var(--fw-medium) 68px/.84 var(--mono);
  font-variant-numeric: tabular-nums; letter-spacing: -.04em;
}
.combat-level-whole { font-size: 68px; }
.combat-level-frac {
  color: var(--ink-3); font-size: 32px; line-height: 1;
  letter-spacing: -.02em;
}

@media (pointer: coarse) {
  .combat-field .tool-input input { height: 44px; }
  .combat-form .tool-run,
  .combat-reset { min-height: 44px; height: 44px; }
}

@media (max-width: 900px) {
  .combatview .data-desk { display: flex; flex-direction: column; }
  .combatview .combat-result {
    order: 1; grid-row: auto;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .combatview .combat-form {
    order: 2; height: auto; border-right: 0; border-bottom: 0;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .calcview .combat-form,
  .calcview .combat-result { padding: 16px; }
  .combat-level { font-size: 58px; }
}

@media (max-width: 380px) {
  .combat-fields { grid-template-columns: minmax(0, 1fr); }
  .combat-level { font-size: 52px; }
}

/* ------------------------------------------------- combat planner result --- */

/* The accepted Live result: the exact level, the next level, and the stat
   routes that reach it. Two columns, one rule, one authored entrance. */

.cru {
  box-sizing: border-box; display: flex; flex-direction: column; gap: 18px;
  width: 100%; color: var(--ink);
}
/* Once a reader edits a stat, the result changes in place. The entrance is for
   the first server render only; rebuilt route rows should not replay it. */
.cru.is-live .cru-hero,
.cru.is-live .cru-route,
.cru.is-live .cru-lede,
.cru.is-live .cru-rail-fill,
.cru.is-live .cru-rail::after { animation: none; }
.cru-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.cru-kicker {
  margin: 0; color: var(--ink-4);
  font: var(--fw-medium) 0.875rem/1.2 var(--mono);
  letter-spacing: .08em; text-transform: uppercase;
}
.cru-target {
  display: inline-flex; align-items: baseline; gap: 8px;
  color: var(--ink-4);
  font: var(--fw-medium) 0.875rem/1.2 var(--mono);
  letter-spacing: .06em; text-transform: uppercase;
}
.cru-target b {
  color: var(--accent);
  font: var(--fw-medium) 24px/1 var(--mono); letter-spacing: -.03em;
}
.cru-hero {
  display: flex; align-items: flex-end; gap: 20px; min-width: 0;
  animation: cru-rise 440ms 160ms cubic-bezier(.16, 1, .3, 1) both;
}
.cru .combat-level {
  color: var(--ink);
  font: var(--fw-medium) 66px/.84 var(--mono);
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
}
.cru .combat-level-whole { font-size: 66px; }
.cru .combat-level-frac {
  color: var(--ink-3); font-size: 30px; line-height: 1;
  letter-spacing: -.02em;
}
.cru-lede {
  max-width: 26ch; margin: 0 0 6px;
  color: var(--ink-3); font-size: var(--text-body);
  line-height: 1.5; text-align: right;
}
.cru-plan { display: flex; flex-direction: column; min-width: 0; }
.cru-plan-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 0 7px; color: var(--ink-4);
  font: var(--fw-medium) 0.875rem/1.2 var(--mono);
  letter-spacing: .06em; text-transform: uppercase;
  border-bottom: 1px solid var(--line-soft);
}
.cru-routes {
  list-style: none; display: grid;
  grid-template-columns: minmax(0, 1fr); gap: 0;
  min-width: 0; margin: 0; padding: 0;
}
.cru-route {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto auto;
  gap: 8px; align-items: center; min-width: 0; padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  animation: cru-rise 360ms cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(250ms + var(--i) * 45ms);
}
.cru-route img { width: 18px; height: 18px; object-fit: contain; }
.cru-skill {
  color: var(--ink-2); font-size: var(--text-body); line-height: 1.2;
}
.cru-levels {
  color: var(--ink-4); font: var(--fw-regular) 0.875rem/1 var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.cru-levels i { color: var(--ink-4); font-style: normal; margin: 0 2px; }
.cru-add {
  min-width: 27px; color: var(--accent);
  font: var(--fw-medium) var(--text-body)/1 var(--mono); text-align: right;
}
@media (max-width: 760px) {
}

@media (max-width: 760px) {
  .cru-hero { align-items: flex-start; flex-direction: column; gap: 12px; }
  .cru-lede { text-align: left; }
  .cru-routes { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .cru-top { align-items: flex-start; flex-direction: column; gap: 8px; }
  .cru-target { align-self: flex-end; }
  .cru .combat-level, .cru .combat-level-whole { font-size: 56px; }
  .cru .combat-level-frac { font-size: 26px; }
}

@keyframes cru-rise {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cru-rail {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .cru, .cru * { animation: none !important; transition: none !important; }
}
/* ==========================================================================
   Alch baseline — every calculator is the finder's page
   ==========================================================================
   The high-alch finder is the reference: one mast, one ruled control strip,
   then a full-width reading surface. Tax, combat and the skill sheets use the
   same tape, the same underlined fields and the same ledger rhythm, so a
   calculator differs by its question, not by its furniture. */

.calcview .calc-stack {
  flex: 1 1 auto; display: flex; flex-direction: column;
  min-height: 0; overflow: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.calcview .calc-stack > .calc-bar { flex: 0 0 auto; }

/* ---- the tape: one live number beside the title ------------------------- */

.calc-tape {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; padding: 0; border: 0; background: transparent;
}
.calc-tape-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 auto; }
.calc-tape-img {
  display: block; width: 24px; height: 24px;
  object-fit: contain; image-rendering: pixelated;
}
.calc-tape-icon .tool-icon { width: 20px; height: 20px; color: var(--accent); }
.calc-tape-copy { min-width: 0; }
.calc-tape-label {
  display: block; color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  letter-spacing: 0; white-space: nowrap;
}
.calc-tape-copy b {
  display: block; margin-top: 3px;
  color: var(--ink-2);
  font: var(--fw-medium) var(--text-body)/1.2 var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.calc-pulse {
  display: inline-block; width: 5px; height: 5px; margin-right: 5px;
  border-radius: 999px; background: var(--accent);
  animation: calc-pulse 2.8s var(--ease) infinite;
}
@keyframes calc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ---- the control strip: the finder's filters, generalised ---------------- */

.calcview .calc-bar {
  display: flex; align-items: flex-end; flex-wrap: wrap;
  gap: 10px 22px; min-width: 0; padding: 11px 0;
  border: 0; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.calc-stack > .calc-bar { position: sticky; top: 0; z-index: 4; }
.calc-bar-fields {
  display: flex; align-items: flex-end; flex-wrap: wrap;
  gap: 10px 22px; min-width: 0;
}
.calc-group {
  display: flex; flex-direction: column; gap: 5px;
  min-width: 0; margin: 0; padding: 0; border: 0;
}
.calc-group-label,
.calc-input-label {
  display: flex; align-items: center; gap: 6px;
  margin: 0; padding: 0;
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  letter-spacing: 0; white-space: nowrap;
}
.calc-group-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
/* The hiscores row is one control: Fetch belongs to the name field, so the row
   never wraps and the field takes whatever width is left. A wrapped button read
   as a separate action and left the field looking unfinished. */
.calc-group-row:has(> .calc-w-name) { flex-wrap: nowrap; }
.calc-group-row > .calc-w-name { flex: 1 1 auto; min-width: 0; }
.calc-group-row > .calc-mini { flex: 0 0 auto; }
.calc-input {
  display: flex; flex-direction: column; gap: 5px;
  min-width: 0; margin: 0;
}
.calc-input-line {
  display: flex; align-items: center; gap: 6px;
  height: 38px; min-width: 0;
  border-bottom: 1px solid var(--line);
  transition: border-color var(--t-quick) var(--ease);
}
.calc-input-line:focus-within { border-bottom-color: var(--accent); }
.calc-input-line input {
  min-width: 0; width: 100%; height: 36px; padding: 0;
  text-align: left;
  border: 0; outline: 0; background: transparent; color: var(--ink);
  font: var(--fw-medium) var(--text-label)/1.2 var(--mono);
  font-variant-numeric: tabular-nums;
}
.calc-input-line input::placeholder { color: var(--ink-4); }
.calc-input-line input[type="number"] {
  -moz-appearance: textfield; appearance: textfield;
}
.calc-input-line input::-webkit-outer-spin-button,
.calc-input-line input::-webkit-inner-spin-button {
  margin: 0; -webkit-appearance: none;
}
.calc-input-line input[type="search"],
.calc-input-name input {
  font-family: var(--sans); font-weight: var(--fw-regular);
}
.calc-input-line em {
  color: var(--ink-4); font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  font-style: normal;
}
.calc-w-price { width: 150px; }
.calc-w-qty { width: 96px; }
.calc-w-item { width: 280px; }
.calc-w-name { width: 180px; }

.calc-checks { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.calc-check {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-2); font-size: var(--text-label); cursor: pointer;
  white-space: nowrap;
}
.calc-check input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.calc-check:hover span { color: var(--ink); }

.calc-bar-actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; margin-left: auto;
}
.calc-mini {
  height: 34px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--bg-2); color: var(--ink-2);
  font: var(--fw-medium) var(--text-label)/1 var(--sans); cursor: pointer;
}
.calc-mini:hover { border-color: var(--accent-line); color: var(--ink); }
.calc-reset { color: var(--ink-3); font-size: var(--text-label); text-decoration: none; }
.calc-reset:hover { color: var(--accent); }

.calc-hiscore-note,
.calc-note {
  flex: 0 0 100%; margin: 0;
  color: var(--ink-4); font-size: var(--text-micro); line-height: 1.35;
}
.calc-hiscore-note:empty,
.calc-note:empty { display: none; }
.calc-hiscore-note.ok, .calc-note.ok { color: var(--ink-3); }
.calc-hiscore-note.bad, .calc-note.bad { color: var(--down); }

.tax-bar .tax-source { flex: 0 0 100%; margin-top: 4px; }

/* ---- the reading: one answer, one ruled ledger --------------------------- */

.calcview .calc-reading {
  flex: 0 0 auto; min-width: 0;
  padding: 18px 0 20px;
  border: 0; background: transparent; overflow: visible;
}
.calc-read-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}
.calc-read-head h3 {
  margin: 0; color: var(--ink-2);
  font-size: var(--text-label); font-weight: var(--fw-medium);
  letter-spacing: 0; line-height: var(--leading-label);
}
.calc-hero {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 2px 12px; padding: 16px 0 20px;
}
.calc-hero-label {
  width: 100%; color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  letter-spacing: .06em; text-transform: uppercase;
}
.calc-hero b {
  color: var(--ink);
  font: var(--fw-medium) clamp(2rem, 3.2vw, 2.75rem)/1 var(--mono);
  letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.calc-hero p { margin: 0; color: var(--ink-3); font-size: var(--text-body); line-height: 1.4; }
.calc-hero .calc-hero-note {
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-label)/1.4 var(--mono);
}
.tax-profit { padding-right: 0; border-right: 0; }

.calc-facts {
  /* A column of facts beside the hero figure, not a register: the rules it
     carried started and stopped inside the block, so the sheet showed lines
     that went nowhere. Space and labels keep the cells apart. */
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0;
}
.calc-facts > div {
  min-width: 0; padding: 9px 16px 10px;
}
.calc-facts > div:first-child { padding-left: 0; }
.calc-facts dt {
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1.2 var(--mono);
}
.calc-facts dd {
  overflow: hidden; margin: 4px 0 0;
  color: var(--ink-2);
  font: var(--fw-medium) var(--text-label)/1.3 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; text-overflow: ellipsis;
}

.calc-ledgerwrap {
  padding-top: 16px; border-top: 1px solid var(--line);
}
.calc-table-scroll { overflow-x: auto; }
.calc-ledger {
  width: 100%; border-collapse: collapse; table-layout: auto;
  font-variant-numeric: tabular-nums;
}
.calc-ledger th {
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1.2 var(--mono);
  letter-spacing: .06em; text-transform: uppercase;
  text-align: right; white-space: nowrap;
}
.calc-ledger th:first-child { padding-left: 0; text-align: left; }
.calc-ledger td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-3);
  font: var(--fw-medium) var(--text-label)/1.3 var(--mono);
  text-align: right; white-space: nowrap;
}
.calc-ledger td:first-child {
  padding-left: 0; text-align: left;
  color: var(--ink-2); font-family: var(--sans); font-weight: var(--fw-regular);
}
.calc-ledger tbody tr:last-child td { border-bottom: 0; }
.calc-ledger tr.is-total td,
.calc-ledger tr.is-total td:first-child { color: var(--ink); }

.calc-footnote {
  /* A note under the ledger, not a second register: the rule it used to carry
     stopped at the note's measure, so it read as a line that ran out. */
  max-width: 92ch; margin: 14px 0 0;
  color: var(--ink-4); font-size: var(--text-micro); line-height: var(--leading-label);
}
.calc-footnote strong { color: var(--ink-3); font-weight: var(--fw-medium); }

/* ---- skill: the same strip, then the goal and the method ledger ---------- */

/* The ledger borrows the alchemy table's chrome: a 39px sticky header, a
   compact mono rhythm, and the active sort column underlined in accent. */
.calcview .skill-ledger .skill-table thead th {
  height: 39px; padding: 0 10px; vertical-align: middle;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/var(--leading-body) var(--mono);
  letter-spacing: .1em; text-transform: none;
}
.calcview .skill-ledger .skill-table thead th[aria-sort="ascending"],
.calcview .skill-ledger .skill-table thead th[aria-sort="descending"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.calcview .skill-ledger .skill-table tbody td {
  height: 40px; padding: 6px 10px; border-bottom: 1px solid var(--line-soft);
  color: var(--ink-3);
  font: var(--fw-medium) var(--text-label)/var(--leading-body) var(--mono);
}
/* The alchemy ledger rules off its numeric groups; these two hairlines put
   the same seams around XP / # and the materials column. */
.calcview .skill-ledger .skill-table :is(thead th, tbody td):nth-child(3),
.calcview .skill-ledger .skill-table :is(thead th, tbody td):nth-child(5),
.calcview .skill-ledger .skill-table :is(thead th, tbody td):nth-child(7) {
  border-left: 1px solid var(--line-soft);
}
.calcview .skill-ledger .skill-table tbody tr:last-child td { border-bottom: 0; }
.calcview .skill-ledger .skill-table tbody tr:hover td { background: var(--hover); }
.calcview .skill-ledger .skill-table .skill-num { font-family: var(--mono); }
.calcview .skill-ledger .skill-table .skill-lvl { width: 56px; text-align: center; }
.calcview .skill-ledger .skill-table th:first-child { text-align: center; }
.calcview .skill-ledger .skill-table th:first-child .skill-sort { text-align: center; }
.calcview .skill-ledger .skill-table tbody td:first-child { color: var(--ink-4); }
.calcview .skill-ledger .skill-table .skill-lvl span {
  color: var(--ink-4); font: var(--fw-medium) var(--text-micro)/1 var(--mono);
}
.calcview .skill-ledger .skill-table .skill-method-copy b {
  color: var(--ink);
  font-family: var(--sans);
}
.calcview .skill-ledger .skill-table .skill-net { color: var(--ink-3); }
.calcview .skill-ledger .skill-table .skill-net.up { color: var(--up); }
.calcview .skill-ledger .skill-table .skill-net.down { color: var(--down); }

/* # is the planning rail: the workload. The tint and start rule lift it; the
   type stays on the ledger's normal scale so the figures still read as the
   same table. The Net column keeps its money colour but no background tint. */
.calcview .skill-ledger .skill-table thead th[data-sort="runs"] {
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
  border-left: 1px solid var(--line);
}
.calcview .skill-ledger .skill-table tbody td.skill-runs {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  border-left: 1px solid var(--line);
}
.calcview .skill-ledger .skill-table tbody tr:hover td.skill-runs {
  background: color-mix(in srgb, var(--accent) 8%, var(--hover));
}

@media (max-width: 900px) {
  /* The table becomes a stack of cards; keep the planning tint, but there is
     no column edge to draw. */
  .calcview .skill-ledger .skill-table tbody td.skill-runs {
    border-left: 0;
  }
}

/* The method filter is an enhancement, not the calculator's contract: it is
   hidden until skillcalc.js has wired it, while the no-script table remains
   complete underneath. */
.calcview .skill-ledger .skill-method-tools {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft);
}
.calcview .skill-ledger .skill-method-tools[hidden] { display: none; }
.calcview .skill-ledger .skill-method-search {
  position: relative; flex: 1 1 220px; min-width: 0; max-width: 320px;
}
.calcview .skill-ledger .skill-method-search-icon {
  position: absolute; top: 50%; left: 10px;
  width: 14px; height: 14px; transform: translateY(-50%);
  color: var(--ink-4); pointer-events: none;
}
.calcview .skill-ledger .skill-method-search input {
  width: 100%; height: 36px; padding: 0 10px 0 31px;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--field); color: var(--ink);
  font: var(--fw-regular) var(--text-label)/1 var(--sans);
}
.calcview .skill-ledger .skill-method-search input::placeholder {
  color: var(--ink-3); opacity: 1;
}
.calcview .skill-ledger .skill-method-category {
  position: relative; flex: 0 0 150px;
}
.calcview .skill-ledger .skill-method-category select {
  width: 100%; height: 36px; padding: 0 28px 0 10px;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--field); color: var(--ink-2);
  font: var(--fw-regular) var(--text-label)/1 var(--sans);
  appearance: none;
}
.calcview .skill-ledger .skill-method-category select option {
  background: var(--field); color: var(--ink);
}
.calcview .skill-ledger .skill-method-caret {
  position: absolute; top: 50%; right: 10px;
  width: 10px; height: 7px; transform: translateY(-50%);
  color: var(--ink-4); pointer-events: none;
}
.calcview .skill-ledger .skill-method-search input:focus-visible,
.calcview .skill-ledger .skill-method-category select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
  border-color: var(--accent);
}
.calcview .skill-ledger .skill-table tbody tr.skill-row.is-filtered-out {
  display: none;
}
.calcview .skill-ledger .skill-method-empty {
  margin: 12px 0 0; color: var(--ink-4); font-size: var(--text-label);
}
.calcview .skill-ledger .skill-method-empty[hidden] { display: none; }

@media (max-width: 900px) {
  .calcview .skill-ledger .skill-method-tools {
    flex-wrap: wrap; padding-bottom: 10px;
  }
  .calcview .skill-ledger .skill-method-search {
    flex: 1 1 100%; max-width: none;
  }
  .calcview .skill-ledger .skill-method-category { flex: 1 1 100%; }
}

@media (max-width: 560px) {
  /* Keep both planning controls on one line above the card list. */
  .calcview .skill-ledger .skill-method-tools { flex-wrap: nowrap; }
  .calcview .skill-ledger .skill-method-search { flex: 1 1 auto; }
  .calcview .skill-ledger .skill-method-category { flex: 0 0 132px; }
}

/* ---- combat: the stat ticket, then the character readout ---------------- */

/* The combat sheet follows the skill worksheets: the seven base levels are
   the ticket in the left rail, and the answer is the sheet beside it. */
.combatview .combat-desk {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0; overflow: hidden;
}
.combatview .combat-form {
  grid-column: 1; grid-row: 1;
  display: flex; flex-direction: column; flex-wrap: nowrap;
  align-items: stretch; gap: 0;
  height: 100%; padding: 20px 24px 20px 0;
  border: 0; border-right: 1px solid var(--line);
  background: transparent; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
/* The rail is paper from the theme's stack: the card's near-white strip along
   its left edge is what read as a sliver of white cut into the cream. */
.shell[data-screen="tools"] .combatview .combat-desk > .calc-bar {
  background: var(--bg-2);
}
/* The desk's own 24px gutter sat outside the ticket, so the rail's fill began
   inside the card and a white sliver showed down the card's left edge. The
   gutter moves into the rail, and the rail's column widens by the same 24px,
   so the controls and the answer column keep their positions. */
@media (min-width: 901px) {
  .shell[data-screen="tools"] .toolview > .calc-desk.combat-desk,
  .shell[data-screen="tools"] .toolview > .calc-desk.skill-desk {
    padding-left: 0;
  }
  /* The page's own bottom gutter left a strip of ground under every
     calculator. On a calculator the sheet runs to the viewport's edge. */
  .shell[data-screen="tools"]:has(.toolview-calc) .workspace {
    padding-bottom: 0;
  }
  .combatview .combat-desk { grid-template-columns: 300px minmax(0, 1fr); }
  .combatview .combat-form { padding-left: 24px; }
  /* skills.css is loaded after this sheet, so the skill ticket's column and
     its new gutter are named with the page's own root to win the cascade. */
  .shell[data-screen="tools"] .skillview .skill-desk {
    grid-template-columns: 300px minmax(0, 1fr);
  }
  .shell[data-screen="tools"] .skillview .skill-desk > .skill-bar {
    padding-left: 24px;
  }
}
.combatview .calc-combat-top { flex: 0 0 auto; display: block; }
.combatview .calc-combat-hiscores {
  margin: 0 0 14px; padding: 0 0 14px;
  border-bottom: 1px solid var(--line-soft);
}
.combatview .calc-combat-hiscores .calc-group-row {
  flex-wrap: nowrap; gap: 6px;
}
.combatview .calc-combat-hiscores .calc-w-name {
  flex: 1 1 auto; width: auto;
}
.combatview .calc-combat-hiscores .calc-mini { flex: 0 0 auto; }
.combatview .calc-combat-hiscores .calc-hiscore-note {
  margin: 6px 0 0;
}
.combatview .calc-combat-hiscores .calc-hiscore-note:empty { display: none; }
.combatview .calc-combat-stats {
  display: flex; flex: 0 0 auto; flex-direction: column; gap: 5px;
  width: 100%; min-width: 0;
}
.combatview .combat-fields {
  display: flex; flex-direction: column; gap: 0; min-width: 0;
}
.combatview .combat-field {
  display: grid; grid-template-columns: minmax(0, 1fr) 66px;
  align-items: center; gap: 10px;
  min-width: 0; padding: 7px 0;
  border: 0; border-bottom: 1px solid var(--line-soft);
}
.combatview .combat-field:focus-within .calc-input-label { color: var(--ink); }
.combatview .combat-field .calc-input-label {
  display: flex; align-items: center; gap: 7px;
  min-width: 0; color: var(--ink-3);
  font-family: var(--sans); font-size: var(--text-label);
  font-weight: var(--fw-medium); line-height: 1.2; letter-spacing: 0;
}
.combatview .combat-field .combat-field-icon {
  display: block; flex: 0 0 auto;
  width: 16px; height: 16px;
  object-fit: contain; image-rendering: pixelated;
}
.combatview .combat-field .calc-input-line {
  height: 32px; padding: 0 6px;
  border-radius: 4px 4px 0 0;
}
.combatview .combat-field .calc-input-line:hover {
  border-bottom-color: var(--line-strong);
}
.combatview .combat-field .calc-input-line:focus-within {
  background: var(--accent-soft); border-bottom-color: var(--accent);
}
.combatview .combat-field .calc-input-line input {
  height: 30px; text-align: right;
}
.combatview .combat-form > .calc-bar-actions {
  flex: 0 0 auto; width: 100%;
  margin: auto 0 0; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  justify-content: flex-start;
}
/* The group legend uses the same field-group role as the skill ticket. */
.combatview .calc-group-label {
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.2;
  letter-spacing: 0;
}
.combatview .combat-result {
  grid-column: 2; grid-row: 1;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  padding: 20px 0 20px 28px;
  border: 0; background: transparent;
  overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.combatview .cru { gap: 14px; }
.combatview .cru-top { align-items: baseline; }
.combatview .cru-kicker {
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: var(--text-label);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
}
.combatview .cru-target { font-size: var(--text-micro); }
.combatview .cru-target b {
  font-size: var(--text-label);
  letter-spacing: 0;
}
.combatview .cru-hero { align-items: flex-end; padding: 4px 0 2px; }
.combatview .cru .combat-level {
  font-size: clamp(2rem, 3.2vw, 2.75rem);
  line-height: 1;
  letter-spacing: -.03em;
}
.combatview .cru .combat-level-whole { font-size: inherit; }
.combatview .cru .combat-level-frac { font-size: .5em; letter-spacing: 0; }
.combatview .cru-plan-head {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 72px;
  align-items: baseline; gap: 10px; padding: 0 0 9px;
  border-bottom: 1px solid var(--line);
  font: var(--fw-medium) var(--text-label)/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.combatview .cru-plan-title {
  grid-column: 1 / 3; margin: 0;
  color: var(--ink);
  font-family: var(--sans); font-size: var(--text-heading);
  font-weight: var(--fw-medium); line-height: 1.2;
  letter-spacing: -.01em; text-transform: none;
}
.combatview .cru-plan-title b {
  color: var(--accent);
  font-family: var(--mono); font-size: 1.15em;
  font-weight: var(--fw-medium); font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}
.combatview .cru-plan-col { color: var(--ink-4); text-align: right; }
.combatview .cru-plan-adds { grid-column: 3; }
.combatview .cru-route {
  grid-template-columns: 36px minmax(0, 1fr) 72px;
  gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  transition: background-color var(--t-quick) var(--ease),
              border-color var(--t-quick) var(--ease);
}
.combatview .cru-route:last-child { border-bottom: 0; }
.combatview .cru-route img {
  display: block; width: 28px; height: 28px; padding: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 6%, var(--field));
  object-fit: contain; image-rendering: pixelated;
  transition: border-color var(--t-quick) var(--ease);
}
.combatview .cru-route-main {
  display: flex; align-items: baseline; gap: 12px; min-width: 0;
}
.combatview .cru-skill {
  color: var(--ink);
  font-size: var(--text-body);
  font-weight: var(--fw-medium);
  line-height: 1.3;
}
.combatview .cru-levels {
  display: inline-flex; align-items: baseline; gap: 4px;
  min-width: 0; padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-label)/1.3 var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.combatview .cru-levels b {
  color: var(--ink); font-weight: var(--fw-medium);
}
.combatview .cru-levels i { color: var(--accent); }
.combatview .cru-add {
  min-width: 0; color: var(--accent);
  font: var(--fw-medium) 20px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; text-align: right;
}
@media (hover: hover) {
  .combatview .cru-route:hover { background: var(--hover); }
  .combatview .cru-route:hover img {
    border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  }
}
.combatview .combat-footnote { margin-top: 12px; }
.combatview .calc-hiscore-note { flex-basis: auto; }

@media (max-width: 1200px) {
  .calc-w-item { width: 220px; }
  .calcview .calc-bar { gap: 10px 18px; }
  .calc-bar-fields { gap: 10px 18px; }
  /* The skill ticket takes the line; its action drops below rather than
     running into the last group. The tax strip still fits on one line. */
  .calcview .skill-bar .calc-bar-fields { flex: 1 1 100%; }
  .calcview .skill-bar .calc-bar-actions {
    width: 100%; margin-left: 0; padding-top: 2px;
    justify-content: flex-end;
  }
}

@media (max-width: 900px) {
  .calcview .calc-stack { min-height: 0; overflow: visible; }
  /* The market turns every board table into Buy/Sell cards. A receipt is a
     table at every width: keep its four columns and drop the card labels. */
  .board-body .calc-ledger tbody td:nth-child(3),
  .board-body .calc-ledger tbody td:nth-child(4),
  .board-body .calc-ledger tbody td:nth-child(5),
  .board-body .calc-ledger tbody td:nth-child(6) {
    display: table-cell; text-align: right;
  }
  .board-body .calc-ledger tbody td:nth-child(3)::before,
  .board-body .calc-ledger tbody td:nth-child(4)::before,
  .board-body .calc-ledger tbody td:nth-child(5)::before,
  .board-body .calc-ledger tbody td:nth-child(6)::before {
    content: none; display: none;
  }
  .calc-stack > .calc-bar { position: static; }
  .calcview .calc-bar { flex-wrap: wrap; }
  .calcview .calc-stack > .combat-form,
  .calcview .calc-stack > .combat-result { order: 0; }
  .calc-bar-actions { margin-left: 0; }
  /* Below the width that fits seven stats beside the action, the stats take
     the line and the action sits under them. */
  .calcview .calc-combat-stats { flex: 0 0 100%; }
  .calcview .combat-form > .calc-bar-actions {
    width: 100%; margin-left: 0; justify-content: flex-end;
  }
}

@media (max-width: 760px) {
  .calcview .calc-bar { padding: 12px 0 14px; gap: 12px; }
  .calc-bar-fields { width: 100%; flex-direction: column; align-items: stretch; gap: 12px; }
  .calc-group { width: 100%; }
  .calc-group-row { width: 100%; }
  .calc-input { flex: 1 1 90px; width: auto; }
  .calc-input-line { width: 100%; }
  .calc-w-name, .calc-w-item { width: auto; }
  .calc-bar-actions { width: 100%; justify-content: flex-end; }
  .calcview .calc-combat-top { flex-direction: column; align-items: stretch; }
  .calcview .calc-combat-hiscores { width: 100%; }
  .calcview .combat-form > .calc-bar-actions { justify-content: flex-end; }
  .calcview .combat-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
  .calcview .calc-combat-stats { width: 100%; }
  .calcview .combat-field { width: auto; }
  .calc-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc-facts > div { padding: 9px 12px; }
  .calc-facts > div:nth-child(odd) { padding-left: 0; }
  .calc-hero b { font-size: var(--text-title); }
  .calc-ledger th, .calc-ledger td { padding-left: 6px; padding-right: 6px; }
  .combatview .cru-plan-head,
  .combatview .cru-route { grid-template-columns: 32px minmax(0, 1fr) 64px; }
  .combatview .cru-route-main { gap: 9px; }
  .combatview .cru-levels { padding-left: 9px; }
}

@media (max-width: 440px) {
  .calc-input { flex-basis: calc(50% - 6px); }
  .calc-input.calc-w-price,
  .calc-input.calc-w-item { flex-basis: 100%; }
  .calc-ledger { font-size: var(--text-label); }
}

@media (prefers-reduced-motion: reduce) {
  .calc-pulse { animation: none; }
}

/* The combat ticket becomes a full-width strip on a phone, exactly as the
   skill ticket does; the answer follows it in the page flow. */
@media (max-width: 900px) {
  .combatview .combat-desk {
    display: flex; flex-direction: column;
    min-height: 0; overflow: visible;
  }
  .combatview .combat-form {
    width: 100%; height: auto; padding: 16px;
    border-right: 0; border-bottom: 1px solid var(--line);
    overflow: visible;
  }
  .combatview .combat-result {
    width: 100%; padding: 16px;
    border-bottom: 0; overflow: visible;
  }
  .combatview .calc-combat-stats { flex: 0 0 auto; }
  .combatview .combat-fields {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
  }
  .combatview .combat-form > .calc-bar-actions {
    margin-top: 14px; justify-content: flex-start;
  }
}

@media (max-width: 380px) {
  .combatview .combat-fields { grid-template-columns: minmax(0, 1fr); }
}

/* The shared .calc-stack display rule is declared later than the tax desk
   rules above. Reassert the tax grid at the end of the cascade so the receipt
   keeps its column instead of falling below a full-width form. */
@media (min-width: 901px) {
  .calcview .calc-stack.tax-desk {
    display: grid;
    grid-template-columns: 276px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }
  .calcview .calc-stack.tax-desk > .tax-bar { position: static; }
}

/* ---- related calculators and the new tool pages -------------------------- */
.tool-related h2,
.hb-tools h2 {
  margin: 0 0 10px;
  color: var(--ink-2);
  font: var(--fw-medium) var(--text-label)/1.3 var(--sans);
}
.tool-related ul,
.hb-tools ul {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tool-related a,
.hb-tools a {
  color: var(--ink-3);
  font-size: var(--text-label);
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
.tool-related a:hover,
.hb-tools a:hover { color: var(--accent); }
.hb-tools {
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line-soft);
}

/* A material is a link to the item's own page now. It keeps the reagent's own
   type and gains the accent on hover, so the ledger still reads as a table
   rather than a wall of links. */
a.skill-reagent { color: inherit; text-decoration: none; }
a.skill-reagent:hover span:last-child,
a.skill-reagent:focus-visible span:last-child {
  color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px;
}
a.skill-reagent:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 2px;
}

/* A method whose name is an item on the catalogue links to that item's page.
   The anchor wraps the row's icon and name, so it is display:contents: the two
   spans stay the flex children the table's layout was built around, and only
   the name takes the hover. The focus ring moves to the name because the
   anchor itself has no box. */
a.skill-method-link {
  display: contents;
  color: inherit; text-decoration: none;
}
a.skill-method-link:hover b,
a.skill-method-link:focus-visible b {
  color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px;
}
a.skill-method-link:focus-visible { outline: none; }
a.skill-method-link:focus-visible b {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px;
}

/* ------------------------------------------------------- the tax ticket --- */
/* The tax calculator asks for three numbers and answers with one, so its desk
   is a single column: the fields on their rule, the answer under them. The
   two-column desk it shared with the alch and limit finders spread four
   numbers across the whole frame (a five-cell strip and a four-column ledger
   restating the same sale) and left the right half of the page empty below it.

The answer band is one line of reading: what you keep, then the sale it came
from and the fee taken out of it, then the per-item figures worth checking
before an offer goes up. Scoped by id because the shared desk rules set their
own grid at two breakpoints, and this screen does not want either. */

#shell[data-screen="tools"] .calcview .tax-desk {
  display: block;
  height: auto; min-height: 0;
  overflow: visible;
}
/* Three fields, one note, one Reset: a two-row strip rather than a column of
   wide empty inputs. The grid is what holds the fields at their own width when
   the desk is 1200px wide; a flex row let the item field take the room. */
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar {
  position: static;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "fields . actions" "source source source";
  align-items: end;
  padding: 12px 0 10px;
  gap: 10px 18px;
  /* The desk's column divider belongs to the two-column layout, not to this
     strip: left on, it drew a line down the form's right edge beside Reset.
     The strip's own rule is the one under it, as on every other calculator. */
  border-right: 0;
  border-bottom: 1px solid var(--line);
}
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-bar-fields {
  grid-area: fields;
  display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end;
  gap: 10px 18px; width: auto;
}
/* A shared rule widens every desk field to the desk; this strip is three short
   ones beside a Reset. */
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-input { width: auto; }
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-w-price {
  flex: 0 0 168px; width: 168px;
}
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-w-qty {
  flex: 0 0 92px; width: 92px;
}
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-w-item {
  flex: 0 1 300px; width: 300px; min-width: 200px; max-width: 340px;
}
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .tax-source {
  grid-area: source; width: auto; margin-top: 0;
}
#shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-bar-actions {
  grid-area: actions; width: auto; margin-left: 0;
  /* Reset sits in the strip's first row; the rule above it was the divider over
     the column layout's foot, and here it was a stub under nothing. */
  border-top: 0;
  padding-top: 0;
}
#shell[data-screen="tools"] .calcview .tax-desk > .tax-receipt {
  display: block;
  height: auto; min-height: 0;
  padding: 16px 0 18px;
  border: 0;
  overflow: visible;
}
/* A short answer does not need a card 450px taller than its content: the plate
   ends where the ticket does instead of framing empty paper. */
#shell[data-screen="tools"] .list-card:has(.taxview) {
  flex-grow: 0;
  align-self: stretch;
}

.tax-settle {
  /* The sale and the fee sit beside the money kept, not at the far edge of the
     frame: the question is one number, and the arithmetic behind it belongs
     within reading distance of it. */
  display: flex; align-items: flex-end; justify-content: flex-start;
  flex-wrap: wrap; gap: 12px 56px; min-width: 0;
}
.tax-net {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0 8px; min-width: 0;
}
.tax-kicker {
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1 var(--mono);
  letter-spacing: .06em; text-transform: uppercase;
}
/* The chip lives beside the label here, not at the far edge of a heading row. */
.tax-net .tax-state { margin-left: 0; font-size: var(--text-micro); }
.tax-net-figure {
  flex: 0 0 100%; margin-top: 7px;
  color: var(--ink);
  font: var(--fw-medium) var(--text-title)/1 var(--mono);
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tax-net-figure span {
  color: var(--ink-3);
  font-size: var(--text-body); letter-spacing: 0;
}
.tax-sums { min-width: 232px; margin: 0; }
.tax-sums div {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 18px; padding: 3px 0;
}
.tax-sums dt {
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1.2 var(--mono);
}
.tax-sums dd {
  margin: 0;
  color: var(--ink-2);
  font: var(--fw-medium) var(--text-label)/1.2 var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tax-sums dd em {
  color: var(--ink-4); font-style: normal;
}
.tax-lines {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 8px 26px;
  margin: 15px 0 0; padding-top: 11px;
  border-top: 1px solid var(--line-soft);
}
.tax-lines div { display: flex; align-items: baseline; gap: 8px; }
.tax-lines dt {
  color: var(--ink-4);
  font: var(--fw-medium) var(--text-micro)/1.2 var(--mono);
}
.tax-lines dd {
  margin: 0;
  color: var(--ink-2);
  font: var(--fw-medium) var(--text-label)/1.2 var(--mono);
  font-variant-numeric: tabular-nums;
}
.tax-receipt .calc-footnote { max-width: 70ch; margin: 13px 0 0; }

/* The Item field's answers are the site's own dropdown, worn unchanged: the
   search card's plate and its rows. It is fixed to the window rather than hung
   inside the field because the desk's card clips what it contains; initTaxCalc
   places it against the field's own box and keeps it there while the page
   moves. */
#shell[data-screen="tools"] .calcview .tax-suggest {
  position: fixed; left: auto; right: auto; top: auto;
  width: 300px; max-width: none;
  z-index: 95;
}
/* The row the arrow keys are on has to say so. The pane paints every button
   in it with its own ink and plate, and that rule outranks the answer row's;
   on the search card the same plate is the card's own fill, which is why a
   marked answer there only darkened its words. */
#shell[data-screen="tools"] .calcview .tax-suggest .sug:hover,
#shell[data-screen="tools"] .calcview .tax-suggest .sug.on,
#shell[data-screen="tools"] .calcview .tax-suggest .sug[aria-selected="true"],
#shell[data-screen="tools"] .calcview .tax-suggest .sug:focus-visible {
  background-color: var(--hover);
  color: var(--ink);
}

@media (max-width: 620px) {
  /* Two short fields on a line, the item under them: the strip a phone can
     fill without scrolling the answer away. */
  #shell[data-screen="tools"] .calcview .tax-desk > .tax-bar {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "fields" "source" "actions";
  }
  #shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-bar-fields {
    width: 100%;
  }
  #shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-w-price,
  #shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-w-qty {
    flex: 0 0 calc(50% - 9px); width: calc(50% - 9px);
  }
  #shell[data-screen="tools"] .calcview .tax-desk > .tax-bar .calc-w-item {
    flex: 1 1 100%; width: 100%; max-width: none;
  }
  .tax-settle { gap: 12px; }
  .tax-sums { width: 100%; min-width: 0; }
  .tax-lines { gap: 6px 20px; }
  .tax-lines div { gap: 6px; }
}
