/* Skill calculators: shared styles for every rs3-<skill> and osrs-<skill> page.
   Layout: status band on top, then inputs on the left and the plan on the right.
   Each page sets --accent (the skill's colour) on <body data-accent>. */
:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --sunk: #ecebe7;
  --line: #dcdad3;
  --fg: #1f1d1a;
  --muted: #67635b;
  --accent: #6b4fbb;
  --accent-ink: #ffffff;
  --good: #2f7d3c;
  --bad: #b0283c;
  --warn-bg: #fff3dc;
  --warn-fg: #6e4f00;
  --font-display: "Alegreya", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312; --surface: #1c1c1a; --sunk: #252522; --line: #34332f;
    --fg: #ecebe6; --muted: #a29e94; --accent-ink: #141414;
    --good: #66c473; --bad: #f06a7c; --warn-bg: #3a2c10; --warn-fg: #f2d38a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131312; --surface: #1c1c1a; --sunk: #252522; --line: #34332f;
  --fg: #ecebe6; --muted: #a29e94; --accent-ink: #141414;
  --good: #66c473; --bad: #f06a7c; --warn-bg: #3a2c10; --warn-fg: #f2d38a; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
.sk-wrap {
  max-width: 1160px; margin: 0 auto;
  padding-block: 20px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; gap: 20px;
}
h1, h2 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; }
h1 { font-size: 1.9rem; line-height: 1.15; }
h2 { font-size: 1.25rem; }
p { margin: 0; }
.label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.intro { color: var(--muted); max-width: 72ch; }
.notice { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 10px 14px; font-size: 0.9rem; }

.status { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 10px; padding: 20px; display: grid; gap: 16px; }
.status-top { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: flex-end; justify-content: space-between; }
.figures { display: flex; flex-wrap: wrap; gap: 12px 32px; }
.figure .big { font-family: var(--font-data); font-size: 1.6rem; font-weight: 500; line-height: 1.1; }
.bar { position: relative; height: 14px; background: var(--sunk); border-radius: 7px; overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 7px; }
.bar-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.82rem; color: var(--muted); }

.console { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .console { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: grid; gap: 14px; min-width: 0; }
.plan { display: grid; gap: 20px; min-width: 0; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) 132px; align-items: center; gap: 10px; }
.field label { font-size: 0.9rem; min-width: 0; }
.field input, .field select, .tools input[type="search"], .tools select {
  width: 100%; font: inherit; font-variant-numeric: tabular-nums;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg);
}
.field input { font-family: var(--font-data); text-align: right; }
.field input:focus-visible, .field select:focus-visible, .tools input:focus-visible, .tools select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.check small { display: block; color: var(--muted); font-size: 0.8rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }

.next { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: center; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 14px 16px; }
@media (max-width: 560px) { .next { grid-template-columns: minmax(0, 1fr); } }
.next .what { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; line-height: 1.15; }
.kpis { display: flex; flex-wrap: wrap; gap: 12px 26px; }
.kpi .v { font-family: var(--font-data); font-size: 1.15rem; }
.row-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.toggle button { font: inherit; font-size: 0.85rem; padding: 5px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tools input[type="search"] { width: 200px; }
.tools .check { align-items: center; }
.tools .check input { margin-top: 0; }
.tools select { width: auto; }

.table-wrap { overflow-x: auto; }
.table-wrap.tall { max-height: 640px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); }
th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1; }
td { white-space: nowrap; }
td.wrap { white-space: normal; min-width: 180px; }
td.n, th.n { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
tr.locked td { color: var(--muted); }
tr.pick td:nth-child(2) { font-weight: 600; }
tr.pick td:nth-child(2)::before { content: "▸ "; color: var(--accent); }
td.profit { color: var(--good); }
td.cost { color: var(--bad); }
tfoot td { font-weight: 600; border-bottom: 0; }
td input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.cat { font-size: 0.75rem; padding: 1px 7px; border-radius: 999px; background: var(--sunk); color: var(--muted); margin-left: 6px; }
.mats { color: var(--muted); font-size: 0.82rem; }
td input.bank { width: 92px; font: inherit; font-family: var(--font-data); font-variant-numeric: tabular-nums; text-align: right;
  padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
td input.bank:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
td input.bank[aria-invalid="true"] { border-color: var(--bad); }
.cat.bundle { background: var(--warn-bg); color: var(--warn-fg); }
.sk-foot { font-size: 0.82rem; color: var(--muted); }
.sk-foot a { color: inherit; }

/* XP boosts (RS3) */
details.boosts { border: 1px solid var(--line); border-radius: 8px; padding: 0; }
details.boosts > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; justify-content: space-between; padding: 10px 32px 10px 12px; position: relative; }
details.boosts > summary::-webkit-details-marker { display: none; }
details.boosts > summary::after { content: "▾"; color: var(--muted); position: absolute; right: 12px; top: 10px; }
details.boosts[open] > summary::after { content: "▴"; }
details.boosts > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.boost-total { font-family: var(--font-data); font-size: 0.85rem; color: var(--fg); }
.boost-body { display: grid; gap: 14px; padding: 4px 12px 12px; border-top: 1px solid var(--line); }
.boost-group { display: grid; gap: 8px; padding-top: 10px; }
.boost-group .field label small { display: block; color: var(--muted); font-size: 0.78rem; }
td input.bank::placeholder { color: var(--muted); opacity: 0.8; font-family: var(--font-body); font-size: 0.8rem; }

/* Tables that don't fit their panel become small cards (engine.js adds .cards after measuring),
   so nothing ever scrolls sideways, on a phone or a desktop. Column names come from data-label;
   the first cell with a name (method or item) spans the card. */
table.stack.cards, table.stack.cards tbody, table.stack.cards tfoot { display: block; width: 100%; }
table.stack.cards thead { display: none; }
table.stack.cards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
table.stack.cards td { display: block; border: 0; padding: 0; min-width: 0; white-space: normal; text-align: left; }
table.stack.cards td.n { text-align: left; }
table.stack.cards td.wrap { min-width: 0; }
table.stack.cards td[data-label]::before { content: attr(data-label); display: block; font-family: var(--font-body); font-size: 0.66rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 1px; }
table.stack.cards td input.bank { width: 100%; max-width: 120px; }
/* Route: levels + method across the top */
#sk-route-table.cards td:nth-child(1) { grid-column: 1 / 2; }
#sk-route-table.cards td:nth-child(2) { grid-column: 2 / -1; }
#sk-route-table.cards td:nth-child(1)::before, #sk-route-table.cards td:nth-child(2)::before { display: none; }
#sk-route-table.cards td:nth-child(1) { font-family: var(--font-data); font-weight: 600; }
#sk-route-table.cards td:nth-child(2) { font-weight: 600; }
/* Shopping list: item name across the top */
#sk-shop-table.cards tbody td:nth-child(1) { grid-column: 1 / -1; font-weight: 600; }
#sk-shop-table.cards tbody td:nth-child(1)::before { display: none; }
#sk-shop-table.cards tfoot tr { grid-template-columns: minmax(0, 1fr) auto; border-bottom: 0; padding: 8px 0 0; }
#sk-shop-table.cards tfoot td { font-weight: 600; }
#sk-shop-table.cards tfoot td.n { text-align: right; }
/* Methods: tick box + name across the top */
#sk-methods-table.cards tr { grid-template-columns: auto repeat(3, minmax(0, 1fr)); }
#sk-methods-table.cards td:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / span 6; }
#sk-methods-table.cards td:nth-child(2) { grid-column: 2 / -1; font-weight: 600; }
#sk-methods-table.cards td:nth-child(1)::before, #sk-methods-table.cards td:nth-child(2)::before { display: none; }
#sk-methods-table.cards td.mats { grid-column: 2 / -1; }
.methods-panel { margin-top: 0; }
.table-wrap.tall:has(table.cards) { max-height: 70vh; }
/* In cards, tags wrap onto the next line instead of poking past the edge. */
table.stack.cards td { overflow-wrap: anywhere; }
table.stack.cards .cat { display: inline-block; margin: 2px 6px 0 0; }
