/* =============================================================================
   StockWon 公開前台
   設計方向：墨色 × 黃銅（取自 logo #B89B6C）的帳冊感；手機優先，桌機是放大版。
   台股慣例紅漲綠跌，一律搭配 ▲▼ 符號，不只靠顏色。
   ========================================================================== */

/* ---- Tokens ------------------------------------------------------------- */
:root {
    color-scheme: light;

    --bg: #F5F2EC;
    --bg-grid: rgba(23, 24, 27, .035);
    --surface: #FFFFFF;
    --surface-2: #FAF8F4;
    --line: #E8E2D7;
    --line-strong: #D8CFC0;
    --ink: #17181B;
    --ink-2: #4A4D55;
    --ink-3: #7D8088;
    --brass: #B89B6C;
    --brass-ink: #7A6139;
    --brass-soft: rgba(184, 155, 108, .16);
    --up: #D21F3C;
    --up-soft: rgba(210, 31, 60, .10);
    --down: #12804A;
    --down-soft: rgba(18, 128, 74, .10);
    --flat: #7D8088;
    --flat-soft: rgba(125, 128, 136, .12);
    --hot-soft: rgba(230, 168, 23, .2);
    --hot-ink: #855A00;
    --focus: #B89B6C;
    /* K 線指標線：均線依序用 1～6（避開紅綠，紅漲綠跌專用）；副圖兩條線用 5、3 */
    --ind-1: #B89B6C;
    --ind-2: #7D8088;
    --ind-3: #3B6FD4;
    --ind-4: #9257C9;
    --ind-5: #E0861A;
    --ind-6: #15929F;
    --ind-bb: #5E7FAF;

    --shadow: 0 1px 0 rgba(23, 24, 27, .03), 0 10px 30px -18px rgba(23, 24, 27, .22);
    --shadow-pop: 0 24px 60px -20px rgba(23, 24, 27, .35);

    --font-ui: "Geist", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
    --font-num: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    --r-lg: 18px;
    --r: 14px;
    --r-sm: 10px;
    --gutter: 16px;
    --topbar-h: 56px;
    --tabbar-h: 58px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0D0E10;
        --bg-grid: rgba(236, 234, 229, .03);
        --surface: #15171A;
        --surface-2: #1B1E22;
        --line: #24282D;
        --line-strong: #323840;
        --ink: #ECEAE5;
        --ink-2: #B4B2AC;
        --ink-3: #82858C;
        --brass: #C9AE7F;
        --brass-ink: #D9C196;
        --brass-soft: rgba(201, 174, 127, .14);
        --up: #FF5468;
        --up-soft: rgba(255, 84, 104, .14);
        --down: #34C77B;
        --down-soft: rgba(52, 199, 123, .13);
        --flat: #82858C;
        --flat-soft: rgba(130, 133, 140, .16);
        --hot-soft: rgba(240, 184, 64, .16);
        --hot-ink: #F0C25E;
        --ind-1: #C9AE7F;
        --ind-2: #9A9DA4;
        --ind-3: #6E9CFF;
        --ind-4: #B98CF2;
        --ind-5: #F2A03D;
        --ind-6: #3CC3CF;
        --ind-bb: #89A6D3;
        --shadow: 0 1px 0 rgba(0, 0, 0, .4), 0 12px 30px -18px rgba(0, 0, 0, .7);
        --shadow-pop: 0 30px 70px -20px rgba(0, 0, 0, .8);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0D0E10;
    --bg-grid: rgba(236, 234, 229, .03);
    --surface: #15171A;
    --surface-2: #1B1E22;
    --line: #24282D;
    --line-strong: #323840;
    --ink: #ECEAE5;
    --ink-2: #B4B2AC;
    --ink-3: #82858C;
    --brass: #C9AE7F;
    --brass-ink: #D9C196;
    --brass-soft: rgba(201, 174, 127, .14);
    --up: #FF5468;
    --up-soft: rgba(255, 84, 104, .14);
    --down: #34C77B;
    --down-soft: rgba(52, 199, 123, .13);
    --flat: #82858C;
    --flat-soft: rgba(130, 133, 140, .16);
    --hot-soft: rgba(240, 184, 64, .16);
    --hot-ink: #F0C25E;
    --ind-1: #C9AE7F;
    --ind-2: #9A9DA4;
    --ind-3: #6E9CFF;
    --ind-4: #B98CF2;
    --ind-5: #F2A03D;
    --ind-6: #3CC3CF;
    --ind-bb: #89A6D3;
    --shadow: 0 1px 0 rgba(0, 0, 0, .4), 0 12px 30px -18px rgba(0, 0, 0, .7);
    --shadow-pop: 0 30px 70px -20px rgba(0, 0, 0, .8);
}

/* ---- Base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* 元件的 display 規則不能蓋過 hidden 屬性 */
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--topbar-h) + 12px);
}

body {
    margin: 0;
    min-height: 100dvh;
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
}

/* 淡淡的方格紙底紋，只鋪在頁面上方，往下漸隱 */
body::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    z-index: -1;
    height: 480px;
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: -1px -1px;
    -webkit-mask-image: linear-gradient(#000 30%, transparent);
    mask-image: linear-gradient(#000 30%, transparent);
    pointer-events: none;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

.num {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
}

.icon {
    width: 20px;
    height: 20px;
    flex: none;
}

.skip {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 8px 14px;
    background: var(--ink);
    color: var(--bg);
    border-radius: var(--r-sm);
}
.skip:focus { top: 12px; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--line);
}

.topbar__inner {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.brand img { width: 84px; height: auto; }
.brand__dark { display: none; }
:root[data-theme="dark"] .brand__light { display: none; }
:root[data-theme="dark"] .brand__dark { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand__light { display: none; }
    :root:not([data-theme="light"]) .brand__dark { display: block; }
}

.searchbox {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-3);
    cursor: text;
    text-align: left;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.searchbox:hover { border-color: var(--line-strong); }
.searchbox .icon { width: 18px; height: 18px; color: var(--ink-2); }
.searchbox__text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.searchbox__kbd { display: none; }

kbd {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink-2);
    font: 600 12px/1 var(--font-num);
}

.topnav { display: none; }

.iconbtn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    transition: background .2s var(--ease);
}
.iconbtn:hover { background: var(--brass-soft); }

/* 主題切換：顯示「按下去會變成的」那個圖示 */
.icon--sun { display: none; }
:root[data-theme="dark"] .icon--sun { display: block; }
:root[data-theme="dark"] .icon--moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon--sun { display: block; }
    :root:not([data-theme="light"]) .icon--moon { display: none; }
}

/* ---- Bottom tab bar (mobile) ------------------------------------------- */
.tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--line);
}

.tabbar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: none;
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    cursor: pointer;
}
.tabbar__item .icon { width: 22px; height: 22px; }
.tabbar__item.is-active { color: var(--brass-ink); }
.tabbar__item:active { transform: scale(.94); }

/* ---- Page --------------------------------------------------------------- */
.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px var(--gutter) 32px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: 16px;
}
.card + .card { margin-top: 12px; }

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.card__title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .02em;
}
.card__title::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 13px;
    margin-right: 8px;
    border-radius: 2px;
    background: var(--brass);
    vertical-align: -1px;
}

.card__sub { color: var(--ink-3); font-size: 12px; }

.empty { color: var(--ink-3); padding: 8px 0; }

.chip {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--brass-soft);
    color: var(--brass-ink);
    font-size: 12px;
    font-weight: 600;
}

.code {
    font-family: var(--font-num);
    color: var(--ink-3);
    font-size: 13px;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    height: 24px;
    padding: 0 8px;
    border-radius: 7px;
    font-family: var(--font-num);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.flat { background: var(--flat-soft); color: var(--flat); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s var(--ease), background .2s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn--primary {
    border-color: transparent;
    background: var(--ink);
    color: var(--bg);
}

/* ---- Stock hero --------------------------------------------------------- */
.hero { padding: 4px 0 16px; }

.hero__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.hero__name {
    font-size: 26px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: .01em;
}

.hero__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}
.hero__meta .code { font-size: 14px; margin-right: 2px; }

.watchbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.watchbtn .icon { width: 18px; height: 18px; }
.watchbtn .icon--on { display: none; color: var(--brass); }
.watchbtn[aria-pressed="true"] {
    border-color: var(--brass);
    background: var(--brass-soft);
    color: var(--brass-ink);
}
.watchbtn[aria-pressed="true"] .icon--on { display: block; animation: pop .35s var(--ease); }
.watchbtn[aria-pressed="true"] .icon--off { display: none; }

@keyframes pop {
    0% { transform: scale(.6); }
    60% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

.quote {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    margin-top: 18px;
}

.quote__price {
    font-size: 44px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -.035em;
}

.quote__change {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.asof {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    color: var(--ink-3);
    font-size: 13px;
}
.asof .icon { width: 14px; height: 14px; }

.ranges {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.range__label {
    display: flex;
    justify-content: space-between;
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    margin-bottom: 6px;
}

.range__track {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--down-soft), var(--line) 50%, var(--up-soft));
}

.range__dot {
    position: absolute;
    top: 50%;
    left: var(--pos, 50%);
    width: 14px;
    height: 14px;
    border: 3px solid var(--surface);
    border-radius: 50%;
    background: var(--brass);
    box-shadow: 0 0 0 1px var(--line-strong), 0 2px 6px rgba(0, 0, 0, .18);
    transform: translate(-50%, -50%);
}
.range__dot.up { background: var(--up); }
.range__dot.down { background: var(--down); }
.range__dot.flat { background: var(--flat); }

.range__ends {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    color: var(--ink-2);
    font-size: 12px;
}

/* ---- Stock layout ------------------------------------------------------- */
.stock__grid { display: grid; gap: 12px; }
.stock__side .card:first-child { margin-top: 0; }
.stock__main, .stock__side { min-width: 0; }

/* ---- Chart -------------------------------------------------------------- */
.seg {
    display: inline-flex;
    padding: 3px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.seg button {
    min-width: 40px;
    height: 30px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-3);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s var(--ease), color .2s var(--ease);
}
.seg button[aria-selected="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--line);
}

.chartcard .card__head { flex-wrap: wrap; }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    min-height: 20px;
    margin-bottom: 6px;
    color: var(--ink-2);
    font-size: 12px;
}
.legend b { font-weight: 600; color: var(--ink-3); margin-right: 3px; font-family: var(--font-ui); }

.chart {
    position: relative;
    height: 320px;
    margin: 0 -6px;
}

/* 指標設定按鈕跟在標題後面，區間切換靠右 */
.chartcard__set { display: inline-flex; align-items: center; gap: 4px; margin-right: auto; }
.chartcard__set .icon { width: 14px; height: 14px; }
.legend__break { flex-basis: 100%; height: 0; }
.legend__ind b { color: var(--c, var(--ink-3)); }
.legend__ind.up b, .legend__ind.down b, .legend__ind.flat b { color: var(--ink-3); }

/* 副圖（MACD、KD、RSI）：疊在主圖下面，時間軸只畫在最下面那張 */
.chartsubs { margin: 0 -6px; }
.chartsub { position: relative; border-top: 1px solid var(--line); }
.chartsub__plot { height: 96px; }
.chartsub:last-child .chartsub__plot { height: 122px; }
.chartsub__legend {
    position: absolute;
    top: 3px;
    left: 6px;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    color: var(--ink-2);
    font-size: 11px;
    pointer-events: none;
}
.chartsub__name { color: var(--ink-3); font-family: var(--font-ui); font-weight: 600; }
.chartsub__legend b { margin-right: 3px; font-family: var(--font-ui); font-weight: 600; }

/* 指標設定面板（stock.js 動態建立） */
.chartset__body { padding: 0 16px; }
.chartset__group { padding: 12px 0; }
.chartset__group + .chartset__group { border-top: 1px solid var(--line); }
.chartset__head { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.chartset__title { margin-right: auto; font-size: 15px; font-weight: 600; }
.chartset__hint { color: var(--ink-3); font-size: 12px; }
.chartset__sub { margin-top: 8px; padding: 10px 0 0; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.chartset__sub + .chartset__group { border-top: 0; }
.chartset__mas { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 12px; margin-top: 8px; }
.chartset__mas li { display: flex; align-items: center; gap: 6px; }
.chartset__dot { flex: none; width: 14px; height: 3px; border-radius: 2px; }
.chartset__mas input, .chartset__num input {
    width: 72px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 500 15px var(--font-num);
}
.chartset__mas input:focus, .chartset__num input:focus { outline: 2px solid var(--brass); outline-offset: -1px; }
.chartset__unit { color: var(--ink-3); font-size: 13px; }
.chartset__mas .iconbtn { width: 32px; height: 32px; margin-left: -2px; }
.chartset__mas .iconbtn .icon { width: 14px; height: 14px; }
.chartset__none { margin-top: 6px; color: var(--ink-3); font-size: 13px; }
.chartset__presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chartset__presets .chipbtn { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-num); }
.chartset__presets .icon { width: 12px; height: 12px; }
.chartset__params { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; }
.chartset__num { display: grid; gap: 4px; color: var(--ink-3); font-size: 12px; }
.chartset__foot {
    position: sticky;
    bottom: 0;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
    padding: 12px 16px calc(12px + var(--safe-b));
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.chartset__status { flex: 1 1 100%; color: var(--ink-3); font-size: 12px; }
.chartset__status a { color: var(--brass-ink); font-weight: 600; text-decoration: underline; }

.note {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 10px;
    color: var(--ink-3);
    font-size: 12px;
}
.legendkey { display: inline-flex; align-items: center; gap: 6px; }
.legendkey i { display: inline-block; width: 14px; height: 2px; border-radius: 2px; }
.legendkey .ma20 { background: var(--brass); }
.legendkey .ma60 { background: var(--ink-3); }

.skeleton {
    position: absolute;
    inset: 0;
    border-radius: var(--r);
    background:
        linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface) 70%, transparent) 50%, transparent 70%) 0 0 / 200% 100%,
        var(--surface-2);
    animation: shimmer 1.4s linear infinite;
}
.skeleton--row { position: relative; height: 56px; margin: 6px 0; }

@keyframes shimmer { to { background-position: -200% 0, 0 0; } }

/* ---- Revenue ------------------------------------------------------------ */
.revhead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.revhead__label { color: var(--ink-3); font-size: 12px; }
.revhead__value { margin-top: 2px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.revhead__growth { display: flex; gap: 16px; }
.revhead__growth dt { color: var(--ink-3); font-size: 12px; }
.revhead__growth dd { font-size: 16px; font-weight: 600; }

.revbars {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    align-items: end;
    gap: 4px;
    height: 112px;
    margin: 16px 0 12px;
}
.revbars li {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    gap: 4px;
    height: 100%;
}
.revbars__bar {
    display: block;
    height: var(--h, 0%);
    min-height: 2px;
    border-radius: 4px 4px 2px 2px;
    background: var(--brass-soft);
    transform-origin: bottom;
    animation: rise-bar .7s var(--ease) both;
}
.revbars li.is-latest .revbars__bar { background: var(--brass); }
.revbars__month {
    color: var(--ink-3);
    font-size: 10px;
    text-align: center;
    line-height: 1;
}
.revbars li.is-latest .revbars__month { color: var(--brass-ink); font-weight: 600; }

@keyframes rise-bar { from { transform: scaleY(0); } }

.revtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.revtable th, .revtable td {
    padding: 8px 0;
    border-top: 1px solid var(--line);
    text-align: right;
    font-weight: 400;
}
.revtable thead th {
    border-top: 0;
    padding-top: 0;
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
}
.revtable th:first-child { text-align: left; color: var(--ink-2); }
.revtable td:nth-child(2) { color: var(--ink); font-weight: 600; }

/* ---- News --------------------------------------------------------------- */
.news li + li { border-top: 1px solid var(--line); }
.news a {
    display: block;
    padding: 12px 0;
    transition: color .2s var(--ease);
}
.news a:hover .news__title { color: var(--brass-ink); }
.news__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
}
.news__meta {
    display: block;
    margin-top: 4px;
    color: var(--ink-3);
    font-size: 12px;
}
.news__meta .dot { margin: 0 6px; }

/* ---- Stats -------------------------------------------------------------- */
.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    overflow: hidden;
    border-radius: var(--r);
    background: var(--line);
    border: 1px solid var(--line);
}
.stats > div {
    padding: 10px 12px;
    background: var(--surface);
}
.stats dt {
    color: var(--ink-3);
    font-size: 12px;
}
.stats dd {
    margin-top: 2px;
    font-size: 17px;
    font-weight: 600;
}
.stats small { margin-left: 3px; color: var(--ink-3); font-size: 12px; font-weight: 400; font-family: var(--font-ui); }

/* ---- 年度 EPS：名稱下面一行（舊到新） ----------------------------------- */
.heroeps {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 12px;
    margin-top: 8px;
    font-size: 13px;
}
.heroeps__label { color: var(--ink-3); }
.heroeps__item { display: inline-flex; align-items: baseline; gap: 5px; }
.heroeps__year { color: var(--ink-3); font-size: 12px; }
.heroeps b { font-weight: 600; }

/* ---- Quote lists (peers, watchlist) ------------------------------------ */
.quotes li + li { border-top: 1px solid var(--line); }
.quotes a {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 6px 0;
}
.quotes__name {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quotes__name small { font-weight: 400; }
.quotes__price { font-weight: 600; text-align: right; }
.quotes a:hover .quotes__name { color: var(--brass-ink); }

.quotes--big a { min-height: 60px; }
.quotes--big .quotes__price { font-size: 17px; }
.quotes__sub { display: block; color: var(--ink-3); font-size: 12px; font-weight: 400; }

.quotes__row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px;
}
.quotes__remove {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--ink-3);
    cursor: pointer;
}
.quotes__remove:hover { background: var(--up-soft); color: var(--up); }
.quotes__remove .icon { width: 16px; height: 16px; }

/* ---- Home widgets ------------------------------------------------------- */
.homehead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0 16px;
}
.homehead__title { font-size: 24px; font-weight: 600; line-height: 1.25; }
.homehead__sub { margin-top: 4px; color: var(--ink-3); font-size: 13px; }
.nextupd__part { white-space: nowrap; }
.nextupd__sep { margin: 0 6px; }
.nextupd__left { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.nextupd--busy::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--brass);
    vertical-align: 1px;
    animation: nextupd-pulse 1.4s ease-in-out infinite;
}
@keyframes nextupd-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .nextupd--busy::before { animation: none; } }

.widgets {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

.widget {
    position: relative;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: 16px;
    animation: reveal .45s var(--ease) both;
}
.widget:nth-child(2) { animation-delay: .04s; }
.widget:nth-child(3) { animation-delay: .08s; }
.widget:nth-child(4) { animation-delay: .12s; }
.widget:nth-child(n+5) { animation-delay: .16s; }

.widget__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
    margin-bottom: 10px;
}
.widget__title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .02em;
}
.widget__title::before {
    content: "";
    display: inline-block;
    width: 3px;
    height: 13px;
    margin-right: 8px;
    border-radius: 2px;
    background: var(--brass);
    vertical-align: -1px;
}
.widget__more {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: var(--brass-ink);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.widget__more .icon { width: 14px; height: 14px; }
.widget__more:hover { text-decoration: underline; text-underline-offset: 3px; }
.widget__note { margin: -4px 0 6px; color: var(--ink-3); font-size: 12px; }
.widget__empty {
    display: grid;
    justify-items: start;
    gap: 10px;
    padding: 8px 0;
    color: var(--ink-3);
}

.quotes__no {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 20px;
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
}
.quotes--rank li:nth-child(-n+3) .quotes__no { color: var(--brass-ink); }
.quotes__name--stack {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    white-space: normal;
}
.quotes__name--stack > span { display: flex; align-items: baseline; gap: 8px; }
.quotes__name--stack .quotes__sub {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quotes__price small { margin-left: 2px; color: var(--ink-3); font-size: 11px; font-weight: 400; font-family: var(--font-ui); }

/* 大盤 */
.market { display: grid; gap: 14px; }
.market__label { color: var(--ink-3); font-size: 12px; }
.market__value { margin-top: 2px; font-size: 34px; font-weight: 600; line-height: 1.1; letter-spacing: -.03em; }
.market__change { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 15px; font-weight: 600; }

.spark { display: block; width: 100%; height: 64px; }
.spark path { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark--up path { stroke: var(--up); }
.spark--down path { stroke: var(--down); }
.spark--flat path { stroke: var(--flat); }

.breadth__bar {
    display: flex;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
}
.breadth__bar span { display: block; height: 100%; }
.up-bg { background: var(--up); }
.down-bg { background: var(--down); }
.flat-bg { background: var(--line-strong); }
.breadth__nums {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 12px;
    margin-top: 12px;
}
.breadth__nums dt { color: var(--ink-3); font-size: 12px; }
.breadth__nums dd { font-size: 16px; font-weight: 600; }

/* ---- List pages (rank / industry / limit-up / news) -------------------- */
.pagehead__crumb { margin-bottom: 4px; font-size: 13px; }
.pagehead__crumb a { color: var(--brass-ink); font-weight: 600; }
.pagehead__crumb a::after { content: " ›"; color: var(--ink-3); }

/* 同一組頁面的切換（_SectionTabs）：放在頁首上方，樣式同 .seg，跟下面的頁內分頁區分開 */
.sectabs {
    display: inline-flex;
    max-width: 100%;
    margin-bottom: 14px;
    padding: 3px;
    overflow-x: auto;
    scrollbar-width: none;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-2);
}
.sectabs::-webkit-scrollbar { display: none; }
.sectabs a {
    display: inline-flex;
    flex: none;
    align-items: center;
    height: 32px;
    padding: 0 14px;
    border-radius: 8px;
    color: var(--ink-3);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.sectabs a:hover { color: var(--ink); }
.sectabs a[aria-current="page"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 0 0 1px var(--line);
}

/* 頁內分頁：手機可橫向滑動 */
.tabs {
    display: flex;
    gap: 4px;
    margin: 0 calc(var(--gutter) * -1) 12px;
    padding: 0 var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
    flex: none;
    padding: 10px 12px;
    border-bottom: 2px solid transparent;
    color: var(--ink-3);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}
.tabs__item:hover { color: var(--ink); }
.tabs__item[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brass); }

.chips { display: flex; gap: 6px; margin-bottom: 12px; }
.chips a {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}
.chips a[aria-current="page"] { border-color: var(--brass); background: var(--brass-soft); color: var(--brass-ink); }
.chips a small { margin-left: 6px; color: var(--ink-3); font-size: 12px; }
.chips a[aria-current="page"] small { color: inherit; }

/* 漲停股（/limit-up）價格與成交量篩選、個人預設 */
.lufilter { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; align-items: end; margin-bottom: 8px; }
.lufilter .btn { grid-column: 1 / -1; }
.lufilter__note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 20px; margin-bottom: 12px; color: var(--ink-3); font-size: 13px; }
.lufilter__note form { display: contents; }
.lufilter__note a, .lufilter__link { padding: 0; border: 0; background: none; color: var(--brass-ink); font: inherit; font-weight: 600; cursor: pointer; }
@media (min-width: 768px) {
    .lufilter { grid-template-columns: repeat(3, minmax(0, 160px)) auto; justify-content: start; }
    .lufilter .btn { grid-column: auto; }
}

.dtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.dtable th {
    position: sticky;
    top: var(--topbar-h);
    z-index: 1;
    padding: 8px 4px;
    background: var(--surface);
    border-bottom: 1px solid var(--line-strong);
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
.dtable td {
    padding: 10px 4px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.dtable tr:last-child td { border-bottom: 0; }
.dtable tbody tr:hover td { background: var(--surface-2); }
/* 整列都能點開個股側頁（sheet.js） */
.dtable tbody tr:has(a[href^="/stock/"], a[href^="/portfolio/"]) { cursor: pointer; }
.dtable .num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dtable th.num { font-family: var(--font-ui); }
.dtable__no { width: 28px; color: var(--ink-3); font-size: 12px; }
.dtable tbody tr:nth-child(-n+3) .dtable__no { color: var(--brass-ink); font-weight: 600; }
/* 手機：名稱與代號上下兩行，表格才放得下 */
.dtable__name { display: inline-flex; flex-direction: column; gap: 0; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.dtable__name .code { font-size: 11px; font-weight: 400; }
.dtable__name:hover { color: var(--brass-ink); }
.dtable__mini { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12px; font-family: var(--font-num); }
.dtable .pill { min-width: 66px; }
.card:has(> .dtable) { padding-left: 10px; padding-right: 10px; }
.hide-sm { display: none; }

.leader { display: inline-block; margin-right: 10px; font-size: 13px; white-space: nowrap; }
.leader:hover { color: var(--brass-ink); }

.statline {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--line);
}
.statline > div { display: grid; gap: 2px; padding: 10px 12px; background: var(--surface); }
.statline > div:last-child:nth-child(3n + 2) { grid-column: span 2; }
.statline span { color: var(--ink-3); font-size: 12px; }
.statline strong { font-size: 17px; font-weight: 600; }

.split { display: grid; gap: 12px; }
.split__main { display: grid; gap: 12px; min-width: 0; align-content: start; }
.split .card + .card { margin-top: 0; }
.quotes li.is-current a { background: var(--brass-soft); margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: var(--r-sm); }

/* ---- Stock pools -------------------------------------------------------- */
.pagehead__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title { margin: 24px 0 10px; font-size: 15px; font-weight: 600; }

.poolintro { display: grid; justify-items: start; gap: 14px; }
.poolintro p { color: var(--ink-2); }

/* 持股紀錄：匯入舊站交易日誌 */
.legacylist li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.legacylist li + li { border-top: 1px solid var(--line); }
.legacylist__id { display: grid; min-width: 0; }
.legacylist__id strong { font-weight: 600; }
.legacylist__id small { color: var(--ink-3); font-size: 12px; }
.legacylist__done { flex: none; color: var(--ink-3); font-size: 13px; }
.legacylist form { flex: none; }
.importres { display: grid; gap: 8px; border-color: var(--brass); background: var(--brass-soft); }
.importres--error { border-color: var(--line); background: var(--surface); }
.importres__warn { display: grid; gap: 4px; padding-left: 18px; list-style: disc; font-size: 13px; }
.importres__warn a { text-decoration: underline; }

.btn--compact { min-height: 38px; padding: 0 14px; gap: 6px; font-size: 14px; }
.btn--compact .icon { width: 16px; height: 16px; }

.poollist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.poollist > li { display: grid; }
.poolcard {
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color .2s var(--ease);
}
.poolcard:hover { border-color: var(--brass); }
.poolcard__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.poolcard__name { font-size: 16px; font-weight: 600; }
.poolcard__count { font-size: 22px; font-weight: 600; }
.poolcard__count small { margin-left: 2px; color: var(--ink-3); font-size: 12px; font-family: var(--font-ui); }
.poolcard__conds { display: flex; flex-wrap: wrap; gap: 4px; }
.poolcard__conds span {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 12px;
    line-height: 1.6;
}
.poolactions { margin-top: 12px; }

.badge {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    height: 20px;
    padding: 0 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge--new { background: var(--up-soft); color: var(--up); }
.dtable .badge { margin-left: 6px; vertical-align: 2px; }

.tplheading { margin-top: 28px; margin-bottom: 4px; }
.tplgroup + .tplgroup { margin-top: 14px; }
.tplgroup__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.tplgroup__head .section-title { margin-bottom: 0; }
.tplgroup__sub { margin: -4px 0 8px; }
.tplgroup__title { color: var(--ink-3); font-size: 13px; font-weight: 600; }
.tplgroup__link { font-size: 13px; }

.templates { display: grid; gap: 8px; }
@media (min-width: 640px) { .templates { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .templates { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.templates > li { display: grid; }
.tplcard {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-2);
    transition: border-color .2s var(--ease), background .2s var(--ease);
}
.tplcard:hover { border-color: var(--brass); background: var(--brass-soft); }
.tplcard__icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    background: var(--brass-soft);
    color: var(--brass-ink);
}
.tplcard__icon .icon { width: 18px; height: 18px; }
.tplcard__text { display: grid; gap: 1px; min-width: 0; flex: 1; }
.tplcard strong { font-size: 14px; font-weight: 600; }
.tplcard small { color: var(--ink-3); font-size: 12px; line-height: 1.45; }
.tplcard__go { width: 16px; height: 16px; color: var(--ink-3); }
.tplcard:hover .tplcard__go { color: var(--brass-ink); }

.condchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.condchips li {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--brass-soft);
    color: var(--brass-ink);
    font-size: 12px;
    font-weight: 600;
}
.condchips li.condchips__add { padding: 0; background: none; }
.condchips__add .chipbtn { display: inline-flex; align-items: center; gap: 4px; }
.condchips__add .icon { width: 14px; height: 14px; }
.addcond__pane { padding: 12px 16px calc(16px + var(--safe-b)); }
.addcond__pane .cond__ctrl { margin-top: 0; }
.addcond__foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.addcond__count { margin-right: auto; color: var(--ink-2); font-size: 13px; }
.statline strong small { color: var(--ink-3); font-size: 12px; font-weight: 400; font-family: var(--font-ui); }
.removed { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.removed a { display: inline-flex; align-items: baseline; gap: 4px; font-weight: 600; }

/* 編輯器 */
.editor { display: grid; gap: 12px; padding-bottom: 72px; }
.editor .card + .card { margin-top: 0; }
.editor__name { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.editor__name input {
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink);
    font: 500 16px var(--font-ui);
}
.editor__templates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--ink-3); font-size: 13px; }
.chipbtn {
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.chipbtn:hover { border-color: var(--brass); }
.chipbtn--on { border-color: var(--brass); background: var(--brass-soft); color: var(--brass-ink); }
.chipbtn--sm { height: 26px; padding: 0 10px; font-size: 12px; }
.note .chipbtn { margin-left: auto; }
.editor__add { margin-top: 10px; }

.conds li.cond { padding: 12px 0; }
.conds li.cond + li.cond { border-top: 1px solid var(--line); }
.cond__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cond__label { font-weight: 600; }
.cond__remove { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 999px; background: none; color: var(--ink-3); cursor: pointer; }
.cond__remove:hover { background: var(--up-soft); color: var(--up); }
.cond__remove .icon { width: 16px; height: 16px; }
.cond__ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.cond__ctrl select, .cond__ctrl input {
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 500 15px var(--font-ui);
}
.cond__ctrl input { width: 110px; font-family: var(--font-num); }
.cond__unit { color: var(--ink-3); font-size: 13px; }
.cond__chips { display: contents; }
.cond__hint { margin-top: 6px; color: var(--ink-3); font-size: 12px; }

.preview__count { font-size: 15px; font-weight: 600; color: var(--brass-ink); }
.preview__count.is-loading { opacity: .5; }

.editor__bar {
    position: fixed;
    inset: auto 0 calc(var(--tabbar-h) + var(--safe-b)) 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px var(--gutter);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--line);
}
.editor__bar .btn { min-height: 40px; padding: 0 16px; }
.editor__delete { color: var(--up); }

.catalog__group { padding: 12px 10px 4px; color: var(--ink-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; }

/* ---- Pro / Donate / Legal ---------------------------------------------- */
.pro { max-width: 880px; margin: 0 auto; }
.pro__hero { padding: 8px 0 24px; }
.pro__eyebrow { color: var(--brass-ink); font: 600 13px var(--font-num); letter-spacing: .12em; text-transform: uppercase; }
.pro__title { margin-top: 8px; font-size: 28px; font-weight: 600; line-height: 1.3; }
.pro__lead { margin-top: 12px; color: var(--ink-2); font-size: 15px; max-width: 36em; }
.pro__foot { margin-top: 20px; color: var(--ink-3); text-align: center; }
.pro__foot a { color: var(--brass-ink); font-weight: 600; }

.plans { display: grid; gap: 12px; }
.plan {
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.plan--pro { border: 2px solid var(--brass); background: linear-gradient(180deg, var(--brass-soft), var(--surface) 40%); }
.plan__name { font-size: 18px; font-weight: 600; }
.plan__price { font-size: 32px; font-weight: 600; letter-spacing: -.02em; }
.plan__price small { color: var(--ink-3); font-size: 14px; font-weight: 400; }
.plan__list { display: grid; gap: 10px; }
.plan__list li { position: relative; padding-left: 22px; color: var(--ink-2); }
.plan__list li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: .55em;
    width: 10px;
    height: 6px;
    border-left: 2px solid var(--brass);
    border-bottom: 2px solid var(--brass);
    transform: rotate(-45deg);
}
.plan__list strong { color: var(--ink); font-weight: 600; }
.soon {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 600;
    vertical-align: 1px;
}
.plan__cta { justify-self: start; }
.plan__notice { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); font-size: 13px; }

.donate { display: grid; justify-items: center; gap: 12px; max-width: 560px; margin: 0 auto; padding: 32px 0; text-align: center; }
.donate__img { width: 120px; height: auto; }
.donate__title { font-size: 26px; font-weight: 600; }
.donate__text { color: var(--ink-2); }
.donate__cta { margin-top: 8px; }
.donate__note { color: var(--ink-3); font-size: 12px; }

.legal { max-width: 760px; margin: 0 auto; }
.legal h1 { font-size: 26px; font-weight: 600; }
.legal__meta { margin-top: 4px; color: var(--ink-3); font-size: 13px; }
.legal h2 { margin: 28px 0 8px; font-size: 17px; font-weight: 600; }
.legal p, .legal li { color: var(--ink-2); line-height: 1.8; }
.legal p + p { margin-top: 8px; }
.legal ul { display: grid; gap: 6px; padding-left: 1.2em; list-style: disc; }
.legal a { color: var(--brass-ink); text-decoration: underline; text-underline-offset: 3px; }
.legal strong { color: var(--ink); }

/* ---- Ads ----------------------------------------------------------------- */
/* 每個版位先保留高度，廣告晚到也不會把內容往下推（CLS） */
.adslot { display: block; margin: 12px 0; }
.adslot__label {
    display: block;
    margin-bottom: 4px;
    color: var(--ink-3);
    font-size: 11px;
    letter-spacing: .08em;
}
.adslot__box {
    min-height: 280px;
    overflow: hidden;
    border-radius: var(--r);
    background: var(--surface-2);
}
.adslot__box--preview {
    display: grid;
    place-items: center;
    border: 1px dashed var(--line-strong);
    color: var(--ink-3);
    font: 600 13px var(--font-num);
}
.widgets > .adslot { grid-column: 1 / -1; margin: 0; }
.widgets.is-editing > .adslot { display: none; }
.adrow td { padding: 4px 0 !important; background: none !important; }

/* ---- Home edit mode ----------------------------------------------------- */
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--accent { border-color: transparent; background: var(--brass); color: #1b1408; }

.editbar {
    position: fixed;
    inset: auto 0 calc(var(--tabbar-h) + var(--safe-b)) 0;
    z-index: 40;
    padding: 10px var(--gutter);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--line);
    box-shadow: var(--shadow-pop);
    animation: rise .2s var(--ease);
}
.editbar__inner {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 1200px;
    margin: 0 auto;
}
.editbar__spacer { flex: 1; }
.editbar .btn { min-height: 40px; padding: 0 14px; }

.widgets.is-editing { padding-bottom: 80px; }
.widgets.is-editing .widget {
    outline: 2px dashed var(--line-strong);
    outline-offset: -2px;
    animation: none;
}
.widgets.is-editing .widget__body { pointer-events: none; opacity: .55; max-height: 220px; overflow: hidden; }
.widgets.is-editing .widget__more { display: none; }

.wtools {
    display: flex;
    align-items: center;
    gap: 4px;
}
.wtools button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
}
.wtools button:hover { border-color: var(--line-strong); color: var(--ink); }
.wtools .icon { width: 18px; height: 18px; }
.wtools__drag { cursor: grab !important; touch-action: none; }
.wtools__size { width: auto !important; padding: 0 10px; font: 600 12px/1 var(--font-num); }
.wtools__remove:hover { background: var(--up-soft) !important; color: var(--up) !important; }

.widget.sortable-ghost { opacity: .35; }
.widget.sortable-chosen { box-shadow: var(--shadow-pop); }

/* 底部彈出面板（桌機置中對話框） */
.sheet {
    width: 100%;
    max-width: 100%;
    max-height: 80dvh;
    margin: auto 0 0;
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
    overflow: auto;
}
.sheet::backdrop { background: rgba(13, 14, 16, .45); }
.sheet[open] { animation: rise .22s var(--ease); }
.sheet__head {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.sheet__title { font-size: 16px; font-weight: 600; }

.catalog { padding: 8px 8px calc(16px + var(--safe-b)); }
.catalog li + li { border-top: 1px solid var(--line); }
.catalog button {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    text-align: left;
    cursor: pointer;
}
.catalog button:hover { background: var(--brass-soft); }
.catalog strong { display: block; font-weight: 600; }
.catalog small { display: block; margin-top: 2px; color: var(--ink-3); font-size: 12px; }
.catalog .icon { color: var(--brass-ink); }

.settings { display: grid; gap: 14px; padding: 16px 16px calc(20px + var(--safe-b)); }
.settings label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.settings select {
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 500 15px var(--font-ui);
}
.settings .btn { justify-self: end; }

/* ---- Page heads & empty states ----------------------------------------- */
.pagehead { padding: 4px 0 16px; }
.pagehead__title { font-size: 26px; font-weight: 600; }
.pagehead__sub { margin-top: 4px; color: var(--ink-3); font-size: 13px; }
.pagehead__link { color: var(--brass-ink); font-weight: 600; }

.emptypage {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 64px 16px;
    text-align: center;
}
.emptypage--inline { padding: 40px 16px; }
.emptypage__code { color: var(--brass-ink); font-size: 14px; font-weight: 600; }
.emptypage__title { font-size: 20px; font-weight: 600; }
.emptypage__text { color: var(--ink-3); margin-bottom: 12px; }
.emptypage__icon { width: 36px; height: 36px; color: var(--brass); }

/* ---- Footer ------------------------------------------------------------- */
.footer {
    border-top: 1px solid var(--line);
    color: var(--ink-3);
    font-size: 12px;
}
.footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px var(--gutter) 28px;
}
.footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
}
.footer__links a { color: var(--ink-2); }
.footer__links a:hover { color: var(--brass-ink); }

/* ---- Search overlay ----------------------------------------------------- */
.search[hidden] { display: none; }

.search {
    position: fixed;
    inset: 0;
    z-index: 60;
}

.search__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 14, 16, .42);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fade .18s var(--ease);
}

.search__panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    animation: rise .22s var(--ease);
}

.search__bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--gutter);
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--line);
}
.search__bar > .icon { color: var(--brass); }

.search__input {
    flex: 1;
    min-width: 0;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--ink);
    /* 16px 以上 iOS 才不會自動放大畫面 */
    font: 500 18px/1.2 var(--font-ui);
    outline: none;
}
.search__input::placeholder { color: var(--ink-3); }
.search__input::-webkit-search-cancel-button { display: none; }

.search__cancel {
    border: 0;
    background: none;
    color: var(--brass-ink);
    font-weight: 600;
    padding: 8px 4px;
    cursor: pointer;
}

.search__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 8px calc(16px + var(--safe-b));
}

.search__section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 10px 6px;
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
}
.search__section .icon { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; }
.search__clear {
    border: 0;
    background: none;
    color: var(--ink-3);
    font-size: 12px;
    cursor: pointer;
}

.result {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
}
.result[aria-selected="true"] { background: var(--brass-soft); }
.result__code { font-family: var(--font-num); font-weight: 600; font-size: 15px; }
.result__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result__meta { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.result mark { background: none; color: var(--brass-ink); }

.search__none {
    padding: 40px 16px;
    color: var(--ink-3);
    text-align: center;
}

.search__foot { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ---- Toast -------------------------------------------------------------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
    z-index: 70;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--bg);
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-pop);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- Page-load reveal --------------------------------------------------- */
.reveal { animation: reveal .5s var(--ease) both; }
.stock__main .reveal:nth-child(1) { animation-delay: .06s; }
.stock__main .reveal:nth-child(2) { animation-delay: .12s; }
.stock__main .reveal:nth-child(3) { animation-delay: .18s; }
.stock__side .reveal:nth-child(1) { animation-delay: .1s; }
.stock__side .reveal:nth-child(2) { animation-delay: .16s; }
.stock__side .reveal:nth-child(3) { animation-delay: .22s; }

@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }

/* ---- 持股紀錄 ------------------------------------------------------------ */
.tradeform__body { display: grid; gap: 14px; padding: 16px; }
.tradeform__side { justify-self: start; }
.tradeform__side button { min-width: 72px; height: 34px; font-size: 14px; }
.tradeform__side button[data-side="buy"][aria-selected="true"] { color: var(--up); }
.tradeform__side button[data-side="sell"][aria-selected="true"] { color: var(--down); }
.tradeform__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tradeform__row:has(.field--unit) { grid-template-columns: 1fr 76px 1fr; }
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.field input, .field select {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 500 16px var(--font-ui);
}
.field input[type="number"] { font-family: var(--font-num); }
.field input:focus, .field select:focus { outline: 2px solid var(--brass); outline-offset: -1px; }
.field__hint { color: var(--ink-3); font-size: 12px; }
.tradeform__total { color: var(--ink-2); font-size: 13px; min-height: 18px; }
.tradeform__error { padding: 10px 12px; border-radius: var(--r-sm); background: var(--up-soft); color: var(--up); font-size: 13px; }
.tradeform__foot {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px calc(12px + var(--safe-b));
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.timeline li { position: relative; display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; padding: 12px 0; }
.timeline li + li { border-top: 1px solid var(--line); }
.timeline__date { color: var(--ink-3); font-size: 12px; padding-top: 2px; }
.timeline__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.timeline__head .badge { margin: 0; }
.timeline__detail { color: var(--ink-2); font-size: 13px; }
.timeline__meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 4px; color: var(--ink-2); font-size: 12px; }
.timeline__after { color: var(--ink-3); }
.timeline__note { margin-top: 4px; color: var(--ink-3); font-size: 12px; }
.timeline__item--buy .timeline__head strong { color: var(--up); }
.timeline__item--sell .timeline__head strong { color: var(--down); }
.timeline__item--dividend .timeline__head strong,
.timeline__item--capitalreduction .timeline__head strong,
.timeline__item--split .timeline__head strong { color: var(--brass-ink); }
.timeline__delete { width: 32px; height: 32px; color: var(--ink-3); }
.timeline__delete:hover { background: var(--up-soft); color: var(--up); }
.timeline__delete .icon { width: 16px; height: 16px; }
.pagehead__title .code { font-size: 15px; font-weight: 400; }
.pro-mark { margin-left: 4px; padding: 1px 5px; border-radius: 6px; background: var(--brass-soft); color: var(--brass-ink); font-size: 10px; font-weight: 700; vertical-align: 2px; }

/* ---- 小工具庫（新增與設定小工具） ---------------------------------------- */
.sheet__head .wlib__back + .sheet__title { margin-right: auto; margin-left: 4px; }
.icon--flip { transform: scaleX(-1); }
.wlib__pane { padding: 12px 16px calc(16px + var(--safe-b)); }
.wlib__pane[data-pane="config"] { padding-bottom: 0; }
.wlib__intro { color: var(--ink-3); font-size: 13px; }
.wlib__group + .wlib__group { margin-top: 16px; }
.wlib__grouptitle { margin: 14px 0 8px; color: var(--ink-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.wcards { display: grid; gap: 8px; }
.wcard {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.wcard:hover { border-color: var(--brass); }
.wcard.is-added { background: var(--surface-2); }
.wcard__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--brass-soft); color: var(--brass-ink); }
.wcard__icon .icon { width: 22px; height: 22px; }
.wcard__body { display: grid; gap: 2px; min-width: 0; }
.wcard__title { font-weight: 600; }
.wcard__desc { color: var(--ink-3); font-size: 12px; line-height: 1.45; }
.wcard__state { color: var(--brass-ink); font-size: 12px; font-weight: 600; white-space: nowrap; }
.wcard__state .icon { width: 18px; height: 18px; }

.wlib__config { display: grid; gap: 16px; }
.wlib__form { display: grid; gap: 14px; }
.wlib__row { display: grid; gap: 6px; }
.wlib__row--inline { grid-template-columns: 1fr auto; align-items: center; }
.wlib__label { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.wlib__seg { display: flex; flex-wrap: wrap; justify-self: start; }
.wlib__seg button { min-width: 56px; height: 32px; }
.wlib__form select {
    justify-self: start;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 500 15px var(--font-ui);
}
.wlib__none { color: var(--ink-3); font-size: 13px; }

.switch {
    position: relative;
    width: 44px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: var(--line-strong);
    cursor: pointer;
    transition: background .18s var(--ease);
}
.switch span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    transition: transform .18s var(--ease);
}
.switch[aria-checked="true"] { background: var(--brass); }
.switch[aria-checked="true"] span { transform: translateX(18px); }

.wlib__previewlabel { margin-bottom: 6px; color: var(--ink-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.wpreview { min-height: 120px; padding: 10px; border-radius: var(--r); background: var(--bg); transition: opacity .15s var(--ease); }
.wpreview.is-loading { opacity: .5; }
.wpreview .widget { margin: 0; animation: none; pointer-events: none; }
.wlib__foot {
    position: sticky;
    bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px -16px 0;
    padding: 12px 16px calc(12px + var(--safe-b));
    background: var(--surface);
    border-top: 1px solid var(--line);
}
.wlib__hint { flex: 1; color: var(--ink-3); font-size: 12px; }
.wlib__foot .btn { margin-left: auto; }

/* ---- 小工具內的圖表 ------------------------------------------------------ */
.market__chart { min-width: 0; }
.mchart { position: relative; height: 200px; margin: 0 -4px; }
.mchart .skeleton { height: 100%; }
.mchart__legend { margin-top: 4px; }

.hbars { display: grid; gap: 2px; }
.hbars__row { display: grid; grid-template-columns: minmax(64px, 7em) 1fr 64px; align-items: center; gap: 10px; padding: 6px 0; }
.hbars__name { overflow: hidden; font-weight: 600; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.hbars__track { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.hbars__bar { position: absolute; top: 0; bottom: 0; left: 0; width: var(--w); border-radius: 999px; }
.hbars--diverging .hbars__bar { left: 50%; width: calc(var(--w) / 2); }
.hbars--diverging .hbars__bar.is-neg { left: auto; right: 50%; }
.hbars__value { text-align: right; font-size: 13px; font-weight: 600; }
.hbars__row:hover .hbars__name { color: var(--brass-ink); }

/* 文字雲：伺服器排好位置的 SVG，紅綠 = 相關個股漲跌，灰階 = 只依提及次數 */
.wordcloud { display: block; width: 100%; height: auto; max-height: 420px; margin: 4px 0 2px; }
.wordcloud text { font-family: var(--font-ui); font-weight: 700; text-anchor: middle; dominant-baseline: central; transition: opacity .15s var(--ease); }
.wordcloud .up { fill: var(--up); }
.wordcloud .down { fill: var(--down); }
.wordcloud .flat, .wordcloud .t1 { fill: var(--ink); }
.wordcloud .t2 { fill: var(--ink-2); }
.wordcloud .t3 { fill: var(--ink-3); }
.wordcloud a:hover text { opacity: .6; }
.legendkey .up-bg, .legendkey .down-bg { width: 10px; height: 10px; border-radius: 3px; }

/* 小工具上的切換按鈕（例如期間），換內容時淡出 */
.wswitch { margin-bottom: 8px; }
.widget.is-switching .widget__body { opacity: .5; transition: opacity .15s var(--ease); }

/* 編輯模式：右邊緣拖拉調整寬度（手機單欄，不顯示） */
.wresize { display: none; }

.pfsum { display: grid; gap: 10px; margin-bottom: 8px; }
.pfsum__label { display: block; color: var(--ink-3); font-size: 12px; }
.pfsum__value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.pfsum__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pfsum__stats dt { color: var(--ink-3); font-size: 12px; }
.pfsum__stats dd { font-size: 15px; font-weight: 600; }
.pfsum__stats small { display: block; font-size: 11px; font-weight: 500; }

@media (min-width: 768px) {
    .sheet.sheet--wide { max-width: 760px; }
    .wcards { grid-template-columns: 1fr 1fr; }
    .wlib__config { grid-template-columns: 260px 1fr; align-items: start; }
    .wlib__preview { position: sticky; top: 64px; }
    .widget--l .mchart { height: 240px; }

    .widgets.is-editing .wresize {
        position: absolute;
        top: 50%;
        right: -7px;
        z-index: 2;
        display: grid;
        place-items: center;
        width: 14px;
        height: 56px;
        padding: 0;
        border: 1px solid var(--line-strong);
        border-radius: 999px;
        background: var(--surface);
        cursor: ew-resize;
        touch-action: none;
        transform: translateY(-50%);
    }
    .widgets.is-editing .wresize::before { content: ""; width: 2px; height: 22px; border-radius: 2px; background: var(--ink-3); }
    .widgets.is-editing .wresize:hover, .widget.is-resizing .wresize { border-color: var(--brass); }
    .widgets.is-editing .wresize:hover::before, .widget.is-resizing .wresize::before { background: var(--brass); }
    .wresize__label {
        position: absolute;
        right: 20px;
        padding: 2px 8px;
        border-radius: 6px;
        background: var(--ink);
        color: var(--surface);
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity .15s var(--ease);
    }
    .widget.is-resizing .wresize__label, .wresize:focus-visible .wresize__label { opacity: 1; }
    .widgets.is-editing .widget.is-resizing { outline-color: var(--brass); }
    /* 預覽框只有半個面板寬，大尺寸也用手機的單欄排版，才不會把圖擠扁 */
    .wpreview .widget--l .market { grid-template-columns: 1fr; }
    .wpreview .widget--l .breadth__nums { grid-template-columns: repeat(3, 1fr); }
    .wpreview .widget--l .mchart { height: 200px; }
}

/* ---- Pro 結帳、我的帳號、付款結果 --------------------------------------- */
.btn--danger { border-color: var(--up); background: transparent; color: var(--up); }
.btn--danger:hover { background: var(--up-soft); }
.badge--pro { background: var(--brass-soft); color: var(--brass-ink); font-weight: 700; }

.callout { padding: 12px 14px; border-radius: var(--r); background: var(--brass-soft); color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.callout--warn { background: var(--up-soft); color: var(--up); margin-bottom: 12px; }

.checkout { max-width: 560px; margin: 0 auto; }
.checkout__card { display: grid; gap: 16px; }
.checkout__plan { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.checkout__name { font-size: 18px; font-weight: 700; }
.checkout__desc { color: var(--ink-3); font-size: 13px; }
.checkout__price { white-space: nowrap; }
.checkout__price .num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.checkout__price small { color: var(--ink-3); }
.checkout__list { display: grid; gap: 8px; }
.checkout__list li { position: relative; padding-left: 22px; }
.checkout__list li::before { content: "✓"; position: absolute; left: 0; color: var(--brass-ink); font-weight: 700; }
.checkout__pay { width: 100%; min-height: 48px; font-size: 16px; }
.checkout__error { color: var(--up); font-size: 13px; }
.checkout__notes { display: grid; gap: 4px; color: var(--ink-3); font-size: 12px; line-height: 1.6; }

.account { display: grid; gap: 12px; }
.account__plan { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; }
.account__text { color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.account__facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.account__facts dt { color: var(--ink-3); font-size: 12px; }
.account__facts dd { font-size: 15px; font-weight: 600; }
.account .btn { justify-self: start; }
.account__cancel summary { color: var(--ink-3); font-size: 13px; cursor: pointer; }
.account__cancel[open] { display: grid; gap: 10px; }
.account__cancel p { color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.account__error { color: var(--up); font-size: 13px; }
.account__row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; }
.account__links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.account__links a { display: flex; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); font-weight: 600; }
.account__links a:hover { border-color: var(--brass); }
.account__links .icon { color: var(--brass-ink); }
.account__logout { margin-top: 12px; text-align: center; }

/* 登入、註冊、忘記密碼、變更密碼（Areas/Public/Views/Account） */
.signin { display: grid; gap: 12px; max-width: 420px; margin: 24px auto; padding: 28px 24px; }
.signin__title { font-size: 22px; font-weight: 600; }
.signin__text { color: var(--ink-2); font-size: 14px; }
.signin__perks { display: grid; gap: 6px; padding-left: 4px; color: var(--ink-2); font-size: 14px; }
.signin__perks li { display: flex; gap: 8px; }
.signin__perks li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: .55em; border-radius: 50%; background: var(--brass); }
.signin__error { padding: 10px 12px; border-radius: var(--r-sm); background: var(--up-soft); color: var(--up); font-size: 13px; }
.signin__error p + p { margin-top: 4px; }
.signin__notice { padding: 10px 12px; border-radius: var(--r-sm); background: var(--brass-soft); color: var(--ink); font-size: 13px; line-height: 1.6; }
.signin__form { display: grid; gap: 12px; margin-top: 8px; }
.signin__submit { width: 100%; margin-top: 4px; }
.signin__links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--ink-3); font-size: 13px; }
.signin__links a { color: var(--brass-ink); font-weight: 600; }
.signin__google { width: 100%; }
.signin__google img { flex: none; }
.signin__note { color: var(--ink-3); font-size: 13px; text-align: center; }
.signin__legal { padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; line-height: 1.6; }
.signin__legal a { color: var(--brass-ink); font-weight: 600; }

.emptypage__icon--ok, .emptypage .emptypage__icon:not(svg) { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--brass-soft); color: var(--brass-ink); font-size: 22px; font-weight: 700; }
.emptypage__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }

/* ---- 個股頁的 Pro 捷徑、新聞頁文字雲 ------------------------------------ */
.hero__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.holding .stats small { margin-left: 4px; font-size: 12px; }
.newscloud .wordcloud { max-height: 520px; }
/* 關鍵字側頁（kwsheet.js）、持股側頁（possheet.js）：沿用個股側頁，比較窄；在個股側頁下面一層，點股票疊上去 */
.ssheet--kw, .ssheet--pos { z-index: 49; }
.ssheet__title { flex: 1; min-width: 0; overflow: hidden; font-size: 15px; font-weight: 600; text-align: center; white-space: nowrap; text-overflow: ellipsis; }
.kwsheet__range { margin-left: 8px; color: var(--ink-3); font-size: 12px; font-weight: 400; }
@media (min-width: 768px) {
    .ssheet--kw .ssheet__panel, .ssheet--pos .ssheet__panel { width: min(560px, calc(100% - 32px)); }
    .ssheet--kw .ssheet__title, .ssheet--pos .ssheet__title { text-align: left; }
    .ssheet--kw .ssheet__body, .ssheet--pos .ssheet__body { padding: 20px 24px 48px; }
}

.newscloud { margin-bottom: 12px; }
.newscloud > summary { margin-bottom: 0; cursor: pointer; list-style: none; }
.newscloud > summary::-webkit-details-marker { display: none; }
.newscloud[open] > summary { margin-bottom: 12px; }
.newscloud > summary .icon { transform: rotate(90deg); transition: transform .2s var(--ease); }
.newscloud[open] > summary .icon { transform: rotate(-90deg); }
.newscloud[open] .newscloud__open, .newscloud:not([open]) .newscloud__close { display: none; }
.kwstats { margin-bottom: 8px; }
.kwnote { margin: 0 0 4px; }
.news__title mark { background: none; color: var(--brass-ink); font-weight: 600; }
@media (min-width: 768px) {
    .kwstats { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
    .newscloud { margin-bottom: 20px; }
}
/* 新聞頁選了關鍵字：手機上明細排在關鍵字清單前面 */
@media (max-width: 1023px) {
    .split--detail-first > .split__main { order: -1; }
}

/* ---- 自選分組 ------------------------------------------------------------ */
.wgroups { display: flex; gap: 6px; margin: 0 calc(var(--gutter) * -1) 12px; padding: 2px var(--gutter); overflow-x: auto; scrollbar-width: none; }
.wgroups::-webkit-scrollbar { display: none; }
.wgroups .chipbtn { display: inline-flex; flex: none; align-items: center; gap: 6px; }
.wgroups .chipbtn small { color: var(--ink-3); font-size: 11px; font-weight: 600; }
.wgroups .chipbtn--on small { color: inherit; }
.chipbtn--ghost { border-style: dashed; color: var(--ink-3); }
.chipbtn--ghost .icon { width: 14px; height: 14px; }
.wgroups--widget { margin: 0 -16px 6px; padding: 2px 16px; }
.wgroups--widget .chipbtn { height: 28px; padding: 0 10px; font-size: 12px; }
.gdot { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--line-strong)); }

.quotes__row:has(.quotes__group) { grid-template-columns: 1fr auto auto; }
.quotes__group {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 96px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.quotes__group span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.quotes__group:hover { border-color: var(--brass); color: var(--brass-ink); }
/* 手機一列放不下名稱、股價、漲跌、分組、移除：分組只留顏色點，名稱寫在按鈕的 aria-label 裡 */
@media (max-width: 520px) {
    .quotes__group { justify-content: center; width: 30px; padding: 0; }
    .quotes__group span:last-child { display: none; }
    .quotes__group .gdot { width: 10px; height: 10px; }
    .quotes__row:has(.quotes__group) { gap: 2px; }
}

.gmove { padding: 8px 8px calc(16px + var(--safe-b)); }
.gmove li + li { border-top: 1px solid var(--line); }
.gmove button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 13px 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.gmove button:hover { background: var(--brass-soft); }
.gmove button[aria-pressed="true"]::after { content: "✓"; margin-left: auto; color: var(--brass-ink); }
.gmove .gdot { width: 11px; height: 11px; }
.gmove__new { color: var(--brass-ink) !important; }
.gmove__new .icon { width: 16px; height: 16px; }

.gmanage { display: grid; gap: 12px; padding: 12px 16px calc(16px + var(--safe-b)); }
.gmanage__list li { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 4px; padding: 6px 0; }
.gmanage__list li + li { border-top: 1px solid var(--line); }
.gmanage__list input, .gmanage__add input {
    width: 100%;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 500 15px var(--font-ui);
}
.gmanage__color { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 999px; background: none; cursor: pointer; }
.gmanage__color .gdot { width: 16px; height: 16px; }
.gmanage__color:hover { background: var(--surface-2); }
.gmanage__list .iconbtn { width: 34px; height: 34px; }
.gmanage__list .iconbtn:disabled { opacity: .3; cursor: default; }
.icon--up { transform: rotate(-90deg); }
.icon--down { transform: rotate(90deg); }
.gmanage__delete:hover { color: var(--up); }
.gmanage__add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.gmanage__note { color: var(--ink-3); font-size: 12px; }

/* ---- 個股頁：報價旁的新聞關鍵字 ------------------------------------------- */
.hero__body { display: grid; gap: 16px; }

.kw { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.kw__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.kw__title { color: var(--ink-2); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.seg--sm { padding: 2px; border-radius: 9px; }
.seg--sm button { min-width: 0; height: 26px; padding: 0 10px; border-radius: 7px; font-size: 12px; }
.kw__body {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 6px;
    max-height: 100px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    transition: opacity .15s var(--ease);
}
.kw__body.is-loading { opacity: .45; }
.kw__empty { color: var(--ink-3); font-size: 13px; }
.kwchip {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    height: 26px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 13px;
    line-height: 24px;
    white-space: nowrap;
}
.kwchip small { color: var(--ink-3); font-size: 11px; }
.kwchip:hover { border-color: var(--brass); color: var(--ink); }
.kwchip--c, .kwchip--g, .kwchip--b { border-color: transparent; font-weight: 600; }
.kwchip--c { background: var(--hot-soft); color: var(--hot-ink); }
.kwchip--g { background: var(--up-soft); color: var(--up); }
.kwchip--b { background: linear-gradient(135deg, var(--hot-soft) 50%, var(--up-soft) 50%); color: var(--up); }
.kwchip--c small, .kwchip--g small, .kwchip--b small { color: inherit; opacity: .75; }
.kw__legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; color: var(--ink-3); font-size: 11px; }
.kw__legend span { display: inline-flex; align-items: center; gap: 5px; }
.kwdot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.kwdot--c { background: var(--hot-soft); box-shadow: inset 0 0 0 1px var(--hot-ink); }
.kwdot--g { background: var(--up-soft); box-shadow: inset 0 0 0 1px var(--up); }

@media (min-width: 1024px) {
    .hero__body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
}

/* ---- 個股側頁：從右側推入（sheet.js） --------------------------------------- */
.has-sheet, .has-sheet body, .has-kwsheet, .has-kwsheet body, .has-possheet, .has-possheet body { overflow: hidden; }

.ssheet { position: fixed; inset: 0; z-index: 50; }
.ssheet__backdrop { position: absolute; inset: 0; background: rgba(13, 14, 16, .45); opacity: 0; transition: opacity .3s var(--ease); }
.ssheet__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--bg);
    box-shadow: var(--shadow-pop);
    transform: translateX(100%);
    transition: transform .32s var(--ease);
}
.ssheet.is-open .ssheet__backdrop { opacity: 1; }
.ssheet.is-open .ssheet__panel { transform: none; }

.ssheet__bar {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: env(safe-area-inset-top, 0px) 8px 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.ssheet__close .icon--back { transform: rotate(180deg); }
.ssheet__close .icon--x { display: none; }
.ssheet__nav { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.ssheet__nav .icon--back { transform: rotate(180deg); }
.ssheet__nav .iconbtn:disabled { opacity: .3; cursor: default; }
.ssheet__nav .iconbtn:disabled:hover { background: none; }
.ssheet__pos { min-width: 64px; color: var(--ink-2); font-size: 13px; text-align: center; }
.ssheet.is-single .ssheet__nav { visibility: hidden; }
.ssheet__keys { display: none; }
.ssheet__full { display: none; }
/* 左邊關閉鈕與右邊同寬，讓中間的切換鈕置中 */
.ssheet__bar::after { content: ""; flex: none; width: 40px; }

.ssheet__body {
    flex: 1;
    min-height: 0;
    padding: 16px var(--gutter) calc(32px + var(--safe-b));
    overflow-y: auto;
    overscroll-behavior: contain;
    outline: none;
    -webkit-overflow-scrolling: touch;
}
.ssheet__body > * { transition: opacity .15s var(--ease); }
.ssheet__body.is-loading > * { opacity: .45; }
.ssheet .reveal { animation: none; }
.ssheet .stock__side { top: 0; }
.ssheet .stock.is-from-next { animation: sheet-next .26s var(--ease); }
.ssheet .stock.is-from-prev { animation: sheet-prev .26s var(--ease); }
@keyframes sheet-next { from { opacity: 0; transform: translateX(32px); } }
@keyframes sheet-prev { from { opacity: 0; transform: translateX(-32px); } }

/* 側頁的抬頭只留名稱、報價、按鈕一列，K 線直接接在下面 */
.hero--sheet { padding: 0 0 14px; }
.hero--sheet .hero__top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "id actions" "quote quote";
    align-items: center;
    gap: 10px 12px;
}
.hero--sheet .hero__id { grid-area: id; }
.hero--sheet .hero__actions { grid-area: actions; }
.hero--sheet .hero__name { font-size: 22px; }
.hero--sheet .hero__meta { margin-top: 4px; }
.quote--sheet { grid-area: quote; align-items: baseline; gap: 4px 10px; margin: 0; }
.quote--sheet .quote__price { font-size: 32px; }
.quote--sheet .asof { margin: 0; font-size: 12px; }

/* 手機：EPS 原本擠在名稱和按鈕中間的窄欄、一年一行；改成整列，年份疊在數字上面，兩行就放完 */
@media (max-width: 767px) {
    .hero__top { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name actions" "meta actions" "eps eps"; column-gap: 12px; }
    .hero--sheet .hero__top { grid-template-areas: "name actions" "meta actions" "eps eps" "quote quote"; gap: 0 12px; }
    .hero__id { display: contents; }
    .hero__name { grid-area: name; }
    .hero__meta { grid-area: meta; }
    .hero__actions { grid-area: actions; align-self: start; }
    .heroeps { grid-area: eps; flex-wrap: nowrap; align-items: last baseline; gap: 0 14px; margin-top: 10px; }
    .heroeps__item { flex-direction: column; align-items: flex-end; gap: 0; line-height: 1.3; }
    .hero--sheet .quote--sheet { margin-top: 10px; }
}

/* 手機與平板：K 線第一、關鍵字（與持股）第二，其餘照原順序 */
@media (max-width: 1023px) {
    .ssheet .stock__grid { display: flex; flex-direction: column; gap: 12px; }
    .ssheet .stock__main, .ssheet .stock__side { display: contents; }
    .ssheet .stock__grid .card + .card { margin-top: 0; }
    .ssheet .chartcard { order: -2; }
    .ssheet .stock__side > .kw, .ssheet .stock__side > .holding { order: -1; }
}
.ssheet .stock__side > .kw { margin-bottom: 20px; }

.ssheet__skeleton { display: grid; gap: 14px; }
.ssheet__skeleton .skeleton { position: relative; }
.skeleton--title { width: 40%; height: 32px; }
.skeleton--price { width: 60%; height: 56px; }
.skeleton--chart { height: 320px; }

@media (min-width: 768px) {
    .ssheet__panel { width: min(1480px, calc(100% - 32px)); border-left: 1px solid var(--line); }
    .ssheet__bar { padding: 0 16px; }
    .ssheet__bar::after { display: none; }
    .ssheet__close .icon--back { display: none; }
    .ssheet__close .icon--x { display: block; }
    .ssheet__nav { margin: 0; }
    .ssheet__keys { display: flex; align-items: center; gap: 12px; margin: 0 auto 0 8px; color: var(--ink-3); font-size: 12px; }
    .ssheet__keys kbd { min-width: 20px; padding: 1px 5px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-2); font: 600 11px var(--font-num); text-align: center; }
    .ssheet__keystep { display: inline-flex; align-items: center; gap: 4px; }
    .ssheet.is-single .ssheet__keystep { display: none; }
    .ssheet__key { display: inline-flex; align-items: center; gap: 4px; padding: 2px; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; cursor: pointer; }
    .ssheet__key:hover { color: var(--ink); }
    .ssheet__key:hover kbd { border-color: var(--brass); color: var(--ink); }
    .ssheet__key:active kbd { transform: translateY(1px); }
    .ssheet__full { display: inline-flex; align-items: center; height: 32px; margin-left: auto; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
    .ssheet__keys + .ssheet__full { margin-left: 0; }
    .ssheet__full:hover { border-color: var(--brass); color: var(--ink); }
    .ssheet__body { padding: 20px 28px 48px; }

    .hero--sheet .hero__top { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "id quote actions"; gap: 12px 28px; }
    .quote--sheet .quote__price { font-size: 36px; }
    /* K 線填滿側頁剩下的高度，打開不用捲就看到整張圖 */
    .ssheet .chart { height: clamp(340px, calc(100dvh - 330px), 640px); }
    .ssheet .stock__side .kw__body { max-height: 200px; }
}

/* ---- 排行類小工具的列（Widgets/_Rows.cshtml、home.js rowHtml）---------------- */
.qrows li + li { border-top: 1px solid var(--line); }
.qrows a, .quotes a.qrow { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 7px 0; }
.qrows a:hover .qrow__name, .quotes a.qrow:hover .qrow__name { color: var(--brass-ink); }
/* 自選頁：價格與漲跌包在一起，窄螢幕改成上下疊 */
.qrow__quote { display: flex; flex: none; align-items: center; gap: 10px; }
.qrow__no { flex: none; width: 18px; color: var(--ink-3); font-size: 12px; font-weight: 600; text-align: center; }
.qrow__no:empty { display: none; }
.qrows li:nth-child(-n+3) .qrow__no { color: var(--brass-ink); }
.qrow__id { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.qrow__name { display: flex; align-items: center; min-width: 0; font-weight: 600; white-space: nowrap; }
.qrow__name > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.qrow__sub { overflow: hidden; color: var(--ink-3); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.qrow__sub .code { color: inherit; font-size: 12px; }
.qtag { flex: none; margin-left: 6px; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 17px; }
.qtag--up { background: var(--up-soft); color: var(--up); }
.qtag--down { background: var(--down-soft); color: var(--down); }
.spark { flex: none; width: 56px; height: 24px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark--up polyline { stroke: var(--up); }
.spark--down polyline { stroke: var(--down); }
.qrow__val { flex: none; min-width: 64px; font-weight: 600; text-align: right; }
.qrow__val small { margin-left: 2px; color: var(--ink-3); font-family: var(--font-ui); font-size: 11px; font-weight: 400; }
.qrows .pill { flex: none; min-width: 62px; }
.widget .wswitch { display: flex; }
.widget .wswitch button { flex: 1; }
.pill--limit { font-family: var(--font-ui); letter-spacing: .1em; }
.pill--limit.up { background: var(--up); color: #fff; }
.pill--limit.down { background: var(--down); color: #fff; }

/* 第一名放大：名稱與標籤一列，下面是寬的走勢圖與大字價格 */
.qrows--top li:first-child a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "no id pill" "no spark val";
    align-items: center;
    gap: 8px 12px;
    margin: 2px 0 6px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-2);
}
.qrows--top li:first-child + li { border-top: 0; }
.qrows--top li:first-child .qrow__no { grid-area: no; align-self: start; padding-top: 2px; font-size: 15px; }
.qrows--top li:first-child .qrow__id { grid-area: id; }
.qrows--top li:first-child .qrow__name { font-size: 17px; }
.qrows--top li:first-child .pill { grid-area: pill; }
.qrows--top li:first-child .spark { grid-area: spark; width: 100%; height: 40px; }
.qrows--top li:first-child .qrow__val { grid-area: val; align-self: end; font-size: 22px; line-height: 1; }

@media (max-width: 400px) {
    .qrows a { gap: 8px; }
    .spark { width: 44px; }
}
@media (max-width: 520px) {
    .qrow__quote { flex-direction: column; align-items: flex-end; gap: 3px; min-width: 76px; }
    .qrow__quote .pill { min-width: 58px; height: 20px; font-size: 12px; }
}
@media (min-width: 768px) {
    .spark { width: 72px; }
}

/* 表格（排行、產業、漲停、選股池）：名稱欄帶連續漲跌停標籤、桌機另起一行顯示產業；近 20 日走勢小圖一欄 */
.dtable__meta { display: inline-flex; align-items: center; gap: 4px; }
.dtable__meta .qtag { margin-left: 2px; }
.dtable__sub { display: none; color: var(--ink-3); font-size: 12px; font-weight: 400; }
th.dtable__spark { width: 56px; }
.dtable .spark { display: block; width: 52px; height: 22px; margin-left: auto; }
@media (min-width: 768px) {
    .dtable__sub { display: block; margin-top: 2px; }
    th.dtable__spark { width: 104px; }
    .dtable .spark { width: 96px; height: 26px; }
}

/* ---- 選股池：訊號條件（期間、常用參數、自訂參數）------------------------------- */
.cond__presets { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.cond__params { display: flex; flex-wrap: wrap; gap: 8px 14px; flex-basis: 100%; }
.cond__param { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.cond__param input { width: 76px; }
.cond__error { flex-basis: 100%; color: var(--up); font-size: 12px; }

/* ---- 公開訊號頁（/signals）---------------------------------------------------- */
/* 篩選換內容不換頁（app.js initSwap）：載入中淡出，換好後不再播進場動畫 */
[data-swap] { transition: opacity .15s var(--ease); }
[data-swap].is-swapping { opacity: .55; pointer-events: none; }
[data-swap].is-swapped .reveal { animation: none; }

.sigfilters { display: grid; gap: 0; margin-bottom: 4px; }
.sigfilters .chips { flex-wrap: wrap; margin-bottom: 8px; }

.sigsplit { display: grid; gap: 12px; margin-bottom: 12px; }
.sigsplit .card + .card { margin-top: 0; }

.sigbars {
    display: grid;
    grid-template-columns: repeat(var(--n, 21), minmax(0, 1fr));
    align-items: end;
    gap: 3px;
    height: 132px;
}
.sigbars li, .sigbars > span { display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; height: 100%; min-width: 0; }
.sigbars__bar { display: block; height: var(--h, 0%); min-height: 2px; border-radius: 3px 3px 1px 1px; background: var(--brass-soft); }
.sigbars .is-latest .sigbars__bar { background: var(--brass); }
.sigbars__n { min-height: 14px; color: var(--ink-2); font-size: 10px; text-align: center; line-height: 14px; }
.sigbars__date { min-height: 12px; color: var(--ink-3); font-size: 10px; text-align: center; line-height: 12px; white-space: nowrap; overflow: visible; }
.sigbars--mini { height: 40px; gap: 2px; }

/* 訊號頁的統計列：依項目數排欄，不留空格 */
.statline--2, .statline--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) {
    .statline--3 { grid-template-columns: repeat(3, 1fr); }
    .statline--4 { grid-template-columns: repeat(4, 1fr); }
}
.statline__ref { color: var(--ink-3); font-size: 12px; }
.statline__ref b { font-weight: 600; }

/* 首頁「今日訊號」小工具 */
.sigrows li + li { border-top: 1px solid var(--line); }
.sigrows a { display: grid; grid-template-columns: minmax(0, 1fr) 72px 44px 44px; align-items: center; gap: 10px; min-height: 54px; padding: 7px 0; }
.sigrows a:hover strong { color: var(--brass-ink); }
.sigrows__id { display: grid; min-width: 0; }
.sigrows__id strong { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.sigrows__id small { overflow: hidden; color: var(--ink-3); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.sigrows .sigbars--mini { height: 28px; gap: 1px; }
.sigrows__num { display: grid; justify-items: end; }
.sigrows__num b { font-size: 17px; font-weight: 600; line-height: 1.1; }
.sigrows__num small { color: var(--ink-3); font-size: 11px; }

.sigind { display: grid; gap: 8px; }
.sigind li { display: grid; grid-template-columns: minmax(84px, auto) 1fr 32px; align-items: center; gap: 10px; font-size: 13px; }
.sigind__bar { display: block; width: var(--w, 0%); height: 10px; border-radius: 5px; background: var(--brass-soft); }
.sigind li:first-child .sigind__bar { background: var(--brass); }
.sigind .num { text-align: right; color: var(--ink-2); }

.sigcta { display: grid; gap: 12px; align-items: center; margin-top: 12px; }
.sigcta p { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.sigcta .btn { justify-self: start; }

.sigcards { display: grid; gap: 12px; }
.sigcard {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color .2s var(--ease);
}
.sigcard:hover { border-color: var(--brass); }
.sigcard__head strong { display: block; font-size: 17px; font-weight: 600; }
.sigcard__head small { color: var(--ink-3); font-size: 12px; }
.sigcard__nums { display: flex; gap: 22px; }
.sigcard__nums span { display: grid; }
.sigcard__nums b { font-size: 26px; font-weight: 600; line-height: 1.1; }
.sigcard__nums small { color: var(--ink-3); font-size: 12px; }
.sigcard__intro { color: var(--ink-2); font-size: 13px; line-height: 1.5; }

@media (min-width: 768px) {
    .sigsplit { grid-template-columns: 3fr 2fr; gap: 20px; margin-bottom: 20px; }
    .sigcards { grid-template-columns: 1fr 1fr; gap: 20px; }
    .sigcta { grid-template-columns: 1fr auto; }
    .sigcta .btn { justify-self: end; }
}

/* admin 的免費會員視角提醒（_ViewModeBar） */
.viewmodebar { margin-bottom: 12px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--hot-soft); color: var(--hot-ink); font-size: 13px; font-weight: 600; }
.viewmodebar a { text-decoration: underline; }

/* ---- 意見回饋（/feedback）------------------------------------------------------ */
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font: 500 15px/1.6 var(--font-ui);
    resize: vertical;
}
.field textarea:focus { outline: 2px solid var(--brass); outline-offset: -1px; }
.field input[type="file"] { height: auto; padding: 10px 12px; font-size: 14px; }

.feedbackpage { max-width: 720px; }
.feedback { display: grid; gap: 12px; }
.feedback__form { display: grid; gap: 14px; }
.feedback__submit { justify-self: start; min-width: 120px; }
.feedback__list li { display: grid; gap: 2px; padding: 12px 0; border-top: 1px solid var(--line); }
.feedback__list li:first-child { border-top: 0; padding-top: 0; }
.feedback__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.feedback__meta { color: var(--ink-3); font-size: 12px; }
.feedback__status { background: var(--hot-soft); color: var(--hot-ink); }
.feedback__status.is-done { background: var(--flat-soft); color: var(--ink-2); }
.feedback__note { margin-top: 6px; padding: 8px 12px; border-left: 3px solid var(--brass); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--surface-2); color: var(--ink-2); font-size: 14px; white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-delay: 0s !important;
        transition-duration: .01ms !important;
    }
}

/* ---- Tablet & desktop --------------------------------------------------- */
@media (min-width: 768px) {
    :root { --gutter: 24px; --topbar-h: 64px; }

    body { padding-bottom: 0; }
    .tabbar { display: none; }
    .toast { bottom: 28px; }

    .brand img { width: 100px; }
    .searchbox { max-width: 420px; margin: 0 auto; }
    .searchbox__kbd { display: inline-grid; }

    .topnav {
        display: flex;
        gap: 4px;
    }
    .topnav a {
        display: inline-flex;
        align-items: center;
        height: 36px;
        padding: 0 12px;
        border-radius: 999px;
        color: var(--ink-2);
        font-weight: 600;
        font-size: 14px;
    }
    /* 選單圖示（沿用首頁小工具與手機下方列） */
    .topnav .icon { width: 16px; height: 16px; margin-right: 5px; color: var(--ink-3); }
    .topnav a.is-active .icon { color: var(--brass-ink); }
    .topnav a:hover { background: var(--brass-soft); }
    .topnav a.is-active { color: var(--ink); background: var(--brass-soft); }

    .page { padding-top: 28px; padding-bottom: 56px; }

    .hero { padding-bottom: 24px; }
    .hero__name { font-size: 32px; }
    .quote__price { font-size: 56px; }
    .ranges { grid-template-columns: 1fr 1fr; gap: 28px; max-width: 640px; }

    .card { padding: 20px; }
    .chart { height: 420px; }
    .chartsub__plot { height: 110px; }
    .chartsub:last-child .chartsub__plot { height: 136px; }

    .hide-sm { display: table-cell; }
    .show-sm { display: none; }
    .tabs { margin-left: 0; margin-right: 0; padding: 0; }
    .statline { grid-template-columns: repeat(5, 1fr); }
    .statline > div:last-child:nth-child(3n + 2) { grid-column: auto; }
    .dtable__name { flex-direction: row; align-items: baseline; gap: 6px; }
    .dtable__name .code { font-size: 13px; }
    .dtable { font-size: 14px; }
    .dtable td { padding: 11px 10px; }
    .dtable th { padding: 8px 10px; }

    .editor__bar { bottom: 0; }
    .editor__bar { left: 50%; right: auto; width: min(1200px, 100%); transform: translateX(-50%); border-radius: var(--r-lg) var(--r-lg) 0 0; }

    .pro__title { font-size: 40px; }
    .plans { grid-template-columns: 1fr 1fr; gap: 20px; }

    .homehead__title { font-size: 30px; }
    .widgets { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
    .widget { padding: 20px; }
    .widget--s { grid-column: span 4; }
    .widget--m { grid-column: span 6; }
    .widget--l { grid-column: span 12; }
    .widget--l .market { grid-template-columns: minmax(220px, 1fr) 2fr; align-items: center; column-gap: 28px; }
    .widget--l .market .breadth { grid-column: 1 / -1; }
    .widget--l .breadth__nums { grid-template-columns: repeat(6, 1fr); }

    .editbar { bottom: 0; }
    .sheet { max-width: 520px; margin: auto; border-radius: var(--r-lg); }

    .search__backdrop { background: rgba(13, 14, 16, .5); }
    .search__panel {
        inset: 10vh auto auto 50%;
        width: min(640px, calc(100% - 48px));
        max-height: 72vh;
        border: 1px solid var(--line);
        border-radius: var(--r-lg);
        background: var(--surface);
        box-shadow: var(--shadow-pop);
        transform: translateX(-50%);
        animation: drop .2s var(--ease);
        overflow: hidden;
    }
    .search__bar { padding: 12px 16px; }
    .search__cancel { display: none; }
    .search__body { padding-bottom: 8px; }
    .search__foot {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 10px 16px;
        border-top: 1px solid var(--line);
        background: var(--surface-2);
        color: var(--ink-3);
        font-size: 12px;
    }

    @keyframes drop { from { opacity: 0; transform: translate(-50%, -8px); } }
}

@media (min-width: 1024px) {
    .stock__grid {
        grid-template-columns: minmax(0, 1fr) 340px;
        gap: 20px;
        align-items: start;
    }
    .adslot--stock-side .adslot__box { min-height: 600px; }

    .split { grid-template-columns: 360px minmax(0, 1fr); gap: 20px; align-items: start; }
    .split__main { gap: 20px; }

    .stock__side {
        position: sticky;
        top: calc(var(--topbar-h) + 20px);
    }
    .card + .card { margin-top: 20px; }
}
