/* ============================================================
   code.novice.tw ｜ 故障碼初心者
   精練・高密度・手機優先：暖白底、深藍、細線、低陰影
   ============================================================ */

:root {
    --bg:        #f8f8f6;
    --bg-soft:   #f1f1ed;
    --card:      #ffffff;
    --ink:       #14181d;
    --ink-2:     #454c54;
    --ink-3:     #7c848d;
    --navy:      #16324f;
    --navy-2:    #0f2740;
    --brass:     #8a6a2f;
    --line:      rgba(20, 24, 29, .13);
    --line-2:    rgba(20, 24, 29, .07);
    --amber:     #9a6206;
    --amber-bg:  #fbf4e2;
    --red:       #b42318;
    --red-bg:    #fdecea;
    --green:     #176149;
    --green-bg:  #e9f5ee;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC",
            "Hiragino Sans TC", "Microsoft JhengHei", Roboto, sans-serif;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --max: 1120px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15.5px;
    line-height: 1.66;
    letter-spacing: .005em;
    padding-top: 52px;
}

img { max-width: 100%; height: auto; }

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--navy-2); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { line-height: 1.32; letter-spacing: -.015em; margin: 0 0 .45em; font-weight: 750; }
h1 { font-size: clamp(1.42rem, 3.2vw, 1.95rem); }
h2 { font-size: clamp(1.08rem, 2.1vw, 1.28rem); }
h3 { font-size: 1rem; }

p { margin: 0 0 .9em; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--ink-3); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 200;
    background: var(--navy); color: #fff; padding: .7rem 1.1rem;
}
.skip-link:focus { left: 12px; top: 8px; }

/* ---------- 頂欄 ---------- */
.topbar {
    position: fixed; inset: 0 0 auto 0; z-index: 100;
    height: 52px;
    background: rgba(248, 248, 246, .92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-inner {
    max-width: var(--max); margin: 0 auto; height: 100%;
    padding: 0 20px; display: flex; align-items: center; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink); flex: 0 0 auto; min-height: 40px; }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
    width: 23px; height: 23px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--navy); color: #fff;
    font-family: var(--mono); font-weight: 700; font-size: 14px;
}
.brand-text { font-weight: 800; font-size: .99rem; letter-spacing: .01em; }
.brand-text em { font-style: normal; color: var(--navy); }

.topnav { display: flex; align-items: center; gap: 1px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.topnav-link {
    padding: .34rem .55rem; border-radius: 7px;
    color: var(--ink-2); font-size: .88rem; font-weight: 600; white-space: nowrap;
}
.topnav-link:hover { background: var(--bg-soft); color: var(--navy); text-decoration: none; }
.topnav-link.is-active { color: var(--navy); background: rgba(22, 50, 79, .08); }

.topsearch { flex: 0 0 auto; display: flex; align-items: center; }
.topsearch input {
    width: 176px; height: 34px;
    padding: 0 .6rem 0 .75rem;
    border: 1px solid var(--line); border-right: 0;
    border-radius: 8px 0 0 8px;
    background: #fff; color: var(--ink); font-size: .85rem; font-family: inherit;
}
.topsearch input:focus { outline: none; border-color: rgba(22,50,79,.45); }
.topsearch button {
    height: 34px; width: 36px; border: 1px solid var(--line); border-left: 0;
    border-radius: 0 8px 8px 0; background: #fff; color: var(--navy);
    cursor: pointer; font-size: .8rem;
}
.topsearch button:hover { background: var(--bg-soft); }

/* ---------- 麵包屑 ---------- */
.crumbs { border-bottom: 1px solid var(--line-2); background: rgba(255,255,255,.55); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; margin: 0; padding: .42rem 0; font-size: .78rem; color: var(--ink-3); }
.crumbs li + li::before { content: "/"; margin-right: .35rem; color: var(--line); }
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--navy); }
.crumbs [aria-current] { color: var(--ink-2); font-weight: 600; }

/* ---------- 首頁主視覺 ---------- */
.hero {
    padding: 30px 0 24px;
    background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--line);
}
.hero-kicker {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .7rem; font-weight: 700; letter-spacing: .14em;
    color: var(--brass); text-transform: uppercase; margin-bottom: .55rem;
}
.hero h1 { max-width: 22em; margin-bottom: .4rem; }
.hero h1 span { color: var(--navy); }
.hero-lead { max-width: 44em; color: var(--ink-2); font-size: .97rem; margin-bottom: 1.05rem; }
.hero-stats {
    display: flex; flex-wrap: wrap; gap: 0; margin-top: 1rem;
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden;
}
.hero-stat { flex: 1 1 0; min-width: 108px; padding: .55rem .85rem; }
.hero-stat + .hero-stat { border-left: 1px solid var(--line-2); }
.hero-stat b { display: inline; font-size: 1.12rem; line-height: 1.2; font-family: var(--mono); color: var(--navy); margin-right: .35rem; }
.hero-stat span { font-size: .78rem; color: var(--ink-3); }

/* ---------- 搜尋框 ---------- */
.searchbox { display: flex; max-width: 620px; }
.searchbox input {
    flex: 1 1 auto; min-width: 0; height: 44px;
    padding: 0 .9rem; font-size: .94rem; font-family: inherit;
    border: 1px solid rgba(22,50,79,.35); border-right: 0;
    border-radius: 9px 0 0 9px; background: #fff; color: var(--ink);
}
.searchbox input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(22,50,79,.12); }
.searchbox button {
    flex: 0 0 auto; height: 44px; padding: 0 1.05rem;
    border: 1px solid var(--navy); border-radius: 0 9px 9px 0;
    background: var(--navy); color: #fff; font-family: inherit; font-size: .9rem; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.searchbox button:hover { background: var(--navy-2); }
.searchbox-lg input, .searchbox-lg button { height: 46px; }
.hero-hints { margin-top: .55rem; font-size: .8rem; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: .3rem .75rem; }
.hero-hints a { color: var(--ink-2); font-family: var(--mono); font-size: .8rem; }

/* ---------- 區塊 ---------- */
.section { padding: 26px 0; }
.section + .section { border-top: 1px solid var(--line-2); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .more { font-size: .84rem; font-weight: 600; color: var(--navy); white-space: nowrap; }
.section-lead { color: var(--ink-2); max-width: 46em; margin-top: -.2rem; font-size: .93rem; }

/* ---------- 代碼晶片 ---------- */
.code-chip {
    display: inline-block; font-family: var(--mono); font-weight: 700;
    font-size: .82rem; letter-spacing: .02em;
    padding: .13rem .48rem; border-radius: 5px;
    background: rgba(22,50,79,.07); color: var(--navy);
    border: 1px solid rgba(22,50,79,.14);
    white-space: nowrap;
}
a.code-chip:hover { background: var(--navy); color: #fff; text-decoration: none; border-color: var(--navy); }
.code-chip-lg { font-size: 1rem; padding: .26rem .65rem; }

/* ---------- 嚴重度 ---------- */
.sev {
    display: inline-block; font-size: .7rem; font-weight: 700;
    padding: .1rem .42rem; border-radius: 999px; white-space: nowrap;
}
.sev-1 { background: var(--green-bg); color: var(--green); }
.sev-2 { background: var(--amber-bg); color: var(--amber); }
.sev-3 { background: var(--red-bg); color: var(--red); }

/* ---------- 速查表 ---------- */
.quicktable-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
.quicktable { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 540px; }
.quicktable th {
    text-align: left; font-size: .7rem; letter-spacing: .07em;
    color: var(--ink-3); font-weight: 700;
    padding: .52rem .8rem; background: var(--bg-soft); border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.quicktable td { padding: .5rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.quicktable tr:last-child td { border-bottom: 0; }
.quicktable tr:hover td { background: #fcfcfa; }
.qt-name a { font-weight: 650; color: var(--ink); }
.qt-name a:hover { color: var(--navy); }
.qt-sub { display: block; font-size: .76rem; color: var(--ink-3); margin-top: .05rem; font-weight: 400; line-height: 1.45; }
.qt-dev, .qt-part { color: var(--ink-2); font-size: .82rem; white-space: nowrap; }

/* ---------- 卡片網格 ---------- */
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.device-card {
    display: flex; align-items: center; gap: .75rem;
    padding: .72rem .85rem; min-height: 56px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); color: var(--ink);
    transition: border-color .15s ease;
}
.device-card:hover { text-decoration: none; border-color: rgba(22,50,79,.32); }
.dc-icon {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(22,50,79,.07); color: var(--navy); font-size: .94rem;
}
.dc-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.dc-name { font-weight: 700; font-size: .94rem; line-height: 1.35; }
.dc-desc { font-size: .76rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-count { flex: 0 0 auto; font-family: var(--mono); font-size: 1.02rem; font-weight: 700; color: var(--navy); }
.dc-count em { font-style: normal; font-size: .66rem; color: var(--ink-3); margin-left: .1rem; font-family: var(--sans); }

.code-card {
    display: block; padding: .78rem .85rem;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); color: var(--ink);
    transition: border-color .15s ease;
}
.code-card:hover { text-decoration: none; border-color: rgba(22,50,79,.32); }
.cc-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .42rem; }
.cc-name { font-weight: 700; font-size: .93rem; margin-bottom: .08rem; line-height: 1.4; }
.cc-meta { font-size: .74rem; color: var(--ink-3); }
.cc-sum { font-size: .8rem; color: var(--ink-2); margin: .38rem 0 0; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 品牌 ---------- */
.brandgrid { display: flex; flex-wrap: wrap; gap: .4rem; }
.brandpill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .32rem .68rem; border-radius: 999px; min-height: 30px;
    background: #fff; border: 1px solid var(--line);
    font-size: .83rem; font-weight: 600; color: var(--ink);
}
.brandpill:hover { text-decoration: none; border-color: rgba(22,50,79,.32); color: var(--navy); }
.brandpill b { font-family: var(--mono); font-size: .76rem; color: var(--ink-3); font-weight: 700; }

/* ---------- 系列分流 ---------- */
/* 資料等級徽章：四級四色，低調但看得懂 */
.srclv {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .7rem; font-weight: 700; letter-spacing: .02em;
    padding: .16rem .48rem; border-radius: 999px; white-space: nowrap;
    border: 1px solid transparent;
}
.srclv b { font-family: var(--mono); font-weight: 700; }
.lv-official    { background: #eef4ec; color: #2c5b3a; border-color: rgba(44,91,58,.22); }
.lv-platform    { background: #eef1f7; color: #2d456e; border-color: rgba(45,69,110,.22); }
.lv-service     { background: #f5f3ec; color: #6b5a2e; border-color: rgba(107,90,46,.22); }
.lv-circulating { background: #f4f0f0; color: #7a4a44; border-color: rgba(122,74,68,.22); }
.srclv-link, .srclv-link:hover { text-decoration: none; }

.level-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .55rem; }
.ls-label { font-size: .72rem; color: var(--ink-3); letter-spacing: .06em; margin-right: .1rem; }

.source-block {
    margin-top: 1.4rem; padding: .9rem 1rem;
    background: var(--card); border: 1px solid var(--line);
    border-left: 3px solid var(--navy); border-radius: var(--radius);
}
.sb-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.sb-head h3 { margin: 0; font-size: .95rem; }
.sb-meta { display: grid; grid-template-columns: 4.4rem 1fr; gap: .18rem .6rem; margin: 0 0 .55rem; font-size: .86rem; }
.sb-meta dt { color: var(--ink-3); font-size: .78rem; padding-top: .1rem; }
.sb-meta dd { margin: 0; color: var(--ink); }
.sb-note { font-size: .85rem; color: var(--ink-2); margin: 0 0 .5rem; }
.sb-hint { font-size: .8rem; color: var(--ink-3); margin: 0 0 .35rem; }
.sb-link { margin: 0; font-size: .84rem; }
@media (max-width: 768px) {
    .sb-meta { grid-template-columns: 1fr; gap: 0; }
    .sb-meta dt { margin-top: .35rem; }
    .source-block { padding: .8rem .85rem; }
}

.series-guide { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.series-guide + .series-guide { margin-top: 14px; }
.series-head { padding: .85rem 1rem .7rem; border-bottom: 1px solid var(--line-2); background: linear-gradient(180deg, #fff, #fcfcfa); }
.series-head h3 { margin: 0 0 .3rem; font-size: 1rem; }
.series-head p { margin: 0; font-size: .88rem; color: var(--ink-2); }
.series-identify { padding: .7rem 1rem; border-bottom: 1px solid var(--line-2); }
.series-identify h4 { font-size: .8rem; letter-spacing: .06em; color: var(--brass); margin-bottom: .4rem; }
.series-identify ol { margin: 0; padding-left: 1.15rem; font-size: .86rem; color: var(--ink-2); }
.series-identify li { margin-bottom: .22rem; }
.series-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.series-table { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 680px; }
.series-table th { text-align: left; font-size: .7rem; letter-spacing: .06em; color: var(--ink-3); padding: .5rem .8rem; background: var(--bg-soft); border-bottom: 1px solid var(--line); white-space: nowrap; }
.series-table td { padding: .55rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.series-table tr:last-child td { border-bottom: 0; }
.series-name { font-weight: 700; white-space: nowrap; }
.series-level { font-size: .72rem; font-weight: 700; padding: .08rem .4rem; border-radius: 999px; background: rgba(138,106,47,.1); color: var(--brass); white-space: nowrap; }
.series-note { padding: .6rem 1rem .8rem; font-size: .78rem; color: var(--ink-3); }

/* ---------- 代碼詳情頁 ---------- */
.code-head { padding: 20px 0 18px; border-bottom: 1px solid var(--line); background: #fff; }
.code-badges { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .6rem; }
.code-head h1 { margin-bottom: .3rem; }
.code-head h1 .h1-code { font-family: var(--mono); color: var(--navy); }
.code-sub { color: var(--ink-2); max-width: 48em; margin: 0; font-size: .95rem; }
.code-meta-line { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .78rem; color: var(--ink-3); margin-top: .65rem; }
.code-meta-line b { color: var(--ink-2); font-weight: 600; }

/* 第一屏速答條 */
.quick-answer {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0;
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
    overflow: hidden; margin-top: 14px; box-shadow: var(--shadow);
}
.qa-cell { padding: .6rem .8rem; min-width: 0; }
.qa-cell + .qa-cell { border-left: 1px solid var(--line-2); }
.qa-label { font-size: .68rem; font-weight: 700; letter-spacing: .09em; color: var(--brass); text-transform: uppercase; margin-bottom: .18rem; }
.qa-value { font-size: .88rem; font-weight: 650; color: var(--ink); line-height: 1.45; }
.qa-value small { display: block; font-weight: 400; color: var(--ink-3); font-size: .78rem; }

.code-layout { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: 34px; padding: 22px 0 6px; align-items: start; }
.code-main > section { margin-bottom: 1.7rem; scroll-margin-top: 64px; }
/* 首頁被 #devices 錨點跳到時，不要被固定頂欄蓋住 */
.section[id] { scroll-margin-top: 64px; }
.code-main h2 { display: flex; align-items: center; gap: .5rem; }
.code-main h2 .num {
    font-family: var(--mono); font-size: .7rem; font-weight: 700;
    width: 21px; height: 21px; border-radius: 6px; flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(22,50,79,.08); color: var(--navy);
}
.meaning { font-size: .99rem; color: var(--ink); }

.callout {
    border-left: 3px solid var(--amber);
    background: var(--amber-bg);
    padding: .68rem .85rem; border-radius: 0 8px 8px 0;
    font-size: .88rem; color: #6b4a06; margin: .8rem 0;
}
.callout.is-danger { border-color: var(--red); background: var(--red-bg); color: #7a1c13; }
.callout.is-info { border-color: var(--navy); background: rgba(22,50,79,.055); color: var(--navy-2); }
.callout b { font-weight: 700; }

/* 原因清單 */
.causes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cause {
    display: grid; grid-template-columns: 30px minmax(0,1fr); gap: .7rem;
    padding: .68rem .85rem; background: var(--card);
    border: 1px solid var(--line); border-radius: 9px;
}
.cause-rank { font-family: var(--mono); font-weight: 700; color: var(--navy); font-size: .9rem; opacity: .65; }
.cause-t { font-weight: 700; margin-bottom: .12rem; font-size: .93rem; }
.cause-k { font-size: .84rem; color: var(--ink-2); }
.cause-p { font-size: .7rem; font-weight: 700; padding: .04rem .38rem; border-radius: 999px; background: var(--bg-soft); color: var(--ink-2); margin-left: .35rem; vertical-align: .1em; white-space: nowrap; }

/* 步驟 */
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.step { position: relative; padding: 0 0 1.05rem 2.35rem; counter-increment: step; }
.step::before {
    content: counter(step);
    position: absolute; left: 0; top: 0;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--navy); color: #fff;
    font-family: var(--mono); font-size: .8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.step::after {
    content: ""; position: absolute; left: 12.5px; top: 30px; bottom: 3px;
    width: 1px; background: var(--line);
}
.step:last-child { padding-bottom: 0; }
.step:last-child::after { display: none; }
.step-t { font-weight: 700; margin-bottom: .15rem; font-size: .94rem; }
.step-d { font-size: .9rem; color: var(--ink-2); }

/* 重置 */
.resetbox {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow);
}
.resetbox ol { margin: 0; padding-left: 1.15rem; }
.resetbox li { margin-bottom: .32rem; font-size: .9rem; color: var(--ink-2); }
.resetbox li:last-child { margin-bottom: 0; }

/* 零件／工具 */
.parts { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.part {
    display: flex; gap: .65rem; align-items: baseline;
    padding: .58rem .8rem; background: var(--card);
    border: 1px solid var(--line); border-radius: 9px; font-size: .88rem;
}
.part-n { font-weight: 700; white-space: nowrap; }
.part-w { color: var(--ink-2); font-size: .84rem; }
.toolrow { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; align-items: center; }
.tool { font-size: .78rem; padding: .16rem .5rem; border-radius: 5px; background: var(--bg-soft); color: var(--ink-2); border: 1px solid var(--line-2); }

/* FAQ */
.faq { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.faq-item + .faq-item { border-top: 1px solid var(--line-2); }
.faq-item summary {
    cursor: pointer; padding: .72rem 1rem; font-weight: 600; font-size: .92rem;
    list-style: none; position: relative; padding-right: 2.1rem; min-height: 44px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: "+"; position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
    font-family: var(--mono); font-size: 1rem; color: var(--ink-3);
}
.faq-item[open] summary::after { content: "−"; }
.faq-a { padding: 0 1rem .85rem; font-size: .88rem; color: var(--ink-2); }

/* 側欄 */
.code-side { position: sticky; top: 66px; display: grid; gap: 12px; }
.side-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .85rem .95rem; box-shadow: var(--shadow);
}
.side-card h3 { font-size: .88rem; margin-bottom: .5rem; }
.side-card ul { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.side-card li { padding: .3rem 0; border-bottom: 1px dashed var(--line-2); display: flex; gap: .5rem; align-items: baseline; }
.side-card li:last-child { border-bottom: 0; }
.side-card li b { font-family: var(--mono); color: var(--navy); font-size: .8rem; flex: 0 0 auto; }
.toc a { color: var(--ink-2); font-size: .85rem; }
.toc a:hover { color: var(--navy); }

/* 標籤牆 */
.tagcloud { display: flex; flex-wrap: wrap; gap: .38rem; }
.tag {
    font-size: .8rem; padding: .26rem .58rem; border-radius: 7px;
    background: #fff; border: 1px solid var(--line); color: var(--ink-2);
}
.tag b { font-family: var(--mono); color: var(--navy); margin-right: .15rem; }
.tag:hover { text-decoration: none; border-color: rgba(22,50,79,.32); color: var(--navy); }

/* 空狀態 */
.empty-state { text-align: center; padding: 48px 0 56px; max-width: 520px; margin: 0 auto; }
.empty-icon { font-size: 1.8rem; color: var(--ink-3); margin-bottom: .8rem; }
.empty-actions { display: flex; gap: .55rem; justify-content: center; flex-wrap: wrap; margin-top: 1.1rem; }

/* 按鈕 */
.btn {
    display: inline-flex; align-items: center; gap: .4rem; min-height: 38px;
    padding: .48rem .9rem; border-radius: 8px; font-size: .88rem; font-weight: 700;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.btn:hover { text-decoration: none; border-color: rgba(22,50,79,.32); color: var(--navy); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); color: #fff; }

/* 廣告／提示條 */
.notice {
    font-size: .8rem; color: var(--ink-3);
    border: 1px dashed var(--line); border-radius: 9px;
    padding: .6rem .8rem; background: rgba(255,255,255,.7);
}

/* ---------- 葉尾 ---------- */
.sitefoot { margin-top: 38px; background: #12161b; color: #cfd3d8; padding: 30px 0 18px; }
.sitefoot a { color: #e8eaee; }
.sitefoot a:hover { color: #fff; }
.foot-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 28px; }
.foot-title { display: flex; align-items: center; gap: .5rem; font-weight: 800; color: #fff; font-size: .98rem; margin-bottom: .55rem; }
.foot-desc { font-size: .84rem; line-height: 1.68; color: #a9b0b8; margin-bottom: .65rem; }
.foot-note { font-size: .74rem; color: #7f868e; }
.foot-col h2 { font-size: .8rem; color: #fff; letter-spacing: .04em; margin-bottom: .6rem; }
.foot-col ul { list-style: none; margin: 0; padding: 0; font-size: .83rem; }
.foot-col li { margin-bottom: .32rem; }
.foot-bottom {
    display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; justify-content: space-between;
    margin-top: 24px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12);
    font-size: .76rem; color: #8f969e;
}
.foot-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ---------- 手機底部導覽 ---------- */
.mnav { display: none; }

@media (max-width: 1000px) {
    .code-layout { grid-template-columns: minmax(0, 1fr); gap: 22px; }
    .code-side { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .code-side .toc { grid-column: 1 / -1; }
    .foot-grid { grid-template-columns: 1fr 1fr; gap: 22px; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 8 個分類在 768～1080px 會擠，先把字距與搜尋框收窄，避免最後一項被裁掉 */
@media (max-width: 1080px) and (min-width: 768px) {
    .topnav-link { padding: .32rem .4rem; font-size: .82rem; }
    .topsearch input { width: 118px; }
}

@media (max-width: 767.98px) {
    body { padding-top: 48px; padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); font-size: 15px; }
    .wrap { padding: 0 14px; }
    .topbar { height: 48px; }
    .topbar-inner { padding: 0 12px; gap: 8px; }
    .topnav { display: none; }    .brand-text { font-size: .92rem; }
    .topsearch { margin-left: auto; }
    .topsearch input { width: 108px; height: 32px; font-size: .82rem; }
    .topsearch button { height: 32px; width: 33px; }
    .crumbs ol { padding: .38rem 0; font-size: .74rem; }
    .hero { padding: 20px 0 18px; }
    .hero-lead { font-size: .9rem; margin-bottom: .85rem; }
    .hero-stats { margin-top: .8rem; }
    .hero-stat { min-width: 0; padding: .42rem .55rem; }
    .hero-stat b { font-size: .95rem; margin-right: .2rem; }
    .hero-stat span { font-size: .7rem; display: block; }
    .searchbox { max-width: none; }
    .searchbox input { height: 42px; font-size: .9rem; padding: 0 .75rem; }
    .searchbox button { height: 42px; padding: 0 .8rem; font-size: .86rem; }
    .searchbox button span { display: none; }
    .searchbox button::after { content: "搜尋"; }
    .section { padding: 20px 0; }
    .section-head { margin-bottom: .65rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { gap: 8px; }
    /* 速查表：手機只留代碼、名稱、處理三欄，避免橫向捲動 */
    .quicktable { min-width: 0; font-size: .85rem; }
    .quicktable th, .quicktable td { padding: .48rem .6rem; }
    .qt-dev, .qt-part, .quicktable th.qt-dev-h, .quicktable th.qt-part-h { display: none; }
    .code-head { padding: 16px 0 14px; }
    .quick-answer { grid-template-columns: minmax(0, 1fr); margin-top: 10px; }
    .qa-cell { padding: .5rem .7rem; }
    .qa-cell + .qa-cell { border-left: 0; border-top: 1px solid var(--line-2); }
    .code-layout { padding-top: 18px; }
    .code-side { grid-template-columns: minmax(0, 1fr); }
    .cause { grid-template-columns: 24px minmax(0,1fr); padding: .6rem .7rem; }
    .step { padding-left: 2.15rem; }
    .part { flex-wrap: wrap; gap: .2rem .6rem; }
    .part-n { white-space: normal; }
    .series-table { min-width: 0; font-size: .82rem; }
    .series-table th { display: none; }
    .series-table, .series-table tbody, .series-table tr, .series-table td { display: block; width: 100%; }
    .series-table tr { padding: .55rem .8rem; border-bottom: 1px solid var(--line-2); }
    .series-table td { padding: .12rem 0; border-bottom: 0; }
    .series-name { white-space: normal; font-size: .92rem; }
    .foot-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
    .foot-brand { grid-column: 1 / -1; }
    .sitefoot { padding-top: 24px; }
    .mnav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
        background: rgba(248,248,246,.96); backdrop-filter: blur(14px);
        border-top: 1px solid var(--line);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .mnav a {
        flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 1px;
        padding: .42rem 0 .38rem; font-size: .66rem; color: var(--ink-3); min-height: 48px; justify-content: center;
    }
    .mnav a i { font-size: .92rem; }
    .mnav a.is-active { color: var(--navy); }
    .mnav a:hover { text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; }
}

@media print {
    .topbar, .mnav, .sitefoot, .code-side { display: none; }
    body { padding: 0; background: #fff; }
}
