:root {
  --ground: #EDF0EF;
  --surface: #FFFFFF;
  --ink: #1E2A31;
  --muted: #66747B;
  --faint: #D5DCDC;
  --ribbon: #A3283A;
  --shelf: #C9BBA6;
  --fs: 1.2rem;
  --serif: "Noto Serif TC", "Noto Serif CJK TC", "Songti TC", "PMingLiU", "MingLiU", serif;
  --sans: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Noto Sans CJK TC", sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121719;
    --surface: #1B2326;
    --ink: #E4E9EA;
    --muted: #94A3A9;
    --faint: #2C373B;
    --ribbon: #D0566A;
    --shelf: #4A4036;
  }
}
/* 睡前模式：很暗的畫面 */
:root[data-night] {
  --ground: #050607;
  --surface: #0A0C0D;
  --ink: #7F898D;
  --muted: #4D575C;
  --faint: #171C1F;
  --ribbon: #6E2A34;
  --shelf: #2A241F;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 5rem); scroll-padding-bottom: 9rem; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.4s;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ribbon); outline-offset: 2px; border-radius: 6px; }

/* ---------- header ---------- */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  background: var(--ground);
  border-bottom: 1px solid var(--faint);
  transition: background-color 0.4s;
}
.top-inner {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.6rem 0.6rem 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}
.title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
  background: none;
  border: 0;
  padding: 0.35rem 0.25rem;
  text-align: left;
  cursor: pointer;
}
.book {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.45rem, 5vw, 1.9rem);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chap { color: var(--muted); font-size: 1rem; white-space: nowrap; }
.chev { width: 0.9rem; height: 0.9rem; color: var(--muted); align-self: center; flex: none; }
.icon-btn {
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink);
}
.icon-btn:hover { background: var(--faint); }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: none; }
.icon-btn svg { width: 1.4rem; height: 1.4rem; }

/* ---------- reading column ---------- */
.page { max-width: 40rem; margin: 0 auto; padding: 1.5rem 0.85rem 11rem 0.6rem; }
@media (min-width: 40rem) { .page { padding-left: 1rem; padding-right: 1rem; } }
.text {
  position: relative;
  padding-left: 0.85rem;
  font-family: var(--serif);
  font-size: var(--fs);
  line-height: 1.9;
}
.verse {
  position: relative;
  margin: 0 0 0.8em;
  padding-left: 1.8em;
  cursor: pointer;
  transition: color 0.3s;
  text-align: justify;
}
.vn {
  position: absolute;
  left: 0;
  top: 0;
  width: 2.3em;
  text-align: right;
  font-family: var(--sans);
  font-size: 0.62em;
  line-height: 3.07;
  color: var(--ribbon);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.vn.range { font-size: 0.5em; line-height: 3.8; letter-spacing: -0.02em; }
.note { font-size: 0.72em; color: var(--muted); }
.text.focus .verse { color: var(--muted); }
.text.focus .verse.current { color: var(--ink); }
#ribbon {
  position: absolute;
  left: 0.1rem;
  top: 0;
  width: 0.45rem;
  height: 2rem;
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 0.4rem), 0 100%);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(.3,.7,.2,1), height 0.45s cubic-bezier(.3,.7,.2,1), opacity 0.3s;
  pointer-events: none;
}
#ribbon.on { opacity: 1; }
.msg { font-family: var(--sans); font-size: 1rem; color: var(--muted); padding: 2rem 0; line-height: 1.7; }
.msg button {
  margin-top: 0.75rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: none;
  cursor: pointer;
}
.source { margin-top: 3rem; font-size: 0.8rem; color: var(--muted); line-height: 1.6; padding-left: 0.85rem; }

/* 第一次載入：書籤垂下 + 文字行 */
.loading { position: relative; padding: 0.4rem 0 0 1.8em; }
.loading .drop {
  position: absolute;
  left: -0.75rem;
  top: 0;
  width: 0.45rem;
  height: 3.2rem;
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 0.4rem), 0 100%);
  transform-origin: top;
  animation: drop 1.4s cubic-bezier(.3,.7,.2,1) infinite alternate;
}
.loading .line {
  height: 0.9em;
  margin: 0 0 1.05em;
  border-radius: 4px;
  background: var(--faint);
  background: linear-gradient(90deg, var(--faint) 0%, var(--faint) 40%, color-mix(in srgb, var(--faint) 40%, var(--ground)) 50%, var(--faint) 60%, var(--faint) 100%);
  background-size: 300% 100%;
  animation: shimmer 1.6s linear infinite;
}
.loading .line:nth-child(3n+2) { width: 82%; }
.loading .line:nth-child(3n) { width: 64%; }
@keyframes drop { from { transform: scaleY(0.35); } to { transform: scaleY(1); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- install card ---------- */
.install-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 0.85rem;
  align-items: center;
  margin: 0 0 1.75rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: 12px;
}
.install-card img { border-radius: 11px; }
.install-copy p { margin: 0; }
.install-title { font-weight: 600; }
.install-text { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem !important; line-height: 1.5; }
.install-actions { grid-column: 1 / -1; display: flex; gap: 0.5rem; justify-content: flex-end; }
.btn-solid, .btn-outline, .btn-text {
  padding: 0.5rem 1.15rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
}
.btn-solid { background: var(--ink); color: var(--surface); border: 1px solid var(--ink); }
.btn-outline { background: none; border: 1px solid var(--ink); }
.btn-text { background: none; border: 1px solid transparent; color: var(--muted); }

/* ---------- download pill & toast ---------- */
.dl-pill, .toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8.6rem + env(safe-area-inset-bottom, 0px));
  z-index: 7;
  max-width: calc(100vw - 2rem);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--faint);
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(10, 20, 25, 0.12);
}
.dl-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem 0.4rem 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.dl-book { width: 1.1rem; height: 1.3rem; color: var(--ink); flex: none; }
#dlFill { transition: y 0.6s ease, height 0.6s ease; opacity: 0.85; }
.dl-pill.wait { opacity: 0.8; }
.toast {
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toast-in 0.35s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 0.5rem); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- player ---------- */
.player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 6;
  background: var(--surface);
  border-top: 1px solid var(--faint);
  padding: 0.6rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  transition: background-color 0.4s;
}
.player-inner { max-width: 40rem; margin: 0 auto; }
.status {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.3em;
  margin-bottom: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.controls { display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 0.75rem; }
.sleep-btn { justify-self: start; }
.rate-btn { justify-self: end; }
.play {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.play svg { width: 1.6rem; height: 1.6rem; }
.play:disabled { opacity: 0.4; cursor: default; }
.pill {
  min-width: 3.4rem;
  height: 2.25rem;
  padding: 0 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--faint);
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}
.pill:hover { border-color: var(--muted); }
.pill svg { width: 1.1rem; height: 1.1rem; }
.sleep-btn.on { border-color: var(--ribbon); color: var(--ribbon); }

/* ---------- dialogs ---------- */
dialog {
  width: min(36rem, calc(100vw - 1.5rem));
  max-height: min(42rem, calc(100dvh - 2rem));
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(10, 20, 25, 0.35);
}
dialog.wide { width: min(44rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1.5rem); }
dialog::backdrop { background: rgba(14, 22, 26, 0.45); }
.dlg { display: flex; flex-direction: column; max-height: inherit; }
.dlg-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.75rem 0.75rem 1.25rem;
  border-bottom: 1px solid var(--faint);
}
.dlg-head h2 { flex: 1; margin: 0; font-size: 1.1rem; font-weight: 600; }
.dlg-body { padding: 1rem 1.25rem 1.5rem; overflow-y: auto; }
.tabs { display: inline-flex; border: 1px solid var(--faint); border-radius: 999px; padding: 3px; margin-bottom: 1rem; }
.tabs button {
  border: 0;
  background: none;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); }
.grid { display: grid; gap: 0.5rem; }
.books { grid-template-columns: repeat(auto-fill, minmax(7.2rem, 1fr)); }
.chapters { grid-template-columns: repeat(auto-fill, minmax(3.1rem, 1fr)); }
.grid button {
  position: relative;
  min-height: 2.9rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--faint);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 1rem;
}
.chapters button { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.chapters button.heard::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ribbon);
  opacity: 0.7;
}
.grid button:hover { border-color: var(--muted); }
.grid button.here { border-color: var(--ribbon); color: var(--ribbon); font-weight: 600; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  border: 0;
  background: none;
  padding: 0.3rem 0;
  cursor: pointer;
  color: var(--muted);
}
.back svg { width: 1rem; height: 1rem; }
.picked { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; margin: 0 0 0.9rem; }

.field { margin-bottom: 1.4rem; }
.field > label:not(.check), .field > .label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: inherit;
  background: var(--ground);
  border: 1px solid var(--faint);
  border-radius: 8px;
}
.seg { display: flex; gap: 0.5rem; }
.seg button {
  flex: 1;
  padding: 0.55rem;
  border: 1px solid var(--faint);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.check { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; padding: 0.35rem 0; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--ribbon); flex: none; }
.hint { font-size: 0.85rem; color: var(--muted); line-height: 1.7; margin: 0.5rem 0 0; }
.hint.first { margin-top: 0; }
.warn { color: var(--ribbon); }
.choice { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin: 1rem 0 1.2rem; }
.choice button {
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--faint);
  border-radius: 10px;
  background: none;
  cursor: pointer;
}
.choice button:last-child { grid-column: 1 / -1; }
.choice button[aria-pressed="true"] { border-color: var(--ribbon); color: var(--ribbon); font-weight: 600; }

/* install guide */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { position: relative; padding: 0 0 1.1rem 2.4rem; line-height: 1.7; counter-increment: s; }
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}
.steps .ico { display: inline-block; width: 1.25em; height: 1.25em; vertical-align: -0.25em; margin: 0 0.15em; color: #1A73E8; }
.steps b { font-weight: 600; }

/* ---------- bookshelf ---------- */
.shelf-summary { font-family: var(--serif); font-size: 1.1rem; line-height: 1.9; margin: 0 0 0.9rem; }
.shelf-summary strong { color: var(--ribbon); font-weight: 600; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.whole { margin: 0 0 1.6rem; }
.whole-bar { height: 6px; border-radius: 3px; background: var(--faint); overflow: hidden; }
.whole-bar span { display: block; height: 100%; background: var(--ribbon); border-radius: 3px; transition: width 0.8s ease; }
.whole p { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }
.shelf-name { font-size: 0.9rem; color: var(--muted); margin: 0 0 0.4rem; }
.shelf-rows { margin-bottom: 1.6rem; }
.shelf-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 1.1rem 6px 0;
  border-bottom: 7px solid var(--shelf);
  border-radius: 0 0 3px 3px;
  margin-bottom: 0.4rem;
  min-height: 7.5rem;
}
.spine {
  --c: #5B6B74;
  --p: 0;
  position: relative;
  flex: none;
  width: 28px;
  border: 0;
  padding: 0;
  border-radius: 3px 3px 1px 1px;
  background:
    linear-gradient(to top, var(--c) calc(var(--p) * 100%), transparent calc(var(--p) * 100%)),
    rgba(120, 130, 135, 0.15);
  background:
    linear-gradient(to top, var(--c) calc(var(--p) * 100%), transparent calc(var(--p) * 100%)),
    color-mix(in srgb, var(--c) 18%, var(--surface));
  box-shadow: inset 0 0 0 1px rgba(120, 130, 135, 0.4);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent);
  cursor: pointer;
  transition: transform 0.2s;
}
.spine:hover { transform: translateY(-3px); }
.spine.sel { transform: translateY(-6px); box-shadow: inset 0 0 0 2px var(--ink); }
.spine span {
  display: block;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 20px;
  letter-spacing: 1px;
  margin: 6px 4px;
  padding: 3px 0;
  color: #1E2A31;
  background: rgba(255, 255, 255, 0.86);
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.spine .stars {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  font-size: 11px;
  line-height: 1;
  color: #C9962E;
  white-space: nowrap;
  padding-bottom: 2px;
  font-family: var(--sans);
}
.spine .stars.pop { animation: pop 0.6s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: translateX(-50%) scale(0.2); } to { transform: translateX(-50%) scale(1); } }
.book-detail {
  position: sticky;
  bottom: -1.5rem;
  margin: 0 -1.25rem -1.5rem;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--surface);
  border-top: 1px solid var(--faint);
}
.book-detail h3 { margin: 0 0 0.3rem; font-family: var(--serif); font-size: 1.25rem; }
.book-detail p { margin: 0 0 0.8rem; color: var(--muted); line-height: 1.6; font-size: 0.95rem; }
.empty-hint { color: var(--muted); font-size: 0.9rem; line-height: 1.7; margin: 0 0 1.4rem; }

/* ---------- celebration ---------- */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(14, 22, 26, 0.35);
  padding: 1.5rem;
}
.cel-card {
  position: relative;
  width: min(22rem, 100%);
  padding: 2rem 1.5rem 1.5rem;
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
  overflow: hidden;
  animation: card-in 0.5s cubic-bezier(.3,1.4,.5,1);
}
.cel-star { font-size: 3.2rem; line-height: 1; color: #C9962E; animation: spin-in 0.9s cubic-bezier(.3,1.4,.5,1); }
.cel-title { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; margin: 0.8rem 0 0.4rem; }
.cel-sub { color: var(--muted); margin: 0 0 1.2rem; line-height: 1.6; }
.cel-confetti i {
  position: absolute;
  top: -1rem;
  width: 7px;
  height: 16px;
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%);
  animation: fall 1.8s ease-in forwards;
  opacity: 0;
}
.cel-confetti i:nth-child(1) { left: 12%; animation-delay: 0.05s; }
.cel-confetti i:nth-child(2) { left: 26%; animation-delay: 0.3s; background: #C9962E; }
.cel-confetti i:nth-child(3) { left: 40%; animation-delay: 0.15s; background: #2F4A68; }
.cel-confetti i:nth-child(4) { left: 55%; animation-delay: 0.4s; }
.cel-confetti i:nth-child(5) { left: 68%; animation-delay: 0.1s; background: #3D5A47; }
.cel-confetti i:nth-child(6) { left: 80%; animation-delay: 0.35s; background: #C9962E; }
.cel-confetti i:nth-child(7) { left: 90%; animation-delay: 0.2s; background: #2F4A68; }
.cel-confetti i:nth-child(8) { left: 6%; animation-delay: 0.5s; background: #3D5A47; }
@keyframes card-in { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spin-in { from { transform: scale(0) rotate(-120deg); } to { transform: scale(1) rotate(0); } }
@keyframes fall {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0; transform: translateY(17rem) rotate(200deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .cel-confetti { display: none; }
}
/* ===================== 第 1.5 版新增 ===================== */
:root { --hl-y: rgba(250, 214, 80, 0.38); --hl-g: rgba(120, 200, 140, 0.32); --hl-b: rgba(110, 170, 235, 0.32); --hl-p: rgba(240, 140, 175, 0.32); }
@media (prefers-color-scheme: dark) {
  :root { --hl-y: rgba(230, 190, 60, 0.28); --hl-g: rgba(90, 180, 120, 0.26); --hl-b: rgba(90, 150, 220, 0.28); --hl-p: rgba(220, 110, 150, 0.28); }
}
:root[data-night] { --hl-y: rgba(150, 120, 40, 0.25); --hl-g: rgba(60, 120, 80, 0.25); --hl-b: rgba(60, 100, 150, 0.25); --hl-p: rgba(150, 70, 100, 0.25); }
.icon-btn.small { width: 2.25rem; height: 2.25rem; }
.icon-btn.small svg { width: 1.15rem; height: 1.15rem; }

/* 標記、選取、筆記、對照 */
.verse .vt { border-radius: 3px; transition: background-color 0.2s; -webkit-box-decoration-break: clone; box-decoration-break: clone; padding: 0.05em 0; }
.verse.hl-y .vt { background: var(--hl-y); }
.verse.hl-g .vt { background: var(--hl-g); }
.verse.hl-b .vt { background: var(--hl-b); }
.verse.hl-p .vt { background: var(--hl-p); }
.verse.sel .vt { text-decoration: underline; text-decoration-color: var(--ribbon); text-decoration-thickness: 1.5px; text-underline-offset: 0.3em; }
.unote {
  display: block;
  margin-top: 0.15em;
  font-family: var(--sans);
  font-size: 0.72em;
  line-height: 1.6;
  color: var(--muted);
  white-space: pre-wrap;
}
.unote::before { content: "✎ "; color: var(--ribbon); }
.par {
  display: block;
  margin-top: 0.2em;
  font-size: 0.8em;
  line-height: 1.7;
  color: var(--muted);
  text-align: left;
}
.par.en { font-family: Georgia, "Times New Roman", serif; }
.text.lang-en, .text.lang-en .verse { text-align: left; }
.text.lang-en { font-family: Georgia, "Times New Roman", var(--serif); }
.text.focus .verse .par, .text.focus .verse .unote { color: var(--muted); }
body.acting .page { padding-bottom: 22rem; }

/* 狀態列 */
.status-row { display: flex; justify-content: center; align-items: baseline; gap: 0.6rem; margin-bottom: 0.4rem; min-height: 1.3em; }
.status-row .status { margin-bottom: 0; min-width: 0; }
.act-link { background: none; border: 0; padding: 0.2rem 0.3rem; color: var(--ribbon); cursor: pointer; font-size: 0.85rem; white-space: nowrap; }

/* 操作列 */
.actbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(8.4rem + env(safe-area-inset-bottom, 0px));
  z-index: 8;
  width: min(36rem, calc(100vw - 1rem));
  background: var(--surface);
  border: 1px solid var(--faint);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(10, 20, 25, 0.18);
  padding: 0.5rem 0.6rem 0.6rem;
  animation: toast-in 0.25s ease;
}
.act-head { display: flex; align-items: center; gap: 0.4rem; padding-left: 0.4rem; }
.act-ref { flex: 1; font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-colors { display: flex; gap: 0.7rem; padding: 0.35rem 0.4rem 0.55rem; }
.dot {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  display: grid; place-items: center;
}
.dot[data-color="y"] { background: #F2CC4B; }
.dot[data-color="g"] { background: #7CC48E; }
.dot[data-color="b"] { background: #79AEE6; }
.dot[data-color="p"] { background: #EE93B4; }
.dot.clear { background: none; border-color: var(--faint); color: var(--muted); }
.dot.clear svg { width: 1rem; height: 1rem; }
.dot.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.act-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.25rem; border-top: 1px solid var(--faint); padding-top: 0.45rem; }
.act-buttons button {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  background: none; border: 0; border-radius: 10px;
  padding: 0.35rem 0.1rem; cursor: pointer; font-size: 0.75rem; color: var(--ink);
}
.act-buttons button:hover { background: var(--faint); }
.act-buttons button:disabled { opacity: 0.35; cursor: default; background: none; }
.act-buttons svg { width: 1.35rem; height: 1.35rem; }

/* 今日經文 */
.daily-card {
  margin: 0 0 1.75rem;
  padding: 0.8rem 1rem 1rem 1.1rem;
  border-left: 4px solid var(--ribbon);
  background: var(--surface);
  border-radius: 4px 12px 12px 4px;
}
.daily-head { display: flex; align-items: center; justify-content: space-between; }
.daily-label { font-size: 0.85rem; color: var(--ribbon); font-weight: 600; letter-spacing: 0.05em; }
.daily-text { font-family: var(--serif); font-size: 1.15rem; line-height: 1.85; margin: 0.3rem 0 0.2rem; }
.daily-card.en .daily-text { font-family: Georgia, "Times New Roman", serif; }
.daily-ref { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.8rem; }
.daily-actions { display: flex; gap: 0.5rem; }

/* 選書卷：搜尋與最近 */
.pick-top { display: flex; gap: 0.5rem; margin-bottom: 0.9rem; }
.search-box {
  flex: 1; min-width: 0;
  padding: 0.65rem 0.8rem;
  font: inherit; font-size: 1rem; color: inherit;
  background: var(--ground);
  border: 1px solid var(--faint);
  border-radius: 10px;
}
.search-box:focus { outline: 2px solid var(--ribbon); outline-offset: 0; }
.ver-mini { width: auto; max-width: 9.5rem; padding: 0.55rem 0.5rem; font-size: 0.85rem; }
.recent { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.recent-label { width: 100%; font-size: 0.85rem; color: var(--muted); }
.chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--faint);
  border-radius: 999px;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.results { display: flex; flex-direction: column; }
.res-go {
  text-align: left; padding: 0.75rem 0.9rem; margin-bottom: 0.8rem;
  border: 1px solid var(--ribbon); color: var(--ribbon); border-radius: 10px; background: none; cursor: pointer; font-weight: 600;
}
.res-meta { font-size: 0.85rem; color: var(--muted); margin: 0.3rem 0 0.6rem; }
.res-item {
  text-align: left; background: none; border: 0; border-bottom: 1px solid var(--faint);
  padding: 0.65rem 0.2rem; cursor: pointer; line-height: 1.7;
}
.res-item:hover { background: color-mix(in srgb, var(--faint) 40%, transparent); }
.res-ref { display: block; font-weight: 600; font-size: 0.9rem; }
.res-text { display: block; font-family: var(--serif); color: var(--muted); }
.res-item mark { background: var(--hl-y); color: inherit; border-radius: 2px; }
.res-filter { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* 書架分頁、收藏 */
.shelf-tabs { margin-bottom: 1.1rem; }
.fav-top { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.fav-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.fav-filters .chip[data-f="y"]::before, .fav-filters .chip[data-f="g"]::before, .fav-filters .chip[data-f="b"]::before, .fav-filters .chip[data-f="p"]::before {
  content: ""; display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 0.35em; vertical-align: -0.05em;
}
.fav-filters .chip[data-f="y"]::before { background: #F2CC4B; }
.fav-filters .chip[data-f="g"]::before { background: #7CC48E; }
.fav-filters .chip[data-f="b"]::before { background: #79AEE6; }
.fav-filters .chip[data-f="p"]::before { background: #EE93B4; }
.fav-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--faint);
  padding: 0.75rem 0.2rem 0.75rem 0.9rem; cursor: pointer; position: relative; line-height: 1.7;
}
.fav-item::before { content: ""; position: absolute; left: 0; top: 0.9rem; bottom: 0.9rem; width: 4px; border-radius: 2px; background: var(--faint); }
.fav-item.c-y::before { background: #F2CC4B; }
.fav-item.c-g::before { background: #7CC48E; }
.fav-item.c-b::before { background: #79AEE6; }
.fav-item.c-p::before { background: #EE93B4; }
.fav-ref { display: block; font-weight: 600; font-size: 0.9rem; }
.fav-text { display: block; font-family: var(--serif); }
.fav-note { display: block; font-size: 0.85rem; color: var(--muted); white-space: pre-wrap; }
.fav-note::before { content: "✎ "; color: var(--ribbon); }

/* 英文書背：橫躺文字 */
.shelf-en .spine span { text-orientation: mixed; font-family: Georgia, serif; letter-spacing: 0.5px; }

/* 筆記、背經對話框 */
.note-ref { font-weight: 600; margin: 0 0 0.6rem; }
textarea {
  width: 100%; font: inherit; color: inherit; line-height: 1.6;
  padding: 0.7rem; border-radius: 10px; border: 1px solid var(--faint); background: var(--ground); resize: vertical;
}
.row-end { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }
.choice.three { grid-template-columns: repeat(3, 1fr); }
.choice.three button:last-child { grid-column: auto; }
.offline-list { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0.8rem; font-size: 0.88rem; }
.offline-list .ok { color: #3D7A55; }
.offline-list span:nth-child(even) { color: var(--muted); text-align: right; }

/* 離線經文：全部下載按鈕 */
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; }
.field-head .label { font-weight: 600; }
.btn-outline.small { padding: 0.35rem 0.9rem; font-size: 0.85rem; white-space: nowrap; }
.btn-outline:disabled { opacity: 0.55; cursor: default; }
