/* チャット (PC とスマホで共通) */
.ch { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 110px); min-height: 420px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ch.mobile { height: calc(100dvh - 90px); }
.ch-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ch-side-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ch-groups { overflow-y: auto; flex: 1; }
.ch-g { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.ch-g:hover { background: var(--soft); }
.ch-g.on { background: var(--soft); box-shadow: inset 3px 0 0 var(--accent); }
.ch-ava { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.ch-g-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ch-g-main .row { gap: 6px; flex-wrap: nowrap; }
.ch-g-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-g-n { flex: none; }
.ch-g-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ch-un, .ch-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; line-height: 1; }
.ch-badge[hidden] { display: none; }
.ch-badge { margin-left: 4px; vertical-align: 1px; }
.ch-push { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; gap: 6px; background: var(--soft); }

.ch-room { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ch-pick { margin: auto; text-align: center; }
.ch-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.ch-head-t { min-width: 0; }
.ch-head-t .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-back { display: none; font-size: 26px; line-height: 1; text-decoration: none; padding: 0 6px; color: var(--ink); }
.ch-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; background: var(--bg); display: flex; flex-direction: column; gap: 2px; }
.ch-day { text-align: center; margin: 10px 0 6px; }
.ch-day span { font-size: 11px; background: var(--soft); color: var(--muted); padding: 2px 10px; border-radius: 99px; }
.ch-sys { text-align: center; font-size: 11px; color: var(--muted); margin: 4px 0; }
.ch-more { text-align: center; margin-bottom: 8px; }
.ch-m { display: flex; flex-direction: column; align-items: flex-start; margin-top: 8px; max-width: 100%; }
.ch-m.cont { margin-top: 2px; }
.ch-m.mine { align-items: flex-end; }
.ch-m-name { font-size: 12px; color: var(--muted); margin: 0 0 2px 4px; }
.ch-m-row { display: flex; align-items: flex-end; gap: 6px; max-width: min(82%, 640px); }
.ch-m.mine .ch-m-row { flex-direction: row-reverse; }
.ch-bub { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 7px 11px; min-width: 0; overflow-wrap: anywhere; }
.ch-m.mine .ch-bub { background: #d9f2e3; border-color: #bfe5cf; }
.ch-bub.del { color: var(--muted); font-size: 12px; font-style: italic; }
.ch-txt { white-space: pre-wrap; }
.ch-meta { display: flex; flex-direction: column; align-items: flex-end; font-size: 10px; color: var(--muted); flex: none; gap: 1px; }
.ch-m:not(.mine) .ch-meta { align-items: flex-start; }
.ch-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0 2px; opacity: 0; }
.ch-m:hover .ch-x, .ch.mobile .ch-x { opacity: .7; }
.ch-scene { display: flex; gap: 10px; align-items: center; text-align: left; margin-top: 4px; padding: 8px 10px; width: 100%; min-width: 220px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--soft); color: var(--ink); cursor: pointer; font: inherit; }
.ch-scene:hover { border-color: var(--accent); }
.ch-scene.off { cursor: default; color: var(--muted); }
.ch-sc-ic { font-size: 22px; }
.ch-sc-main { display: flex; flex-direction: column; min-width: 0; }
.ch-attach { padding: 8px 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; background: var(--soft); }
.ch-comp { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px; border-top: 1px solid var(--line); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.ch-comp textarea { flex: 1; resize: none; min-height: 38px; max-height: 160px; font: inherit; padding: 8px 10px; border-radius: 18px; }

.ch-modal { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 12px; }
.ch-modal-box { background: var(--panel); color: var(--ink); border-radius: 12px; padding: 14px 16px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.ch-f { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.ch-f input:not([type]) { width: 100%; }
.ch-quick { gap: 6px; }
.ch-pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.ch-pp { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ch-pp[hidden] { display: none; }
.ch-pp .sub { margin-left: auto; }
.ch-mem { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--soft); border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.ch-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; }

/* スマホ: 一覧と会話を切り替える */
@media (max-width: 760px) {
  .ch { grid-template-columns: 1fr; border-radius: 0; border-left: 0; border-right: 0; }
  .ch.open .ch-side { display: none; }
  .ch:not(.open) .ch-room { display: none; }
  .ch-back { display: block; }
  .ch-m-row { max-width: 88%; }
}
.m-chat { position: relative; font-size: 14px; text-decoration: none; line-height: 1; }
.m-chat .ch-badge { position: absolute; top: -6px; right: -10px; margin: 0; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ch-m.mine .ch-bub { background: #17402a; border-color: #20573a; }
}

/* 写真・ファイル・スタンプ・リアクション・作戦ボード */
.ch-usage { padding: 6px 12px; border-top: 1px solid var(--line); font-size: 11px; }
.ch-tb { padding: 6px 8px; font-size: 13px; line-height: 1; }
.ch-ext { flex: none; font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); padding: 3px 5px; }
.ch-bub.media { padding: 3px; background: transparent; border-color: transparent; }
.ch-m.mine .ch-bub.media { background: transparent; border-color: transparent; }
.ch-img, .ch-vid { display: block; max-width: 100%; height: auto; border-radius: 10px; cursor: zoom-in; background: var(--soft); }
.ch-vid { cursor: default; }
.ch-bub .ch-img, .ch-bub .ch-vid { margin: 4px 0; }
.ch-file { display: flex; gap: 10px; align-items: center; padding: 6px 4px; color: var(--ink); text-decoration: none; min-width: 200px; }
.ch-file:hover b { text-decoration: underline; }
.ch-board-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 2px; }
.ch-board-h .btn { margin-left: auto; }
.ch-stamp { display: inline-flex; flex-direction: column; align-items: center; padding: 4px 8px; }
.ch-stamp-e { font-size: 44px; line-height: 1.1; }
.ch-stamp-t { font-weight: 800; font-size: 14px; color: var(--accent); }
.ch-stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; padding: 8px; border-top: 1px solid var(--line); background: var(--soft); max-height: 220px; overflow-y: auto; }
.ch-stamp-btn { border: 1px solid transparent; background: var(--panel); border-radius: 10px; cursor: pointer; padding: 2px; }
.ch-stamp-btn:hover { border-color: var(--accent); }
.ch-stamp-btn .ch-stamp-e { font-size: 30px; }
.ch-stamp-btn .ch-stamp-t { font-size: 11px; }
.ch-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.ch-re { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 1px 8px; font-size: 13px; cursor: pointer; color: var(--ink); }
.ch-re.on { border-color: var(--accent); background: #e3f4ea; }
.ch-rpick { position: fixed; z-index: 300; display: flex; gap: 2px; padding: 4px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.ch-rpick button { border: 0; background: none; font-size: 22px; cursor: pointer; padding: 2px 4px; border-radius: 8px; }
.ch-rpick button:hover { background: var(--soft); transform: scale(1.15); }
.ch-modal.lb .ch-modal-box { width: auto; max-width: 96vw; background: #111; }
.ch-lb-img { display: block; max-width: 92vw; max-height: 82vh; margin: 0 auto; cursor: zoom-out; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ch-re.on { background: #17402a; }
}
/* 運営者に知らせる */
.ch-rep-note { font-size: 12px; line-height: 1.6; background: var(--bg, rgba(0,0,0,.04)); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.ch-modal-box textarea { width: 100%; box-sizing: border-box; }
