:root {
  --bg: #ffffff;
  --bg-sunken: #f6f7f9;
  --bg-raised: #ffffff;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --fg: #1b1f27;
  --fg-muted: #6b7280;
  --fg-faint: #9aa1ac;
  --accent: #4f46e5;
  --accent-fg: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --shadow: 0 8px 28px rgba(16, 20, 30, .12);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --ui: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --bg-sunken: #101216;
    --bg-raised: #1c1f26;
    --border: #2a2e37;
    --border-strong: #3a3f4a;
    --fg: #e7e9ee;
    --fg-muted: #9aa1ad;
    --fg-faint: #6d737e;
    --accent: #818cf8;
    --accent-fg: #16181d;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --err-bg: #2a1a1a;
    --shadow: 0 8px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* id セレクタで display を指定している要素が多いので、hidden 属性を必ず勝たせる */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui);
  font-size: 13px;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

.spacer { flex: 1; }

/* ------------------------------------------------------------------ boot */

#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 50;
}
.boot-inner { width: min(420px, 84vw); text-align: center; }
.boot-mark {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.02em;
  margin-bottom: 20px;
}
.boot-bar {
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.boot-bar i {
  display: block;
  height: 100%;
  width: 36%;
  background: var(--accent);
  border-radius: 3px;
  animation: slide 1.25s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
.boot-msg { margin-top: 14px; color: var(--fg-muted); }
.boot-note { margin-top: 8px; font-size: 11.5px; color: var(--fg-faint); line-height: 1.6; }
#boot.login .boot-bar,
#boot.login .boot-note { display: none; }
#boot.login .boot-msg { margin: 0 0 18px; }
#boot.failed .boot-bar { display: none; }
#boot.failed .boot-msg { color: var(--err); white-space: pre-wrap; text-align: left; font-family: var(--mono); }

#initial-load-dialog {
  width: min(420px, calc(100vw - 48px));
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
  background: var(--bg);
  box-shadow: 0 18px 70px #0003;
}
#initial-load-dialog::backdrop { background: #0007; }
#initial-load-title { margin: 0 0 20px; font-size: 17px; font-weight: 650; }
#initial-load-message { margin: 16px 0 0; line-height: 1.6; overflow-wrap: anywhere; }
.initial-load-note { margin: 12px 0 0; color: var(--fg-muted); font-size: 12px; line-height: 1.6; }
#initial-load-retry { margin-top: 20px; }

/* ---------------------------------------------------------------- layout */

#app { height: 100%; display: flex; flex-direction: column; }

#topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  flex: none;
}
.brand { font-weight: 640; letter-spacing: -.01em; }
.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-fg);
  vertical-align: 2px;
  margin-left: 2px;
}

#main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--w-files, 240px) 5px minmax(0, var(--w-editor, 1fr)) 5px minmax(0, 1fr);
}

/* 閲覧モード: プレビューだけを全幅で見せる */
#main.view-only { grid-template-columns: minmax(0, 1fr); }
#main.view-only > #files,
#main.view-only > #editor-pane,
#main.view-only > .splitter { display: none; }

/* ファイルマネージャーの折りたたみ: 幅を細い帯に縮め、開閉ボタンだけ残す */
#main.files-collapsed:not(.view-only) {
  grid-template-columns: 34px 0 minmax(0, var(--w-editor, 1fr)) 5px minmax(0, 1fr);
}
/* display:none にすると grid の自動配置から丸ごと外れ、後続の editor-pane /
   preview-pane が繰り上がって 0 幅・5px 幅のトラックに押し込まれてしまう
   (トラックの数=子要素の数を前提にした auto-placement のため)。
   幅は 0 トラックで既に見えないので、操作だけ無効化する。 */
#main.files-collapsed:not(.view-only) > .splitter[data-target="files"] { pointer-events: none; }
#main.files-collapsed #files .pane-head { padding: 0; justify-content: center; }
#main.files-collapsed #files .pane-head > *:not(#btn-files-toggle) { display: none; }
#main.files-collapsed #files > *:not(.pane-head) { display: none; }

#files, #editor-pane, #preview-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#files { background: var(--bg-sunken); border-right: 1px solid var(--border); overflow-y: auto; }
#editor-pane { border-right: 1px solid var(--border); }

.splitter {
  cursor: col-resize;
  background: var(--border);
  opacity: .6;
}
.splitter:hover, .splitter.dragging { background: var(--accent); opacity: 1; }

.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px 0 10px;
  flex: none;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--fg-muted);
  background: var(--bg-raised);
}
#files .pane-head { background: transparent; }
.path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- status */

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.status .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--fg-faint);
  flex: none;
}
.status.ok .dot { background: var(--ok); }
.status.busy .dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.status.warn .dot { background: var(--warn); }
.status.warn { color: var(--warn); }
.status.err .dot { background: var(--err); }
.status.err { color: var(--err); }
@keyframes pulse { 50% { opacity: .3; } }

/* -------------------------------------------------- 編集 / 閲覧の切り替え */

.segmented {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
}
.seg {
  height: 24px;
  padding: 0 11px;
  border: 0;
  background: var(--bg-raised);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 12px;
}
.seg + .seg { border-left: 1px solid var(--border); }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.seg:disabled { opacity: .45; cursor: not-allowed; }

#btn-follow[aria-pressed="false"] { color: var(--fg-faint); border-color: var(--border); }
#btn-follow[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- buttons */

.btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-raised);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(.5px); }
.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--fg-faint);
  transform: none;
}
.btn-small { height: 22px; padding: 0 8px; font-size: 11.5px; }
.btn-quiet { border-color: transparent; color: var(--fg-muted); }
.btn-quiet:hover { border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { opacity: .88; color: var(--accent-fg); }
.icon-btn {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 0; border-radius: 5px;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.icon-btn:hover { background: var(--border); color: var(--fg); }

.actions { display: flex; gap: 6px; align-items: center; }
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0; top: 30px;
  min-width: 200px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  z-index: 20;
}
.menu button {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}
.menu button:hover { background: var(--bg-sunken); }

/* ------------------------------------------------------------------- tree */

.repo-branches { flex: none; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.branch-toggle {
  width: 100%; padding: 5px 7px; text-align: left; overflow-wrap: anywhere;
  border: 1px solid var(--border); border-radius: 5px; background: var(--bg-raised); cursor: pointer;
  font-family: var(--mono); font-size: 11.5px;
}
.branch-picker { margin-top: 9px; }
.branch-picker label { display: block; margin-bottom: 5px; font-size: 11px; color: var(--fg-muted); }
.branch-picker input {
  width: 100%; height: 28px; padding: 0 7px; border: 1px solid var(--border-strong);
  border-radius: 5px; color: var(--fg); background: var(--bg-raised); font: inherit;
}
.branch-options { list-style: none; padding: 0; margin: 5px 0; max-height: 160px; overflow: auto; }
.branch-option { padding: 6px; border-radius: 4px; overflow-wrap: anywhere; cursor: pointer; font-family: var(--mono); font-size: 11px; }
.branch-option:hover, .branch-option[aria-selected="true"] { background: var(--border); }
.branch-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.sidebar-note { margin: 5px 0 0; font-size: 11px; color: var(--fg-muted); line-height: 1.5; }
.sidebar-note:empty { display: none; }
.changed-files { flex: none; max-height: 30vh; display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--border); }
.changed-files h2 { margin: 0 10px 4px; font-size: 11.5px; font-weight: 600; color: var(--fg-muted); }
.changed-files .sidebar-note { margin-left: 10px; margin-right: 10px; }
.changed-files-list { overflow: auto; min-height: 0; }
.changed-file-row { display: flex; align-items: start; }
.changed-file {
  display: flex; align-items: start; flex: 1; min-width: 0; gap: 6px; padding: 5px 4px 5px 10px; border: 0;
  background: transparent; color: var(--fg); text-align: left; cursor: pointer; font-size: 11px;
}
.changed-file:hover:enabled, .changed-file-diff:hover { background: var(--border); }
.changed-file:disabled { color: var(--fg-muted); cursor: default; }
.changed-file-diff { flex: none; margin: 2px 5px 2px 0; padding: 3px 4px; border: 0; background: transparent; color: var(--fg-muted); font-size: 10px; cursor: pointer; }
.changed-file-path { flex: 1; min-width: 0; overflow-wrap: anywhere; font-family: var(--mono); }
.change-status { flex: none; font-family: var(--mono); font-weight: 600; }
.change-status.added { color: var(--ok); }
.change-status.modified { color: var(--accent); }
.change-status.deleted { color: var(--err); }
.change-pending { flex: none; font-size: 10px; color: var(--fg-muted); }

.tree-search { flex: none; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.tree-search input {
  width: 100%;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg-raised);
  color: var(--fg);
  font-size: 12px;
}
.tree-search input:focus { outline: none; border-color: var(--accent); }

.tree { flex: 1; overflow: auto; padding: 6px 0 12px; }
.tree-empty { padding: 10px; color: var(--fg-faint); font-size: 12px; }
.tree-dir > .row { color: var(--fg-muted); cursor: pointer; }
.row {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px 0 0;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.row:hover { background: var(--border); }
.row.active { background: var(--accent); color: var(--accent-fg); }
.row.active .row-actions .icon-btn { color: var(--accent-fg); }
.row .name { overflow: hidden; text-overflow: ellipsis; }
.row .caret { width: 12px; flex: none; text-align: center; color: var(--fg-faint); font-size: 9px; }
.row.active .caret { color: var(--accent-fg); }
.row.deleted { color: var(--fg-faint); }
.row.deleted .name { text-decoration: line-through; }
.file-states { margin-left: auto; display: flex; align-items: center; gap: 3px; }
.file-state {
  height: 17px;
  min-width: 17px;
  padding: 0 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  background: transparent;
  color: var(--warn);
  font: 600 9.5px/15px var(--ui);
  cursor: pointer;
}
.file-state.pending { color: var(--err); }
.file-state.added { color: var(--ok); }
.file-state.deleted { color: var(--err); }
.row.active .file-state { color: var(--accent-fg); }
.row-actions { margin-left: auto; display: none; gap: 2px; }
.file-states + .row-actions { margin-left: 0; }
.row:hover .row-actions { display: flex; }
.row-actions .icon-btn { width: 18px; height: 18px; font-size: 11px; }
.tree-children.collapsed { display: none; }

.storage-note {
  flex: none;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  color: var(--warn);
  font-size: 11px;
  line-height: 1.5;
}

/* ----------------------------------------------------------------- editor */

#editor { flex: 1; min-height: 0; overflow: hidden; }
#editor.dropping { outline: 2px dashed var(--accent); outline-offset: -3px; }
#editor .cm-editor { height: 100%; }
#editor .cm-scroller { font-family: var(--mono); font-size: 12.5px; line-height: 1.65; }
#editor .cm-gutters { border-right: 1px solid var(--border); }
#editor .cm-content { padding: 8px 0 40vh; }

.dirty {
  font-size: 10.5px;
  color: var(--warn);
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
}

.problems {
  flex: none;
  max-height: 30%;
  overflow: auto;
  border-top: 1px solid var(--border);
  background: var(--err-bg);
  color: var(--err);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
}
.problems > summary {
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  background: inherit;
}
#problems-body {
  padding: 0 10px 8px;
  white-space: pre-wrap;
}
.problems.warn { color: var(--warn); background: transparent; }
.problems.progress { color: var(--fg-muted); background: var(--bg-sunken); }

/* ------------------------------------------------ front matter のフォーム */

.fm {
  flex: none;
  max-height: 45%;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunken);
}

.fm-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 6px;
  flex: none;
  font-size: 11.5px;
  color: var(--fg-muted);
}

.fm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 0;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--fg);
  font-size: 11.5px;
}
.fm-toggle:hover { background: var(--bg-raised); }
.fm-toggle .caret { color: var(--fg-faint); font-size: 9px; }

.fm-note {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 10.5px;
  color: var(--fg-faint);
}
.fm-source {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40ch;
}
.fm-leak {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px 2px 8px;
  border: 1px solid var(--warn);
  border-radius: 999px;
  color: var(--warn);
}
.fm-leak code { font-family: var(--mono); }

.fm-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 10px;
  align-items: start;
  padding: 2px 10px 10px;
}
/* 1 項目 = ラベルと入力欄の 2 列。grid の行に直接並べる */
.fm-field { display: contents; }

.fm-label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding-top: 3px;
  font-size: 11.5px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.fm-req {
  font-size: 9.5px;
  color: var(--warn);
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 3px;
}

.fm-control { min-width: 0; }
.fm-control input[type="text"],
.fm-control input[type="number"],
.fm-control input[type="date"],
.fm-control input[type="datetime-local"],
.fm-control select,
.fm-control textarea {
  width: 100%;
  font: inherit;
  font-size: 12px;
  color: var(--fg);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 4px 7px;
}
.fm-control textarea { resize: vertical; line-height: 1.5; }
.fm-control input:focus, .fm-control select:focus, .fm-control textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.fm-control input:disabled, .fm-control select:disabled, .fm-control textarea:disabled {
  color: var(--fg-faint);
  background: var(--bg-sunken);
}

.fm-bool { display: flex; align-items: center; min-height: 26px; }
.fm-bool input { width: 15px; height: 15px; accent-color: var(--accent); }

.fm-checks { display: flex; flex-wrap: wrap; gap: 4px 12px; padding-top: 4px; }
.fm-checks label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }

.fm-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}
.fm-chips:focus-within { border-color: var(--accent); }
.fm-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 3px 1px 7px;
  font-size: 11.5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.fm-chip-x {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--fg-faint);
  padding: 0 2px;
  line-height: 1;
}
.fm-chip-x:hover { color: var(--err); }
.fm-chips .fm-chip-input {
  flex: 1;
  min-width: 8ch;
  border: 0 !important;
  background: transparent !important;
  padding: 2px 3px !important;
}

.fm-raw {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg-muted);
  background: var(--bg-raised);
  border: 1px dashed var(--border-strong);
  border-radius: 5px;
  padding: 4px 7px;
  overflow: auto;
  white-space: pre-wrap;
}

.fm-hint { font-size: 10.5px; color: var(--fg-faint); padding: 2px 2px 0; line-height: 1.5; }
.fm-error { font-size: 10.5px; color: var(--err); padding: 2px 2px 0; }
.fm-empty { grid-column: 1 / -1; font-size: 11.5px; color: var(--fg-faint); padding: 4px 2px; }

.fm-warn {
  flex: none;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  color: var(--warn);
  font-size: 11px;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- preview */

/* プレビューの 2 枚重ね。裏の 1 枚は visibility で隠す — display:none にすると
   レイアウトが無くなり、スクロール位置合わせ (scrollPreviewToEditor) が
   読めなくなる。 */
.preview-stack { flex: 1; min-height: 0; position: relative; background: #fff; }
.preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.preview-frame.inactive { visibility: hidden; }

/* ------------------------------------------------------------------ modal */

#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, .45);
  display: grid;
  place-items: center;
  z-index: 60;
}
#modal {
  width: min(440px, 90vw);
  padding: 18px;
  border-radius: 12px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
#modal h2 { margin: 0 0 6px; font-size: 14px; }
#modal p {
  margin: 0 0 12px;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap; /* 追加読み込みの一覧などで改行を活かす */
  max-height: 40vh;
  overflow: auto;
}
#modal input, #modal textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
}
#modal input { height: 30px; padding-block: 0; }
#modal textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
#modal label {
  display: block;
  margin: 10px 0 5px;
  color: var(--fg-muted);
  font-size: 11.5px;
}
#modal label[hidden] { display: none; }
#modal input:focus, #modal textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}
#modal input[hidden], #modal textarea[hidden] { display: none; }
.modal-error { margin-top: 8px; color: var(--err); font-size: 11.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ------------------------------------------------- 新しい記事のウィザード */

/* z-index は modal (60) より **下**。ウィザードから確認ダイアログを開くことは
   無いが、提案の一覧と同じ理由で modal を覆わせない。 */
#np-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, .45);
  display: grid;
  place-items: center;
  z-index: 56;
}
#np {
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow: auto;
  padding: 18px;
  border-radius: 12px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
#np h2 { margin: 0 0 6px; font-size: 14px; }
#np-lead { margin: 0 0 14px; color: var(--fg-muted); font-size: 12px; line-height: 1.6; }
.np-section {
  margin: 14px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--fg-faint);
}
.np-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
/* .fm-body と同じ 2 列の grid。ただしスクロールはダイアログ側に任せる。 */
.np-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 10px;
  align-items: start;
}
#np .fm-note { padding: 8px 2px 0; }
#np .fm-warn { border-top: 0; padding: 6px 2px 0; }
.np-layout { display: flex; flex-direction: column; gap: 3px; padding-top: 3px; }
.np-layout label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.np-layout input { width: 15px; height: 15px; accent-color: var(--accent); }
/* URL の行 (docs §31.8)。既定は自動 = 入力欄は disabled で、
   「自動で出す」を押したときだけ Hugo が決めた値が入る。 */
.np-url-actions { display: flex; gap: 6px; margin-top: 5px; }
.np-url-actions .btn { font-size: 11.5px; padding: 3px 8px; }
.np-url-actions .btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
.np-url-stale { margin-top: 5px; color: var(--err); font-size: 11.5px; line-height: 1.5; }
#np-url:disabled { color: var(--fg-muted); background: var(--bg-sunken); }
.np-path {
  display: block;
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--bg-sunken);
  color: var(--fg-muted);
  font: 11.5px/1.6 var(--mono);
  overflow-wrap: anywhere;
}
#np .modal-actions { justify-content: flex-start; }

/* --------------------------------------------------------------- proposals */

/* 提案 (PR) の一覧。modal と同じ見た目の土台に、行のリストを載せる。 */
/* z-index は modal (60) より **下**。提案の一覧から確認ダイアログを開くので、
   同じ値だと DOM の後ろにある側 (この要素) が modal を覆ってしまい、
   ボタンが押せなくなる。 */
#proposals-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, .45);
  display: grid;
  place-items: center;
  z-index: 55;
}
#proposals {
  width: min(680px, 92vw);
  padding: 18px;
  border-radius: 12px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.proposals-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#proposals h2 { margin: 0; font-size: 14px; }
#proposals-note { margin: 6px 0 12px; color: var(--fg-muted); font-size: 12px; line-height: 1.6; }
#proposals-list { max-height: 50vh; overflow: auto; }
.proposal {
  padding: 10px 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.proposal:first-child { border-top: 0; }
.proposal-main { flex: 1; min-width: 0; }
.proposal-title { font-size: 12.5px; margin-bottom: 3px; }
.proposal-meta { color: var(--fg-muted); font-size: 11.5px; line-height: 1.5; }
.proposal-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.proposal-actions .btn { height: 24px; padding: 0 8px; font-size: 11.5px; }
.proposal-empty { color: var(--fg-muted); font-size: 12px; padding: 8px 0; }

/* ------------------------------------------------------------ unified diff */

#diff-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, .45);
  display: grid;
  place-items: center;
  z-index: 58;
}
#diff-modal {
  width: min(1080px, 94vw);
  height: min(780px, 90vh);
  padding: 16px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.diff-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
#diff-title { margin: 0; font-size: 14px; }
#diff-note { margin: 4px 0 12px; color: var(--fg-muted); font-size: 11.5px; }
#diff-content {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 10px 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--fg);
  font: 11.5px/1.55 var(--mono);
  tab-size: 2;
}
.diff-line { display: block; min-width: max-content; padding: 0 10px; white-space: pre; }
.diff-line.add { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.diff-line.remove { color: var(--err); background: color-mix(in srgb, var(--err) 10%, transparent); }
.diff-line.hunk { color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.diff-line.file { color: var(--fg-muted); font-weight: 600; }

/* ----------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  right: 14px; bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 70;
}
.toast {
  padding: 9px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  font-size: 12px;
  max-width: 380px;
  line-height: 1.5;
  animation: rise .18s ease-out;
}
.toast.err { border-color: var(--err); color: var(--err); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* 幅が足りない端末では 3 ペインを縦に積む */
@media (max-width: 860px) {
  #main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(90px, 22%) minmax(0, 1fr) minmax(0, 1fr);
    overflow: auto;
  }
  #files { border-right: 0; border-bottom: 1px solid var(--border); }
  #editor-pane { border-right: 0; border-bottom: 1px solid var(--border); }
  .splitter { display: none; }
  #topbar { height: auto; padding: 6px 10px; flex-wrap: wrap; }
  /* 縦積みでは幅ではなく高さを縮める */
  #main.files-collapsed:not(.view-only) {
    grid-template-columns: 1fr;
    grid-template-rows: 32px minmax(0, 1fr) minmax(0, 1fr);
  }
}
