:root {
  --bg: #f6f5f2; --surface: #fff; --text: #1a1d22; --muted: #626b76;
  --line: #deded8; --up: #bd342a; --down: #167743; --accent: #946b08;
  --notice: #fffae9; --shadow: 0 2px 8px #161c2410;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --surface: #1d2229; --text: #e8eaed; --muted: #adb5c1;
    --line: #333a44; --up: #ff8185; --down: #66d99c; --accent: #efc15b;
    --notice: #332e1d; --shadow: none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system,
  BlinkMacSystemFont, "Noto Sans CJK TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  line-height: 1.55; -webkit-font-smoothing: antialiased; }
header { position: sticky; top: 0; z-index: 5; background: var(--bg);
  border-bottom: 1px solid var(--line); padding: calc(16px + env(safe-area-inset-top,0px)) 20px 14px; }
.header-inner { max-width: 960px; margin: auto; display: flex; gap: 14px;
  justify-content: space-between; align-items: center; }
.eyebrow { font-size: 10px; letter-spacing: .15em; color: var(--muted); margin: 0 0 3px; }
h1 { font-size: 23px; margin: 0; letter-spacing: -.02em; }
.version { font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }
#statusLine { font-size: 12px; margin: 4px 0 0; color: var(--muted); }
button { font: inherit; cursor: pointer; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 100px; min-height: 42px; padding: 8px 14px; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
#refresh { flex: none; font-size: 13px; }
main { max-width: 1000px; padding: 18px 20px 28px; margin: auto; }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 15px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; overflow-wrap: anywhere; }
.notice strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 13px; }
.notice span { display: block; }
.notice.demo, .notice.warning { background: var(--notice); border-color: var(--accent); color: var(--text); }
.meta { font-size: 12px; color: var(--muted); margin: 12px 0 8px; overflow-wrap: anywhere; }
.toolbar { display: flex; gap: 8px; overflow: auto; padding: 3px 0 13px; }
.chip { flex: none; font-size: 13px; }
.chip.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 17px; box-shadow: var(--shadow); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.identity { min-width: 0; }
.name { font-size: 17px; margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.sym { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 7px; }
.industry, .date-line, .fetch-line { font-size: 11.5px; color: var(--muted); margin: 4px 0; }
.count { flex: none; border: 1px solid var(--line); border-radius: 7px; padding: 3px 7px;
  font-size: 11px; font-variant-numeric: tabular-nums; }
.price-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 12px; }
.price { font-size: 28px; font-weight: 650; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.change { font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.badge { border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
  font-size: 11px; padding: 4px 7px; color: var(--muted); }
.badge.pass { border-color: var(--accent); color: var(--accent); }
.metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 14px;
  padding-top: 11px; border-top: 1px solid var(--line); margin: 0; }
.metric { min-width: 0; font-size: 12px; }
.metric dt { color: var(--muted); font-size: 11px; }
.metric dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card-warning { background: var(--notice); padding: 8px 10px; border-radius: 7px;
  color: var(--text); font-size: 11.5px; margin: 10px 0 0; overflow-wrap: anywhere; }
.err { color: var(--up); font-size: 12.5px; overflow-wrap: anywhere; margin-top: 12px; }
.empty { grid-column: 1 / -1; padding: 36px 18px; text-align: center;
  color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; }
.rules { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; font-size: 12px; color: var(--muted); }
summary { cursor: pointer; color: var(--text); font-size: 13px; padding: 8px 0; }
.rules dl { margin: 8px 0; } .rules dt { font-weight: 650; color: var(--text); margin-top: 12px; }
.rules dd { margin: 3px 0; }
footer { text-align: center; color: var(--muted); font-size: 11px; padding: 12px 20px calc(24px + env(safe-area-inset-bottom,0px)); }
@media (max-width: 680px) {
  .list { grid-template-columns: minmax(0,1fr); } main { padding: 14px 15px 24px; }
  header { padding-left: 15px; padding-right: 15px; } h1 { font-size: 21px; }
}
.subtitle { margin: 4px 0; font-size: 14px; color: var(--muted); }
.summary-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.summary-item { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.summary-item span { display: block; color: var(--muted); font-size: 11px; }
.summary-item strong { font-size: 19px; overflow-wrap: anywhere; }
.section-title { font-size: 16px; margin: 20px 0 10px; }
.filter-label { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.search-controls { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.search-controls label { min-width: 0; font-size: 12px; color: var(--muted); }
input, select { display: block; width: 100%; min-width: 0; margin-top: 5px; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge.new { background: var(--notice); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.candidate-reasons { font-size: 12px; color: var(--accent); overflow-wrap: anywhere; }
.warning-code { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.more-wrap { text-align: center; margin: 20px 0; }
.price-line { flex-wrap: wrap; }
@media (max-width: 680px) {
  .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .search-controls { grid-template-columns: minmax(0,1fr); }
  .header-inner > div { min-width: 0; }
  #refresh { padding: 8px 10px; font-size: 12px; }
}

/* Mobile UI polish; desktop card and header layout stay intact. */
.signal-short { display: none; }
.warning-technical { margin-top: 3px; }
.warning-technical summary { min-height: 32px; padding: 3px 0; font-size: 11px; }
.warning-code { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.card-details > summary { display: none; }
.details-summary { min-height: 42px; padding: 10px 0; }
.detail-body { min-width: 0; }

@media (max-width: 520px) {
  body { overflow-x: clip; }
  header { padding: calc(7px + env(safe-area-inset-top,0px)) 12px 8px; }
  .header-inner { gap: 8px; align-items: center; }
  .header-inner > div { flex: 1 1 auto; min-width: 0; }
  .eyebrow { font-size: 8px; letter-spacing: .1em; margin-bottom: 1px; white-space: nowrap; }
  h1 { font-size: 19px; line-height: 1.2; }
  .version { font-size: 9px; }
  .subtitle { font-size: 12px; line-height: 1.25; margin: 2px 0 0; }
  #statusLine { max-width: 100%; margin-top: 2px; font-size: 10px; line-height: 1.25;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #refresh { flex: 0 0 auto; min-height: 40px; max-width: 116px; padding: 6px 9px;
    white-space: normal; line-height: 1.15; font-size: 11px; }
  main { min-width: 0; padding: 10px 12px 20px; }
  .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .summary-item { padding: 8px 10px; }
  .summary-item span { font-size: 10px; }
  .summary-item strong { font-size: 16px; }
  .summary-item.candidate-summary { border-color: var(--accent); }
  .summary-item.candidate-summary strong { color: var(--accent); font-size: 21px; }
  .toolbar { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; overflow-y: hidden;
    overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .chip { min-height: 42px; touch-action: pan-x; }
  .search-controls, .search-controls label { min-width: 0; width: 100%; }
  input, select { width: 100%; max-width: 100%; font-size: 16px; }
  .card { padding: 13px; }
  .card-top { gap: 6px; }
  .name { min-width: 0; font-size: 16px; overflow-wrap: anywhere; word-break: normal; }
  .sym { white-space: nowrap; font-size: 11px; margin-left: 4px; }
  .industry { overflow-wrap: anywhere; }
  .price-line { align-items: baseline; gap: 5px 10px; }
  .price { font-size: clamp(22px, 7vw, 27px); }
  .change { white-space: normal; text-align: right; overflow-wrap: anywhere; }
  .badges { gap: 5px; margin: 8px 0; }
  .badge { min-height: 30px; padding: 5px 7px; font-size: 11px; }
  .signal-long { display: none; }
  .signal-short { display: inline; }
  .candidate-reasons { overflow-wrap: anywhere; }
  .card-details { min-width: 0; margin-top: 7px; border-top: 1px solid var(--line); }
  .card-details > summary { min-height: 44px; padding: 11px 0; font-size: 13px; font-weight: 600; }
  .detail-body { display: block; min-width: 0; }
  .card-details:not([open]) > .detail-body { display: none; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 10px; }
  .metric, .metric dd { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
  .warning-technical summary { min-height: 36px; }
  .more-wrap button { min-height: 44px; }
}
