/* ===== Folio ===== */
:root {
  --bg: #12110E;
  --surface: #1C1A16;
  --surface2: #24211C;
  --line: #2E2A23;
  --line2: #3A352C;
  --text: #EDE6D6;
  --text-strong: #F5EFE2;
  --sub: #A69C88;
  --mute: #8C836F;
  --accent: #C9A45C;
  --accent-ink: #1A160F;
  --idea: #E2A65B;  --idea-soft: #2A2116;  --idea-ink: #22180A;
  --lib: #7FB2A8;   --lib-soft: #22302D;   --lib-ink: #10201C;
  --memo: #8FA6CF;  --memo-soft: #1E2533;  --memo-ink: #0F1626;
  --ins: #C49BD6;   --ins-soft: #261F2C;   --ins-ink: #1E1426;
  --star-off: #4A4438;
  --shadow: 0 10px 28px rgba(0, 0, 0, .45);
  --serif: 'Shippori Mincho B1', 'Yu Mincho', serif;
  --latin: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F4EFE4; --surface: #FBF8F1; --surface2: #EEE7D8; --line: #E2D9C6; --line2: #D3C8B0;
    --text: #2A251C; --text-strong: #17130C; --sub: #6E6553; --mute: #857B66;
    --accent: #8C6A24; --accent-ink: #FFFFFF;
    --idea: #A8661A; --idea-soft: #F6E7D2; --idea-ink: #FFFFFF;
    --lib: #3B7468; --lib-soft: #DCEBE7; --lib-ink: #FFFFFF;
    --memo: #45608F; --memo-soft: #E0E6F1; --memo-ink: #FFFFFF;
    --ins: #7D4F93; --ins-soft: #EEE2F3; --ins-ink: #FFFFFF;
    --star-off: #D8CDB6; --shadow: 0 10px 28px rgba(60, 45, 20, .18);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #F4EFE4; --surface: #FBF8F1; --surface2: #EEE7D8; --line: #E2D9C6; --line2: #D3C8B0;
  --text: #2A251C; --text-strong: #17130C; --sub: #6E6553; --mute: #857B66;
  --accent: #8C6A24; --accent-ink: #FFFFFF;
  --idea: #A8661A; --idea-soft: #F6E7D2; --idea-ink: #FFFFFF;
  --lib: #3B7468; --lib-soft: #DCEBE7; --lib-ink: #FFFFFF;
  --memo: #45608F; --memo-soft: #E0E6F1; --memo-ink: #FFFFFF;
  --ins: #7D4F93; --ins-soft: #EEE2F3; --ins-ink: #FFFFFF;
  --star-off: #D8CDB6; --shadow: 0 10px 28px rgba(60, 45, 20, .18);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--sans); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----- レイアウト ----- */
#app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; padding: calc(env(safe-area-inset-top) + 16px) 18px 120px; max-width: 1100px; margin: 0 auto; }
.side { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: color-mix(in srgb, var(--bg) 92%, black); border-top: 1px solid var(--line);
  padding: 4px 6px calc(env(safe-area-inset-bottom) + 6px);
  backdrop-filter: blur(10px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px; padding: 6px 0; border: 0; background: none; color: var(--mute); font-size: 10px; text-decoration: none; }
.tab.is-on { color: var(--tc, var(--accent)); }
.tab svg { width: 22px; height: 22px; }
.fab {
  position: fixed; z-index: 21; right: max(18px, calc((100vw - 1100px) / 2 + 18px)); bottom: calc(env(safe-area-inset-bottom) + 84px);
  width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--fc, var(--accent)); color: var(--fi, var(--accent-ink));
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}

@media (min-width: 900px) {
  .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
    width: 232px; flex: none; padding: 26px 14px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, black);
  }
  :root[data-theme="light"] .side { background: var(--surface2); }
  .main { padding: 32px 40px 80px; }
  .fab { bottom: 32px; right: 32px; }
  .side .logo { margin: 0 10px 18px; }
  .side .tab { flex: none; flex-direction: row; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; font-size: 14px; color: var(--sub); }
  .side .tab:hover { background: var(--surface); }
  .side .tab.is-on { background: var(--surface2); color: var(--tc, var(--accent)); font-weight: 700; }
  .side .tab svg { width: 20px; height: 20px; }
  .side .count { margin-left: auto; font-size: 12px; color: var(--mute); font-weight: 400; }
  .side .sp { flex: 1; }
  .homehead .logo { visibility: hidden; height: 20px; }
}

/* ----- 共通パーツ ----- */
.logo { font-family: var(--latin); font-style: italic; font-weight: 600; font-size: 40px; line-height: 1; color: var(--accent); letter-spacing: .01em; text-decoration: none; }
.logo small { display: block; margin-top: 4px; font-family: var(--sans); font-style: normal; font-weight: 400; font-size: 11px; color: var(--sub); letter-spacing: .18em; }
.latin { font-family: var(--latin); font-style: italic; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 18px; }
.pagehead h1 { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 700; letter-spacing: .06em; }
.pagehead .latin { font-size: 16px; margin-left: 10px; color: var(--pc, var(--accent)); }
.sec { margin: 26px 0 0; }
.sechead { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.sechead h2 { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.more { font-size: 12px; color: var(--sub); text-decoration: none; background: none; border: 0; padding: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line2); color: var(--sub); white-space: nowrap; }
.stars { font-size: 11px; color: var(--accent); letter-spacing: 1px; white-space: nowrap; }
.stars i { font-style: normal; color: var(--star-off); }
.empty { border: 1px dashed var(--line2); border-radius: 14px; padding: 18px; color: var(--sub); font-size: 13px; display: flex; align-items: center; gap: 12px; }
.btn { height: 44px; padding: 0 18px; border-radius: 13px; border: 1px solid var(--line2); background: none; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; text-decoration: none; white-space: nowrap; flex: none; }
.btn.primary { border: 0; background: var(--bc, var(--accent)); color: var(--bi, var(--accent-ink)); font-weight: 700; }
.btn.small { height: 34px; padding: 0 12px; font-size: 12px; border-radius: 10px; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: none; color: var(--sub); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.iconbtn:hover { background: var(--surface); color: var(--text); }
.search { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 15px; }
.search svg { color: var(--mute); flex: none; }

/* ----- ホーム ----- */
.homehead { display: flex; align-items: flex-end; justify-content: space-between; margin: 8px 0 18px; }
.homehead .stat { font-size: 11px; color: var(--sub); text-align: right; line-height: 1.7; }
.revisit { margin-top: 18px; background: var(--surface); border: 1px solid var(--line2); border-radius: 18px; padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 10px; }
.revisit .lab { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.revisit .lab .latin { color: var(--accent); font-size: 16px; letter-spacing: .05em; }
.revisit .lab span:last-child { font-size: 11px; color: var(--sub); }
.revisit p { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.75; color: var(--text-strong); }
.revisit .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.revisit .foot a { font-size: 12px; color: var(--sub); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.homegrid { display: grid; gap: 0 36px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .homegrid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }

/* ----- 本 ----- */
.shelf-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.shelf-row::-webkit-scrollbar { display: none; }
.shelf-row .book { width: 84px; flex: none; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 20px 14px; }
@media (min-width: 900px) { .shelf { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 26px 20px; } }
.book { display: flex; flex-direction: column; gap: 6px; min-width: 0; text-decoration: none; color: var(--text); }
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 3px 7px 7px 3px; overflow: hidden; background: var(--cv, #3E3326); box-shadow: inset 5px 0 0 rgba(0,0,0,.22), 0 6px 14px rgba(0,0,0,.3); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .ct { position: absolute; inset: 0; padding: 10px 9px; font-family: var(--serif); font-size: 12px; line-height: 1.45; color: #F1E8D6; overflow: hidden; }
.book .bt { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book .ba { font-size: 10px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book:hover .cover { transform: translateY(-2px); transition: transform .15s; }

/* ----- 切替・絞り込み ----- */
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); max-width: 420px; }
.seg button { flex: 1; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--sub); font-size: 13px; }
.seg button.is-on { background: var(--lib-soft); color: var(--text-strong); font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.fchip { height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line2); background: none; color: var(--sub); font-size: 12px; white-space: nowrap; flex: none; }
.fchip.is-on { background: var(--cc, var(--lib)); border-color: var(--cc, var(--lib)); color: var(--ci, var(--lib-ink)); font-weight: 700; }
.sortline { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--sub); margin: 8px 0 14px; }
.sortline select { background: none; border: 0; color: var(--sub); font-size: 12px; padding: 6px 0; }

/* ----- 行 ----- */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); border-radius: 6px; }
.row:hover { background: var(--surface); }
.row .bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--rc, var(--lib)); flex: none; }
.row .rm { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.row .rt { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .rs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--sub); }
.row .rd { font-size: 11px; color: var(--sub); flex: none; }
.row .rx { font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grouphead { font-size: 12px; color: var(--sub); letter-spacing: .08em; margin: 20px 0 4px; display: flex; gap: 8px; align-items: center; }
.grouphead b { color: var(--text); font-weight: 700; }

/* ----- 知見カード ----- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.icard { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.icard:hover { border-color: var(--ins); }
.icard .it { font-family: var(--serif); font-size: 16px; font-weight: 700; line-height: 1.5; }
.icard .ic { font-size: 13px; color: var(--sub); line-height: 1.6; }
.icard .is { display: flex; flex-wrap: wrap; gap: 6px; }

/* ----- ノート表示 ----- */
.note { max-width: 760px; margin: 0 auto; }
.notebar { display: flex; align-items: center; justify-content: space-between; margin: -4px -8px 4px; }
.notebar .latin { font-size: 16px; color: var(--nc, var(--accent)); }
.notebar .acts { display: flex; }
.notetop { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.notetop .cover { width: 92px; flex: none; }
.notetop .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.note h1.title { margin: 0; font-family: var(--serif); font-size: 23px; line-height: 1.45; font-weight: 700; color: var(--text-strong); }
.note .subtitle { font-size: 13px; color: var(--sub); margin-top: -4px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--sub); }
.meta a { color: var(--sub); }
.conclusion { margin: 4px 0 18px; padding: 14px 16px; border-radius: 14px; background: var(--ins-soft); font-family: var(--serif); font-size: 17px; line-height: 1.75; color: var(--text-strong); }
.related { margin-top: 28px; display: flex; flex-direction: column; gap: 8px; }
.relcard { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--ins-soft); border: 1px solid color-mix(in srgb, var(--ins) 30%, transparent); text-decoration: none; color: var(--text); }
.relcard.lib { background: var(--lib-soft); border-color: color-mix(in srgb, var(--lib) 30%, transparent); }
.relcard .rl { font-size: 11px; color: var(--sub); }
.relcard .rt { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.relcard > div { flex: 1; min-width: 0; }

/* ----- 本文（Markdown） ----- */
.md { font-size: 15px; line-height: 1.8; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--serif); letter-spacing: .03em; color: var(--text-strong); }
.md h2 { display: flex; align-items: center; gap: 9px; font-size: 17px; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md h2 svg { flex: none; color: var(--hc, var(--accent)); }
.md h3 { font-size: 15px; margin: 20px 0 8px; }
.md h4 { font-size: 14px; margin: 16px 0 6px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 1.4em; }
.md li { margin: 2px 0; }
.md li::marker { color: var(--accent); }
.md li.task { list-style: none; margin-left: -1.4em; display: flex; gap: 8px; align-items: flex-start; }
.md li.task input { margin-top: 6px; accent-color: var(--accent); width: 16px; height: 16px; }
.md blockquote { margin: 0 0 14px; padding: 10px 16px; border-radius: 12px; background: var(--surface); font-family: var(--serif); color: var(--text-strong); }
.md blockquote p:last-child { margin: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md img { display: block; border-radius: 10px; margin: 10px 0 14px; border: 1px solid var(--line); background: var(--surface); cursor: zoom-in; max-height: 70vh; object-fit: contain; }
.md .tbl { overflow-x: auto; margin: 0 0 14px; }
.md table { border-collapse: collapse; font-size: 13px; min-width: 100%; }
.md th, .md td { border: 1px solid var(--line2); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface2); }
.md code { font-size: 13px; background: var(--surface2); padding: 1px 6px; border-radius: 6px; }
.md a { color: var(--accent); word-break: break-all; }
.md a.inner { word-break: normal; }

/* ----- 編集 ----- */
.editor { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.editbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 5; padding: 8px 0; background: var(--bg); }
.editbar .state { font-size: 12px; color: var(--sub); }
.f-title { width: 100%; border: 0; background: none; outline: none; font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--text-strong); padding: 4px 0; }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.props label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--sub); }
.props .wide { grid-column: 1 / -1; }
.props input, .props select, .props textarea { height: 38px; border-radius: 9px; border: 1px solid var(--line2); background: var(--bg); padding: 0 10px; font-size: 14px; color: var(--text); outline: none; width: 100%; }
.props textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.6; }
.rating { display: flex; gap: 2px; height: 38px; align-items: center; }
.rating button { width: 30px; height: 34px; border: 0; background: none; font-size: 20px; color: var(--star-off); padding: 0; }
.rating button.on { color: var(--accent); }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar button { height: 36px; min-width: 40px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--sub); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.toolbar button:hover { color: var(--text); }
.f-body { width: 100%; min-height: 50vh; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 16px; font-family: var(--sans); font-size: 15px; line-height: 1.8; outline: none; resize: vertical; }
.f-body.drag { border-color: var(--accent); }
.hint { font-size: 11px; color: var(--mute); }
.srcpick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.srcchip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--lib-soft); color: var(--text); font-size: 12px; }
.srcchip button { width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--sub); }

/* ----- シート（下から出る／PCは中央） ----- */
.layer { position: fixed; inset: 0; z-index: 40; background: rgba(8, 7, 6, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--surface); border-top: 1px solid var(--line2); border-radius: 24px 24px 0 0; padding: 10px 20px calc(env(safe-area-inset-bottom) + 22px); display: flex; flex-direction: column; gap: 16px; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line2); align-self: center; }
.sheet .sh { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 700; letter-spacing: .04em; }
.sheet .lab { font-size: 12px; color: var(--sub); letter-spacing: .05em; }
.sheet .fld { width: 100%; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); padding: 11px 13px; font-size: 15px; line-height: 1.6; outline: none; resize: vertical; }
.sheet textarea.big { min-height: 160px; font-family: var(--serif); font-size: 16px; line-height: 1.8; }
.types { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.types button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 62px; padding: 8px 0; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--sub); font-size: 11px; }
.types button.is-on { border-color: var(--tc); background: var(--ts); color: var(--text-strong); font-weight: 700; }
.types svg { width: 20px; height: 20px; }
.types button.is-on svg { color: var(--tc); }
.toggle { display: inline-flex; border: 1px solid var(--line2); border-radius: 12px; overflow: hidden; }
.toggle button { height: 38px; padding: 0 14px; border: 0; background: none; color: var(--sub); font-size: 12px; }
.toggle button.is-on { background: var(--idea-soft); color: var(--text-strong); font-weight: 700; }
.quote { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--ins-soft); font-family: var(--serif); font-size: 14px; line-height: 1.7; }
.picklist { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.picklist button { display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; }
.picklist button:last-child { border-bottom: 0; }
.picklist button:hover { background: var(--surface2); }
.picklist img { width: 40px; height: 58px; object-fit: cover; border-radius: 3px; flex: none; background: var(--surface2); }
.picklist .pt { font-size: 13px; }
.picklist .pa { font-size: 11px; color: var(--sub); }
@media (min-width: 900px) {
  .layer { align-items: center; }
  .sheet { border-radius: 22px; border: 1px solid var(--line2); max-height: 86vh; padding: 18px 24px 22px; }
  .sheet .grab { display: none; }
}

/* ----- 選択ツール・トースト・拡大 ----- */
.seltool { position: absolute; z-index: 30; display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--ins-soft); border: 1px solid color-mix(in srgb, var(--ins) 45%, transparent); box-shadow: var(--shadow); }
.seltool button { height: 34px; padding: 0 12px; border: 0; border-radius: 9px; background: none; color: var(--text); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seltool button[data-act="promote"] { background: var(--ins); color: var(--ins-ink); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 150px); transform: translate(-50%, 20px); z-index: 60; padding: 10px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.zoom { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.zoom img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lock { max-width: 420px; margin: 18vh auto 0; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.lock p { color: var(--sub); font-size: 13px; }
.sync { font-size: 11px; color: var(--mute); }
.hl { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; }

/* ----- Notion 風エディタ ----- */
.f-editor { min-height: 50vh; }
.fe-wrap { position: relative; padding-left: 30px; }
.fe-doc { outline: none; min-height: 45vh; padding: 4px 0 40vh; caret-color: var(--accent); }
.fe-doc p.is-empty::before, .fe-doc h2.is-empty::before, .fe-doc h3.is-empty::before, .fe-doc h4.is-empty::before {
  content: attr(data-placeholder); float: left; height: 0; pointer-events: none; color: var(--mute); opacity: .7;
}
.fe-doc p.is-empty:not(.has-focus)::before { content: none; }
.fe-doc h2 { display: block; }
.fe-doc img { cursor: default; max-height: 60vh; }
.fe-doc img.ProseMirror-selectednode { outline: 3px solid var(--accent); outline-offset: 2px; }
.fe-doc .ProseMirror-selectednode:not(img) { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); border-radius: 6px; }
.fe-doc ul[data-type="taskList"] { list-style: none; padding-left: 0; }
.fe-doc ul[data-type="taskList"] li { display: flex; gap: 8px; align-items: flex-start; }
.fe-doc ul[data-type="taskList"] li > label { margin-top: 5px; flex: none; }
.fe-doc ul[data-type="taskList"] li > label input { width: 16px; height: 16px; accent-color: var(--accent); }
.fe-doc ul[data-type="taskList"] li > div { flex: 1; min-width: 0; }
.fe-doc ul[data-type="taskList"] li[data-checked="true"] > div { color: var(--mute); text-decoration: line-through; }
.fe-doc table { border-collapse: collapse; width: 100%; margin: 0 0 14px; table-layout: fixed; }
.fe-doc td, .fe-doc th { border: 1px solid var(--line2); padding: 6px 10px; vertical-align: top; position: relative; }
.fe-doc th { background: var(--surface2); }
.fe-doc .selectedCell { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.fe-doc .tableWrapper { overflow-x: auto; }
.md mark { background: color-mix(in srgb, var(--accent) 38%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; }
.fe-doc pre, .md pre { background: var(--surface2); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
.fe-handle {
  position: absolute; left: 0; width: 24px; height: 28px; border: 0; border-radius: 6px; background: none;
  color: var(--mute); font-size: 15px; line-height: 28px; padding: 0; cursor: grab; touch-action: none;
}
.fe-handle:hover { background: var(--surface2); color: var(--text); }
.fe-bmenu, .fe-menu {
  position: absolute; z-index: 35; background: var(--surface); border: 1px solid var(--line2); border-radius: 14px;
  padding: 6px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 150px;
}
.fe-bmenu { left: 0; }
.fe-menu { width: 230px; max-height: 320px; overflow-y: auto; }
.fe-menu-h { font-size: 10px; color: var(--mute); padding: 4px 10px 6px; letter-spacing: .08em; }
.fe-bmenu button, .fe-menu button {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 13px; text-align: left;
}
.fe-menu button span { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line2); background: var(--bg); display: inline-flex; align-items: center; justify-content: center; color: var(--sub); flex: none; }
.fe-bmenu button:hover, .fe-menu button:hover, .fe-menu button.on { background: var(--surface2); }
.fe-bmenu button svg { color: var(--sub); }
.fe-bar {
  position: sticky; top: 52px; z-index: 4; display: flex; gap: 2px; align-items: center; flex-wrap: nowrap; overflow-x: auto;
  padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); scrollbar-width: none;
}
.fe-bar::-webkit-scrollbar { display: none; }
.fe-bar button { height: 36px; min-width: 36px; padding: 0 8px; border: 0; border-radius: 9px; background: none; color: var(--sub); display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: none; }
.fe-bar button:hover { color: var(--text); background: var(--surface2); }
.fe-bar button.on { color: var(--accent); background: var(--surface2); }
.fe-bar .fe-sep { width: 1px; height: 20px; background: var(--line2); margin: 0 4px; flex: none; }
.fe-bar .fe-promote { margin-left: auto; color: var(--ins); font-size: 12px; font-weight: 700; padding: 0 10px; }
@media (max-width: 899px) {
  /* スマホは書式バーを画面下（キーボードの上）に固定 */
  .fe-bar { position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 25; border-radius: 0; border-width: 1px 0 0; padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); }
  body:has(.fe-bar) .tabbar { display: none; }
  .fe-wrap { padding-left: 26px; margin-left: -8px; }
}
