* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f6f8; --sidebar: #2b2d3a; --sidebar-fg: #cfd2e0;
  --accent: #4a6cf7; --accent-d: #3a55d0; --border: #e3e6ec;
  --task: #e8a13a; --done: #3aa55d; --danger: #d04545;
}
body { font-family: "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
  background: var(--bg); color: #222; height: 100vh; overflow: hidden; }

/* ---------- 認証 ---------- */
.auth-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.auth-card { background: #fff; width: 360px; padding: 32px; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.10); }
.auth-title { font-size: 22px; text-align: center; }
.auth-sub { text-align: center; color: #888; font-size: 13px; margin: 6px 0 20px; }
.auth-error { background: #fdecec; color: var(--danger); padding: 9px 12px;
  border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.auth-tabs { display: flex; margin-bottom: 18px; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; }
.auth-tab { flex: 1; padding: 9px; background: #fff; border: none; cursor: pointer;
  font-size: 14px; color: #666; }
.auth-tab.is-active { background: var(--accent); color: #fff; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: #666; margin-bottom: 5px; }
.field input, .field select { width: 100%; padding: 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; }
.btn-primary { width: 100%; padding: 11px; background: var(--accent); color: #fff;
  border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { padding: 11px 16px; background: #eee; border: none; border-radius: 8px;
  cursor: pointer; }

/* ---------- レイアウト ---------- */
.app { display: flex; height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar); color: var(--sidebar-fg);
  display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.me { display: flex; align-items: center; gap: 9px; }
.me-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.me-name { font-size: 14px; color: #fff; }
.logout-form { margin: 0; }
.logout-btn { background: none; border: none; color: var(--sidebar-fg); cursor: pointer;
  font-size: 16px; }
.sidebar-section { padding: 14px 8px; }
.sidebar-section-head { display: flex; justify-content: space-between; align-items: center;
  padding: 0 8px 8px; font-size: 12px; letter-spacing: .04em; color: #9aa0b5; }
.add-btn { background: none; border: none; color: #9aa0b5; cursor: pointer; font-size: 18px; }
.add-btn:hover { color: #fff; }
.channel-list { list-style: none; }
.channel-item { display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; }
.channel-item:hover { background: rgba(255,255,255,.06); }
.channel-item.is-active { background: var(--accent); color: #fff; }
.channel-name { display: flex; align-items: center; gap: 6px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; }
.channel-kind { opacity: .6; font-size: 12px; }
.badge { background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px;
  padding: 1px 7px; min-width: 18px; text-align: center; }

/* ---------- メイン ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header { height: 54px; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: #fff; }
.chat-title { font-weight: 600; font-size: 16px; }
.chat-online { font-size: 12px; color: #3aa55d; }
.messages { flex: 1; overflow-y: auto; padding: 18px 20px; }
.empty-hint { color: #aaa; text-align: center; margin-top: 40px; }

.msg { display: flex; gap: 10px; margin-bottom: 16px; }
.msg-avatar { width: 36px; height: 36px; border-radius: 8px; background: #c9cee0;
  color: #444; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-weight: 600; }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.msg-name { font-weight: 600; font-size: 14px; }
.msg-time { font-size: 11px; color: #999; }
.msg-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.msg-file a { color: var(--accent); font-size: 13px; text-decoration: none; }
.msg-file a:hover { text-decoration: underline; }

/* タスク */
.msg.is-task .msg-text { background: #fff7ec; border-left: 3px solid var(--task);
  padding: 8px 10px; border-radius: 0 6px 6px 0; }
.task-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  cursor: pointer; padding: 2px 8px; border-radius: 12px; border: 1px solid var(--task);
  color: var(--task); margin-top: 5px; user-select: none; }
.task-chip.done { border-color: var(--done); color: var(--done); }
.task-chip .ck { font-weight: 700; }

/* 入力 */
.typing-bar { height: 18px; padding: 0 20px; font-size: 12px; color: #999; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 20px;
  border-top: 1px solid var(--border); background: #fff; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; font-family: inherit;
  max-height: 140px; }
.attach-btn { cursor: pointer; font-size: 20px; padding-bottom: 6px; }
.task-toggle { font-size: 12px; color: #777; display: flex; align-items: center; gap: 4px;
  padding-bottom: 8px; white-space: nowrap; }
.send-btn { background: var(--accent); color: #fff; border: none; border-radius: 9px;
  padding: 10px 18px; cursor: pointer; font-size: 14px; }
.send-btn:hover { background: var(--accent-d); }

/* モーダル */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; width: 400px; padding: 26px; border-radius: 12px; }
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.member-list { max-height: 160px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px; }
.member-row { display: flex; align-items: center; gap: 8px; padding: 5px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ヘッダー検索 */
.header-spacer { flex: 1; }
.search-input { width: 240px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; }
.badge-mention { background: var(--task); }

/* 検索パネル */
.search-panel { border-bottom: 1px solid var(--border); background: #fbfbfd;
  max-height: 50%; overflow-y: auto; }
.search-panel-head { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; font-size: 13px; color: #555; position: sticky; top: 0; background: #fbfbfd; }
.btn-ghost-sm { background: #eee; border: none; border-radius: 6px; padding: 4px 10px;
  cursor: pointer; font-size: 12px; }
.search-item { padding: 10px 20px; border-top: 1px solid var(--border); cursor: pointer; }
.search-item:hover { background: #f0f2f7; }
.search-item-meta { font-size: 12px; color: #888; margin-bottom: 3px; }
.search-item-body { font-size: 14px; }

/* メッセージ操作 */
.msg-actions { display: none; gap: 4px; margin-left: auto; }
.msg:hover .msg-actions { display: inline-flex; }
.msg-actions button { background: none; border: none; cursor: pointer; font-size: 13px;
  opacity: .6; padding: 0 2px; }
.msg-actions button:hover { opacity: 1; }
.msg-meta { display: flex; align-items: center; gap: 8px; }
.edited { font-size: 11px; color: #aaa; }
.msg.deleted .msg-text.muted { color: #bbb; font-style: italic; }

/* メンション */
.mention { color: var(--accent); background: #eaf0ff; border-radius: 4px; padding: 0 3px; }
.mention-me { background: #fff2d6; color: #b8791a; font-weight: 600; }

/* リアクション */
.react-palette { display: flex; gap: 4px; margin-top: 5px; background: #fff;
  border: 1px solid var(--border); border-radius: 18px; padding: 3px 8px; width: fit-content; }
/* hidden 属性で確実に隠す（.react-palette の display:flex が [hidden] を上書きしてしまう対策） */
.react-palette[hidden] { display: none; }
.react-palette span { cursor: pointer; font-size: 16px; }
.react-palette span:hover { transform: scale(1.25); }
.reactions { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.react-chip { font-size: 12px; border: 1px solid var(--border); border-radius: 12px;
  padding: 1px 8px; cursor: pointer; background: #fff; }
.react-chip.mine { border-color: var(--accent); background: #eaf0ff; }

/* 編集 */
.edit-box { margin-top: 4px; }
.edit-input, .thread-input { width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; font-size: 14px; font-family: inherit; resize: vertical; }
.edit-actions { display: flex; gap: 6px; margin-top: 6px; }
.btn-mini { background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 5px 12px; cursor: pointer; font-size: 12px; }
.btn-mini.ghost { background: #eee; color: #444; }

/* スレッド */
.thread-toggle { font-size: 12px; color: var(--accent); cursor: pointer; margin-top: 6px;
  display: inline-block; }
.thread-toggle:hover { text-decoration: underline; }
.thread { margin-top: 8px; border-left: 2px solid var(--border); padding-left: 12px; }
.reply { display: flex; gap: 8px; margin-bottom: 10px; }
.msg-avatar.sm { width: 28px; height: 28px; font-size: 12px; border-radius: 6px; }
.thread-composer { display: flex; gap: 6px; align-items: flex-end; margin-top: 4px; }
.thread-composer textarea { flex: 1; }

/* メンションポップ */
.composer { position: relative; }
.mention-pop { position: absolute; bottom: 64px; left: 60px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 180px; z-index: 20; overflow: hidden; }
.mention-item { padding: 8px 12px; font-size: 14px; cursor: pointer; }
.mention-item.active, .mention-item:hover { background: #eaf0ff; }

/* ピン留めバー */
.pin-bar { background: #fffdf5; border-bottom: 1px solid #f0e2bf; padding: 8px 20px;
  font-size: 13px; max-height: 140px; overflow-y: auto; }
.pin-bar-title { font-weight: 600; color: #b8791a; margin-bottom: 4px; }
.pin-item { padding: 3px 0; cursor: pointer; color: #555; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; }
.pin-item:hover { color: #000; }
.pin-remove { color: #c00; margin-left: 6px; cursor: pointer; font-weight: 700; }
.msg-actions button.pinned { opacity: 1; filter: none; }

/* 画像インライン */
.msg-image { margin-top: 6px; }
.msg-image img { max-width: 320px; max-height: 260px; border-radius: 8px;
  border: 1px solid var(--border); display: block; }

/* リアクションパレット（多絵文字対応で折り返し） */
.react-palette { flex-wrap: wrap; max-width: 280px; }

/* ドラッグ&ドロップ */
.main { position: relative; }
.main.dragging::after { content: '📎 ここにドロップして添付'; position: absolute;
  inset: 8px; border: 3px dashed var(--accent); border-radius: 14px;
  background: rgba(74,108,247,.08); color: var(--accent); font-size: 18px;
  display: flex; align-items: center; justify-content: center; z-index: 50; pointer-events: none; }

/* ジャンプ時のハイライト */
.msg.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: #fff3cd; } 100% { background: transparent; } }

/* ヘッダーボタン（スター一覧） */
.header-btn { background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 15px; }
.header-btn:hover { background: #f0f2f7; }
.msg-actions button.starred { opacity: 1; }

/* 動画・音声・PDF プレビュー */
.msg-media { margin-top: 6px; }
.msg-media video { max-width: 360px; max-height: 280px; border-radius: 8px; display: block; }
.msg-media audio { width: 320px; }
.msg-pdf { margin-top: 6px; }
.msg-pdf embed { width: 100%; max-width: 480px; height: 360px; border: 1px solid var(--border);
  border-radius: 8px; }

/* スイート連携リンク */
.suite-links { margin-top: auto; }
.suite-link { width: calc(100% - 16px); margin: 0 8px; padding: 9px; background: rgba(255,255,255,.06);
  color: var(--sidebar-fg); border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
  cursor: pointer; font-size: 13px; text-align: left; }
.suite-link:hover { background: rgba(255,255,255,.12); color: #fff; }

/* 今日やる3つ（フォーカス） */
.focus-add-btn { margin-left: 6px; background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 7px; font-size: 12px; cursor: pointer; color: #555; }
.focus-add-btn:hover { background: #eef3ff; color: var(--accent); }
.focus-add-btn:disabled { opacity: .7; cursor: default; }
.focus-panel { background: #fff; border-bottom: 1px solid var(--border); padding: 12px 20px;
  max-height: 60%; overflow-y: auto; }
.focus-current { border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px;
  background: #f6f9ff; margin-bottom: 12px; }
.focus-now-tag { display: inline-block; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--accent); border-radius: 6px; padding: 1px 8px; margin-bottom: 6px; }
.focus-now-body { font-size: 15px; margin: 4px 0; white-space: pre-wrap; }
.focus-now-meta { font-size: 12px; color: #888; margin-bottom: 8px; }
.focus-now-actions { display: flex; gap: 8px; }
.focus-alldone { padding: 14px; border: 1px solid #cfe9d4; background: #f3fbf4;
  border-radius: 12px; color: #1d8a3a; margin-bottom: 12px; }
.focus-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex;
  flex-direction: column; gap: 6px; }
.focus-list li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.focus-list li.on { border-color: var(--accent); background: #f6f9ff; }
.focus-list li.is-done .focus-subj { color: #aaa; text-decoration: line-through; }
.focus-pos { display: inline-flex; align-items: center; justify-content: center; width: 20px;
  height: 20px; border-radius: 999px; background: #eef3ff; color: var(--accent);
  font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.focus-subj { flex: 1; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.focus-chan { color: #999; font-size: 12px; flex: 0 0 auto; }
.focus-x { background: none; border: none; color: #c00; cursor: pointer; font-size: 12px; }
.focus-cand-h { font-size: 12px; font-weight: 600; color: #666; margin: 6px 0; }
