/* テーマはCSS変数で定義。設定画面の「カスタムCSS」から上書きできます */
:root {
  --accent: #3b7ddd;
  --font: system-ui, sans-serif;
  --fs: 15px;
  --lh: 1.6;
  --indent: 24px;
  --maxw: 900px;
  --bg: #ffffff;
  --bg-side: #f6f6f4;
  --bg-head: #fbfbfa;
  --fg: #1f2328;
  --fg-mute: #8a8f98;
  --line: #e6e6e3;
  --guide: #e4e4e0;
  --hover: rgba(0,0,0,.045);
  --code-bg: rgba(0,0,0,.06);
  --mark: #fff3a3;
}
[data-theme="dark"] {
  --bg: #1d1f23; --bg-side: #17181b; --bg-head: #202227; --fg: #e3e5e8; --fg-mute: #7d838c;
  --line: #30333a; --guide: #33363d; --hover: rgba(255,255,255,.06); --code-bg: rgba(255,255,255,.08); --mark: #6b5d1a;
}
[data-theme="sepia"] {
  --bg: #f7f1e3; --bg-side: #efe7d4; --bg-head: #f3ecdb; --fg: #3b3226; --fg-mute: #98886f;
  --line: #e2d7bf; --guide: #e0d4ba; --hover: rgba(80,60,20,.06); --code-bg: rgba(80,60,20,.08); --mark: #f3dd8a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: var(--fs); color: var(--fg); background: var(--bg); overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { background: var(--hover); }
button.icon { border: none; padding: 2px 7px; color: var(--fg-mute); font-size: 15px; line-height: 1.4; }
button.icon:hover, button.icon.on { color: var(--accent); }
#app { display: flex; height: 100vh; }

/* ---- サイドバー ---- */
#sidebar { width: 230px; flex: none; background: var(--bg-side); border-right: 1px solid var(--line); display: flex; flex-direction: column; font-size: 14px; }
.no-sidebar #sidebar { display: none; }
#show-sidebar { display: none; position: fixed; left: 4px; bottom: 8px; z-index: 5; }
.no-sidebar #show-sidebar { display: block; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 14px; }
.logo { font-weight: 700; letter-spacing: .02em; }
.doc-list { flex: 1; overflow: auto; padding: 2px 6px; }
.doc-item { display: flex; align-items: center; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.doc-item:hover { background: var(--hover); }
.doc-item.open .doc-title { font-weight: 500; }
.doc-item.active { background: var(--hover); color: var(--accent); font-weight: 600; }
.doc-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; outline: none; }
.doc-item.editing .doc-title { background: var(--bg); padding: 0 3px; border-radius: 3px; white-space: normal; }
.doc-item .del { visibility: hidden; font-size: 13px; }
.doc-item:hover .del { visibility: visible; }
.new-doc { margin: 6px 10px; border-style: dashed; color: var(--fg-mute); }
.side-foot { display: flex; gap: 6px; padding: 8px 10px 12px; border-top: 1px solid var(--line); }
.side-foot button { flex: 1; font-size: 13px; }

/* ---- ペイン ---- */
#panes { flex: 1; display: flex; min-width: 0; min-height: 0; }
.split { display: flex; min-width: 0; min-height: 0; flex: 1 1 0; }
.split.row { flex-direction: row; }
.split.column { flex-direction: column; }
.pane { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.pane-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); background: var(--bg-head); flex: none; }
.pane.active:not(#panes.single .pane) .pane-head { box-shadow: inset 0 -2px 0 var(--accent); }
#panes.single .pane-head button[data-act="close"] { display: none; }
.crumbs { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--fg-mute); }
.crumb { cursor: pointer; padding: 1px 3px; border-radius: 4px; }
.crumb:hover { background: var(--hover); color: var(--fg); }
.crumb.current { color: var(--fg); }
.sep { margin: 0 2px; opacity: .6; }
.filter { width: 150px; font: inherit; font-size: 13px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); outline: none; }
.filter:focus { border-color: var(--accent); width: 200px; }
.resizer { flex: none; background: var(--line); background-clip: content-box; }
.split.row > .resizer { width: 5px; cursor: col-resize; padding: 0 2px; }
.split.column > .resizer { height: 5px; cursor: row-resize; padding: 2px 0; }
.resizer:hover { background-color: var(--accent); }
.resizing { user-select: none; }
.resizing-row { cursor: col-resize; } .resizing-col { cursor: row-resize; }

.pane-body { flex: 1; overflow: auto; }
.pane-inner { max-width: var(--maxw); margin: 0 auto; padding: 22px 32px 120px 26px; line-height: var(--lh); }
.counts .pane-inner { padding-left: 44px; }
.title { font-size: 1.6em; font-weight: 700; margin: 0 0 14px 22px; outline: none; line-height: 1.3; min-height: 1.3em; }
.title:empty::before { content: '無題'; color: var(--fg-mute); }
.title.checked { text-decoration: line-through; color: var(--fg-mute); }
.add-item { margin: 6px 0 0 22px; color: var(--fg-mute); cursor: pointer; font-size: .9em; opacity: 0; transition: opacity .15s; display: inline-block; }
.pane-inner:hover .add-item, .pane-inner.empty .add-item { opacity: 1; }
.add-item:hover { color: var(--accent); }

/* ---- 項目 ---- */
.row { display: flex; align-items: flex-start; position: relative; border-radius: 4px; }
.count { position: absolute; right: calc(100% + 1px); top: 0; height: calc(var(--fs) * var(--lh)); display: flex; align-items: center; font-size: .68em; font-weight: 600; color: var(--count); font-variant-numeric: tabular-nums; cursor: pointer; white-space: nowrap; }
.count:empty { display: none; }
.row.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--accent) 30%, transparent); } 100% { background: transparent; } }
.row:hover { background: var(--hover); }
.toggle { flex: none; width: 16px; height: calc(var(--fs) * var(--lh)); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--fg-mute); font-size: 10px; visibility: hidden; }
.node.has-kids > .row:hover .toggle { visibility: visible; }
.node.has-kids > .row .toggle::before { content: '▼'; transform: scale(.85); }
.node.has-kids.collapsed > .row .toggle::before { content: '▶'; }
.bullet { flex: none; width: 18px; height: calc(var(--fs) * var(--lh)); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.bullet::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--fg-mute); transition: transform .1s; }
.bullet:hover::before { transform: scale(1.5); background: var(--accent); }
.node.collapsed > .row .bullet::before { box-shadow: 0 0 0 4px var(--line); background: var(--fg); }
[data-bullet="dash"] .bullet::before { width: 8px; height: 2px; border-radius: 1px; }
[data-bullet="none"] .bullet::before { opacity: 0; }
[data-bullet="none"] .row:hover .bullet::before { opacity: 1; }
.content { flex: 1; min-width: 0; outline: none; white-space: pre-wrap; word-break: break-word; padding: 0 4px; min-height: calc(var(--fs) * var(--lh)); }
.note { display: none; margin-left: 38px; padding: 0 4px 2px; font-size: .87em; color: var(--fg-mute); white-space: pre-wrap; word-break: break-word; outline: none; }
.note.show, .note:focus { display: block; }
.note:empty::before { content: 'メモ'; opacity: .6; }
.children { margin-left: 24px; padding-left: max(0px, calc(var(--indent) - 24px)); border-left: 1px solid transparent; }
.guides .children { border-left-color: var(--guide); }
.node.checked > .row .content { text-decoration: line-through; color: var(--fg-mute); }
.node.checked > .note { opacity: .6; }
.hide-completed .node.checked { display: none; }
.node.dragging { opacity: .4; }
.row.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.row.drop-after { box-shadow: 0 2px 0 var(--accent); }
.row.drop-child { box-shadow: 40px 2px 0 -0px var(--accent); }

/* インライン書式 */
.content code, .title code, .note code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
.content a, .title a, .note a { color: var(--accent); text-decoration: none; }
.content a:hover { text-decoration: underline; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.tag { color: var(--accent); cursor: pointer; }
.tag:hover { text-decoration: underline; }

/* ---- 設定ダイアログ ---- */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; }
#modal[hidden] { display: none; }
.dialog { background: var(--bg); color: var(--fg); width: min(640px, 94vw); max-height: 86vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden; font-size: 14px; }
.dialog header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 6px; }
.dialog h2 { margin: 0; font-size: 17px; }
.dialog h3 { font-size: 14px; margin: 14px 0 8px; }
.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 10px; color: var(--fg-mute); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.dialog section { padding: 14px 18px 18px; overflow: auto; }
.dialog label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.dialog label.check { flex-direction: row; align-items: center; gap: 8px; }
.dialog input[type=text], .dialog select, .dialog textarea { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.dialog textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.dialog .val { color: var(--fg-mute); font-size: 12px; }
.hint { color: var(--fg-mute); font-size: 12.5px; line-height: 1.6; margin: 0 0 10px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.ghost { color: var(--fg-mute); }
.keytable { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.krow { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px; align-items: center; }
.krow input { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.krow button.on { color: var(--accent); border-color: var(--accent); }

@media (max-width: 700px) {
  #sidebar { position: fixed; z-index: 20; height: 100%; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .pane-inner { padding: 14px 12px 120px 4px; }
  .filter { width: 90px; }
}

/* ---- 編集中の書式表示 ---- */
.mk { color: var(--fg-mute); opacity: .55; font-weight: normal; font-style: normal; }
.mk-img { font-size: .85em; }
.content .url, .content .lnk { color: var(--accent); }

/* ---- 文字色・背景色 ---- */
:root {
  --c-red: #d93a3a; --c-orange: #e07b17; --c-yellow: #b38f00; --c-green: #2e9a4f; --c-blue: #2f6fd6; --c-purple: #8b4fd1; --c-pink: #d6418e; --c-gray: #8a8f98;
  --b-red: #fde0e0; --b-orange: #fde9d4; --b-yellow: #fff3a3; --b-green: #d8f3df; --b-blue: #dbe8fd; --b-purple: #ebdffb; --b-pink: #fbdcec; --b-gray: #e9eaec;
}
[data-theme="dark"] {
  --c-red: #ff7676; --c-orange: #ffad5c; --c-yellow: #ffd84d; --c-green: #6fdc8c; --c-blue: #78a9ff; --c-purple: #be95ff; --c-pink: #ff7eb6; --c-gray: #a0a6ae;
  --b-red: #5c2626; --b-orange: #5b3a17; --b-yellow: #5a4c12; --b-green: #1e4a2b; --b-blue: #1f3a63; --b-purple: #3d2a5c; --b-pink: #5a2340; --b-gray: #3a3d43;
}
.fg-red { color: var(--c-red); } .fg-orange { color: var(--c-orange); } .fg-yellow { color: var(--c-yellow); } .fg-green { color: var(--c-green); }
.fg-blue { color: var(--c-blue); } .fg-purple { color: var(--c-purple); } .fg-pink { color: var(--c-pink); } .fg-gray { color: var(--c-gray); }
.bg-red { background: var(--b-red); } .bg-orange { background: var(--b-orange); } .bg-yellow { background: var(--b-yellow); } .bg-green { background: var(--b-green); }
.bg-blue { background: var(--b-blue); } .bg-purple { background: var(--b-purple); } .bg-pink { background: var(--b-pink); } .bg-gray { background: var(--b-gray); }
[class*="bg-"]:not(.dot) { border-radius: 3px; padding: 0 1px; }

/* ---- 画像・リンク ---- */
.content img.img, .title img.img, .note img.img { display: block; max-width: 100%; max-height: 360px; margin: 4px 0; border-radius: 6px; cursor: zoom-in; border: 1px solid var(--line); }
img.img.missing { width: 120px; height: 60px; background: var(--hover); }
.favicon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; border-radius: 3px; }
.card-slot { margin-left: 38px; }
.card-slot:empty { display: none; }
.card { display: flex; max-width: 520px; margin: 4px 0 6px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; cursor: pointer; position: relative; background: var(--bg); font-size: .86em; line-height: 1.45; }
.card:hover { border-color: var(--accent); }
.card-img { flex: none; width: 120px; min-height: 76px; background: var(--hover) center/cover no-repeat; }
.card-body { padding: 7px 10px; min-width: 0; flex: 1; }
.card-t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-d { color: var(--fg-mute); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
.card-h { color: var(--fg-mute); font-size: .9em; margin-top: 3px; display: flex; align-items: center; gap: 5px; }
.card-h img { width: 13px; height: 13px; border-radius: 2px; }
.card.loading { opacity: .6; cursor: default; }
.card-x { position: absolute; top: 3px; right: 3px; border: none; background: var(--bg); padding: 0 6px; border-radius: 4px; color: var(--fg-mute); display: none; }
.card:hover .card-x { display: block; }

/* ---- 書式ツールバー ---- */
.fmtbar { position: fixed; z-index: 60; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.16); padding: 4px; font-size: 13px; }
.fmtbar[hidden] { display: none; }
.fb-main { display: flex; align-items: center; gap: 1px; }
.fmtbar button { border: none; padding: 3px 8px; border-radius: 5px; min-width: 28px; }
.fmtbar code { font-size: 11px; }
.fb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.pal-btn { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; }
.pal-btn .a { font-weight: 700; }
.pal-btn .bar { width: 14px; height: 3px; border-radius: 2px; margin-top: 2px; }
.pal-btn .hl { padding: 1px 4px; border-radius: 3px; font-weight: 700; }
.fb-pal { display: flex; align-items: center; gap: 3px; padding: 6px 4px 2px; border-top: 1px solid var(--line); margin-top: 4px; }
.fb-pal[hidden] { display: none; }
.fb-l { font-size: 11px; color: var(--fg-mute); margin-right: 4px; }
.dot { width: 20px; height: 20px; min-width: 0 !important; padding: 0 !important; border-radius: 50% !important; border: 1px solid var(--line) !important; }
.dot.fg-red { background: var(--c-red); } .dot.fg-orange { background: var(--c-orange); } .dot.fg-yellow { background: var(--c-yellow); } .dot.fg-green { background: var(--c-green); }
.dot.fg-blue { background: var(--c-blue); } .dot.fg-purple { background: var(--c-purple); } .dot.fg-pink { background: var(--c-pink); } .dot.fg-gray { background: var(--c-gray); }
.dot.none { font-size: 11px; color: var(--fg-mute); }
.dot:hover { transform: scale(1.15); }

/* ---- 右クリックメニュー・トースト・画像ビューア ---- */
.ctxmenu { position: fixed; z-index: 70; min-width: 220px; max-width: 360px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 4px; font-size: 13px; }
.ctxmenu button { display: flex; justify-content: space-between; gap: 16px; width: 100%; border: none; text-align: left; padding: 5px 10px; border-radius: 5px; }
.ctxmenu button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctxmenu button:hover { background: var(--hover); }
.ctxmenu kbd { font-family: inherit; color: var(--fg-mute); font-size: 11px; }
.ctxmenu hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.ctx-h { font-size: 11px; color: var(--fg-mute); padding: 4px 10px 2px; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #2b2d31; color: #fff; padding: 7px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.2); transition: opacity .3s; }
.toast.out { opacity: 0; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.8); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 4px; }

/* ---- 設定：キー割り当て ---- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 90px; gap: 0 12px; }
.key-summary { padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.key-summary.ok { background: color-mix(in srgb, #2e9a4f 12%, transparent); color: #2e9a4f; }
.key-summary.warn { background: color-mix(in srgb, #e07b17 14%, transparent); color: #b8650f; }
.key-summary.error { background: color-mix(in srgb, #d93a3a 13%, transparent); color: #c22; }
.kgroup { margin-bottom: 14px; }
.kgroup h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.krow { display: grid; grid-template-columns: 170px 1fr auto; gap: 4px 8px; align-items: center; padding: 2px 0; }
.krow.has-error input { border-color: #d93a3a; }
.krow.has-warn:not(.has-error) input { border-color: #e07b17; }
.kissue { grid-column: 1 / -1; padding-left: 170px; }
.kissue:empty { display: none; }
.ki { font-size: 12px; line-height: 1.5; }
.ki.error { color: #d93a3a; } .ki.warn { color: #c77012; } .ki.info { color: var(--fg-mute); }
.ki code { font-size: 11.5px; }

/* ---- タイトル上のパンくず（現在の階層） ---- */
.path { margin: 0 0 2px 22px; font-size: .86em; color: var(--fg-mute); line-height: 1.6; display: flex; flex-wrap: wrap; align-items: center; row-gap: 0; }
.path[hidden] { display: none; }
.path .crumb { cursor: pointer; padding: 0 3px; border-radius: 4px; max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path .crumb:hover { color: var(--fg); background: var(--hover); text-decoration: underline; }
.path .sep { margin: 0 3px; opacity: .7; }

/* ---- アカウント・一覧 ---- */
.account { padding: 0 10px 8px; }
.login-btn { width: 100%; background: var(--accent); color: #fff; border: none; padding: 6px 10px; font-weight: 600; }
.login-btn:hover { filter: brightness(1.08); background: var(--accent); }
.acct-btn { display: flex; align-items: center; gap: 8px; width: 100%; border: none; padding: 4px 6px; text-align: left; }
.acct-btn img, .acct-btn .ini { width: 24px; height: 24px; border-radius: 50%; flex: none; }
.acct-btn .ini { background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.acct-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.acct-local { font-size: 12px; color: var(--fg-mute); padding: 0 4px; }
.doc-group { font-size: 11px; color: var(--fg-mute); padding: 10px 8px 3px; letter-spacing: .03em; }
.doc-item .act { visibility: hidden; font-size: 13px; }
.doc-item:hover .act { visibility: visible; }
.doc-item .badge { font-size: 11px; color: var(--fg-mute); margin: 0 2px; }
.doc-item .badge.warn { color: #d93a3a; font-weight: 700; }
.doc-item.gone .doc-title { opacity: .55; }

/* ---- ペインヘッダー：同期状態・参加者・共有 ---- */
.sync-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-right: 2px; background: var(--fg-mute); opacity: .35; }
.sync-dot.synced { background: #30a46c; opacity: 1; }
.sync-dot.syncing { background: #ffb224; opacity: 1; }
.sync-dot.offline { background: #e5484d; opacity: 1; }
.peers { display: flex; gap: 2px; }
.peer { width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 2px solid var(--bg-head); }
.peer img { width: 100%; height: 100%; object-fit: cover; }
.share-btn { font-size: 12px !important; border: 1px solid var(--line) !important; padding: 2px 9px !important; color: var(--fg) !important; }
.row.has-peer { box-shadow: inset 3px 0 0 var(--peer); }
.row.has-peer::after { content: attr(data-peer); position: absolute; right: 2px; top: -9px; font-size: 10px; line-height: 14px; padding: 0 5px; border-radius: 4px; background: var(--peer); color: #fff; pointer-events: none; }
.pane.readonly .pane-head::after { content: '閲覧のみ'; font-size: 11px; color: var(--fg-mute); border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }
.pane.readonly .content, .pane.readonly .title { cursor: default; }
.pane-inner.loading .tree::before { content: 'サーバーから読み込み中…'; color: var(--fg-mute); margin-left: 22px; }

/* ---- 共有ダイアログ ---- */
.share-dialog { width: min(560px, 94vw); }
.invite { display: flex; gap: 6px; margin-bottom: 10px; }
.invite input { flex: 1; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.invite select { font: inherit; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.mlist, .llist { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.mrow, .lrow { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.mname { flex: 1; display: flex; flex-direction: column; }
.mname small { color: var(--fg-mute); font-size: 11.5px; }
.mrole { font-size: 12px; color: var(--fg-mute); }
.lrow input { flex: 1; font: inherit; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--hover); color: var(--fg); }
.lrole { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--hover); white-space: nowrap; }
.lrole.editor { color: var(--accent); }

/* ---- スマホ用操作バー ---- */
.mobilebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 65; display: flex; overflow-x: auto; gap: 2px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); background: var(--bg-head); border-top: 1px solid var(--line); }
.mobilebar[hidden] { display: none; }
.mobilebar button { flex: none; min-width: 42px; height: 38px; border: none; font-size: 17px; border-radius: 8px; }
.mobilebar button:active { background: var(--hover); }
.mobilebar-on .pane-body { padding-bottom: 56px; }
@media (pointer: coarse) {
  .bullet { width: 24px; }
  .toggle { visibility: visible !important; opacity: .5; }
  .node:not(.has-kids) > .row .toggle { visibility: hidden !important; }
  .doc-item { padding: 9px 8px; }
  .doc-item .act { visibility: visible; }
}
@media (max-width: 700px) {
  .no-sidebar #show-sidebar { top: 8px; bottom: auto; left: 6px; background: var(--bg-head); border-radius: 6px; z-index: 30; }
  .no-sidebar .pane-head { padding-left: 40px; }
  .share-btn { display: none; }
}

/* ---- iOS・ノッチ対応 ---- */
#app { height: 100vh; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.bullet, .count, .toggle { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.ios .content, .ios .title, .ios .note { -webkit-user-select: text; }
.ios body { -webkit-text-size-adjust: 100%; }
.install-hint { position: fixed; left: 8px; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 75; display: flex; gap: 8px; align-items: flex-start; background: #2b2d31; color: #fff; font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.install-hint b { font-weight: 600; }
.install-hint button { border: none; color: #fff; padding: 0 4px; font-size: 18px; line-height: 1; }
@media (pointer: coarse) {
  .filter, .invite input, .dialog input[type=text], .dialog select, .dialog textarea, .lrow input { font-size: 16px; }
  .fmtbar button { min-width: 36px; padding: 6px 8px; }
  .ctxmenu button { padding: 10px 12px; font-size: 15px; }
}
@media (pointer: coarse) { .ctxmenu kbd { display: none; } }
