/* ── CSS変数 ─────────────────────────────────────── */
:root {
  --bg-primary:    #313338;
  --bg-secondary:  #2b2d31;
  --bg-tertiary:   #1e1f22;
  --bg-input:      #383a40;
  --bg-msg-hover:  #2e3035;
  --text-primary:  #dbdee1;
  --text-secondary:#b5bac1;
  --text-muted:    #949ba4;
  --text-link:     #00a8fc;
  --accent:        #5865f2;
  --accent-hover:  #4752c4;
  --green:         #23a559;
  --red:           #da373c;
  --yellow:        #f0b232;
  --border:        #3f4147;
  --hover:         #35373c;
  --active:        #404249;
  --mention-bg:    rgba(88,101,242,0.15);
  --header-primary:#f2f3f5;
  --channel-icon:  #80848e;
  --sidebar-w:     240px;
  --thread-w:      360px;
}
[data-theme="light"] {
  --bg-primary:    #fafafa;
  --bg-secondary:  #f0f0f2;
  --bg-tertiary:   #e3e5e8;
  --bg-input:      #ffffff;
  --bg-msg-hover:  #f4f4f6;
  --text-primary:  #1d1c1d;
  --text-secondary:#4e5058;
  --text-muted:    #868686;
  --text-link:     #1264a3;
  --border:        #e8e8e8;
  --hover:         #ebebeb;
  --active:        #dddde0;
  --mention-bg:    rgba(88,101,242,0.08);
  --header-primary:#1d1c1d;
  --channel-icon:  #868686;
}

/* ── リセット ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', 'Segoe UI', sans-serif;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea, select {
  font: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88,101,242,.2); }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ── ログイン画面 ─────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-tertiary);
}
.login-box {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 40px 48px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.login-logo {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  margin-bottom: 28px;
  letter-spacing: -0.5px;
}
.login-box h2 {
  font-size: 20px;
  margin-bottom: 24px;
  text-align: center;
  color: var(--header-primary);
  font-weight: 700;
}
.login-box input { width: 100%; margin-bottom: 12px; font-size: 15px; }
.login-box button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  transition: background .15s, transform .1s;
}
.login-box button:hover { background: var(--accent-hover); }
.login-box button:active { transform: scale(.98); }
.login-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }

/* ── レイアウト ───────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── サイドバー ───────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}
.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 16px;
  color: var(--header-primary);
  letter-spacing: -0.3px;
}
#channel-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.category-label {
  padding: 18px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.category-label button { opacity: 0; font-size: 16px; color: var(--text-muted); transition: opacity .15s; line-height: 1; }
.category-label:hover button { opacity: 1; }
.channel-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 12px;
  height: 34px;
  border-radius: 6px;
  margin: 1px 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
  transition: background .1s, color .1s;
}
.channel-item:hover { background: var(--hover); color: var(--text-secondary); }
.channel-item.active { background: var(--active); color: var(--text-primary); }
.channel-item .ch-icon { font-size: 16px; flex-shrink: 0; color: var(--channel-icon); }
.channel-item.active .ch-icon { color: var(--text-primary); }
.channel-item .ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.channel-item.active .ch-name { font-weight: 600; }
.ch-badge { background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 6px; min-width: 18px; text-align: center; }

/* DM */
.section-label { padding: 12px 16px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: .7px; }
.dm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 12px;
  border-radius: 6px;
  margin: 1px 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  transition: background .1s;
}
.dm-item:hover { background: var(--hover); color: var(--text-secondary); }
.dm-item.active { background: var(--active); color: var(--text-primary); }
.dm-item .dm-name { flex: 1; font-weight: 500; }

/* フッター */
.sidebar-footer { border-top: 1px solid var(--border); padding: 8px; }
.footer-user { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 6px; }
.footer-info { flex: 1; }
.footer-info > div { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.footer-actions { display: flex; gap: 2px; }
.footer-actions button { padding: 5px 7px; border-radius: 4px; font-size: 15px; color: var(--text-muted); transition: background .1s, color .1s; }
.footer-actions button:hover { background: var(--hover); color: var(--text-primary); }

/* リサイズハンドル */
#resize-handle-sidebar { width: 4px; background: transparent; cursor: col-resize; transition: background .15s; }
#resize-handle-sidebar:hover { background: var(--accent); }

/* ── メインエリア ─────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-primary); }

/* チャンネルヘッダー */
#channel-header {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
#hamburger-btn { display: none; font-size: 18px; color: var(--text-muted); padding: 4px; }
#channel-icon { font-size: 20px; color: var(--channel-icon); }
#channel-name-header { font-size: 16px; font-weight: 700; color: var(--header-primary); letter-spacing: -0.2px; }
#channel-desc-header {
  font-size: 13px;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 12px;
  margin-left: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.header-actions { margin-left: auto; display: flex; gap: 4px; }
.header-actions button { padding: 6px 8px; border-radius: 6px; color: var(--text-muted); font-size: 16px; transition: background .1s, color .1s; }
.header-actions button:hover { background: var(--hover); color: var(--text-primary); }

/* 検索パネル */
#search-panel { border-bottom: 1px solid var(--border); padding: 10px 16px; }
.search-inner { display: flex; gap: 8px; }
#search-input { flex: 1; font-size: 15px; }
#search-close { color: var(--text-muted); }
#search-results { margin-top: 10px; max-height: 300px; overflow-y: auto; }
.search-result-item { padding: 10px; border-radius: 6px; cursor: pointer; }
.search-result-item:hover { background: var(--hover); }
.search-result-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.search-result-content { font-size: 14px; }

/* コンテンツ行 */
#content-row { flex: 1; display: flex; overflow: hidden; }

/* メッセージフィード */
#feed-column { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#message-area { flex: 1; overflow-y: auto; padding: 8px 0 16px; }
#messages { display: flex; flex-direction: column; }

/* ── メッセージ ───────────────────────────────────── */
.msg {
  display: flex;
  gap: 10px;
  padding: 2px 20px;
  position: relative;
  transition: background .1s;
  align-items: flex-start;
}
.msg:not(.msg-compact) { padding-top: 18px; }
.msg:hover { background: var(--bg-msg-hover); }
.msg:hover .msg-actions { opacity: 1; }
.msg.mention-highlight { background: var(--mention-bg); border-left: 3px solid var(--accent); }

/* 自分のメッセージは右寄せ */
.msg.msg-mine { flex-direction: row-reverse; }

/* アバター */
.msg-avatar { flex-shrink: 0; margin-top: 2px; }
.msg-compact .msg-avatar { visibility: hidden; }
.msg-compact { padding-top: 2px; }

/* メッセージ本体 */
.msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.msg-mine .msg-body { align-items: flex-end; }

/* ヘッダー（ユーザー名＋時刻） */
.msg-group-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
}
.msg-mine .msg-group-header { flex-direction: row-reverse; }
.msg-author {
  font-weight: 700;
  font-size: 15px;
  color: var(--header-primary);
  cursor: pointer;
  line-height: 1.3;
}
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 12px; color: var(--text-muted); font-weight: 400; line-height: 1.3; }

/* チャットバブル */
.msg-bubble {
  background: var(--bg-secondary);
  border-radius: 4px 16px 16px 16px;
  padding: 10px 14px;
  max-width: 72%;
  box-shadow: 0 1px 2px rgba(0,0,0,.07);
  word-break: break-word;
}
.msg-compact:not(.msg-mine) .msg-bubble { border-radius: 12px 16px 16px 12px; }

/* 自分のバブル：アクセントカラー */
.msg-mine .msg-bubble {
  background: var(--accent);
  border-radius: 16px 4px 16px 16px;
  box-shadow: 0 1px 4px rgba(88,101,242,.25);
}
.msg-mine.msg-compact .msg-bubble { border-radius: 16px 12px 12px 16px; }

/* バブル内テキスト */
.msg-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-mine .msg-bubble .msg-content { color: #fff; }
.msg-content .mention {
  color: var(--accent);
  font-weight: 600;
  background: var(--mention-bg);
  border-radius: 4px;
  padding: 0 3px;
}
.msg-mine .msg-bubble .mention { color: #fff; background: rgba(255,255,255,.25); }
.msg-content a { color: var(--text-link); }
.msg-mine .msg-bubble a { color: rgba(255,255,255,.85); }
.msg-content code {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 13px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.msg-mine .msg-bubble code { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.2); color: #fff; }
.msg-content strong { font-weight: 700; }
.msg-edited { font-size: 11px; color: var(--text-muted); margin-left: 5px; }
.msg-mine .msg-bubble .msg-edited { color: rgba(255,255,255,.6); }

/* リアクションを自分のメッセージは右寄せ */
.msg-mine .reactions { justify-content: flex-end; }

/* 日付セパレーター */
.date-separator { text-align: center; margin: 20px 0 4px; position: relative; }
.date-separator::before { content: ''; position: absolute; left: 20px; right: 20px; top: 50%; height: 1px; background: var(--border); }
.date-separator span {
  position: relative;
  background: var(--bg-primary);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .3px;
}

/* スレッド表示 */
.thread-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
}
.thread-summary:hover { background: var(--mention-bg); }

/* リアクション */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.reaction-btn:hover, .reaction-btn.mine { background: rgba(88,101,242,.15); border-color: var(--accent); }
.reaction-count { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

/* 添付ファイル */
.attachments { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-img { max-width: 360px; max-height: 240px; border-radius: 8px; cursor: pointer; border: 1px solid var(--border); }
.attachment-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.attachment-file a { color: var(--text-link); font-size: 14px; font-weight: 500; }
.attachment-size { font-size: 12px; color: var(--text-muted); }

/* メッセージアクション（ホバー時） */
.msg-actions {
  position: absolute;
  right: 20px;
  top: -18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: 2px;
  padding: 4px;
  opacity: 0;
  transition: opacity .1s;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.msg-actions button { padding: 4px 7px; border-radius: 5px; font-size: 15px; color: var(--text-muted); }
.msg-actions button:hover { background: var(--hover); color: var(--text-primary); }

/* ── メンション候補ドロップアップ ────────────────── */
#mention-suggest {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  margin: 0 0 8px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.2);
  max-height: 220px;
  overflow-y: auto;
}
.mention-item-suggest {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
}
.mention-item-suggest:hover { background: var(--hover); }
.mention-suggest-name { font-size: 14px; font-weight: 600; color: var(--header-primary); }
.mention-suggest-id { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ── 入力エリア ───────────────────────────────────── */
#input-area { padding: 0 16px 20px; flex-shrink: 0; }
#input-wrapper {
  background: var(--bg-input);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: border-color .15s, box-shadow .15s;
}
#input-wrapper:focus-within {
  border-color: var(--border);
  box-shadow: 0 0 0 1px rgba(88,101,242,.3);
}
.input-row { display: flex; align-items: flex-end; gap: 4px; padding: 10px 10px 10px 12px; }
#file-label { cursor: pointer; padding: 4px 8px; color: var(--text-muted); font-size: 20px; flex-shrink: 0; line-height: 1; }
#file-label:hover { color: var(--text-primary); }
#file-input { display: none; }
#message-input {
  flex: 1;
  background: transparent;
  border: none;
  resize: none;
  max-height: 220px;
  line-height: 1.6;
  padding: 2px 0;
  font-size: 15px;
  color: var(--text-primary);
  box-shadow: none;
}
#message-input::placeholder { color: var(--text-muted); font-size: 15px; }
#message-input:focus { border: none; box-shadow: none; }
#emoji-btn-input { padding: 4px 8px; border-radius: 4px; color: var(--text-muted); font-size: 18px; flex-shrink: 0; }
#emoji-btn-input:hover { color: var(--text-primary); }
#send-btn {
  padding: 6px 14px;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  background: var(--accent);
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#send-btn:hover { background: var(--accent-hover); }
#send-btn:active { transform: scale(.95); }
#attachment-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px 0; }
.preview-item { position: relative; }
.preview-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.preview-item .preview-name { font-size: 11px; color: var(--text-muted); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-remove { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* ── スレッドパネル ───────────────────────────────── */
#thread-panel { width: var(--thread-w); background: var(--bg-secondary); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.thread-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
#thread-messages { flex: 1; overflow-y: auto; padding: 8px 0; }
.thread-input-area { padding: 10px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
#thread-input {
  flex: 1;
  resize: none;
  max-height: 140px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.6;
  border: 1px solid var(--border);
}
#thread-send-btn { padding: 9px 16px; background: var(--accent); color: #fff; border-radius: 6px; font-size: 14px; font-weight: 700; }
#thread-send-btn:hover { background: var(--accent-hover); }
#resize-handle-thread { width: 4px; background: transparent; cursor: col-resize; transition: background .15s; }
#resize-handle-thread:hover { background: var(--accent); }

/* ── フォーラム ───────────────────────────────────── */
#forum-area { flex: 1; display: flex; overflow: hidden; }
#forum-list { flex: 1; overflow-y: auto; padding: 20px; }
.forum-header-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.forum-header-bar h3 { font-size: 17px; font-weight: 700; color: var(--header-primary); }
.btn-primary { padding: 9px 18px; background: var(--accent); color: #fff; border-radius: 6px; font-weight: 700; font-size: 14px; transition: background .15s; }
.btn-primary:hover { background: var(--accent-hover); }
.forum-post-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.forum-post-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.forum-post-card.pinned { border-left: 3px solid var(--yellow); }
.forum-post-title { font-size: 15px; font-weight: 700; color: var(--header-primary); margin-bottom: 6px; }
.forum-post-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 14px; }
.forum-post-replies { color: var(--accent); font-weight: 600; }
#forum-detail { flex: 1; overflow-y: auto; padding: 20px; border-left: 1px solid var(--border); }
.forum-back-btn { color: var(--accent); margin-bottom: 14px; cursor: pointer; font-size: 14px; font-weight: 600; }
.forum-post-full { background: var(--bg-secondary); border-radius: 8px; padding: 24px; margin-bottom: 20px; }
.forum-post-full h2 { font-size: 19px; font-weight: 700; color: var(--header-primary); margin-bottom: 14px; line-height: 1.4; }
.forum-reply { padding: 14px 0; border-bottom: 1px solid var(--border); }
.forum-reply-input { margin-top: 18px; }
.forum-reply-input textarea { width: 100%; resize: none; margin-bottom: 10px; font-size: 15px; }
.forum-reply-input button { padding: 9px 18px; background: var(--accent); color: #fff; border-radius: 6px; font-weight: 700; }

/* ── パネルオーバーレイ ───────────────────────────── */
.panel-overlay {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 380px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.2);
}
.panel-inner { display: flex; flex-direction: column; height: 100%; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
.panel-close { color: var(--text-muted); font-size: 18px; padding: 4px; border-radius: 4px; }
.panel-close:hover { background: var(--hover); color: var(--text-primary); }
#bookmark-list, #mention-list, #task-list { flex: 1; overflow-y: auto; padding: 10px; }

/* ── タスク ───────────────────────────────────────── */
.task-filters { display: flex; gap: 4px; padding: 10px; border-bottom: 1px solid var(--border); }
.task-filter { padding: 5px 12px; border-radius: 14px; font-size: 13px; font-weight: 500; color: var(--text-muted); border: 1px solid transparent; transition: all .15s; }
.task-filter.active { background: var(--accent); color: #fff; }
.task-filter:hover:not(.active) { background: var(--hover); color: var(--text-secondary); }
.task-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: box-shadow .15s;
}
.task-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.task-card-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--header-primary); }
.task-card-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.task-card-actions { margin-top: 8px; display: flex; gap: 4px; }
.task-card-actions button { font-size: 12px; padding: 3px 10px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); font-weight: 500; }
.task-card-actions button:hover { background: var(--hover); color: var(--text-primary); }
.priority-high { color: var(--red); font-weight: 600; }
.priority-medium { color: var(--yellow); font-weight: 600; }
.priority-low { color: var(--green); font-weight: 600; }
.status-badge { padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 700; letter-spacing: .3px; }
.status-todo { background: rgba(148,155,164,.2); color: var(--text-muted); }
.status-in_progress { background: rgba(240,178,50,.2); color: var(--yellow); }
.status-done { background: rgba(35,165,89,.2); color: var(--green); }

/* ── ブックマーク / メンション ───────────────────── */
.bookmark-item, .mention-item {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background .1s;
}
.bookmark-item:hover, .mention-item:hover { background: var(--hover); }
.bm-meta, .mn-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 500; }
.bm-content, .mn-content { font-size: 14px; line-height: 1.5; }
.mention-item.unread { border-left: 3px solid var(--accent); }

/* ── モーダル ─────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-box {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 28px 32px;
  width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header span { font-size: 19px; font-weight: 700; color: var(--header-primary); }
.modal-header button { color: var(--text-muted); font-size: 20px; padding: 4px; border-radius: 4px; }
.modal-header button:hover { background: var(--hover); color: var(--text-primary); }
.modal-box label { display: block; font-size: 13px; font-weight: 700; color: var(--text-secondary); margin-bottom: 14px; text-transform: uppercase; letter-spacing: .4px; }
.modal-box label input, .modal-box label textarea, .modal-box label select { width: 100%; margin-top: 6px; font-size: 15px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; justify-content: flex-end; }
.modal-actions button:first-child { padding: 10px 24px; background: var(--accent); color: #fff; border-radius: 6px; font-weight: 700; font-size: 14px; transition: background .15s; }
.modal-actions button:first-child:hover { background: var(--accent-hover); }
.modal-actions button:last-child { padding: 10px 18px; background: var(--hover); color: var(--text-secondary); border-radius: 6px; font-size: 14px; font-weight: 600; }

/* ── 絵文字ピッカー ───────────────────────────────── */
#emoji-picker { position: fixed; z-index: 300; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px; padding: 10px; box-shadow: 0 4px 24px rgba(0,0,0,.35); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 34px); gap: 3px; }
.emoji-btn-item { width: 34px; height: 34px; font-size: 20px; display: flex; align-items: center; justify-content: center; border-radius: 6px; cursor: pointer; transition: background .1s; }
.emoji-btn-item:hover { background: var(--hover); }

/* ── コンテキストメニュー ────────────────────────── */
#context-menu { position: fixed; z-index: 400; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 4px; box-shadow: 0 4px 20px rgba(0,0,0,.35); min-width: 170px; }
.ctx-item { padding: 9px 14px; border-radius: 5px; cursor: pointer; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.ctx-item:hover { background: var(--hover); }

/* ── アバター ─────────────────────────────────────── */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.bot-icon { font-size: 20px; }

/* ── 保留タスク確認ボタン ────────────────────────── */
.pending-task-btns { display: flex; gap: 8px; margin-top: 10px; }
.pending-task-btns button { padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 700; transition: opacity .15s; }
.btn-confirm { background: var(--green); color: #fff; }
.btn-confirm:hover { opacity: .85; }
.btn-reject { background: var(--hover); color: var(--text-secondary); border: 1px solid var(--border); }

/* ── スクロールバー ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── レスポンシブ ─────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 50; transition: left .25s; width: 260px; min-width: 260px; }
  #sidebar.open { left: 0; }
  #sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
  #sidebar-backdrop.show { display: block; }
  #hamburger-btn { display: block; }
  #resize-handle-sidebar, #resize-handle-thread { display: none; }
  #thread-panel { position: fixed; inset: 0; width: 100%; z-index: 60; }
  .panel-overlay { width: 100%; }
  #channel-desc-header { display: none; }
  .msg { padding: 2px 12px; }
  .msg:not(.msg-compact) { padding-top: 14px; }
  #input-area { padding: 0 10px 16px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 210px; --thread-w: 320px; }
}
