/* 連絡（#/chat）。LINE のPC版と同じ構成（11/18 本人「LINEのUIをまるパクり」）：
   左に相手のリスト（検索・丸いアイコン・名前・最後の連絡・時刻・未読の丸）、右にトーク（名前・やりとり・下に固定の入力欄）。
   スマホ（〜699px）はリスト → トーク（戻る付き）の2段。色は app.css の変数だけ。LINE のロゴ・色・画像は使わない。 */
.lc {
  --lc-accent: var(--brand);
  --lc-on-accent: var(--on-brand);
  --lc-list-w: clamp(280px, 34%, 400px);
  --lc-row-on: var(--fill);
  --lc-row-hover: var(--fill);
  --lc-other: var(--fill);
  display: grid; grid-template-columns: var(--lc-list-w) minmax(0, 1fr);
  height: 100%; min-height: 0; background: var(--bg);
}

/* 外枠：連絡のときだけ本文の余白と幅の上限を外し、画面いっぱいにする（スクロールはリストとトークの中だけ） */
.pane:has(.lc) { display: flex; flex-direction: column; overflow: hidden; }
.pane:has(.lc) > .pane-in { flex: 1; min-height: 0; max-width: none; margin: 0; padding: 0; gap: 0; display: flex; flex-direction: column; }
.pane:has(.lc) > .pane-in > .lc { flex: 1 1 auto; height: auto; }
/* 進め方の帯（スマホ）はリストの上に置くだけ。本文の余白を外したので、帯の負のマージンと sticky も外す */
#main.pane:has(.lc) .stage-fold { flex: none; position: static; margin: 0; }

/* ───── 左：リスト ───── */
.lc-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--bg); }
.lc-tools { display: flex; gap: 8px; padding: 16px 16px 12px; }
.lc-search { position: relative; flex: 1; min-width: 0; display: block; }
.lc-search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--label2); pointer-events: none; }
.lc .lc-tools .lc-search input[type="search"] { width: 100%; min-height: 44px; padding: 0 12px 0 36px; border: 1px solid transparent; border-radius: var(--r-ctl); background: var(--fill); font-size: var(--fs-15); }
.lc .lc-tools .lc-search input[type="search"]:focus-visible { border-color: var(--focus); outline: none; background: var(--bg); }
.lc .lc-tools select.lc-sort { flex: none; width: auto; min-height: 44px; padding: 0 28px 0 12px; border-color: var(--line); font-size: var(--fs-13); }
.lc-rows { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.lc-rows-none { padding: 16px; }
.lc-rows-list { margin: 0; padding: 0; list-style: none; }
.lc-row { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px 16px; color: var(--label); text-decoration: none; }
@media (hover: hover) { .lc-row:hover { background: var(--lc-row-hover); } }
.lc-row.on { background: var(--tint); }
.lc-row.on .lc-name { color: var(--brand-text); }
.lc-row.on .lc-av { background: var(--brand); color: var(--on-brand); }
.lc-row:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: 0; }
.lc-av { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--fill); color: var(--label2); font-size: var(--fs-17); font-weight: 600; line-height: 1; }
.lc-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lc-row-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-15); font-weight: 600; }
/* 相手の役（進路指導・学科担当）は名前の下の1行に。名前の横だと長い学校名が5字で切れて、2行が同じに見えた（11/22 機械検査） */
.lc-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label2); font-size: var(--fs-13); }
.lc-time { flex: none; margin-left: auto; padding-left: 8px; color: var(--label2); font-size: var(--fs-13); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lc-row-bottom { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.lc-last { flex: 1; min-width: 0; display: block; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; overflow-wrap: anywhere; color: var(--label2); font-size: var(--fs-13); line-height: 1.45; }
.lc-row.is-unread .lc-name { font-weight: 600; }
.lc-row.is-unread .lc-last { color: var(--label); }
.lc-badge { flex: none; margin-left: auto; min-width: 20px; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--lc-accent); color: var(--lc-on-accent); font-size: var(--fs-13); font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.lc-note { padding: 12px 16px;  border-top: 1px solid var(--line); }
.lc-note p { margin: 0; font-size: var(--fs-13); overflow-wrap: anywhere; }
.lc-note a, .lc-note .btn { margin-left: 8px; }

/* ───── 右：トーク ───── */
.lc-room { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.lc-none { margin: auto; color: var(--label2); font-size: var(--fs-15); }
.lc-head { flex: none; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.lc-back { display: none; }
.lc-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lc-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-17); font-weight: 600; line-height: 1.35; }
.lc-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--label2); }
.lc-acts { flex: none; display: flex; align-items: center; gap: 8px; }
.lc-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 24px 20px; }
.lc-body .thread-empty { padding: 24px 0; text-align: center; }

/* やりとり（.thread の部品は app.css。ここは LINE の形に寄せる差分だけ） */
.lc .msg-day { margin: 16px 0 8px; }
.lc .msg-day span { padding: 0; background: none; color: var(--label2); border-radius: 0; font-size: var(--fs-13); }
.lc .msg { max-width: min(78%, 640px); margin-top: 12px; }
.lc .msg.cont { margin-top: 4px; }
.lc .msg-av { width: 36px; height: 36px; }
.lc .msg.cont .msg-av { height: 0; }
.lc .msg-bubble { padding: 8px 12px; background: var(--lc-other); }
.lc .msg.mine .msg-bubble { background: var(--lc-accent); color: var(--lc-on-accent); }
.msg-meta { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 0; color: var(--label2); font-size: var(--fs-13); line-height: 1.3; font-variant-numeric: tabular-nums; }
.msg.mine .msg-meta { align-items: flex-end; }
.msg-meta time { font-size: var(--fs-13); color: var(--label2); }
.msg-read { font-size: var(--fs-13); color: var(--label2); }
.msg-file { min-width: 0; max-width: 100%; }
.msg-img { display: block; line-height: 0; }
.msg-img img { display: block; height: 200px; width: auto; max-width: min(320px, 100%); object-fit: cover; border: 1px solid var(--line); border-radius: 12px; background: var(--fill); }
.lc .case-file, .chat-page .case-file { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: var(--ctl); padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--label); text-decoration: none; }
@media (hover: hover) { .lc a.case-file:hover { background: var(--fill); } }
.lc .case-file-kind { flex: none; padding: 0 4px; border: 1px solid var(--line-strong); font-size: var(--fs-13); font-weight: 600; color: var(--label2); line-height: 1.5; }
.lc .case-file-name { min-width: 0; overflow: hidden; font-size: var(--fs-15); text-overflow: ellipsis; white-space: nowrap; }
.lc .case-file-size { flex: none; font-size: var(--fs-13); color: var(--label2); font-variant-numeric: tabular-nums; }
.lc .case-doc .case-file-kind { border-color: var(--brand); color: var(--brand-text); }

/* ───── 下：入力欄（固定）。＋から画像・ファイル・書類 ───── */
.lc .lc-composer { position: relative; flex: none; margin: 0; padding: var(--sp-12) var(--sp-16) calc(var(--sp-12) + var(--safe-b)); }
.lc-plus { position: relative; flex: none; }
.lc-plus-btn { flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--label2); }
.lc-plus-btn[aria-expanded="true"] { background: var(--fill); color: var(--label); } @media (hover: hover) { .lc-plus-btn:hover { background: var(--fill); color: var(--label); } }
.lc-plus-btn .i { width: 24px; height: 24px; }
.lc-plus-menu { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 20; min-width: 220px; display: flex; flex-direction: column; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--bg); }
.lc-plus-menu[hidden] { display: none; }
.lc-plus-item { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 4px 12px; border: 0; border-radius: var(--r-ctl); background: none; color: var(--label); font-size: var(--fs-15); text-align: left; cursor: pointer; }
@media (hover: hover) { .lc-plus-item:hover { background: var(--fill); } }
.lc-plus-item:focus-within, .lc-plus-item:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.lc-plus-item .i { width: 20px; height: 20px; color: var(--label2); }
.lc-plus-item small { display: block; color: var(--label2); font-size: var(--fs-13); line-height: 1.3; }
/* 「書類を送る」（school2.js の chatDocsButton）。文字だけのボタンなので、印は CSS で付ける */
.lc-plus-item[data-act="chat-docs"]::before { content: ""; flex: none; width: 20px; height: 20px; background: var(--label2); -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='M6.5 3.5h7.5l4.5 4.5v12.5h-12z'/%3E%3Cpath d='M14 3.5V8h4.5'/%3E%3Cpath d='M9.5 13h5M9.5 16.5h5'/%3E%3C/svg%3E") center / contain 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='M6.5 3.5h7.5l4.5 4.5v12.5h-12z'/%3E%3Cpath d='M14 3.5V8h4.5'/%3E%3Cpath d='M9.5 13h5M9.5 16.5h5'/%3E%3C/svg%3E") center / contain no-repeat; }
.lc-plus-full { margin: 0; padding: 8px 12px; color: var(--label2); font-size: var(--fs-13); }

/* ───── スマホ：リスト → トークの2段 ───── */
@media (max-width: 699px) {
  .lc { display: block; position: relative; }
  .lc-list, .lc-room { height: 100%; }
  .lc-list { border-right: 0; }
  .lc-room { display: none; }
  .lc.lc-on .lc-list { display: none; }
  .lc.lc-on .lc-room { display: flex; }
  .lc-tools { padding: 12px 16px 8px; }
  .lc-row { padding: 12px 16px; }
  .lc-head { min-height: 52px; padding: 4px 12px 4px 4px; gap: 4px; }
  .lc-back { display: grid; place-items: center; flex: none; width: 44px; height: 44px; color: var(--label); }
  .lc-back .i { width: 24px; height: 24px; }
  .lc-acts .btn { padding: 0 12px; }
  .lc-body { padding: 8px 12px 16px; }
  .lc .msg { max-width: 86%; }
  .msg-img img { height: 160px; max-width: min(240px, 100%); }
  .lc .lc-composer { padding: 8px 8px calc(8px + var(--safe-b)); }
  .lc .lc-composer textarea { font-size: var(--fs-17); }
  /* トークの中は LINE と同じく下のタブと名前の帯を隠し、入力欄を一番下に置く */
  html:has(.lc.lc-on) :is(.tabbar, #k-tabbar) { display: none; }
  .pane:has(.lc.lc-on) :is(.mobile-identity, .stage-fold) { display: none; }
}

@media print {
  .lc { display: block; height: auto; }
  .lc-list, .lc-plus, .lc-back, .lc-acts { display: none !important; }
  .lc-body { overflow: visible; }
}

/* 11/19 apple r2 軽2：一覧の行は罫線（頭文字の丸の右から）＋スマホは右に ›。検索と並べ替えは同じ灰色の塗りの欄 */
.lc-rows-list > li { border-bottom: 1px solid var(--line); margin-left: 76px; }
.lc-rows-list > li > .lc-row { margin-left: -76px; }
.lc .lc-tools select.lc-sort { border-color: transparent; border-radius: var(--r-ctl); background-color: var(--fill); font-size: var(--fs-15); }
@media (max-width: 699px) {
  .lc-row::after { content: "›"; flex: none; margin-left: 4px; color: var(--label2); font-size: var(--fs-20); line-height: 1; }
}

/* 体験の帯・通信状態の帯を含めて画面に収める。従来の #app は bar の高さしか引かず、
   体験のバナーの分だけ composer が画面外へ押し出されていた。 */
.chat-viewport { --chat-viewport-height: 100dvh; --chat-viewport-top: 0px; }
html body:has(.lc) { display: flex; flex-direction: column; height: var(--chat-viewport-height, 100dvh); min-height: 0; overflow: hidden; }
html body:has(.lc) > :is(.bar, .demo-bar, .net-banner) { flex: none; }
html body:has(.lc) > #app { flex: 1; min-height: 0; height: auto; }
.shell:has(.lc) { min-height: 0; grid-template-rows: minmax(0, 1fr); }
.pane:has(.lc) { min-height: 0; }
.pane:has(.lc) > :not(.pane-in) { flex: none; }
@media (max-width: 699px) {
  html body:has(.lc.lc-on) { position: fixed; top: var(--chat-viewport-top, 0px); left: 0; right: 0; }
  html body:has(.lc.lc-on) > .bar { display: none; }
  .lc .lc-composer { padding: var(--sp-8) var(--sp-12) calc(var(--sp-8) + var(--safe-b)); }
  .lc-title h1 { white-space: normal; overflow-wrap: anywhere; }
  .lc-acts .btn { font-size: var(--fs-13); padding-inline: var(--sp-8); }
}
@media print {
  html body:has(.lc) { display: block; position: static; height: auto; overflow: visible; }
  .chat-conversation { display: block; height: auto; }
  .composer, .chat-starter, .chat-latest { display: none; }
}
