/* =============================================
   JVLab Chat - メインスタイルシート
   カラーパレット: ダークネイビー + ゴールドアクセント
   ============================================= */

:root {
  --bg-primary:    #0d0f1a;
  --bg-secondary:  #151929;
  --bg-tertiary:   #1e2438;
  --bg-hover:      #252b42;
  --bg-active:     #2e3654;
  --accent:        #c9a84c;
  --accent-light:  #e8c96e;
  --accent-dark:   #a07830;
  --text-primary:  #e8eaf0;
  --text-secondary:#9ba3c0;
  --text-muted:    #5a6280;
  --border:        #252b42;
  --border-light:  #303858;
  --success:       #4caf7d;
  --danger:        #e05555;
  --online:        #4caf7d;
  --mention:       rgba(201, 168, 76, 0.15);
  --sidebar-width: 260px;
  --thread-width:  340px;
  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --transition:    0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; font-family: 'Noto Sans JP', sans-serif; background: var(--bg-primary); color: var(--text-primary); font-size: 14px; line-height: 1.6; }

/* =====================
   認証ページ
   ===================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 40%, #1a2040 0%, var(--bg-primary) 60%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 24px 16px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #0d0f1a;
  margin-bottom: 12px;
  box-shadow: 0 4px 20px rgba(201,168,76,0.3);
}

.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.auth-logo p  { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

.auth-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 14px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.auth-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  font-weight: 600;
}

.auth-tab:hover:not(.active) { background: var(--bg-hover); }

.auth-form { padding: 28px 24px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.hint { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

.input-with-toggle { position: relative; }
.input-with-toggle input { padding-right: 42px; }
.toggle-password {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px;
}

.form-error   { color: var(--danger);  font-size: 13px; margin-bottom: 12px; }
.form-success { color: var(--success); font-size: 13px; margin-bottom: 12px; padding: 10px 14px; background: rgba(76,175,125,0.1); border-radius: var(--radius); border: 1px solid rgba(76,175,125,0.3); }
.form-note    { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 12px; }

.terms-check-group { margin-bottom: 4px; }
.terms-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}
.terms-check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}
.terms-check-label a {
  color: var(--accent);
  text-decoration: underline;
}
.terms-check-label a:hover { color: var(--accent-light); }

.register-hints {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(201,168,76,0.07);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.register-hints p {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}
.register-hints strong { color: var(--accent-light); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #0d0f1a;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: var(--transition);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--transition);
}
.btn-secondary:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn-full { width: 100%; }

/* =====================
   アプリレイアウト
   ===================== */
.app-body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* モバイルヘッダー */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  align-items: center; justify-content: space-between;
}

.hamburger, .mobile-dm-btn {
  background: none; border: none; color: var(--text-primary);
  font-size: 20px; cursor: pointer; padding: 4px;
}

.mobile-title { font-weight: 700; font-size: 16px; color: var(--accent); }

/* サイドバー */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.workspace-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #0d0f1a;
  flex-shrink: 0;
}

.workspace-name strong { display: block; font-size: 13px; line-height: 1.3; }
.online-indicator { font-size: 11px; color: var(--online); }

.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }

/* 検索 */
.sidebar-search { padding: 12px 16px; position: relative; }
.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 13px; font-family: inherit;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }

.search-results {
  position: absolute; top: 100%; left: 16px; right: 16px; z-index: 100;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 300px; overflow-y: auto;
}

.search-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-result-item:hover { background: var(--bg-hover); }
.search-result-item .result-channel { font-size: 11px; color: var(--accent); margin-bottom: 2px; }
.search-result-item .result-content { font-size: 13px; color: var(--text-primary); }
.search-result-item .result-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* チャンネルリスト */
.channel-section {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.channel-section + .channel-section {
  border-top: 1px solid var(--border);
  flex: none;
  max-height: 200px;
}

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 4px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.add-channel-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px; line-height: 1;
  padding: 2px 4px; border-radius: 4px;
  transition: var(--transition);
}
.add-channel-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.channel-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; cursor: pointer;
  border-radius: 4px; margin: 1px 8px;
  transition: var(--transition);
  color: var(--text-secondary);
}

.channel-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.channel-item.active { background: var(--bg-active); color: var(--text-primary); }
.channel-item .channel-name { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.channel-item .channel-hash { color: var(--text-muted); font-size: 16px; }
.channel-item .channel-lock { font-size: 11px; color: var(--accent); }
.channel-item .unread-badge {
  background: var(--danger); color: white;
  border-radius: 10px; padding: 1px 6px;
  font-size: 11px; font-weight: 700;
}
.channel-item .unread-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-primary); flex-shrink: 0;
}

.dm-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px; cursor: pointer;
  border-radius: 4px; margin: 1px 8px;
  transition: var(--transition);
  color: var(--text-secondary);
}
.dm-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dm-item.active { background: var(--bg-active); color: var(--text-primary); }
.dm-item .dm-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-active);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--accent);
  flex-shrink: 0; position: relative;
}
.dm-item .dm-avatar .online-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--online); border: 2px solid var(--bg-secondary);
}
.dm-item .dm-name { font-size: 13px; }
.dm-item .dm-unread {
  margin-left: auto;
  background: var(--danger); color: white;
  border-radius: 10px; padding: 1px 6px;
  font-size: 11px; font-weight: 700;
}

/* サイドバーフッター */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}

.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dark), var(--bg-active));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--accent-light);
  flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-details { min-width: 0; }
.user-details strong { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--accent); }

.user-actions { display: flex; gap: 4px; }

.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px;
  padding: 6px; border-radius: var(--radius);
  transition: var(--transition); text-decoration: none;
  display: inline-flex; align-items: center;
}
.icon-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* =====================
   メインコンテンツ
   ===================== */
.main-content {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.channel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.channel-header-info {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}

.channel-hash { color: var(--text-muted); font-size: 20px; }
#channelName { font-size: 16px; font-weight: 700; }
.channel-desc { color: var(--text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.channel-header-actions { display: flex; gap: 8px; }

/* メッセージエリア */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex; flex-direction: column;
}

.welcome-screen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 32px;
  color: var(--text-secondary);
}
.welcome-icon { font-size: 56px; }
.welcome-screen h2 { font-size: 22px; color: var(--text-primary); }

/* メッセージ */
.message {
  display: flex; gap: 12px;
  padding: 4px 20px;
  transition: background var(--transition);
  position: relative;
}
.message:hover { background: var(--bg-secondary); }
.message:hover .message-actions { opacity: 1; }

.message.mention-highlight { background: var(--mention); }

.message-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-active);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: var(--accent);
  flex-shrink: 0; overflow: hidden; margin-top: 2px;
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }

.message-body { flex: 1; min-width: 0; }

.message-header {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px;
}

.message-author { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.message-author.conductor { color: var(--accent); }
.message-author.admin { color: #e8c96e; }
.message-time { font-size: 11px; color: var(--text-muted); }
.message-edited { font-size: 11px; color: var(--text-muted); font-style: italic; }

.message-content {
  font-size: 14px; color: var(--text-primary);
  word-break: break-word; white-space: pre-wrap;
  line-height: 1.6;
}

.message-content a { color: var(--accent); text-decoration: none; }
.message-content a:hover { text-decoration: underline; }

.mention { color: var(--accent); font-weight: 600; background: rgba(201,168,76,0.1); padding: 1px 3px; border-radius: 3px; }

/* リアクション */
.message-reactions {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}

.reaction-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  cursor: pointer; font-size: 13px; transition: var(--transition);
  color: var(--text-secondary);
}
.reaction-btn:hover, .reaction-btn.reacted {
  background: rgba(201,168,76,0.15); border-color: var(--accent); color: var(--accent);
}
.reaction-count { font-size: 12px; font-weight: 600; }

/* メッセージアクション（ホバー時） */
.message-actions {
  position: absolute; top: 0; right: 20px;
  display: flex; gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  opacity: 0; transition: opacity var(--transition);
  z-index: 10;
}

.message-action-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px;
  padding: 4px 8px; border-radius: 4px;
  transition: var(--transition);
}
.message-action-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

/* スレッド返信インジケーター */
.thread-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 4px; padding: 3px 8px;
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 12px;
  border-radius: 4px; transition: var(--transition);
}
.thread-indicator:hover { background: rgba(201,168,76,0.1); }

/* ファイル添付 */
.message-files { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  text-decoration: none; color: var(--text-primary);
  font-size: 12px; transition: var(--transition);
}
.file-item:hover { border-color: var(--accent); }
.file-image { max-width: 320px; max-height: 240px; border-radius: var(--radius); cursor: pointer; }

/* 日付区切り */
.date-divider {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 20px; color: var(--text-muted); font-size: 12px;
}
.date-divider::before, .date-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* 入力エリア */
.input-area {
  padding: 0 16px 16px;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  transition: border-color var(--transition);
}
.input-wrapper:focus-within { border-color: var(--accent); }

.attach-btn, .emoji-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px;
  padding: 4px; flex-shrink: 0;
  transition: var(--transition);
}
.attach-btn:hover, .emoji-btn:hover { color: var(--accent); }

#messageInput, #threadInput, #dmInput {
  flex: 1;
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 14px; font-family: inherit;
  resize: none; min-height: 22px; max-height: 150px;
  line-height: 1.5;
}
#messageInput::placeholder { color: var(--text-muted); }

.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #0d0f1a; border: none; border-radius: var(--radius);
  padding: 6px 14px; font-size: 13px; font-weight: 700; font-family: inherit;
  cursor: pointer; flex-shrink: 0; transition: var(--transition);
}
.send-btn:hover { filter: brightness(1.1); }

.file-preview {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 4px 6px;
  min-height: 0;
}

.file-preview-item {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; background: var(--bg-active);
  border-radius: 4px; font-size: 12px; color: var(--text-secondary);
}

.file-preview-remove {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 0 2px;
}

/* 絵文字ピッカー */
.emoji-picker {
  position: absolute; bottom: 70px; right: 20px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px;
  box-shadow: var(--shadow); z-index: 100;
}

.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 32px); gap: 4px;
}

.emoji-item {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; border-radius: 6px;
  transition: background var(--transition);
}
.emoji-item:hover { background: var(--bg-hover); }

/* =====================
   スレッドパネル
   ===================== */
.thread-panel {
  width: var(--thread-width);
  min-width: var(--thread-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh;
}

.thread-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
}

.thread-parent {
  padding: 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

.thread-replies {
  flex: 1; overflow-y: auto; padding: 8px 0;
}

.thread-input {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}

.thread-input textarea {
  flex: 1;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text-primary); font-size: 13px; font-family: inherit;
  resize: none; outline: none; transition: border-color var(--transition);
}

.thread-input textarea:focus { border-color: var(--accent); }

/* =====================
   DMパネル
   ===================== */
.dm-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px; background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 150; box-shadow: var(--shadow);
}

.dm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
}

.dm-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.dm-input {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}
.dm-input textarea {
  flex: 1;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  color: var(--text-primary); font-size: 13px; font-family: inherit;
  resize: none; outline: none;
}
.dm-input textarea:focus { border-color: var(--accent); }

.dm-message { display: flex; gap: 8px; align-items: flex-start; }
.dm-message.own { flex-direction: row-reverse; }
.dm-bubble {
  max-width: 75%; padding: 8px 12px;
  background: var(--bg-tertiary); border-radius: 12px;
  font-size: 13px; word-break: break-word;
}
.dm-message.own .dm-bubble {
  background: linear-gradient(135deg, var(--accent-dark), #7a5a20);
  color: var(--text-primary);
}
.dm-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-align: center; }

/* =====================
   モーダル
   ===================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}

.modal {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 520px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  margin: auto;
}

.modal-large { max-width: 760px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-secondary); z-index: 1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 20px;
  padding: 4px; border-radius: 4px; transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body { padding: 24px; }

/* プロフィールタブ */
.profile-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}

.profile-tab {
  padding: 10px 16px; background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 14px;
  font-family: inherit; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: var(--transition);
}
.profile-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.profile-tab:hover:not(.active) { color: var(--text-primary); }

.profile-content { display: flex; flex-direction: column; gap: 16px; }

/* 100の質問 */
.onboarding-phase {
  margin-bottom: 24px;
}

.phase-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary); border-radius: var(--radius);
  cursor: pointer; margin-bottom: 8px;
}

.phase-title { font-weight: 600; font-size: 15px; }
.phase-progress { font-size: 12px; color: var(--accent); }

.phase-questions { display: none; }
.phase-questions.open { display: block; }

.question-item { margin-bottom: 12px; }
.question-text { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.question-item textarea {
  width: 100%; padding: 8px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 13px; font-family: inherit; resize: vertical;
  outline: none; min-height: 60px;
}
.question-item textarea:focus { border-color: var(--accent); }

.save-onboarding-btn {
  position: sticky; bottom: 0;
  width: 100%; padding: 12px;
  background: var(--bg-secondary); border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* プログレスバー */
.progress-bar-wrap { background: var(--bg-tertiary); border-radius: 10px; height: 8px; overflow: hidden; }
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  border-radius: 10px; transition: width 0.5s ease;
}

/* リソースサマリー */
.resource-summary {
  background: var(--bg-tertiary); border-radius: var(--radius-lg);
  padding: 16px; border: 1px solid var(--border); white-space: pre-wrap;
  font-size: 14px; line-height: 1.8;
}

.resource-card {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; align-items: flex-start; gap: 12px;
}

.resource-card .avatar { width: 40px; height: 40px; font-size: 16px; }

.resource-card-body { flex: 1; min-width: 0; }
.resource-card-name { font-weight: 700; font-size: 14px; }
.resource-card-role { font-size: 11px; color: var(--accent); margin-bottom: 4px; }
.resource-card-summary { font-size: 12px; color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.resource-search { display: flex; gap: 8px; margin-bottom: 16px; }
.resource-search input { flex: 1; padding: 10px 14px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none; }
.resource-search input:focus { border-color: var(--accent); }

/* コンテキストメニュー */
.context-menu {
  position: fixed; z-index: 300;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 160px; overflow: hidden;
}

.context-item {
  display: block; width: 100%;
  padding: 10px 16px; background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 13px; font-family: inherit;
  text-align: left; transition: var(--transition);
}
.context-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.context-item.danger { color: var(--danger); }
.context-item.danger:hover { background: rgba(224,85,85,0.1); }

/* ローディング */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 32px; color: var(--text-muted);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* トースト通知 */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }

.toast {
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--bg-secondary); border: 1px solid var(--border);
  box-shadow: var(--shadow); font-size: 13px; max-width: 300px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger);  }
.toast.info    { border-color: var(--accent);   color: var(--accent);  }

.toast { display: flex; align-items: center; gap: 10px; }
.toast-close {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.6; font-size: 14px; padding: 0;
  line-height: 1; flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ユーティリティ */
.hidden { display: none !important; }

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

/* =====================
   管理者画面
   ===================== */
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 220px; background: var(--bg-secondary);
  border-right: 1px solid var(--border); padding: 20px 0;
}

.admin-nav-item {
  display: block; padding: 10px 20px;
  color: var(--text-secondary); text-decoration: none;
  transition: var(--transition); cursor: pointer;
  background: none; border: none; width: 100%; text-align: left;
  font-size: 14px; font-family: inherit;
}
.admin-nav-item:hover, .admin-nav-item.active { background: var(--bg-hover); color: var(--text-primary); }

.admin-content { flex: 1; padding: 24px; overflow-y: auto; }
.admin-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: 12px 14px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.data-table tr:hover td { background: var(--bg-hover); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.badge-pending  { background: rgba(255,193,7,0.15);  color: #ffc107; }
.badge-active   { background: rgba(76,175,125,0.15); color: var(--success); }
.badge-disabled { background: rgba(224,85,85,0.15);  color: var(--danger); }
.badge-conductor { background: rgba(201,168,76,0.15); color: var(--accent); }
.badge-admin    { background: rgba(201,168,76,0.25); color: var(--accent-light); }

.btn-sm {
  padding: 4px 10px; border-radius: 4px;
  font-size: 12px; font-weight: 600; cursor: pointer; border: none;
  font-family: inherit; transition: var(--transition);
}
.btn-approve { background: rgba(76,175,125,0.2); color: var(--success); }
.btn-approve:hover { background: rgba(76,175,125,0.4); }
.btn-reject  { background: rgba(224,85,85,0.2);  color: var(--danger); }
.btn-reject:hover  { background: rgba(224,85,85,0.4); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* =====================
   チャンネルアナウンスバー
   ===================== */
.announcement-bar {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 20px;
  background: rgba(201,168,76,0.08);
  border-bottom: 1px solid rgba(201,168,76,0.2);
  font-size: 13px; color: var(--text-secondary);
  flex-shrink: 0;
}
.announcement-icon { font-size: 14px; flex-shrink: 0; margin-top: 2px; }
.announcement-body { flex: 1; min-width: 0; }
.announcement-text {
  white-space: pre-wrap; word-break: break-word;
  /* デフォルトは2行まで */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: all 0.2s ease;
}
.announcement-text.expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.announcement-text a { color: var(--accent); }
.announcement-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 12px;
  padding: 2px 0; margin-top: 4px;
  display: inline-block; transition: var(--transition);
}
.announcement-toggle:hover { opacity: 0.8; }

/* =====================
   引用返信スタイル
   ===================== */
.quote-block {
  display: block;
  padding: 4px 12px;
  margin-bottom: 4px;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  border-radius: 0 4px 4px 0;
  font-size: 13px;
}

/* =====================
   メンバー一覧パネル
   ===================== */
.member-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 300px; background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 140; box-shadow: var(--shadow);
}
.member-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.member-panel-body { flex: 1; overflow-y: auto; padding: 12px; }

.member-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  transition: var(--transition); cursor: default;
}
.member-item:hover { background: var(--bg-hover); }
.member-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-active);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--accent);
  flex-shrink: 0; position: relative;
}
.member-avatar .online-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--online); border: 2px solid var(--bg-secondary);
}
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-role-label { font-size: 11px; color: var(--accent); }
.member-role-label.role-member { color: var(--text-muted); }
.member-role-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
  font-family: inherit;
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}
.member-role-select:hover { border-color: var(--accent); }

.member-dm-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px;
  padding: 4px 6px; border-radius: 4px;
  transition: var(--transition); flex-shrink: 0;
}
.member-dm-btn:hover { color: var(--accent); background: var(--bg-hover); }

.member-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted);
  padding: 12px 10px 4px;
}

/* =====================
   出席管理
   ===================== */
.attendance-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.att-tab {
  padding: 10px 16px; background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 14px;
  font-family: inherit; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: var(--transition);
}
.att-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.att-tab:hover:not(.active) { color: var(--text-primary); }
.att-content { display: flex; flex-direction: column; gap: 12px; }

.event-card {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 14px 14px 18px;
  border-left: 5px solid var(--border);
}
.event-card.past { opacity: 0.5; }

/* 種別カラー（左ボーダー＋日付色） */
.event-type-conductor { border-left-color: #d4af37; }
.event-type-general   { border-left-color: #4ecdc4; }
.event-type-admin     { border-left-color: #9b59b6; }

/* 大きな日付 */
.event-card-date-large {
  font-size: 22px; font-weight: 800; letter-spacing: 0.02em;
  margin-bottom: 4px; line-height: 1.2;
}
.event-type-conductor .event-card-date-large { color: #d4af37; }
.event-type-general   .event-card-date-large { color: #4ecdc4; }
.event-type-admin     .event-card-date-large { color: #9b59b6; }

/* イベント名 + バッジ行 */
.event-card-name-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 6px;
}
.event-card-name { font-weight: 700; font-size: 15px; }
.event-card-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.event-card-stats { display: flex; gap: 12px; font-size: 12px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.event-stat-present { color: var(--success); font-weight: 600; }
.event-stat-absent  { color: var(--danger);  font-weight: 600; }
.event-stat-total   { color: var(--text-muted); font-size: 11px; }
.attendee-toggle    { cursor: pointer; text-decoration: underline dotted; }
.attendee-toggle:hover { opacity: 0.8; }
.toggle-arrow       { font-size: 10px; }

/* 出席者名一覧（展開） */
.attendee-names {
  margin-bottom: 10px; padding: 10px 12px;
  background: var(--bg-primary); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.attendee-group { margin-bottom: 6px; }
.attendee-group:last-child { margin-bottom: 0; }
.attendee-group-label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 4px; }
.attendee-chip {
  display: inline-block; font-size: 12px; padding: 2px 8px;
  background: rgba(76,175,125,0.15); color: var(--success);
  border-radius: 10px; margin: 2px 3px 2px 0;
}
.attendee-chip.absent {
  background: rgba(224,85,85,0.12); color: var(--danger);
}

/* ロールバッジ */
.event-role-badge {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 10px; font-weight: 600;
}
.event-role-badge.conductor { background: rgba(212,175,55,0.15); color: #d4af37; border: 1px solid rgba(212,175,55,0.4); }
.event-role-badge.admin     { background: rgba(155,89,182,0.15); color: #9b59b6; border: 1px solid rgba(155,89,182,0.4); }
.event-role-badge.general   { background: rgba(78,205,196,0.12); color: #4ecdc4; border: 1px solid rgba(78,205,196,0.4); }

/* 出席ボタン — スマホでも押しやすい大きさ */
.att-btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.att-btn {
  flex: 1; min-width: 80px;
  padding: 10px 8px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--bg-primary);
  color: var(--text-secondary); cursor: pointer; font-size: 13px;
  font-family: inherit; transition: var(--transition);
  text-align: center; font-weight: 500;
}
.att-btn:hover { border-color: var(--accent); color: var(--accent); }
.att-btn.present { background: rgba(76,175,125,0.18); border-color: var(--success); color: var(--success); font-weight: 700; }
.att-btn.absent  { background: rgba(224,85,85,0.15);  border-color: var(--danger);  color: var(--danger);  font-weight: 700; }
.att-btn.pending { background: rgba(90,98,128,0.15);  border-color: var(--text-muted); color: var(--text-muted); }

.att-matrix-table { width: 100%; border-collapse: collapse; }
.att-matrix-table th, .att-matrix-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; text-align: left;
}
.att-matrix-table th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.att-matrix-table tr:hover td { background: var(--bg-hover); }
.att-status-present { color: var(--success); font-weight: 700; }
.att-status-absent  { color: var(--danger);  font-weight: 700; }
.att-status-pending { color: var(--text-muted); }

/* =====================
   レスポンシブ（スマホ）
   ===================== */
@media (max-width: 768px) {
  .app-body { padding-top: 52px; }
  .mobile-header { display: flex; }
  .sidebar-close { display: block; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .thread-panel {
    position: fixed; inset: 0; z-index: 150;
    width: 100%;
  }

  .dm-panel { width: 100%; }

  .channel-header-actions .icon-btn span { display: none; }
  .modal { max-width: 100%; margin: 8px; }
}

/* =====================
   参加者リソースモーダル
   ===================== */
.er-section {
  margin-bottom: 28px;
}

.er-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.er-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  transition: border-color 0.15s;
}

.er-card:hover {
  border-color: var(--border-light);
}

.er-card-guest {
  border-left: 3px solid var(--accent);
}

.er-avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-active), var(--accent-dark));
  color: var(--text-primary);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.er-avatar-guest {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #000;
}

.er-card-body {
  flex: 1;
  min-width: 0;
}

.er-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.er-company {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.er-role-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-active);
  color: var(--text-secondary);
}

.er-role-badge.guest {
  background: rgba(201,168,76,0.15);
  color: var(--accent);
  border: 1px solid rgba(201,168,76,0.3);
}

.er-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre-line;
}

.er-no-data {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ゲストの10問Q&A */
.er-qa-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.er-qa-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
}

.er-qa-label {
  color: var(--accent);
  font-weight: 600;
  font-size: 11px;
  padding-top: 1px;
}

.er-qa-ans {
  color: var(--text-secondary);
}

/* 今日の相談 */
.er-consultation {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(201,168,76,0.08);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.er-consultation-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

/* =====================
   アーカイブセクション
   ===================== */
.archive-section {
  margin-top: 4px;
}

.archive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: var(--transition);
  user-select: none;
}

.archive-header:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.archive-toggle {
  font-size: 10px;
}

.archive-list {
  /* hidden クラスで display:none */
}

/* イベントチャンネルの小さなドット */
.channel-event-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0.7;
}

/* マークダウン変換後のスタイル */
.er-md-h2 { font-size: 15px; font-weight: 700; color: var(--accent); margin: 14px 0 6px; }
.er-md-h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); margin: 12px 0 4px; }
.er-md-h4 { font-size: 13px; font-weight: 700; color: var(--text-secondary); margin: 10px 0 4px; }
.er-md-ul { margin: 4px 0 8px 16px; }
.er-md-ul li { font-size: 13px; color: var(--text-secondary); line-height: 1.8; }
.er-md-arrow { font-size: 12px; color: var(--text-muted); padding-left: 12px; line-height: 1.7; }
.er-md-hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

@media (max-width: 580px) {
  .er-qa-item {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .er-qa-label::after {
    content: '：';
  }
}
