/* 布可掃書 v2（10-25）：照 App Store 的做法——大量留白、一次一個主要動作、字大、一個主色加灰階、次要的東西收起來 */
:root {
  --bg: #ffffff;
  --bg-2: #f5f5f7;        /* 分組底色 */
  --bg-3: #ececf0;        /* 按下去的底色 */
  --line: #e3e3e8;        /* 分隔線 */
  --ink: #1d1d1f;
  --ink-2: #6e6e73;       /* 次要文字（白底對比 5:1） */
  --ink-3: #aeaeb2;       /* 圖示、裝飾線（不放文字） */
  --accent: #d4571d;      /* 唯一的主色（圖示的橘色） */
  --accent-ink: #b5470f;  /* 主色的文字版（白底對比 5.4:1） */
  --accent-soft: #fdf0e9;
  --ok: #34c759;          /* 只用在教學圖的「掃對了」勾勾 */
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 20px rgba(0, 0, 0, .07);
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-ink); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.nb { display: inline-block; } /* 這幾個字不要拆到兩行 */
p:not(.rules-src), .sc-line, .note, .st p, .foot p, .sum-v, .tc span { text-wrap: pretty; }
h1, h2, h3 { margin: 0; }
body.sheet-open, body.page-open, body.scanning { overflow: hidden; }
/* 有抽屜、整頁、掃描畫面、結果卡開著時，後面的首頁固定不動（overlay.js 記下原本捲到哪，關掉後回去）；iPhone 只設 overflow 擋不住 */
body.scroll-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }

.wrap {
  max-width: 560px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); /* 底部留給兩顆浮動鈕 */
}

/* ---------- 加到主畫面：一條淡提示（像 iPhone 的 App 橫幅） ---------- */
.install-bar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) max(12px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.install-bar img { border-radius: 9px; flex: none; }
.ib-text { flex: 1; min-width: 0; font-size: 16px; color: var(--ink-2); line-height: 1.35; }
.ib-text b { display: block; color: var(--ink); font-weight: 600; }
.ib-add { flex: none; border: 0; border-radius: 999px; background: #fff; color: var(--accent-ink); font-size: 16px; font-weight: 700; min-height: 44px; padding: 0 16px; white-space: nowrap; box-shadow: 0 0 0 1px var(--line) inset; }
.ib-x { flex: none; border: 0; background: transparent; color: var(--ink-2); font-size: 24px; width: 44px; height: 44px; line-height: 1; }
.install-bar + .wrap { padding-top: 20px; }

/* ---------- 內建瀏覽器提示 ---------- */
.inapp { background: #fff6e5; border-radius: 14px; padding: 12px 14px; margin: 0 0 18px; }
.inapp p { margin: 0; font-size: 17px; line-height: 1.45; }
.inapp .inapp-tip { margin-top: 4px; font-size: 16px; color: #6b4a10; }
.btn-open { margin-top: 10px; width: 100%; min-height: 50px; border: 0; border-radius: 14px; background: #06c755; color: #fff; font-size: 18px; font-weight: 700; }

/* ---------- 第一屏 ---------- */
.hero { margin: 4px 0 28px; }
.hero-row { display: flex; align-items: center; gap: 14px; }
.app-icon { border-radius: 13px; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.hero-name { flex: 1; min-width: 0; }
.hero-name h1 { font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: .01em; }
.hero-tag { margin: 2px 0 0; font-size: 16px; color: var(--ink-2); }
.icon-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bg-2); color: var(--ink); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:active { background: var(--bg-3); }
.hero-lead { margin: 18px 0 0; font-size: 19px; line-height: 1.5; color: var(--ink-2); }

.btn-scan {
  width: 100%; min-height: 128px; border: 0; border-radius: 26px;
  background: var(--accent); color: #fff; font-size: 26px; font-weight: 700; letter-spacing: .06em;
  display: flex; align-items: center; justify-content: center; gap: 14px; white-space: nowrap;
  box-shadow: 0 10px 26px rgba(212, 87, 29, .28);
  transition: transform .12s ease, filter .12s ease;
}
.btn-scan svg { width: 44px; height: 44px; flex: none; }
.btn-scan:active { transform: scale(.98); filter: brightness(.94); }
.photo-link { display: flex; align-items: center; justify-content: center; min-height: 44px; margin: 8px 0 0; padding: 4px; color: var(--ink-2); font-size: 16px; cursor: pointer; }
.photo-link span { color: var(--accent-ink); }
.data-status { margin: 0; text-align: center; font-size: 16px; color: var(--ink-2); }
.data-status.warn { color: var(--accent-ink); font-weight: 600; }

/* 年級與清單摘要：兩列，像 iPhone 設定的分組 */
.summary { margin: 26px 0 0; background: var(--bg-2); border-radius: var(--radius); overflow: hidden; }
.grade-tip { margin: 10px 0 0; text-align: center; font-size: 17px; color: var(--accent-ink); }
.grade-tip b { font-weight: 700; }
.sum-row {
  width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 12px;
  align-items: center; text-align: left; border: 0; background: transparent; padding: 14px 16px; min-height: 72px;
}
.sum-row + .sum-row { border-top: 1px solid var(--line); }
.sum-row:active { background: var(--bg-3); }
.sum-k { grid-column: 1; font-size: 16px; color: var(--ink-2); line-height: 1.3; }
.sum-v { grid-column: 1; font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1.4; }
.sum-row.unset .sum-v { color: var(--accent-ink); font-weight: 600; }
.sum-row .chev { grid-column: 2; grid-row: 1 / span 2; }
.chev { width: 10px; height: 16px; color: var(--ink-3); flex: none; }

/* ---------- 往下滑：怎麼用 ---------- */
.howto { margin: 64px 0 0; }
.howto-title { font-size: 26px; font-weight: 800; line-height: 1.35; margin: 0 0 26px; }
.hl { position: relative; display: inline-block; z-index: 0; white-space: nowrap; }
.hl svg { position: absolute; left: -.1em; bottom: -.12em; width: calc(100% + .2em); height: .5em; overflow: visible; z-index: -1; pointer-events: none; }
.hl .draw { stroke-width: 5; stroke: rgba(212, 87, 29, .55); }

/* 手繪線：用 pathLength=1 的虛線位移畫出來；預設是畫好的（沒有動態時直接顯示） */
.draw { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.draw-ok { stroke: #fff; stroke-width: 3.5; }

/* 時間軸：左邊一條線，跟著往下滑一路畫下去 */
.tl { position: relative; padding-left: 46px; }
.tl-rail { position: absolute; left: 15px; top: 18px; bottom: 30px; width: 3px; border-radius: 2px; background: var(--line); overflow: hidden; transition: opacity .6s; }
.motion .tl:not(.in) .tl-rail { opacity: 0; }
.tl-fill { position: absolute; inset: 0; background: var(--accent); transform-origin: top; transform: scaleY(1); }
.steps { list-style: none; margin: 0; padding: 0; }
.st { position: relative; padding: 0 0 46px; }
.st-dot {
  position: absolute; left: -46px; top: 0; width: 33px; height: 33px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 0 0 5px var(--bg);
}
.st h3 { font-size: 22px; font-weight: 800; line-height: 1.4; margin: 1px 0 8px; }
.st p { margin: 0 0 14px; font-size: 18px; line-height: 1.6; color: var(--ink-2); }
.ill { display: block; width: 100%; max-width: 320px; height: auto; margin: 4px 0 0; font-family: var(--font); }
.ill .i-book { fill: var(--bg-2); stroke: #c7c7cc; stroke-width: 3; }
.ill .i-edge { stroke: #c7c7cc; stroke-width: 3; }
.ill .i-label { fill: #fff; stroke: #c7c7cc; stroke-width: 2; }
.ill .i-ink { fill: var(--ink); }
.ill .i-white { fill: #fff; }
.ill .i-phone { fill: #fff; stroke: var(--ink); stroke-width: 3; }
.ill .i-screen { fill: var(--bg-2); }
.ill .i-cam { fill: #2c2c2e; }
.ill .i-corner { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.ill .i-cover { fill: #e5e5ea; }
.ill .i-bar { fill: #d1d1d6; }
.ill .i-box { fill: #fff; stroke: #c7c7cc; stroke-width: 2; }
.ill .i-btn { fill: var(--accent); }
.ill .i-planet { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3; }
.ill .i-ring { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.ill .i-accbg { fill: var(--accent-soft); }
.ill .i-okbg { fill: var(--ok); }
.ill .i-t { font-size: 16px; fill: var(--ink); text-anchor: middle; font-weight: 600; }
.ill .i-t-s { font-size: 16px; }
.ill .i-t-b { font-weight: 700; letter-spacing: .02em; }
.ill .i-t-l { text-anchor: start; font-weight: 700; }
.ill .i-t-r { text-anchor: end; font-weight: 700; }
.ill .i-acc { fill: var(--accent-ink); }
.ill .i-mute { fill: var(--ink-2); }
.ill .i-big { font-size: 56px; font-weight: 800; fill: var(--ink); text-anchor: middle; }
.ill .i-btn-t { fill: #fff; font-weight: 700; font-size: 17px; }
.ill .i-sum { text-anchor: middle; font-size: 18px; }
.two-codes { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 12px 0 14px; }
.tc { display: grid; gap: 2px; align-content: start; background: var(--bg-2); border-radius: 14px; padding: 12px 14px; font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.tc b { color: var(--ink); font-size: 17px; }
.tc-go { color: var(--ink); font-weight: 600; }
.tc-ok { box-shadow: 0 0 0 2px var(--accent) inset; }
.inline-link { border: 0; background: none; padding: 0; color: var(--accent-ink); font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* 規則注音卡（教學最後一段） */
.rules-card { margin: 4px 0 0; }
.rules { background: var(--bg-2); border-radius: var(--radius); padding: 18px 16px 14px; }
.rules h2 { font-size: 24px; margin: 0 0 6px; }
/* 直式注音：國字右邊一欄注音，聲調在注音右邊（注音本身是附注，字較小） */
.zy ruby { display: inline-flex; align-items: center; margin: 0 1px; vertical-align: middle; }
.zy rp { display: none; }
.zy rt { display: inline-flex; align-items: center; font-size: 0.46em; line-height: 1; color: #7a5a2e; font-weight: 500; margin-left: 1px; }
.zy .zy-s { writing-mode: vertical-rl; text-orientation: upright; letter-spacing: -0.04em; }
.zy .zy-t { margin-left: -1px; }
.rule-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rule-list li { display: grid; grid-template-columns: 34px 1fr; gap: 6px; align-items: center; font-size: 23px; line-height: 1.75; padding: 6px 0; border-bottom: 1px solid var(--line); }
.rule-list li:last-child { border-bottom: 0; }
.rule-list .ri { font-size: 28px; line-height: 1; text-align: center; }
.rules-src { font-size: 17px; color: var(--ink-2); margin: 8px 0 0; line-height: 1.8; }

/* 三種動態（只在支援、而且沒開「減少動態效果」時才加 .motion） */
.motion .st, .motion .rv { transition: opacity .7s ease-out, transform .8s cubic-bezier(.2, .7, .2, 1); }
.motion .st:not(.in), .motion .rv:not(.in) { opacity: 0; transform: translateY(18px); }
.motion .draw { transition: stroke-dashoffset .9s cubic-bezier(.6, .1, .3, 1) var(--d, .3s); }
.motion .st:not(.in) .draw, .motion .howto-title:not(.in) .draw { stroke-dashoffset: 1; }
.motion .st-dot { transition: background .4s, color .4s; }
.motion .st:not(.in) .st-dot { background: var(--bg-2); color: var(--ink-2); }

/* ---------- 歡迎分享（教學與規則卡之後） ---------- */
.share-card { margin: 34px 0 0; }
.share-title { font-size: 22px; font-weight: 800; line-height: 1.35; }
.share-lead { margin: 4px 2px 12px; font-size: 17px; line-height: 1.5; color: var(--ink-2); }
.share-row > span { flex: 1; min-width: 0; }
.share-row .sh-ic { width: 30px; height: 30px; flex: none; }

/* ---------- 頁尾：一排很淡的連結 ---------- */
.foot { margin: 56px 0 0; padding-top: 22px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 16px; line-height: 1.6; }
.foot { padding-bottom: calc(env(safe-area-inset-bottom) + 96px); } /* 最後一行要能捲到兩顆浮動鈕（52～64px＋邊距）上方，不被蓋住 */
.foot p { margin: 0 0 8px; }
.foot a { color: var(--ink-2); }
.foot-links { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin: 0 0 14px; }
.foot-links > * { display: inline-flex; align-items: center; min-height: 44px; border: 0; background: none; padding: 0; color: var(--ink-2); font-size: 16px; text-decoration: none; white-space: nowrap; }
.foot-links > * + *::before { content: "・"; color: var(--ink-3); padding: 0 6px; }

/* ---------- 浮動掃描鈕：主按鈕捲出畫面才浮出來 ---------- */
/* iPhone Safari 26 的固定定位元素會停在下方工具列上緣（工具列底下不畫），所以 bottom 從可視範圍底部算起＋安全區（主畫面模式的 Home 條） */
.fab-scan {
  position: fixed; right: max(18px, calc(env(safe-area-inset-right) + 8px)); bottom: calc(env(safe-area-inset-bottom) + 20px); z-index: 45;
  width: 64px; height: 64px; border: 0; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 22px rgba(212, 87, 29, .38);
  visibility: hidden; opacity: 0; transform: scale(.6);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.fab-scan svg { width: 32px; height: 32px; }
.fab-scan.show { visibility: visible; opacity: 1; transform: none; transition: opacity .2s ease, transform .2s ease, visibility 0s; }
.fab-scan:active { transform: scale(.94); }
body.card-open .fab-scan, body.sheet-open .fab-scan, body.page-open .fab-scan, body.scanning .fab-scan { visibility: hidden; opacity: 0; }

/* 回到最上方：左下角，跟掃描鈕同一條水平中線；白底灰箭頭、比較小，不搶主按鈕 */
.fab-top {
  position: fixed; left: max(18px, calc(env(safe-area-inset-left) + 8px)); bottom: calc(env(safe-area-inset-bottom) + 26px); z-index: 45;
  width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .94); color: var(--ink-2);
  display: grid; place-items: center; box-shadow: 0 0 0 1px rgba(0, 0, 0, .07), 0 6px 18px rgba(0, 0, 0, .13);
  -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
  visibility: hidden; opacity: 0; transform: translateY(10px) scale(.9);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.fab-top svg { width: 26px; height: 26px; }
.fab-top.show { visibility: visible; opacity: 1; transform: none; transition: opacity .2s ease, transform .2s ease, visibility 0s; }
.fab-top:active { background: var(--bg-3); transform: scale(.94); }
body.card-open .fab-top, body.sheet-open .fab-top, body.page-open .fab-top, body.scanning .fab-top { visibility: hidden; opacity: 0; }

/* ---------- 共用按鈕 ---------- */
.btn-primary, .btn-submit {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; padding: 0 18px;
  border: 0; border-radius: 15px; background: var(--accent); color: #fff; font-size: 19px; font-weight: 700;
  text-decoration: none; white-space: nowrap;
}
.btn-primary:active, .btn-submit:active { filter: brightness(.93); }
.btn-primary[disabled], .btn-submit[disabled], .btn-secondary[disabled] { opacity: .55; }
.btn-secondary, .btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; padding: 0 18px;
  border: 0; border-radius: 15px; background: var(--bg-2); color: var(--ink); font-size: 18px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.btn-secondary:active, .btn-ghost:active { background: var(--bg-3); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > * { flex: 1 1 auto; width: auto; }
.btn-danger { display: block; margin: 22px auto 0; border: 0; background: none; color: var(--accent-ink); font-size: 17px; padding: 10px 16px; min-height: 44px; }
.link-more { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; border: 0; background: none; color: var(--ink-2); font-size: 16px; padding: 4px 2px 0; white-space: nowrap; }
.link-more svg { width: 12px; height: 12px; transition: transform .2s; }
.link-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.note { margin: 8px 2px 0; font-size: 16px; line-height: 1.5; color: var(--ink-2); }

/* ---------- 分組列（更多、清單工具、年級選項） ---------- */
.group { background: var(--bg-2); border-radius: 14px; overflow: hidden; }
.group-title { font-size: 16px; font-weight: 600; color: var(--ink-2); margin: 22px 4px 8px; }
.g-row {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 12px 16px;
  border: 0; background: transparent; text-align: left; color: var(--ink); font-size: 18px; text-decoration: none;
}
.g-row > span:first-child { flex: 1; min-width: 0; }
.g-row + .g-row { border-top: 1px solid var(--line); }
.g-row:active { background: var(--bg-3); }
.g-check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.g-choice { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.g-choice .c-main { font-size: 18px; font-weight: 600; }
.g-choice .c-sub { display: block; font-size: 16px; color: var(--ink-2); font-weight: 400; }
.g-choice .c-check { width: 22px; height: 22px; color: var(--accent); visibility: hidden; }
.g-choice[aria-checked="true"] .c-check { visibility: visible; }
.g-choice[aria-checked="true"] .c-main { color: var(--accent-ink); }

/* ---------- 抽屜（從下往上；照 Apple HIG 的 sheet，10-25 改版） ----------
   - 抽屜外框跟著「真正看得到的範圍」（overlay.js 用 visualViewport 設 --vvt／--vvh：Safari 工具列、鍵盤都扣掉）；
     抽屜最高＝看得到的高度扣掉上方安全區再空 24px（露出一條暗底，看得出是浮在首頁上、點了就關），永遠不會頂到狀態列底下。
   - 抽屜本身捲動；標題列（含拖曳把手與關閉鈕）固定在抽屜頂端。關閉鈕點擊範圍 44×44。
   - 往下滑關、點背景關、Esc 關、返回鍵關（overlay.js）。 */
.sheet {
  position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100%); z-index: 70;
  display: flex; flex-direction: column; justify-content: flex-end;
}
/* 暗底往下延伸到鍵盤後面（iPhone 打字時，網址小膠囊那一條不在 visualViewport 裡，但畫面上看得到） */
.sheet-backdrop { position: absolute; inset: 0 0 calc(-1 * var(--kb, 0px)); background: rgba(0, 0, 0, .32); animation: fade .24s ease; }
.sheet-panel {
  position: relative; flex: none; width: 100%; max-width: 560px; margin: 0 auto;
  max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
  max-height: min(calc(100% - env(safe-area-inset-top) - 24px), calc(100dvh - env(safe-area-inset-top) - 24px));
  overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border-radius: 22px 22px 0 0;
  padding: 0 20px calc(env(safe-area-inset-bottom) + 20px); /* 最寬 560px 置中，橫向時離瀏海很遠，左右不用再加安全區 */
  display: grid; gap: 12px; align-content: start; animation: rise .24s ease;
  grid-auto-rows: max-content; /* 內容比抽屜高時，每一列照原本高度、整個抽屜捲動（不然 overflow: hidden 的分組會被擠扁成 0） */
}
.sheet-panel:focus { outline: none; }
.sheet-panel { scroll-padding-top: 80px; } /* 鍵盤跳出來把欄位捲進畫面時，不要躲到標題列底下 */
.sheet-panel .group-title { margin: 10px 4px 0; }
.sheet-head {
  position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin: 0 -20px; padding: 20px 12px 6px 20px; min-height: 70px; background: #fff; border-radius: 22px 22px 0 0;
  touch-action: none; /* 拖標題列＝拉抽屜，不捲內容 */
}
/* 拖曳把手（grabber）：36×5，跟 iPhone 的抽屜一樣 */
.sheet-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: #c7c7cc; }
.sheet-panel.scrolled .sheet-head { box-shadow: 0 1px 0 var(--line); }
.sheet-head h2 { font-size: 22px; font-weight: 800; min-width: 0; }
/* 關閉鈕：看得到的圓 36px，按得到的範圍 44×44 */
.sheet-x {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; padding: 0;
  background: radial-gradient(circle closest-side, var(--bg-2) 81%, transparent 83%);
  font-size: 24px; line-height: 1; color: var(--ink-2); display: grid; place-items: center;
}
.sheet-x:active { background: radial-gradient(circle closest-side, var(--bg-3) 81%, transparent 83%); }
.sheet-lead { margin: 0; font-size: 17px; line-height: 1.55; color: var(--ink-2); }
/* 送出鈕固定在抽屜底部：鍵盤跳出來、內容捲到一半也按得到（意見回饋、匯入備份） */
.sheet-panel:has(> .sheet-foot) { padding-bottom: 0; scroll-padding-bottom: 96px; } /* 也不要躲到底部的送出鈕底下 */
.sheet-foot {
  position: sticky; bottom: 0; z-index: 2; margin: 0 -20px; padding: 10px 20px calc(env(safe-area-inset-bottom) + 16px);
  background: linear-gradient(rgba(255, 255, 255, 0), #fff 10px);
}
.kb-open .sheet-panel { padding-bottom: 12px; box-shadow: 0 var(--kb, 0px) 0 #fff; } /* 白底接到鍵盤，中間不露出首頁 */
.kb-open .sheet-foot { padding-bottom: 12px; }

/* ---------- 整頁（清單、找書） ---------- */
.page { position: fixed; inset: 0; z-index: 55; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; animation: rise .22s ease; }
.page-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) max(20px, env(safe-area-inset-right)) 12px max(20px, env(safe-area-inset-left)); background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--line);
}
.page-head h2 { font-size: 24px; font-weight: 800; }
.page-done { flex: none; border: 0; background: none; color: var(--accent-ink); font-size: 18px; font-weight: 700; padding: 8px 4px; min-height: 44px; min-width: 44px; }
.page-body { max-width: 560px; margin: 0 auto; padding: 16px 20px calc(env(safe-area-inset-bottom) + 40px); }

/* 清單 */
.list-summary { display: flex; gap: 10px; margin: 4px 0 14px; }
.list-summary:empty { display: none; }
.sum-box { flex: 1; min-width: 0; background: var(--bg-2); border-radius: 14px; padding: 12px 10px; text-align: center; }
.sum-box .n { display: block; font-size: 30px; font-weight: 800; line-height: 1.15; color: var(--ink); }
.sum-box .l { display: block; font-size: 16px; color: var(--ink-2); line-height: 1.35; }
.sum-box .l span { display: inline-block; }
.list-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item { background: #fff; border-radius: 16px; padding: 14px 14px 10px 16px; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr auto; column-gap: 12px; }
.item.new { animation: pop .28s ease; }
.item .t { font-weight: 700; font-size: 18px; line-height: 1.4; word-break: break-word; }
.item .s { grid-column: 1 / -1; font-size: 16px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 2px; line-height: 1.45; }
.item .p { text-align: right; font-weight: 800; font-size: 26px; line-height: 1.1; color: var(--ink); white-space: nowrap; }
.item .p small { display: block; font-size: 16px; font-weight: 500; color: var(--ink-2); }
.item.no .p { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.item-act { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.chk { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 17px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.wait, .loan-line { flex-basis: 100%; font-size: 16px; color: var(--ink-2); line-height: 1.45; }
.wait.busy { color: var(--accent-ink); }
.loan-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.loan-line .due { color: var(--ink); font-weight: 600; }
.loan-line.soon .due, .loan-line.late .due { color: var(--accent-ink); font-weight: 700; }
.loan-line button { border: 0; background: none; color: var(--accent-ink); font-size: 16px; padding: 0; min-height: 44px; }
.go-sm { margin-left: auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 16px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.del { border: 0; background: none; width: 44px; height: 44px; border-radius: 10px; color: var(--ink-3); font-size: 22px; line-height: 1; flex: none; }
.del:active { background: var(--bg-2); }
.item .rename { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 0; color: var(--ink); font-weight: 700; font-size: 18px; line-height: 1.4; overflow-wrap: anywhere; }
.item .rename .pen { color: var(--ink-3); font-weight: 400; }
.item .lookup { color: var(--accent-ink); padding: 11px 0; margin: -11px 0; } /* 看起來是一行字，按得到的範圍上下各多 11px（≥44） */
.rename-box { display: flex; gap: 6px; }
.rename-box input { flex: 1; min-width: 0; border: 2px solid var(--accent); border-radius: 10px; padding: 8px 10px; font-size: 17px; }
.btn-save { border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 700; padding: 0 14px; min-height: 44px; white-space: nowrap; }
.list-empty { color: var(--ink-2); font-size: 17px; margin: 18px 4px; text-align: center; }
.grade { display: inline-block; font-size: 16px; line-height: 1.4; padding: 1px 9px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); white-space: nowrap; }
.pf-tag { background: var(--accent-soft); color: var(--accent-ink); }
.lang { font-size: 16px; color: var(--ink-2); }
.calc { font-size: 16px; color: var(--ink-2); line-height: 1.4; }
.calc.up { color: var(--accent-ink); }

/* 小廣告位（清單頁最下面一行，不動畫） */
.ad-slot { margin-top: 26px; }
.ad {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink);
  background: var(--bg-2); border-radius: 12px; padding: 0 12px; height: 44px; font-size: 16px; line-height: 1.3; overflow: hidden;
}
.ad-label { flex: none; font-size: 16px; color: var(--ink-2); }
.ad-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.ad-text b { color: var(--ink); font-weight: 600; }
.ad-go { flex: none; color: var(--ink-3); font-size: 20px; }

/* 備份抽屜 */
.bk-lead, .bk-note { margin: 0; font-size: 16px; color: var(--ink-2); line-height: 1.5; }
.bk-text { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 16px; font-family: ui-monospace, Menlo, monospace; background: var(--bg-2); word-break: break-all; }
.bk-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.bk-actions > * { flex: 1 1 auto; width: auto; }
.bk-preview { margin: 0; font-size: 16px; color: var(--ink); min-height: 1.4em; }
.bk-preview.bad { color: var(--accent-ink); }

/* 找書 */
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border-radius: 14px; padding: 0 8px 0 12px; min-height: 54px; }
.search-box:focus-within { box-shadow: 0 0 0 2px var(--accent) inset; }
.search-box svg { width: 22px; height: 22px; color: var(--ink-2); flex: none; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 19px; padding: 12px 0; }
.search-box input::-webkit-search-cancel-button { display: none; }
/* 清除鈕：看得到的圓 26px，按得到的範圍 44×44 */
.search-clear { border: 0; padding: 0; width: 44px; height: 44px; margin: 0 -8px 0 -6px; border-radius: 50%; background: radial-gradient(circle closest-side, var(--ink-3) 59%, transparent 61%); color: #fff; font-size: 18px; line-height: 1; flex: none; }
.results { margin-top: 14px; display: grid; gap: 10px; }
.result { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 14px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.result .title { font-weight: 700; font-size: 18px; line-height: 1.4; word-break: break-word; }
.result .by { color: var(--ink-2); font-size: 16px; word-break: break-word; }
.result .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; }
.result .side { grid-row: 1 / span 3; grid-column: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pts { display: inline-flex; flex-direction: column; align-items: center; color: var(--ink); font-weight: 800; line-height: 1.1; }
.pts b { font-size: 26px; }
.pts small { font-size: 16px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.btn-add { min-width: 72px; min-height: 44px; border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 16px; padding: 0 14px; white-space: nowrap; }
.btn-add[disabled] { background: var(--bg-2); color: var(--ink-2); }
.results .none { color: var(--ink-2); padding: 6px 2px; margin: 0; }
.btn-more { border: 0; background: transparent; color: var(--accent-ink); font-size: 16px; padding: 8px 2px; min-height: 44px; justify-self: start; }

/* ---------- 意見回饋 ---------- */
.fb-types { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-types label { position: relative; }
.fb-types input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.fb-types span { display: inline-block; min-height: 44px; line-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--bg-2); font-size: 16px; font-weight: 600; white-space: nowrap; }
.fb-types input:checked + span { background: var(--ink); color: #fff; }
.fb-types input:focus-visible + span { outline: 3px solid var(--accent); }
#fbMsg, #fbContact { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 17px; background: var(--bg-2); }
#fbMsg:focus, #fbContact:focus { outline: 0; border-color: var(--accent); background: #fff; }
.fb-contact { display: grid; gap: 4px; font-size: 16px; color: var(--ink-2); }
.fb-warn { margin: -2px 0 0; font-size: 16px; font-weight: 700; color: var(--accent-ink); }

/* ---------- 我借了這本 ---------- */
.loan-book { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.4; }
.field { display: grid; gap: 6px; font-size: 16px; color: var(--ink-2); }
.field input[type="date"] { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 18px; background: var(--bg-2); color: var(--ink); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 10px; min-height: 44px; font-size: 16px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.due-box { background: var(--bg-2); border-radius: 14px; padding: 14px 16px; }
.due-box .k { font-size: 16px; color: var(--ink-2); }
.due-box .v { font-size: 28px; font-weight: 800; line-height: 1.25; }
.due-box .s { font-size: 16px; color: var(--ink-2); }

/* ---------- 掃描畫面 ---------- */
.scanner { position: fixed; inset: 0; background: #000; z-index: 50; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-shade { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.frame {
  position: relative; width: min(84vw, 420px); height: min(34vw, 170px); border-radius: 18px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5); border: 3px solid rgba(255, 255, 255, .95);
  transition: border-color .2s, box-shadow .2s;
}
.laser { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: #ff7a3d; box-shadow: 0 0 10px #ff7a3d; animation: laser 1.6s ease-in-out infinite; }
/* 對焦／距離即時提示（10-25）：紅＝模糊或太近、橘＝太遠、綠＝對到焦 */
.frame.hint-bad { border-color: #ff5a43; box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5), 0 0 18px #ff5a43; }
.frame.hint-warn { border-color: #ffb020; box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5), 0 0 18px #ffb020; }
.frame.hint-good { border-color: #36d07f; box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5), 0 0 22px #36d07f; }
.frame.flash-ok { border-color: #36d07f; box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5), 0 0 24px #36d07f; }
.frame.flash-no { border-color: #ff6a4d; box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .5), 0 0 24px #ff6a4d; }
.scanner-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  /* 瀏海、動態島、橫向時的圓角都避開（安全區）；「完成」一直在右上角看得到 */
  padding: calc(env(safe-area-inset-top) + 14px) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
}
.scan-status { margin: 0; flex: 1; min-width: 0; color: #fff; font-size: 18px; line-height: 1.45; background: rgba(0, 0, 0, .55); border-radius: 14px; padding: 10px 14px; }
.btn-done { border: 0; background: #fff; color: var(--ink); font-weight: 700; font-size: 18px; border-radius: 999px; padding: 0 20px; min-height: 48px; flex: none; white-space: nowrap; }
.scanner-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 16px) max(16px, env(safe-area-inset-left)); text-align: center; pointer-events: none; }
.scan-count { display: inline-block; color: #fff; font-size: 16px; background: rgba(0, 0, 0, .55); border-radius: 999px; padding: 6px 14px; }
.scan-count:empty { display: none; }

/* ---------- 結果卡 ---------- */
.card-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(0, 0, 0, .32); }
.scan-card {
  position: fixed; z-index: 60; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
  bottom: calc(var(--kb, 0px) + env(safe-area-inset-bottom) + 12px); /* 鍵盤跳出來時整張卡往上，搜尋框與結果不會被蓋住 */
  max-width: 540px; margin: 0 auto; background: #fff; border-radius: 24px; padding: 0 20px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .28); animation: rise .25s ease;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  max-height: calc(var(--vvh, 100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain;
}
/* 頂端把手列：固定在卡片頂端（內容捲下去，關閉鈕也一直在）；拖這裡往下滑＝關掉 */
.sc-bar { position: sticky; top: 0; z-index: 3; height: 20px; margin: 0 -20px; touch-action: none; }
.sc-bar::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: #d1d1d6; }
.sc-x {
  position: absolute; top: 4px; right: 6px; width: 44px; height: 44px; border: 0; padding: 0; border-radius: 50%;
  background: radial-gradient(circle closest-side, var(--bg-2) 77%, transparent 79%); color: var(--ink-2); font-size: 22px; line-height: 1;
}
.sc-x:active { background: radial-gradient(circle closest-side, var(--bg-3) 77%, transparent 79%); }
.sc-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 26px; line-height: 1.25; padding-right: 36px; }
.sc-head svg { width: 28px; height: 28px; flex: none; }
.scan-card.ok .sc-head { color: var(--accent-ink); }
.scan-card.no .sc-head, .scan-card.lib .sc-head { color: var(--ink); }
.scan-card.no .sc-head svg { color: var(--ink-3); }
.scan-card.warn .sc-head { color: var(--ink); }
.scan-card.warn .sc-head svg { color: #c99a2e; }
.sc-title { margin: 8px 0 0; font-size: 20px; font-weight: 700; line-height: 1.4; word-break: break-word; }
.sc-points { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 0; }
.sc-points b { font-size: 60px; line-height: 1; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.sc-points small { font-size: 18px; font-weight: 700; color: var(--ink-2); }
.sc-line { margin: 4px 0 0; font-size: 16px; color: var(--ink-2); line-height: 1.5; }
.sc-line .calc { font-size: 16px; }
.sc-isbn { margin: 8px 0 0; font-size: 19px; font-weight: 600; letter-spacing: .03em; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.sc-actions { display: grid; gap: 10px; margin-top: 16px; }
/* 重新掃描：每張卡都有（掃錯了可以馬上回去掃）；次要時用主色外框，跟灰色的其他按鈕分得出來 */
.sc-rescan svg { width: 24px; height: 24px; flex: none; }
.sc-rescan.btn-secondary { background: #fff; color: var(--accent-ink); box-shadow: 0 0 0 2px var(--accent) inset; }
.sc-rescan.btn-secondary:active { background: var(--accent-soft); }
.sc-go-note { margin: -4px 0 2px; font-size: 16px; line-height: 1.45; color: var(--ink-2); text-align: center; }
.sc-sub { margin: -2px 0 0; font-size: 16px; color: var(--ink-2); text-align: center; line-height: 1.45; }
.sc-src { margin: 12px 0 0; font-size: 16px; color: var(--ink-2); line-height: 1.5; }
.sc-more { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.sc-more p { margin: 0; font-size: 16px; color: var(--ink-2); line-height: 1.5; }
.sc-more a:not(.btn-secondary) { color: var(--accent-ink); }
.sc-other { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.sc-libs { margin: 12px 0 0; font-size: 16px; color: var(--ink-2); line-height: 1.5; background: var(--bg-2); border-radius: 12px; padding: 10px 12px; }
.sc-libs a { color: var(--accent-ink); white-space: nowrap; }
.link-btn { border: 0; background: none; color: var(--accent-ink); font-size: 16px; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.item-act .link-btn { min-height: 44px; } /* 單獨一顆的（不是夾在句子裡的）要按得到 */
.sc-alias { color: var(--ink); background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.sc-alias b { display: block; font-weight: 700; }
.sc-alias span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sc-search { margin-top: 12px; }
.scan-card .results { margin-top: 10px; }
.scan-card .result { box-shadow: none; background: var(--bg-2); padding: 12px; }
.sc-libhelp { display: flex; align-items: center; gap: 14px; margin: 12px 0 0; background: var(--bg-2); border-radius: 14px; padding: 12px 14px; }
.sc-libhelp p { margin: 0; font-size: 17px; line-height: 1.5; color: var(--ink); }
.sc-cover { width: 60px; height: 75px; flex: none; }
/* 10-25 不在書單的卡片：書名、同名版本、在網路上找 */
.sc-by { font-weight: 600; color: var(--ink-2); font-size: 17px; }
.sc-isbn-sm { font-size: 16px; margin-top: 4px; }
.sc-tsrc { margin: 2px 0 0; font-size: 16px; color: var(--ink-2); }
.sc-same { margin-top: 12px; background: var(--bg-2); border-radius: 14px; padding: 12px; }
.sc-same.ok { background: var(--accent-soft); }
.sc-same-h { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink); }
.sc-same.ok .sc-same-h { color: var(--accent-ink); }
.sc-same-s { margin: 2px 0 0; font-size: 16px; color: var(--ink-2); line-height: 1.45; }
.sc-same .results { margin-top: 8px; }
.sc-same .result { background: #fff; }
.sc-webbtn[disabled] { opacity: 1; color: var(--ink-2); }
#scWebBtn:empty { display: none; }
.sc-web { margin-top: 12px; display: grid; gap: 10px; animation: fade .25s ease; }
.web-status { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; color: var(--ink); }
.web-status.done { font-weight: 400; font-size: 16px; color: var(--ink-2); }
.web-src, .web-else { background: var(--bg-2); border-radius: 14px; padding: 10px 12px; }
.web-src-h { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--ink-2); letter-spacing: .02em; }
.web-hit { margin: 0; display: grid; gap: 2px; font-size: 17px; line-height: 1.45; }
.web-hit b { color: var(--ink); word-break: break-word; }
.web-hit span { color: var(--ink-2); font-size: 16px; }
.web-hit .web-note, .web-note { font-size: 16px; color: var(--ink-2); margin: 0; }
.web-none, .web-wait { margin: 0; font-size: 16px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.web-book { display: flex; gap: 12px; align-items: flex-start; }
.web-cover { width: 56px; height: auto; max-height: 84px; object-fit: contain; border-radius: 4px; background: #fff; flex: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.web-else ul { margin: 2px 0 6px; padding: 0; list-style: none; display: grid; }
.web-else li a { display: flex; align-items: center; min-height: 44px; font-size: 17px; color: var(--accent-ink); border-bottom: 1px solid var(--line); }
.web-else li:last-child a { border-bottom: 0; }
.spin { display: inline-block; width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.sc-head .spin { width: 24px; height: 24px; border-width: 3px; }

.toast {
  /* 首頁：浮在兩顆浮動鈕上方；抽屜、整頁、結果卡開著時改到上方（不蓋住底下的按鈕）；
     掃描畫面：在清單計數上方（右上角的「完成」不被蓋住）。不吃點擊，下面的按鈕照樣按得到 */
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + var(--kb, 0px) + 96px); transform: translateX(-50%);
  background: rgba(29, 29, 31, .92); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 17px;
  z-index: 80; width: max-content; max-width: calc(100% - 32px); text-align: center; line-height: 1.45; pointer-events: none;
}
body.sheet-open .toast, body.page-open .toast, body.card-open .toast { top: calc(var(--vvt, 0px) + env(safe-area-inset-top) + 12px); bottom: auto; }
body.scanning .toast { top: auto; bottom: calc(env(safe-area-inset-bottom) + 64px); }

/* ---------- 加到主畫面圖解 ---------- */
.ig-panel { z-index: 1; }
.sheet.with-arrow .sheet-panel { padding-bottom: calc(env(safe-area-inset-bottom) + 74px); }
.ig-lead { margin: 0; color: var(--ink-2); font-size: 16px; }
.tb-svg { width: 100%; height: auto; }
.ig-steps { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; font-size: 18px; line-height: 1.5; }
.ig-steps svg { vertical-align: -5px; margin-left: 4px; }
.ios-arrow { position: fixed; z-index: 75; pointer-events: none; animation: nudge 1.1s ease-in-out infinite; }
.ios-arrow.at-bottom-center { left: calc(50% - 20px); bottom: calc(env(safe-area-inset-bottom) + 2px); }
.ios-arrow.at-bottom-right { right: 18px; bottom: calc(env(safe-area-inset-bottom) + 2px); }
.ios-arrow.at-top-right { right: 60px; top: 4px; transform: rotate(180deg); animation: none; }

@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes pop { from { transform: scale(.97); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes laser { 0%, 100% { transform: translateY(-34px); } 50% { transform: translateY(34px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* 系統開了「減少動態效果」：全部直接顯示、不播動畫 */
@media (prefers-reduced-motion: reduce) {
  .item.new, .scan-card, .sheet-panel, .sheet-backdrop, .page, .laser, .ios-arrow, .sc-web { animation: none; }
  .spin { animation-duration: 2.4s; } /* 還是要看得出「正在查」，轉慢一點 */
  .motion .st, .motion .rv { opacity: 1 !important; transform: none !important; transition: none !important; }
  .draw { stroke-dashoffset: 0 !important; transition: none !important; }
  .tl-fill { transform: scaleY(1) !important; }
  .fab-scan, .fab-top, .btn-scan, .frame { transition: none; }
}

/* 小螢幕再收一點留白 */
@media (max-width: 360px) {
  .wrap { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .sheet-panel { padding-left: 16px; padding-right: 16px; }
  .sheet-head, .sheet-foot { margin: 0 -16px; padding-left: 16px; }
  .sheet-foot { padding-right: 16px; }
  .btn-scan { font-size: 24px; }
  .two-codes { grid-template-columns: 1fr; }
}

/* 橫向、矮螢幕：主按鈕、教學圖收矮一點，抽屜標題列收緊，留多一點給內容 */
@media (max-height: 500px) and (orientation: landscape) {
  .btn-scan { min-height: 88px; }
  .sheet-head { min-height: 60px; padding-top: 16px; }
  .scanner-top { padding-top: calc(env(safe-area-inset-top) + 8px); }
  .frame { height: min(34vw, 130px); }
}

/* ---------- 隱私說明頁 ---------- */
.privacy h1 { font-size: 28px; margin: 8px 0 12px; }
.privacy h2 { margin: 24px 0 8px; font-size: 21px; }
.privacy ul { padding-left: 1.2em; }
.privacy li { margin-bottom: 8px; }
.privacy .small { color: var(--ink-2); font-size: 16px; }
.privacy code { font-size: 16px; background: var(--bg-2); border-radius: 6px; padding: 1px 5px; }
.privacy .tbl-wrap { overflow-x: auto; margin: 4px 0 12px; }
.privacy table { width: 100%; border-collapse: collapse; font-size: 16px; line-height: 1.5; }
.privacy th, .privacy td { text-align: left; vertical-align: top; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.privacy th { color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.privacy td:first-child { font-weight: 600; min-width: 5.5em; }
.privacy td:last-child { white-space: nowrap; color: var(--ink-2); }
