/* 殻: 上下のバー・ホーム・下からの板・確認・通知・検索バー・下部バーの共通ボタン */
.screen { position: fixed; inset: 0; }

/* ---- 上のバー ---- */
.topbar { position: fixed; left: 0; right: 0; top: 0; z-index: 20; height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 4px 0; display: flex; align-items: center; gap: 2px;
  background: var(--surface); border-bottom: 1px solid var(--line); transition: transform .22s ease; }
.ib { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; flex: none; }
.ib:active, .bb-btn:active, .tb-btn:active, .menu-item:active, .list .open:active, .continue:active { background: var(--press); }
.tb-title { flex: 1; min-width: 0; padding: 0 6px; line-height: 1.3; }
.tb-title b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title small { display: block; font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#homeBar .tb-title { padding-left: 12px; }
#homeBar .tb-title b { font-size: 17px; }

/* ---- 読む画面 ---- */
#scroller { position: fixed; inset: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#mount { padding-top: calc(var(--top-h) + var(--safe-t)); padding-bottom: calc(var(--bot-h) + var(--safe-b) + 8px); min-height: 100%; }
#mount.k-sheet, #mount.k-html { padding-bottom: calc(var(--bot-h) + var(--safe-b)); }
.chrome-hidden #readerBar { transform: translateY(-100%); }
.chrome-hidden #bottombar { transform: translateY(100%); }
#progress { position: fixed; left: 0; right: 0; top: calc(var(--top-h) + var(--safe-t) - 2px); height: 3px; z-index: 21;
  pointer-events: none; transition: top .22s ease; }
.chrome-hidden #progress { top: var(--safe-t); }
#progress i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
#loading { position: fixed; left: 0; right: 0; top: 40%; text-align: center; color: var(--sub); z-index: 5; pointer-events: none; }

/* ---- 下のバー（親指の位置） ---- */
#bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--bot-h) + var(--safe-b));
  padding: 0 4px var(--safe-b); display: flex; align-items: center; gap: 2px;
  background: var(--surface); border-top: 1px solid var(--line); transition: transform .22s ease; }
.finding #bottombar { visibility: hidden; }
.bb-btn { flex: none; width: 52px; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; border-radius: 10px; font-size: 11px; color: var(--sub); }
.bb-btn .icon { color: var(--ink); }
.bb-btn .aa { line-height: 22px; color: var(--ink); }
/* 中央の枠。中央寄せは左右の auto 余白で行う（justify-content: center だと、はみ出したとき左端が切れて戻れない）。
   収まらないときは枠の中だけ横にスクロールする */
#toolbar { flex: 1 1 auto; min-width: 0; height: 100%; display: flex; align-items: center; gap: 2px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; }
#toolbar::-webkit-scrollbar { display: none; }
#toolbar > :first-child { margin-left: auto; }
#toolbar > :last-child { margin-right: auto; }
/* 縮めるのは値の表示とシート名などの文字の長い押せる値（tb-btn tb-val）。押すだけのボタンは文字が欠けないよう縮めない */
#toolbar > .tb-val { flex: 0 1 auto; min-width: 2.5em; overflow: hidden; text-overflow: ellipsis; }
#toolbar > .tb-btn.tb-val { min-width: 44px; }
/* 狭い画面で中央に3個以上あるときは、目次・検索・表示を文字なしのアイコンだけにする（押せる大きさ 44px は保つ） */
.tb-compact .bb-btn { width: 44px; }
.tb-compact .bb-btn span { display: none; }

/* 描画が下部バーに置く部品（B と共有するクラス） */
.tb-btn { min-width: 44px; height: 44px; padding: 0 9px; border-radius: 10px; display: inline-flex; align-items: center;
  justify-content: center; gap: 4px; font-size: 14px; white-space: nowrap; flex: 0 0 auto; color: var(--ink); }
.tb-compact .tb-btn { padding: 0 7px; }
.tb-btn.on, .tb-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tb-btn .icon { width: 20px; height: 20px; }
.tb-val { font-size: 13px; color: var(--sub); white-space: nowrap; padding: 0 4px; flex: 0 1 auto; font-variant-numeric: tabular-nums; }
.tb-btn.tb-val { color: var(--ink); font-size: 13px; padding: 0 9px; max-width: 11em; overflow: hidden; text-overflow: ellipsis;
  display: inline-block; line-height: 44px; border: 1px solid var(--line); }
.tb-input { width: 3.4em; height: 36px; text-align: center; font-size: 16px; padding: 0 2px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--bg); flex: none; min-width: 2.6em; }

/* ---- 検索バー（下部バーの位置に重ねる） ---- */
#findbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 22; min-height: calc(var(--bot-h) + var(--safe-b));
  padding: 6px 4px calc(6px + var(--safe-b)) 10px; display: flex; align-items: center; gap: 2px;
  background: var(--surface); border-top: 1px solid var(--line); }
#findq { flex: 1; min-width: 0; height: 42px; font-size: 16px; padding: 0 12px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: var(--bg); }
#findc { font-size: 12px; color: var(--sub); min-width: 3.6em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- ホーム ---- */
#homeScroll { position: fixed; inset: 0; overflow: auto; overscroll-behavior: contain;
  padding: calc(var(--top-h) + var(--safe-t)) 0 calc(96px + var(--safe-b)); }
.home { max-width: 640px; margin: 0 auto; padding: 8px 14px 24px; }
.home h2 { font-size: 13px; color: var(--sub); font-weight: 600; margin: 22px 4px 8px; letter-spacing: .04em; }
.home .lead { color: var(--sub); font-size: 15px; line-height: 1.8; margin: 16px 4px; }
.continue { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; margin-top: 16px; padding: 14px 16px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.continue-k { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: .04em; }
.continue-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.continue b { font-size: 16px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue small { color: var(--sub); font-size: 12px; }
.meter { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.list li { display: flex; align-items: center; border-top: 1px solid var(--line); min-height: 60px; padding-right: 4px; }
.list li:first-child { border-top: 0; }
.list .open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 6px 10px 12px; min-height: 60px; }
.list .nm { flex: 1; min-width: 0; }
.list .nm b { display: block; font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .nm small { display: block; color: var(--sub); font-size: 12px; }
.kb { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 10px;
  font-weight: 700; color: #fff; letter-spacing: .02em; }
.kb-md { background: #4F5D6B; } .kb-docx { background: #2B579A; } .kb-sheet { background: #1E6B41; }
.kb-pptx { background: #B13F22; } .kb-pdf { background: #B3261E; } .kb-html { background: #8A4B08; }
.kb-text { background: #5F6B76; } .kb-image { background: #7B3FA0; } .kb-unsupported, .kb-guess { background: #6F757B; }
.guide { margin: 26px 0 0; padding: 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 14px; line-height: 1.8; color: var(--sub); }
.guide summary { color: var(--ink); font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: 10px;
  cursor: pointer; list-style: none; }
.guide summary::-webkit-details-marker { display: none; }
/* 開閉の印（山形）。閉じているとき下向き、開いているとき上向き */
.guide summary::after { content: ""; flex: none; width: 8px; height: 8px; margin: 0 4px 0 auto; border-right: 2px solid var(--sub);
  border-bottom: 2px solid var(--sub); transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.guide[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.guide ol { margin: 4px 0 8px; padding-left: 1.4em; color: var(--ink); }
.guide p { margin: 0 0 12px; }
.home-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 14px 16px calc(14px + var(--safe-b));
  background: linear-gradient(to bottom, transparent, var(--bg) 35%); }
.bigbtn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; max-width: 608px; margin: 0 auto;
  height: 56px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 600;
  box-shadow: 0 4px 14px var(--shade); }

/* ---- 下からの板 ---- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .42); opacity: 0; transition: opacity .2s; }
.backdrop.open { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-width: 640px; margin: 0 auto; max-height: 84dvh;
  display: flex; flex-direction: column; background: var(--surface); border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px var(--shade); transform: translateY(100%); transition: transform .22s ease; padding-bottom: var(--safe-b); }
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 18px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h3 { flex: 1; min-width: 0; margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { overflow: auto; padding: 6px 0 14px; overscroll-behavior: contain; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 6px 18px; text-align: left; font-size: 15px; }
.menu-item.cur { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.menu-row { display: flex; align-items: center; padding-right: 6px; }
.menu-row.cur { background: var(--accent-soft); }
.menu-item.grow { flex: 1; min-width: 0; }
.grow-txt { min-width: 0; }
.grow-txt b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow-txt small { display: block; font-size: 12px; color: var(--sub); }
.menu-h { margin: 14px 18px 4px; font-size: 12px; color: var(--sub); letter-spacing: .04em; }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.info { margin: 0; padding: 4px 18px 8px; display: grid; grid-template-columns: 5em 1fr; gap: 6px 10px; font-size: 14px; }
.info dt { color: var(--sub); }
.info dd { margin: 0; overflow-wrap: anywhere; }
.toc-item { display: block; width: 100%; text-align: left; min-height: 44px; padding: 10px 18px; font-size: 15px; line-height: 1.45; }
.toc-item.l2 { padding-left: 34px; }
.toc-item.l3 { padding-left: 50px; font-size: 14px; color: var(--sub); }
.toc-item.cur { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 var(--accent); }
.cell-full { padding: 8px 18px; }
.cell-v { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs); line-height: 1.7; }
.cell-f { margin: 12px 0 0; font-family: var(--mono); font-size: 13px; color: var(--sub); overflow-wrap: anywhere; }

/* 表示の板 */
.settings { padding: 4px 0; }
.set-row { padding: 10px 18px; }
.set-row h4 { margin: 0 0 8px; font-size: 13px; color: var(--sub); font-weight: 600; }
.set-note { margin: 4px 18px 10px; font-size: 12px; color: var(--sub); line-height: 1.7; }
.set-row .set-note { margin: 0 0 10px; }
.seg { display: flex; gap: 4px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.seg button { flex: 1; min-height: 44px; border-radius: 9px; font-size: 14px; }
.seg button.on { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px var(--shade); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 64px; height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 20px; }
.stepper .v { flex: 1; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- 確認・入力 ---- */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 18px; box-shadow: 0 8px 30px var(--shade); }
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.modal p { margin: 0 0 12px; line-height: 1.7; }
.modal-input { width: 100%; height: 46px; font-size: 16px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); }
.modal-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); font-size: 15px; }
.btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ---- 通知・お知らせ・ドロップ ---- */
#toast { position: fixed; left: 50%; bottom: calc(var(--bot-h) + var(--safe-b) + 14px); transform: translateX(-50%);
  z-index: 70; max-width: min(88vw, 520px); padding: 10px 14px; border-radius: 10px; background: rgba(28, 30, 33, .94);
  color: #fff; font-size: 14px; line-height: 1.6; pointer-events: none; opacity: 0; transition: opacity .2s; }
#toast.show { opacity: 1; }
#banner { position: fixed; left: 8px; right: 8px; top: calc(var(--top-h) + var(--safe-t) + 8px); z-index: 40; max-width: 560px;
  margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: 0 4px 16px var(--shade); font-size: 14px; }
#banner span { flex: 1; }
#drop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; border: 4px dashed var(--accent);
  background: var(--accent-soft); color: var(--accent); font-size: 20px; font-weight: 600; pointer-events: none; }

/* ---- 表示できなかったときの札 ---- */
.card { max-width: 560px; margin: 32px auto; padding: 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; line-height: 1.7; }
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card p { margin: 0 0 8px; color: var(--sub); font-size: 14px; overflow-wrap: anywhere; }
#mount > .card { margin: 32px 16px; }
@media (min-width: 600px) { #mount > .card { margin: 32px auto; } }

/* ---- 画像・HTML（文章系以外の殻寄りの見た目） ---- */
.imgv { min-height: calc(var(--view-h) - 30px); display: grid; place-items: center; padding: 12px; }
.imgv img { max-width: 100%; max-height: calc(var(--view-h) - 40px); height: auto; object-fit: contain;
  background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.imgv.full { display: block; overflow: auto; }
.imgv.full img { max-width: none; max-height: none; }
.imgv-meta { text-align: center; font-size: 12px; color: var(--sub); margin: 0; }
.htmlv { height: var(--view-h); display: flex; flex-direction: column; }
.htmlv-note { flex: none; margin: 0; padding: 6px 14px; font-size: 12px; color: var(--sub); border-bottom: 1px solid var(--line); }
.htmlv-frame { flex: 1; width: 100%; border: 0; background: #fff; color-scheme: light; }
.htmlv.src { height: auto; display: block; }
