:root {
  --bg-dark: #1e1f22;
  --bg-surface: #2b2d31;
  --bg-chat: #313338;
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --accent: #5865f2;
  --border: #3f4147;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: sans-serif; }
body { background-color: var(--bg-dark); color: var(--text-normal); display: flex; justify-content: center; align-items: center; height: 100vh; }

.app-shell {
  width: 100%;
  max-width: 600px;
  height: 100vh;
  background-color: var(--bg-chat);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* メイン表示領域（ボトムバーの上のスペース） */
.main-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100% - 60px);
}

/* ボトムナビゲーション用の画面切り替え設定 */
.tab-view {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  display: none;
  flex-direction: column;
}
.tab-view.active { display: flex; }

/* 全画面オーバーレイビュー（トーク画面やQR画面用） */
.overlay-view {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background-color: var(--bg-chat);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.1, 0.76, 0.55, 0.94);
  z-index: 10;
}
.overlay-view.active { transform: translateY(0); }

/* ヘッダー */
.view-header { height: 56px; background-color: var(--bg-surface); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--border); }
.view-title { font-size: 20px; font-weight: bold; }
.room-title { font-weight: bold; font-size: 15px; flex: 1; text-align: center; }
.icon-btn, .back-btn, .call-trigger { background: transparent; border: none; color: var(--text-normal); cursor: pointer; }
.icon-btn { font-size: 18px; padding: 6px; }
.back-btn { font-size: 14px; font-weight: bold; color: var(--text-muted); }
.call-trigger { border: 1px solid var(--accent); padding: 4px 12px; border-radius: 4px; font-size: 12px; }

.view-main { flex: 1; overflow-y: auto; }
.search-box { padding: 12px 16px; }
.search-box input { width: 100%; background-color: var(--bg-dark); border: none; border-radius: 6px; padding: 8px 12px; color: var(--text-normal); outline: none; }

/* トーク・友達リスト共通スタイル */
.chat-list, .friends-list { display: flex; flex-direction: column; }
.chat-item, .friend-item { display: flex; padding: 14px 16px; gap: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.02); cursor: pointer; align-items: center; }
.chat-item:hover, .friend-item:hover { background-color: var(--bg-surface); }
.item-avatar { width: 44px; height: 44px; background-color: var(--accent); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px; }
.item-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.item-upper { display: flex; justify-content: space-between; align-items: baseline; }
.item-name, .friend-name { font-weight: 600; font-size: 15px; }
.item-time { font-size: 11px; color: var(--text-muted); }
.item-lower { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }

.friends-section-title { padding: 16px 16px 4px 16px; font-size: 12px; font-weight: bold; color: var(--text-muted); text-transform: uppercase; }

/* ==========================================
   プロフィール画面用のスタイル
   ========================================== */
.profile-main { padding: 24px; display: flex; flex-direction: column; gap: 24px; align-items: center; }
.profile-card { text-align: center; }
.profile-avatar { width: 80px; height: 80px; background-color: var(--accent); border-radius: 24px; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: bold; margin: 0 auto 12px; }
.profile-name-display { font-size: 20px; font-weight: bold; margin-bottom: 4px; }
.profile-id-display { font-size: 13px; color: var(--text-muted); }

.profile-form { width: 100%; background-color: var(--bg-surface); padding: 20px; border-radius: 8px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: bold; color: var(--text-muted); }
.form-group input { background-color: var(--bg-dark); border: 1px solid var(--border); border-radius: 6px; padding: 10px; color: var(--text-normal); outline: none; font-size: 14px; }
.form-group input[readonly] { opacity: 0.5; cursor: not-allowed; }
.save-btn { background-color: var(--accent); border: none; color: white; padding: 12px; border-radius: 6px; font-weight: bold; cursor: pointer; transition: background 0.2s; }
.save-btn:hover { background-color: #4752c4; }

/* 下部ナビゲーションバー */
.bottom-nav {
  height: 60px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 5;
}
.nav-item {
  background: transparent; border: none;
  color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; width: 33%; height: 100%; justify-content: center;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 20px; }
.nav-label { font-size: 10px; font-weight: bold; }

/* チャットルーム & QR用残余スタイル */
.message-stream { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.msg-row { display: flex; flex-direction: column; align-items: flex-start; }
.msg-row.is-me { border-left: 2px solid var(--accent); padding-left: 8px; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg-user { font-weight: 600; font-size: 14px; }
.msg-time { font-size: 11px; color: var(--text-muted); }
.msg-body { font-size: 14px; color: #e3e5e8; }
.media-block { margin-top: 8px; background-color: var(--bg-surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px; width: 100%; max-width: 320px; }
.media-container { width: 100%; border-radius: 4px; overflow: hidden; background-color: #000; }
.lazy-image { filter: blur(8px); opacity: 0.6; }
.media-container img { width: 100%; height: auto; display: block; }
.max-res-loader { width: 100%; margin-top: 8px; background: transparent; border: 1px solid var(--border); color: var(--text-muted); font-size: 11px; padding: 6px; cursor: pointer; border-radius: 4px; text-align: left; }
.input-area { padding: 16px; background-color: var(--bg-chat); display: flex; gap: 12px; }
.action-trigger { width: 44px; height: 44px; background-color: var(--bg-surface); border: none; color: var(--text-normal); font-size: 20px; border-radius: 8px; cursor: pointer; }
#msg-input { flex: 1; background-color: var(--bg-surface); border: none; border-radius: 8px; padding: 0 16px; color: var(--text-normal); font-size: 14px; outline: none; }
.send-trigger { background-color: var(--accent); border: none; color: white; padding: 0 16px; border-radius: 8px; font-weight: bold; cursor: pointer; }

.qr-main { display: flex; flex-direction: column; align-items: center; padding: 24px; }
.qr-tabs { display: flex; background-color: var(--bg-surface); padding: 4px; border-radius: 8px; margin-bottom: 32px; width: 100%; }
.qr-tab-btn { flex: 1; background: transparent; border: none; color: var(--text-muted); padding: 8px; font-weight: bold; font-size: 14px; cursor: pointer; border-radius: 6px; }
.qr-tab-btn.active { background-color: var(--accent); color: white; }
.qr-section { display: none; width: 100%; flex-direction: column; align-items: center; }
.qr-section.active { display: flex; }
.qr-instruction { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 24px; }
.qr-code-wrapper { background-color: white; padding: 16px; border-radius: 12px; }
.my-id-display { margin-top: 16px; font-size: 14px; color: var(--text-normal); background-color: var(--bg-surface); padding: 6px 16px; border-radius: 20px; }
.scanner-container { width: 100%; max-width: 320px; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; border: 2px solid var(--border); background-color: #000; }
#reader { width: 100% !important; height: 100% !important; border: none !important; }
#reader video { object-fit: cover; }
#reader__dashboard { display: none !important; }