:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  --background: #10161d;
  --paper: #171f29;
  --field: #111922;
  --soft: #202b38;
  --ink: #e3eaf1;
  --muted: #a2afbc;
  --line: #2a3645;
  --frame: #374658;
  --accent: #efb980;
  --accent-soft: #352d29;
  --chart-min: #72d4cb;
  --chart-median: #efb980;
  --price-up: #ef9a8d;
  --price-down: #8bcaa8;
  color: var(--ink);
  background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, select, input { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
a { color: var(--accent); text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.frame { width: calc(100% - 1.5rem); max-width: 120rem; margin-inline: auto; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { position: absolute; top: .5rem; left: .75rem; z-index: 5; padding: .65rem; background: var(--paper); }

.topbar { flex: none; border-bottom: 1px solid var(--frame); background: var(--paper); }
.topbar-inner { display: flex; min-height: 3.5rem; align-items: center; gap: clamp(.9rem, 2vw, 2.5rem); }
.brand { display: flex; gap: .6rem; align-items: center; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand strong { font-size: 1.2rem; }
.brand-label { margin-left: .2rem; font-size: .875rem; font-weight: 500; color: var(--muted); }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid #b58a60; border-radius: 7px 2px; background: var(--accent-soft); color: var(--accent); font-size: .875rem; font-weight: 700; }
.main-nav { display: flex; align-self: stretch; gap: 1.25rem; margin-right: auto; }
.main-nav a { display: flex; align-items: center; border-bottom: 2px solid transparent; padding-top: 2px; font-size: .875rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.main-nav a[aria-current], .main-nav a:hover { color: var(--accent); border-bottom-color: currentColor; }
.market-actions { display: flex; gap: .45rem; align-items: center; }
.market-actions > label { color: var(--muted); font-size: .875rem; white-space: nowrap; }
.market-actions select { min-width: 8rem; }
select { min-width: 0; max-width: 100%; appearance: none; border: 1px solid var(--frame); border-radius: 5px; background: linear-gradient(45deg, transparent 50%, #a2afbc 50%) right .86rem center / .3rem .3rem no-repeat, linear-gradient(135deg, #a2afbc 50%, transparent 50%) right .56rem center / .3rem .3rem no-repeat, var(--field); padding: .4rem 1.55rem .4rem .6rem; font-size: .875rem; }
.outline-button { background: var(--soft); border: 1px solid var(--frame); padding: .4rem .7rem; border-radius: 5px; font-size: .875rem; white-space: nowrap; }
.outline-button:not(:disabled):hover, .outline-button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.refresh-button { color: var(--accent); }
.small-button { padding: .3rem .6rem; }
.text-button { padding: .2rem .15rem; border: 0; background: transparent; color: var(--accent); font-size: .875rem; white-space: nowrap; }
.text-button:hover { text-decoration: underline; }
input[type="checkbox"] { accent-color: var(--accent); margin: 0; }
input:not([type="checkbox"]) { min-width: 0; border: 1px solid var(--frame); border-radius: 5px; background: var(--field); font-size: .875rem; padding: .45rem .55rem; }
input::placeholder { color: var(--muted); opacity: 1; }

.terminal { display: flex; flex-direction: column; gap: .5rem; }
.market-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem 1rem; min-height: 2.1rem; }
.market-overview, .market-status { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .75rem; }
.market-header h1 { margin: 0; font-size: .875rem; font-weight: 600; }
#market-time, #market-status { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#market-status { display: inline-flex; align-items: center; gap: .4rem; }
#market-status::before { content: ""; width: .38rem; height: .38rem; flex: none; border-radius: 50%; background: var(--muted); }
#market-status[data-state="ready"]::before { background: var(--chart-min); }
#market-status[data-state="error"]::before { background: var(--price-up); }
.auto-refresh-control { display: inline-flex; align-items: center; gap: .4rem; border-left: 1px solid var(--frame); padding-left: .75rem; font-size: .875rem; white-space: nowrap; }

.market-ticker { display: flex; align-items: stretch; min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.market-ticker > h2 { align-content: center; padding: .45rem .65rem; color: var(--muted); font-size: .8125rem; white-space: nowrap; }
.featured-grid { display: grid; flex: 1; grid-template-columns: repeat(4, minmax(0, 1fr)); min-width: 0; }
.featured-item { display: flex; align-items: center; gap: .45rem; min-width: 0; border: 0; border-left: 1px solid var(--line); background: transparent; text-align: left; padding: .35rem .6rem; }
.featured-item:not(:disabled):hover, .featured-item[aria-pressed="true"] { background: var(--soft); }
.featured-item[aria-pressed="true"] { box-shadow: inset 0 -2px var(--accent); }
.featured-item .item-icon { width: 1.35rem; height: 1.35rem; }
.featured-copy { display: flex; align-items: baseline; flex: 1; justify-content: space-between; gap: .35rem; min-width: 0; }
.featured-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8125rem; font-weight: 500; }
.featured-price { display: flex; align-items: baseline; gap: .4rem; flex: none; font-size: .8125rem; }
.featured-price .price-text { color: var(--accent); }

.market-grid { display: grid; grid-template-columns: minmax(16rem, 28%) minmax(0, 1fr); gap: .55rem; align-items: start; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--frame); border-radius: 7px; }
h2, h3 { margin: 0; }
.panel h2, .panel h3 { font-size: .9375rem; font-weight: 600; }
.panel-head, .section-head, .rail-head { display: flex; align-items: center; justify-content: space-between; gap: .45rem; min-height: 2.65rem; padding: .45rem .7rem; border-bottom: 1px solid var(--line); background: var(--soft); }
.panel-head, .depth-box > .rail-head { border-radius: 6px 6px 0 0; }
.secondary { margin: .2rem 0 0; font-size: .8125rem; color: var(--muted); }

.list-panel { grid-row: span 2; display: flex; flex-direction: column; min-height: 0; }
.list-controls { min-height: 0; }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .42rem; padding: .55rem .65rem .45rem; }
.filters > * { grid-column: 1 / -1; }
.filters:not(:has(> details[open])) > details { grid-column: auto; }
.search-input { display: flex; gap: .3rem; }
.search-input input { flex: 1; }
#clear-search { padding-inline: .62rem; }
.category-browser, .advanced-filters { border: 1px solid var(--line); border-radius: 5px; background: var(--field); font-size: .875rem; }
:is(.category-browser, .advanced-filters) > summary { padding: .36rem .5rem; }
:is(.category-browser, .advanced-filters)[open] > summary { border-bottom: 1px solid var(--line); color: var(--accent); }
.category-tree { max-height: 13rem; overflow: auto; padding: .3rem; }
.category-tree summary { padding: .32rem .45rem; }
.category-tree button { display: block; width: 100%; padding: .32rem .55rem; border: 0; border-left: 2px solid transparent; background: transparent; color: var(--muted); text-align: left; font-size: .875rem; }
.category-tree details button { padding-left: 1.25rem; }
.category-tree button[aria-pressed="true"], .category-tree button:hover { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); }
.advanced-fields { display: grid; gap: .65rem; padding: .5rem; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.filter-grid label { min-width: 0; display: grid; gap: .25rem; font-size: .8125rem; color: var(--muted); }
.quality-filter { padding: .4rem 0 0; margin: 0; border: 0; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); }
.quality-filter legend { padding: 0 .25rem 0 0; }
#quality { display: flex; flex-wrap: wrap; gap: .4rem .65rem; }
#quality label { display: inline-flex; gap: .25rem; align-items: center; }
.filter-error { margin: 0; color: var(--price-up); font-size: .8125rem; line-height: 1.55; }
.filter-footer, .pagination { display: flex; align-items: center; justify-content: space-between; gap: .35rem; }
.filter-footer p { margin: 0; }
.watch-groups { display: grid; gap: .45rem; padding: .55rem .65rem; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); }
.watch-groups > label { display: grid; gap: .35rem; }
.watch-groups summary { color: var(--accent); }
.watch-groups p { line-height: 1.6; margin: .4rem 0; }
.watch-groups input { width: 100%; }
.group-actions { display: flex; flex-wrap: wrap; gap: .3rem; margin: .45rem 0; }

.category-tree, .market-table-wrap, .history-table-wrap { scrollbar-color: var(--frame) transparent; scrollbar-width: thin; }
.market-table-wrap { overflow: auto; max-height: 42rem; border-top: 1px solid var(--line); }
.market-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; text-align: left; }
.market-table th { position: sticky; z-index: 1; top: 0; background: var(--soft); box-shadow: 0 1px var(--line); color: var(--muted); font-size: .8125rem; font-weight: 500; padding: .55rem .3rem; }
.market-table th:first-child { padding-left: .65rem; width: 49%; }
.market-table th:nth-child(2) { width: 30%; }
.market-table :is(th, td):last-child { padding-right: .55rem; }
.market-table td { border-bottom: 1px solid var(--line); padding: .3rem; font-size: .875rem; font-variant-numeric: tabular-nums; }
.market-table td:first-child { padding-left: .55rem; }
.market-table :is(th, td):not(:first-child) { text-align: right; }
.market-table th button { padding: 0; color: inherit; border: 0; background: transparent; text-decoration: underline dotted; text-underline-offset: 3px; }
.market-table th button:hover { color: var(--accent); }
.market-table tr { cursor: pointer; }
.market-table tr:hover td { background: var(--soft); }
.market-table tr.is-selected td { background: var(--accent-soft); }
.market-table tr.is-selected td:first-child { box-shadow: inset 3px 0 var(--accent); }
.row-button { display: flex; align-items: center; gap: .45rem; min-width: 0; padding: .05rem 0; color: inherit; text-decoration: none; }
.row-button > span:last-child { min-width: 0; }
.row-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row-subtitle { display: block; color: var(--muted); font-size: .75rem; margin-top: .08rem; }
.item-icon { flex: none; display: block; width: 1.7rem; height: 1.7rem; border: 1px solid var(--frame); border-radius: 4px; overflow: hidden; background: var(--soft); }
.item-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.item-icon[data-quality="优秀"] { border-color: #72a76d; }
.item-icon[data-quality="精良"] { border-color: #6795b9; }
.item-icon[data-quality="史诗"] { border-color: #9979b8; }
.item-icon[data-quality="传说"] { border-color: #cb8a49; }
.price-text, .change { white-space: nowrap; font-weight: 500; font-variant-numeric: tabular-nums; }
.change[data-direction="up"] { color: var(--price-up); }
.change[data-direction="down"] { color: var(--price-down); }
.empty-message { margin: 0; border-top: 1px solid var(--line); padding: 1.5rem .75rem; color: var(--muted); font-size: .875rem; line-height: 1.7; }
.pagination { border-top: 1px solid var(--line); padding: .45rem .65rem; font-size: .8125rem; color: var(--muted); }

.item-panel { min-width: 0; }
.mobile-back { display: none; }
.instrument-panel { padding: .7rem .85rem 0; }
.item-head { display: flex; align-items: center; gap: .65rem; }
.item-title { flex: 1; min-width: 0; }
.item-title h2 { font-size: 1.2rem; overflow-wrap: anywhere; }
[data-quality="优秀"]:is(h2, .row-name) { color: #a8cf87; }
[data-quality="精良"]:is(h2, .row-name) { color: #87b6e2; }
[data-quality="史诗"]:is(h2, .row-name) { color: #c59be6; }
[data-quality="传说"]:is(h2, .row-name) { color: #edb16c; }
.large-icon { width: 2.5rem; height: 2.5rem; }
.quote-grid { display: grid; grid-template-columns: 1.2fr repeat(3, minmax(0, 1fr)); align-items: center; gap: .55rem; margin: 0; padding: .75rem 0; }
.quote-grid > div { min-width: 0; border-left: 1px solid var(--line); padding-left: .65rem; }
.quote-grid > div:first-child { border-left: 0; padding-left: 0; }
.quote-grid dt, .facts-box dt, .price-reference dt { font-size: .8125rem; color: var(--muted); }
.quote-grid dd { margin: .22rem 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.quote-grid .primary-quote dd { color: var(--accent); font-size: 1.28rem; }
.chart-section { border-top: 1px solid var(--frame); }
.chart-head, .chart-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .4rem; padding: .4rem .7rem; }
.chart-head { background: var(--soft); }
.chart-toolbar { border-bottom: 1px solid var(--line); }
.ranges { display: inline-flex; flex-wrap: wrap; gap: .12rem; border: 1px solid var(--line); border-radius: 5px; padding: .12rem; background: var(--field); }
.ranges button { border: 1px solid transparent; border-radius: 3px; padding: .2rem .45rem; background: transparent; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.ranges button[aria-pressed="true"] { color: var(--accent); border-color: #85654b; background: var(--accent-soft); }
.ranges button:hover:not(:disabled) { color: var(--accent); }
.chart-options { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; font-size: .875rem; }
.chart-options select { padding-block: .2rem; }
.chart-options label:not(.sr-only) { display: inline-flex; align-items: center; gap: .25rem; }
.chart-readout { min-height: 2rem; margin: 0; padding: .45rem .7rem; color: var(--muted); font-size: .8125rem; line-height: 1.45; font-variant-numeric: tabular-nums; }
.plot { --plot-height: clamp(19rem, calc(100dvh - 24rem), 42rem); position: relative; margin: 0 .4rem; background: var(--field); border: 1px solid var(--line); border-radius: 4px; }
.plot canvas { display: block; width: 100%; height: var(--plot-height); touch-action: pan-y; cursor: crosshair; }
.plot > p { display: grid; min-height: var(--plot-height); place-content: center; margin: 0; padding: .85rem; color: var(--muted); text-align: center; font-size: .875rem; }
.chart-tooltip { pointer-events: none; position: absolute; top: .45rem; left: .45rem; max-width: calc(100% - .9rem); padding: .5rem .65rem; background: var(--paper); border: 1px solid var(--frame); border-radius: 4px; color: var(--ink); font-size: .8125rem; line-height: 1.6; white-space: pre-line; box-shadow: 0 3px 12px #0006; }
.chart-note, .chart-credit, .history-details { margin: .5rem .7rem; font-size: .8125rem; line-height: 1.6; color: var(--muted); }
.history-details summary { color: var(--accent); }
.history-table-wrap { overflow: auto; max-height: 16rem; margin-top: .4rem; }
.history-table { width: 100%; border-collapse: collapse; color: var(--ink); }
.history-table :is(th, td) { padding: .4rem .3rem; border-bottom: 1px solid var(--line); text-align: left; }
.history-table th { background: var(--soft); }
.chart-credit { display: flex; flex-wrap: wrap; gap: .2rem .6rem; }
.chart-credit a { color: var(--muted); }
.chart-section:fullscreen { padding: .6rem; overflow: auto; background: var(--paper); }
.chart-section:fullscreen .plot { --plot-height: max(300px, calc(100dvh - 250px)); }
.section-note { color: var(--muted); font-size: .8125rem; }
.price-reference { border-top: 1px solid var(--frame); }
.price-reference dl { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: .55rem; padding: .7rem; margin: 0; }
.price-reference dd { margin: .35rem 0 0; color: var(--accent); font-size: .875rem; line-height: 1.5; font-variant-numeric: tabular-nums; }

.item-facts { grid-column: 2; min-width: 0; }
.facts-box + .facts-box, .data-info { border-top: 1px solid var(--frame); }
.facts-box > h3 { padding: .65rem .7rem; border-bottom: 1px solid var(--line); background: var(--soft); }
.depth-columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: .55rem .65rem; font-size: .8125rem; color: var(--muted); border-bottom: 1px solid var(--line); text-align: right; }
.depth-columns > :first-child { text-align: left; }
.depth-empty { display: grid; place-content: center; gap: .35rem; min-height: 9rem; padding: .8rem; margin: 0; background: var(--field); color: var(--muted); text-align: center; font-size: .875rem; }
.depth-empty small { font-size: .8125rem; }
.depth-footer { grid-template-columns: 1fr 1fr; border: 0; border-top: 1px solid var(--line); }
.depth-footer strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.facts-box dl { display: grid; gap: .55rem; margin: 0; padding: .65rem .7rem; }
.facts-box dl > div { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.facts-box dd { margin: 0; font-size: .875rem; text-align: right; font-variant-numeric: tabular-nums; }
.data-info { font-size: .8125rem; color: var(--muted); }
.data-info summary { padding: .65rem .7rem; font-size: .875rem; }
.data-info p { margin: 0; padding: 0 .7rem .65rem; line-height: 1.65; }

.site-footer { display: flex; justify-content: space-between; align-items: center; gap: .35rem .8rem; padding: .25rem 0 .55rem; color: var(--muted); font-size: .8125rem; }
.site-footer a { color: inherit; }

@media (min-width: 1100px) {
  body { display: flex; flex-direction: column; height: 100dvh; min-height: 37rem; }
  .terminal { flex: 1; min-height: 0; }
  .market-grid { flex: 1; min-height: 0; grid-template-columns: clamp(18rem, 24%, 23rem) minmax(0, 1fr) clamp(13rem, 18%, 17rem); align-items: stretch; }
  .list-panel { grid-row: auto; }
  .list-controls { flex: 0 1 auto; max-height: 52%; overflow: auto; }
  .market-table-wrap { flex: 1; min-height: 0; max-height: none; }
  .item-facts { grid-column: auto; }
  .item-panel, .item-facts { overflow: auto; }
  .list-controls, .item-panel, .item-facts { scrollbar-width: thin; scrollbar-color: var(--frame) transparent; }
  .list-panel > :is(.panel-head, .pagination) { flex: none; }
}

@media (max-width: 1120px) {
  .featured-copy { flex-direction: column; gap: .1rem; }
  .featured-copy strong { max-width: 100%; }
}

@media (max-width: 760px) {
  .frame { width: calc(100% - 1rem); }
  .topbar-inner { min-height: 0; flex-wrap: wrap; gap: .4rem .75rem; padding-block: .45rem; }
  .main-nav { margin: 0 0 0 auto; gap: .65rem; }
  .market-actions { flex: 1 0 100%; }
  .market-actions select { min-width: 0; flex: 1; }
  #terminal-fullscreen { display: none; }
  .market-header { padding-top: .35rem; }
  .market-ticker { display: block; }
  .market-ticker > h2 { padding-block: .28rem; }
  .featured-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .featured-item { border-top: 1px solid var(--line); padding-block: .45rem; }
  .featured-item:nth-child(odd) { border-left: 0; }
  .market-grid { grid-template-columns: minmax(0, 1fr); }
  .list-panel { grid-row: auto; }
  .item-facts { grid-column: auto; }
  .market-table-wrap { max-height: min(60dvh, 36rem); }
  .mobile-back { display: block; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: .875rem; }
  body[data-screen="list"] :is(.item-panel, .item-facts), body[data-screen="item"] :is(.list-panel, .market-ticker) { display: none; }
  .plot { --plot-height: 19rem; }
}

@media (max-width: 435px) {
  .main-nav a[aria-current] { display: none; }
  .quote-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: .8rem; }
  .quote-grid > div:nth-child(3) { border-left: 0; padding-left: 0; }
}
