:root {
  --bg: #14161a; --panel: #1c1f25; --line: #2c313a; --text: #e6e8eb; --muted: #8b93a1;
  --accent: #f0b23a; --c-min: #f0b23a; --c-recent: #5fb3f5; --c-market: #7bd88f;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f6f7f9; --panel: #fff; --line: #dde1e7; --text: #1b1e23; --muted: #667080;
    --accent: #b97a00; --c-min: #c98400; --c-recent: #1f7fd1; --c-market: #2f9a4a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }
header { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { color: var(--accent); font-weight: 700; text-decoration: none; font-size: 16px; }
#q { flex: 1 1 240px; min-width: 0; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 14px; }
select { padding: 7px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
footer { max-width: 1400px; margin: 0 auto; padding: 8px 16px 32px; font-size: 12px; }
h2 { margin: 8px 0 4px; font-size: 20px; }
h3 { margin: 20px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.n { text-align: right; font-variant-numeric: tabular-nums; }
#results tbody tr { cursor: pointer; }
#results tbody tr:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.controls { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: var(--panel); color: var(--text); border: 0; border-right: 1px solid var(--line);
  padding: 6px 12px; cursor: pointer; font: inherit; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #14161a; font-weight: 600; }
#chart { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; position: relative; }
#chart svg { display: block; width: 100%; height: 340px; }
#chart text { fill: var(--muted); font-size: 11px; }
#chart .gl { stroke: var(--line); stroke-width: 1; }
#chart .s-min { stroke: var(--c-min); fill: var(--c-min); }
#chart .s-recent { stroke: var(--c-recent); fill: var(--c-recent); }
#chart .s-market { stroke: var(--c-market); fill: var(--c-market); }
#chart path { fill: none; stroke-width: 2; }
#chart .cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
#tip { position: fixed; pointer-events: none; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; font-size: 12px; z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
#tip b { display: block; margin-bottom: 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }
#hours { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.hour { display: grid; grid-template-columns: 44px 1fr 90px 48px 30px; gap: 8px; align-items: center; font-size: 12px; padding: 1px 0; }
.hour.head { font-size: 11px; padding-bottom: 4px; }
.hour .bar { height: 10px; background: var(--c-min); border-radius: 2px; min-width: 2px; }
.hour .low { background: var(--c-market); }
.hour .high { background: #e06c5c; }
.coin-g { color: #e9c349; } .coin-s { color: #b9c0cc; } .coin-c { color: #c98a5a; }
.nav { color: var(--text); text-decoration: none; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; }
.nav:hover { border-color: var(--accent); color: var(--accent); }
table.rows tbody tr { cursor: pointer; }
table.rows tbody tr:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
#legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 6px; font-size: 12px; }
table.recipes td { vertical-align: top; white-space: normal; }
table.recipes td.n { white-space: nowrap; }
.pos { color: var(--c-market); } .neg { color: #e06c5c; }
#min-sold { padding: 2px 4px; }
table.rows td:first-child { white-space: normal; min-width: 220px; }
.star { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 15px; padding: 0 4px 0 0; line-height: 1; }
.star.big { font-size: 22px; }
.p { cursor: help; border-bottom: 1px dotted color-mix(in srgb, var(--muted) 60%, transparent); }
sup.src { color: var(--muted); font-size: 9px; margin-left: 2px; }
#tip div + div { margin-top: 6px; }
#tip .tip-title { font-weight: 600; color: var(--accent); }
.controls label { display: inline-flex; align-items: center; gap: 6px; }
.controls select { padding: 4px 6px; }
.setting { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 16px 12px; margin: 12px 0; max-width: 720px; }
.setting label { display: block; padding: 4px 0; cursor: pointer; }
.seg button:disabled { opacity: .4; cursor: default; }
.icon { width: 20px; height: 20px; border-radius: 3px; vertical-align: middle; margin-right: 6px; display: inline-block;
  background: var(--line); border: 1px solid var(--line); }
.icon.big { width: 36px; height: 36px; margin-right: 10px; }
.help { cursor: help; text-decoration: underline dotted color-mix(in srgb, var(--muted) 70%, transparent); text-underline-offset: 3px; }
#tip { max-width: 340px; line-height: 1.4; }
.tooltip { display: inline-block; min-width: 260px; max-width: 420px; background: #0c0e14; color: #e8e8e8; border: 1px solid #5a6072;
  border-radius: 6px; padding: 10px 12px; margin: 4px 0 12px; font-size: 13px; line-height: 1.5; }
.tooltip .tt-name { font-size: 15px; font-weight: 600; }
.tooltip .tt-effect { color: #1eff00; }
.tooltip .tt-flavor { color: #ffd100; font-style: italic; }
.tooltip .tt-note { color: #87abff; }
.tooltip .tt-muted { color: #9aa3b2; }
.q-poor { color: #9d9d9d; } .q-common { color: #ffffff; } .q-uncommon { color: #1eff00; } .q-rare { color: #0070dd; }
.q-epic { color: #a335ee; } .q-legendary { color: #ff8000; }
nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav.on { border-color: var(--accent); color: var(--accent); }
.statusline { margin: 0 0 4px; font-size: 12px; }
.toolbar { display: flex; gap: 6px 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 6px 0; }
.toolbar p, .toolbar h3 { margin: 0; }
.export button, .inline button, #listmenu button { background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; }
.export button:hover, .inline button:hover, #listmenu button:hover { border-color: var(--accent); color: var(--accent); }
.inline input, #listmenu input[name=name] { padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.inline { margin: 12px 0; }
.err { color: #e06c5c; font-size: 12px; }
#export-out { flex-basis: 100%; margin: 4px 0 8px; }
#export-out textarea { width: 100%; font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; resize: vertical; }
#export-out div { font-size: 12px; }
#listmenu { position: fixed; z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  min-width: 220px; max-width: 320px; max-height: 60vh; overflow: auto; box-shadow: 0 4px 14px rgba(0,0,0,.3); font-size: 13px; }
#listmenu label { display: block; padding: 3px 0; cursor: pointer; }
#listmenu form { margin-top: 8px; display: flex; gap: 6px; }
#listmenu form input { flex: 1; min-width: 0; }
.addl, .unlist { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 4px 0 0; line-height: 1; }
.addl:hover, .unlist:hover { color: var(--accent); }
.addl.big { font-size: 22px; }
table.rows th { white-space: normal; vertical-align: bottom; }
.sub { font-size: 11px; }
.listblock { margin: 20px 0; }
thead th, thead th.help { cursor: pointer; user-select: none; }
thead th:hover { color: var(--text); }
th[data-dir="asc"]::after { content: " ▲"; font-size: 9px; }
th[data-dir="desc"]::after { content: " ▼"; font-size: 9px; }
.p.duo { display: inline-flex; flex-direction: column; align-items: flex-end; border-bottom: 0; line-height: 1.25; }
.src-v { white-space: nowrap; }
.src-v.alt { font-size: 11px; color: var(--muted); }
.src-v.alt .coin-g, .src-v.alt .coin-s, .src-v.alt .coin-c { color: inherit; }
.src-v.alt.off { color: #e8a13a; font-weight: 600; }
a.rowlink { color: inherit; text-decoration: none; }
a.rowlink:hover { text-decoration: underline; }
.src-l { font-size: 9px; color: var(--muted); margin-right: 4px; font-weight: 400; }
.zoomsel { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: var(--accent); stroke-width: 1; }
#chart svg { cursor: crosshair; user-select: none; }
.zoomhint { margin-left: auto; }
#zoomreset { background: var(--panel); color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 1px 8px; cursor: pointer; font: inherit; }
.sources { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; max-width: 720px; }
.sources .tip-title { margin-top: 6px; }
.sources .tip-title:first-child { margin-top: 0; }
td.learned { white-space: normal; min-width: 180px; max-width: 280px; }
#whoami { font-size: 12px; white-space: nowrap; }
#logout { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
main.login { max-width: 380px; margin: 12vh auto 0; }
#login label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; cursor: default; }
#login input { padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
#login button { margin-top: 6px; padding: 8px 14px; border-radius: 6px; border: 0; background: var(--accent); color: #14161a; font: inherit; font-weight: 600; cursor: pointer; }
#login button:disabled { opacity: .6; }
