/* 股市避雷針 Web — Light Mode（premium fintech/wellness aesthetic）。 */
:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --card-border: #e6e8ee;
  --text: #1f2733;          /* charcoal */
  --muted: #667085;
  --text-dim: #98a1b0;
  --fill-soft: #f6f8fb;     /* subtle row/chip fill on white */
  --green: #16a34a;
  --green-glow: rgba(22, 163, 74, 0.10);
  --yellow: #ca8a04;
  --yellow-glow: rgba(202, 138, 4, 0.12);
  --orange: #ea7a00;
  --orange-glow: rgba(234, 122, 0, 0.10);
  --red: #e11d48;
  --red-glow: rgba(225, 29, 72, 0.10);
  --blue: #2563eb;          /* corporate blue accent */
  --blue-glow: rgba(37, 99, 235, 0.10);
  --chart-def: #7c5cff;     /* defensive rotation line (violet) */
  --chart-risk: #e11d48;    /* big-drop risk line (red) */
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 16px -8px rgba(16, 24, 40, 0.10);
  --font: 'Inter', -apple-system, sans-serif;
  --font-out: 'Outfit', 'Inter', sans-serif;
  --t: all .3s cubic-bezier(.25, .8, .25, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  color: var(--text); font-family: var(--font); min-height: 100vh;
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fa 38%, #f3f5f8 100%) fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 進入轉場（Splash）— 與 iOS/Android 一致：品牌底色 + logo + 股名 + 標語，淡出進主畫面 */
#splash {
  position: fixed; inset: 0; z-index: 9999; background: #f8fbfe;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .46s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-lockup {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: splashIn .5s cubic-bezier(.25, .8, .25, 1) both;
}
.splash-logo {
  width: 108px; height: 108px; border-radius: 26px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgba(47, 140, 255, .18);
}
.splash-title {
  font-family: var(--font-out); font-size: 1.72rem; font-weight: 800;
  color: #1c2333; letter-spacing: .04em;
}
.splash-tag { font-size: .92rem; color: #8a93a6; letter-spacing: .02em; }
@keyframes splashIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

/* 說明頁：使用指南條列 */
.info-list { margin: 8px 0 4px; padding-left: 1.15rem; color: var(--muted); font-size: .9rem; line-height: 1.7; }
.info-list li { margin-bottom: 6px; }
.info-list b { color: var(--text); font-weight: 600; }
.glossary { margin-top: 6px; }
.glossary dt { font-weight: 700; color: var(--text); margin-top: 14px; font-size: .92rem; }
.glossary dt:first-of-type { margin-top: 0; }
.glossary dd { margin: 3px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.68; }

/* 說明頁底部「目前版本」 */
.app-version { text-align: center; color: var(--text-dim); font-size: .82rem; margin: 6px 0 10px; }

svg text { text-rendering: geometricPrecision; }
.rrg-svg text { pointer-events: none; }
.rrg-svg line { shape-rendering: crispEdges; }
.rrg-svg polyline, .rrg-svg circle, .svg-chart path { shape-rendering: geometricPrecision; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 14px 28px; background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: saturate(1.4); backdrop-filter: saturate(1.4);
  border-bottom: 1px solid var(--card-border);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { display: block; }
.brand h1 { font-family: var(--font-out); font-size: 1.3rem; font-weight: 800; letter-spacing: -.6px; color: var(--text); }
.sync { display: flex; align-items: center; gap: 6px; font-size: .72rem; color: var(--muted); }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* Tabs */
.tabs {
  position: sticky; top: 51px; z-index: 19;
  display: flex; gap: 4px; padding: 8px 22px; overflow-x: auto;
  background: rgba(248, 249, 250, 0.92);
  border-bottom: 1px solid var(--card-border); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; background: transparent; border: none; color: var(--muted);
  padding: 8px 16px; font-size: .85rem; font-weight: 600; border-radius: 9px;
  cursor: pointer; transition: var(--t); font-family: var(--font);
}
.tab:hover { color: var(--text); background: rgba(16, 24, 40, 0.04); }
.tab.active { background: var(--blue-glow); color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .30); }

/* Content */
.content { max-width: 1080px; margin: 0 auto; padding: 22px 24px 52px; }
.view { display: none; }
.view.active { display: block; }
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 760px) { .grid { grid-template-columns: 1fr 1fr; }
  #card-curve, .section-label { grid-column: 1 / -1; } }

.banner { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px;
  background: var(--orange-glow); border: 1px solid var(--orange); color: #9a4f00; font-size: .85rem; }

/* Cards */
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px;
  padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow-card); }
.grid .card { margin-bottom: 0; }
.card-primary { border-color: rgba(37, 99, 235, .35);
  background: linear-gradient(180deg, #f5f9ff, #ffffff); }
.card-title { font-size: .76rem; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .6px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--muted); font-size: .8rem; line-height: 1.55; }
.note { font-size: .68rem; color: var(--text-dim); margin-top: 8px; line-height: 1.35; }
.section-label { display: flex; align-items: center; gap: 8px; font-size: .72rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.step { font-family: var(--font-out); font-size: .95rem; font-weight: 800; color: var(--blue); }

.badge { font-size: .65rem; font-weight: 700; padding: 2px 7px; border-radius: 5px;
  background: #eef1f5; color: var(--muted); border: 1px solid transparent; }
.badge-lead { background: var(--blue-glow); color: var(--blue); border: 1px solid rgba(37, 99, 235, .25); }

/* Defensive rotation */
.rot-main { display: flex; justify-content: space-between; align-items: center; }
.rot-main h3 { font-family: var(--font-out); font-size: 1.6rem; font-weight: 800; letter-spacing: -.5px; }
.rot-main p { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.rot-status { font-size: .85rem; font-weight: 700; padding: 6px 12px; border-radius: 10px;
  background: var(--fill-soft); border: 1px solid var(--card-border); white-space: nowrap; }
.rot-desc { font-size: .76rem; color: #475467; line-height: 1.5; margin-top: 12px; }

/* 卡內分隔線 */
.card-sep { border-top: 1px solid var(--card-border); margin: 16px 0 12px; }

/* 防禦輪動 刻度條 */
.defbar-label { font-size: .72rem; color: var(--muted); margin-top: 14px; }
.defbar { margin-top: 6px; }
.defbar svg { width: 100%; height: auto; display: block; }
.defbar-cap { display: flex; justify-content: space-between; font-size: .6rem; color: var(--text-dim); margin-top: 4px; }

/* Risk gauge — gauge+badge+score 左欄，7 訊號右側並排（圖2 版面） */
.risk-top { display: flex; gap: 18px; align-items: flex-start; }
.risk-right { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.risk-head { display: flex; align-items: center; gap: 14px; }
.risk-head .risk-badge { margin-bottom: 0; }
.risk-right .rot-desc { margin-top: 0; }
@media (max-width: 520px) { .risk-top { flex-direction: column; } }
.risk-hero { display: flex; align-items: center; gap: 16px; }
.gauge { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg { fill: none; stroke: #e9ecf1; stroke-width: 8; }
.gauge-fill { fill: none; stroke-width: 8; stroke-linecap: round; stroke-dasharray: 226; stroke-dashoffset: 226;
  transition: stroke-dashoffset .8s cubic-bezier(.4, 0, .2, 1), stroke .5s; }
.gauge-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-out); font-size: 1.3rem; font-weight: 800; }
.risk-info { flex-grow: 1; }
.risk-badge { display: inline-block; padding: 4px 11px; border-radius: 30px; font-size: .82rem; font-weight: 700; margin-bottom: 6px; }
.risk-count { font-size: .85rem; color: var(--muted); }
/* 6 訊號 check 清單 */
.signals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 14px; }
.sig { display: flex; align-items: center; gap: 7px; font-size: .73rem; color: var(--muted); }
.sig-mark { width: 15px; height: 15px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-size: .62rem; font-weight: 700; background: #eef1f5; color: var(--text-dim); flex-shrink: 0; }
.sig.on { color: var(--text); font-weight: 600; }
.sig.on .sig-mark { background: var(--red-glow); color: var(--red); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pill { background: var(--fill-soft); border: 1px solid var(--card-border);
  padding: 4px 9px; border-radius: 8px; font-size: .72rem; color: #475467; }
.pill::before { content: '⚡'; margin-right: 4px; font-size: .65rem; }

/* 綜合解讀 strip */
.insight { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px;
  margin-bottom: 16px; font-size: .84rem; line-height: 1.55; border: 1px solid; }
.insight .ic { font-size: 1.05rem; line-height: 1.4; flex-shrink: 0; }
.insight b { font-weight: 700; }
.insight.ok { background: var(--green-glow); border-color: rgba(22, 163, 74, .3); }
.insight.warn { background: var(--orange-glow); border-color: rgba(234, 122, 0, .35); }
.insight.danger { background: var(--red-glow); border-color: rgba(225, 29, 72, .35); }

/* 「為什麼」expandable */
.why-toggle { background: none; border: none; color: var(--blue); font-size: .7rem; font-weight: 600;
  cursor: pointer; padding: 0; margin-top: 10px; }
.why { max-height: 0; overflow: hidden; transition: max-height .35s; font-size: .73rem; color: var(--muted); line-height: 1.6; }
.why.open { max-height: 260px; margin-top: 7px; }

/* Dashboard hero (危險指數 hero + 防禦輪動) */
.dash-hero { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (min-width: 760px) { .dash-hero { grid-template-columns: 1.08fr 1fr; } }
.gauge-lg { width: 112px; height: 112px; }
.gauge-lg + .risk-info .risk-badge { font-size: .92rem; }
.snapshot { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px;
  padding-top: 10px; border-top: 1px solid var(--card-border); font-size: .7rem; color: var(--muted); }
.snapshot b { color: var(--text); font-weight: 600; }

/* Chart (legacy mini + Chart A/B with axes) */
.chart-box { height: 140px; margin-top: 8px; }
.chart-box svg { width: 100%; height: 100%; overflow: visible; }
.chart2-box { width: 100%; margin-top: 6px; position: relative; }
.chart2-box svg { width: 100%; height: auto; display: block; touch-action: none; }
.chart-tip { position: absolute; top: 4px; display: none; pointer-events: none; z-index: 5;
  background: #fff; border: 1px solid var(--card-border); border-radius: 8px;
  box-shadow: var(--shadow-card); padding: 7px 9px; font-size: .66rem; color: var(--muted); white-space: nowrap; }
.chart-tip .tip-date { font-weight: 700; color: var(--text); margin-bottom: 3px; font-size: .68rem; }
.chart-tip .sw { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.chart-tip b { color: var(--text); }
.chart-tip div { line-height: 1.55; }
/* 圖上方「最後取得大盤資訊」的日期時間 + 收盤/漲跌/成交金額列 */
.chart-asof { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px;
  margin: 2px 0 4px; font-size: .72rem; color: var(--muted); }
.chart-asof .asof-date { font-weight: 600; color: #344054; }
.chart-asof .asof-sep { color: var(--card-border); }
.chart-asof b { font-family: var(--font-out); font-weight: 700; color: var(--text); }
.chart-asof .up, .chart-tip .up { color: var(--red); }
.chart-asof .down, .chart-tip .down { color: var(--green); }
.chart-asof .sw { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 4px; vertical-align: middle; }
.chart-note { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 18px; margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--card-border); font-size: .68rem; color: var(--muted); line-height: 1.4; }
@media (min-width: 620px) { .chart-note { grid-template-columns: repeat(5, 1fr); } }
/* flatten the two legend-row wrappers so every item flows into the same 5-column grid */
.chart-note .chart-legend-row { display: contents; }
.chart-note span { display: flex; align-items: center; }
.chart-note .sw { display: inline-block; width: 15px; flex-shrink: 0; margin-right: 7px; }
.chart-note .sw.solid { height: 3px; border-radius: 2px; }
.chart-note .sw.dash { height: 0; }
.chart-note b { color: #344054; font-weight: 600; }
/* legend moved to the right of the chart title (個股走勢圖) */
.sc-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px 12px;
  font-size: .6rem; font-weight: 500; color: var(--muted); text-transform: none;
  letter-spacing: 0; max-width: 64%; line-height: 1.5; }
.sc-legend span { display: inline-flex; align-items: center; }
.sc-legend .sw { display: inline-block; width: 13px; flex-shrink: 0; margin-right: 5px; }
.sc-legend .sw.solid { height: 3px; border-radius: 2px; }
.sc-legend .sw.dash { height: 0; }
.sc-legend b { color: #344054; font-weight: 600; }
#card-stock-chart .card-title { flex-wrap: wrap; gap: 6px 12px; }
@media (max-width: 520px) { .sc-legend { max-width: 100%; justify-content: flex-start; } }

.chart-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; justify-content: flex-end;
  font-size: .62rem; color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500; }
.chart-legend span { display: inline-flex; align-items: center; }
.lg-line { display: inline-block; width: 13px; height: 3px; border-radius: 2px; margin-right: 3px; }
.lg-dash { display: inline-block; width: 13px; height: 0; border-top: 1.5px dashed var(--text-dim); }
.ax-line { stroke: var(--card-border); stroke-width: 1; shape-rendering: crispEdges; }
.ax-grid { stroke: rgba(30, 41, 59, .06); stroke-width: .5; shape-rendering: crispEdges; }
.ax-zero { stroke: rgba(30, 41, 59, .22); stroke-width: 1; shape-rendering: crispEdges; }
.ax-warn { stroke: var(--text-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.ax-text { fill: var(--muted); font-size: 10px; }
.ax-text.r { text-anchor: end; }

/* RRG */
.rrg-box { width: 100%; max-width: 330px; aspect-ratio: 1; margin: 4px auto 0; }
.rrg-svg { width: 100%; height: 100%; overflow: visible; }
.rrg-q { font-size: 9px; font-weight: 700; fill: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }
.rrg-grid { stroke: rgba(30, 41, 59, .07); stroke-width: .5; shape-rendering: crispEdges; }
.rrg-border { fill: none; stroke: rgba(30, 41, 59, .14); stroke-width: 1; shape-rendering: crispEdges; }
.focus-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.focus-name { font-family: var(--font-out); font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; }
.focus-badge { font-size: .62rem; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--card-border); background: var(--fill-soft); }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; margin-top: 12px; }
@media (min-width: 520px) { .legend { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 720px) { .legend { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.legend-item { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px; }
.legend-item:hover { background: var(--fill-soft); }
.legend-item.sel { background: var(--blue-glow); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-name { font-size: .74rem; color: #344054; flex-grow: 1; }
.legend-quad { font-size: .68rem; font-weight: 700; }

/* Factors */
.factor-list { display: flex; flex-direction: column; gap: 8px; }
.factor { background: var(--fill-soft); border: 1px solid var(--card-border); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; transition: var(--t); }
.factor:hover { background: #eef2f7; }
.factor-head { display: flex; justify-content: space-between; align-items: center; }
.factor-left { display: flex; align-items: center; gap: 10px; }
.factor-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.factor-name { font-size: .82rem; font-weight: 600; color: #344054; }
.factor-right { display: flex; align-items: center; gap: 8px; }
.factor-val { font-size: .75rem; color: var(--muted); }
.factor-tag { font-size: .65rem; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: #eef1f5; color: var(--muted); }
.factor-tag.fired { background: var(--red-glow); color: var(--red); }
.factor-detail { max-height: 0; overflow: hidden; transition: max-height .35s; font-size: .72rem; color: var(--muted); padding-left: 20px; }
.factor.open .factor-detail { max-height: 160px; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--card-border); }
.fac-plain { color: #344054; line-height: 1.55; margin-bottom: 5px; }
.fac-stat { color: var(--muted); }

/* Industry / stocks */
.industry-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 10px; }
.industry-title { font-family: var(--font-out); font-size: 1.05rem; font-weight: 800; }
/* wrapped chips in a fixed-height box; scroll vertically to reach all industries */
.picker { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 6px 2px 2px;
  max-height: 84px; overflow-y: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.picker::-webkit-scrollbar { width: 6px; }
.picker::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 3px; }
.chip { flex-shrink: 0; background: var(--card-bg); border: 1px solid var(--card-border);
  color: #475467; padding: 7px 14px; font-size: .78rem; font-weight: 600; border-radius: 20px;
  cursor: pointer; white-space: nowrap; transition: var(--t); font-family: var(--font); }
.chip:hover { background: var(--fill-soft); }
.chip.active { background: var(--blue-glow); border-color: rgba(37, 99, 235, .4); color: #1d4ed8; }
.summary-stats { display: flex; gap: 8px; }
.sstat { display: flex; flex-direction: column; gap: 2px; background: var(--fill-soft);
  border: 1px solid var(--card-border); border-radius: 10px; padding: 8px 10px; min-width: 64px; }
.sstat.grow { flex-grow: 1; }
.sstat-v { font-family: var(--font-out); font-size: .95rem; font-weight: 700; }
.sstat-v.sm { font-family: var(--font); font-size: .8rem; font-weight: 600; }
.sstat-l { font-size: .62rem; color: var(--muted); }
.stock-list { display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; padding-right: 4px; }  /* max-height set in JS to match RRG height */
.stock-list::-webkit-scrollbar { width: 6px; }
.stock-list::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 3px; }
.srow { background: var(--fill-soft); border: 1px solid var(--card-border); border-radius: 12px; padding: 14px 16px; transition: var(--t); }
.srow:hover { background: #eef2f7; cursor: pointer; }
.srow.sel { background: var(--blue-glow); border-color: rgba(37, 99, 235, .4); }
.srow-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.srow-id { display: flex; align-items: baseline; gap: 6px; }
.srow-sym { font-family: var(--font-out); font-size: 1.05rem; font-weight: 800; color: var(--text); }
.srow-name { font-size: .82rem; color: var(--muted); }
.srow-status-text { font-size: .82rem; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 4px; }
/* 突破5均 promoted to a header tag (only shown when a breakout fired) */
.srow-breakout { font-size: .78rem; font-weight: 700; white-space: nowrap; }
.srow-quad { font-size: .74rem; font-weight: 700; padding: 3px 10px; border: 1px solid; border-radius: 20px; white-space: nowrap; }
.srow-metrics { display: grid; grid-template-columns: 1.7fr 1fr 1.1fr 1fr; gap: 6px; }
.srow-metrics .sm-v { font-size: .88rem; }
.smetric .sm-chg { font-family: var(--font-out); font-weight: 700; font-size: .82rem; }
.smetric { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.sm-v { font-family: var(--font-out); font-size: .95rem; font-weight: 700; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-l { font-size: .68rem; color: var(--muted); white-space: nowrap; }
/* 建議 cell carries a tooltip (建議依據); hint it is interactive */
.smetric.sm-rec { cursor: help; }
.smetric.sm-rec .sm-v { font-family: var(--font); }

/* Sectors main grid & mini stock list */
.sectors-main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (min-width: 860px) {
  .sectors-main-grid {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}
.stocks-main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (min-width: 860px) {
  .stocks-main-grid {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: start;
  }
}
.stock-list-mini {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}
.stock-list-mini::-webkit-scrollbar { width: 6px; }
.stock-list-mini::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 3px; }
.srow-mini {
  display: grid;
  grid-template-columns: 14px auto 1.2fr 1fr auto;
  grid-template-rows: auto auto;
  gap: 6px 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--fill-soft);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  transition: var(--t);
}
.srow-mini:hover {
  background: #eef2f7;
}
.srow-mini-star {
  grid-column: 1;
  grid-row: 1;
  color: var(--yellow);
  font-weight: bold;
  font-size: 0.85rem;
  line-height: 1;
}
.srow-mini-sym {
  grid-column: 2;
  grid-row: 1;
  font-family: var(--font-out);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.srow-mini-name {
  grid-column: 3 / span 3;
  grid-row: 1;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1;
}
.srow-mini-price {
  grid-column: 3;
  grid-row: 2;
  font-family: var(--font-out);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}
.srow-mini-change {
  grid-column: 4;
  grid-row: 2;
  font-family: var(--font-out);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}
.srow-mini-quad {
  grid-column: 5;
  grid-row: 2;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}
.srow-star {
  color: var(--yellow);
  font-weight: bold;
  font-size: 0.9rem;
}

.view h3 { font-size: .92rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }

/* Footer ad — unobtrusive: below all content, subtle, clearly labelled */
.site-foot { max-width: 1080px; margin: 0 auto; padding: 8px 24px 40px; }
.ad-wrap { padding-top: 14px; }
.ad-label { display: block; font-size: .58rem; color: var(--text-dim); letter-spacing: .5px;
  text-transform: uppercase; margin-bottom: 6px; text-align: center; }
.adsbygoogle { min-height: 1px; }

/* Fixed bottom bar: sponsor ad (height capped to ~1/3 of the old in-article render)
   + one-line company info, pinned to the viewport bottom (2026-07-21 user request). */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--card-bg); border-top: 1px solid var(--card-border);
  padding: 4px 12px calc(4px + env(safe-area-inset-bottom));
  text-align: center;
}
.bottom-bar .ad-label { margin-bottom: 2px; }
.bottom-bar-ad {
  display: block; width: 100%; max-width: 1080px; height: 90px;
  margin: 0 auto; overflow: hidden;
}
/* darker than --text-dim: the pale grey was unreadable over the light bar (2026-07-22) */
.bottom-bar-info { font-size: .72rem; color: #4a5568; font-weight: 500; margin: 4px 0 0; }
.bottom-bar-info a { color: inherit; }
.bottom-bar-info .divider { margin: 0 4px; color: var(--card-border); }
/* keep scrollable content clear of the fixed bar */
body { padding-bottom: 148px; }
/* Short landscape (phone rotated): the 90px slot ate ~half the viewport. Halve it —
   50px is the smallest standard banner height (320x50), so the slot still fills.
   app.js re-requests the ad on orientation change so the creative matches the size. */
@media (orientation: landscape) and (max-height: 500px) {
  .bottom-bar-ad { height: 50px; }
  .bottom-bar .ad-label { display: none; }
  .bottom-bar-info { margin-top: 2px; }
  body { padding-bottom: 96px; }
}

/* RRG Guide Section Styles */
.rrg-guide-section {
  padding: 24px;
}
.rrg-guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0 24px;
}
@media (max-width: 640px) {
  .rrg-guide-grid {
    grid-template-columns: 1fr;
  }
}
.rrg-guide-card {
  background: var(--fill-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--t);
}
.rrg-guide-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.rrg-guide-card.improving {
  border-left: 4px solid var(--blue);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}
.rrg-guide-card.leading {
  border-left: 4px solid var(--green);
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}
.rrg-guide-card.lagging {
  border-left: 4px solid var(--red);
  background: linear-gradient(135deg, rgba(225, 29, 72, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}
.rrg-guide-card.weakening {
  border-left: 4px solid var(--yellow);
  background: linear-gradient(135deg, rgba(202, 138, 4, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}
.quad-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.quad-header h4 {
  font-family: var(--font-out);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.quad-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.quad-dot.blue { background-color: var(--blue); box-shadow: 0 0 6px var(--blue); }
.quad-dot.green { background-color: var(--green); box-shadow: 0 0 6px var(--green); }
.quad-dot.red { background-color: var(--red); box-shadow: 0 0 6px var(--red); }
.quad-dot.yellow { background-color: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

.quad-meta {
  font-family: var(--font-out);
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.quad-text {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}
.quad-action {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: auto;
  border: 1px solid transparent;
}
.quad-action.blue { background: var(--blue-glow); color: var(--blue); border-color: rgba(37, 99, 235, 0.15); }
.quad-action.green { background: var(--green-glow); color: var(--green); border-color: rgba(22, 163, 74, 0.15); }
.quad-action.red { background: var(--red-glow); color: var(--red); border-color: rgba(225, 29, 72, 0.15); }
.quad-action.yellow { background: rgba(202, 138, 4, 0.1); color: var(--yellow); border-color: rgba(202, 138, 4, 0.15); }

.rrg-guide-footer {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--card-border);
  padding-top: 18px;
}
.guide-tip h5 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.guide-tip p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
}

/* RRG Mini Guide under the chart */
.rrg-mini-guide {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--card-border);
}
.mini-guide-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.mini-guide-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-bottom: 10px;
}
@media (min-width: 580px) {
  .mini-guide-items {
    grid-template-columns: repeat(4, 1fr);
  }
}
.mg-item {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  text-align: center;
  white-space: nowrap;
}
.mg-item.leading { background: var(--green-glow); color: var(--green); border-color: rgba(22, 163, 74, 0.15); }
.mg-item.weakening { background: rgba(202, 138, 4, 0.08); color: var(--yellow); border-color: rgba(202, 138, 4, 0.15); }
.mg-item.lagging { background: var(--red-glow); color: var(--red); border-color: rgba(225, 29, 72, 0.15); }
.mg-item.improving { background: var(--blue-glow); color: var(--blue); border-color: rgba(37, 99, 235, 0.15); }

.mini-guide-note {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 6px;
}

/* Compact horizontal layout for the Sector Focus Card (name+status / stats / badge
   on one row; wraps gracefully on very narrow widths). */
.focus-body-layout {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 8px;
}
.focus-body-left { flex: 1 1 auto; min-width: 0; }
.focus-body-stats { flex: 0 0 auto; display: flex; gap: 8px; flex-wrap: wrap; }
.focus-body-right { flex: 0 0 auto; display: flex; align-items: center; }
@media (min-width: 768px) {
  .focus-body-layout { gap: 24px; }
  .focus-body-left { max-width: 45%; }
  .focus-body-stats { gap: 12px; flex-wrap: nowrap; }
}

/* Stock detail chart layout */
.stock-chart-layout {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 12px;
}
.stock-chart-layout .chart2-box {
  width: 100%;
  margin-top: 0;
}
.sc-legend-bottom {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  padding: 10px 14px;
  background: var(--fill-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  font-size: 0.72rem;
  color: var(--muted);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.02);
}
.sc-legend-bottom div {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}
.sc-legend-bottom .sw {
  display: inline-block;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}
.sc-legend-bottom .sw.solid {
  height: 3px;
}
.sc-legend-bottom .sw.dash {
  height: 0;
}

/* Stock metadata bar */
.stock-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 12px 16px;
  background: var(--fill-soft);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.02);
}
.smeta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.smeta-label {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.smeta-value {
  font-family: var(--font-out);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* Search page layout */
.search-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
@media (min-width: 990px) {
  .search-filters-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-item label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}
.filter-item select,
.filter-item input[type="text"],
.filter-item input[type="number"] {
  padding: 8px 12px;
  background: var(--fill-soft);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: var(--t);
  width: 100%;
}
.filter-item select:focus,
.filter-item input[type="text"]:focus,
.filter-item input[type="number"]:focus {
  border-color: rgba(37, 99, 235, 0.5);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.search-actions { display: flex; gap: 12px; }
/* Card titles: make the key part stand out from the muted card title */
.card-title-strong,
.sc-stock-id {
  font-size: 1rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: 0;
  margin-right: 2px;
}

.sort-controls { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; }
.sort-controls label { font-size: .72rem; font-weight: 600; color: var(--muted); }
.sort-controls select {
  padding: 4px 8px;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  cursor: pointer;
}
.search-actions .chip {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: var(--t);
}
.search-actions .chip.active {
  background: var(--blue-glow);
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.3);
}
.search-actions .chip.active:hover {
  background: rgba(37, 99, 235, 0.15);
}
.search-actions .chip:hover:not(.active) {
  background: rgba(16, 24, 40, 0.04);
  color: var(--text);
}

/* Results stacked vertically: list on top (fixed height), chart below */
.search-results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}
.search-result-list {
  /* Fixed height ~= 3 rows of stock cards */
  height: 330px;
  overflow-y: auto;
  /* Two stocks per row (overrides .stock-list flex column) */
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-content: start;
}
.search-result-list > .muted { grid-column: 1 / -1; }
@media (max-width: 700px) {
  .search-result-list { grid-template-columns: 1fr; }
}

/* Sidebar Ad Layout */
.main-layout {
  width: 100%;
}
.sidebar-ad {
  display: none;
}

@media (min-width: 1240px) {
  .main-layout {
    display: flex;
    max-width: 1440px;
    margin: 0 auto;
    align-items: flex-start;
    gap: 24px;
    padding: 0 24px;
  }
  .content {
    flex: 1;
    max-width: 1080px;
    margin: 0;
    padding-right: 0;
    padding-left: 0;
  }
  .sidebar-ad {
    display: block;
    width: 300px;
    margin-top: 22px;
    flex-shrink: 0;
  }
  .ad-sticky {
    position: sticky;
    top: 130px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-card);
    text-align: center;
  }
}

/* Footer Company Section */
.footer-content {
  margin-top: 30px;
  font-family: var(--font);
}
.footer-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
@media (min-width: 760px) {
  .footer-top {
    flex-direction: row;
    justify-content: space-between;
  }
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.footer-title {
  font-family: var(--font-out);
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: -.4px;
}
.footer-links {
  display: flex;
  gap: 10px;
  font-size: .8rem;
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: var(--t);
}
.footer-links a:hover {
  color: var(--blue);
}
.footer-links .divider {
  color: var(--text-dim);
}
.footer-divider {
  height: 1px;
  background: var(--card-border);
  margin: 20px 0;
}
/* Footer app download badges (store QR codes) */
.footer-apps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
}
.app-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: var(--t);
}
a.app-badge:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
}
.app-qr {
  width: 88px;
  height: 88px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 4px;
}
.app-qr-pending {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fill-soft);
  border-style: dashed;
  color: var(--text-dim);
  font-size: .72rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}
.app-badge-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.app-badge-store {
  font-family: var(--font-out);
  font-weight: 700;
  font-size: .92rem;
  color: var(--text);
}
.app-badge-hint {
  font-size: .72rem;
  color: var(--muted);
}
.app-badge-pending {
  opacity: .8;
}
.footer-bottom {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.footer-disclaimer {
  font-size: .68rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: justify;
}
.footer-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@media (min-width: 760px) {
  .footer-meta {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
  }
}
.footer-company-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.footer-company {
  font-size: .74rem;
  font-weight: 700;
  color: var(--text);
}
.footer-email {
  font-size: .7rem;
  color: var(--muted);
}
.footer-copy {
  font-size: .68rem;
  color: var(--text-dim);
  text-align: center;
}
@media (min-width: 760px) {
  .footer-copy {
    text-align: right;
  }
}

.footer-company a {
  color: var(--text);
  text-decoration: none;
  transition: var(--t);
}
.footer-company a:hover {
  color: var(--blue);
}

/* --- 夜盤入口（參考資料，不列入危險指數計分） --- */
.night-entry { display: flex; justify-content: center; margin-top: 10px; }
.btn-night {
  /* --blue is the corporate accent; there is no --accent token (an earlier draft used
     one, which resolved to nothing and left white text on a white card). */
  background: var(--blue);
  border: 1px solid var(--blue);
  color: #fff;
  padding: 7px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
  transition: var(--t);
  font-family: var(--font);
}
.btn-night:hover { filter: brightness(1.08); }
.btn-night-close {
  background: none; border: 1px solid var(--card-border); color: var(--muted);
  padding: 2px 8px; font-size: .7rem; border-radius: 10px; cursor: pointer;
  font-family: var(--font);
}
.btn-night-close:hover { background: var(--fill-soft); }

/* --- Stock curve navigation buttons --- */
.btn-nav {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--t);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
}
.btn-nav:hover:not(:disabled) {
  background: var(--fill-soft);
  border-color: var(--text-dim);
}
.btn-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--fill-soft);
  border-color: var(--card-border);
}

/* --- Sectors stock mini-list selection highlight --- */
.srow-mini.sel {
  background: var(--blue-glow);
  border-color: rgba(37, 99, 235, 0.4);
}


