/* Tool pages (planner, leveling, mastery, market) and the chart kit. */

.tools-head { max-width: 1180px; margin: 0 auto; padding: 8px 20px 18px; }
.tools-head h1 { margin: 0 0 8px; }
.tools-head p { color: var(--on-sea); font-size: 18px; margin: 0; }
.tools-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.tools-nav .pill { font-size: 15px; }

.tool-grid { max-width: 1180px; margin: 0 auto; padding: 0 20px; display: grid; gap: 24px; }
.panel h2 .ptext { --s: 1; }
.panel > h2 { margin-top: 0; }
.panel .lede { color: var(--text-dim); margin-bottom: 18px; }

/* Controls: one row above everything they scope. */
.controls { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-end; }
.control { display: grid; gap: 6px; min-width: 150px; }
.control label, .control .control-label { font-weight: 700; font-size: 15px; color: var(--text); }
.control output { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.control input[type="range"] { width: 220px; accent-color: var(--gold); }
.control select, .control input[type="number"] {
  font: inherit; font-size: 16px; color: var(--text); background: var(--tile);
  border: 2px solid var(--panel-lo); border-radius: 8px; padding: 7px 10px; min-width: 150px;
}
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg .pill { font: inherit; font-size: 15px; font-weight: 700; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 22px 0 6px; }
.stat { border: 18px solid transparent; border-image: url("../assets/ui/MenuRowStrip.png") 12 fill / 18px stretch; image-rendering: pixelated; background: none; border-radius: 0; padding: 0 2px 2px; display: grid; gap: 2px; align-content: start; }
.stat-label { font-size: 14px; color: var(--text-dim); }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.15; display: flex; align-items: center; gap: 8px; }
.stat-value img { width: 28px; height: 28px; }
.stat-sub { font-size: 14px; color: var(--text-dim); }

.chart-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.chart-title { font-weight: 700; font-size: 17px; margin: 0 0 4px; }
.chart-sub { font-size: 14px; color: var(--text-dim); margin: 0 0 12px; }
.footnote { font-size: 14px; color: var(--text-dim); margin-top: 14px; }

/* ---- Bars ---------------------------------------------------------------- */
.viz-bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.viz-bar-row {
  display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: center; gap: 10px;
  border-radius: 6px; padding: 2px 4px; outline-offset: 2px;
}
.viz-bar-row:hover, .viz-bar-row:focus-visible { background: rgb(255 255 255 / 0.05); }
.viz-bar-label { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); min-width: 0; }
.viz-bar-label img { width: 24px; height: 24px; flex: none; }
.viz-bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-bar-row.is-emph .viz-bar-name { font-weight: 700; }
.viz-bar-track { position: relative; height: 22px; margin-right: 76px; }
.viz-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  border-radius: 0 4px 4px 0;
  transition: width 450ms cubic-bezier(.2,.7,.2,1), background-color 300ms;
}
.viz-bar-value {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: left 450ms cubic-bezier(.2,.7,.2,1);
}
.viz-bars.is-empty::after { content: attr(data-empty); color: var(--text-dim); }

/* ---- Lines --------------------------------------------------------------- */
.viz-lines { position: relative; width: 100%; }
.viz-lines svg { display: block; overflow: visible; touch-action: pan-y; }
.viz-grid line { stroke: var(--rule); stroke-width: 1; }
.viz-tick { fill: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.viz-axis-label { fill: var(--text-dim); font-size: 12px; font-weight: 700; }
.viz-end-label, .viz-mark-label { fill: var(--text); font-size: 13px; font-weight: 700; paint-order: stroke; stroke: #14102a; stroke-width: 4px; }
.viz-mark-label { font-weight: 600; font-size: 12px; }
.viz-crosshair { stroke: var(--text-dim); stroke-width: 1; }
.viz-you-rule { stroke: var(--gold); stroke-width: 1; opacity: 0.5; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 14px; color: var(--text); }
.viz-legend:empty { display: none; }
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend-item i { width: 14px; height: 2px; border-radius: 1px; }

/* ---- Tooltip ------------------------------------------------------------- */
.viz-tip {
  position: absolute; left: 0; top: 0; z-index: 60; pointer-events: none;
  background: #fff; color: var(--ink);
  border: 2px solid var(--dialog-ink); border-radius: 8px; padding: 8px 10px;
  box-shadow: inset 3px -3px 0 var(--dialog-shade), 0 3px 0 rgb(20 16 42 / 0.4);
  font-size: 14px; opacity: 0; transition: opacity 120ms;
  max-width: 260px;
}
.viz-tip.is-on { opacity: 1; }
.viz-tip-title { font-weight: 700; margin-bottom: 4px; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; }
.viz-tip-row i { width: 12px; height: 2px; flex: none; }
.viz-tip-row strong { font-variant-numeric: tabular-nums; }
.viz-tip-row span { color: #5f5873; }

/* ---- Sparklines (market board) -------------------------------------------- */
.viz-spark-base { stroke: #3a3370; stroke-width: 1; }

/* ---- Table twin ---------------------------------------------------------- */
.viz-table { margin-top: 14px; }
.viz-table summary { cursor: pointer; color: var(--gold); font-weight: 700; font-size: 15px; }
.viz-table-scroll { overflow-x: auto; margin-top: 10px; }
.viz-table table { border-collapse: collapse; width: 100%; font-size: 14px; }
.viz-table th, .viz-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.viz-table th { color: var(--text-dim); font-weight: 700; }
.viz-table .num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .chart-pair { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tools-head { padding: 4px 16px 14px; }
  .tool-grid { padding: 0 16px; }
  .control input[type="range"] { width: 100%; }
  .control { min-width: 0; flex: 1 1 100%; }
  .viz-bar-row { grid-template-columns: 96px minmax(0, 1fr); }
  .viz-bar-track { margin-right: 64px; }
  .stat-value { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .viz-bar-fill, .viz-bar-value { transition: none; }
}

/* Unlock ladder (leveling) */
.unlock-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px; }
.unlock { display: grid; grid-template-columns: 52px 30px 1fr; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 15px; }
.unlock-level { font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.unlock-art img { max-width: 28px; max-height: 24px; display: block; }
.unlock.is-done { opacity: 0.45; }
.unlock.is-ahead { background: rgb(255 205 117 / 0.1); }
.unlock.is-ahead .unlock-level { color: var(--gold); }

.plain-table { border-collapse: collapse; width: 100%; font-size: 15px; }
.plain-table th, .plain-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); }
.plain-table th { color: var(--text-dim); font-weight: 700; font-size: 14px; }
.plain-table td:first-child { font-weight: 700; white-space: nowrap; }

/* Market board: small multiples, one card per crop, same scale per card */
.market-board { list-style: none; margin: 0; padding: 0; max-width: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.market-card { border: 18px solid transparent; border-image: url("../assets/ui/MenuRowStrip.png") 12 fill / 18px stretch; image-rendering: pixelated; background: none; border-radius: 0; padding: 0 2px; }
.market-card.is-hot { filter: drop-shadow(0 0 5px rgb(255 205 117 / 0.7)); }
.mc-head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.mc-head img { width: 24px; height: 24px; }
.mc-name { flex: 1; }
.mc-badge { font-size: 12px; font-weight: 700; color: var(--ink); background: var(--gold); border-radius: 99px; padding: 2px 8px; }
.mc-price { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 4px; }
.mc-price strong { font-size: 24px; }
.mc-mult { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.market-banner { background: rgb(255 205 117 / 0.12); border: 2px solid var(--gold); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 700; }

/* Price bands */
.ranges { display: grid; gap: 6px; }
.range-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); align-items: center; gap: 10px; padding: 2px 4px; border-radius: 6px; }
.range-row:hover, .range-row:focus-visible { background: rgb(255 255 255 / 0.05); }
.range-label { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.range-label img { width: 24px; height: 24px; }
.range-track { position: relative; height: 22px; }
.range-band { position: absolute; top: 5px; bottom: 5px; background: var(--muted); border-radius: 4px; }
.range-one { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--text-dim); opacity: 0.5; }
.range-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px #14102a; transition: left 450ms; }
.range-axis { position: relative; height: 20px; margin-left: 138px; font-size: 12px; color: var(--text-dim); }
.range-axis span { position: absolute; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .range-row { grid-template-columns: 96px minmax(0, 1fr); }
  .range-axis { margin-left: 106px; }
  .market-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Rare drops */
.setup-h { font-size: 17px; margin: 26px 0 10px; color: var(--text); }
.keystones { margin-top: 18px; gap: 12px 22px; }
.control-note { font-size: 13px; color: var(--text-dim); }
.control input[type="range"]:disabled { opacity: 0.35; }
.rkey { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: 0; }
.multiples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 32px; }
.multiple { margin: 0; }
@media (max-width: 900px) { .multiples { grid-template-columns: 1fr; } }
.tool-grid > * { min-width: 0; }
