/* チャット — デザイン言語 v3
   8pxグリッド / 3段タイポ（見出し・本文・補助）/ 角丸 12・16 / 浅い影とボーダーの使い分け / アクセント1色（上品なオレンジ）
   外部フォント不使用（中国から遮断されるため）: システムフォントの太さと字間で品を出す。 */

/* ================================================================ トークン */
:root,
[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-sidebar: #f7f8fa;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-hover: #f1f3f6;
  --bg-active: #e8ebf0;
  --border: #e6e8ec;
  --border-strong: #d6dae1;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #64748b;
  --accent: #c2410c;          /* 白文字 5.18:1 */
  --accent-hover: #9a3412;
  --accent-2: #ea580c;        /* 装飾用（グラデーション・細線） */
  --accent-text: #ffffff;
  --accent-subtle: rgba(234, 88, 12, 0.07);
  --accent-soft: rgba(234, 88, 12, 0.12);
  --accent-glow: rgba(234, 88, 12, 0.22);
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.10);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.08);
  --amber: #b45309;
  --amber-bg: rgba(217, 119, 6, 0.10);
  --blue: #2563eb;
  --tome-bg: rgba(234, 88, 12, 0.05);
  --flash: rgba(234, 88, 12, 0.18);
  --sk: #eceef2;
  --sk-hi: #f6f7f9;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, 0.10), 0 2px 4px -2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, 0.18), 0 4px 12px -4px rgba(16, 24, 40, 0.08);
  --scrim: rgba(17, 24, 39, 0.40);
  --date-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-sidebar: #0d121c;
  --bg-surface: #111827;
  --bg-elevated: #161e2e;
  --bg-subtle: #0f1522;
  --bg-hover: #1a2335;
  --bg-active: #222c41;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #e6e9ef;
  --text-secondary: #a8b1c2;
  --text-muted: #8b95a7;       /* #111827 上で 5.9:1 */
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --accent-2: #f97316;
  --accent-text: #1a0e05;      /* オレンジ上で 8.4:1 */
  --accent-subtle: rgba(251, 146, 60, 0.09);
  --accent-soft: rgba(251, 146, 60, 0.15);
  --accent-glow: rgba(251, 146, 60, 0.26);
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.12);
  --blue: #7cb1ff;
  --tome-bg: rgba(251, 146, 60, 0.06);
  --flash: rgba(251, 146, 60, 0.20);
  --sk: #1a2233;
  --sk-hi: #222c40;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.55), 0 2px 6px -2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.65), 0 6px 16px -6px rgba(0, 0, 0, 0.45);
  --scrim: rgba(3, 6, 12, 0.62);
  --date-scheme: dark;
}

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "PingFang SC", "Microsoft YaHei", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, Menlo, monospace;
  /* タイポ 3段 */
  --fs-title: 15px;
  --fs-body: 14px;
  --fs-meta: 12px;
  --tracking-title: -0.012em;
  --tracking-meta: 0.01em;
  /* 余白 8pxグリッド */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* 角丸 */
  --r-xs: 6px; --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --left-w: 296px;
  --right-w: 336px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* ================================================================ 基本 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  font-feature-settings: "palt" 0;
  overflow: hidden;
  color-scheme: var(--date-scheme);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
[hidden] { display: none !important; }
::selection { background: var(--accent-glow); }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-meta); }
.center { text-align: center; }
.pad { padding: var(--s4); }
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); }
*::-webkit-scrollbar-track { background: transparent; }

/* ================================================================ 部品 */
.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.logo {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 10px; color: #fff;
  background: linear-gradient(140deg, #fb923c 0%, #ea580c 55%, #c2410c 100%);
  box-shadow: 0 1px 2px rgba(194, 65, 12, .35), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.logo svg { width: 70%; height: 70%; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: var(--bg-hover); color: var(--text);
  font-weight: 600; font-size: 13.5px; letter-spacing: .005em; white-space: nowrap;
  transition: background .14s var(--ease), border-color .14s var(--ease), box-shadow .14s var(--ease), transform .08s;
}
.btn .ic { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { background: var(--bg-active); }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); font-weight: 700; box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: var(--bg-surface); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-hover); }
.btn.danger { background: #dc2626; color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--red); border-color: var(--border); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--red-bg); border-color: transparent; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--r-xs); }
.btn.lg { height: 44px; font-size: 15px; border-radius: var(--r); }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--text-secondary);
  transition: background .14s var(--ease), color .14s var(--ease); text-decoration: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }

.input {
  width: 100%; min-height: 38px; padding: 8px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text);
  outline: none; transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.input::placeholder { color: var(--text-muted); }
textarea.input { resize: vertical; line-height: 1.55; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: auto; padding-right: 8px; }
.lbl { display: block; font-size: var(--fs-meta); font-weight: 600; letter-spacing: var(--tracking-meta); color: var(--text-secondary); margin: var(--s4) 0 6px; }
.form .lbl:first-child { margin-top: 0; }
.form.narrow { max-width: 400px; }
.form-error { margin-top: var(--s3); color: var(--red); font-size: 13px; }
.inline { display: flex; gap: var(--s2); align-items: center; }
.inline .input { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin: var(--s3) 0; }
.btn-row.center { justify-content: center; }

.switch {
  appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--bg-active);
  position: relative; cursor: pointer; transition: background .16s var(--ease); flex: none; margin: 0; box-shadow: inset 0 0 0 1px var(--border);
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .16s var(--ease); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch:checked { background: var(--accent); box-shadow: none; }
.switch:checked::after { transform: translateX(16px); }

/* アバター（画像があれば画像・無ければイニシャル） */
.avatar {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; overflow: hidden;
  width: 36px; height: 36px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 14px;
  user-select: none; line-height: 1; letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--bg-hover); }
.avatar.has-img .av-ch { visibility: hidden; }
.avatar.group { border-radius: 10px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.sm.group { border-radius: 8px; }
.avatar.xs { width: 22px; height: 22px; font-size: 10.5px; }
.avatar.lg { width: 52px; height: 52px; font-size: 20px; }
.avatar.xl { width: 72px; height: 72px; font-size: 28px; }
.avatar.xxl { width: 96px; height: 96px; font-size: 36px; }
.avatar.all { background: var(--accent) !important; color: var(--accent-text); }
.has-profile { cursor: pointer; }
.av-wrap { position: relative; display: inline-flex; flex: none; }
.av-wrap .dot { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--bg-sidebar); width: 11px; height: 11px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); opacity: .45; flex: none; }
.dot.on { background: #22c55e; opacity: 1; }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 1px 6px; border-radius: 5px; background: var(--bg-active); color: var(--text-secondary); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-pill); background: var(--bg-active); color: var(--text-secondary); white-space: nowrap; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.bad { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-text);
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; font-variant-numeric: tabular-nums;
}
.badge.sm { min-width: 18px; height: 18px; font-size: 10.5px; }
.badge.muted { background: var(--bg-active); color: var(--text-secondary); }
.badge.to { background: #dc2626; color: #fff; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { display: flex; gap: var(--s2); align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bg-hover); color: var(--text-secondary); font-size: 13px; margin: var(--s2) 0; }
.hint.warn { background: var(--amber-bg); color: var(--amber); }
.empty-note { padding: var(--s5) var(--s4); text-align: center; color: var(--text-muted); font-size: 13px; }
.empty-note.big { padding: 48px var(--s4); }

/* スケルトン（骨組み） */
.sk { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--sk) 0%, var(--sk-hi) 45%, var(--sk) 90%); background-size: 240% 100%; animation: sk 1.3s ease-in-out infinite; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -40% 0; } }
.sk-room { display: flex; gap: var(--s3); align-items: center; padding: 10px 12px; }
.sk-msg { display: flex; gap: var(--s3); padding: 12px 24px; }
.sk-av { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 3px; }
.sk-name { height: 10px; width: 22%; }
.sk-l1 { height: 10px; width: 70%; }
.sk-l2 { height: 10px; width: 45%; }

/* ================================================================ レイアウト */
.app {
  display: grid; grid-template-columns: var(--left-w) minmax(0, 1fr);
  height: 100vh; height: var(--app-h, 100dvh);
}
body.right-open .app { grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); }
.pane-left { grid-column: 1; display: flex; flex-direction: column; min-height: 0; background: var(--bg-sidebar); border-right: 1px solid var(--border); }
.pane-center { grid-column: 2; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg-surface); position: relative; }
.pane-right { grid-column: 3; display: none; flex-direction: column; min-height: 0; background: var(--bg-sidebar); border-left: 1px solid var(--border); }
body.right-open .pane-right { display: flex; }
.page { grid-column: 2 / -1; grid-row: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
body.page-open .pane-center, body.page-open .pane-right { display: none !important; }
.only-mobile { display: none !important; }
.only-touch { display: none !important; }
@media (hover: none) and (pointer: coarse) { .only-touch { display: inline-flex !important; } }

/* ================================================================ 左ペイン */
.left-head { display: flex; align-items: center; gap: var(--s1); padding: 14px 10px 10px 16px; padding-top: calc(14px + var(--safe-t)); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-btn { border: 0; background: transparent; padding: 3px; border-radius: 50%; display: inline-flex; margin-left: 2px; }
.me-btn:hover { background: var(--bg-hover); }
.left-search { padding: 2px 12px 10px; }
.search-input { min-height: 36px; background: var(--bg-surface); border-color: var(--border); box-shadow: var(--shadow-xs); padding-left: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b95a7' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px 50%; background-size: 15px; }
.left-tabs { display: flex; gap: 2px; padding: 0 12px 6px; overflow-x: auto; flex: none; scrollbar-width: none; }
.left-tabs::-webkit-scrollbar { display: none; }
.left-tabs.fade { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.tab {
  border: 0; background: transparent; color: var(--text-secondary); font-size: 12.5px; font-weight: 600;
  padding: 5px 9px; border-radius: var(--r-pill); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.on { background: var(--bg-surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.tab-n { font-size: 10.5px; background: var(--bg-active); color: var(--text-secondary); border-radius: 9px; padding: 0 6px; min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.tab.on .tab-n { background: var(--accent); color: var(--accent-text); }
.tab.alert .tab-n { background: #dc2626; color: #fff; }
.room-list { flex: 1; overflow-y: auto; padding: 2px 8px 12px; overscroll-behavior: contain; }
.sec-head {
  display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: transparent; color: var(--text-muted);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 12px 8px 6px; border-radius: var(--r-xs);
}
.sec-head:hover { color: var(--text); }
.sec-chev { width: 14px; height: 14px; transition: transform .16s var(--ease); }
.sec-head.collapsed .sec-chev { transform: rotate(-90deg); }
.sec-label { flex: 0 1 auto; }
.sec-n { font-weight: 600; color: var(--text-muted); opacity: .8; }
.sec-head .badge { margin-left: auto; }
.room-item {
  position: relative; display: flex; gap: var(--s3); align-items: center; padding: 8px 10px; margin: 1px 0; border-radius: 10px;
  text-decoration: none; color: var(--text); outline-offset: -2px; transition: background .14s var(--ease);
}
.room-item:hover { background: var(--bg-hover); }
.room-item.active { background: var(--bg-surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.room-item.active::before { content: ""; position: absolute; left: -8px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.ri-main { flex: 1; min-width: 0; }
.ri-top, .ri-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ri-top { margin-bottom: 1px; }
.ri-name { font-weight: 600; font-size: 14px; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.has-unread .ri-name { font-weight: 750; }
.ri-flag { width: 13px; height: 13px; color: var(--text-muted); }
.ri-time { margin-left: auto; font-size: 11.5px; color: var(--text-muted); flex: none; font-variant-numeric: tabular-nums; }
.has-unread .ri-time { color: var(--accent); font-weight: 700; }
.ri-prev { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.has-unread .ri-prev { color: var(--text-secondary); font-weight: 500; }
.typing-inline { color: var(--accent) !important; font-style: italic; }
.left-foot { display: flex; gap: var(--s2); padding: 10px 12px; padding-bottom: calc(10px + var(--safe-b)); border-top: 1px solid var(--border); }
.left-foot .btn { flex: 1; }

/* 初回の案内カード */
.onboard { margin: 0 12px 10px; padding: 12px; border-radius: var(--r); background: var(--bg-surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); flex: none; }
.ob-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.ob-head > .ic { width: 16px; height: 16px; color: var(--accent); }
.ob-count { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ob-bar { height: 4px; border-radius: 4px; background: var(--bg-active); margin: 8px 0 6px; overflow: hidden; }
.ob-bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s var(--ease); }
.ob-step { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 6px 4px; border-radius: var(--r-sm); font-size: 13px; text-align: left; color: var(--text); }
.ob-step:hover:not(:disabled) { background: var(--bg-hover); }
.ob-step:disabled { cursor: default; }
.ob-num { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text-secondary); flex: none; }
.ob-step.done .ob-num { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ob-step.done .ob-num .ic { width: 13px; height: 13px; }
.ob-step.done .ob-label { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }

/* ================================================================ 中央ペイン */
.room-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.conn-banner {
  display: flex; align-items: center; gap: var(--s2); justify-content: center; padding: 6px 12px;
  background: var(--amber-bg); color: var(--amber); font-size: 12.5px; font-weight: 600; flex: none;
}
.conn-banner .ic { width: 15px; height: 15px; }
.room-head {
  display: flex; align-items: center; gap: var(--s3); padding: 10px 12px 10px 20px; min-height: 60px;
  border-bottom: 1px solid var(--border); background: var(--bg-surface); flex: none;
}
.head-title { min-width: 0; }
.head-title .name { font-weight: 700; font-size: 15.5px; letter-spacing: var(--tracking-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-title .sub { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-meta); color: var(--text-muted); border: 0; background: none; padding: 0; max-width: 100%; min-width: 0; }
.head-title .sub .ic { width: 13px; height: 13px; }
.sub-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.link-like:hover { color: var(--accent); }
.chip-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-secondary); border-radius: var(--r-pill); padding: 3px 10px; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-xs); }
.chip-btn .ic { width: 14px; height: 14px; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }

.msg-wrap { flex: 1; min-height: 0; position: relative; }
.msgs { position: absolute; inset: 0; overflow-y: auto; padding: 8px 0 16px; overscroll-behavior: contain; outline: none; }
.msgs-top, .msgs-bottom { text-align: center; font-size: var(--fs-meta); color: var(--text-muted); padding: 14px; }
.msgs-top.end { opacity: .75; }
.day-sep { position: sticky; top: 6px; z-index: 1; display: flex; justify-content: center; margin: 14px 0 8px; pointer-events: none; }
.day-sep span {
  pointer-events: auto; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); letter-spacing: var(--tracking-meta);
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 3px 12px; box-shadow: var(--shadow-xs);
}
.unread-line { display: flex; align-items: center; gap: 10px; margin: 10px 20px; font-size: 11.5px; font-weight: 700; color: var(--red); letter-spacing: var(--tracking-meta); }
.unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: var(--red); opacity: .45; }
.room-empty { text-align: center; padding: 56px 24px; color: var(--text-muted); }
.room-empty-mark { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 12px; }
.room-empty-t { font-weight: 700; color: var(--text); font-size: var(--fs-title); margin-bottom: 4px; }

.msg { position: relative; display: flex; gap: var(--s3); padding: 6px 24px 6px 20px; border-left: 3px solid transparent; transition: background .12s var(--ease); }
.msg.compact { padding-top: 1px; padding-bottom: 2px; }
.msg:hover { background: var(--bg-subtle); }
.msg.to-me { background: var(--tome-bg); border-left-color: var(--accent-2); }
.msg.flash { animation: flash 2.4s ease-out; }
.msg.enter { animation: enter .12s var(--ease); }
@keyframes flash { 0%, 30% { background: var(--flash); } 100% { background: transparent; } }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }
.msg-gutter { width: 36px; flex: none; display: flex; justify-content: center; }
.side-time { font-size: 10.5px; color: var(--text-muted); opacity: 0; padding-top: 4px; font-variant-numeric: tabular-nums; }
.msg.compact:hover .side-time { opacity: 1; }
.msg-main { flex: 1; min-width: 0; position: relative; max-width: 880px; }
.msg-head { display: flex; align-items: baseline; gap: var(--s2); margin-bottom: 1px; }
.msg-name { font-weight: 700; font-size: 14px; letter-spacing: -0.005em; border-radius: 4px; }
.msg-name:hover { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.msg-time { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pin-flag { position: absolute; right: 0; top: 2px; color: var(--accent); }
.pin-flag .ic { width: 14px; height: 14px; }
.msg-text { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.65; color: var(--text); }
.msg-text .p { white-space: pre-wrap; }
.msg-text blockquote.q {
  margin: 4px 0; padding: 4px 12px; border-left: 3px solid var(--border-strong); color: var(--text-secondary);
  background: var(--bg-subtle); border-radius: 0 var(--r-sm) var(--r-sm) 0; white-space: pre-wrap;
}
.msg-text .link { color: var(--blue); text-decoration: none; word-break: break-all; }
.msg-text .link:hover { text-decoration: underline; }
.edited { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.msg-deleted { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-style: italic; font-size: 13px; }
.msg-deleted .ic { width: 14px; height: 14px; }
.to-chip {
  display: inline-block; padding: 0 7px; margin: 0 2px; border-radius: 6px; font-size: 12.5px; font-weight: 700; line-height: 1.65;
  background: var(--bg-active); color: var(--text-secondary); white-space: nowrap; vertical-align: 1px;
}
.to-chip.me, .to-chip.all { background: var(--accent); color: var(--accent-text); }
.reply-ref {
  display: flex; align-items: center; gap: 6px; max-width: 100%; margin: 2px 0 4px; padding: 5px 10px; border: 0;
  border-left: 2px solid var(--accent-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--bg-subtle); color: var(--text-secondary);
  font-size: 12.5px; text-align: left;
}
.reply-ref .ic { width: 14px; height: 14px; color: var(--accent); }
.reply-name { font-weight: 700; flex: none; }
.reply-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.reply-ref:hover { color: var(--text); background: var(--bg-hover); }

/* 添付: 画像グリッド（2〜4枚はタイル）・ファイルは種類別の色付きカード */
.atts { display: flex; flex-direction: column; gap: var(--s2); margin-top: 6px; }
.att-imgs { display: grid; gap: 4px; max-width: 420px; border-radius: var(--r); overflow: hidden; }
.att-imgs.one { display: flex; max-width: none; border-radius: 0; overflow: visible; }
.att-imgs.two { grid-template-columns: 1fr 1fr; }
.att-imgs.three { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.att-imgs.three .big { grid-row: span 2; }
.att-imgs.four { grid-template-columns: 1fr 1fr; }
.att-imgs.many { grid-template-columns: repeat(3, 1fr); }
.att-img { padding: 0; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--bg-hover); line-height: 0; max-width: 100%; transition: filter .14s, box-shadow .14s; }
.att-img:hover { filter: brightness(1.03); box-shadow: var(--shadow-md); }
.att-img img { display: block; object-fit: cover; max-width: 100%; height: auto; }
.att-img.unknown img { object-fit: contain; }
.att-img.tile { border: 0; border-radius: 0; aspect-ratio: 1 / 1; min-height: 100px; }
.att-img.tile img { width: 100%; height: 100%; }
.att-imgs.three .att-img.tile { aspect-ratio: auto; }
.att-file {
  display: flex; align-items: center; gap: var(--s3); padding: 10px 10px 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-surface); max-width: 400px; flex-wrap: wrap; box-shadow: var(--shadow-xs); transition: box-shadow .14s, border-color .14s;
}
.att-file:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.file-ext {
  position: relative; width: 40px; height: 44px; border-radius: 9px; background: #64748b; color: #fff; flex: none;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.file-glyph { width: 16px; height: 16px; opacity: .9; }
.file-ext-t { font-size: 9.5px; font-weight: 800; letter-spacing: .04em; line-height: 1; }
.file-ext.x-excel { background: #16a34a; }
.file-ext.x-word { background: #2563eb; }
.file-ext.x-pdf { background: #dc2626; }
.file-ext.x-zip { background: #a16207; }
.file-ext.x-ppt { background: #ea580c; }
.file-ext.x-image { background: #7c3aed; }
.file-ext.x-text { background: #475569; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: var(--fs-meta); color: var(--text-muted); }
.file-by { width: 100%; }

.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.react {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--bg-subtle); font-size: 12.5px; color: var(--text-secondary);
  transition: border-color .12s, background .12s;
}
.react:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.react.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.react.just { animation: pop .15s var(--ease); }
@keyframes pop { 0% { transform: scale(.8); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
.react-e { font-size: 15px; line-height: 1; }
.react-n { font-variant-numeric: tabular-nums; }
.react.add { opacity: 0; padding: 0 7px; }
.react.add .ic { width: 15px; height: 15px; }
.msg:hover .react.add { opacity: 1; }
.receipt { position: absolute; right: 20px; bottom: 5px; display: flex; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.receipt:empty { display: none; }
.msg.has-receipt { padding-right: 88px; }
.receipt .ic { width: 13px; height: 13px; color: var(--green); }
.receipt-dm { display: inline-flex; align-items: center; gap: 3px; }
.receipt-btn { display: inline-flex; align-items: center; gap: 3px; border: 0; background: none; color: var(--text-muted); font-size: 11.5px; padding: 0 3px; border-radius: 5px; }
.receipt-btn:hover { color: var(--accent); background: var(--bg-hover); }

/* ホバーで右上に出る小さなアクションバー */
.msg-tools {
  position: absolute; right: 18px; top: -16px; display: none; gap: 1px; padding: 3px; z-index: 2;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md);
}
.msg:hover .msg-tools, .msg:focus-within .msg-tools { display: flex; animation: fade .1s var(--ease); }
.msg-tools .icon-btn { width: 30px; height: 30px; border-radius: 7px; }
.msg-tools .icon-btn .ic { width: 16px; height: 16px; }
.tool-emoji { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 7px; font-size: 15px; line-height: 1; }
.tool-emoji:hover { background: var(--bg-hover); }

.editor { margin-top: 4px; }
.edit-input { font-size: 14px; }
.editor-bar { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.jump-btn {
  position: absolute; right: 20px; bottom: 16px; display: inline-flex; align-items: center; gap: 6px; z-index: 3;
  height: 38px; min-width: 38px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-lg); font-size: 12.5px; font-weight: 700;
  animation: fade .14s var(--ease);
}
.jump-btn .ic { width: 16px; height: 16px; }
.jump-btn.has-new { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.jump-label:empty { display: none; }
.typing { min-height: 20px; padding: 0 24px; font-size: var(--fs-meta); color: var(--text-muted); font-style: italic; flex: none; transition: opacity .15s; opacity: 0; }
.typing.on { opacity: 1; }

/* 部屋未選択の空画面 */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); padding: var(--s5); }
.empty-state h2 { color: var(--text); font-size: 20px; font-weight: 750; letter-spacing: -0.02em; margin: 20px 0 6px; }
.empty-state p { margin: 0 0 8px; font-size: 13.5px; max-width: 360px; }
.empty-art { width: 240px; max-width: 70vw; }
.empty-art svg { width: 100%; height: auto; display: block; }
.empty-art .ea-floor { fill: var(--bg-hover); }
.empty-art .ea-card { fill: var(--bg-surface); stroke: var(--border-strong); stroke-width: 1.5; }
.empty-art .ea-line { fill: var(--bg-active); }
.empty-art .ea-line2 { fill: var(--bg-hover); }
.empty-art .ea-accent { fill: var(--accent-2); }
.empty-art .ea-dot { fill: #fff; }
.empty-art .ea-spark, .empty-art .ea-spark2 { fill: var(--accent-soft); }
.empty-art .ea-sparkline { stroke: var(--accent-2); stroke-width: 2; stroke-linecap: round; opacity: .6; }

/* ================================================================ 入力欄（浮いたカード） */
.composer { padding: 0 20px 16px; padding-bottom: calc(16px + var(--safe-b)); flex: none; background: var(--bg-surface); }
.cmp-box {
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--bg-surface);
  box-shadow: var(--shadow-md); transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.cmp-box:focus-within, .cmp-box.focus { border-color: var(--accent); box-shadow: var(--shadow-md), 0 0 0 3px var(--accent-soft); }
.cmp-field { position: relative; }
.cmp-input, .cmp-mirror {
  font-size: 14.5px; line-height: 1.55; padding: 12px 14px 4px; letter-spacing: normal;
  overflow-wrap: break-word; word-break: normal; white-space: pre-wrap; font-family: inherit;
}
.cmp-input {
  position: relative; z-index: 1; display: block; width: 100%; border: 0; outline: none; resize: none; background: transparent; color: var(--text);
  min-height: 46px; max-height: 40vh;
}
.cmp-input::placeholder { color: var(--text-muted); }
.cmp-input:disabled { opacity: .5; }
/* TOの「@名前」の背景だけを裏に敷く（文字は入力欄そのもの＝位置ずれ・名前切れが起きない） */
.cmp-mirror { position: absolute; left: 0; top: 0; display: none; overflow: hidden; pointer-events: none; color: transparent; box-sizing: border-box; }
.cmp-field.has-tok .cmp-mirror { display: block; }
.tok { color: transparent; background: var(--accent-soft); border-radius: 5px; box-shadow: 0 0 0 2px var(--accent-soft); }
.cmp-bar { display: flex; align-items: center; gap: 6px; padding: 4px 8px 8px; }
.cmp-tools { display: flex; gap: 2px; }
.cmp-tools .icon-btn { color: var(--text-muted); }
.cmp-tools .icon-btn:hover { color: var(--text); }
.cmp-hint { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.send-btn { height: 34px; padding: 0 14px; border-radius: 10px; background: var(--bg-hover); color: var(--text-secondary); box-shadow: none; }
.send-btn.ready { background: var(--accent); color: var(--accent-text); box-shadow: var(--shadow-xs); }
.send-btn.ready:hover { background: var(--accent-hover); }
.cmp-reply, .cmp-archived, .cmp-outbox {
  display: flex; align-items: center; gap: var(--s2); padding: 7px 10px; margin-bottom: var(--s2); border-radius: var(--r-sm); font-size: 12.5px;
}
.cmp-reply { background: var(--bg-subtle); border: 1px solid var(--border); }
.cmp-archived { color: var(--amber); background: var(--amber-bg); }
.cmp-outbox { background: var(--amber-bg); color: var(--amber); font-weight: 600; flex-wrap: wrap; }
.cmp-outbox .ic { width: 15px; height: 15px; }
.cr-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.cr-main .ic { width: 15px; height: 15px; color: var(--accent); }
.cr-label { color: var(--text-muted); flex: none; }
.cr-body { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cmp-files { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 2px var(--s2); }
.cf {
  display: flex; align-items: center; gap: var(--s2); padding: 6px 4px 6px 6px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-surface); min-width: 200px; max-width: 260px; flex: none; position: relative; box-shadow: var(--shadow-xs);
}
.cf.error { border-color: var(--red); }
.cf-thumb { width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: cover; flex: none; background: var(--bg-hover); display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); }
.cf-meta { flex: 1; min-width: 0; }
.cf-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-sub { font-size: 11.5px; color: var(--text-muted); }
.cf-err { color: var(--red); }
.cf-bar { display: block; height: 3px; border-radius: 2px; background: var(--bg-active); margin-top: 4px; overflow: hidden; }
.cf-fill { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.drop-overlay { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: flex; align-items: center; justify-content: center; pointer-events: none; animation: fade .12s; }
.drop-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 36px 48px; border: 2px dashed var(--accent); border-radius: var(--r-lg); background: var(--bg-surface); color: var(--accent); font-weight: 700; font-size: 16px; box-shadow: var(--shadow-lg); }
.drop-box .ic { width: 36px; height: 36px; }

/* ================================================================ 右ペイン */
.right-head { display: flex; align-items: center; gap: 4px; padding: 12px 8px 8px 12px; padding-top: calc(12px + var(--safe-t)); border-bottom: 1px solid var(--border); flex: none; min-height: 60px; }
.right-tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.right-tabs .tab { padding: 5px 9px; font-size: 12.5px; }
.right-body { flex: 1; overflow-y: auto; padding: 4px 0 24px; }
.r-sec { padding: var(--s4); border-bottom: 1px solid var(--border); }
.r-sec:last-child { border-bottom: 0; }
.r-profile { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }
.r-title { font-weight: 700; font-size: var(--fs-title); letter-spacing: var(--tracking-title); word-break: break-word; }
.r-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin: var(--s2) 0 6px; }
.r-desc { white-space: pre-wrap; word-break: break-word; font-size: 13px; color: var(--text-secondary); }
.r-status { margin-top: 6px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--bg-surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); word-break: break-word; }
.r-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; }
.r-row select { width: auto; min-width: 140px; }
.r-row .ic { color: var(--text-muted); }
.member { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: var(--r-sm); }
.member:hover { background: var(--bg-hover); }
.member .av-wrap .dot { border-color: var(--bg-sidebar); }
.member-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-main { min-width: 0; }
.r-sec > .btn.block { margin-bottom: var(--s2); }
.pin-item { display: flex; gap: 4px; align-items: flex-start; padding: 4px 0; border-bottom: 1px solid var(--border); }
.pin-item:last-child { border-bottom: 0; }
.pin-main { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: var(--r-sm); }
.pin-main:hover { background: var(--bg-hover); }
.pin-author { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 12.5px; }
.pin-author .ic { width: 13px; height: 13px; color: var(--accent); }
.pin-body { font-size: 13px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.r-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: var(--s3); }
.r-thumb { padding: 0; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; aspect-ratio: 1; background: var(--bg-hover); }
.r-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.right-body .att-file { margin-bottom: var(--s2); max-width: none; }

/* ================================================================ モーダル */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: var(--s4);
  animation: fade .14s var(--ease); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 480px; max-height: calc(100% - 32px); display: flex; flex-direction: column;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: modalIn .16s var(--ease);
}
@keyframes modalIn { from { transform: translateY(6px) scale(.97); opacity: 0; } }
.modal:focus { outline: none; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; gap: var(--s2); padding: 16px 12px 8px 20px; }
.modal-title { margin: 0; font-size: 16px; font-weight: 750; letter-spacing: var(--tracking-title); flex: 1; min-width: 0; word-break: break-word; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: var(--s2); padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.confirm-text { margin: 4px 0 8px; white-space: pre-wrap; color: var(--text-secondary); }
.lightbox { max-width: min(1100px, 96vw); }
.lb-body { position: relative; display: flex; align-items: center; justify-content: center; background: var(--bg-subtle); border-radius: var(--r); min-height: 200px; touch-action: pan-y; }
.lb-img { max-width: 100%; max-height: 72vh; object-fit: contain; cursor: zoom-out; border-radius: var(--r-sm); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); opacity: .92;
}
.lb-nav:hover { opacity: 1; color: var(--accent); }
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
.lb-count { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.pick-list { max-height: 46vh; overflow-y: auto; margin-top: var(--s2); border: 1px solid var(--border); border-radius: var(--r); background: var(--bg-surface); }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .1s; }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--bg-hover); }
.pick-row.on { background: var(--accent-subtle); }
.pick-main { display: flex; flex-direction: column; min-width: 0; }
.pick-name { font-weight: 600; }
.pick-status { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub { color: var(--text-muted); font-size: var(--fs-meta); margin-left: auto; flex: none; }
.sched .presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s2); }
.sched-preview { padding: 8px 12px; border-radius: var(--r-sm); background: var(--bg-subtle); border: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); white-space: pre-wrap; word-break: break-word; max-height: 90px; overflow: hidden; }
.sub-h { display: flex; align-items: center; gap: var(--s2); font-size: 13px; font-weight: 750; margin: var(--s4) 0 var(--s2); }
.sched-list { display: flex; flex-direction: column; gap: 6px; }
.sched-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; background: var(--bg-surface); }
.sched-at { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.sched-room { flex: none; font-weight: 600; text-decoration: none; }
.sched-body { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.search-modal .modal-body { min-height: 300px; }
.search .check { margin: 10px 0 4px; }
.search-results { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s2); }
.sr-item { text-align: left; border: 1px solid var(--border); background: var(--bg-surface); border-radius: var(--r); padding: 10px 14px; transition: border-color .12s, box-shadow .12s; }
.sr-item:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.sr-head { display: flex; gap: var(--s2); align-items: baseline; font-size: 12.5px; }
.sr-room { font-weight: 750; color: var(--accent); }
.sr-name { font-weight: 600; }
.sr-body { font-size: 13px; color: var(--text-secondary); word-break: break-word; margin-top: 2px; }
.sr-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sr-file { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; padding: 2px 8px; border-radius: var(--r-xs); background: var(--bg-hover); }
.sr-file .ic { width: 14px; height: 14px; color: var(--text-muted); }
.sr-file mark, .sr-body mark { background: var(--accent-glow); color: var(--text); border-radius: 3px; padding: 0 1px; }

/* スマホの下シート */
.sheet .modal-body { padding: 4px 12px 12px; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 6px auto 12px; }
.sheet-preview { font-size: 12.5px; color: var(--text-secondary); padding: 0 6px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-quick { display: flex; justify-content: space-between; gap: 6px; padding: 4px 4px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.sheet-emoji { flex: 1; height: 50px; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg-surface); font-size: 24px; display: inline-flex; align-items: center; justify-content: center; }
.sheet-emoji.on { border-color: var(--accent); background: var(--accent-soft); }
.sheet-emoji.more .ic { width: 22px; height: 22px; color: var(--text-secondary); }
.sheet-list { display: flex; flex-direction: column; }
.sheet-item { display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 0 12px; border: 0; background: transparent; border-radius: var(--r); font-size: 15.5px; text-align: left; color: var(--text); }
.sheet-item .ic { width: 20px; height: 20px; color: var(--text-secondary); }
.sheet-item:active { background: var(--bg-hover); }
.sheet-item.danger, .sheet-item.danger .ic { color: var(--red); }
.msg.swipe-ready { background: var(--accent-subtle); }

/* ================================================================ ポップオーバー */
.popover {
  position: fixed; z-index: 70; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow-lg); overflow: auto; max-width: calc(100vw - 16px); animation: popIn .12s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(3px) scale(.98); } }
.menu { display: flex; flex-direction: column; padding: 6px; min-width: 216px; }
.menu-item { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 8px 10px; border-radius: var(--r-sm); text-align: left; font-size: 13.5px; color: var(--text); }
.menu-item .ic { width: 16px; height: 16px; color: var(--text-secondary); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--bg-hover); outline: none; }
.menu-item:disabled { opacity: .75; cursor: default; }
.menu-item.danger, .menu-item.danger .ic { color: var(--red); }
.menu-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-hint { font-size: 11px; color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.pop-title { font-size: 11px; font-weight: 750; color: var(--text-muted); padding: 10px 12px 4px; text-transform: uppercase; letter-spacing: .06em; }
.pop-note { font-size: 11px; color: var(--text-muted); padding: 6px 12px 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.mention-pop { width: 300px; }
.mention-list { display: flex; flex-direction: column; padding: 0 6px 6px; max-height: 280px; overflow-y: auto; }
.mention-item { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 6px 8px; border-radius: var(--r-sm); text-align: left; }
.mention-item.on, .mention-item:hover { background: var(--accent-subtle); }
.mi-name { font-weight: 600; font-size: 13.5px; }
.mi-sub { margin-left: auto; font-size: 11.5px; color: var(--text-muted); }
.readers, .reactors { min-width: 220px; max-height: 360px; overflow-y: auto; padding-bottom: 4px; }
.reader { display: flex; align-items: center; gap: 8px; padding: 5px 12px; font-size: 13px; }
.emoji-pop { width: 344px; }
.emoji-picker { display: flex; flex-direction: column; }
.emoji-search-wrap { padding: 10px 10px 0; }
.emoji-search { min-height: 34px; padding: 6px 10px; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.emoji-tab { flex: 1; border: 0; background: transparent; border-radius: var(--r-sm); height: 32px; font-size: 17px; }
.emoji-tab.on, .emoji-tab:hover { background: var(--bg-hover); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; max-height: 250px; overflow-y: auto; }
.emoji-cat { grid-column: 1 / -1; font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 2px 4px 4px; text-transform: uppercase; letter-spacing: .05em; }
.emoji-btn { border: 0; background: transparent; border-radius: var(--r-sm); height: 36px; font-size: 21px; line-height: 1; padding: 0; transition: transform .08s, background .1s; }
.emoji-btn:hover { background: var(--bg-hover); transform: scale(1.12); }

/* プロフィールカード */
.profile-pop { width: 280px; overflow: hidden; padding: 0; }
.pc-banner { height: 56px; opacity: .85; }
.pc-body { padding: 0 16px 16px; margin-top: -36px; }
.pc-av { position: relative; display: inline-flex; border-radius: 50%; box-shadow: 0 0 0 4px var(--bg-elevated); }
.pc-av .dot { position: absolute; right: 3px; bottom: 3px; width: 14px; height: 14px; border: 3px solid var(--bg-elevated); }
.pc-name { display: flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 750; letter-spacing: -0.015em; margin-top: 8px; }
.pc-user { font-size: var(--fs-meta); color: var(--text-muted); margin-bottom: 8px; }
.pc-text { font-size: 13px; color: var(--text-secondary); padding: 8px 12px; border-radius: var(--r-sm); background: var(--bg-subtle); border: 1px solid var(--border); margin-bottom: 12px; word-break: break-word; }
.pc-body .btn { margin-top: 4px; }

/* ================================================================ トースト */
.toasts { position: fixed; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: var(--s2); width: min(520px, calc(100vw - 24px)); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: var(--s2); padding: 10px 8px 10px 14px; border-radius: var(--r); pointer-events: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: popIn .16s var(--ease); transition: opacity .18s, transform .18s;
}
.toast.out { opacity: 0; transform: translateY(-6px); }
.toast.error { border-color: var(--red); }
.toast.error > .ic { color: var(--red); }
.toast.ok > .ic { color: var(--green); }
.toast.info > .ic { color: var(--accent); }
.toast-text { flex: 1; word-break: break-word; white-space: pre-wrap; padding-top: 1px; }
.toast-x { border: 0; background: none; color: var(--text-muted); padding: 2px; display: inline-flex; border-radius: 5px; }
.toast-x .ic { width: 15px; height: 15px; }

/* ================================================================ 設定・管理 */
.page-head { display: flex; align-items: center; gap: var(--s2); padding: 12px 20px; padding-top: calc(12px + var(--safe-t)); border-bottom: 1px solid var(--border); background: var(--bg-surface); flex: none; min-height: 60px; }
.page-head h1 { margin: 0; font-size: 17px; font-weight: 750; letter-spacing: -0.02em; }
.page-body { flex: 1; overflow-y: auto; padding: var(--s5); padding-bottom: calc(32px + var(--safe-b)); }
.settings { max-width: 720px; margin: 0 auto; }
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 20px 24px; margin-bottom: var(--s4); }
.card-title { margin: 0 0 var(--s3); font-size: var(--fs-title); font-weight: 750; letter-spacing: var(--tracking-title); }
.set-profile { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.set-row { display: flex; align-items: center; gap: var(--s4); padding: 12px 0; border-top: 1px solid var(--border); }
.set-label { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.set-ctl { flex: 0 1 380px; display: flex; justify-content: flex-end; }
.set-ctl select.input { width: auto; min-width: 170px; }
.av-edit { display: flex; align-items: center; gap: 20px; padding-bottom: var(--s4); }
.av-drop { position: relative; border: 0; padding: 0; background: none; border-radius: 50%; flex: none; }
.av-drop .avatar { box-shadow: 0 0 0 4px var(--bg-surface), 0 0 0 5px var(--border); }
.av-drop-ov { position: absolute; inset: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: rgba(0, 0, 0, .42); opacity: 0; transition: opacity .14s; }
.av-drop-ov .ic { width: 24px; height: 24px; }
.av-drop:hover .av-drop-ov, .av-drop:focus-visible .av-drop-ov, .av-drop.over .av-drop-ov { opacity: 1; }
.av-drop.over .avatar { box-shadow: 0 0 0 4px var(--bg-surface), 0 0 0 6px var(--accent); }
.av-side { min-width: 0; flex: 1; }
.av-side .btn-row { margin: 10px 0 6px; }
.av-prog { width: 120px; }
.push-status { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
.push-status .hint { flex-basis: 100%; order: 9; }
.kv { display: flex; gap: var(--s2); align-items: center; font-size: 13px; }
.result { padding: 8px 12px; border-radius: var(--r-sm); background: var(--bg-hover); font-size: 13px; margin: 6px 0; }
.result.ok { background: var(--green-bg); color: var(--green); font-weight: 700; }
.result.bad { background: var(--red-bg); color: var(--red); }
.devices { margin-top: 6px; }
.device { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 6px; }
.device.off { opacity: .55; }
.device.mine { border-color: var(--accent); }
.device-ua { font-weight: 600; font-size: 13px; }
.admin { max-width: 1200px; margin: 0 auto; }
.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: var(--s4); }
.admin-tabs .tab { font-size: 13.5px; padding: 7px 14px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--s3); }
.toolbar .input { max-width: 260px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg-surface); box-shadow: var(--shadow-xs); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg-subtle); }
.tbl tr.off td { opacity: .5; }
.tbl tr.warn-row td { background: var(--red-bg); }
.tbl code { font-family: var(--mono); font-size: 12px; }
.tbl code.url { word-break: break-all; }
.tbl .detail { font-family: var(--mono); font-size: 11.5px; color: var(--text-secondary); word-break: break-all; }
.cell-user { display: flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 16px; box-shadow: var(--shadow-xs); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent-2); }
.stat.ok::before { background: var(--green); }
.stat.bad::before { background: var(--red); }
.stat.bad .stat-v { color: var(--red); }
.stat.warn::before { background: var(--amber); }
.stat-v { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-l { font-size: var(--fs-meta); color: var(--text-muted); }
.meter-row { margin: var(--s3) 0; }
.meter-label { font-size: 13px; margin-bottom: 6px; }
.meter { height: 10px; border-radius: 6px; background: var(--bg-active); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.meter-fill.warn { background: var(--amber); }
.meter-fill.bad { background: var(--red); }
.bot-card.off { opacity: .6; }
.bot-head { display: flex; align-items: center; gap: 10px; }

/* ================================================================ ログイン */
.login-body { overflow: auto; background: var(--bg); }
.login-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.lg-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5; }
.lg-orb.a { width: 520px; height: 520px; left: -140px; top: -180px; background: radial-gradient(circle, rgba(251, 146, 60, .35), transparent 70%); }
.lg-orb.b { width: 460px; height: 460px; right: -120px; bottom: -160px; background: radial-gradient(circle, rgba(124, 58, 237, .18), transparent 70%); }
[data-theme="dark"] .lg-orb { opacity: .6; }
.login-wrap { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 392px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 32px 28px 24px; animation: modalIn .2s var(--ease); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo { width: 52px; height: 52px; border-radius: 15px; margin-bottom: 14px; }
.login-title { font-size: 22px; margin: 0; font-weight: 800; letter-spacing: -0.025em; }
.login-sub { color: var(--text-muted); margin: 6px 0 0; font-size: 13px; }
.field { display: block; margin-bottom: var(--s4); }
.field > span { display: block; font-size: var(--fs-meta); font-weight: 650; color: var(--text-secondary); margin-bottom: 6px; letter-spacing: var(--tracking-meta); }
.field > span em { font-style: normal; font-weight: 500; color: var(--text-muted); margin-left: 4px; }
.field input { width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--bg-surface); color: var(--text); outline: none; font-size: 15px; transition: border-color .14s, box-shadow .14s; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pw-row { position: relative; display: flex; }
.pw-row input { flex: 1; padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 6px; height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: var(--bg-hover); color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.pw-toggle:hover { background: var(--bg-active); color: var(--text); }
.login-error { white-space: pre-line; line-height: 1.6; background: var(--red-bg); color: var(--red); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; margin-bottom: var(--s3); }
.login-note { font-size: 11.5px; color: var(--text-muted); text-align: center; margin: var(--s4) 0 0; line-height: 1.7; }

/* ================================================================ タッチ端末 */
@media (hover: none) {
  .cmp-hint, .menu-hint { display: none !important; }
  .msg:hover { background: transparent; }
  .msg-tools { display: none !important; }
  .react.add { opacity: 1; }
  .side-time { opacity: .7; }
}
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn.sm { width: 40px; height: 40px; }
  .send-btn { width: 44px; height: 44px; padding: 0; }
  .send-btn .send-label { display: none; }
  .react { height: 32px; padding: 0 10px; }
  .react.add { min-width: 44px; height: 44px; justify-content: center; }
  .reply-ref { min-height: 44px; }
  .cmp-bar { padding: 2px 6px 6px; }
  .cmp-tools { gap: 0; }
  .receipt-btn { min-height: 28px; }
  .sec-head { min-height: 40px; }
}

/* ================================================================ スマホ */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .app, body.right-open .app { grid-template-columns: minmax(0, 1fr); }
  .pane-left { grid-column: 1; border-right: 0; }
  .pane-center { grid-column: 1; display: none; }
  body.in-room .pane-left { display: none; }
  body.in-room .pane-center { display: flex; }
  .pane-right, body.right-open .pane-right { display: none; }
  body.right-mobile .pane-right { display: flex; position: fixed; inset: 0; z-index: 40; border-left: 0; animation: fade .14s; }
  .page { grid-column: 1; position: fixed; inset: 0; z-index: 35; }
  body.page-open .pane-left { display: none; }
  .only-mobile { display: inline-flex !important; }
  .room-head { padding: 6px 6px 6px 4px; padding-top: calc(6px + var(--safe-t)); min-height: 56px; gap: 6px; }
  .room-head .avatar { width: 32px; height: 32px; }
  .room-head .chip-btn { display: none; }
  .head-title .name { font-size: 16px; }
  .room-item { padding: 10px 10px; }
  .room-item.active::before { display: none; }
  .msg { padding: 6px 12px 6px 9px; gap: 10px; }
  .msg-gutter { width: 32px; }
  .msg-gutter .avatar { width: 32px; height: 32px; }
  .msg.has-receipt { padding-right: 72px; }
  .receipt { right: 12px; }
  .day-sep { top: 4px; }
  .composer { padding: 0 8px 8px; padding-bottom: calc(8px + var(--safe-b)); }
  .cmp-box { border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
  .cmp-input, .cmp-mirror { font-size: 16px; } /* iOS のズーム防止（裏の層も同じ大きさ） */
  .cmp-hint { display: none; }
  .send-label { display: none; }
  .send-btn { width: 44px; height: 44px; padding: 0; }
  .att-file { max-width: 100%; }
  .att-imgs { max-width: 100%; }
  .modal-back { align-items: flex-end; padding: 0; }
  .modal { max-width: none !important; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92%; padding-bottom: var(--safe-b); animation: sheetIn .2s var(--ease); border-bottom: 0; }
  @keyframes sheetIn { from { transform: translateY(24px); opacity: .4; } }
  .input, .field input, select.input { font-size: 16px; }
  .page-body { padding: 12px; }
  .card { padding: 16px; border-radius: var(--r); }
  .set-row { flex-direction: column; align-items: stretch; gap: var(--s2); }
  .set-ctl { flex: none; justify-content: flex-start; }
  .set-row:has(.switch) { flex-direction: row; align-items: center; }
  .set-row:has(.switch) .set-ctl { justify-content: flex-end; }
  .av-edit { flex-direction: column; text-align: center; }
  .av-side .btn-row { justify-content: center; }
  .grid2 { grid-template-columns: 1fr; }
  .emoji-pop { width: calc(100vw - 16px); }
  .mention-pop { width: calc(100vw - 16px); }
  .jump-btn { right: 12px; }
  .onboard { margin: 0 10px 8px; }
  .login-card { padding: 28px 20px 20px; border-radius: var(--r-lg); }
}

/* ================================================================ 動きを減らす設定 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .sk { animation: none; }
}
