/* =====================
   REPO 共通スタイル
   ===================== */

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

:root {
  --rb:  #185FA5;
  --rbl: #E6F1FB;
  --rbm: #378ADD;
  --rbd: #0C447C;

  --text-primary:   #222;
  --text-secondary: #999;
  --text-muted:     #bbb;
  --border-light:   #e0e0e0;
  --border-lighter: #f0f0f0;
  --bg-input:       #f7f7f7;
  --bg-hover:       #f8fbff;
  --bg-message:     #EEF4FB;

  --danger: #E24B4A;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN',
               'ヒラギノ角ゴ ProN W3', Meiryo, sans-serif;

  --sidebar-width: 300px;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
body {
  overflow-y: hidden;
}

button { font-family: inherit; }
input, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ローディング */
.loading-screen {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--rbl);
  border-top-color: var(--rb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ログイン画面 */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--rbl);
  padding: 20px;
}
.login-card {
  background: #fff;
  padding: 36px 32px;
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 360px;
}
.login-logo {
  font-size: 28px; font-weight: 600; letter-spacing: 6px;
  color: var(--rb);
  text-align: center;
  margin-bottom: 6px;
}
.login-subtitle {
  font-size: 12px; color: var(--text-secondary);
  text-align: center; margin-bottom: 28px;
  letter-spacing: 1px;
}
.login-field { margin-bottom: 16px; }
.login-label {
  display: block; font-size: 12px; color: var(--text-secondary);
  margin-bottom: 6px; font-weight: 500;
}
.login-input {
  width: 100%; padding: 10px 12px;
  border: 0.5px solid #ddd; border-radius: 8px;
  font-size: 14px; background: var(--bg-input);
  color: var(--text-primary); outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.login-input:focus { border-color: var(--rbm); background: #fff; }
.login-input:disabled { opacity: 0.6; cursor: not-allowed; }
.login-error {
  margin: 14px 0 8px; padding: 8px 12px;
  background: #fdecea; border: 0.5px solid #f8c3c1;
  border-radius: 8px; color: var(--danger);
  font-size: 12px; line-height: 1.5;
}
.login-btn {
  width: 100%; margin-top: 10px; padding: 12px 0;
  background: var(--rb); color: #fff;
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s;
}
.login-btn:hover:not(:disabled) { background: var(--rbd); }
.login-btn:disabled { background: #aaa; cursor: not-allowed; }
.login-btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* メインアプリ */
.app {
  display: flex;
  height: 100vh;
  height: -webkit-fill-available;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  background: #fff;
  position: relative;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: 200px;
  max-width: 600px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 0.5px solid var(--border-light);
  background: #fff;
  overflow: hidden;
}
.s-header {
  padding: 12px 16px;
  background: var(--rbd);
  display: flex; align-items: center; gap: 8px;
  min-height: 54px;
  flex-shrink: 0;
}
.logo {
  font-size: 15px; font-weight: 500;
  color: #fff; letter-spacing: 3px;
}
.my-av {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #B5D4F4;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500;
  color: var(--rbd);
  margin-left: auto;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.my-av:hover { opacity: 0.85; }
.my-av img { width: 100%; height: 100%; object-fit: cover; }

.s-tabs {
  display: flex;
  border-bottom: 0.5px solid var(--border-light);
  flex-shrink: 0;
}
.s-tab {
  flex: 1; padding: 9px 0;
  text-align: center; font-size: 12px;
  cursor: pointer; color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  user-select: none;
}
.s-tab.active {
  color: var(--rbm);
  border-bottom-color: var(--rbm);
  font-weight: 500;
}

.side-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.search-box {
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border-light);
  flex-shrink: 0;
}
.search-box input {
  width: 100%;
  padding: 6px 10px;
  border: 0.5px solid #ddd; border-radius: 8px;
  font-size: 12px; background: var(--bg-input);
  color: #333; outline: none;
}

.new-bar {
  display: flex; gap: 8px;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border-light);
  flex-shrink: 0;
}
.new-btn {
  flex: 1;
  min-width: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 5px; padding: 7px 0;
  border-radius: 8px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; border: none;
  background: var(--rb); color: #fff;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.new-btn:hover:not(:disabled) { background: var(--rbd); }
.new-btn:disabled { background: #ccc; cursor: not-allowed; }
.new-btn i { font-size: 14px; flex-shrink: 0; }

.list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  min-height: 0;
}
.list-empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  background: #fff;
  border-bottom: 0.5px solid var(--border-lighter);
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  transition: background 0.12s;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.active { background: var(--rbl); }

.av {
  width: 40px; height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500;
  color: var(--rbd);
  background: #B5D4F4;
  overflow: hidden;
  flex-shrink: 0;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.group { background: #9FE1CB; color: #085041; }
.av.group i { font-size: 18px; }

.li-info { flex: 1; min-width: 0; }
.li-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text-primary);
}
.li-sub {
  font-size: 11px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.li-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.li-time {
  font-size: 11px;
  color: var(--text-muted);
}
.badge {
  background: var(--rbm);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* リサイザ */
.resizer {
  width: 5px;
  flex-shrink: 0;
  background: transparent;
  cursor: col-resize;
  position: relative;
  transition: background 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.resizer:hover { background: var(--rbm); }
.resizer.dragging { background: var(--rbm); }
body.resizing {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}
body.resizing * {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* チャット領域 */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-width: 0;
  overflow: hidden;
}

.chat-empty {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  color: var(--text-muted);
}
.chat-empty i { font-size: 48px; color: var(--rbl); }
.chat-empty-msg { font-size: 13px; }

.chat-room {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.c-header {
  padding: 11px 16px;
  border-bottom: 0.5px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
  background: #fff;
  min-height: 54px;
  flex-shrink: 0;
}
.c-header.clickable {
  cursor: pointer;
  transition: background 0.12s;
}
.c-header.clickable:hover { background: var(--bg-hover); }

.c-back {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-primary);
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
}
.c-back:hover { background: var(--bg-hover); }
.c-back i { font-size: 22px; }

.c-header .av {
  width: 34px; height: 34px; min-width: 34px;
  font-size: 12px;
}
.c-titles { min-width: 0; flex: 1; }
.c-name {
  font-size: 14px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.c-sub {
  font-size: 11px;
  color: var(--text-secondary);
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  background: #f5f7fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.input-area {
  padding: 8px 12px;
  border-top: 0.5px solid var(--border-light);
  background: #fff;
  flex-shrink: 0;
}

.placeholder-msg {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* モーダル共通 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  position: relative;
  max-width: 100%;
  max-height: 100%;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 32px; height: 32px;
  border: none; background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
  z-index: 1;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.modal-close i { font-size: 20px; }

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-right: 32px;
}

.modal-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* プロフィールモーダル */
.profile-modal {
  width: 360px;
  max-width: 100%;
  padding: 28px 24px 20px;
  text-align: center;
}

.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: #B5D4F4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  color: var(--rbd);
  overflow: hidden;
}
.profile-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.profile-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}

.profile-company {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 22px;
  word-break: break-word;
}

.profile-section {
  margin-bottom: 22px;
  text-align: left;
}

.profile-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.profile-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  padding: 10px 14px;
  border-radius: 10px;
}

.profile-id {
  flex: 1;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--rbd);
  word-break: break-all;
}

.profile-copy-btn {
  width: 32px; height: 32px;
  background: var(--rb);
  border: none;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.profile-copy-btn:hover { background: var(--rbd); }
.profile-copy-btn i { font-size: 16px; }

.profile-copied {
  margin-top: 6px;
  font-size: 11px;
  color: var(--rbm);
  text-align: center;
  animation: fadeIn 0.18s ease;
}

.profile-qr {
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  border: 0.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  width: fit-content;
  max-width: 100%;
}
.profile-qr canvas,
.profile-qr img {
  display: block;
  width: 200px;
  height: 200px;
  max-width: 100%;
}
.profile-qr-hint {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

.profile-actions {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 0.5px solid var(--border-light);
}

.profile-logout-btn {
  width: 100%;
  padding: 10px;
  background: #fff;
  border: 0.5px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}
.profile-logout-btn:hover {
  background: var(--danger);
  color: #fff;
}
.profile-logout-btn i { font-size: 16px; }

/* ID検索モーダル */
.search-id-modal {
  width: 380px;
  max-width: 100%;
  padding: 24px 22px 20px;
}

.search-id-row {
  display: flex;
  gap: 8px;
}

.search-id-input {
  flex: 1;
  padding: 10px 12px;
  border: 0.5px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  letter-spacing: 2px;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  text-transform: uppercase;
}
.search-id-input:focus { border-color: var(--rbm); background: #fff; }
.search-id-input::placeholder {
  text-transform: none;
  font-family: var(--font-sans);
  letter-spacing: normal;
  color: var(--text-muted);
}

.search-id-btn {
  padding: 0 18px;
  background: var(--rb);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.search-id-btn:hover:not(:disabled) { background: var(--rbd); }
.search-id-btn:disabled { background: #aaa; cursor: not-allowed; }
.search-id-btn-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.search-id-error {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fdecea;
  border: 0.5px solid #f8c3c1;
  border-radius: 8px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.search-id-result {
  margin-top: 16px;
}

.search-result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-input);
  border-radius: 10px;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-company {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.search-result-add-btn {
  padding: 6px 14px;
  background: var(--rb);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.search-result-add-btn:hover:not(:disabled) { background: var(--rbd); }
.search-result-add-btn:disabled { background: #aaa; cursor: not-allowed; }

.search-result-already {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--border-lighter);
  border-radius: 8px;
  flex-shrink: 0;
}

/* QRスキャンモーダル */
.qr-scan-modal {
  width: 380px;
  max-width: 100%;
  padding: 24px 22px 20px;
}

.qr-scan-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 8px;
}
.qr-scan-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qr-scan-frame {
  position: absolute;
  inset: 15%;
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.35);
  pointer-events: none;
}

.qr-scan-status {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
}
.qr-scan-status.error {
  color: var(--danger);
}
.qr-scan-status.success {
  color: var(--rbm);
}

/* ユーザー確認モーダル */
.confirm-user-modal {
  width: 340px;
  max-width: 100%;
  padding: 24px 22px 20px;
}

.confirm-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-input);
  border-radius: 12px;
  margin-bottom: 16px;
}

.confirm-user-avatar {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 50%;
  background: #B5D4F4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 500;
  color: var(--rbd);
  overflow: hidden;
  flex-shrink: 0;
}
.confirm-user-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.confirm-user-info {
  flex: 1;
  min-width: 0;
}
.confirm-user-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.confirm-user-company {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.confirm-user-msg {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 14px;
}
.confirm-user-msg.error {
  background: #fdecea;
  border: 0.5px solid #f8c3c1;
  color: var(--danger);
}
.confirm-user-msg.success {
  background: #e6f7ed;
  border: 0.5px solid #b6e6c8;
  color: #1f8a4d;
}

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

.confirm-user-cancel {
  flex: 1;
  padding: 10px;
  background: #fff;
  border: 0.5px solid #ddd;
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.confirm-user-cancel:hover:not(:disabled) { background: var(--bg-hover); }
.confirm-user-cancel:disabled { opacity: 0.5; cursor: not-allowed; }

.confirm-user-add {
  flex: 1;
  padding: 10px;
  background: var(--rb);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.confirm-user-add:hover:not(:disabled) { background: var(--rbd); }
.confirm-user-add:disabled { background: #aaa; cursor: not-allowed; }
.confirm-user-add-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ピッカー（個人/グループ作成）モーダル */
.picker-modal {
  width: 420px;
  max-width: 100%;
  max-height: 85vh;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
}

.picker-name-row {
  margin-bottom: 12px;
}
.picker-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 0.5px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.picker-name-input:focus { border-color: var(--rbm); background: #fff; }

.picker-search {
  margin-bottom: 8px;
}
.picker-search input {
  width: 100%;
  padding: 8px 12px;
  border: 0.5px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
}
.picker-search input:focus { border-color: var(--rbm); background: #fff; }

.picker-selected-info {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 4px 8px;
}

.picker-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border: 0.5px solid var(--border-light);
  border-radius: 10px;
  min-height: 200px;
  max-height: 400px;
}

.picker-list .list-item {
  padding: 10px 12px;
}
.picker-list .list-item:last-child {
  border-bottom: 0 !important;
}
.picker-list .av {
  width: 36px; height: 36px; min-width: 36px;
}

.picker-list .list-item.selected {
  background: var(--rbl);
}

.picker-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
  background: #fff;
  transition: all 0.12s;
}
.list-item.selected .picker-check {
  border-color: var(--rb);
  background: var(--rb);
  color: #fff;
}
.picker-check i { font-size: 14px; }

.picker-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fdecea;
  border: 0.5px solid #f8c3c1;
  border-radius: 8px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.picker-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-light);
}

.picker-cancel {
  flex: 1;
  padding: 10px;
  background: #fff;
  border: 0.5px solid #ddd;
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.picker-cancel:hover:not(:disabled) { background: var(--bg-hover); }
.picker-cancel:disabled { opacity: 0.5; cursor: not-allowed; }

.picker-submit {
  flex: 1;
  padding: 10px;
  background: var(--rb);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.picker-submit:hover:not(:disabled) { background: var(--rbd); }
.picker-submit:disabled { background: #aaa; cursor: not-allowed; }
.picker-submit-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* グループメンバー確認モーダル */
.members-modal {
  width: 380px;
  max-width: 100%;
  max-height: 80vh;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
}

.members-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 36px; /* 右上の×ボタン分の余白 */
  margin-bottom: 4px;
}
.members-header .modal-title {
  flex: 1;
  margin-bottom: 0;
  padding-right: 0;
  word-break: break-word;
}
.members-edit-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rb);
  transition: background 0.12s;
  flex-shrink: 0;
}
.members-edit-btn:hover { background: var(--bg-hover); }
.members-edit-btn i { font-size: 18px; }

.members-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border: 0.5px solid var(--border-light);
  border-radius: 10px;
  margin-top: 4px;
  max-height: 60vh;
}

.members-list .list-item {
  padding: 10px 12px;
  cursor: default;
}
.members-list .list-item:last-child {
  border-bottom: 0 !important;
}
.members-list .list-item:hover { background: #fff; }
.members-list .av {
  width: 36px; height: 36px; min-width: 36px;
}

.member-self-badge {
  font-size: 11px;
  color: var(--rbm);
  background: var(--rbl);
  padding: 2px 8px;
  border-radius: 8px;
  flex-shrink: 0;
}

/* グループ名編集モーダル */
.edit-group-name-modal {
  width: 360px;
  max-width: 100%;
  padding: 24px 22px 20px;
}

.edit-group-name-input {
  width: 100%;
  padding: 10px 12px;
  border: 0.5px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.edit-group-name-input:focus { border-color: var(--rbm); background: #fff; }

.edit-group-name-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fdecea;
  border: 0.5px solid #f8c3c1;
  border-radius: 8px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.edit-group-name-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.edit-group-name-cancel {
  flex: 1;
  padding: 10px;
  background: #fff;
  border: 0.5px solid #ddd;
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.edit-group-name-cancel:hover:not(:disabled) { background: var(--bg-hover); }
.edit-group-name-cancel:disabled { opacity: 0.5; cursor: not-allowed; }

.edit-group-name-save {
  flex: 1;
  padding: 10px;
  background: var(--rb);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.edit-group-name-save:hover:not(:disabled) { background: var(--rbd); }
.edit-group-name-save:disabled { background: #aaa; cursor: not-allowed; }
.edit-group-name-save-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* コンテキストメニュー */
.context-menu {
  position: fixed;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 4px 0;
  min-width: 150px;
  z-index: 2000;
  animation: fadeIn 0.12s ease;
  border: 0.5px solid var(--border-light);
}

.context-menu-item {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s;
}
.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item i { font-size: 16px; }

/* 共通：モーダル内オーバーレイ（処理中の視覚的フィードバック） */
.modal {
  position: relative;
}
.modal-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 14px;
  animation: fadeIn 0.12s ease;
}
.modal-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--rbl);
  border-top-color: var(--rb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* 削除処理中のカーソル */
body.app-busy,
body.app-busy * {
  cursor: wait !important;
}

/* =====================
   プロフィールアバター編集UI
   ===================== */
.profile-avatar-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
}
.profile-avatar-wrap .profile-avatar {
  margin: 0;
}
.profile-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.profile-avatar-wrap:hover .profile-avatar-overlay {
  opacity: 1;
}
.profile-avatar-overlay i {
  font-size: 28px;
}

/* グループアバター（メンバー確認モーダル内） */
.members-header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.members-avatar-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
}
.members-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #9FE1CB;
  color: #0F6E56;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 500;
  overflow: hidden;
}
.members-avatar img { width: 100%; height: 100%; object-fit: cover; }
.members-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.members-avatar-wrap:hover .members-avatar-overlay { opacity: 1; }
.members-avatar-overlay i { font-size: 24px; }
/* 編集モーダル内のタイトル行はセンタリング */
.members-header-center .members-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
}
.members-header-center .modal-desc {
  text-align: center;
  margin: 0;
}

/* アイコン編集メニューモーダル */
.icon-menu-modal {
  width: 320px;
  max-width: 100%;
  padding: 24px 22px 18px;
}
.icon-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.icon-menu-btn {
  padding: 12px;
  background: #fff;
  border: 0.5px solid #ddd;
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}
.icon-menu-btn:hover:not(:disabled) { background: var(--bg-hover); }
.icon-menu-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-menu-btn i { font-size: 18px; color: var(--rb); }
.icon-menu-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}
.icon-menu-btn.danger i { color: var(--danger); }
.icon-menu-btn.danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}
.icon-menu-btn.danger:hover:not(:disabled) i { color: #fff; }

.icon-menu-cancel {
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}
.icon-menu-cancel:hover { background: var(--bg-hover); }

/* Cropperモーダル */
.crop-modal {
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
}

.cropper-canvas-wrap {
  width: 100%;
  height: 320px;
  max-height: 50vh;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0;
}
.cropper-canvas-wrap img {
  display: block;
  max-width: 100%;
}

.cropper-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fdecea;
  border: 0.5px solid #f8c3c1;
  border-radius: 8px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.cropper-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-light);
}
.cropper-cancel {
  flex: 1;
  padding: 10px;
  background: #fff;
  border: 0.5px solid #ddd;
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.cropper-cancel:hover:not(:disabled) { background: var(--bg-hover); }
.cropper-cancel:disabled { opacity: 0.5; cursor: not-allowed; }
.cropper-save {
  flex: 1;
  padding: 10px;
  background: var(--rb);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.cropper-save:hover:not(:disabled) { background: var(--rbd); }
.cropper-save:disabled { background: #aaa; cursor: not-allowed; }
.cropper-save-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* =====================
   メッセージエリア
   ===================== */
.messages {
  position: relative;
}

.messages-loading {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px;
  z-index: 5;
}
.messages-loading-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--rbl);
  border-top-color: var(--rb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.messages-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 20px;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* 日付区切り */
.msg-date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 8px 0;
  margin: 4px 0;
  position: relative;
}
.msg-date-divider span {
  background: #fff;
  padding: 2px 12px;
  border-radius: 12px;
  border: 1px solid #c5cbd2;
}

/* メッセージグループ（送信者ごと） */
.msg-group {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.msg-group.is-mine {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px; height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: #B5D4F4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--rbd);
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-start;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-avatar.invisible {
  display: none;
}

.msg-bubbles {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 70%;
  min-width: 0;
}
.msg-group.is-mine .msg-bubbles {
  align-items: flex-end;
}

.msg-sender-name {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
  padding: 0 4px;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.msg-group.is-mine .msg-row {
  flex-direction: row-reverse;
}

.msg-bubble {
  background: #fff;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
  border: 0.5px solid #e5e8ee;
  min-width: 0;
}
.msg-group.is-mine .msg-bubble {
  background: #DCEDFD;
  border: 0.5px solid #C5DFF5;
}

.msg-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-size: 10px;
  color: #666;
  flex-shrink: 0;
  padding-bottom: 0;
}
.msg-group.is-mine .msg-meta {
  align-items: flex-end;
}
.msg-read {
  color: var(--rbm);
  font-size: 10px;
  cursor: default;
}
.msg-read.clickable {
  cursor: pointer;
}

/* 入力エリア */
.input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
}

.message-input {
  flex: 1;
  border: 0.5px solid #ddd;
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 14px;
  line-height: 1.4;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 36px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  overflow-y: hidden;
  box-sizing: border-box;
  vertical-align: middle;
}
.message-input:focus { border-color: var(--rbm); background: #fff; }
.message-input::placeholder { color: var(--text-muted); }
.message-input:disabled { opacity: 0.6; cursor: not-allowed; }

.message-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--rb);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.message-send-btn:hover:not(:disabled) { background: var(--rbd); }
.message-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}
.message-send-btn i { font-size: 18px; }
.message-send-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* 既読者一覧モーダル */
.readers-modal {
  width: 380px;
  max-width: 100%;
  max-height: 80vh;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
}

.readers-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  margin-top: 4px;
  max-height: 60vh;
}

.readers-list .list-item {
  padding: 10px 12px;
  cursor: default;
}
.readers-list .list-item:last-child {
  border-bottom: 0 !important;
}
.readers-list .list-item:hover { background: #fff; }
.readers-list .av {
  width: 36px; height: 36px; min-width: 36px;
}

.reader-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* =====================
   添付ファイル UI
   ===================== */

/* 添付ボタン（クリップアイコン） */
.message-attach-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.message-attach-btn:hover { background: var(--bg-hover); color: var(--rb); }
.message-attach-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.message-attach-btn i { font-size: 20px; }

/* 絵文字ボタン */
.message-emoji-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.message-emoji-btn:hover { background: var(--bg-hover); color: var(--rb); }
.message-emoji-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.message-emoji-btn i { font-size: 20px; }
.message-emoji-btn.active { color: var(--rb); background: var(--bg-hover); }

/* 絵文字ピッカーラッパー */
.emoji-picker-wrap {
  position: absolute;
  bottom: 60px;
  right: 12px;
  z-index: 100;
  background: #fff;
  border: 0.5px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  overflow: hidden;
}
.repo-emoji-picker {
  width: 320px;
  height: 380px;
  display: block;
  --background: #fff;
  --border-color: transparent;
  --border-radius: 12px;
  --button-active-background: var(--bg-hover);
  --button-hover-background: var(--bg-hover);
  --indicator-color: var(--rb);
  --input-border-color: var(--border-light);
  --input-border-radius: 8px;
  --input-font-size: 13px;
  --input-padding: 6px 10px;
  --num-columns: 8;
  --emoji-size: 1.4rem;
  --category-emoji-size: 1.2rem;
  --category-font-size: 11px;
  --outline-size: 1px;
}

/* Drag&Dropエリア（メッセージエリア） */
.messages.drag-over {
  background: rgba(55, 138, 221, 0.05);
  outline: 2px dashed var(--rbm);
  outline-offset: -8px;
}
.messages.drag-over::before {
  content: 'ここにファイルをドロップ';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: var(--rbd);
  font-size: 14px;
  font-weight: 500;
  background: rgba(255,255,255,0.95);
  padding: 12px 20px;
  border-radius: 10px;
  border: 0.5px solid var(--rbm);
  pointer-events: none;
  z-index: 10;
}

/* メッセージ吹き出し内の添付ファイル */
.msg-attach-image {
  display: block;
  max-width: 280px;
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 12px;
  cursor: pointer;
  background: #eee;
  object-fit: cover;
}

/* 画像サイズが既知の場合のラッパー（aspect-ratioでガタつき防止） */
.msg-attach-image-wrap {
  display: block;
  position: relative;
  max-width: 280px;
  max-height: 280px;
  border-radius: 12px;
  background: #eee;
  overflow: hidden;
  cursor: pointer;
}
.msg-attach-image-wrap .msg-attach-image {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  object-fit: cover;
  max-width: none;
  max-height: none;
}
/* 画像読み込み中のスピナー */
.msg-attach-image-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  margin-left: -16px;
  border: 3px solid rgba(0, 0, 0, 0.15);
  border-top-color: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  animation: msg-attach-spin 0.8s linear infinite;
  pointer-events: none;
}
@keyframes msg-attach-spin {
  to { transform: rotate(360deg); }
}

.msg-attach-video {
  position: relative;
  max-width: 280px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  display: inline-block;
}
.msg-attach-video img {
  display: block;
  max-width: 280px;
  max-height: 280px;
  width: auto;
  height: auto;
}
/* サムネサイズが既知の動画用：ラッパーいっぱいに広げてガタつき防止 */
.msg-attach-video.has-known-size img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
}
.msg-attach-video .video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.2);
}
.msg-attach-video .video-play-overlay i {
  font-size: 48px;
  color: #fff;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.msg-attach-video .video-no-thumb {
  width: 200px;
  height: 120px;
  background: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
}

.msg-attach-audio {
  display: block;
  max-width: 280px;
  width: 280px;
}

.msg-attach-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 0.5px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  min-width: 220px;
  max-width: 280px;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.msg-attach-file:hover { text-decoration: none; }
.msg-group.is-mine .msg-attach-file { background: #DCEDFD; }
.msg-attach-file:hover { background: var(--bg-hover); }
.msg-attach-file-icon {
  width: 36px;
  height: 36px;
  background: var(--rb);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.msg-attach-file-icon i { font-size: 20px; }
.msg-attach-file-info {
  flex: 1;
  min-width: 0;
}
.msg-attach-file-name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-attach-file-size {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.msg-attach-expired {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f5f5f5;
  border: 0.5px solid var(--border-light);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}
.msg-attach-expired i { font-size: 18px; }

/* 添付ファイルの「保存」リンク */
.msg-attach-save {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 0;
  background: transparent;
  color: var(--rb);
  font-size: 11px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  align-self: flex-start;
  transition: color 0.15s;
}
.msg-attach-save:hover { color: var(--rbd); }
.msg-attach-save i { font-size: 13px; }

/* 画像拡大ビューワー */
.image-viewer-overlay,
.video-viewer-overlay {
  background: rgba(0,0,0,0.92);
}
.image-viewer-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
}
.video-viewer-video {
  max-width: 92vw;
  max-height: 88vh;
  background: #000;
  border-radius: 4px;
}
.image-viewer-close,
.image-viewer-download {
  position: absolute;
  top: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 10;
}
.image-viewer-close { right: 16px; }
.image-viewer-download { right: 64px; }
.image-viewer-close:hover,
.image-viewer-download:hover { background: rgba(255,255,255,0.3); }
.image-viewer-close i,
.image-viewer-download i { font-size: 22px; }

/* ファイル送信プレビューモーダル */
.file-preview-modal {
  width: 480px;
  max-width: 100%;
  max-height: 80vh;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
}
.file-preview-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  margin-top: 4px;
  max-height: 50vh;
}
.file-preview-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border-lighter);
}
.file-preview-item:last-child { border-bottom: 0 !important; }
.file-preview-thumb {
  width: 56px;
  height: 56px;
  background: #eee;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.file-preview-thumb img,
.file-preview-thumb canvas { width: 100%; height: 100%; object-fit: cover; }
.file-preview-thumb i {
  font-size: 28px;
  color: var(--text-secondary);
}
.file-preview-thumb .video-play-mini {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  color: #fff;
}
.file-preview-thumb .video-play-mini i { font-size: 20px; color: #fff; }
.file-preview-info {
  flex: 1;
  min-width: 0;
}
.file-preview-name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-preview-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.file-preview-meta.error { color: var(--danger); }
.file-preview-remove {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.file-preview-remove:hover { background: #fdecea; color: var(--danger); }
.file-preview-remove i { font-size: 16px; }
.file-preview-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fdecea;
  border: 0.5px solid #f8c3c1;
  border-radius: 8px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-line;
}
.file-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-light);
}
.file-preview-cancel {
  flex: 1;
  padding: 10px;
  background: #fff;
  border: 0.5px solid #ddd;
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.file-preview-cancel:hover:not(:disabled) { background: var(--bg-hover); }
.file-preview-cancel:disabled { opacity: 0.5; cursor: not-allowed; }
.file-preview-send {
  flex: 1;
  padding: 10px;
  background: var(--rb);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
}
.file-preview-send:hover:not(:disabled) { background: var(--rbd); }
.file-preview-send:disabled { background: #aaa; cursor: not-allowed; }
.file-preview-send-spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}


/* グループアバター画像が設定された時のスタイル */
.av.has-image,
.chat-avatar.has-image {
  background: transparent !important;
  padding: 0;
}
.av.has-image img,
.chat-avatar.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* レスポンシブ */
@media screen and (max-width: 767px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100vw;
  }

  .app {
    flex-direction: column;
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
    width: 100vw;
    max-width: 100vw;
  }

  .sidebar,
  .side-panel,
  .search-box,
  .new-bar,
  .list,
  .s-tabs,
  .s-header {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    box-sizing: border-box;
  }

  .sidebar {
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
    border-right: none;
  }

  .new-btn {
    min-width: 0;
    overflow: hidden;
  }

  .resizer { display: none; }

  .chat-area {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: #fff;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: none;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    height: 100dvh;
  }

  .app.show-chat .chat-area {
    transform: translateX(0);
    display: flex;
  }

  .app.show-chat .sidebar { display: none; }

  .c-back {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* iOS自動拡大防止 */
  .login-input,
  .search-box input,
  .search-id-input,
  .picker-name-input,
  .picker-search input,
  .edit-group-name-input,
  .message-input {
    font-size: 16px;
  }

  .profile-modal {
    width: 100%;
    padding: 24px 20px 16px;
  }
  .profile-qr canvas,
  .profile-qr img {
    width: 180px;
    height: 180px;
  }

  .search-id-modal,
  .qr-scan-modal,
  .confirm-user-modal,
  .picker-modal,
  .members-modal,
  .edit-group-name-modal,
  .readers-modal,
  .file-preview-modal {
    width: 100%;
    padding: 22px 18px 18px;
  }

  .msg-attach-image,
  .msg-attach-image-wrap,
  .msg-attach-video,
  .msg-attach-video img {
    max-width: 240px;
    max-height: 240px;
  }
  .msg-attach-audio { width: 240px; max-width: 240px; }
  .msg-attach-file { max-width: 240px; min-width: 200px; }

  /* 絵文字ピッカー：モバイルではコンパクトかつ画面幅に合わせる */
  .emoji-picker-wrap {
    right: 8px;
    left: 8px;
    bottom: 60px;
  }
  .repo-emoji-picker {
    width: 100%;
    height: 340px;
    --num-columns: 7;
    --emoji-size: 1.3rem;
  }

  /* モバイルでは音声以外の「保存」リンクは非表示
     （画像/動画/PDFはモバイル標準機能で保存可能なため） */
  .msg-attach-wrap .msg-attach-save { display: none; }
  /* 音声のみ保存リンクを表示 */
  .msg-attach-wrap:has(.msg-attach-audio) .msg-attach-save { display: inline-flex; }

  .picker-list {
    max-height: 50vh;
  }
  .members-list {
    max-height: 55vh;
  }
}

/* =====================
   通知設定セクション
   ===================== */
.notification-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notification-loading {
  color: #888;
  font-size: 14px;
  text-align: center;
  padding: 8px;
}
.notification-enable-btn {
  background-color: #185FA5;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.notification-enable-btn:hover {
  background-color: #134d87;
}
.notification-enable-btn:disabled {
  background-color: #999;
  cursor: not-allowed;
}
.notification-enabled {
  color: #2e7d32;
  font-size: 14px;
  text-align: center;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.notification-denied {
  color: #c62828;
  font-size: 13px;
  line-height: 1.5;
  padding: 8px;
  background-color: #ffebee;
  border-radius: 6px;
}
.notification-unsupported {
  color: #888;
  font-size: 13px;
  text-align: center;
  padding: 8px;
}

/* =====================
   ルーム一覧エラーUI
   ===================== */

/* 上部エラーバナー（既存リストがある場合） */
.room-list-error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #ffebee;
  color: #c62828;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid #ffcdd2;
  gap: 8px;
}
.room-list-error-banner .banner-text {
  flex: 1;
  line-height: 1.4;
}
.room-list-error-banner .banner-reload-btn {
  background-color: #c62828;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.room-list-error-banner .banner-reload-btn:hover {
  background-color: #a31515;
}
.room-list-error-banner .banner-reload-btn:disabled {
  background-color: #999;
  cursor: not-allowed;
}

/* 中央エラー画面（初回起動失敗時） */
.room-list-error-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  color: #c62828;
}
.room-list-error-full .error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.room-list-error-full .error-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 12px;
}
.room-list-error-full .error-message {
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
  color: #555;
}
.room-list-error-full .error-reload-btn {
  background-color: #185FA5;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.room-list-error-full .error-reload-btn:hover {
  background-color: #134d87;
}
.room-list-error-full .error-reload-btn:disabled {
  background-color: #999;
  cursor: not-allowed;
}

/* =====================
   タブ競合オーバーレイ（複数タブ防止）
   ===================== */
.tab-conflict-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.tab-conflict-box {
  background-color: #fff;
  border-radius: 12px;
  padding: 40px 32px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.tab-conflict-icon {
  font-size: 56px;
  margin-bottom: 16px;
}
.tab-conflict-title {
  font-size: 18px;
  font-weight: bold;
  color: #185FA5;
  margin-bottom: 16px;
  line-height: 1.4;
}
.tab-conflict-message {
  font-size: 14px;
  color: #555;
  line-height: 1.7;
  margin-bottom: 24px;
}
.tab-conflict-btn {
  background-color: #185FA5;
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 500;
}
.tab-conflict-btn:hover {
  background-color: #134d87;
}
.tab-conflict-btn:disabled {
  background-color: #999;
  cursor: not-allowed;
}
