/* =====================================================================
   Pusu Patas Kari Truku — 網站樣式
   色彩取自太魯閣族織布：紅、黑、白，搭配山林綠。
   ===================================================================== */

:root {
    --red: #a4161a;
    --red-dark: #7a0f12;
    --red-soft: #fbeaea;
    --green: #2f5d50;
    --green-soft: #e6f0ec;
    --gold: #b88a12;
    --ink: #1f1a17;
    --text: #2b2521;
    --muted: #6b625b;
    --bg: #f8f5f0;
    --surface: #ffffff;
    --surface-2: #f2ede6;
    --line: #e4dbcf;
    --focus: #1f6feb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(31, 26, 23, .06), 0 4px 16px rgba(31, 26, 23, .06);
    --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-truku: "Segoe UI", "Helvetica Neue", Arial, var(--font);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --red: #e05a5e;
        --red-dark: #f08a8d;
        --red-soft: #3a1d1e;
        --green: #7fc2ad;
        --green-soft: #1d2f2a;
        --gold: #e0b84a;
        --ink: #0f0d0c;
        --text: #ece6df;
        --muted: #a69c92;
        --bg: #171412;
        --surface: #211d1a;
        --surface-2: #2a2521;
        --line: #3a332d;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 16px/1.7 var(--font);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
img { max-width: 100%; height: auto; }

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

h1, h2, h3 { line-height: 1.3; color: var(--ink); margin: 0 0 .6em; }
@media (prefers-color-scheme: dark) { h1, h2, h3 { color: var(--text); } }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.skip-link {
    position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

.truku { font-family: var(--font-truku); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- 織紋裝飾條 ---------------------------------------------------- */
.weave {
    height: 12px;
    background-color: var(--ink);
    background-image:
        linear-gradient(135deg, var(--red) 25%, transparent 25%),
        linear-gradient(225deg, var(--red) 25%, transparent 25%),
        linear-gradient(315deg, #fff 25%, transparent 25%),
        linear-gradient(45deg, #fff 25%, transparent 25%);
    background-size: 12px 12px;
    background-position: -6px 0, -6px 0, 0 0, 0 0;
}

/* ---- 頁首 ---------------------------------------------------------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }

.header-inner { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 40px; height: 40px; object-fit: contain; flex: none; transform-origin: top left; transition: transform .2s ease; }
.brand { position: relative; z-index: 1; }
.brand:hover img, .brand:focus-visible img { transform: scale(10); }
@media (prefers-reduced-motion: reduce) {
    .brand img { transition: none; }
}
.brand strong { display: block; font: 700 1.1rem/1.2 var(--font-truku); letter-spacing: .01em; color: var(--text); }
.brand strong b { color: var(--red); }
.brand small { display: block; color: var(--muted); font-size: .8rem; }

.header-search { margin-left: auto; display: flex; flex: 0 1 280px; }
.header-search input {
    flex: 1; min-width: 0; padding: .5rem .75rem; border: 1px solid var(--line); border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius); font: inherit; background: var(--bg); color: var(--text);
}
.header-search button { border-radius: 0 var(--radius) var(--radius) 0; }

.site-header .nav-toggle { display: none; }

/* 語言切換（中文 / English） */
.lang-switch {
    margin-left: auto; flex: none; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px;
    font-size: .875rem; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap;
}
.lang-switch:hover { border-color: var(--red); color: var(--red); }
.header-search + .lang-switch { margin-left: 0; }

/* 選單與 logo 同一列 */
.header-inner { padding-top: 6px; padding-bottom: 6px; }
.main-nav { min-width: 0; }
.main-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
.main-nav a {
    display: block; padding: .5rem .75rem; text-decoration: none; color: var(--text); font-size: 1rem;
    border-bottom: 3px solid transparent;
}
.main-nav a:hover { color: var(--red); }
.main-nav a[aria-current="page"] { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }
.main-nav .nav-end { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.main-nav .nav-end form { margin: 0; }
.link-button {
    background: none; border: 0; padding: .55rem .8rem; font: inherit; font-size: .95rem; color: var(--text); cursor: pointer;
}
.link-button:hover { color: var(--red); }

@media (max-width: 760px) {
    .header-inner { flex-wrap: wrap; }
    .brand small { display: none; }
    .site-header .nav-toggle { display: inline-flex; margin-left: auto; }
    .header-search + .lang-switch { margin-left: auto; }
    .lang-switch + .nav-toggle { margin-left: 0 !important; }
    .header-search { order: 3; flex: 1 1 100%; }
    .main-nav { display: none; order: 4; flex: 1 1 100%; border-top: 1px solid var(--line); }
    .main-nav.is-open { display: block; }
    .main-nav ul { flex-direction: column; }
    .main-nav a { border-bottom: 0; border-left: 3px solid transparent; }
    .main-nav a[aria-current="page"] { border-left-color: var(--red); }
    .main-nav .nav-end { margin-left: 0; flex-direction: column; align-items: stretch; border-top: 1px solid var(--line); }
    .link-button { text-align: left; width: 100%; }
}

/* ---- 按鈕與表單 ---------------------------------------------------- */
.btn, .header-search button {
    display: inline-flex; align-items: center; justify-content: center; gap: .4em;
    padding: .5rem 1rem; border: 1px solid var(--red); background: var(--red); color: #fff;
    border-radius: var(--radius); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.4;
    white-space: nowrap; flex: none;
}
.btn:hover, .header-search button:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--red); }
.btn-outline:hover { background: var(--red-soft); color: var(--red-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-danger { background: #b42318; border-color: #b42318; }
.btn-sm { padding: .25rem .6rem; font-size: .875rem; font-weight: 500; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

label { font-weight: 600; display: block; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .85rem; margin-top: .25rem; }
input[type="text"], input[type="search"], input[type="email"], input[type="url"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
    width: 100%; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font: inherit; background: var(--surface); color: var(--text);
}
textarea { min-height: 7rem; resize: vertical; }
input[type="file"] { font: inherit; max-width: 100%; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin-right: 1rem; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: .5rem; border-top: 1px solid var(--line); margin-top: 1rem; }
.hp-field { position: absolute; left: -9999px; }

/* ---- 卡片、版面 ---------------------------------------------------- */
.page { padding-top: 24px; padding-bottom: 48px; }
.page-header { margin-bottom: 20px; }
.page-header p { color: var(--muted); margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-title h2 { margin: 0; }
.card-title a { font-size: .9rem; white-space: nowrap; }

.grid { display: grid; gap: 16px; }
.grid > .card + .card { margin-top: 0; } /* 並排卡片不需要上邊距，避免高低不齊 */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.breadcrumb { font-size: .875rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }

/* ---- 首頁 ---------------------------------------------------------- */
.hero { background: var(--surface); border-bottom: 1px solid var(--line); padding: 40px 0 32px; text-align: center; }
.hero h1 { font-family: var(--font-truku); font-size: clamp(2.4rem, 1.4rem + 4vw, 4.2rem); margin-bottom: .2em; }
@media (max-width: 760px) { .hero h1 { font-size: 2rem; } } /* 手機 */
.fx-title b { -webkit-text-stroke: 3px #000; paint-order: stroke fill; } /* 字首：青、洋紅、黃、綠四色 + 黑邊 */
.fx-title b:nth-of-type(4n+1) { color: #00aeef; } /* C */
.fx-title b:nth-of-type(4n+2) { color: #ec008c; } /* M */
.fx-title b:nth-of-type(4n+3) { color: #fff200; } /* Y */
.fx-title b:nth-of-type(4n)   { color: #00a651; } /* 綠 */
/* 滑鼠經過標題（首頁大標、頁尾站名 .fx-title）每個字母：由 app.js 把字母包成 .fx-letter，隨機加上 .fx-* 動畫與顏色 */
.fx-title b, .fx-title .fx-letter { display: inline-block; cursor: default; transition: color .25s; }
.fx-title .fx-bounce { animation: fx-bounce .7s ease; }
.fx-title .fx-spin   { animation: fx-spin .7s ease-in-out; }
.fx-title .fx-wobble { animation: fx-wobble .8s ease; }
.fx-title .fx-jelly  { animation: fx-jelly .8s ease; }
.fx-title .fx-flip   { animation: fx-flip .7s ease-in-out; }
.fx-title .fx-pop    { animation: fx-pop .5s ease; }
.fx-title .fx-swing  { animation: fx-swing .9s ease; transform-origin: top center; }
@keyframes fx-bounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-.45em); } 50% { transform: translateY(0); } 70% { transform: translateY(-.18em); } }
@keyframes fx-spin   { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes fx-wobble { 0%,100% { transform: translateX(0) rotate(0); } 20% { transform: translateX(-.15em) rotate(-10deg); } 40% { transform: translateX(.12em) rotate(8deg); } 60% { transform: translateX(-.08em) rotate(-5deg); } 80% { transform: translateX(.04em) rotate(2deg); } }
@keyframes fx-jelly  { 0%,100% { transform: scale(1,1); } 30% { transform: scale(1.3,.75); } 40% { transform: scale(.75,1.3); } 55% { transform: scale(1.15,.88); } 75% { transform: scale(.96,1.05); } }
@keyframes fx-flip   { from { transform: perspective(300px) rotateY(0); } to { transform: perspective(300px) rotateY(360deg); } }
@keyframes fx-pop    { 0%,100% { transform: scale(1); } 50% { transform: scale(1.5); } }
@keyframes fx-swing  { 0%,100% { transform: rotate(0); } 20% { transform: rotate(15deg); } 40% { transform: rotate(-10deg); } 60% { transform: rotate(5deg); } 80% { transform: rotate(-5deg); } }
@media (prefers-reduced-motion: reduce) { .fx-title [class*="fx-"] { animation: none; } }
.hero p { color: var(--muted); }
/* 頁尾站名：字型比照首頁大標；字小，黑邊改細 */
.site-footer .fx-title { font-family: var(--font-truku); font-size: 1.15rem; }
.site-footer .fx-title b { -webkit-text-stroke-width: 1.5px; }
.hero .container { max-width: none; }
.hero-search { width: 100%; max-width: 1080px; margin: 20px auto 0; }
.hero-search .search-row { display: flex; gap: 8px; }
.hero-search input[type="search"] { font-size: 1.15rem; padding: .7rem 1rem; }
.hero-search .btn { font-size: 1.05rem; padding: .7rem 1.4rem; }
.search-options { margin-top: 10px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; font-size: .92rem; }

.stats-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; margin-top: 18px; color: var(--muted); font-size: .9rem; }
.stats-row strong { color: var(--ink); font-size: 1.1rem; }
@media (prefers-color-scheme: dark) { .stats-row strong { color: var(--text); } }

.daily-card { border-top: 4px solid var(--red); border-top-color: color-mix(in srgb, var(--red) 50%, transparent); } /* 上緣紅線淡化為 50%（舊瀏覽器維持原色） */
.daily-card .label { font-size: .8rem; font-weight: 700; color: var(--red); letter-spacing: .08em; }
.daily-card .term { font: 700 1.5rem/1.3 var(--font-truku); margin: .2em 0; word-break: break-word; }
.daily-card .term a { color: var(--ink); text-decoration: none; }
@media (prefers-color-scheme: dark) { .daily-card .term a { color: var(--text); } }
.daily-card .meaning { color: var(--muted); }
.daily-card.sentence .term { font-size: 1.15rem; font-weight: 600; }
/* 字卡內容平時灰階、低對比，滑鼠經過（或鍵盤移入）時恢復；手機等無滑鼠裝置維持原樣 */
@media (hover: hover) {
    .daily-card > * { filter: grayscale(1); opacity: .5; transition: filter .25s, opacity .25s; }
    .daily-card:hover > *, .daily-card:focus-within > * { filter: none; opacity: 1; }
}

/* ---- 首頁新聞（與每日一句相同的長方形卡片） ---------------------------- */
.home-news { margin-top: 24px; }
.home-news .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.home-news .section-head h2 { margin: 0; }
.home-news .section-head a { font-size: .9rem; white-space: nowrap; }
.news-card .term { font-family: inherit; }
/* 首頁新聞：多則新聞放在同一張卡片，以分隔線區隔 */
.news-card .news-item + .news-item { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.daily-card.news-card .label { font-size: .7rem; }
.daily-card.news-card .term { font-size: .9rem; }
.daily-card.news-card .meaning { font-size: .8rem; }
.home-news-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 20px; }
.home-news-settings .check { margin-right: 0; }
.home-news-settings select { width: auto; display: inline-block; padding: .2rem .4rem; }

/* ---- 清單 ---------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .55rem 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; align-items: baseline; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.entry-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.entry-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; display: flex; gap: 8px; align-items: flex-start; }
.entry-list li > div { flex: 1; min-width: 0; }
.entry-list a.t { font: 600 1.05rem/1.4 var(--font-truku); text-decoration: none; word-break: break-word; }
.entry-list .c { color: var(--muted); font-size: .9rem; }

.sentence-list { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.sentence-list li { padding: .75rem 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; }
.sentence-list li > div { flex: 1; min-width: 0; }
.sentence-list .t { font-family: var(--font-truku); font-weight: 600; text-decoration: none; }
.sentence-list .c { color: var(--muted); }

.letters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; }
.letters a, .letters span {
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 46px; padding: .3rem .5rem;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none;
    font: 700 1.05rem/1.2 var(--font-truku); color: var(--text);
}
.letters small { font: 400 .7rem/1 var(--font); color: var(--muted); margin-top: 2px; }
.letters a:hover { border-color: var(--red); color: var(--red); }
.letters a[aria-current="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.letters a[aria-current="true"] small { color: #fde; }
.letters span { opacity: .4; }

/* ---- 表格 ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .95rem; }
.table th, .table td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tr:hover td { background: var(--bg); }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions form { display: inline; }

/* ---- 詳細頁 -------------------------------------------------------- */
.entry-head { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-start; }
.entry-head .main { flex: 1 1 320px; min-width: 0; }
.entry-term { font: 700 clamp(2rem, 1.4rem + 2.5vw, 3rem)/1.15 var(--font-truku); margin: 0 0 .2em; word-break: break-word; }
.entry-term.long { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.7rem); line-height: 1.5; }
.entry-chinese { font-size: 1.25rem; margin: 0 0 .5em; }
.entry-image { flex: 0 0 auto; max-width: 260px; }
.entry-image img { border-radius: var(--radius); border: 1px solid var(--line); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: .5rem 0; padding: 0; list-style: none; }
.tag { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .85rem; background: var(--green-soft); color: var(--green); text-decoration: none; }
.tag.red { background: var(--red-soft); color: var(--red); }
a.tag:hover { filter: brightness(.95); }

.translations { list-style: none; margin: 0; padding: 0; counter-reset: t; }
.translations li { counter-increment: t; display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 8px; padding: .7rem 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.translations li::before { content: "(" counter(t) ")"; color: var(--red); font-weight: 700; }
.translations .t { font-family: var(--font-truku); font-weight: 600; }
.translations .c { display: block; color: var(--muted); }

.note { background: var(--surface-2); border-left: 4px solid var(--gold); padding: .7rem 1rem; border-radius: 0 8px 8px 0; margin: 1rem 0; }

.entry-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1rem; }

/* ---- 發音按鈕 ------------------------------------------------------ */
.play {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
    color: var(--red); cursor: pointer; text-decoration: none; vertical-align: middle;
}
.play:hover { background: var(--red-soft); border-color: var(--red); }
.play.is-playing { background: var(--red); color: #fff; border-color: var(--red); }
.play svg { width: 18px; height: 18px; }
.play-lg { width: 48px; height: 48px; }
.play-lg svg { width: 24px; height: 24px; }

/* ---- 分頁 ---------------------------------------------------------- */
.pagination { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 24px 0 0; padding: 0; list-style: none; align-items: center; }
.pagination a, .pagination span { display: inline-block; min-width: 36px; padding: .3rem .6rem; text-align: center; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; background: var(--surface); }
.pagination [aria-current="page"] { background: var(--red); border-color: var(--red); color: #fff; }
.pagination .gap { border: 0; background: none; }
.pagination-info { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 6px; }

/* ---- 提示訊息 ------------------------------------------------------ */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin: 16px 0 0; border: 1px solid; }
.flash-success { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.flash-error { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.flash-info { background: var(--surface-2); border-color: var(--line); }

.empty { color: var(--muted); padding: 1rem 0; }

/* ---- 搜尋結果 ------------------------------------------------------ */
.result-group + .result-group { margin-top: 24px; }
.result-group h2 { display: flex; gap: 8px; align-items: baseline; }
.result-group h2 .count { font-size: .9rem; color: var(--muted); font-weight: 400; }
mark { background: #fff2a8; color: inherit; padding: 0 1px; border-radius: 2px; }
@media (prefers-color-scheme: dark) { mark { background: #6b5a12; } }

/* ---- 統計圖 -------------------------------------------------------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bars .bar { flex: 1; background: var(--red); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars .bar:hover { opacity: 1; }
.bars-labels { display: flex; gap: 3px; font-size: .7rem; color: var(--muted); }
.bars-labels span { flex: 1; text-align: center; overflow: hidden; white-space: nowrap; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-tile .n { font-size: 1.6rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .stat-tile .n { color: var(--text); } }
.stat-tile .l { color: var(--muted); font-size: .85rem; }

/* ---- 頁尾 ---------------------------------------------------------- */
.site-footer { background: var(--ink); color: #d9d2ca; margin-top: 32px; font-size: .9rem; }
.site-footer a { color: #fff; }
.footer-inner { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px 32px; align-items: start; padding-top: 24px; padding-bottom: 24px; }
.footer-inner p { margin: 0 0 .3em; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; align-content: flex-start; gap: 4px 16px; list-style: none; margin: 0; padding: 0; }
.footer-links form { margin: 0; }
.footer-links .link-button { width: auto; padding: 0; color: #fff; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.footer-stats { display: flex; gap: 8px 28px; margin: 0; justify-content: center; text-align: center; }
.footer-stats dt { font-size: .8rem; color: #b8afa6; }
.footer-stats dd { margin: 0; font-size: 1.25rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
    .footer-inner { grid-template-columns: 1fr; }
    .footer-stats { justify-content: flex-start; }
    .footer-links { justify-content: flex-start; }
}

/* ---- 後台 ---------------------------------------------------------- */
.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 24px; padding-top: 24px; padding-bottom: 48px; }
.admin-nav { position: sticky; top: 120px; align-self: start; }
.admin-nav ul { list-style: none; margin: 0 0 16px; padding: 0; }
.admin-nav h3 { font-size: .75rem; letter-spacing: .1em; color: var(--muted); margin: 12px 0 4px; }
.admin-nav a { display: flex; justify-content: space-between; padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--text); }
.admin-nav a:hover { background: var(--surface-2); }
.admin-nav a[aria-current="page"] { background: var(--red-soft); color: var(--red); font-weight: 600; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--red); color: #fff; font-size: .75rem; text-align: center; line-height: 1.6; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; flex: 1 1 280px; max-width: 420px; }
.trans-row { display: grid; grid-template-columns: 140px 1fr 1fr 1fr auto auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.trans-row .check { margin: 0; font-weight: 400; }
.media-box { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: .7rem; border: 1px dashed var(--line); border-radius: 8px; }
.media-box img { max-height: 90px; border-radius: 6px; }
@media (max-width: 860px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-nav { position: static; }
    .admin-nav ul { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
    .admin-nav h3 { width: 100%; }
    .trans-row { grid-template-columns: 1fr 1fr; }
}

/* ---- 錯誤頁 -------------------------------------------------------- */
.error-page { text-align: center; padding-top: 64px; padding-bottom: 64px; }
.error-page .code { font: 800 5rem/1 var(--font-truku); color: var(--red); }

@media print {
    .site-header, .site-footer, .play, .entry-actions, .pagination { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}

/* ---- 所見即所得內容（新聞、版權說明） ---------------------------------- */
.rich-content { overflow-wrap: anywhere; line-height: 1.75; }
.rich-content > :first-child { margin-top: 0; }
.rich-content > :last-child { margin-bottom: 0; }
.rich-content img, .rich-content video { max-width: 100%; height: auto; border-radius: 6px; }
.rich-content iframe { max-width: 100%; border: 0; border-radius: 6px; }
.rich-content audio { width: 100%; max-width: 480px; }
.rich-content figure { margin: 1.2em 0; }
.rich-content figure.image { display: table; }
.rich-content figure.image[style*="margin-left: auto"] { margin-left: auto; margin-right: auto; }
.rich-content figcaption { color: var(--muted); font-size: .9rem; text-align: center; margin-top: .4em; }
.rich-content blockquote { margin: 1em 0; padding: .4em 1em; border-left: 4px solid var(--line); color: var(--muted); }
.rich-content table { border-collapse: collapse; max-width: 100%; margin: 1em 0; display: block; overflow-x: auto; }
.rich-content th, .rich-content td { border: 1px solid var(--line); padding: .45em .7em; vertical-align: top; }
.rich-content th { background: var(--surface-2); }
.rich-content pre { white-space: pre-wrap; background: var(--surface-2); padding: .8em 1em; border-radius: 6px; }
.rich-content hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.rich-content ul, .rich-content ol { padding-left: 1.6em; }

/* ---- 訪客來源世界地圖（後台「訪客來源」） ------------------------------------
   國家：單一色相（藍）深淺分 5 級，淺色模式由淺到深；深色模式由暗到亮（越接近背景越少）。
   城市圓點：橘色，外圈留 2px 底色間隙。色彩已通過色盲與對比檢查。 */
:root {
    --geo-q1: #86b6ef; --geo-q2: #5598e7; --geo-q3: #2a78d6; --geo-q4: #1c5cab; --geo-q5: #0d366b;
    --geo-dot: #eb6834;
    --geo-empty: #e6dfd4;
}
@media (prefers-color-scheme: dark) {
    :root {
        --geo-q1: #184f95; --geo-q2: #256abf; --geo-q3: #3987e5; --geo-q4: #6da7ec; --geo-q5: #9ec5f4;
        --geo-dot: #d95926;
        --geo-empty: #3a342f;
    }
}
.geo-map { margin: 0; }
.geo-map-views { margin-bottom: 8px; }
.geo-map-frame { position: relative; }
.geo-svg { display: block; width: 100%; height: auto; max-height: 70vh; background: var(--surface); }
.geo-c { fill: var(--geo-empty); stroke: var(--surface); stroke-width: .5px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.geo-c.q1 { fill: var(--geo-q1); } .geo-c.q2 { fill: var(--geo-q2); } .geo-c.q3 { fill: var(--geo-q3); }
.geo-c.q4 { fill: var(--geo-q4); } .geo-c.q5 { fill: var(--geo-q5); }
.geo-c[data-v] { stroke: var(--surface); cursor: default; }
.geo-c[data-v]:hover, .geo-c.is-active, .geo-c[data-v]:focus-visible { stroke: var(--ink); stroke-width: 1.5px; outline: none; }
@media (prefers-color-scheme: dark) { .geo-c[data-v]:hover, .geo-c.is-active, .geo-c[data-v]:focus-visible { stroke: var(--text); } }
.geo-city { outline: none; }
.geo-city .hit { fill: transparent; }
.geo-city .dot { fill: var(--geo-dot); fill-opacity: .9; stroke: var(--surface); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.geo-city:hover .dot, .geo-city.is-active .dot, .geo-city:focus-visible .dot { fill-opacity: 1; stroke: var(--ink); }
@media (prefers-color-scheme: dark) { .geo-city:hover .dot, .geo-city.is-active .dot, .geo-city:focus-visible .dot { stroke: var(--text); } }
.geo-tip {
    position: absolute; z-index: 5; pointer-events: none; min-width: 120px; max-width: 240px;
    background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
    box-shadow: var(--shadow); padding: 6px 10px; font-size: .85rem; line-height: 1.5;
}
.geo-tip strong { font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .geo-tip strong { color: var(--text); } }
.geo-tip-meta { color: var(--muted); font-size: .8rem; }
.geo-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 10px; font-size: .85rem; color: var(--muted); }
.geo-legend-title { color: var(--text); font-weight: 600; }
.geo-key { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.geo-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; background: var(--geo-empty); border: 1px solid var(--line); }
.geo-swatch.q1 { background: var(--geo-q1); } .geo-swatch.q2 { background: var(--geo-q2); } .geo-swatch.q3 { background: var(--geo-q3); }
.geo-swatch.q4 { background: var(--geo-q4); } .geo-swatch.q5 { background: var(--geo-q5); }
.geo-swatch.q1, .geo-swatch.q2, .geo-swatch.q3, .geo-swatch.q4, .geo-swatch.q5 { border-color: transparent; }
.geo-swatch-dot { border-radius: 50%; background: var(--geo-dot); border-color: transparent; }
.geo-bar { height: 8px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--geo-q3); }
.geo-others td { border-top: 2px solid var(--line); }
.geo-others tr + tr td { border-top: 0; }
@media (forced-colors: active) {
    .geo-c[data-v] { fill: Highlight; } .geo-city .dot { fill: LinkText; }
}

/* ---- 英文版 ------------------------------------------------------------------ */
/* 英文選單字較長：縮小間距與頁首搜尋框，讓選單維持一行 */
html[lang="en"] .main-nav a { padding-left: .5rem; padding-right: .5rem; }
html[lang="en"] .header-search { flex-basis: 220px; }
/* 英文頁面上的中文內容（尚無英文翻譯時）與英文翻譯下方的中文對照 */
.zh-ref { color: var(--muted); font-size: .9em; }
.ai-note { color: var(--muted); font-size: .8rem; font-style: italic; }
.ai-mark { font-size: .7em; vertical-align: super; color: var(--muted); text-decoration: none; margin-left: 2px; }
