/* ── twstock 盤後摘要 (home) — Terminal register, dual-theme via role vars.
   Spec: designer mockup-twstock-home-2026-09-27 (A). No charts on this page:
   numbers, ranked lists and one-reading bars only. ── */

#box_main {
  flex: 1;
  min-width: 0;
  min-height: 800px;
  padding-top: var(--space-16);
  padding-left: var(--space-16);
  max-width: 1340px;
}

.tw_home .pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-16);
  flex-wrap: wrap;
  margin-bottom: var(--space-16);
}
.tw_home .titlewrap { display: flex; flex-direction: column; gap: var(--space-2); }
.tw_home .titlewrap h1 { margin: 0; color: var(--ink); }
.tw_home .titlewrap .meta { font-size: 13px; color: var(--color-greyMedium); }

/* Select trigger (canon › Input › Select 觸發鈕) — opens the shared stock
   modal; 36 visual, 44 hit (border sits outside the pseudo's padding box). */
.tw_home .picker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 36px;
  width: 280px;
  padding: 0 var(--space-12) 0 var(--space-32);
  border: 1px solid var(--border-frame);
  border-radius: var(--radius-xs);
  background: var(--surface-field) url("/static/img/lucide/search.greyMedium.svg") no-repeat var(--space-12) center / 16px;
  color: var(--color-greyMedium);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease-standard);
}
.tw_home .picker::before { content: ""; position: absolute; inset: -5px -1px; }
.tw_home .picker span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw_home .picker:hover { border-color: var(--color-greyMedium); }
body.dark-mode .tw_home .picker { background-image: url("/static/img/lucide/search.greyMediumDark.svg"); }

.tw_home .grid { display: grid; gap: var(--space-16); }
.tw_home .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tw_home .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tw_home .g2 > :only-child { grid-column: 1 / -1; }

.tw_home .card {
  background: var(--surface-card);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-16);
  min-width: 0;
}
.tw_home .card-h {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  flex-wrap: wrap;
  margin-bottom: var(--space-12);
}
.tw_home .card-h h2 { margin: 0; color: var(--ink); }
.tw_home .card-h .date { font-size: 12px; color: var(--color-greyMedium); }
.tw_home .card-h .r { margin-left: auto; display: flex; align-items: center; gap: var(--space-8); }
.tw_home a.title-link { color: var(--ink); text-decoration: none; }
.tw_home a.title-link:hover h2 { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

.tw_home .up { color: var(--color-greenText); }
.tw_home .dn { color: var(--color-redText); }
.tw_home .cap { font-size: 12px; color: var(--chart-caption); }

/* Stat strip (canon › Command bar › Stat 條): cells capped ~220, packed to the start edge. */
.tw_home .strip { display: flex; flex-wrap: wrap; }
.tw_home .strip .c { flex: 0 1 220px; min-width: 0; padding: 0 var(--space-16); border-left: 1px solid var(--border-hairline); }
.tw_home .strip .c:first-child { padding-left: 0; border-left: none; }
.tw_home .strip .sl { display: block; font-size: 13px; font-weight: 600; color: var(--color-greyMedium); }
.tw_home .strip .sv {
  display: block;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
}
.tw_home .strip .sv.big { font-size: 28px; line-height: 1.25; }
.tw_home .strip .sv small { font-size: 13px; }
.tw_home .strip .sub { display: block; font-size: 13px; }
.tw_home .brd { display: flex; height: 4px; gap: 1px; margin-top: var(--space-6); border-radius: var(--radius-micro); overflow: hidden; }
.tw_home .brd i { display: block; height: 100%; }
.tw_home .brd .g { background: var(--color-green); }
.tw_home .brd .n { background: var(--color-greyLightMedium); }
.tw_home .brd .r { background: var(--color-red); }
body.dark-mode .tw_home .brd .n { background: var(--color-darkBorder); }

/* Summary rows — 32 high, hairline between; each row links to its market page. */
.tw_home .rows { list-style: none; margin: 0; padding: 0; }
.tw_home .rows li { border-top: 1px solid var(--border-hairline); }
.tw_home .rows li:first-child { border-top: none; }
.tw_home .rows .rw {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  min-height: 32px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--ink);
  text-decoration: none;
}
.tw_home .rows .rw .l { min-width: 0; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw_home .rows .rw .v { white-space: nowrap; text-align: right; }
.tw_home .rows .rw .v small { margin-left: var(--space-4); font-size: 12px; color: var(--color-greyMedium); }
/* PCR for visitors: reads as clickable (the whole row links to the PCR page, which has its own login wall) */
.tw_home .rows .rw .v.login { color: var(--link-quiet); text-decoration: underline; text-underline-offset: 3px; }
.tw_home .rows li.tot .rw .l { color: var(--ink); font-weight: 600; }
.tw_home .rows a.rw:hover { background: var(--surface-row-hover); }
.tw_home .rows a.rw:hover .l { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.tw_home .foot { margin-top: var(--space-8); padding-top: var(--space-8); border-top: 1px solid var(--border-hairline); }

/* Segment (canon › Interaction states › segment) — same shape as the twstock toolbars. */
.tw_home .segment { display: inline-flex; border: 1px solid var(--border-frame); border-radius: var(--radius-sm); }
.tw_home .segment button {
  position: relative;
  height: 32px;
  padding: 0 var(--space-12);
  border: none;
  border-right: 1px solid var(--border-frame);
  background: transparent;
  color: var(--color-greyMedium);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-standard);
}
.tw_home .segment button::before { content: ""; position: absolute; inset: -7px 0; }
.tw_home .segment button:first-child { border-radius: calc(var(--radius-sm) - 1px) 0 0 calc(var(--radius-sm) - 1px); }
.tw_home .segment button:last-child { border-right: none; border-radius: 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0; }
.tw_home .segment button:hover { background: var(--surface-muted); }
.tw_home .segment button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw_home .segment button[aria-pressed="true"] { background: var(--surface-control-on); color: var(--ink); font-weight: 600; }

/* Ranked lists */
.tw_home .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-32); }
.tw_home .colh {
  display: flex;
  justify-content: space-between;
  gap: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-greyDark);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-greyMedium);
}
.tw_home .rk { list-style: none; margin: 0; padding: 0; }
.tw_home .rk li {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  min-height: 32px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-hairline);
  font-size: 13px;
}
.tw_home .rk li:last-child { border-bottom: none; }
.tw_home .rk .n { flex-shrink: 0; width: 16px; font-size: 12px; color: var(--color-greyMedium); }
.tw_home .rk .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.tw_home .rk .v { white-space: nowrap; }
/* canon › 連結 › 表格代號連結: same ink as the row, no resting underline */
.tw_home a.sym { color: var(--ink); text-decoration: none; }
.tw_home a.sym .code { margin-left: var(--space-4); font-size: 12px; color: var(--color-greyMedium); }
.tw_home a.sym:hover { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* Sector bars: one reading (the day's move), not a time series. */
.tw_home .sb li { gap: var(--space-12); }
.tw_home .sb .nm { flex: 0 0 84px; }
.tw_home .sb .bar { flex: 1; min-width: 24px; height: 8px; }
.tw_home .sb .bar i { display: block; height: 100%; border-radius: var(--radius-micro); }
.tw_home .sb .bar i.g { background: var(--color-green); }
.tw_home .sb .bar i.r { background: var(--color-red); }
.tw_home .sb .v { flex: 0 0 60px; text-align: right; }
/* Latin sector names ("Electronic Parts" / "Electronic Products") are unreadable at 84px:
   give them 40% and let them wrap to two lines; CJK names fit the fixed column. */
html:not(:lang(zh)):not(:lang(ja)) .tw_home .sb .nm { flex: 0 0 40%; white-space: normal; line-height: 1.3; }

/* 主力分點買超 — fixed layout so long branch names ellipsize instead of widening the card */
.tw_home table.br { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; color: var(--ink); }
.tw_home table.br td.up { color: var(--color-greenText); }
.tw_home table.br td.dn { color: var(--color-redText); }
.tw_home table.br th {
  padding: 0 0 var(--space-4);
  border-bottom: 1px solid var(--color-greyDark);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  color: var(--color-greyMedium);
}
.tw_home table.br td { height: 32px; padding: 7px 0; border-bottom: 1px solid var(--border-hairline); vertical-align: middle; }
.tw_home table.br tbody tr:last-child td { border-bottom: none; }
.tw_home table.br tbody tr:has(+ tr[hidden]) td { border-bottom: none; }
.tw_home table.br .n { width: 24px; }
.tw_home table.br td.n { font-size: 12px; color: var(--color-greyMedium); }
.tw_home table.br .v { width: 104px; text-align: right; }
.tw_home table.br .s { width: 34%; padding-left: var(--space-16); }
.tw_home table.br .ell { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw_home .broker .card-h .rank_lock_tag { margin-left: 0; }
.tw_home .is-wait .skel { background: var(--surface-card); }
.tw_home .g2.is-open { align-items: start; }
/* 「顯示全部」 reuses the rank-wall row and the quiet-link look, as a button */
.tw_home .rank_wall button.quiet_link {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--link-quiet);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
  cursor: pointer;
}
.tw_home .rank_wall button.quiet_link:hover { color: var(--link-quiet-hover); }
.tw_home .rank_wall button.quiet_link::after { content: ""; position: absolute; inset: calc(-1 * var(--space-12)) 0; }
/* Beside the broker card the sector card is half width: Latin sector names
   (40% column, two lines) need the lists stacked, at every width. */
html:not(:lang(zh)):not(:lang(ja)) .tw_home .g2:has(#broker_card) .sec-two { grid-template-columns: minmax(0, 1fr); gap: var(--space-16); }

/* States */
.tw_home .empty { padding: var(--space-16) 0 var(--space-8); font-size: 13px; color: var(--ink-2); }
.tw_home .empty p { margin: 0 0 var(--space-8); }
.tw_home .btn-out {
  position: relative;
  height: 30px;
  padding: 0 var(--space-12);
  border: 1px solid var(--border-frame);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease-standard);
}
.tw_home .btn-out::before { content: ""; position: absolute; inset: -8px -1px; }
.tw_home .btn-out:hover { background: var(--surface-muted); }

@media (prefers-reduced-motion: reduce) {
  .tw_home .picker,
  .tw_home .segment button,
  .tw_home .btn-out { transition: none; }
}

@media (max-width: 1300px) {
  #box_main { padding-left: 0; }
  /* the offcanvas button already names the page; keep the data-date line */
  .tw_home .titlewrap h1 { display: none; }
  /* the TW container is 588 wide here: phone arrangement for the strip and the three money cards */
  .tw_home .strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-16); }
  .tw_home .strip .c { padding: 0 0 0 var(--space-12); }
  .tw_home .strip .c:first-child { grid-column: 1 / -1; padding-left: 0; }
  .tw_home .strip .c:nth-child(2) { padding-left: 0; border-left: none; }
  .tw_home .g3,
  .tw_home .g2 { grid-template-columns: minmax(0, 1fr); }
  /* Latin sector names need the 40% column to stay within two lines */
  html:not(:lang(zh)):not(:lang(ja)) .tw_home .sec-two { grid-template-columns: minmax(0, 1fr); gap: var(--space-16); }
}

@media (max-width: 768px) {
  .tw_home .pagehead { flex-direction: column; align-items: stretch; gap: var(--space-12); }
  .tw_home .picker { width: 100%; height: 44px; }
  .tw_home .picker::before { display: none; }
  .tw_home .g2 { grid-template-columns: minmax(0, 1fr); }
  .tw_home table.br .s { width: 38%; }
  .tw_home table.br .v { width: 88px; }
  .tw_home .two { grid-template-columns: minmax(0, 1fr); gap: var(--space-16); }
  .tw_home .card-h .r { margin-left: 0; width: 100%; }
  .tw_home .segment { display: flex; width: 100%; }
  .tw_home .segment button { flex: 1; min-width: 0; padding: 0 var(--space-6); }
}
