/* tvm-taba：暖灰底、襯線標題、紅色強調、深色色塊大卡。只做淺色模式 */

:root {
    --bg: #f0efeb;
    --bg-soft: #e7e5df;
    --ink: #1c1a17;
    --ink-soft: #46423c;
    --mute: #77726a;
    --rule: #d3cfc6;
    /* 強調色讀後台 Design & branding 的 Accent color，沒設定時用品牌紅 */
    --red: var(--ghost-accent-color, #d32f2f);
    --red-dark: color-mix(in srgb, var(--red) 85%, #000);
    --tone-ink: #2c211c;
    --tone-pine: #23443e;
    --tone-navy: #1f3550;
    --tone-wine: #5c2329;
    --tone-ochre: #6b4e1e;
    --tone-plum: #3d2b47;
    --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
    --sans: "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
    --wrap: 1200px;
    --gutter: clamp(16px, 4vw, 40px);
    --font-serif-alt: var(--serif);
    --color-primary-text: var(--ink);
    --color-secondary-text: var(--mute);
    --color-border: var(--rule);
    --color-light-gray: var(--bg-soft);
    --color-lighter-gray: var(--bg-soft);
    --color-mid-gray: var(--rule);
    --background-color: var(--bg);
}

html {
    background: var(--bg);
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.6rem;
}

a {
    color: inherit;
    text-decoration: none;
}

.gh-viewport {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: clip;
}

.gh-main {
    flex-grow: 1;
}

.tb-wrap {
    width: 100%;
    max-width: calc(var(--wrap) + var(--gutter) * 2);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.tb-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

/* ---------- 按鈕 ---------- */

.tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    font-family: var(--sans);
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--ink);
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.tb-btn.is-outline:hover {
    color: var(--bg);
    background: var(--ink);
}

.tb-btn.is-red {
    color: #fff;
    background: var(--red);
    border-color: var(--red);
}

.tb-btn.is-red:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}

.tb-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--ink);
    background: none;
    border: 0;
    cursor: pointer;
}

.tb-icon-btn svg {
    width: 20px;
    height: 20px;
}

.tb-grid-icon {
    width: 12px;
    height: 12px;
}

/* ---------- 頁首 ---------- */

.tb-header {
    position: relative;
    z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
}

/* 行情列：頁首最上方一條深色窄列，放不下時橫向捲動；漲跌照台灣習慣紅漲綠跌 */
.tb-ticker {
    background: var(--ink);
    color: #fff;
}

.tb-ticker[hidden] {
    display: none;
}

.tb-ticker-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 32px;
    overflow-x: auto;
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    scrollbar-width: none;
}

.tb-ticker-inner::-webkit-scrollbar {
    display: none;
}

/* 用 auto 外距置中，內容超寬時才不會把左邊切掉 */
.tb-tick:first-child {
    margin-left: auto;
}

.tb-tick:last-child {
    margin-right: auto;
}

.tb-tick {
    display: inline-flex;
    gap: 6px;
    color: inherit;
    text-decoration: none;
}

a.tb-tick:hover .tb-tick-label {
    text-decoration: underline;
}

.tb-tick-label {
    opacity: 0.7;
}

.tb-tick-pct.is-up {
    color: #ff7a70;
}

.tb-tick-pct.is-down {
    color: #5fd38d;
}

/* 桌機頁首固定在上方，捲過頁首後收成一列（tvm.js 加 is-compact）。
   用 fixed 加 body 預留完整頁首高度，收合時內容不會跳動；主題面板跟著頁首走，太高時面板內自己捲 */
@media (min-width: 768px) {
    html {
        scroll-padding-top: var(--tb-header-h, 120px);
    }

    body {
        padding-top: calc(var(--tb-ann-h, 0px) + var(--tb-header-full, 120px));
    }

    /* Ghost 公告列放在頁首上方，跟著頁面捲走；捲過公告列後頁首才貼到最上面（top 由 tvm.js 設定） */
    #announcement-bar-root {
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
    }

    .tb-header {
        position: fixed;
        top: var(--tb-header-top, 0px);
        right: 0;
        left: 0;
        transition: box-shadow 0.2s;
    }

    .tb-topics {
        max-height: calc(100vh - var(--tb-header-h, 120px));
        overflow-y: auto;
    }

    .tb-header.is-compact {
        box-shadow: 0 8px 20px -14px rgb(0 0 0 / 0.35);
    }

    .tb-header.is-compact .tb-ticker {
        display: none;
    }

    .tb-header.is-compact .tb-bar {
        grid-template-columns: auto auto 1fr;
        gap: 20px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .tb-header.is-compact .tb-logo img {
        width: 170px;
    }

    .tb-header.is-compact .tb-logo img.is-site-logo {
        width: auto;
        max-height: 28px;
    }

    /* 收合時選單疊在同一列正中間，寬度不夠就收起來，改用主題面板 */
    .tb-header.is-compact .tb-nav {
        display: none;
    }
}

@media (min-width: 1200px) {
    .tb-header.is-compact .tb-nav {
        position: absolute;
        top: 0;
        right: 0;
        left: 0;
        display: block;
        height: var(--tb-header-h, 60px);
        pointer-events: none;
    }

    .tb-header.is-compact .tb-nav .tb-wrap,
    .tb-header.is-compact .tb-nav .nav {
        height: 100%;
    }

    .tb-header.is-compact .tb-nav .nav {
        flex-wrap: nowrap;
        align-items: center;
        padding: 0;
    }

    .tb-header.is-compact .tb-nav a {
        pointer-events: auto;
    }
}

.tb-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding-top: 20px;
    padding-bottom: 12px;
}

.tb-bar-left {
    display: flex;
    gap: 10px;
}

.tb-logo img {
    width: clamp(220px, 24vw, 320px);
    height: auto;
}

/* 後台上傳的 Publication logo 比例不固定，改用高度限制 */
.tb-logo img.is-site-logo {
    width: auto;
    max-width: clamp(220px, 24vw, 320px);
    max-height: 56px;
}

.tb-bar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* 國際站：連到英文國際站，不是語系切換 */
.tb-intl {
    padding: 0 6px;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.tb-intl:hover {
    color: var(--ink);
}

.tb-members {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 正式站注入的 EN 切換鈕 */
.tb-members .tvm-lang {
    margin-right: 4px;
    font-size: 1.4rem;
    opacity: 0.8;
}

.tb-nav .nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 28px;
    margin: 0;
    padding: 4px 0 16px;
    list-style: none;
}

.tb-nav .nav a {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--ink-soft);
}

.tb-nav .nav a:hover,
.tb-nav .nav-current a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 6px;
}

/* 主題面板 */
.tb-topics {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--ink);
    box-shadow: 0 18px 30px -18px rgb(0 0 0 / 0.25);
}

.tb-topics[hidden] {
    display: none;
}

.tb-topics-inner {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 48px;
    padding-top: 28px;
    padding-bottom: 32px;
}

.tb-topics-label {
    margin-bottom: 14px;
    padding-bottom: 8px;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--mute);
    border-bottom: 1px solid var(--rule);
}

.tb-topics-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tb-topics-list a,
.tb-topics-site .nav a {
    font-family: var(--serif);
    font-size: 1.8rem;
    font-weight: 600;
}

.tb-topics-list a:hover,
.tb-topics-site .nav a:hover {
    color: var(--red);
}

.tb-topics-site .nav {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tb-topics-actions {
    display: none;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.tb-topics-actions svg {
    width: 16px;
    height: 16px;
}

/* ---------- 共用：分類標、署名 ---------- */

.tb-kicker {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--red);
}

.tb-kicker:hover {
    text-decoration: underline;
}

.tb-byline {
    margin-top: 10px;
    font-size: 1.3rem;
    line-height: 1.6;
    color: var(--ink-soft);
}

.tb-byline-authors {
    font-weight: 500;
}

.tb-byline-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 10px;
    font-size: 1.25rem;
    color: var(--mute);
}

.tb-byline-meta > * + *::before {
    content: "·";
    margin-right: 10px;
}

.tb-paid {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
    color: var(--red);
}

.tb-paid svg {
    width: 11px;
    height: 11px;
}

/* ---------- 圖片 40:21 ---------- */

.tb-media {
    display: block;
    aspect-ratio: 40 / 21;
    overflow: hidden;
    background: var(--bg-soft);
}

.tb-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.2s;
}

.tb-media:hover img {
    opacity: 0.88;
}

/* ---------- 卡片與格線 ---------- */

.tb-grid {
    display: grid;
    gap: 28px 24px;
}

.tb-grid.is-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tb-grid.is-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tb-card {
    display: flex;
    flex-direction: column;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--rule);
}

.tb-card-body {
    padding-top: 14px;
}

.tb-card-title {
    font-family: var(--serif);
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: 0;
}

.is-4 .tb-card-title {
    font-size: 1.8rem;
}

.tb-card-title a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.tb-card-excerpt {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    margin-top: 8px;
    font-size: 1.45rem;
    line-height: 1.75;
    color: var(--ink-soft);
}

/* ---------- 色塊大卡 ---------- */

.tb-hero {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: center;
    gap: 32px;
    padding: 24px;
    color: #f4f1ea;
    background: var(--tone-ink);
}

.tb-hero.is-pine {
    background: var(--tone-pine);
}

.tb-hero-text {
    padding: 8px 0 8px 8px;
}

.tb-hero-label {
    margin-bottom: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    opacity: 0.75;
}

.tb-hero .tb-kicker {
    color: #f4f1ea;
}

.tb-hero-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    font-family: var(--serif);
    font-size: clamp(2.6rem, 2.4vw, 3.4rem);
    font-weight: 600;
    line-height: 1.38;
    letter-spacing: 0;
}

.tb-hero-title a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 5px;
}

.tb-hero-excerpt {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    margin-top: 14px;
    font-size: 1.55rem;
    line-height: 1.8;
    opacity: 0.88;
}

.tb-hero .tb-byline,
.tb-hero .tb-byline-meta {
    color: rgb(244 241 234 / 0.8);
}

.tb-hero .tb-paid {
    color: #fff;
}

.tb-hero .tb-media {
    background: rgb(0 0 0 / 0.2);
}

/* ---------- 精選輪播 ---------- */

.tb-carousel-track {
    position: relative;
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
}

.tb-carousel-track::-webkit-scrollbar {
    display: none;
}

.tb-carousel-slide {
    display: flex;
    flex: 0 0 100%;
    scroll-snap-align: start;
}

.tb-carousel-slide > .tb-hero {
    flex: 1;
}

/* 每張輪流換底色：松綠、藏青、酒紅、赭黃、梅紫 */
.tb-carousel-slide:nth-child(5n + 2) > .tb-hero {
    background: var(--tone-navy);
}

.tb-carousel-slide:nth-child(5n + 3) > .tb-hero {
    background: var(--tone-wine);
}

.tb-carousel-slide:nth-child(5n + 4) > .tb-hero {
    background: var(--tone-ochre);
}

.tb-carousel-slide:nth-child(5n) > .tb-hero {
    background: var(--tone-plum);
}

.tb-carousel-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 14px;
}

.tb-carousel-nav[hidden] {
    display: none;
}

.tb-carousel-dots {
    display: flex;
    gap: 4px;
}

.tb-carousel-dot {
    width: 24px;
    height: 24px;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}

.tb-carousel-dot::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    margin: auto;
    background: var(--rule);
    border-radius: 50%;
    transition: background 0.2s, transform 0.2s;
}

.tb-carousel-dot:hover::before {
    background: var(--mute);
}

.tb-carousel-dot[aria-current="true"]::before {
    background: var(--ink);
    transform: scale(1.25);
}

.tb-carousel-arrows {
    display: flex;
    gap: 8px;
}

.tb-carousel-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--ink);
    background: none;
    border: 1px solid var(--ink);
    border-radius: 50%;
    cursor: pointer;
}

.tb-carousel-arrow:focus:not(:focus-visible),
.tb-carousel-dot:focus:not(:focus-visible) {
    outline: none;
}

.tb-carousel-arrow:hover {
    color: var(--bg);
    background: var(--ink);
}

.tb-carousel-arrow svg {
    width: 8px;
    height: 14px;
}

@media (prefers-reduced-motion: reduce) {
    .tb-carousel-track {
        scroll-behavior: auto;
    }
}

/* 手機用手指滑，箭頭收起來，圓點置中 */
@media (max-width: 767px) {
    .tb-carousel-arrows {
        display: none;
    }

    .tb-carousel-nav {
        justify-content: center;
    }
}

/* ---------- 區塊 ---------- */

.tb-top {
    display: grid;
    gap: 28px;
    padding-top: 28px;
}

.tb-section {
    margin-top: 56px;
}

.tb-section-head {
    margin-bottom: 22px;
    padding-bottom: 8px;
    font-family: var(--sans);
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: 0;
    border-bottom: 2px solid var(--ink);
}

.tb-section-head a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.tb-section-head svg {
    width: 8px;
    height: 14px;
}

.tb-section-head a:hover {
    color: var(--red);
}

/* 純文字清單 */
.tb-textlist {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tb-textlist li {
    padding: 14px 0;
    border-bottom: 1px solid var(--rule);
}

.tb-textlist-title {
    display: block;
    margin-bottom: 6px;
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.55;
}

.tb-textlist-title:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* 訂閱 */
.tb-signup {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 32px;
    padding: 36px 40px;
    background: var(--bg-soft);
    border-top: 3px solid var(--red);
}

.tb-signup-title {
    font-family: var(--serif);
    font-size: 2.6rem;
    font-weight: 600;
    letter-spacing: 0;
}

.tb-signup p {
    margin-top: 8px;
    font-size: 1.5rem;
    line-height: 1.75;
    color: var(--ink-soft);
}

.tb-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.tb-form-input {
    flex: 1 1 220px;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    font-size: 1.5rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--ink);
    border-radius: 0;
}

.tb-form .tb-btn {
    min-height: 44px;
}

.tb-form-loading,
.tb-form-done,
.tb-form .tb-form-error {
    display: none;
}

.tb-form.loading .tb-form-idle,
.tb-form.success .tb-form-idle {
    display: none;
}

.tb-form.loading .tb-form-loading,
.tb-form.success .tb-form-done {
    display: inline;
}

.tb-form.error .tb-form-error {
    display: block;
    flex-basis: 100%;
    font-size: 1.3rem;
    color: var(--red);
}

/* ---------- 列表頁 ---------- */

.tb-archive-head {
    padding-top: 48px;
    padding-bottom: 32px;
    text-align: center;
}

.tb-author-avatar {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    object-fit: cover;
    border-radius: 50%;
}

.tb-archive-title {
    font-family: var(--serif);
    font-size: clamp(3.2rem, 4vw, 4.4rem);
    font-weight: 600;
    letter-spacing: 0;
}

.tb-archive-desc {
    max-width: 640px;
    margin: 10px auto 0;
    font-size: 1.6rem;
    line-height: 1.75;
    color: var(--ink-soft);
}

.tb-archive-count {
    margin-top: 8px;
    font-size: 1.4rem;
    color: var(--mute);
}

.tb-archive {
    display: grid;
    gap: 32px;
}

.tb-loadmore-wrap {
    display: flex;
    justify-content: center;
}

/* ---------- 文章頁 ---------- */

.tb-post-band {
    padding: 32px var(--gutter) 0;
}

.tb-post-figure {
    max-width: 900px;
    margin: 0 auto;
}

.tb-post-figure img {
    width: 100%;
    aspect-ratio: 40 / 21;
    object-fit: contain;
    background: #000;
}

.tb-post-figure figcaption {
    margin-top: 8px;
    font-size: 1.3rem;
    color: var(--mute);
    text-align: center;
}

.tb-post-head,
.tb-page-head {
    max-width: calc(780px + var(--gutter) * 2);
    padding-top: 32px;
    text-align: center;
}

.tb-article-title {
    font-family: var(--serif);
    font-size: clamp(3rem, 3.6vw, 4.4rem);
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0;
    text-wrap: balance;
}

.tb-article-dek {
    max-width: 640px;
    margin: 16px auto 0;
    font-size: 1.8rem;
    line-height: 1.75;
    color: var(--ink-soft);
}

.tb-post-byline {
    margin-top: 20px;
    padding-bottom: 24px;
    font-size: 1.4rem;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--rule);
}

.tb-post-byline a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tb-post-byline .tb-byline-meta {
    justify-content: center;
    margin-top: 4px;
}

/* 內文窄欄 680px，寬版卡片放寬 */
.tb-content {
    display: grid;
    grid-template-columns:
        [full-start] minmax(var(--gutter), 1fr)
        [wide-start] minmax(0, 120px)
        [main-start] min(680px, calc(100% - 2 * var(--gutter))) [main-end]
        minmax(0, 120px) [wide-end]
        minmax(var(--gutter), 1fr) [full-end];
    margin-top: 36px;
    padding-bottom: 24px;
    font-size: 1.8rem;
    line-height: 1.9;
    letter-spacing: 0.01em;
    color: var(--ink);
    --content-font-size: 1.8rem;
}

.tb-content > * {
    grid-column: main-start / main-end;
}

.tb-content > .kg-width-wide {
    grid-column: wide-start / wide-end;
}

.tb-content > .kg-width-full {
    grid-column: full-start / full-end;
}

.tb-content > h2 {
    font-family: var(--serif);
    font-size: 2.6rem;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: 0;
}

.tb-content > h3 {
    font-family: var(--serif);
    font-size: 2.1rem;
    font-weight: 600;
    letter-spacing: 0;
}

.tb-content > [id]:not(:first-child) {
    margin-top: 1.9em;
}

.tb-content a {
    color: var(--red);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.tb-content strong {
    font-weight: 700;
}

.tb-content blockquote:not([class]) {
    padding-left: 20px;
    font-family: var(--serif);
    border-left: 3px solid var(--red);
}

.tb-content figcaption {
    font-size: 1.35rem;
    line-height: 1.6;
    color: var(--mute);
}

.tb-content .gh-table table {
    font-size: 1.5rem;
    white-space: normal;
}

.tb-content .gh-table {
    overflow-x: auto;
}

/* 付費牆 */
.tb-content .gh-post-upgrade-cta-content,
.tb-content .gh-post-upgrade-cta {
    color: var(--ink);
    background-color: var(--bg-soft) !important;
    border-top: 3px solid var(--red);
    border-radius: 0;
}

.tb-content .gh-post-upgrade-cta h2 {
    font-family: var(--serif);
    color: var(--ink);
}

.tb-content .gh-post-upgrade-cta a.gh-btn {
    color: #fff !important;
    background: var(--red) !important;
    border-radius: 0;
    text-decoration: none;
}

.tb-content .gh-post-upgrade-cta p,
.tb-content .gh-post-upgrade-cta p a {
    color: var(--ink-soft) !important;
}

/* 正式站注入的分享按鈕 */
.tb-content > .social-share-buttons {
    margin: 40px 0 0 !important;
    border-color: var(--rule) !important;
}

.tb-post-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 680px;
    margin: 24px auto 0;
    padding-inline: var(--gutter);
    box-sizing: content-box;
}

.tb-post-tags a {
    padding: 4px 12px;
    font-size: 1.35rem;
    border: 1px solid var(--rule);
}

.tb-post-tags a:hover {
    border-color: var(--ink);
}

.tb-comments {
    max-width: 680px;
    margin: 48px auto 0;
    padding-inline: var(--gutter);
    box-sizing: content-box;
}

.tb-related {
    margin-bottom: 8px;
}

/* 一般頁面 */
.tb-page-head {
    padding-top: 56px;
}

.tb-page-figure {
    max-width: 900px;
    margin: 32px auto 0;
    padding-inline: var(--gutter);
}

/* ---------- 頁尾 ---------- */

.tb-footer {
    margin-top: 80px;
    background: var(--bg-soft);
    border-top: 1px solid var(--rule);
}

.tb-footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: calc(640px + var(--gutter) * 2);
    padding-top: 56px;
    padding-bottom: 40px;
    text-align: center;
}

.tb-footer-logo img {
    width: 240px;
    height: auto;
}

.tb-footer-logo img.is-site-logo {
    width: auto;
    max-width: 240px;
    max-height: 48px;
}

.tb-footer-desc {
    margin-top: 16px;
    font-size: 1.45rem;
    line-height: 1.8;
    color: var(--ink-soft);
}

.tb-footer .tb-form {
    max-width: 440px;
    margin-top: 24px;
}

.tb-footer-nav .nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 22px;
    margin: 28px 0 0;
    padding: 0;
    list-style: none;
}

.tb-footer-nav a {
    font-size: 1.4rem;
    color: var(--ink-soft);
}

.tb-footer-nav a:hover {
    color: var(--ink);
}

.tb-social {
    display: flex;
    gap: 18px;
    margin-top: 20px;
}

.tb-social svg {
    width: 20px;
    height: 20px;
    fill: var(--ink-soft);
}

.tb-footer-bottom {
    padding: 18px 0;
    font-size: 1.3rem;
    color: var(--mute);
    text-align: center;
    border-top: 1px solid var(--rule);
}

/* ---------- 窄螢幕 ---------- */

@media (max-width: 1023px) {
    .tb-grid.is-4,
    .tb-textlist {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tb-hero {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

@media (max-width: 1023px) {
    .tb-logo img {
        width: clamp(180px, 26vw, 240px);
    }
}

@media (max-width: 767px) {
    .tb-hide-mobile,
    .tb-nav {
        display: none !important;
    }

    .tb-bar {
        grid-template-columns: auto 1fr auto;
        gap: 8px;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .tb-logo {
        justify-self: center;
    }

    .tb-logo img {
        width: min(150px, 36vw);
    }

    .tb-logo img.is-site-logo {
        width: auto;
        max-width: min(150px, 36vw);
        max-height: 36px;
    }

    .tb-bar-right,
    .tb-members {
        gap: 4px;
    }

    /* 手機：登入改文字連結，訂閱維持紅底；EN 移進主題面板 */
    .tb-members .tb-signin {
        min-height: 36px;
        padding: 0 6px;
        border-color: transparent;
    }

    .tb-members .tb-signin:hover {
        color: var(--ink);
        background: none;
        text-decoration: underline;
    }

    .tb-members .tb-signup-btn,
    .tb-members .tb-account {
        min-height: 36px;
        padding: 0 12px;
    }

    .tb-members .tvm-lang {
        display: none;
    }

    .tb-btn {
        min-height: 38px;
        padding: 0 12px;
        font-size: 1.4rem;
    }

    .tb-topics-toggle .tb-grid-icon {
        display: none;
    }

    .tb-topics {
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .tb-topics-inner {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .tb-topics-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .tb-topics-actions {
        display: flex;
    }

    .tb-grid.is-3,
    .tb-grid.is-4,
    .tb-textlist {
        grid-template-columns: minmax(0, 1fr);
    }

    .tb-hero {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 12px 12px 20px;
    }

    .tb-hero-media {
        order: -1;
    }

    .tb-hero-text {
        padding: 0 4px;
    }

    .tb-top {
        padding-top: 16px;
    }

    .tb-section {
        margin-top: 44px;
    }

    .tb-signup {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
        padding: 28px 20px;
    }

    .tb-post-band {
        padding-top: 0;
        padding-inline: 0;
    }

    .tb-content {
        font-size: 1.7rem;
        --content-font-size: 1.7rem;
    }

    .tb-content > .kg-width-wide {
        grid-column: main-start / main-end;
    }
}

/* ---------- 底部訂閱列 ---------- */

.tb-subbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 900;
    border-top: 1px solid var(--rule);
    background: var(--bg-soft);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.tb-subbar.is-visible {
    transform: translateY(0);
}

.tb-subbar-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 14px 72px 14px var(--gutter);
}

.tb-subbar-text {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.8rem;
    color: var(--ink);
}

.tb-subbar-close {
    position: absolute;
    top: 50%;
    right: 16px;
    display: flex;
    padding: 8px;
    border: 0;
    background: none;
    color: var(--mute);
    cursor: pointer;
    transform: translateY(-50%);
}

.tb-subbar-close:hover {
    color: var(--ink);
}

@media (max-width: 767px) {
    .tb-subbar-inner {
        justify-content: flex-start;
        gap: 12px;
        padding: 10px 16px;
    }

    .tb-subbar-text {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        font-size: 1.5rem;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .tb-subbar-cta {
        flex-shrink: 0;
    }

    .tb-subbar-close {
        position: static;
        flex-shrink: 0;
        transform: none;
    }
}

/* 訂閱列出現時，把正式站注入的 Saily 浮動鈕推到訂閱列上方 */
#tv-saily {
    transition: bottom 0.3s ease;
}

body.tb-subbar-on #tv-saily {
    bottom: calc(var(--tb-subbar-h, 64px) + 12px);
}

/* ---------- 內文裡的 HTML 區塊 ----------
   編輯器的 HTML 卡片會包一層 section／div，裡面的元素吃不到 .gh-content > * 的間距，
   這裡補上同一套節奏。HTML 卡片裡的標題沒有 id，所以用標籤名判斷 */
.gh-content > :is(section, div:not([class])) > * + * {
    margin-top: calc(28px * var(--content-spacing-factor, 1));
}

.gh-content > :is(section, div:not([class])) > :is(h2, h3, h4):not(:first-child) {
    margin-top: calc(56px * var(--content-spacing-factor, 1));
}

.gh-content > :is(section, div:not([class])) > :is(h2, h3, h4) + p {
    margin-top: calc(12px * var(--content-spacing-factor, 1));
}

/* 區塊以標題開頭時，上方用標題的間距 */
.gh-content > :is(section, div:not([class])):has(> :is(h2, h3, h4):first-child):not(:first-child) {
    margin-top: calc(56px * var(--content-spacing-factor, 1));
}

/* 編輯器多按 Enter 留下的空段落不佔版面 */
.gh-content p:empty {
    display: none;
}

/* 國際站照西方習慣綠漲紅跌 */
html:not([lang="zh-Hant"]) .tb-tick-pct.is-up {
    color: #5fd38d;
}

html:not([lang="zh-Hant"]) .tb-tick-pct.is-down {
    color: #ff7a70;
}
