/* ============================================================
   app.css  ikiikild
   ・スマホ前提。1カラム、上に固定ヘッダ、下に入力欄。
   ・色はCSS変数にまとめ、ダークモードは変数だけ差し替える。
   ・safe-area（iPhoneのノッチ・ホームバー）を必ず見込む。
   ============================================================ */

:root {
  --bg:        #f6f7f8;
  --surface:   #ffffff;
  --surface-2: #eef0f2;
  --text:      #14181c;
  --text-dim:  #6b7580;
  --line:      #e2e6ea;
  --accent:    #0f766e;
  --accent-ink:#ffffff;
  --mine:      #d7f0ec;   /* 自分の吹き出し */
  --mine-ink:  #10312e;
  --danger:    #c0392b;
  --ok:        #157347;
  --shadow:    0 1px 2px rgba(16,24,32,.06), 0 4px 16px rgba(16,24,32,.06);
  --radius:    14px;
  --head-h:    54px;
  --safe-t:    env(safe-area-inset-top, 0px);
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14171a;
    --surface:   #1c2024;
    --surface-2: #262b31;
    --text:      #e8eaed;
    --text-dim:  #98a2ad;
    --line:      #2f353c;
    --accent:    #2dd4bf;
    --accent-ink:#06201d;
    --mine:      #1f3f3b;
    --mine-ink:  #d7f0ec;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}

/* hidden 属性は「常に」効かせる。
   .ring-overlay{display:grid} のように display を持つクラスがあると、
   ブラウザ既定の [hidden]{display:none} に勝ってしまい、
   JSで el.hidden = true にしても消えない（＝着信画面が出っぱなしになる）。 */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
a { color: var(--accent); }
svg { width: 22px; height: 22px; flex: none; }
button { font: inherit; color: inherit; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-passkey { background: var(--surface); }
.btn-danger  { color: var(--danger); }
.btn-sm { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- ログイン前 ---------- */
.auth-body { display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 18px; padding: 28px 22px; box-shadow: var(--shadow);
}
.auth-title { margin: 0 0 14px; font-size: 24px; letter-spacing: .02em; }
.auth-title .brand-logo img { height: 42px; width: auto; max-width: 100%; }
.auth-lead  { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }
.auth-form  { display: grid; gap: 14px; }
.auth-note  { margin: 18px 0 0; font-size: 13px; color: var(--text-dim); line-height: 1.8; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-dim); }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.code-input { letter-spacing: .5em; font-size: 22px !important; text-align: center; font-variant-numeric: tabular-nums; }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-dim); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.invite-msg { margin: 0 0 18px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; font-size: 14px; }

.alert { padding: 11px 14px; border-radius: 11px; font-size: 14px; margin-bottom: 14px; }
.alert.err { background: #fdecea; color: #8b2b20; }
.alert.dev { background: #fff6d6; color: #6b5300; }
@media (prefers-color-scheme: dark) {
  .alert.err { background: #3a201d; color: #ffb4a8; }
  .alert.dev { background: #34301c; color: #ffe08a; }
}

/* ---------- アプリの枠 ---------- */
/* 画面の高さ。
   iOS Safari は 100dvh がツールバーぶんを含んだ高さになることがあり、
   そのとき一番下の入力欄が下のツールバーに隠れて見えなくなる。
   ・100svh ＝ ツールバーが出ている前提の高さ。隠れることがない
   ・さらに JS が --app-h に「いま実際に見えている高さ」を入れる
     （キーボードが出たときも入力欄がその上に来る）
   古いブラウザ向けに 100vh → 100svh → var の順に重ねる。 */
.app-shell { display: flex; flex-direction: column; height: 100vh; height: 100svh; height: var(--app-h, 100svh); }
.app-head {
  position: sticky; top: 0; z-index: 30; flex: none;
  display: flex; align-items: center; gap: 10px;
  height: calc(var(--head-h) + var(--safe-t)); padding: var(--safe-t) 10px 0;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
/* 左上のロゴ。<picture> は箱なので、中の <img> に高さを与える */
.brand { display: flex; align-items: center; text-decoration: none; flex: none; }
.brand-logo { display: block; line-height: 0; }
.brand-logo img { height: 26px; width: auto; display: block; }
@media (min-width: 900px) { .brand-logo img { height: 28px; } }
.head-title { flex: 1; font-weight: 700; font-size: 16px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.head-btn {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; background: none; border-radius: 50%; color: var(--text); text-decoration: none; cursor: pointer;
}
.head-btn:active { background: var(--surface-2); }
.head-btn.back { margin-left: -4px; }
.head-btn .dot { position: absolute; top: 7px; right: 7px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.app-main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- アバター ---------- */
.avatar {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 18px; text-decoration: none; overflow: hidden;
}
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }
.avatar.xs { width: 26px; height: 26px; font-size: 12px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 部屋の一覧 ---------- */
.room-list { list-style: none; margin: 0; padding: 0 0 calc(90px + var(--safe-b)); }
.room-item { display: flex; gap: 12px; align-items: center; padding: 12px 16px;
  text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.room-item:active { background: var(--surface-2); }
.room-body { flex: 1; min-width: 0; }
.room-top { display: flex; align-items: baseline; gap: 8px; }
.room-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-when { margin-left: auto; font-size: 12px; color: var(--text-dim); flex: none; }
.room-prev { font-size: 14px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-grid; place-items: center; min-width: 21px; height: 21px; padding: 0 6px;
  border-radius: 11px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.badge.mute { background: var(--text-dim); }
.room-tag { font-size: 11px; color: var(--text-dim); border: 1px solid var(--line);
  border-radius: 5px; padding: 0 5px; flex: none; }

.empty { padding: 60px 28px; text-align: center; color: var(--text-dim); }
.empty svg { width: 46px; height: 46px; opacity: .35; margin-bottom: 12px; }

/* 右下の丸ボタン */
.fab {
  position: fixed; right: 18px; bottom: calc(20px + var(--safe-b)); z-index: 20;
  display: grid; place-items: center; width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }

/* ---------- チャット ---------- */
/* 部屋の中だけは、画面ではなく chatScroll をスクロールさせる
   （入力欄を常に下に固定し、iOSでキーボードが出ても隠れないようにするため） */
body.in-room .app-main { display: flex; flex-direction: column; overflow: hidden; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 4px; }
#chatList { display: flex; flex-direction: column; }
.tc { text-align: center; padding: 4px 0 8px; }

.day-sep { align-self: center; margin: 14px 0 8px; padding: 3px 12px; border-radius: 11px;
  background: var(--surface-2); color: var(--text-dim); font-size: 12px; }
.sys-msg { align-self: center; margin: 6px 0; padding: 4px 12px; border-radius: 11px;
  background: var(--surface-2); color: var(--text-dim); font-size: 12.5px; text-align: center; }
/* メモ・アルバムのお知らせは、その画面へ飛べる */
a.sys-msg.link { color: var(--accent); font-weight: 600; text-decoration: none; }
a.sys-msg.link:active { background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }

.msg { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; max-width: 100%; }
.msg.mine { flex-direction: row-reverse; }
.msg.same { margin-top: 2px; }
.msg.same > .avatar { visibility: hidden; height: 0; margin: 0; }

.msg-col { min-width: 0; max-width: min(78%, 560px); display: flex; flex-direction: column; }
.msg.mine .msg-col { align-items: flex-end; }
.msg-author { font-size: 12px; color: var(--text-dim); margin: 0 0 3px 4px; }

/* 吹き出しはタップできる（詳細モーダルが開く）。ボタンは一切載せない。 */
.bubble { padding: 9px 13px; border-radius: 16px 16px 16px 4px; background: var(--surface);
  box-shadow: var(--shadow); word-break: break-word; overflow-wrap: anywhere; cursor: pointer; }
.msg.mine .bubble { background: var(--mine); color: var(--mine-ink); border-radius: 16px 16px 4px 16px; }
.bubble .btext { white-space: pre-wrap; }
.bubble.deleted { color: var(--text-dim); font-style: italic; background: transparent;
  box-shadow: none; border: 1px dashed var(--line); cursor: default; }
.bubble a { text-decoration: underline; }

.msg-meta { display: flex; align-items: center; gap: 8px; margin: 3px 4px 0;
  font-size: 11px; color: var(--text-dim); }
.msg.mine .msg-meta { flex-direction: row-reverse; }
.msg-meta button { border: 0; background: none; padding: 0; font-size: 11px; cursor: pointer; }
.read-n { color: var(--accent); font-weight: 700; }
.cmt-n { color: var(--accent); font-weight: 700; background: var(--surface-2);
  border-radius: 10px; padding: 1px 8px !important; }

/* 添付 */
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.bubble .btext + .files { margin-top: 8px; }
.file-img { display: block; max-width: 240px; max-height: 300px; border-radius: 12px;
  cursor: zoom-in; background: var(--surface-2); object-fit: cover; }
.file-chip { display: flex; align-items: center; gap: 9px; padding: 9px 12px; max-width: 260px;
  background: var(--surface-2); border-radius: 12px; text-decoration: none; color: inherit; }
.file-chip svg { width: 20px; height: 20px; color: var(--text-dim); }
.file-chip .fname { display: block; font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fsize { display: block; font-size: 11px; color: var(--text-dim); }

/* 押されたリアクションだけをチップで出す */
.reacts { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 2px 0; }
.reacts:empty { display: none; }
.msg.mine .reacts { justify-content: flex-end; }
.react { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font-size: 13px; cursor: pointer; line-height: 1.8; }
.react.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.react .n { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ---------- 詳細モーダルの中身 ---------- */
.th-parent { background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; line-height: 1.7; word-break: break-word; margin-bottom: 4px; }
.th-parent .th-who { display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--text-dim); margin-bottom: 4px; }
.th-parent .th-who .nm { font-weight: 700; color: var(--text); }

/* タップすると絵文字を選べる。押せることが分かるように、うっすら反応させる */
.tappable { cursor: pointer; transition: background .12s; }
.tappable:active { background: var(--surface-2); }
@media (hover: hover) { .tappable:hover { background: var(--surface-2); } }

/* 絵文字を選ぶ（常設せず、押したいときだけ出す） */
.emoji-pick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 18px 16px; }
.emoji-pick button { width: 52px; height: 52px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); font-size: 25px; cursor: pointer; }
.emoji-pick button:active { background: var(--surface-2); }

/* コメントの入力欄（モーダルの一番下） */
.th-input-wrap { position: sticky; bottom: 0; background: var(--surface);
  padding-top: 10px; margin-top: 14px; border-top: 1px solid var(--line); }


.th-acts { display: flex; gap: 8px; margin-bottom: 14px; }
.th-act-btn { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 8px; font-size: 14px; font-weight: 700; cursor: pointer; }
.th-act-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.th-input { display: flex; gap: 8px; align-items: flex-end; }
.th-input textarea { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 13px; font-size: 16px; font-family: inherit; resize: none; line-height: 1.5;
  background: var(--bg); color: var(--text); }
.th-count { font-size: 12px; font-weight: 700; color: var(--text-dim); margin: 16px 0 6px;
  padding-top: 12px; border-top: 1px solid var(--line); }
/* コメントは元の発言の直下に、少し内側へ寄せて並べる（返信だと分かるように） */
.th-item { padding: 10px 12px; margin-left: 14px; border-left: 2px solid var(--line);
  border-radius: 0 10px 10px 0; }
.th-item + .th-item { margin-top: 4px; }
.th-head { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-dim); }
.th-head .nm { font-weight: 700; color: var(--text); }
.th-act { margin-left: auto; display: flex; gap: 10px; }
.th-act button { border: 0; background: none; color: var(--accent); font-size: 11.5px;
  font-weight: 700; cursor: pointer; padding: 0; }
.th-act button.del { color: var(--danger); }
.th-body { font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; margin-top: 3px; }
.th-body.del { color: var(--text-dim); font-style: italic; }

/* 既読の内訳 */
.rd-head { font-size: 12px; font-weight: 700; color: var(--text-dim); margin: 12px 0 6px; }
.rd-names { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-name { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 4px 11px; }
.rd-name.yet { background: transparent; color: var(--text-dim); }

/* ---------- 入力欄 ---------- */
.composer {
  flex: none; padding: 8px 10px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px); border-top: 1px solid var(--line);
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; min-height: 42px; max-height: 140px; padding: 10px 14px; resize: none;
  font-size: 16px; line-height: 1.5; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 20px;
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  border: 0; border-radius: 50%; background: var(--surface-2); color: var(--text); cursor: pointer;
}
.icon-btn.send { background: var(--accent); color: var(--accent-ink); }
.icon-btn:disabled { opacity: .45; }

/* 送信前のファイルプレビュー */
.pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px 8px; }
.pending .pf { display: flex; align-items: center; gap: 7px; padding: 5px 9px;
  background: var(--surface-2); border-radius: 10px; font-size: 12.5px; max-width: 190px; }
.pending .pf span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending .pf button { border: 0; background: none; color: var(--text-dim); cursor: pointer; padding: 0; }
.pending .pf img { width: 34px; height: 34px; border-radius: 7px; object-fit: cover; }

/* 返信・編集のバー */

/* アップロード進捗 */
.upbar { height: 3px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-bottom: 7px; }
.upbar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- 汎用シート（下から出るモーダル） ---------- */
.sheet-back {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.42);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .18s;
}
.sheet-back.show { opacity: 1; }
.sheet {
  /* キーボードが出ても隠れないよう、実際に見えている高さ（--app-h）を基準にする */
  width: 100%; max-width: 560px; max-height: calc(var(--app-h, 86svh) * 0.86);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0;
  padding-bottom: var(--safe-b); transform: translateY(100%); transition: transform .2s;
}
.sheet-back.show .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; margin: 0; font-size: 16px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.sheet-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 0; }

.menu-list { list-style: none; margin: 0; padding: 6px 0; }
.menu-list button, .menu-list a {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px;
  border: 0; background: none; text-align: left; text-decoration: none; color: inherit; cursor: pointer; font-size: 15px;
}
.menu-list button:active, .menu-list a:active { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }

/* 画像の拡大表示 */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.92);
  display: grid; place-items: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 88dvh; object-fit: contain; }
.lightbox .lb-close { position: absolute; top: calc(12px + var(--safe-t)); right: 12px;
  width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; cursor: pointer; }
.lightbox .lb-dl { position: absolute; bottom: calc(20px + var(--safe-b)); color: #fff;
  background: rgba(255,255,255,.18); border-radius: 20px; padding: 9px 18px; text-decoration: none; font-size: 14px; }

/* ---------- 一覧（友だち・メンバー・設定） ---------- */
.section { margin: 14px 0; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section h2 { margin: 0; padding: 12px 16px 6px; font-size: 12px; font-weight: 700;
  color: var(--text-dim); letter-spacing: .08em; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .who { flex: 1; min-width: 0; }
.list .who b { display: block; font-weight: 600; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .who small { color: var(--text-dim); font-size: 12px;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .acts { display: flex; gap: 6px; flex: none; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; flex: none; }
.pagepad { padding: 0 0 calc(30px + var(--safe-b)); }
.formcard { background: var(--surface); border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); padding: 16px; display: grid; gap: 12px; }
.hint { font-size: 12.5px; color: var(--text-dim); margin: 0; line-height: 1.7; }
.plain-input { width: 100%; padding: 12px 14px; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; font-size: 14px; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }

/* ---------- 通話 ---------- */
.ring-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(8,12,16,.9);
  display: grid; place-items: center; padding: 24px; }
.ring-card { text-align: center; color: #fff; }
.ring-avatar { width: 92px; height: 92px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 36px; font-weight: 700;
  background: var(--accent); color: #fff; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(45,212,191,.5); } 70% { box-shadow: 0 0 0 26px rgba(45,212,191,0); } 100% { box-shadow: 0 0 0 0 rgba(45,212,191,0); } }
.ring-name { font-size: 22px; font-weight: 700; }
.ring-sub  { color: #9aa4ae; font-size: 14px; margin-top: 4px; }
.ring-actions { display: flex; gap: 44px; justify-content: center; margin-top: 40px; }
.btn-round { width: 66px; height: 66px; border: 0; border-radius: 50%; display: grid; place-items: center;
  color: #fff; cursor: pointer; }
.btn-round svg { width: 28px; height: 28px; }
.btn-round.accept  { background: #16a34a; }
.btn-round.decline { background: #dc2626; }

.call-panel {
  position: fixed; inset: 0; z-index: 85; background: #0d1114; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(30px + var(--safe-t)) 24px calc(30px + var(--safe-b));
}
.call-peers { display: flex; flex-wrap: wrap; gap: 22px; justify-content: center; margin-bottom: 26px; }
.call-peer { text-align: center; width: 96px; }
.call-peer .avatar { width: 72px; height: 72px; font-size: 27px; margin: 0 auto 8px;
  transition: box-shadow .12s; }
.call-peer.talking .avatar { box-shadow: 0 0 0 4px #22c55e; }
.call-peer .pname { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-peer .pstate { font-size: 11px; color: #9aa4ae; }
.call-timer { font-size: 15px; color: #9aa4ae; font-variant-numeric: tabular-nums; margin-bottom: 34px; }
.call-actions { display: flex; gap: 26px; }
.call-actions .btn-round { background: rgba(255,255,255,.14); }
.call-actions .btn-round.off { background: #fff; color: #0d1114; }
.call-actions .btn-round.hang { background: #dc2626; }
.call-warn { margin-top: 22px; font-size: 12.5px; color: #f0b429; text-align: center; max-width: 320px; }

/* 部屋の中の「通話中」バー */
.call-bar { display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.call-bar svg { width: 18px; height: 18px; }

/* ---------- トースト ---------- */
.toast { position: fixed; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%);
  z-index: 95; max-width: 90vw; padding: 11px 18px; border-radius: 22px;
  background: rgba(20,24,28,.94); color: #fff; font-size: 14px; box-shadow: var(--shadow); }
.toast.err { background: #b3261e; }

/* ---------- 細かい調整 ---------- */
.spinner { width: 20px; height: 20px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.muted  { color: var(--text-dim); }
.tiny   { font-size: 12px; }
.hidden { display: none !important; }
/* ============================================================
   PC表示（900px以上）：左にトーク一覧、右に本体（LINE・Teams と同じ形）
   スマホ（900px未満）は今までどおりの1カラム。.side は出さない。
   ============================================================ */
/* min-height:0 が無いと、縦のflexの中で中身の高さぶんだけ伸びてしまう。
   すると画面全体がスクロールし、ヘッダとタブが流れて、
   トークを開いた位置も一番上（古い方）になる。ここは外さないこと。 */
.app-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.side { display: none; }

@media (min-width: 900px) {
  .app-shell { flex-direction: row; max-width: 1180px; margin: 0 auto;
    border-inline: 1px solid var(--line); }

  .side {
    display: flex; flex-direction: column; width: 310px; flex: none;
    border-right: 1px solid var(--line); background: var(--surface);
    padding-top: var(--safe-t);
  }
  .side-head { display: flex; align-items: center; gap: 8px; height: var(--head-h);
    padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); flex: none; }
  .side-head .brand { text-decoration: none; }
  .side-list { flex: 1; min-height: 0; overflow-y: auto; }
  .side-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
  .side-item:hover { background: var(--surface-2); }
  .side-item.on { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
  .side-item .avatar { width: 40px; height: 40px; font-size: 16px; }
  .side-body { flex: 1; min-width: 0; }
  .side-top { display: flex; align-items: baseline; gap: 8px; }
  .side-name { font-weight: 600; font-size: 14.5px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
  .side-when { margin-left: auto; font-size: 11px; color: var(--text-dim); flex: none; }
  .side-prev { font-size: 12.5px; color: var(--text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-foot { flex: none; padding: 10px 14px calc(10px + var(--safe-b));
    border-top: 1px solid var(--line); }
  .side-foot .btn { width: 100%; }

  /* 左に一覧があるので、右側の「戻る」と丸ボタンは不要 */
  body.has-side .head-btn.back { display: none; }
  body.has-side .fab { display: none; }
  /* トップ画面は右側を案内だけにする（一覧は左にある） */
  body.has-side.is-home .room-list { display: none; }
  body.has-side.is-home .home-hint { display: block; }

  .msg-col { max-width: min(70%, 620px); }
}
.home-hint { display: none; }

/* ---------- 部屋の中の機能タブ ---------- */
/* 部屋の中のタブは常に上に固定する。
   トークは .app-main が flex なので flex:none で、
   メモ・アルバム・検索は本文がスクロールするので sticky で留める。 */
.room-tabs { display: flex; gap: 2px; padding: 6px 10px; flex: none;
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
.room-tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px;
  border-radius: 10px; text-decoration: none; color: var(--text-dim);
  font-size: 13px; font-weight: 600; white-space: nowrap; }
.room-tab svg { width: 17px; height: 17px; }
.room-tab.on { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); }
.room-tab:hover { background: var(--surface-2); }

/* ---------- メモ ---------- */
.note-body { font-size: 15px; line-height: 1.9; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.note-edit { font-family: inherit; line-height: 1.8; resize: vertical; min-height: 220px; }

/* ---------- アルバム ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; padding: 16px; }
.album-card { border: 0; padding: 0; background: none; cursor: pointer; text-align: left; }
.album-card img, .album-blank { width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 14px; background: var(--surface-2); display: block; }
.album-blank { display: grid; place-items: center; font-size: 34px; }
.album-name { margin-top: 6px; font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-n { font-size: 11.5px; color: var(--text-dim); }

.album-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); }
.album-title { flex: 1; font-weight: 700; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 4px; padding: 4px; }
.photo { position: relative; margin: 0; }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  border-radius: 6px; cursor: zoom-in; background: var(--surface-2); }
.photo-del { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-size: 12px; cursor: pointer; opacity: 0; transition: opacity .12s; }
.photo:hover .photo-del { opacity: 1; }
@media (hover: none) { .photo-del { opacity: .8; } }

/* ---------- 検索 ---------- */
/* 検索は「上を固定して、結果だけスクロール」にする。
   sticky の top をピクセルで当てると、タブの高さが変わったときにずれる。
   トークと同じく flex で組めば、数字を決め打ちしなくて済む。 */
body.fixed-top .app-main { display: flex; flex-direction: column; overflow: hidden; }
body.fixed-top .app-main > .room-tabs,
body.fixed-top .app-main > .search-bar { flex: none; position: static; }
body.fixed-top #results { flex: 1; min-height: 0; overflow-y: auto; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.search-bar svg { color: var(--text-dim); }
.search-bar input { flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-size: 16px; color: var(--text); }
mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit;
  border-radius: 3px; padding: 0 2px; }
.list .who b { white-space: normal; }

/* ---------- QRコード ---------- */
.qr-box { display: grid; place-items: center; gap: 14px; padding: 20px 0; }
.qr-box svg { width: min(260px, 70vw); height: auto; background: #fff;
  padding: 12px; border-radius: 14px; box-shadow: var(--shadow); }
.qr-name { font-weight: 700; font-size: 17px; }
#qrVideo { width: 100%; max-width: 420px; border-radius: 14px; background: #000; display: block; }
.qr-scan-hint { text-align: center; font-size: 13px; color: var(--text-dim); margin-top: 10px; }

/* ---------- 通話：画面共有 ---------- */
.call-stage { width: 100%; max-width: 900px; margin-bottom: 18px; display: none; }
.call-stage.on { display: block; }
.call-stage video { width: 100%; max-height: 56vh; border-radius: 14px; background: #000; object-fit: contain; }
.call-stage .who { text-align: center; font-size: 12.5px; color: #9aa4ae; margin-top: 6px; }

/* ---------- アイコン変更 ---------- */
.me-row { display: flex; align-items: center; gap: 14px; }
.avatar.lg { width: 64px; height: 64px; font-size: 25px; }
.icon-edit { position: relative; border: 0; background: none; padding: 0; cursor: pointer; flex: none; }
.icon-edit-badge { position: absolute; right: -2px; bottom: -2px; width: 26px; height: 26px;
  display: grid; place-items: center; border-radius: 50%; background: var(--accent);
  color: var(--accent-ink); border: 2px solid var(--surface); }
.icon-edit-badge svg { width: 14px; height: 14px; }
.me-btn { display: block; border: 0; background: none; padding: 0; text-decoration: none; }

/* ============================================================
   トーク一覧の横スワイプ（LINE と同じ考え方）
   行を左へ引くと、後ろから 固定／通知オフ／削除 が出る。
   ボタンは行の【後ろ】に置き、手前の .sw-face だけを動かす。
   ============================================================ */
.sw-row { position: relative; overflow: hidden; }
.sw-face { position: relative; z-index: 2; background: var(--surface); will-change: transform; }
.sw-acts { position: absolute; inset: 0 0 0 auto; z-index: 1; display: flex; }
.sw-btn {
  width: 72px; border: 0; cursor: pointer; color: #fff;
  font-size: 12px; font-weight: 700; line-height: 1.35; text-align: center;
}
.sw-btn.pin  { background: #6b7580; }
.sw-btn.mute { background: #b8860b; }
.sw-btn.del  { background: var(--danger); }
@media (prefers-color-scheme: dark) { .sw-btn.mute { background: #a07a10; } }

/* 一覧に出す印 */
.pin-mark { font-size: 12px; flex: none; }
.mute-mark { display: inline-flex; flex: none; color: var(--text-dim); }
.mute-mark svg { width: 14px; height: 14px; }

/* マウスの端末用の「…」。スワイプできない環境でも同じ操作ができるように */
.row-more { display: none; flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: none; color: var(--text-dim); cursor: pointer; }
.row-more svg { width: 18px; height: 18px; }
.row-more:hover { background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) {
  .room-item:hover .row-more, .side-item:hover .row-more { display: grid; place-items: center; }
}
