/* モジナリア。デザインシステム v1.0（docs/デザイン/）適用。
   合言葉「文具のように道具らしく、原稿より前に出ない」。
   角丸4px基本（例外：主ボタン・✂＝999px、バッジ＝3px）。枠1.5px・区切り1px。
   見出し・主役文言＝Kiwi Maru、数字＝DM Mono、本文＝端末ゴシック */

:root {
  --bg: #f7faf9;  --card: #ffffff;  --ink: #1d1d1b;
  --sub: #54615c;  --line: #d3ddd9;  --line-strong: #2a2a27;
  --accent: #14958f;  --accent-deep: #0d6b66;  --accent-bg: #eaf6f4;
  --danger: #c0392b;  --warn-bg: #b5541e;
  --radius: 4px;  --radius-badge: 3px;  --border-w: 1.5px;
  --font-brand: "Kiwi Maru", "Hiragino Sans", sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;

  /* 種別パレット（KP盤の実値を継承。KPメモだけDS指定で淡色＋破線運用） */
  --k-desc: #2f7d68;  --k-desc-bg: #e4f2ee;
  --k-info: #3f6d9e;  --k-info-bg: #e8f0f8;
  --k-doc:  #8a6a2f;  --k-doc-bg:  #f5efe0;
  --k-proc: #63558c;  --k-proc-bg: #eeebf5;
  --k-expl: #4a6f7a;  --k-expl-bg: #e6f0f2;
  --k-narr: #7a7268;  --k-narr-bg: #f0eeea;
  --k-meta: #9aa0a8;  --k-meta-bg: #f2f4f6;
  --k-memo: #b9ad8a;  --k-memo-bg: #faf6ea;
  --k-un:   #a04a4a;  --k-un-bg:   #f7eaea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a201f;  --card: #212927;  --ink: #e6ece9;
    --sub: #9fb0ab;  --line: #32403d;  --line-strong: #0b0e0d;
    --accent: #3fbdb5;  --accent-deep: #7fd6cf;  --accent-bg: #1e3230;

    --k-desc: #6fc4a8;  --k-desc-bg: #1e3a33;
    --k-info: #82b2e2;  --k-info-bg: #1f3244;
    --k-doc:  #d4ab63;  --k-doc-bg:  #3a301d;
    --k-proc: #a89bd6;  --k-proc-bg: #2c2740;
    --k-expl: #8db8c4;  --k-expl-bg: #22343a;
    --k-narr: #b5aca0;  --k-narr-bg: #302c27;
    --k-meta: #9aa2aa;  --k-meta-bg: #292d31;
    --k-memo: #c9a86a;  --k-memo-bg: #332b1c;
    --k-un:   #e08a80;  --k-un-bg:   #3a2523;
  }
}

.k-desc { --kc: var(--k-desc); --kc-bg: var(--k-desc-bg); }
.k-info { --kc: var(--k-info); --kc-bg: var(--k-info-bg); }
.k-doc  { --kc: var(--k-doc);  --kc-bg: var(--k-doc-bg); }
.k-proc { --kc: var(--k-proc); --kc-bg: var(--k-proc-bg); }
.k-expl { --kc: var(--k-expl); --kc-bg: var(--k-expl-bg); }
.k-narr { --kc: var(--k-narr); --kc-bg: var(--k-narr-bg); }
.k-meta { --kc: var(--k-meta); --kc-bg: var(--k-meta-bg); }
.k-memo { --kc: var(--k-memo); --kc-bg: var(--k-memo-bg); }
.k-un   { --kc: var(--k-un);   --kc-bg: var(--k-un-bg); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.9;
}
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
svg { vertical-align: middle; }
.num { font-family: var(--font-mono); }

/* ============ 枠組み：ドロワー＋本文 ============ */
.layout { min-height: 100vh; }
.main { min-width: 0; }

.dveil {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .35);
  display: none;
}
.dveil.show { display: block; }

.drawer {
  position: fixed; top: 0; bottom: 0; z-index: 41;
  width: min(86vw, 330px);
  background: var(--bg);
  transition: transform .18s ease-out;
  overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.dw-l { left: 0; border-right: var(--border-w) solid var(--line); transform: translateX(-102%); }
.dw-r { right: 0; border-left: var(--border-w) solid var(--line); transform: translateX(102%); }
.drawer.open { transform: none; }

@media (min-width: 1180px) {
  .layout { display: flex; }
  .drawer {
    position: sticky; top: 0;
    transform: none;
    height: 100vh; flex: none;
  }
  .dw-l { width: 320px; order: 1; }
  .main { flex: 1; order: 2; min-width: 0; }
  .dw-r { width: 280px; order: 3; }
  .dveil, .mbtn { display: none !important; }
  .shelf { left: 320px; right: 280px; }
}

.d-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 10px 9px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--card);
  font-family: var(--font-brand); font-weight: 500; font-size: 15px;
  border-bottom: var(--border-w) solid var(--line-strong);
}
.d-head svg { color: var(--ink); }
.d-acts { display: flex; gap: 6px; margin-left: auto; }
.markrow {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px;
}
.markrow label { flex: 1; font-size: 13px; color: var(--sub); }
.markrow input {
  width: 4.5em; text-align: center;
  border: var(--border-w) solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 6px 4px;
  font-size: 16px; font-family: var(--font-mono);
}
.markrow input:focus { outline: none; border-color: var(--accent); }
.ckrow {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 6px; font-size: 13px; color: var(--sub);
  cursor: pointer;
}
.ckrow input { width: 18px; height: 18px; accent-color: var(--accent); }
.d-note { margin: 0 6px 6px; font-size: 11px; color: var(--sub); }

/* ---- 目次 ---- */
.toc { padding: 8px 8px 12px; }
.t-pg, .t-sc {
  display: flex; align-items: center; gap: 5px;
  border-radius: var(--radius);
}
.t-sc { padding-left: 22px; }
.t-sc.cur { background: var(--accent-bg); }
.t-sc.cur .t-name { color: var(--accent-deep); font-weight: 600; }
.t-tgl {
  flex: none; width: 24px; min-height: 42px;
  border: none; background: none;
  color: var(--sub); font-size: 10px; cursor: pointer;
}
.pnum {
  flex: none;
  font-family: var(--font-mono); font-size: 10px;
  color: var(--accent-deep); background: var(--accent-bg);
  border: 1px solid var(--line); border-radius: var(--radius-badge);
  padding: 0 5px;
}
.t-name {
  flex: 1; min-width: 0;
  border: none; background: none;
  text-align: left; padding: 10px 2px;
  font-size: 13.5px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.t-pg > .t-name { font-weight: 600; }
.t-meta { flex: none; font-family: var(--font-mono); font-size: 9.5px; color: var(--sub); white-space: nowrap; }
.t-more {
  flex: none; min-width: 34px; min-height: 42px;
  border: none; background: none; border-radius: var(--radius);
  color: var(--sub); font-size: 15px; letter-spacing: 1px; cursor: pointer;
}
.t-more:active { background: var(--line); }

/* 並べ替えの▲▼＝つまみ風（8b） */
.mv { display: flex; flex: none; }
.mv button {
  border: 1px solid var(--line); background: none;
  width: 24px; min-height: 34px; padding: 0;
  color: var(--sub); opacity: .75;
  font-size: 8px; cursor: pointer;
  border-radius: var(--radius-badge);
  margin-left: 2px;
}
.mv button:active { background: var(--line); opacity: 1; }

/* ⋯のインライン展開（モーダルではない） */
.t-panel {
  margin: 2px 4px 8px 24px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card);
}
.t-panel input {
  border: none; border-bottom: 1px solid var(--line);
  background: none; padding: 8px 4px; font-size: 16px;
  margin-bottom: 4px;
}
.t-panel input:focus { outline: none; border-bottom-color: var(--accent); }
.t-panel button {
  border: none; background: none;
  text-align: left; padding: 10px 6px; min-height: 44px;
  font-size: 13.5px; border-radius: var(--radius); cursor: pointer;
}
.t-panel button:active { background: var(--line); }
.t-panel .danger { color: var(--danger); }

/* ---- 機能ドロワー ---- */
.d-sec { padding: 4px 10px; }
.d-sec summary {
  padding: 11px 4px; font-size: 13px; font-weight: 600;
  color: var(--sub); cursor: pointer; list-style-position: inside;
}
.d-card {
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  padding: 4px 12px 10px;
  margin: 2px 0 8px;
}
.statgrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin: 8px 0;
}
.statgrid span {
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  padding: 7px 0; text-align: center;
}
.statgrid b {
  display: block;
  font-family: var(--font-mono); font-weight: 500; font-size: 14px;
  color: var(--accent-deep);
}
.statgrid i { font-style: normal; font-size: 9px; color: var(--sub); }
.d-chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px 2px 10px; }
.chip {
  border: var(--border-w) solid var(--line);
  background: var(--card);
  border-radius: var(--radius-badge);
  padding: 3px 10px; min-height: 30px;
  font-size: 12px; color: var(--sub);
  cursor: pointer; white-space: nowrap;
}
.chip.kind { border-left: 4px solid var(--kc, var(--line)); }
.chip.kind.on { background: var(--kc-bg); border-color: var(--kc); color: var(--kc); font-weight: 700; }
.chip.tag { border-color: var(--tc, var(--line)); color: var(--tc, var(--sub)); }
.chip.tag.on { font-weight: 700; background: var(--card); box-shadow: inset 0 0 0 1px var(--tc); }
.d-list { display: flex; flex-direction: column; padding: 2px 0 8px; }
.d-list button {
  border: none; background: none;
  text-align: left; padding: 10px 4px; min-height: 44px;
  font-size: 13.5px; border-radius: var(--radius); cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid var(--line);
}
.d-list button:last-child { border-bottom: none; }
.d-list button:active { background: var(--line); }
.fbdg {
  flex: none; width: 44px; text-align: center;
  font-family: var(--font-mono); font-size: 9px; font-weight: 500;
  background: var(--accent-bg); color: var(--accent-deep);
  border: 1px solid var(--line); border-radius: var(--radius-badge);
  padding: 2px 4px;
}
.fmain { flex: 1; min-width: 0; }
.fmain small { display: block; font-size: 10px; color: var(--sub); }
.d-stat { margin: 2px 2px 6px; font-family: var(--font-mono); font-size: 11px; color: var(--sub); }
.d-tags { padding: 2px 0 8px; }
.tagrow { display: flex; align-items: center; gap: 8px; padding: 3px 2px; border-bottom: 1px solid var(--line); }
.tagrow:last-child { border-bottom: none; }
.tagrow input {
  flex: 1; min-width: 0;
  border: none; background: none; padding: 8px 2px; font-size: 16px;
}
.tagrow input:focus { outline: none; }
.tagrow .tcount { font-family: var(--font-mono); font-size: 10px; color: var(--sub); }
.tsw {
  flex: none; width: 16px; height: 16px;
  border: none; border-radius: 50%; cursor: pointer;
}
.mini {
  border: var(--border-w) solid var(--line); background: var(--card);
  border-radius: var(--radius); padding: 5px 11px;
  font-size: 12px; color: var(--sub);
  min-height: 32px; cursor: pointer;
}
.mini:active { background: var(--line); }
.toc > .mini {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: calc(100% - 8px);
  margin: 10px 4px 2px;
  border-style: dashed; padding: 9px 0; min-height: 42px;
}

/* ============ 上のバー（2段：タイトル行＋道具バー） ============ */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-r1 {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 12px 0;
}
.top-r2 {
  display: flex; align-items: center; gap: 2px;
  padding: 0 8px 4px;
}
.top h1 {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-brand); font-weight: 500; font-size: 18px;
  margin: 0 4px;
}
.top h1 small { color: var(--sub); font-family: var(--font-mono); font-weight: 400; font-size: 10px; }
.icon {
  min-width: 44px; min-height: 42px;
  border: none; background: none; border-radius: var(--radius);
  color: var(--sub); cursor: pointer;
  display: inline-grid; place-items: center;
}
.icon:active { background: var(--line); }
.icon:disabled { opacity: .3; }
.icon.on { color: var(--accent-deep); background: var(--accent-bg); }
.title {
  flex: 1; min-width: 0;
  border: none; background: none;
  text-align: center;
  font-family: var(--font-brand); font-weight: 500; font-size: 16.5px;
  padding: 6px 4px;
}
.title:focus { outline: none; border-bottom: 2px solid var(--accent); }
.hdr-chars {
  flex: none; min-width: 44px; text-align: right;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--sub);
}

.warn { background: var(--warn-bg); color: #fff; padding: 6px 12px; font-size: 13px; }

.findi {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--sub);
}
.findi-x {
  margin-left: auto;
  border: var(--border-w) solid var(--line); background: none;
  border-radius: var(--radius); padding: 3px 12px; min-height: 30px;
  font-size: 12px; cursor: pointer;
}

/* ============ ページ送り ============ */
.pager {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.pgr {
  flex: none;
  border: none; background: none; border-radius: var(--radius);
  min-width: 44px; min-height: 40px;
  font-size: 20px; color: var(--sub); cursor: pointer;
}
.pgr:active { background: var(--line); }
.pgr:disabled { opacity: .25; }
.pgr-name {
  flex: 1; min-width: 0;
  border: none; background: none;
  min-height: 40px;
  font-family: var(--font-brand); font-weight: 500; font-size: 14px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pgr-name small { color: var(--sub); font-family: var(--font-mono); font-weight: 400; font-size: 10px; }
.olbtn { font-size: 16px; }

/* ============ 一覧（見出しの深さ） ============ */
.ol { padding: 4px 0 120px; }
.ol-pg, .ol-sc {
  display: flex; align-items: baseline; gap: 10px;
  width: 100%;
  border: none; background: none;
  text-align: left; cursor: pointer;
  border-radius: var(--radius);
  padding: 10px 8px; min-height: 48px;
}
.ol-pg { margin-top: 10px; border-bottom: var(--border-w) solid var(--accent); border-radius: 0; }
.ol-pg .ol-name { font-family: var(--font-brand); font-weight: 500; font-size: 17px; color: var(--accent-deep); }
.ol-sc { padding-left: 26px; }
.ol-sc:active, .ol-pg:active { background: var(--line); }
.ol-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-meta { flex: none; font-family: var(--font-mono); font-size: 10px; color: var(--sub); }

/* ============ 選んでまとめる ============ */
.t-sel {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  border: none; background: none;
  text-align: left; cursor: pointer;
  border-radius: var(--radius);
  padding: 9px 6px 9px 20px; min-height: 44px;
}
.t-sel:active { background: var(--line); }
.t-sel .t-chk { flex: none; color: var(--sub); }
.t-sel.on { background: var(--accent-bg); }
.t-sel.on .t-chk, .t-sel.on .t-name { color: var(--accent-deep); font-weight: 600; }
.mini.selon { border-color: var(--accent); color: var(--accent-deep); }
.b-sel {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-left: 4px solid var(--kc, var(--line));
  border-radius: var(--radius);
  text-align: left; cursor: pointer;
  padding: 10px 10px 10px 12px; min-height: 48px;
  margin: 5px 0;
}
.b-sel .t-chk { flex: none; color: var(--sub); }
.b-sel .b-sel-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-sel.on { background: var(--accent-bg); border-color: var(--accent); }
.b-sel.on .t-chk, .b-sel.on .b-sel-t { color: var(--accent-deep); font-weight: 600; }
.selbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: var(--border-w) solid var(--line-strong);
}
.sel-n { flex: 1; font-size: 12px; color: var(--sub); }
.selbar button {
  flex: none;
  border: var(--border-w) solid var(--line); background: var(--card);
  border-radius: var(--radius);
  padding: 8px 14px; min-height: 40px;
  font-size: 13px; cursor: pointer;
}
.selbar button:active { background: var(--line); }
.selbar button:disabled { opacity: .35; }

/* ============ 本文（文書アウトライン） ============ */
.tree { padding: 6px 18px 150px; max-width: 720px; margin: 0 auto; }
.hide { display: none; }

.pgh {
  margin: 20px 0 8px;
  border-bottom: var(--border-w) solid var(--accent);
  padding-bottom: 6px;
}
.pgh-r1 { display: flex; align-items: center; gap: 4px; }
.pgh input {
  flex: 1; min-width: 0;
  border: none; background: none;
  font-family: var(--font-brand); font-weight: 500; font-size: 17px;
  color: var(--accent-deep);
  padding: 4px 0;
}
.pgh input:focus { outline: none; }
.pgh input::placeholder { color: var(--line); }
.pgh-meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--sub);
}

.ftgl {
  flex: none; width: 24px; min-height: 36px;
  border: none; background: none; padding: 0;
  color: var(--sub); opacity: .6;
  font-size: 10px; cursor: pointer; border-radius: var(--radius);
}
.ftgl:active { background: var(--line); }

.sch { display: flex; align-items: center; gap: 8px; margin: 14px 0 2px; }
.sqd { flex: none; width: 9px; height: 9px; background: var(--accent); }
.sch input {
  flex: 1; min-width: 0;
  border: none; background: none;
  /* 入力欄は16px未満にしない。iOSが拡大して戻らない（KP盤の教訓） */
  font-family: var(--font-brand); font-weight: 500; font-size: 16px;
  padding: 4px 0;
}
.sch input:focus { outline: none; }
.sch input::placeholder { color: var(--line); }
.scc { flex: none; font-family: var(--font-mono); font-size: 10px; color: var(--sub); }

/* ブロック＝本文。組み替え＝カード、執筆＝流れ（左3px線のみ） */
.blk {
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-left: 4px solid var(--kc, var(--line));
  border-radius: var(--radius);
  padding: 6px 12px;
  margin: 6px 0;
}
.blk.unkind, .blk.k-memo { border-style: dashed; }
.blk.k-memo { background: var(--kc-bg); }
.blk.act {
  border-color: var(--accent);
  border-left-color: var(--kc, var(--accent));
  box-shadow: 0 2px 8px rgba(20, 149, 143, .12);
}
.blk textarea {
  display: block; width: 100%;
  border: none; background: none;
  resize: none; overflow: hidden;
  padding: 2px 0;
  min-height: 1.9em;
  line-height: 1.9;
}
.blk textarea:focus { outline: none; }
.bhead {
  display: block; width: 100%;
  border: none; background: none;
  font-size: 16px; font-weight: 600;
  color: var(--kc, var(--sub));
  padding: 2px 0 0;
}
.bhead:focus { outline: none; }
.bhead::placeholder { color: var(--line); font-weight: normal; }
.btext {
  padding: 2px 0;
  white-space: pre-wrap;
  cursor: text;
  min-height: 1.9em;
  line-height: 1.9;
}
.leadline {
  display: block;
  font-weight: 600;
  color: var(--kc, var(--ink));
}

/* 操作行：触っているブロックの直下にだけインライン展開 */
.bctl { display: none; border-top: 1px solid var(--line); margin-top: 8px; padding: 6px 0 4px; }
.blk.act .bctl { display: block; }
.brow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 2px 0; }
.kbtn {
  border: var(--border-w) solid var(--line); background: var(--card);
  border-left: 4px solid var(--kc, var(--line));
  border-radius: var(--radius-badge);
  padding: 2px 9px; min-height: 30px;
  font-size: 11.5px; color: var(--sub); cursor: pointer;
}
.kbtn.on { background: var(--kc-bg); border-color: var(--kc); color: var(--kc); font-weight: 700; }
.cpy {
  margin-left: auto;
  border: var(--border-w) dashed var(--line); background: none;
  border-radius: var(--radius-badge);
  padding: 2px 9px; min-height: 30px;
  font-size: 10.5px; color: var(--sub); cursor: pointer;
}
.cpy.on { border-style: solid; border-color: var(--accent); color: var(--accent-deep); }
.tchip {
  border: var(--border-w) solid var(--tc, var(--line));
  background: var(--card);
  border-radius: var(--radius-badge);
  padding: 2px 9px; min-height: 30px;
  font-size: 11.5px; color: var(--tc, var(--sub)); cursor: pointer;
}
.tchip.on { font-weight: 700; box-shadow: inset 0 0 0 1px var(--tc); }
.tadd {
  flex: none; width: 6.5em;
  border: none; background: none;
  font-size: 16px; color: var(--sub);
  padding: 4px 2px;
}
.tadd:focus { outline: none; border-bottom: 1px solid var(--accent); }
.bop {
  border: none; background: none;
  padding: 6px 8px; min-height: 36px;
  font-size: 11.5px; color: var(--sub);
  border-radius: var(--radius); cursor: pointer;
}
.bop:active { background: var(--line); }
.bop.danger { color: var(--danger); }

/* ブロック間の＋（ギャップ挿入）＝薄いゴースト */
.gap {
  display: block; width: 100%;
  border: none; background: none;
  min-height: 17px; padding: 0;
  color: transparent; font-size: 11px;
  cursor: pointer; line-height: 1;
}
.gap:active, .gap:hover { color: var(--sub); }

/* ============ 下の棚（✂中央固定＋4枠） ============ */
.shelf {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center;
  padding: 4px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: var(--border-w) solid var(--line-strong);
}
.shelf button {
  flex: 1;
  border: none; background: none;
  color: var(--ink); cursor: pointer;
  padding: 6px 0 2px; min-height: 48px;
  font-size: 14px;
}
.shelf button i {
  display: block; font-style: normal;
  font-size: 9px; color: var(--sub); margin-top: 1px;
}
.shelf button:disabled { color: var(--line); }
.shelf button:disabled i { color: var(--line); }
.shelf .scut {
  flex: none;
  width: 50px; height: 50px; min-height: 50px;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  border: var(--border-w) solid var(--accent-deep);
  margin: 0 6px;
  opacity: .45;
}
.shelf .scut.on { opacity: 1; box-shadow: 0 4px 12px rgba(20, 149, 143, .3); }

/* ============ 執筆モード：構造の道具を消して文章だけに ============ */
#app.mode-write .gap,
#app.mode-write .bctl,
#app.mode-write .ftgl,
#app.mode-write .scc { display: none; }
#app.mode-write .blk {
  background: none; border: none;
  border-left: 3px solid var(--kc, transparent);
  border-radius: 0;
  padding: 2px 0 2px 12px;
  margin: 4px 0;
}
#app.mode-write .blk.k-memo {
  background: var(--kc-bg);
  border-left-style: dashed;
  font-size: 14px; color: var(--sub);
}
#app.mode-write .blk.act { box-shadow: none; }
#app.mode-write .pgh input { font-size: 17px; }

/* ============ トースト ============ */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 60;
  background: var(--ink); color: var(--bg);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 12.5px;
  max-width: 86vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============ 一覧 ============ */
.list-top { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; }
.open-btn { margin-left: auto; }
.books { padding: 12px 14px 60px; max-width: 760px; margin: 0 auto; }
.empty { color: var(--sub); text-align: center; margin-top: 48px; }
.bkcard {
  display: flex; align-items: stretch;
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  margin: 8px 0;
  overflow: hidden;
}
.bkcard:active { border-color: var(--accent); }
.bk-open {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  border: none; background: none;
  padding: 13px 14px;
  cursor: pointer; text-align: left;
}
.bk-x {
  flex: none;
  border: none; background: none;
  border-left: 1px solid var(--line);
  min-width: 48px;
  color: var(--sub); font-size: 14px; cursor: pointer;
}
.bk-x:active { background: var(--k-un-bg); color: var(--k-un); }
.bk-t { font-family: var(--font-brand); font-weight: 500; font-size: 15.5px; }
.bk-m { color: var(--sub); font-family: var(--font-mono); font-size: 11px; }

.newbook {
  display: block;
  margin: 18px auto 0;
  background: var(--accent); color: #fff;
  border: var(--border-w) solid var(--accent-deep);
  border-radius: 999px;
  padding: 13px 28px; min-height: 52px;
  font-family: var(--font-brand); font-weight: 500; font-size: 15px;
  box-shadow: 0 4px 12px rgba(20, 149, 143, .3);
  cursor: pointer;
}
