/* =============================================================================
 *  RSS 聚合管理中心 (RSS Manager)  v1.1
 *  檔案：assets/style.css  —  全站樣式
 *
 *  版面採用 CSS Grid 與 Flexbox，支援桌機三欄、平板兩欄、手機單欄。
 *  色彩以 CSS 變數（Custom Properties）定義，並自動跟隨系統深色模式。
 * ===========================================================================*/

/* ----------------------------- 色彩變數 ----------------------------- */
:root {
    --bg:          #f4f6f8;
    --bg-panel:    #ffffff;
    --bg-soft:     #eef1f5;
    --bg-hover:    #e8edf3;
    --border:      #dde3ea;
    --border-soft: #eaeef3;
    --text:        #1d2733;
    --text-soft:   #5b6b7c;
    --text-mute:   #8a99a8;
    --accent:      #2f6fed;
    --accent-dark: #1f56c4;
    --accent-soft: #e8f0ff;
    --danger:      #d64545;
    --danger-soft: #fdecec;
    --ok:          #1f9254;
    --ok-soft:     #e6f5ec;
    --warn:        #b4741a;
    --warn-soft:   #fdf3e3;
    --star:        #e8a317;
    --shadow:      0 1px 3px rgba(16, 32, 52, .08), 0 6px 18px rgba(16, 32, 52, .06);
    --radius:      10px;
    --radius-sm:   6px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:          #151a21;
        --bg-panel:    #1c232c;
        --bg-soft:     #222b36;
        --bg-hover:    #2a3440;
        --border:      #2e3846;
        --border-soft: #262f3b;
        --text:        #e4eaf1;
        --text-soft:   #a7b4c2;
        --text-mute:   #78889a;
        --accent:      #5590ff;
        --accent-dark: #3d78ea;
        --accent-soft: #1e2b44;
        --danger:      #f07171;
        --danger-soft: #3a2020;
        --ok:          #4bc383;
        --ok-soft:     #17301f;
        --warn:        #e0a94a;
        --warn-soft:   #362a15;
        --star:        #f2b52b;
        --shadow:      0 1px 3px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    }
}

/* ----------------------------- 基本重設 ----------------------------- */
* { box-sizing: border-box; }

/**
 * 【重要】hidden 屬性的強制隱藏規則。
 *
 * 瀏覽器內建樣式表對 hidden 屬性的規則是 display:none，
 * 但只要元素本身另外設定了 display（例如 flex、inline-flex），
 * 該設定的優先權較高，會使 hidden 失效、元素依然顯示。
 * 本系統大量以 JavaScript 切換 hidden 來顯示／隱藏區塊，
 * 故在此統一以 !important 確保 hidden 必然生效。
 */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
                 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .92em;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: 4px;
    padding: 1px 5px;
    word-break: break-all;
}

/* ----------------------------- 按鈕 ----------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-mini { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-soft);
    font-size: 16px;
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ----------------------------- 表單 ----------------------------- */
.field { display: block; margin-bottom: 14px; }
.field-label {
    display: block;
    margin-bottom: 5px;
    font-size: 12.5px;
    color: var(--text-soft);
    font-weight: 600;
}
.field-label em { color: var(--danger); font-style: normal; }

input[type="text"], input[type="url"], input[type="password"],
input[type="number"], input[type="search"], input[type="file"], select, textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-check { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.field-check input { width: auto; }
.field-inline { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }

/* ----------------------------- 提示區塊 ----------------------------- */
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-ok    { background: var(--ok-soft);     border-color: var(--ok);     color: var(--ok); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-info  { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

.empty-hint {
    padding: 28px 18px;
    text-align: center;
    color: var(--text-mute);
    font-size: 13px;
}
.empty-hint.small { padding: 12px; text-align: left; }

/* =============================================================================
 *  登入頁
 * ===========================================================================*/
.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}
.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px 28px;
}
.login-title { margin: 0 0 4px; font-size: 20px; }
.login-sub { margin: 0 0 22px; color: var(--text-mute); font-size: 12.5px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--text-mute); line-height: 1.7; }

/* =============================================================================
 *  共用頂部工具列
 * ===========================================================================*/
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 54px;
    padding: 0 14px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.brand-text { font-size: 15px; }

.topbar-search { flex: 1; display: flex; align-items: center; gap: 4px; max-width: 420px; }
.topbar-search input { height: 34px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.seg {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.seg-btn {
    padding: 6px 13px;
    border: none;
    background: var(--bg-panel);
    color: var(--text-soft);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: var(--bg-hover); }
.seg-btn.is-active { background: var(--accent); color: #fff; }

/* =============================================================================
 *  閱讀介面：三欄版面
 * ===========================================================================*/
/**
 * 閱讀頁採用「上下彈性配置」：頂部工具列高度自動，其餘空間全給三欄區。
 * 如此即使工具列因換行而變高（手機版），版面也不會被截斷或產生多餘捲軸。
 */
.page-reader {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.page-reader .topbar { flex: none; }

.layout {
    display: grid;
    grid-template-columns: 262px 380px 1fr;
    flex: 1;
    min-height: 0;   /* 允許子項目內部自行捲動，而非撐開整個版面 */
}

/* ------------------------- 左欄 ------------------------- */
.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 10px 0;
}
.sidebar-section { padding: 0 8px 8px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-icon { width: 16px; text-align: center; color: var(--text-mute); flex: none; }
.nav-item.is-active .nav-icon { color: var(--accent); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
    flex: none;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 9px;
    background: var(--bg-soft);
    color: var(--text-mute);
    font-size: 11px;
    text-align: center;
}
.nav-count.is-zero { visibility: hidden; }

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px 6px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--text-mute);
    text-transform: uppercase;
    border-top: 1px solid var(--border-soft);
}
.link-mini { font-size: 11.5px; font-weight: 600; text-transform: none; letter-spacing: 0; }

.sidebar-tree { flex: 1; padding: 0 8px; }

.tree-group { margin-bottom: 2px; }
.tree-group-row { display: flex; align-items: center; }
.tree-toggle {
    width: 20px; height: 26px;
    border: none; background: transparent;
    color: var(--text-mute); cursor: pointer;
    font-size: 10px; flex: none;
}
.tree-children { padding-left: 18px; }
.tree-children[hidden] { display: none; }

.sidebar-foot {
    padding: 10px 18px 4px;
    border-top: 1px solid var(--border-soft);
    font-size: 11px;
    color: var(--text-mute);
}
.foot-line { margin-bottom: 2px; }

/* ------------------------- 中欄 ------------------------- */
.listpane {
    background: var(--bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.listpane-head {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.listpane-title { margin: 0; font-size: 15px; font-weight: 700; }
.listpane-meta { font-size: 12px; color: var(--text-mute); }

.list { flex: 1; }

.list-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-bottom: 1px solid var(--border-soft);
    border-left: 3px solid transparent;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.is-active { background: var(--accent-soft); border-left-color: var(--accent); }
.list-item.is-read .list-item-title { font-weight: 400; color: var(--text-soft); }
.list-item.is-read .list-item-excerpt { color: var(--text-mute); }

.list-item-top {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    font-size: 11.5px;
    color: var(--text-mute);
}
.list-item-source {
    color: var(--accent);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55%;
}
.list-item-dot { opacity: .5; }
.list-item-star { margin-left: auto; color: var(--star); }

.list-item-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.list-item-excerpt {
    font-size: 12.5px;
    color: var(--text-soft);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.list-more { padding: 12px 16px 24px; }

/* ------------------------- 右欄 ------------------------- */
.readpane {
    background: var(--bg-panel);
    overflow-y: auto;
}
.readpane-empty {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-mute);
}
.readpane-empty-icon { font-size: 40px; margin-bottom: 10px; text-align: center; }

.article { max-width: 760px; margin: 0 auto; padding: 22px 34px 80px; }

.article-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
}
#btnStar.is-on { color: var(--star); border-color: var(--star); }

.article-title { margin: 0 0 8px; font-size: 23px; line-height: 1.4; font-weight: 800; }
.article-meta { font-size: 12.5px; color: var(--text-mute); margin-bottom: 20px; }

.article-body { font-size: 15px; line-height: 1.85; word-wrap: break-word; }
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 12px 0; }
.article-body p { margin: 0 0 1em; }
.article-body h1, .article-body h2, .article-body h3,
.article-body h4, .article-body h5, .article-body h6 { margin: 1.6em 0 .6em; line-height: 1.4; }
.article-body ul, .article-body ol { padding-left: 1.6em; margin: 0 0 1em; }
.article-body blockquote {
    margin: 1em 0;
    padding: 6px 16px;
    border-left: 3px solid var(--border);
    color: var(--text-soft);
    background: var(--bg-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-body pre {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 13px;
}
.article-body table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: 13.5px; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.article-body th { background: var(--bg-soft); }
.article-body figure { margin: 1em 0; }
.article-body figcaption { font-size: 12.5px; color: var(--text-mute); text-align: center; margin-top: 6px; }

/* =============================================================================
 *  管理介面
 * ===========================================================================*/
.page-manage { background: var(--bg); }
.manage-wrap { max-width: 1180px; margin: 0 auto; padding: 22px 18px 80px; }

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 20px;
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 16px; }
.card-desc { margin: 0 0 16px; font-size: 12.8px; color: var(--text-soft); line-height: 1.7; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
.table th, .table td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table th { background: var(--bg-soft); font-size: 12px; color: var(--text-soft); font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-hover); }
.td-empty { text-align: center; color: var(--text-mute); padding: 22px; }
.td-actions { white-space: nowrap; }
.td-actions .btn + .btn { margin-left: 4px; }
.td-url { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.row-disabled { opacity: .55; }
.row-error-detail td { font-size: 12px; color: var(--danger); background: var(--danger-soft); padding-top: 4px; padding-bottom: 6px; }

.url-cell { display: flex; align-items: center; gap: 6px; }
.url-input { font-size: 12px; padding: 5px 8px; font-family: ui-monospace, Menlo, Consolas, monospace; }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 9px;
    font-size: 11px;
    background: var(--bg-soft);
    color: var(--text-mute);
    white-space: nowrap;
}
.tag-ok  { background: var(--ok-soft);     color: var(--ok); }
.tag-err { background: var(--danger-soft); color: var(--danger); }
.tag-off { background: var(--bg-soft);     color: var(--warn); margin-left: 6px; }

.group-block { margin-bottom: 22px; }
.group-title {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 8px; font-size: 13.5px; color: var(--text-soft);
}
.group-count {
    padding: 0 7px; border-radius: 9px;
    background: var(--bg-soft); color: var(--text-mute); font-size: 11px; font-weight: 400;
}

.hint-box {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    margin-top: 14px;
    font-size: 12.5px;
    line-height: 1.8;
}
.hint-box ul { margin: 6px 0 0; padding-left: 20px; }
.hint-box p  { margin: 5px 0 0; }
.hint-box li { margin-bottom: 5px; }
/*
 * 僅「直接位於 hint-box 之下」的 strong 才當作小標題獨立成行。
 * 若寫成 .hint-box strong，會連句子中、清單項目中的行內粗體字一併變成區塊元素，
 * 造成句子在粗體字前後被強制斷行。
 */
.hint-box > strong { display: block; margin-top: 10px; }
.hint-box > strong:first-child { margin-top: 0; }

.code-block {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    margin: 6px 0 10px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.cron-status {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    font-size: 12.5px;
}

.inline-form { padding: 4px 0; }
.test-result { font-size: 12.5px; line-height: 1.7; }
.test-result.ok  { color: var(--ok); }
.test-result.err { color: var(--danger); }

/* ----------------------- 來源健康檢查 ----------------------- */
.check-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.check-progress {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-soft);
    overflow: hidden;
}
.check-progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .25s ease;
}
.check-status { font-size: 12.5px; color: var(--text-soft); white-space: nowrap; }

.check-url {
    font-size: 11.5px;
    color: var(--text-mute);
    word-break: break-all;
    margin-top: 2px;
}
.check-note { font-size: 12.5px; line-height: 1.65; }
.check-note code { display: inline-block; margin-top: 3px; }
.check-err  { color: var(--danger); }
.check-hint { color: var(--text-soft); margin-top: 3px; }

.row-check-fail  td { background: var(--danger-soft); }
.row-check-moved td { background: var(--warn-soft); }

.row-suggest-detail td {
    font-size: 12.5px;
    background: var(--warn-soft);
    color: var(--text);
    padding-top: 6px;
    padding-bottom: 8px;
}

.tag-warn { background: var(--warn-soft); color: var(--warn); }

.env-summary { display: flex; gap: 6px; }
.td-note { font-size: 12.5px; line-height: 1.7; }

/* 區塊型核取方塊（含補充說明） */
.field-check-block {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 4px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
}
.field-check-block input { margin-top: 3px; }
.field-note {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-soft);
    line-height: 1.65;
}

/* =============================================================================
 *  v1.2 新增樣式
 * ===========================================================================*/

/* ----------------------- 文章內的影片嵌入 ----------------------- */

/*
 * 以 aspect-ratio 維持 16:9，使嵌入影片在任何寬度下都不變形。
 * 較舊的瀏覽器不支援 aspect-ratio，故另以 padding-top 作為後備方案。
 */
.article-body .embed-box {
    position: relative;
    width: 100%;
    margin: 1.2em 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9;
}
@supports not (aspect-ratio: 16 / 9) {
    .article-body .embed-box { height: 0; padding-top: 56.25%; }
}
.article-body .embed-box iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.article-body video,
.article-body audio {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 1.2em 0;
    border-radius: var(--radius-sm);
    background: #000;
}
.article-body audio { background: transparent; }

/* ----------------------- 內容來源狀態列 ----------------------- */
.article-source {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    font-size: 12.5px;
    color: var(--text-soft);
}
.article-source.is-full {
    border-color: var(--ok);
    background: var(--ok-soft);
}
.article-source.is-full .source-label { color: var(--ok); font-weight: 600; }
.source-label { flex: 1; min-width: 140px; }
.source-btn {
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-panel);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.source-btn:hover { background: var(--bg-hover); }
.source-error {
    flex-basis: 100%;
    margin-top: 2px;
    color: var(--danger);
    line-height: 1.6;
}

/* ----------------------- PWA 提示列 ----------------------- */
.install-bar {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 85;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 92vw;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: var(--bg-panel);
    box-shadow: var(--shadow);
    font-size: 13px;
}

/*
 * 離線提示列。
 *
 * 刻意「不」使用 position: fixed —— 固定定位會浮在版面之上，
 * 遮住下方的文章列表標題。改為插入 body 的最前方並參與正常排版，
 * 閱讀頁的縱向彈性版面會自動把其餘內容往下推，不會有任何遮擋。
 */
.offline-bar {
    flex: none;
    padding: 6px 12px;
    background: var(--warn);
    color: #fff;
    font-size: 12.5px;
    text-align: center;
}

/* ----------------------- 儲存空間管理 ----------------------- */
.usage-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}
.usage-chip:hover { background: var(--bg-hover); text-decoration: none; }
.usage-chip-label { color: var(--text-mute); }
.usage-chip-num { font-weight: 700; font-size: 13px; }

.usage-total {
    padding: 18px 20px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    text-align: center;
}
.usage-total-sm { padding: 12px 16px; }
.usage-total-num { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.usage-total-sm .usage-total-num { font-size: 20px; }
.usage-total-label { margin-top: 3px; font-size: 12.5px; color: var(--text-soft); }

.usage-bar {
    display: flex;
    height: 14px;
    margin-bottom: 16px;
    border-radius: 7px;
    overflow: hidden;
    background: var(--bg-soft);
}
.usage-seg { height: 100%; }

.usage-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-radius: 50%;
    vertical-align: baseline;
}

/* 各類別的代表色 */
.usage-c1 { background: #2f6fed; }
.usage-c2 { background: #1f9254; }
.usage-c3 { background: #b4741a; }
.usage-c4 { background: #8a99a8; }
.usage-c5 { background: #a05ad6; }

.usage-note { margin-left: 8px; font-size: 12px; color: var(--text-mute); }

.purge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 14px;
}
.purge-item {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
}
.purge-item h3 { margin: 0 0 6px; font-size: 13.5px; }
.purge-item p {
    margin: 0 0 12px;
    font-size: 12.3px;
    color: var(--text-soft);
    line-height: 1.7;
}
.purge-item.purge-danger { border-color: var(--danger); }
.purge-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.purge-inline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.purge-num { width: 72px; padding: 5px 8px; font-size: 12.5px; }
.inline-post { display: inline; }

/* ----------------------- 診斷頁 ----------------------- */
.diag-result { margin-top: 18px; }
.diag-step {
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    margin-bottom: 10px;
    background: var(--bg-panel);
}
.diag-step-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.diag-step-body { margin-top: 5px; font-size: 12.8px; line-height: 1.7; word-break: break-all; }
.diag-step-extra {
    margin: 8px 0 0;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: inherit;
}
.diag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    flex: none;
}
.diag-ok    { border-left-color: var(--ok); }
.diag-ok    .diag-icon { background: var(--ok); }
.diag-warn  { border-left-color: var(--warn); }
.diag-warn  .diag-icon { background: var(--warn); }
.diag-error { border-left-color: var(--danger); }
.diag-error .diag-icon { background: var(--danger); }

/* =============================================================================
 *  對話框、提示訊息、遮罩
 * ===========================================================================*/
.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(12, 20, 30, .55);
}
.modal[hidden] { display: none; }
.modal-box {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
}
.modal-title { margin: 0 0 18px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 90;
    max-width: 88vw;
    padding: 10px 18px;
    border-radius: 22px;
    background: #1d2733;
    color: #fff;
    font-size: 13px;
    box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }
.toast.is-error { background: var(--danger); }

.overlay {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(12, 20, 30, .45);
}
.overlay[hidden] { display: none; }
.overlay-box {
    background: var(--bg-panel);
    border-radius: var(--radius);
    padding: 24px 34px;
    text-align: center;
    box-shadow: var(--shadow);
}
.overlay-text { margin-top: 12px; font-size: 13px; color: var(--text-soft); }

.spinner {
    width: 30px;
    height: 30px;
    margin: 0 auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================
 *  響應式（Responsive）調整
 * ===========================================================================*/
.only-mobile { display: none; }

@media (max-width: 1100px) {
    .layout { grid-template-columns: 232px 340px 1fr; }
    .article { padding: 20px 24px 70px; }
}

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; position: relative; }

    .sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow);
    }
    .sidebar.is-open { transform: translateX(0); }

    .listpane { border-right: none; }

    .readpane {
        position: absolute;
        inset: 0;
        z-index: 20;
        transform: translateX(100%);
        transition: transform .22s ease;
    }
    .readpane.is-open { transform: translateX(0); }

    .only-mobile { display: inline-flex; }
    .topbar-search { max-width: none; }
    .topbar-actions .seg { display: none; }
    .topbar-actions .btn { padding: 6px 10px; font-size: 12px; }

    .row-2, .row-3 { grid-template-columns: 1fr; }
    .manage-wrap { padding: 16px 12px 60px; }
    .card { padding: 16px 14px; }
}

@media (max-width: 560px) {
    .topbar { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 8px; }

    /* 搜尋框強制獨占一整列，避免與按鈕互相擠壓 */
    .topbar-search {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        max-width: none;
    }
    .topbar-actions { margin-left: auto; gap: 6px; }

    .article { padding: 16px 14px 60px; }
    .article-title { font-size: 19px; }
}
