:root { font-family: "Microsoft JhengHei", sans-serif; background: #f3f5f8; color: #192b43; }
.page-width { width: min(100% - 64px, 1140px); }
.app-header { background: #122a44; padding: 34px 0 28px; border-bottom: 4px solid #db6250; }
.header-row { align-items: flex-start; }
.eyebrow { color: #93adc9; font-size: 11px; letter-spacing: .16em; margin-bottom: 12px; }
h1 { font-size: 34px; letter-spacing: .03em; }
.title-dot { color: #ed806c; margin-left: 4px; }
.hero-description { color: #b7c9db; margin: 13px 0 18px; font-size: 14px; }
.status-row { justify-content: flex-start; gap: 22px; padding-top: 5px; font-size: 11px; color: #b7c9db; }
#connection-status { border: 1px solid #506174; border-radius: 5px; padding: 4px 9px; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 16px; }
.section-kicker { font-size: 10px; font-weight: 700; letter-spacing: .13em; color: #758397; }
.workspace-heading h2 { margin-top: 7px; font-size: 21px; }
.weekly-badge { color: #496780; background: #e4ebf2; font-size: 11px; border-radius: 5px; padding: 7px 11px; }
.tools { margin: 0; border-radius: 12px; padding: 18px 22px; box-shadow: none; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.search-row { grid-column: 1; border-radius: 7px; background: #f8fafc; }
.search-row input { font-size: 13px; }
.threshold-selects { grid-row: 1; grid-column: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.threshold-selects label { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 11px; color: #526478; }
.threshold-selects select { width: 100%; border: 1px solid #dce3ec; border-radius: 7px; background: #f8fafc; color: #192b43; padding: 0 10px; font-size: 13px; }
.threshold-context { grid-column: 2; grid-row: 2; margin: 0; align-self: center; text-align: right; font-size: 11px; }
.chip-row { margin: 0; grid-column: 1; gap: 6px; }
.chip { border-radius: 7px; padding: 0 12px; font-size: 12px; background: transparent; color: #68798d; }
.chip.is-active { background: #192f49; color: white; }
.chip-filter { border: 1px solid #dce3ec; margin-left: 6px; }
.summary { gap: 16px; padding: 20px 0 25px; }
.metric { border-radius: 10px; padding: 18px 22px; background: #fff; border-color: #e1e7ef; position: relative; }
.metric span { font-size: 11px; }
.metric strong { font-size: 24px; letter-spacing: -.03em; margin-top: 10px; color: #20344c; }
.metric:nth-child(2) strong { color: #c3473f; font-size: 22px; }
.section-heading { padding: 0 0 6px; }
.section-heading h2 { font-size: 19px; }
.text-button { color: #557087; font-size: 12px; font-weight: 500; }
.ranking-status { font-size: 11px; margin-bottom: 14px; }
.ranking-list { display: block; background: #fff; border: 1px solid #e1e7ef; border-radius: 0 0 12px 12px; overflow: hidden; }
.comparison-header { display: grid; grid-template-columns: 32% 17% repeat(3, 17%); background: #e9eef4; color: #64768b; padding: 13px 22px; font-size: 11px; border: 1px solid #e1e7ef; border-radius: 10px 10px 0 0; }
.comparison-header span:nth-child(n+3) { text-align: right; }
.stock-row { border: none; border-bottom: 1px solid #edf0f4; border-radius: 0; box-shadow: none; padding: 19px 22px; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 16px; min-height: 84px; align-items: center; position: relative; }
.stock-row:last-child { border-bottom: none; }
.stock-row:hover { background: #f8fafc; }
.rank { background: #eef2f6; color: #697e93; width: 28px; font-size: 11px; }
.stock-row:nth-child(-n+3) .rank { background: #fbeddf; color: #b4803e; }
.stock-row > div:first-of-type { display: grid; grid-template-columns: auto auto 1fr; width: 24%; position: relative; gap: 5px 0; }
.stock-link { grid-row: 1; font-size: 15px; }
.market { grid-row: 1; justify-self: start; align-self: center; font-size: 10px; margin-left: 9px; }
.stock-name { grid-row: 2; grid-column: 1 / -1; font-size: 12px; margin: 0; color: #53677e; white-space: nowrap; }
.sparkline { position: absolute; width: 110px; height: 30px; left: calc(100% + 35px); top: 1px; margin: 0; opacity: .8; }
.stock-row > div:last-child { position: absolute; right: 22px; top: 31px; display: grid; grid-template-columns: repeat(3, 1fr); width: 47%; gap: 14px; }
.change, .four-week, .retail { font-size: 16px; margin: 0; font-weight: 700; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.interpretation { background: #eaf0f5; border: 1px solid #dce5ef; border-radius: 10px; padding: 18px 22px; margin-bottom: 26px; }
.interpretation strong { font-size: 12px; color: #3d5871; }
.interpretation p { color: #6a7c8f; font-size: 11px; line-height: 1.9; margin: 7px 0 0; }
.footer { font-size: 10px; padding-top: 15px; }
.freshness-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); font-size: 11px; gap: 8px 24px; }
.watch-button { grid-row: 1; grid-column: 3; justify-self: end; margin: -13px 0; }
.saved-tools { grid-column: 1 / -1; margin: 0; padding-top: 10px; border-top: 1px solid #edf0f4; }
.saved-tools label { font-size: 11px; margin-right: auto; }
.saved-tools select { font-size: 12px; min-width: 200px; }
.saved-tools .chip { border: 1px solid #dce3ec; }
.storage-status { grid-column: 1 / -1; margin: -5px 0 0; font-size: 10px; }
.ranking-scope-note { margin: 8px 0; font-size: 11px; }
.update-result { font-size: 11px; padding: 11px 14px; margin-bottom: 12px; }
#updated-date { display: none; }
@media (max-width: 719px) {
  .page-width { width: calc(100% - 32px); }
  .app-header { padding: 26px 0 20px; }
  h1 { font-size: 28px; }
  .eyebrow { font-size: 9px; letter-spacing: .12em; }
  .hero-description { font-size: 12px; margin-bottom: 13px; }
  .status-row { font-size: 10px; gap: 10px; flex-wrap: wrap; }
  .workspace-heading { margin-top: 23px; }
  .workspace-heading h2 { font-size: 18px; }
  .section-kicker { font-size: 9px; }
  .weekly-badge { font-size: 10px; padding: 6px 8px; }
  .tools { display: flex; flex-direction: column; padding: 15px; gap: 12px; }
  .threshold-selects { order: 1; gap: 10px; }
  .threshold-selects label { display: grid; gap: 5px; }
  .search-row { order: 0; }
  .chip-row { order: 2; }
  .chip { padding: 0 9px; font-size: 11px; }
  .chip-row { flex-wrap: wrap; overflow: visible; }
  .chip-filter { margin-left: 0; }
  .threshold-context { order: 3; text-align: left; font-size: 10px; }
  .saved-tools { order: 4; padding-top: 12px; margin: 0; gap: 8px; }
  .saved-tools label { width: 100%; display: grid; grid-template-columns: auto 1fr; gap: 10px; }
  .saved-tools select { min-width: 0; width: 100%; }
  .storage-status { order: 5; margin: 0; }
  .freshness-grid { font-size: 10px; gap: 7px 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 10px; line-height: 1.6; }
  .hero-description { display: none; }
  .summary { grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 0 23px; }
  .metric { padding: 15px; }
  .metric strong { font-size: 23px; }
  .metric:nth-child(2) strong { font-size: 15px; margin-top: 16px; }
  .metric:nth-child(3) { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; }
  .metric:nth-child(3) strong { margin: 0; font-size: 14px; }
  .section-heading h2 { font-size: 17px; }
  .comparison-header { display: none; }
  .ranking-list { background: transparent; border: 0; border-radius: 0; display: grid; gap: 10px; }
  .stock-row { background: #fff; border: 1px solid #e1e7ef; border-radius: 10px; padding: 16px; min-height: 144px; align-items: start; gap: 12px; }
  .stock-row > div:first-of-type { width: 65%; }
  .sparkline { left: auto; right: -44%; width: 78px; top: 4px; }
  .stock-row > div:last-child { top: auto; bottom: 18px; left: 16px; right: 16px; width: auto; border-top: 1px solid #edf0f4; padding-top: 13px; gap: 4px; }
  .change, .four-week, .retail { font-size: 16px; text-align: left; line-height: 1.7; white-space: normal; }
  .change::before, .four-week::before, .retail::before { display: block; font-size: 10px; color: #7d8c9d; font-weight: 500; }
  .change::before { content: "本週增幅"; }
  .four-week::before { content: "四週增幅"; }
  .retail::before { content: "散戶週變動"; }
  .interpretation { padding: 16px; }
}

/* Keep stock names, trends and numbers in flow when text wraps. */
.stock-row { grid-template-columns: 28px minmax(0, 1fr) minmax(0, 51%); }
.stock-row > div:first-of-type { width: 100%; grid-template-columns: auto auto minmax(44px, 1fr) minmax(0, 35%); }
.stock-name { grid-column: 1 / 4; white-space: normal; overflow-wrap: anywhere; }
.sparkline { position: static; grid-column: 4; grid-row: 1 / 3; width: 100%; align-self: center; }
.stock-row > div:last-child { position: static; width: 100%; gap: 10px; }
.search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #467eb3; outline-offset: 3px; }
@media (min-width: 720px) and (max-width: 1000px) {
  .tools { grid-template-columns: 1fr; }
  .search-row, .threshold-context, .chip-row, .threshold-selects { grid-column: 1; grid-row: auto; }
  .chip-row { flex-wrap: wrap; overflow: visible; }
  .threshold-context { text-align: left; }
}
@media (max-width: 719px) {
  .stock-row { grid-template-columns: 28px minmax(0, 1fr); }
  .stock-row > div:first-of-type { width: 100%; grid-template-columns: auto auto minmax(44px, 1fr) 78px; }
  .stock-row > div:last-child { grid-column: 1 / -1; width: 100%; padding-top: 13px; }
  .sparkline { position: static; width: 100%; }
}
@media (max-width: 359px) {
  .stock-row > div:first-of-type { grid-template-columns: auto auto minmax(44px, 1fr) 48px; }
}
