:root {
  color-scheme: dark;
  --bg: #000;
  --text: #f4f1ea;
  --muted: #cfc9be;
  --line: #2a2a2a;
  --up: #3ee08f;
  --down: #ff5c5c;
  --up-bar: #16c47c;
  --down-bar: #ff2d2d;
  --gold: #ffe08a;
  --pad: 10px;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang TC", "Hiragino Sans CNS", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", "WenQuanYi Micro Hei", "Droid Sans Fallback", sans-serif;
  line-height: 1.3;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; font-size: 16px; }

button { touch-action: manipulation; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.top { border-bottom: 3px solid #666; }
.top[data-tone="live"] { border-bottom-color: var(--up-bar); }
.top[data-tone="down"] { background: #240000; border-bottom-color: var(--down-bar); }
.top[data-tone="stale"] { background: #241c08; border-bottom-color: var(--gold); }
.top[data-tone="paused"] { background: #141414; border-bottom-color: #8d8d8d; }
.top[data-tone="loading"] { border-bottom-color: #8d8d8d; }

.top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 800;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 15px;
  font-weight: 700;
}

#density, #refresh {
  min-height: 40px;
  padding: 0 12px;
  background: #000;
  border: 2px solid #5c5c5c;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

#refresh {
  margin-left: auto;
  color: var(--gold);
  border-color: var(--gold);
}

#density[aria-pressed="true"] {
  color: #000;
  background: var(--text);
  border-color: var(--text);
}

#status {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}

#q, #sort {
  min-height: 40px;
  padding: 0 10px;
  background: #000;
  border: 2px solid #5c5c5c;
  border-radius: 8px;
}

#q { flex: 1 1 12rem; min-width: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; }

.tab {
  min-height: 40px;
  padding: 0 12px;
  background: #000;
  border: 2px solid #5c5c5c;
  border-radius: 999px;
  cursor: pointer;
}

.tab.is-on {
  background: var(--text);
  color: #000;
  border-color: var(--text);
  font-weight: 800;
}

.count { margin: 0; color: var(--muted); font-size: 15px; font-weight: 700; }

.notes { margin: 0 0 6px; }
.notes summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.notes p { margin: 6px 0 0; }

.warning {
  margin: 6px 0;
  padding: 8px 10px;
  background: #241c08;
  border: 2px solid var(--gold);
  border-radius: 8px;
}

.noscript {
  margin: 6px 0;
  padding: 8px 10px;
  background: #240000;
  border: 2px solid var(--down);
  border-radius: 8px;
  font-weight: 700;
}

#board { padding-bottom: 8px; }

.cols.head { display: none; }

.quote { border-top: 1px solid var(--line); min-width: 0; }
.quote.is-open { background: #0c0c0c; }

.quote-btn {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 3.25rem;
  grid-template-areas: "zh px chg meter";
  gap: 2px 6px;
  align-items: center;
  padding: 4px 2px;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.quote-btn:hover { background: #121212; }

.name-zh {
  grid-area: zh;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.zh {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code { display: none; color: var(--muted); font-size: 15px; font-weight: 700; }

.name-meta, .hint, .px-label { display: none; }

.px-wrap { grid-area: px; min-width: 0; }
.chg-wrap { grid-area: chg; text-align: right; }

.px, .chg {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.up { color: var(--up); }
.down { color: var(--down); }
.flat, .none { color: var(--text); }
.num { font-variant-numeric: tabular-nums; }

.meter {
  grid-area: meter;
  position: relative;
  height: 10px;
  background: #141414;
  border: 1px solid #333;
  overflow: hidden;
}

.meter-neg, .meter-pos {
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 0;
}
.meter-neg { right: 50%; background: var(--down-bar); }
.meter-pos { left: 50%; background: var(--up-bar); }
.meter-zero {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--text);
}

.detail { padding: 2px 2px 8px; }
.book-banner { margin: 0 0 6px; font-weight: 700; }

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 0;
}

.facts dt { margin: 0; color: var(--muted); font-size: 15px; font-weight: 700; }
.facts dd {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.sub { display: none; }

.empty { padding: 16px 0; font-weight: 700; }

.footer {
  padding-top: 8px;
  padding-bottom: 12px;
  border-top: 1px solid var(--line);
}

.disclaimer { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.35; }

@media (min-width: 720px) {
  .code { display: inline; flex: none; }
  #q { flex-basis: 16rem; }
}

@media (min-width: 1100px) {
  body:not(.comfort) #board {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 18px;
  }
  body:not(.comfort) .quote.is-open { grid-column: 1 / -1; }
}

body.comfort .quote-btn {
  min-height: 56px;
  padding: 8px 2px;
  grid-template-areas:
    "zh px chg meter"
    "meta meta meta meta";
}
body.comfort .name-zh,
body.comfort .px,
body.comfort .chg { font-size: 20px; }
body.comfort .meter { height: 16px; }
body.comfort .name-meta {
  display: block;
  grid-area: meta;
  min-width: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}
body.comfort .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 15px; font-weight: 500; }
body.comfort .facts { gap: 12px; }

@media (min-width: 860px) {
  body.comfort .cols.head {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) auto auto minmax(7rem, 9rem);
    gap: 8px 10px;
    padding: 4px 2px;
    color: var(--muted);
    font-size: 15px;
    font-weight: 700;
  }
  body.comfort .cols.head span:nth-child(2),
  body.comfort .cols.head span:nth-child(3) { text-align: right; }
  body.comfort .quote-btn {
    grid-template-columns: minmax(0, 1.4fr) auto auto minmax(7rem, 9rem);
  }
}
