:root {
  --bg: #f7f3ec;
  --card: #fffdf8;
  --ink: #2a2622;
  --muted: #7d746a;
  --line: #e4ddd1;
  --accent: #7a1f2b;
  --accent-soft: #f3e3e4;
  --fs: 19px;
  --serif: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --hl-y: #fbeaa0; --hl-g: #cdeccb; --hl-b: #cfe3f7; --hl-p: #f4d3e6;
  --c-green: #3f7d4a; --c-white: #c9b98d; --c-red: #b3262f; --c-violet: #6a3d8f; --c-rose: #d98aa6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513; --card: #211e1b; --ink: #ece6dc; --muted: #9b9184; --line: #34302b;
    --accent: #e08a95; --accent-soft: #3a2427;
    --hl-y: #5b4f1d; --hl-g: #24452a; --hl-b: #1f3a55; --hl-p: #4d2a40;
    --c-white: #d9cfb3;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); }
body { padding-top: calc(48px + env(safe-area-inset-top)); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; }
a { color: var(--accent); }

#top { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(48px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0; display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
#top-title { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top-actions { display: flex; gap: 6px; }
#top-actions button { background: none; border: 0; font-size: 15px; padding: 8px 10px; color: var(--accent); border-radius: 8px; }

#tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; background: none; border: 0; padding: 7px 0 6px; display: flex; flex-direction: column; align-items: center;
  font-size: 11px; color: var(--muted); gap: 1px; }
#tabs button .ti { font-size: 21px; line-height: 26px; filter: grayscale(1); opacity: .7; }
#tabs button.on { color: var(--accent); }
#tabs button.on .ti { filter: none; opacity: 1; }

#view { max-width: 720px; margin: 0 auto; padding: 12px 14px 30px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 12px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-size: 15px; text-decoration: none; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn:disabled { opacity: .5; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---- Today ---- */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daynav button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; width: 44px; height: 40px; font-size: 18px; color: var(--accent); }
.daynav .date { text-align: center; flex: 1; position: relative; }
.daynav .date .d1 { font-size: 17px; font-weight: 700; }
.daynav .date .d2 { font-size: 12px; color: var(--muted); }
.daynav .date input { position: absolute; inset: 0; opacity: 0; width: 100%; }
.cel { margin-top: 10px; }
.cel h1 { font-family: var(--serif); font-size: 23px; margin: 4px 0 2px; font-weight: 700; }
.cel .meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.15); }
.dot.green { background: var(--c-green); } .dot.white { background: #fff; border-color: var(--c-white); } .dot.red { background: var(--c-red); }
.dot.violet { background: var(--c-violet); } .dot.rose { background: var(--c-rose); }
.opt { font-size: 13px; color: var(--muted); margin-top: 6px; }
.mass-name { font-family: var(--serif); font-size: 18px; font-weight: 700; margin: 22px 0 4px; color: var(--accent); }
.reading { margin: 16px 0 6px; }
.reading .lab { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 8px; }
.reading .lab b { font-size: 14px; color: var(--accent); letter-spacing: .05em; }
.reading .lab .ref { font-size: 13px; color: var(--muted); text-align: right; }
.reading .note { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.alts { margin-top: 6px; }
.alts button { background: none; border: 1px dashed var(--line); color: var(--accent); border-radius: 8px; padding: 6px 10px; font-size: 13px; }

/* ---- Scripture text ---- */
.scripture { font-family: var(--serif); font-size: var(--fs); line-height: 1.95; letter-spacing: .02em; word-break: normal; line-break: strict; }
.scripture .v { border-radius: 4px; }
.scripture .vn { font-family: var(--sans); font-size: .55em; color: var(--accent); vertical-align: .55em; padding: 0 .25em 0 .1em; cursor: pointer; user-select: none; -webkit-user-select: none; }
.scripture .vn.mk::after { content: "🔖"; font-size: .9em; }
.scripture .part { font-family: var(--sans); font-size: .5em; color: var(--muted); vertical-align: .6em; }
.scripture.para .v { display: inline; }
.scripture .v.hl-y { background: var(--hl-y); } .scripture .v.hl-g { background: var(--hl-g); }
.scripture .v.hl-b { background: var(--hl-b); } .scripture .v.hl-p { background: var(--hl-p); }
.scripture .gap { display: block; text-align: center; color: var(--muted); font-size: 14px; margin: 2px 0; }
.scripture rt { font-family: var(--sans); font-size: .45em; color: var(--accent); }
.scripture .tapped { background: var(--accent-soft); outline: 1px solid var(--accent); border-radius: 3px; }
.missing { font-size: 14px; color: var(--muted); background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; }

/* ---- Bible ---- */
.grp { font-size: 13px; color: var(--muted); margin: 18px 2px 6px; font-weight: 700; letter-spacing: .08em; }
.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.books button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; font-size: 14px; text-align: center; }
.books button.na { opacity: .45; }
.chaps { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.chaps button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; height: 48px; font-size: 16px; }
.chapnav { display: flex; justify-content: space-between; margin: 26px 0 10px; gap: 10px; }
.chapnav button { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: var(--accent); font-size: 15px; }
.ch-title { font-family: var(--serif); font-size: 21px; font-weight: 700; margin: 6px 0 12px; }

/* ---- Marks ---- */
.mark { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.mark .mref { font-size: 13px; color: var(--accent); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.mark .mtext { font-family: var(--serif); font-size: 15px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.y { background: var(--hl-y); } .sw.g { background: var(--hl-g); } .sw.b { background: var(--hl-b); } .sw.p { background: var(--hl-p); }

/* ---- Settings ---- */
.set h3 { margin: 0 0 6px; font-size: 16px; }
.set p { margin: 6px 0; font-size: 14px; line-height: 1.6; }
.set input[type=range] { width: 100%; }
.prog { background: var(--line); height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 0; }
.prog > div { background: var(--accent); height: 100%; width: 0; transition: width .2s; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 15px; }
code.bm { display: block; font-size: 11px; word-break: break-all; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; user-select: all; -webkit-user-select: all; }
ol.steps { padding-left: 1.3em; margin: 6px 0; font-size: 14px; line-height: 1.7; }

/* ---- Bottom sheet ---- */
#sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 40; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 62vh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.18);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
#sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.dict-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dict-head .w { font-family: var(--serif); font-size: 28px; font-weight: 700; }
.dict-head .r { font-size: 17px; color: var(--accent); }
.dict-head .cm { font-size: 11px; color: #fff; background: var(--c-green); border-radius: 4px; padding: 1px 5px; }
.dict-entry { padding: 10px 0; border-bottom: 1px solid var(--line); }
.dict-entry:last-child { border-bottom: 0; }
.dict-entry ol { margin: 6px 0 0; padding-left: 1.4em; font-size: 15px; line-height: 1.5; }
.dict-entry .alt { font-size: 13px; color: var(--muted); margin-top: 2px; }
.dict-why { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }
.chips button { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; font-size: 14px; font-family: var(--serif); }
.chips button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.act { display: grid; gap: 8px; }
.act .colors { display: flex; gap: 10px; justify-content: center; margin: 4px 0 6px; }
.act .colors button { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); }
.act .colors button.y { background: var(--hl-y); } .act .colors button.g { background: var(--hl-g); }
.act .colors button.b { background: var(--hl-b); } .act .colors button.p { background: var(--hl-p); }
.act .colors button.none { background: var(--card); font-size: 16px; }
.act .colors button.on { border-color: var(--accent); }
.act > button { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60;
  background: rgba(40,36,32,.92); color: #fff; padding: 9px 16px; border-radius: 20px; font-size: 14px; max-width: 90vw; }
::highlight(tap) { background-color: #f1c9cd; color: inherit; }
@media (prefers-color-scheme: dark) { ::highlight(tap) { background-color: #6a3a40; } }
