/*
 * tsuzuri 基本レイアウト (Ember テーマ)。Markdown の見た目は markdown-default.css と %APPDATA%\tsuzuri\theme.css を参照。
 *
 * Ember: 暖色の炭色を基調にしたダークテーマ。アクセントは琥珀 1 色、補助色に緑 1 色 (未保存マーク・インラインコード)。
 * 角丸なし・影なし・グラデーションなし・アニメーションなし。UI を含めて全て等幅フォント。
 * 色は下記トークン以外を足さない (純白 #ffffff / 純黒 #000000 も使わない)。
 */
:root {
  color-scheme: dark;
  --sidebar-width: 240px;
  /* 本文の折り返し幅。none = ウィンドウ幅いっぱい (現在行の帯が右端まで届く)。例: 860px */
  --content-max-width: none;

  /* ---- カラートークン (Ember) ---- */
  --bg: #1f1b18;             /* エディタ本文の背景 */
  --chrome: #171411;         /* サイドバー・ステータスバーの背景 */
  --border: #2b2621;         /* 区切り線 (1px)、スクロールバーのつまみ */
  --line-highlight: #292420; /* 現在行の帯、項目のホバー */
  /* 選択範囲の背景。半透明にして本文の上に重ねる (下の base.css の .cm-selectionLayer を参照)。bg の上では #4d3d24 (accent を bg に 24% 混ぜた色) に見える。
     #3a3128 では現在行の帯と見分けがつかなかった */
  --selection: color-mix(in srgb, var(--accent) 24%, transparent);
  --text: #d3cbc0;           /* 本文、現在行の行番号 */
  --text-bright: #efe8dd;    /* 見出し、アクティブなファイル名 */
  --text-dim: #8a8075;       /* 非アクティブなファイル名・見出し */
  --text-status: #978d81;    /* ステータスバーの文字 */
  --gutter: #57504a;         /* 行番号 (現在行以外) */
  --control: #a89e92;        /* 操作ボタンの線 */
  --accent: #e0a84a;         /* キャレット、Markdown 記号、言語名、アクティブ表示の縁 */
  --secondary: #6fcf9a;      /* 未保存マーク、インラインコード */
  --link: #7fa6c9;           /* リンクの文字 (暖色の炭色になじむ、彩度を落とした青。青系はこれだけ) */
  --link-underline: #4c6a85; /* リンクの下線 */
  --scrollbar-hover: #3a332d;
  --input-border: #332d27;

  /* 旧変数名との互換 (theme.css から参照している場合のため) */
  --bg-editor: var(--bg);
  --bg-sidebar: var(--chrome);
  --fg: var(--text);
  --fg-muted: var(--text-dim);
  --active-line: var(--line-highlight);

  /* ---- タイポグラフィ (UI も本文も同じ等幅スタック) ---- */
  --font-body: "Spline Sans Mono", "Cascadia Mono", "Consolas", "BIZ UDGothic", "MS Gothic", monospace;
  --font-mono: var(--font-body);
  --font-size: 13.5px;
  --line-height: 22px;
  --font-size-sidebar: 12.5px;
  --font-size-status: 11.5px;

  /* ---- 寸法 ---- */
  --gutter-width: 60px;       /* 行番号欄 (右パディング含む)。左端の「隠す」欄 (--hide-gutter-width) もこの中に含む */
  --hide-gutter-width: 18px;  /* 行番号の左の「隠す」欄 (docs/design-spec-hide-lines.md) */
  --gutter-padding-right: 16px;
  --content-padding-left: 10px;
  --editor-padding-top: 12px;
  --statusbar-height: 26px;
}

* {
  box-sizing: border-box;
}

/* hidden 属性は display を当てたクラス (.dlg-row { display: flex } 等) より常に優先する */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--font-size);
  line-height: var(--line-height);
  /* ダブルタップ・ピンチでページを拡大させない (iPhone。docs/design-spec-web-iphone.md 6 節) */
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
}

/* サイドバー + エディタの横並び。その下にステータスバー */
#workspace {
  flex: 1;
  min-height: 0;
  display: flex;
}

/* ---- サイドバー (背景 chrome、右辺 1px border) ---- */
#sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--chrome);
  border-right: 1px solid var(--border);
  min-width: 0;
  user-select: none;
}
body.sidebar-hidden #sidebar {
  display: none;
}

/* サイドバーとエディタの境目 (src/sidebar/resizer.ts)。
   サイドバーの右辺 1px border にまたがる 7px の掴み幅。普段は透明で、ホバー / ドラッグ中だけ border の位置に 1px の線を accent で出す */
.sb-resizer {
  position: relative;
  flex: 0 0 0;
  width: 0;
  z-index: 2;
  cursor: col-resize;
}
.sb-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 7px;
}
.sb-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 1px;
  background: transparent;
}
.sb-resizer:hover::after,
.sb-resizer.dragging::after {
  background: var(--accent);
}
body.sidebar-hidden .sb-resizer {
  display: none;
}
/* ドラッグ中はエディタやサイドバーの文字が選択されたりカーソルが変わったりしないようにする */
body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}
body.sidebar-resizing #editor,
body.sidebar-resizing #sidebar {
  pointer-events: none;
}

/* ヘッダー: 左にプロジェクト切り替え (▷ フォルダ名)、右に操作ボタン。
   高さ 40px。上 6px + 中央寄せで内容 (26px) の上余白 10px / 下余白 4px にし、直下の月見出し行 (28px、文字は中央) との見た目の間隔を上下で揃える */
.sb-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 6px 8px 0 8px;
  flex: none;
}

/* ---- プロジェクト切り替え (src/sidebar/projectSwitcher.ts) ---- */
.sb-project {
  min-width: 0;
  flex: 1;
}
.sb-project-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  height: 26px;
  padding: 0 8px 0 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--font-size-sidebar);
  font-weight: 600;
  cursor: pointer;
}
.sb-project-btn:hover,
.sb-project-btn.open {
  background: var(--border);
  color: var(--text-bright);
}
.sb-project-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
/* 右向きの三角。開いている間は下向き (回転のみ、アニメーションなし) */
.sb-project-caret {
  display: block;
  flex: none;
  color: var(--gutter);
}
.sb-project-caret .icon {
  width: 10px;
  height: 10px;
}
.sb-project-btn.open .sb-project-caret {
  color: var(--accent);
  transform: rotate(90deg);
}
.sb-project-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* プルダウン: 背景 chrome、枠 1px、角丸・影なし。ヘッダーの直下に重ねる */
.sb-project-menu {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 38px;
  z-index: 10;
  padding: 4px 0;
  background: var(--chrome);
  border: 1px solid var(--border);
  font-size: var(--font-size-sidebar);
}
.sb-project-item {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 6px 0 14px;
  border-left: 2px solid transparent;
  color: var(--text);
  cursor: pointer;
}
.sb-project-item:hover {
  background: var(--line-highlight);
  color: var(--text-bright);
}
.sb-project-item.current {
  border-left-color: var(--accent);
  color: var(--text-bright);
  font-weight: 600;
  cursor: default;
}
.sb-project-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sb-project-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--gutter);
  cursor: pointer;
  padding: 0;
}
.sb-project-remove .icon {
  width: 12px;
  height: 12px;
}
.sb-project-remove:hover {
  background: var(--border);
  color: var(--text-bright);
}
.sb-project-add {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 4px;
  padding: 2px 16px 0;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: var(--font-size-sidebar);
  text-align: left;
  cursor: pointer;
}
.sb-project-add:hover {
  background: var(--line-highlight);
  color: var(--text);
}
.sb-project-remove:focus-visible,
.sb-project-add:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
/* Git 同期しているプロジェクトの印 (× の隣)。ローカルだけの項目には出ない */
.sb-project-synced {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--text-dim);
}
.sb-project-synced .icon {
  width: 12px;
  height: 12px;
}

/* ヘッダーの同期ボタン: 未設定は他のボタンと同じ、設定済みは文字色、同期中は琥珀、失敗は琥珀 + 下線 */
.sb-sync.is-synced {
  color: var(--text-dim);
}
.sb-sync.is-syncing {
  color: var(--accent);
}
.sb-sync.is-error {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}
.sb-actions {
  display: flex;
  gap: 0;
}
.sb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--gutter); /* 通常は控えめに。ホバーで text-bright まで上げる */
  cursor: pointer;
  padding: 0;
}
.sb-btn:hover {
  background: var(--border);
  color: var(--text-bright);
}
.sb-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* ---- UI アイコン (src/icons.ts が生成する SVG)。線画・1px 前後、色は currentColor ---- */
.icon {
  width: 14px;
  height: 14px;
  display: block;
  flex: none;
  pointer-events: none;
  stroke-width: 1.4;
}

/* ---- ファイル一覧 (S2c: 月見出し + 「日 曜日」+ # で階層)。指示書は docs/design-spec-sidebar-s2c.md ---- */
.sb-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 12px;
  font-size: var(--font-size-sidebar);
}

/* サイドバー最下部のバージョン表示 (src/main.ts が textContent を埋める) */
/* バージョン表示のタップで出る画面寸法の診断 (src/diagnostics.ts)。全面に重ねる。タップで閉じる */
.diag-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  margin: 0;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
  overflow: auto;
  background: var(--chrome);
  color: var(--text);
  font-size: 11px;
  line-height: 15px;
  white-space: pre-wrap;
  word-break: break-all;
}
#sidebar-version {
  flex: none;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
}

/* 月見出し: 小さな文字 + 右へ伸びる 1px の線。クリック不可 (data-pos なし) */
.sb-month {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 28px;
  padding: 0 14px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--gutter);
  font-variant-numeric: tabular-nums;
}
.sb-month-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.sb-file {
  padding: 0;
}

/* 日付行: 「日 曜日」。高さ 26px */
.sb-file-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 14px;
  border-left: 2px solid transparent;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  cursor: pointer;
}
.sb-wd {
  color: var(--gutter);
}
.sb-file-title:hover {
  color: var(--text);
}
.sb-file-title:hover .sb-wd {
  color: var(--text-dim);
}
/* 現在のファイル: 背景を本文と地続きにし、左縁だけ琥珀。日と曜日はどちらも明るく太く */
.sb-file.active .sb-file-title {
  background: var(--bg);
  border-left-color: var(--accent);
  color: var(--text-bright);
  font-weight: 600;
}
.sb-file.active .sb-wd {
  color: var(--text-bright);
}

/* 見出し行: # の欄 (最低 3 文字幅) + テキスト。高さ 22px、インデントなし (階層は # の数) */
.sb-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 22px;
  padding: 0 14px 0 30px;
  color: var(--text-dim);
  cursor: pointer;
}
.sb-hash {
  flex: none;
  min-width: 3ch;
  color: var(--gutter);
  font-weight: 400; /* 見出しがアクティブでも太くしない */
}
.sb-file.active .sb-hash {
  color: var(--accent); /* 現在のファイルの # だけ琥珀 */
}
.sb-heading-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-heading:hover {
  background: var(--line-highlight);
  color: var(--text);
}
.sb-heading.active {
  color: var(--text-bright);
  font-weight: 600;
}
/* 見出し中のリンク: 記法は出さず表示文だけ。リンク色 + 下線 */
.sb-link {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 0.15em;
}
.sb-heading:hover .sb-link,
.sb-heading.active .sb-link {
  color: var(--link);
}
/* 見出し中の強調・打消し・コード (sidebar/outline.ts の parseInline)。本文 Preview と同じ見え方に寄せる。
   コードの色は本文のインラインコードと同じ --secondary。リンクと打消しが重なれば下線と取り消し線の両方 */
.sb-em {
  font-style: italic;
}
.sb-strong {
  font-weight: 600;
}
.sb-strike {
  text-decoration: line-through;
}
.sb-link.sb-strike {
  text-decoration: underline line-through;
  text-decoration-color: var(--link-underline);
}
.sb-code {
  color: var(--secondary);
}

/* ---- エディタ (背景 bg) ---- */
#editor {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--bg);
}
/* CodeMirror 自身が注入する基本スタイル (.ͼ1 .cm-xxx = クラス 2 つ分) に勝つため #editor を付けて詳細度を上げる */
#editor .cm-editor {
  height: 100%;
  font-size: var(--font-size);
  background: var(--bg);
  color: var(--text);
}
#editor .cm-editor.cm-focused {
  outline: none;
}
/* ファイルをドラッグ中の落とし先 (src/editor/attachments.ts)。outline なのでレイアウトは動かない */
#editor .cm-editor.cm-drop-target {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
#editor .cm-scroller {
  font-family: var(--font-body);
  line-height: var(--line-height);
  overflow-x: hidden;
  overflow-y: auto;
  padding-top: var(--editor-padding-top);
}
#editor .cm-content {
  max-width: var(--content-max-width);
  margin: 0;
  padding: 0 var(--content-padding-left) 35vh;
  caret-color: var(--accent);
  flex-grow: 1;
  min-width: 0;
}
/* CodeMirror 既定の左右パディング (0 2px 0 6px) を打ち消す。上下は markdown-default.css の見出し等が padding で余白を付けるので触らない。
   どの行も最低 1 行分 (22px) の高さにして、行番号欄の数字が縮んだ行 (コードブロック末尾など) で重ならないようにする */
.cm-editor .cm-line {
  padding-left: 0;
  padding-right: 0;
  min-height: var(--line-height);
}

/* 行番号欄: 幅 60px、右揃え、右パディング 16px、縦線なし、背景は本文と同じ */
#editor .cm-gutters {
  background: var(--bg);
  border-right: none;
  color: var(--gutter);
}
#editor .cm-lineNumbers .cm-gutterElement {
  /* 左の「隠す」欄と合わせて --gutter-width になるようにする (選択範囲の層の clip-path や本文の開始位置を変えない) */
  min-width: calc(var(--gutter-width) - var(--hide-gutter-width));
  padding: 0 var(--gutter-padding-right) 0 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* 現在行の帯: 行番号欄から右端まで 1 本の帯に見せる */
#editor .cm-activeLine {
  /* CodeMirror は選択範囲 (.cm-selectionBackground) を行の背景より奥に描くので、帯を不透明にすると
     現在行の選択範囲が隠れる。--line-highlight と同じ見え方になる半透明 (text を 5% 重ねる) で塗る */
  background: color-mix(in srgb, var(--text) 5%, transparent);
}
#editor .cm-activeLineGutter {
  background: var(--line-highlight);
  color: var(--text);
}
#editor .cm-selectionBackground,
#editor .cm-editor.cm-focused .cm-selectionBackground {
  background: var(--selection) !important;
}
/* CodeMirror は選択範囲の層を本文の奥に置くので、コードブロックや見出しの帯のように不透明な背景を持つ行では
   選択範囲が隠れてしまう。層を本文の手前に出し、色は半透明 (--selection) にして文字が透けて読めるようにする。
   行番号欄は z-index 200 の sticky なので、この層より手前のまま。
   !important が必要: CodeMirror (LayerView.setOrder) は z-index を style 属性 (インライン) に "-1 - 順番" で書き込むため、
   通常の宣言では負ける。2026-09-07 に !important 無しで一度「直った」ように見えて再発した。外さないこと。
   回帰は scripts\check-selection.ps1 で機械的に確認できる */
#editor .cm-selectionLayer {
  z-index: 1 !important;
  pointer-events: none;
}
/* 複数行の選択で 2 行目以降の帯は .cm-content の左端から描かれ、本文の左余白 (--content-padding-left) まで塗られてしまう
   (CodeMirror は .cm-line の padding は差し引くが .cm-content の padding は見ない)。選択レイヤーを本文の開始位置で切り落とす。
   レイヤーは行番号欄も含む .cm-scroller 全幅なので、行番号欄の幅 + 左余白ぶんを左から削る */
#editor .cm-selectionLayer {
  /* .cm-selectionLayer 自体は幅も高さも 0 (帯は絶対座標の子要素) なので、左以外は負の値で無制限に広げる。
     inset(0 0 0 X) だと 0x0 の箱で切られて帯が全部消える */
  clip-path: inset(-99999px -99999px -99999px calc(var(--gutter-width) + var(--content-padding-left)));
}
#editor .cm-cursor,
#editor .cm-dropCursor {
  border-left: 2px solid var(--accent);
}

/* ---- 「隠す」の欄 (行番号の左、幅 18px)。docs/design-spec-hide-lines.md 3 節。
   マークの付いた行に小さな「目に斜線」。主張しない: 色は行番号と同じ --gutter、ホバーで --text。欄のどこを押しても付け外し。
   マークの無い行はホバーでさらに薄い同じ印 (--border) を出す ---- */
#editor .cm-hide-gutter .cm-gutterElement {
  width: var(--hide-gutter-width);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  cursor: pointer;
}
.cm-hide-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--line-height);
  color: var(--gutter);
}
#editor .cm-hide-mark .icon {
  width: 12px;
  height: 12px;
  stroke-width: 1.6;
}
#editor .cm-hide-gutter .cm-gutterElement:hover .cm-hide-mark {
  color: var(--text);
}
/* マークの無い行: ホバーで薄い印 (SVG の mask-image。色は background-color) */
#editor .cm-hide-gutter .cm-gutterElement:not(.is-marked):hover::after {
  content: "";
  width: 12px;
  height: var(--line-height);
  background-color: var(--border);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3l18 18'/%3E%3Cpath d='M10.6 10.6a2 2 0 0 0 2.8 2.8'/%3E%3Cpath d='M9.9 5.2A9.8 9.8 0 0 1 12 5c6 0 9.5 7 9.5 7a15.6 15.6 0 0 1-2.2 3.1'/%3E%3Cpath d='M6.6 6.6C4 8.4 2.5 12 2.5 12s3.5 7 9.5 7a9.4 9.4 0 0 0 4.4-1.1'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3l18 18'/%3E%3Cpath d='M10.6 10.6a2 2 0 0 0 2.8 2.8'/%3E%3Cpath d='M9.9 5.2A9.8 9.8 0 0 1 12 5c6 0 9.5 7 9.5 7a15.6 15.6 0 0 1-2.2 3.1'/%3E%3Cpath d='M6.6 6.6C4 8.4 2.5 12 2.5 12s3.5 7 9.5 7a9.4 9.4 0 0 0 4.4-1.1'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}

/* ---- スクロールバー: 幅 10px、トラック透明、つまみ border、角丸・矢印なし ---- */
#editor .cm-scroller::-webkit-scrollbar,
.sb-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
#editor .cm-scroller::-webkit-scrollbar-track,
.sb-list::-webkit-scrollbar-track {
  background: transparent;
}
#editor .cm-scroller::-webkit-scrollbar-thumb,
.sb-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 0;
}
#editor .cm-scroller::-webkit-scrollbar-thumb:hover,
.sb-list::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}
#editor .cm-scroller::-webkit-scrollbar-button,
.sb-list::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

/* ---- ファイルの見出し兼区切り線: 各ファイルの 1 行目の上に「日付 ────」を置く (左に日付、右に線) ---- */
.cm-file-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  /* 高さは 1 行 (22px) + 上下 padding。src/editor/boundaries.ts の FILE_HEADER_HEIGHT と揃えること */
  padding: var(--sep-padding-top, 22px) 0 var(--sep-padding-bottom, 11px);
  line-height: var(--line-height);
  pointer-events: none;
}
/* 最初のファイルは上に余白を取らない */
.cm-file-sep[data-first] {
  padding-top: 0;
}
.cm-file-sep-line {
  flex: 1;
  height: 1px;
  background: var(--sep-color, var(--border));
}
.cm-file-sep-label {
  font-size: var(--sep-label-size, 1em);
  font-weight: var(--sep-label-weight, 600);
  color: var(--sep-label-color, var(--text-bright));
  font-variant-numeric: tabular-nums;
}
.cm-file-sep.flash .cm-file-sep-line {
  background: var(--accent);
}
.cm-file-sep.flash .cm-file-sep-label {
  color: var(--accent);
}

/* ---- 絵文字ピッカー (src/emoji/picker.ts)。":" の下に 1 行 10 個のグリッド ---- */
#editor .cm-tooltip {
  border: 1px solid var(--border);
  background: var(--chrome);
  color: var(--text);
  border-radius: 0;
}
.cm-emoji-picker {
  /* 幅を固定する。フッターの長い名前で広がらないように (中身は省略記号) */
  width: 342px; /* スクロール領域 332px + スクロールバー 10px */
  font-family: var(--font-body);
  font-size: var(--font-size-sidebar);
}
.cm-emoji-scroll {
  width: 342px;
  max-height: 300px;
  overflow-y: scroll;
  overscroll-behavior: contain; /* 端まで来ても本文をスクロールさせない */
  padding: 2px 6px 6px;
}
.cm-emoji-section-title {
  height: 22px;
  line-height: 22px;
  padding: 0 4px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--gutter);
}
.cm-emoji-grid {
  display: flex;
  flex-direction: column;
}
/* 1 行 = 10 個。画面外の行は描画を省く (絵文字グリフ 1,900 個のラスタライズを避け、スクロールを軽くする)。
   contain-intrinsic-size で高さを予約しておき、見えたときに描く */
.cm-emoji-row {
  display: flex;
  height: 32px;
  content-visibility: auto;
  contain-intrinsic-size: auto 320px 32px;
}
.cm-emoji-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.cm-emoji-cell img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.cm-emoji-cell:hover {
  background: var(--line-highlight);
}
.cm-emoji-cell.selected {
  background: var(--line-highlight);
  border-color: var(--accent);
}
.cm-emoji-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 26px;
  padding: 0 10px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}
.cm-emoji-foot-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.cm-emoji-foot-hint {
  flex: none;
  font-size: var(--font-size-status);
  color: var(--gutter);
}
.cm-emoji-scroll::-webkit-scrollbar {
  width: 10px;
}
.cm-emoji-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.cm-emoji-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
}
.cm-emoji-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}
.cm-emoji-scroll::-webkit-scrollbar-button,
.cm-emoji-scroll::-webkit-scrollbar-corner {
  display: none;
  background: transparent;
}

/* ---- ステータスバー (高さ 26px、背景 chrome、上辺 1px border、文字のみ) ---- */
#statusbar {
  flex: none;
  height: var(--statusbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: var(--chrome);
  border-top: 1px solid var(--border);
  font-size: var(--font-size-status);
  line-height: calc(var(--statusbar-height) - 1px);
  color: var(--text-status);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}
.st-group {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}
.st-item {
  font-variant-numeric: tabular-nums;
  flex: none;
}
.st-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
/* 未保存マーク: 直径 7px の円 (角丸を使う唯一の例外)。保存が完了すると消える */
.st-dirty {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary);
}
.st-file.dirty .st-dirty {
  display: inline-block;
}
.st-lang {
  color: var(--accent);
}
/* Git 同期インジケーター (src/sync/syncIndicator.ts)。状態は data-state。同期中だけ回転する (ユーザー要望による例外) */
.st-sync {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-status);
  cursor: pointer;
}
.st-sync:hover {
  background: var(--line-highlight);
}
.st-sync-icon {
  position: relative;
  display: inline-flex;
  width: 14px;
  height: 14px;
}
.st-sync-icon .icon {
  position: absolute;
  inset: 0;
  width: 14px;
  height: 14px;
}
.st-sync[data-state="off"] {
  color: var(--gutter);
}
.st-sync[data-state="idle"] {
  color: var(--text-status);
}
.st-sync[data-state="dirty"] {
  color: var(--secondary);
}
.st-sync[data-state="syncing"] {
  color: var(--accent);
}
.st-sync[data-state="syncing"] .st-sync-icon {
  animation: st-sync-spin 1.2s linear infinite;
}
.st-sync[data-state="error"] {
  color: var(--accent);
}
@keyframes st-sync-spin {
  to {
    transform: rotate(360deg);
  }
}
/* 「隠す」マークの行の一括非表示 (Ctrl+H) の目印 (src/editor/hideLines)。ON のときだけ出る。目に斜線 + 隠している行数。
   隠している行を触る変更を拒否したとき一瞬光る (.flash) */
.st-hide {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: var(--font-size-status);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.st-hide:hover {
  background: var(--line-highlight);
}
.st-hide.flash {
  background: var(--selection);
}
.st-hide-icon {
  display: inline-flex;
}
.st-hide .icon {
  width: 14px;
  height: 14px;
}
/* 右クリック (クリック) メニュー */
.st-sync-menu {
  position: fixed;
  z-index: 90;
  width: 420px;
  padding: 10px 12px 12px;
  background: var(--chrome);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--font-size-sidebar);
  line-height: 18px;
}
.st-sync-menu-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.st-sync-menu-summary {
  color: var(--text-bright);
  font-weight: 600;
}
.st-sync-menu-error-title {
  color: var(--accent);
}
.st-sync-menu-error-action {
  color: var(--text);
  white-space: pre-wrap;
}
.st-sync-menu-error-detail {
  max-height: 72px;
  overflow-y: auto;
  color: var(--text-dim);
  font-size: var(--font-size-status);
  white-space: pre-wrap;
  word-break: break-all;
}
.st-sync-menu-legend {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.st-sync-legend-row {
  display: grid;
  grid-template-columns: 22px 120px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  padding: 0 4px;
  color: var(--text-dim);
}
.st-sync-legend-row.current {
  background: var(--line-highlight);
  color: var(--text-bright);
}
.st-sync-legend-icon {
  position: relative;
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: var(--text-status);
}
.st-sync-legend-icon .icon {
  position: absolute;
  inset: 0;
  width: 14px;
  height: 14px;
}
.st-sync-legend-row[data-kind="off"] .st-sync-legend-icon { color: var(--gutter); }
.st-sync-legend-row[data-kind="dirty"] .st-sync-legend-icon { color: var(--secondary); }
.st-sync-legend-row[data-kind="syncing"] .st-sync-legend-icon,
.st-sync-legend-row[data-kind="error"] .st-sync-legend-icon { color: var(--accent); }
.st-sync-legend-label {
  color: inherit;
}
.st-sync-legend-desc {
  font-size: var(--font-size-status);
  color: var(--text-dim);
}
.st-sync-menu-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
}

/* ---- ダイアログ (Git 同期設定)。Ember 7 章: 背景 chrome、枠 1px border、角丸・影なし。主ボタンだけ枠が琥珀 ---- */
.dlg-backdrop[hidden] {
  display: none;
}
.dlg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 64px;
  background: rgb(23 20 17 / 0.72); /* chrome を透過。ぼかしは使わない */
}
.dlg {
  position: relative;
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  background: var(--chrome);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--font-size-sidebar);
}
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--border);
}
.dlg-title {
  color: var(--text-bright);
  font-weight: 600;
}
.dlg-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border: 0;
  background: transparent;
  color: var(--gutter);
  cursor: pointer;
  padding: 0;
}
.dlg-close:hover {
  background: var(--border);
  color: var(--text-bright);
}
.dlg-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}
.dlg-project {
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dlg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dlg-label {
  color: var(--text-dim);
  font-size: var(--font-size-status);
}
.dlg-input {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--input-border);
  background: var(--chrome);
  color: var(--text-bright);
  font: inherit;
  font-size: var(--font-size-sidebar);
  outline: none;
}
.dlg-input:focus {
  border-color: var(--accent);
}
.dlg-hint {
  color: var(--gutter);
  font-size: var(--font-size-status);
  line-height: 16px;
}
.dlg-status {
  min-height: 22px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  line-height: 18px;
  white-space: pre-wrap;
  word-break: break-all;
}
.dlg-status.ok {
  color: var(--text);
}
.dlg-status.error {
  color: var(--accent);
  border-color: var(--accent);
}
.dlg-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}
.dlg-spacer {
  flex: 1;
}
.dlg-btn {
  height: 26px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  background: transparent;
  color: var(--control);
  font: inherit;
  font-size: var(--font-size-sidebar);
  cursor: pointer;
}
.dlg-btn:hover {
  background: var(--line-highlight);
  color: var(--text-bright);
}
.dlg-btn.primary {
  border-color: var(--accent);
  color: var(--text-bright);
}
.dlg-btn:disabled {
  color: var(--gutter);
  border-color: var(--border);
  cursor: default;
  background: transparent;
}
.dlg-btn:focus-visible,
.dlg-close:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* ダイアログ内のセクション (GitHub アカウント / リポジトリ) */
.dlg-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.dlg-section-title {
  color: var(--text-bright);
  font-size: var(--font-size-status);
  font-weight: 600;
  letter-spacing: 0.08em;
}
.dlg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dlg-account {
  flex: 1;
  min-width: 0;
  color: var(--text-dim);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dlg-account.on {
  color: var(--text);
}
.dlg-device {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
}
/* ブラウザに入力するコード。等幅・大きめ・琥珀 */
.dlg-code {
  flex: 1;
  color: var(--accent);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.12em;
  user-select: text;
}
.dlg-select {
  flex: 1;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 24px;
  /* 下向きの小さな線画の矢印 (SVG) を右端に */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8075' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px 12px;
}
.dlg-select option {
  background: var(--chrome);
  color: var(--text);
}
.dlg-details summary {
  color: var(--text-dim);
  font-size: var(--font-size-status);
  cursor: pointer;
  list-style: none;
}
.dlg-details summary::-webkit-details-marker {
  display: none;
}
.dlg-details summary::before {
  content: "+ ";
  color: var(--gutter);
}
.dlg-details[open] summary::before {
  content: "- ";
}
.dlg-details[open] summary {
  margin-bottom: 8px;
}

/* 「新しいプロジェクト...」を押したときの名前入力欄 (メニュー内、項目と同じ高さ) */
.sb-project-new {
  display: flex;
  align-items: center;
  height: 30px;
  margin-top: 4px;
  padding: 2px 8px 0 8px;
  border-top: 1px solid var(--border);
}
.sb-project-new-input {
  flex: 1;
  min-width: 0;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  background: var(--chrome);
  color: var(--text-bright);
  font: inherit;
  font-size: var(--font-size-sidebar);
  outline: none;
}

/* 項目の少ないダイアログ (プロジェクト設定・添付ファイルの警告) */
.dlg-narrow {
  width: 420px;
}
.dlg-wide {
  width: 620px;
}
.dlg-back {
  margin-right: 4px;
}
.dlg-head .dlg-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dlg-grow {
  flex: 1;
  min-width: 0;
}
.dlg-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
}
.dlg-check input,
.emoji-range {
  accent-color: var(--accent);
}

/* ---- カスタム絵文字の管理 (src/emoji/manager.ts、設定ダイアログの 2 枚目) ---- */
.emoji-mgr {
  gap: 12px;
}
.emoji-crop-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
/* 切り抜きのステージ。一辺は manager.ts の STAGE と揃える */
.emoji-stage {
  position: relative;
  flex: none;
  width: 240px;
  height: 240px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  user-select: none;
}
.emoji-stage img {
  position: absolute;
  pointer-events: none;
}
/* 切り抜き枠。外側は巨大な outline で暗くする (overflow: hidden のステージに収まる) */
.emoji-cropbox {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid var(--accent);
  outline: 600px solid rgb(23 20 17 / 0.6);
  cursor: move;
}
.emoji-stage.no-crop .emoji-cropbox {
  display: none;
}
.emoji-crop-side {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
}
.emoji-key-row {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}
.emoji-key-row .dlg-input {
  flex: 1;
  min-width: 0;
}
.emoji-range {
  width: 100%;
  margin: 0;
}
#emoji-size-field.disabled {
  opacity: 0.4;
}
.emoji-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.emoji-preview-row canvas {
  background: var(--bg);
  border: 1px solid var(--border);
}
.emoji-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, 72px);
  gap: 6px;
}
.emoji-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 72px;
  height: 76px;
  padding: 8px 2px 0;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.emoji-tile:hover {
  background: var(--line-highlight);
  border-color: var(--border);
}
.emoji-tile img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.emoji-tile-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-status);
  color: var(--text-dim);
}
/* 拡大表示。ダイアログ全体に重ねる */
.emoji-zoom {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: var(--chrome);
}
.emoji-zoom img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  background: var(--bg);
  border: 1px solid var(--border);
}
.emoji-zoom-name {
  color: var(--text-bright);
  font-weight: 600;
}
#emoji-zoom-path {
  max-width: 100%;
  text-align: center;
  word-break: break-all;
}

/* 添付ファイルの警告に並べるファイル一覧 (src/editor/attachDialog.ts) */
.attach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}
.attach-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.attach-item-name {
  flex: 1;
  min-width: 0;
  color: var(--text-bright);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.attach-item-size {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.attach-item-detail {
  flex: 1;
  min-width: 0;
  color: var(--text-dim);
  font-size: var(--font-size-status);
  word-break: break-all;
}

/* ---- 狭い画面 (幅 700px 以下 = iPhone)。body.narrow は src/narrow.ts が付ける。docs/plan-web-iphone.md 4.1。
   Ember の配色・等幅・22px の行はそのまま。変えるのは「物理的に無いもの」に関わる箇所だけ:
   上に 36px の操作列 (キーボードで打てない操作)、サイドバーはドロワー、左の欄は行番号だけ (28〜34px)、
   「隠す」は行番号に斜線、ステータスバーは短く ---- */
.topbar {
  display: none;
}
body.narrow .topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  height: calc(36px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 4px 0;
  background: var(--chrome);
  border-bottom: 1px solid var(--border);
}
.tb-btn {
  width: 40px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--control);
  cursor: pointer;
}
.tb-btn .icon {
  width: 16px;
  height: 16px;
}
.tb-btn:active {
  background: var(--line-highlight);
}
#topbar-hide.on {
  color: var(--accent);
}
/* 同期ボタンの色は同期インジケーター (.st-sync[data-state]) と同じ */
#topbar-sync[data-state="off"] {
  color: var(--gutter);
}
#topbar-sync[data-state="dirty"] {
  color: var(--secondary);
}
#topbar-sync[data-state="syncing"],
#topbar-sync[data-state="error"] {
  color: var(--accent);
}
.tb-project {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-left: 4px;
  color: var(--text-bright);
  font-weight: 600;
  font-size: var(--font-size-sidebar);
}
/* サイドバーは左からのドロワー (幅 246px)。開閉は body.drawer-open。Ctrl+B の sidebar-hidden は無視する */
body.narrow #sidebar,
body.narrow.sidebar-hidden #sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 246px;
  flex: none;
  z-index: 60;
  display: flex;
  padding-top: env(safe-area-inset-top, 0px);
  transform: translateX(-100%);
  transition: transform 0.2s ease-out;
}
body.narrow.drawer-open #sidebar {
  transform: none;
}
/* ホームインジケーター (iPhone) に重ならないよう下端にもセーフエリア分の余白を足す */
body.narrow #sidebar-version {
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}
body.narrow .sb-resizer {
  display: none;
}
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(10 8 6 / 0.55);
}
body.narrow.drawer-open .drawer-backdrop {
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  body.narrow #sidebar {
    transition: none;
  }
}
/* 左の欄は行番号だけ。「隠す」欄は出さず、マークの付いた行は行番号を少し明るくして斜線を重ねる。番号のタップで付け外し (createEditor.ts) */
body.narrow {
  --gutter-width: 34px;
  --hide-gutter-width: 0px;
  --gutter-padding-right: 6px;
  --content-padding-left: 8px;
  height: var(--vvh, 100%);
}
/* タッチ端末 (iPhone): アプリ全体を visualViewport にぴったり重ねる (--vvh / --vvt は src/narrow.ts)。
   キーボードが出たときに Safari がページごと上へスクロールして、タップした行が画面の上端へ飛ぶのを防ぐ。
   スクロールするのはエディタの中 (.cm-scroller) だけ */
@media (pointer: coarse) {
  body.narrow {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    height: auto; /* 高さの計測に頼らず、上下を画面の端に貼り付けて画面いっぱいにする (下に隙間を作らない) */
    overflow: hidden;
  }
  /* キーボードが出ている間だけ visualViewport の位置と高さに合わせる */
  body.narrow.keyboard-open {
    top: var(--vvt, 0px);
    bottom: auto;
    height: var(--vvh, 100%);
  }
}
/* キーボードが出ている間はステータスバーを隠す (キーボードの上に浮いて邪魔になる)。空いた分は本文に回る */
body.narrow.keyboard-open #statusbar {
  display: none;
}
/* iOS は 16px 未満の入力欄にフォーカスすると画面を自動で拡大するので、狭い画面では本文と入力欄を 16px にする。
   行の高さ (22px) と行番号欄はそのまま (行番号は --font-size 13.5px に据え置く) */
body.narrow #editor .cm-editor {
  font-size: 16px;
}
body.narrow #editor .cm-gutters {
  font-size: var(--font-size);
}
body.narrow input,
body.narrow textarea,
body.narrow select {
  font-size: 16px;
}
body.narrow #editor .cm-hide-gutter {
  display: none;
}
body.narrow #editor .cm-lineNumbers .cm-gutterElement {
  cursor: pointer;
}
#editor .cm-lineNumbers .cm-gutterElement.cm-marked-line {
  position: relative;
  color: var(--text-dim);
}
body.narrow #editor .cm-lineNumbers .cm-gutterElement.cm-marked-line::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 3px;
  top: 11px;
  height: 1px;
  background: var(--text-dim);
  transform: rotate(-28deg);
}
/* ステータスバーはファイル名・行列・同期・非表示の目印・Markdown だけ */
body.narrow .st-wide {
  display: none;
}
/* ホームインジケーターの分だけ下に余白を足す。ただし iOS の値 (34px) をそのまま足すとバー本体 (26px) より
   余白の方が高く「浮いている」ように見えるので、14px 差し引く (インジケーターは下端から 8〜13px なので、20px 空けば重ならない) */
body.narrow #statusbar {
  --statusbar-safe: max(env(safe-area-inset-bottom, 0px) - 14px, 0px);
  height: calc(var(--statusbar-height) + var(--statusbar-safe));
  padding-bottom: var(--statusbar-safe);
}

/* ---- リンクの吹き出し (src/editor/linkPopup.ts、タッチ端末だけ)。docs/plan-web-iphone.md 4.2。
   背景 chrome、枠 1px、角丸・影なし。下向きの小さな菱形の矢印がリンクの中央を指す ---- */
.link-popup {
  position: fixed;
  z-index: 80;
  display: inline-flex;
  background: var(--chrome);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--font-size-sidebar);
  line-height: 28px;
  white-space: nowrap;
  --arrow-left: 14px;
}
.link-popup button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.link-popup button + button {
  border-left: 1px solid var(--border);
}
.link-popup button:active {
  background: var(--line-highlight);
}
.link-popup .link-popup-open {
  color: var(--link);
}
.link-popup .icon {
  width: 13px;
  height: 13px;
}
.link-popup::after {
  content: "";
  position: absolute;
  left: var(--arrow-left);
  bottom: -5px;
  width: 8px;
  height: 8px;
  background: var(--chrome);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}
.link-popup.below::after {
  bottom: auto;
  top: -5px;
  border: 0;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

/* ---- 初回起動 (Web 版、src/platform/web/setup.ts)。手元にプロジェクトが無いときだけ全画面で出る。docs/plan-web-iphone.md 4.3。
   背景 bg、一覧は chrome の枡に 1px の枠、選んだ行は左 2px の琥珀。角丸・影なし ---- */
.first-run {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(48px + env(safe-area-inset-top, 0px)) 16px 32px;
}
.fr-card {
  width: 100%;
  max-width: 440px;
  font-size: var(--font-size-sidebar);
  line-height: 18px;
}
.fr-logo {
  color: var(--text-bright);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.fr-title {
  margin: 18px 0 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-bright);
}
.fr-text {
  margin: 0 0 14px;
  color: var(--text-dim);
  font-size: var(--font-size-status);
  line-height: 17px;
}
.fr-field {
  display: block;
  margin: 12px 0 0;
}
.fr-label {
  display: block;
  color: var(--text-dim);
  font-size: var(--font-size-status);
  margin-bottom: 4px;
}
.fr-input {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--input-border);
  background: var(--chrome);
  color: var(--text);
  font: inherit;
  font-size: var(--font-size-sidebar);
  outline: none;
}
.fr-input:focus {
  border-color: var(--accent);
}
.fr-account {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--chrome);
  color: var(--text);
  font-size: var(--font-size-status);
}
.fr-link {
  margin-left: auto;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--link);
  font: inherit;
  font-size: var(--font-size-status);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  cursor: pointer;
}
.fr-label-row {
  display: flex;
  justify-content: space-between;
  margin: 16px 0 4px;
  color: var(--text-dim);
  font-size: var(--font-size-status);
}
.fr-repos {
  border: 1px solid var(--border);
  background: var(--chrome);
  max-height: 46vh;
  overflow-y: auto;
}
.fr-repo {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--font-size-sidebar);
  text-align: left;
  cursor: pointer;
}
.fr-repo + .fr-repo {
  border-top: 1px solid var(--border);
}
.fr-repo:hover {
  background: var(--line-highlight);
}
.fr-repo.sel {
  border-left-color: var(--accent);
  background: var(--line-highlight);
  color: var(--text-bright);
  font-weight: 600;
}
.fr-repo-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.fr-meta {
  flex: none;
  color: var(--gutter);
  font-size: 10.5px;
  font-weight: 400;
}
.fr-meta.note {
  color: var(--secondary);
}
.fr-empty {
  padding: 10px 12px;
  color: var(--text-dim);
  font-size: var(--font-size-status);
}
.fr-go {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  margin-top: 18px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--text-bright);
  font: inherit;
  font-size: var(--font-size-sidebar);
  cursor: pointer;
}
.fr-go:disabled {
  border-color: var(--border);
  color: var(--gutter);
  cursor: default;
}
.fr-go:not(:disabled):hover {
  background: var(--line-highlight);
}
/* 配信前の確認用 (トークンを貼る) のボタンは琥珀にしない */
.fr-go.fr-go-sub {
  margin-top: 10px;
  border-color: var(--input-border);
  color: var(--text);
}
.fr-fine {
  margin: 12px 0 0;
  color: var(--gutter);
  font-size: 10.5px;
  line-height: 15px;
}
.fr-status {
  margin-top: 10px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: var(--font-size-status);
}
.fr-status.error {
  border-color: var(--accent);
  color: var(--text);
}
/* 「既存のリポジトリを追加」のモーダル版は同じ部品をダイアログの中に */
.fr-dialog .fr-body {
  font-size: var(--font-size-sidebar);
}
.fr-dialog .fr-title {
  margin-top: 4px;
}
