*{box-sizing:border-box}body{margin:0;background:#101114;color:#eee;font-family:system-ui,-apple-system,Segoe UI,sans-serif}.top{height:58px;display:flex;align-items:center;gap:12px;padding:0 16px;background:#17181c;border-bottom:1px solid #292b31;position:sticky;top:0;z-index:5}.top b{margin-right:auto}.top a,.top button,button{background:#2a2d34;color:#fff;border:0;border-radius:9px;padding:9px 13px;text-decoration:none;cursor:pointer}.center{min-height:100vh;display:grid;place-items:center}.card{width:min(430px,92vw);background:#18191d;border:1px solid #2a2c31;border-radius:16px;padding:28px;display:flex;flex-direction:column;gap:12px}.card h1{margin:0}.card input,.admin input,.composer input{background:#0e0f12;border:1px solid #30323a;color:#fff;border-radius:10px;padding:12px;font-size:16px}.card a{color:#aaa;text-align:center}.error{color:#ff7777}.muted,small{color:#999}.chat{max-width:900px;margin:auto;height:calc(100vh - 58px);display:flex;flex-direction:column}.messages{flex:1;overflow:auto;padding:16px}.msg{display:flex;gap:9px;align-items:flex-end;margin:9px 0;max-width:86%}.msg.mine{margin-left:auto;flex-direction:row-reverse}.avatar{width:38px;height:38px;border-radius:50%;object-fit:cover;background:#222;flex:none}.bubble{background:#22252b;border-radius:15px;padding:9px 12px;overflow-wrap:anywhere}.mine .bubble{background:#294764}.meta{font-size:12px;color:#aaa;margin-bottom:3px}.composer{display:flex;gap:8px;padding:12px;border-top:1px solid #292b31;background:#15161a}.composer input{flex:1}.notice{margin:12px;padding:14px;border-radius:12px;background:#472323;text-align:center}.admin{max-width:900px;margin:auto;padding:18px}.admin input{width:100%;margin-bottom:12px}.row{display:flex;align-items:center;gap:12px;padding:10px;margin:8px 0;background:#18191d;border:1px solid #292b31;border-radius:12px;flex-wrap:wrap}.row .info{display:flex;flex-direction:column;min-width:140px}.actions{margin-left:auto;display:flex;gap:6px;flex-wrap:wrap}.profilebox{display:flex;gap:15px;align-items:center}.bigavatar{width:96px;height:96px;border-radius:50%;object-fit:cover}
/* =========================
   メッセージメニュー
========================= */

.msg {
  position: relative;
}


/* 3点メニュー本体 */
.message-menu {
  position: relative;
  flex: 0 0 auto;

  display: flex;
  align-items: center;

  height: 100%;
}


/* 3点ボタン */
.menu-dots {
  width: 24px;
  height: 30px;

  padding: 0;
  border: 0;
  background: transparent;

  color: inherit;
  font-size: 19px;
  line-height: 1;

  cursor: pointer;

  opacity: 0;

  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}


/* PC：メッセージにホバーしたら表示 */
.msg:hover .menu-dots {
  opacity: 0.55;
}


/* 3点自身にホバー */
.menu-dots:hover {
  opacity: 1;
  transform: scale(1.1);
}


/* =========================
   自分のメッセージ
   バブルの左側に3点
========================= */

.msg.mine {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
}


/* 自分の場合：
   avatar → bubble → menu
   に見えるように調整 */

.msg.mine .message-menu {
  margin-right: 4px;
  margin-left: 0;
}


/* =========================
   他人のメッセージ
   バブルの右側に3点
========================= */

.msg:not(.mine) .message-menu {
  margin-left: 4px;
}


/* =========================
   ポップアップ
========================= */

.menu-popup {
  position: absolute;

  top: 50%;
  transform: translateY(-50%);

  display: none;

  min-width: 70px;

  padding: 4px;

  background: white;

  border: 1px solid #ddd;
  border-radius: 8px;

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

  z-index: 50;
}


/* 相手側：3点の右側に表示 */
.msg:not(.mine) .menu-popup {
  left: 28px;
}


/* 自分側：3点の左側に表示 */
.msg.mine .menu-popup {
  right: 28px;
}


/* 開いた状態 */
.menu-popup.open {
  display: block;
}


/* 削除ボタン */
.delete-message {
  width: 100%;

  padding: 7px 10px;

  border: 0;
  border-radius: 6px;

  background: transparent;

  color: #d33;

  cursor: pointer;

  text-align: left;
  white-space: nowrap;
}


.delete-message:hover {
  background: #f5f5f5;
}


/* =========================
   タッチ端末
========================= */

@media (hover: none) {

  .menu-dots {
    opacity: 0.45;
  }

}
.system-message {
  width: 100%;
  text-align: center;
  color: #e53935;
  font-size: 13px;
  margin: 10px 0;
  padding: 3px 10px;
  box-sizing: border-box;
}
/* =========================
   STEP 15.2
   チャット + オンライン一覧
========================= */

.chat-layout {
  width: min(1100px, 100%);
  height: calc(100vh - 58px);
  margin: 0 auto;

  display: grid;

  /*
   * 左：チャット
   * 右：オンライン
   *
   * 画面が狭くなっても
   * 右側を維持する
   */
  grid-template-columns:
    minmax(0, 1fr)
    clamp(120px, 22vw, 220px);

  gap: 8px;

  padding: 0 8px;
}


/* =========================
   チャット本体
========================= */

.chat {
  width: 100%;
  max-width: none;
  margin: 0;

  height: 100%;

  min-width: 0;

  display: flex;
  flex-direction: column;

  background: transparent;
}


/* =========================
   オンラインパネル
========================= */

.online-panel {
  min-width: 0;
  min-height: 0;

  height: 100%;

  display: flex;
  flex-direction: column;

  background: #17181c;

  border-left: 1px solid #292b31;
}


/* =========================
   オンライン見出し
========================= */

.online-header {
  height: 48px;

  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 12px;

  border-bottom: 1px solid #292b31;

  font-size: 14px;
  font-weight: 600;
}

.online-header span:last-child {
  color: #999;
  font-size: 12px;
}


/* =========================
   オンラインユーザー一覧
========================= */

.online-users {
  flex: 1;

  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 8px;
}


/* =========================
   ユーザー1人
========================= */

.online-user {
  display: flex;
  align-items: center;

  gap: 8px;

  width: 100%;

  padding: 7px 5px;

  border-radius: 9px;

  min-width: 0;
}


/* =========================
   Avatar
========================= */

.online-avatar {
  width: 32px;
  height: 32px;

  flex: 0 0 32px;

  border-radius: 50%;

  object-fit: cover;

  background: #222;
}


/* =========================
   名前
========================= */

.online-name {
  min-width: 0;

  overflow: hidden;

  text-overflow: ellipsis;

  white-space: nowrap;

  font-size: 13px;
}


/* =========================
   誰もいない場合
========================= */

.online-empty {
  padding: 12px 5px;

  color: #888;

  font-size: 12px;

  text-align: center;

  line-height: 1.5;
}


/* =========================
   スクロールバー
========================= */

.online-users::-webkit-scrollbar {
  width: 6px;
}

.online-users::-webkit-scrollbar-thumb {
  background: #353840;
  border-radius: 10px;
}

.online-users::-webkit-scrollbar-track {
  background: transparent;
}


/* =========================
   狭い画面
========================= */

@media (max-width: 600px) {

  .chat-layout {
    /*
     * オンライン欄をさらに細くする
     * それでも右側を維持
     */
    grid-template-columns:
      minmax(0, 1fr)
      120px;

    gap: 5px;

    padding: 0 4px;
  }


  .online-panel {
    border-left: 1px solid #292b31;
  }


  .online-header {
    padding: 0 8px;

    font-size: 12px;
  }


  .online-users {
    padding: 5px;
  }


  .online-user {
    gap: 5px;
    padding: 6px 2px;
  }


  .online-avatar {
    width: 28px;
    height: 28px;

    flex-basis: 28px;
  }


  .online-name {
    font-size: 12px;
  }


  .messages {
    padding: 10px;
  }

}


/* =========================
   かなり狭いスマホ
========================= */

@media (max-width: 380px) {

  .chat-layout {
    grid-template-columns:
      minmax(0, 1fr)
      108px;
  }


  .online-avatar {
    width: 26px;
    height: 26px;

    flex-basis: 26px;
  }


  .online-name {
    font-size: 11px;
  }

}
/* =========================
   STEP 15.2
   レイアウトを画面に固定
========================= */

html,
body {
  height: 100%;
  overflow: hidden;
}


.chat-layout {
  height: calc(100vh - 58px);
  overflow: hidden;
}


/* =========================
   左側だけスクロール
========================= */

.chat {
  min-height: 0;
}


.messages {
  min-height: 0;
  overflow-y: auto;
}


/* =========================
   右側は常に画面内
========================= */

.online-panel {
  min-height: 0;
  overflow: hidden;
}


.online-users {
  min-height: 0;
  overflow-y: auto;
}
/* =========================
   STEP 15.3
   権限バッジ
========================= */

.avatar-wrap {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.avatar-wrap .avatar {
  width: 38px;
  height: 38px;
}

.role-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;

  width: 15px;
  height: 15px;

  border-radius: 50%;
  border: 2px solid #101114;

  box-sizing: border-box;
}

.role-dot.owner {
  background: #ffd43b;
}

.role-dot.manager {
  background: #ff922b;
}

.role-dot.user {
  background: #51cf66;
}
.role-dot.moderator {
  background: #0117be;
}

.role-dot.regular {
  background: #74c0fc;
}

.role-dot.guest {
  background: #51cf66;
}


/* オンライン欄 */

.online-avatar-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
}

.online-avatar-wrap .online-avatar {
  width: 32px;
  height: 32px;
}

.online-role-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;

  width: 15px;
  height: 15px;

  border-radius: 50%;
  border: 2px solid #17181c;

  box-sizing: border-box;
}

.online-role-dot.owner {
  background: #ffd43b;
}

.online-role-dot.manager {
  background: #ff922b;
}

.online-role-dot.user {
  background: #51cf66;
}
.online-role-dot.moderator {
   background: #0117be;
}

.online-role-dot.regular {
  background: #74c0fc;
}

.online-role-dot.guest {
  background: #51cf66;
}
/* =========================
   STEP 15.3
   iPad / Safari viewport対策
========================= */

html,
body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

.top {
  flex: 0 0 58px;
}

.chat-layout {
  height: calc(100vh - 58px);
  height: calc(100dvh - 58px);
  min-height: 0;
  overflow: hidden;
}

.chat {
  min-height: 0;
  height: 100%;
}

.messages {
  min-height: 0;
  overflow-y: auto;
}

.composer {
  flex: 0 0 auto;
}
/* =========================
   STEP 15.3
   Visual Viewport高さ
========================= */

.chat-layout {
  height: calc(var(--app-height, 100vh) - 58px);
}
/* =========================
   STEP 16.3
   iPad / Safari composer fix
========================= */


.messages {
  padding-bottom: 80px;
}
/* =========================
   STEP 16.3
   iPad / Safari layout fix
========================= */

.chat-layout {
  position: fixed;
  top: 58px;
  left: 0;
  right: 0;
  bottom: 0;

  height: auto;
  margin: 0 auto;
}

.chat {
  position: relative;
  min-height: 0;
  height: 100%;
}

.composer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;

  width: 100%;
  margin: 0;

  z-index: 20;
}

.messages {
  min-height: 0;
  padding-bottom: 80px;
}
 /* =========================
    STEP 18 - Profile Popover
 ========================= */

.profile-popover {
  position: fixed;
  width: 240px;
  padding: 16px;
  background: #17181c;
  border: 1px solid #292b31;
  border-radius: 14px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45);
  z-index: 1000;
  box-sizing: border-box;
}

.profile-popover-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.profile-popover-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: #222;
}

.profile-popover-name {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  word-break: break-word;
}

.profile-popover-username {
  margin-top: 3px;
  text-align: center;
  color: #999;
  font-size: 13px;
  word-break: break-word;
}

.profile-popover-role {
  margin-top: 8px;
  text-align: center;
  color: #aaa;
  font-size: 12px;
}

.profile-popover-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.profile-popover-actions button {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: #25272d;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}

.profile-popover-actions button:hover {
  background: #30333a;
}
.dm-layout {
  width: min(1100px, 100%);
  height: calc(100vh - 58px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 8px;
  padding: 0 8px;
  box-sizing: border-box;
}

.dm-list,
.dm-chat {
  min-height: 0;
}

.dm-list {
  overflow: hidden;
}

.dm-chat {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#dm-content {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}


.dm-composer {
  flex: 0 0 auto;
}


.dm-thread-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.dm-thread-item:hover {
  background: #22242a;
}

.dm-thread-avatar-wrap {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.dm-thread-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #222;
}

.dm-thread-info {
  min-width: 0;
  flex: 1;
}

.dm-thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dm-thread-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-thread-last {
  margin-top: 3px;
  font-size: 12px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-thread-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e03131;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
/* いろんな既存CSS */

/* 最後に追加 */
.chat-layout {
  grid-template-columns: 220px minmax(0, 1fr) clamp(120px, 22vw, 220px);
}
.chat {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#main-chat-view {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#dm-chat-view[hidden] {
  display: none !important;
}
#dm-chat-view:not([hidden]) {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#dm-header {
  flex: 0 0 auto;
  box-sizing: border-box;
}

#dm-messages {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  box-sizing: border-box;
}

#dm-form {
  flex: 0 0 auto;
}

.dm-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 8px 12px;
  background: #17181c;
  border-bottom: 1px solid #292b31;
}

.dm-back-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.dm-back-button:hover {
  background: #25272d;
}

.dm-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dm-header-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #222;
}

.dm-header-info {
  min-width: 0;
}

.dm-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-header-username {
  margin-top: 2px;
  font-size: 12px;
  color: #999;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* =========================================================
   DM FINAL UI
   Main Chat と統一するための最終上書き
========================================================= */

/* ---------- DM全体 ---------- */

#dm-chat-view {
  min-height: 0;
}

#dm-chat-view:not([hidden]) {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}


/* ---------- DMヘッダー ---------- */

#dm-header {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  gap: 10px;

  min-height: 64px;
  padding: 8px 12px;

  background: #17181c;
  border-bottom: 1px solid #292b31;

  box-sizing: border-box;
}

.dm-back-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;

  border: 0;
  border-radius: 8px;

  background: transparent;
  color: #fff;

  font-size: 22px;
  cursor: pointer;
}

.dm-back-button:hover {
  background: #25272d;
}

.dm-header-profile {
  display: flex;
  align-items: center;
  gap: 10px;

  min-width: 0;
}

.dm-header-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;

  border-radius: 50%;
  object-fit: cover;

  background: #222;
}

.dm-header-info {
  min-width: 0;
}

.dm-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-header-username {
  margin-top: 2px;

  font-size: 12px;
  color: #999;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ---------- DM入力欄 ---------- */

#dm-form {
  display: flex;
  gap: 8px;

  flex: 0 0 auto;

  padding: 12px;

  border-top: 1px solid #292b31;

  background: #15161a;

  box-sizing: border-box;
}

#dm-form input {
  flex: 1;

  min-width: 0;

  background: #0e0f12;
  border: 1px solid #30323a;

  color: #fff;

  border-radius: 10px;

  padding: 12px;

  font-size: 16px;

  outline: none;
}

#dm-form input:focus {
  border-color: #4b5563;
}

#dm-form button {
  flex: 0 0 auto;

  background: #2a2d34;
  color: #fff;

  border: 0;
  border-radius: 9px;

  padding: 9px 13px;

  cursor: pointer;
}

#dm-form button:hover {
  background: #343740;
}


/* ---------- 左側DM一覧 ---------- */

.dm-list {
  min-height: 0;
  overflow: hidden;

  background: #15161a;

  border: 1px solid #292b31;
  border-radius: 10px;
}

.dm-thread-item {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px;

  border-radius: 10px;

  cursor: pointer;

  box-sizing: border-box;
}

.dm-thread-item:hover {
  background: #22242a;
}

.dm-thread-avatar-wrap {
  width: 42px;
  height: 42px;

  flex: 0 0 42px;
}

.dm-thread-avatar {
  width: 42px;
  height: 42px;

  border-radius: 50%;

  object-fit: cover;

  background: #222;
}

.dm-thread-info {
  min-width: 0;
  flex: 1;
}

.dm-thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 8px;
}

.dm-thread-name {
  min-width: 0;

  font-size: 14px;
  font-weight: 600;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-thread-last {
  margin-top: 3px;

  font-size: 12px;
  color: #999;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dm-thread-unread {
  min-width: 18px;
  height: 18px;

  padding: 0 5px;

  border-radius: 999px;

  background: #e03131;
  color: #fff;

  font-size: 11px;
  font-weight: 700;

  display: flex;
  align-items: center;
  justify-content: center;

  box-sizing: border-box;
}

/* =========================================================
   DM MESSAGE FINAL
========================================================= */
.dm-message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: fit-content;
  max-width: 86%;
  margin: 9px 0;
}

.dm-message.mine {
  margin-left: auto;
  flex-direction: row-reverse;
}

.dm-message-avatar-wrap {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.dm-message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}





.dm-message-seen {
  margin-top: 3px;
  font-size: 11px;
  color: #999;
  text-align: right;
}

.dm-message-seen {
  text-align: right;
  line-height: 1;
  margin-top: 2px;
}

#dm-messages .dm-message-seen {
  margin: 1px 0 0 0;
  padding: 0;
  line-height: 1;
}
#dm-messages .dm-message-content {
  min-width: 0;
  width: fit-content;
  max-width: 100%;
}


#dm-messages .dm-message-seen {
  margin-top: 2px;
  padding: 0;
  text-align: right;
  line-height: 1;
  font-size: 11px;
  color: #999;
}
#dm-messages {
  padding: 16px;
}
.menu-popup {
  padding: 4px !important;
}

.menu-popup button {
  padding: 6px 9px !important;
  font-size: 12px !important;
  line-height: 1.2 !important;
  min-height: 0 !important;
}
.menu-popup {
  width: fit-content !important;
  min-width: 0 !important;
  padding: 4px !important;
}

.menu-popup button {
  display: block !important;
  width: 100% !important;
  white-space: nowrap;
}


#cancel-reply {
  flex: 0 0 auto;
  padding: 3px 7px;
  font-size: 16px;
}
.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.composer-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.composer-row input {
  flex: 1;
}
#reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 2px 4px;
  margin-bottom: 2px;
  background: rgba(34, 37, 43, 0.35);
  border-left: 2px solid rgba(255, 255, 255, 0.25);
  box-sizing: border-box;
}

#reply-preview[hidden] {
  display: none !important;
}

.reply-preview-text {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#cancel-reply {
  flex: 0 0 auto;
  padding: 1px 5px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(34, 37, 43, 0.35);
}
.composer {
  background: linear-gradient(
    to bottom,
    transparent 0,
    transparent var(--reply-height, 0px),
    #15161a var(--reply-height, 0px),
    #15161a 100%
  );
}
.composer-row {
  display: flex;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
#reply-preview {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  width: 100%;
  box-sizing: border-box;
}
.reply-quote {
  margin-bottom: 7px;
  padding: 6px 9px;
  border-left: 3px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.16);
  max-width: 100%;
  overflow: hidden;
}

.reply-quote-name {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.68);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-quote-text {
  font-size: 11px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-quote {
  cursor: pointer;
  transition: background 0.15s ease;
}

.reply-quote:hover {
  background: rgba(255, 255, 255, 0.08);
}
.reply-highlight {
  outline: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  transition: outline 0.2s ease;
}
.dm-message {
  position: relative;
}


.dm-menu-dots {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: transparent !important;
  color: rgba(255, 255, 255, 0.55);
  border-radius: 7px;
}

.dm-menu-dots:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

.dm-menu-popup {
  position: absolute;
  right: 0;
  bottom: 32px;
  display: none;
  width: fit-content;
  min-width: 0;
  padding: 4px;
  background: #292c33;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.dm-menu-popup.open {
  display: block;
}

.dm-menu-popup button {
  display: block;
  width: 100%;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.2;
  min-height: 0;
  white-space: nowrap;
  background: transparent;
  border-radius: 5px;
}

.dm-menu-popup button:hover {
  background: rgba(255, 255, 255, 0.08);
}
#dm-messages {
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 90px;
  box-sizing: border-box;
}
.dm-message-menu {
  position: absolute;
  right: -34px;
  bottom: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.dm-message-menu {
  position: absolute;
  right: -34px;
  bottom: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.dm-message:hover .dm-message-menu,
.dm-message-menu.open {
  opacity: 1;
  pointer-events: auto;
}
.dm-message,
.dm-message-content {
  overflow: visible !important;
}

.dm-message-menu {
  position: absolute;
  right: -34px;
  bottom: 5px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}


.dm-menu-dots {
  position: relative;
  z-index: 101;
}
.dm-message-menu {
  position: absolute;
  right: -34px;
  bottom: 5px;
  width: 28px;
  height: 28px;
  z-index: 100;
  opacity: 0;
  pointer-events: auto;
}

.dm-message-menu:hover,
.dm-message-menu.open {
  opacity: 1;
}
#dm-reply-preview {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
}
#dm-reply-preview {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  width: 100%;
  box-sizing: border-box;

  display: flex;
  align-items: center;
  gap: 8px;

  padding: 2px 4px;
  margin-bottom: 2px;

  background: transparent !important;

  border-left: 2px solid rgba(255, 255, 255, 0.25);
}

#dm-reply-preview[hidden] {
  display: none !important;
}

#dm-reply-preview .reply-preview-text {
  flex: 1;
  min-width: 0;

  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#dm-cancel-reply {
  flex: 0 0 auto;

  padding: 1px 5px;

  font-size: 15px;
  color: rgba(255, 255, 255, 0.5);

  background: rgba(34, 37, 43, 0.35);
}
/* =========================
   STEP 20.2
   入力中アニメーション（修正版）
========================= */

/* 元の位置・サイズを維持する */
.online-role-dot {
  position: absolute;
  transition:
    width 0.2s ease,
    height 0.2s ease,
    border-radius 0.2s ease;
  box-sizing: border-box;
}

/* 入力中は右下の位置を維持して横長にする */
.online-role-dot.is-typing {
  width: 25px;
  height: 12px;
  right: -2px;
  bottom: -2px;
  border-radius: 999px;
}

/* 3つの点を中央に配置 */
.online-role-dot.is-typing::before {
  content: "";
  position: absolute;
  left: 2.5px;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #333;
  box-shadow:
    6px 0 #888,
    12px 0 #ccc;
  transform: translateY(-50%);
  animation: typingDots 1s infinite ease-in-out;
}

@keyframes typingDots {
  0%, 60%, 100% {
    opacity: 0.5;
    transform: translateY(-50%);
  }

  30% {
    opacity: 1;
    transform: translateY(calc(-50% - 2px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .online-role-dot {
    transition: none;
  }

  .online-role-dot.is-typing::before {
    animation: none;
  }
}/* Main chat reconnect status */
.chat-reconnect-status {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 999999;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  width: max-content;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  padding: 14px 20px;

  color: #fff;
  background: #222;
  border: 1px solid #666;
  border-radius: 12px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);

  font-size: 14px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.chat-reconnect-status[hidden] {
  display: none;
}

.chat-reconnect-status.is-visible {
  opacity: 1;
  visibility: visible;
}

.chat-reconnect-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: chatReconnectSpin 1s linear infinite;
}

.chat-reconnect-dots::after {
  content: "";
  display: inline-block;
  width: 18px;
  animation: chatReconnectDots 1.2s steps(4, end) infinite;
}

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

@keyframes chatReconnectDots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-reconnect-spinner,
  .chat-reconnect-dots::after {
    animation: none;
  }

  .chat-reconnect-status {
    transition: none;
  }
}

.chat-reconnect-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: chatReconnectSpin 0.75s linear infinite;
}

.chat-reconnect-dots::after {
  content: "";
  display: inline-block;
  width: 18px;
  text-align: left;
  animation: chatReconnectDots 1.2s steps(4, end) infinite;
}

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

@keyframes chatReconnectDots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-reconnect-spinner,
  .chat-reconnect-dots::after {
    animation: none;
  }

  .chat-reconnect-status {
    transition: none;
  }
}
#sticker-picker {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--background, #fff);
}

#sticker-picker[hidden] {
  display: none;
}

#sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
}

.sticker-option {
  min-width: 0;
  min-height: 70px;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.sticker-option img {
  display: block;
  width: 100%;
  height: 70px;
  object-fit: contain;
}

.message-sticker {
  display: block;
  max-width: 160px;
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.message-sticker {
  display: block;
  width: auto;
  height: auto;
  max-width: 180px;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
}
.msg:has(.message-sticker) .bubble {
  width: fit-content;
  max-width: min(280px, 75vw);
}

.message-sticker {
  display: block;
  width: auto;
  height: auto;
  max-width: min(220px, 65vw);
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
}
.selected-sticker-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}

.selected-sticker-preview[hidden] {
  display: none;
}

.selected-sticker-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100px;
  max-height: 100px;
  object-fit: contain;
}

.selected-sticker-preview button {
  cursor: pointer;
}
/* スタンプだけのメッセージは吹き出しを透明にする */
/* .msg.sticker-only .bubble {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
} */

/* スタンプ自体の余白を抑える */
.msg.sticker-only .message-sticker {
  display: block;
  margin: 0;
}
.profile-action-divider {
  border: 0;
  border-top: 1px solid #3a3d46;
  margin: 8px 0;
}

#profile-popover-actions button {
  display: block;
  width: 100%;
  margin-top: 6px;
  cursor: pointer;
}

#profile-popover-actions .profile-danger-button {
  color: #ff7777;
}

/* Profile Popover — Compact UI */
#profile-popover {
  width: 220px;
  max-width: calc(100vw - 20px);
  padding: 12px;
  box-sizing: border-box;
  border-radius: 12px;
}

#profile-popover-avatar {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

#profile-popover-name {
  font-size: 15px;
  line-height: 1.3;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

#profile-popover-username {
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

#profile-popover-role {
  font-size: 11px;
  line-height: 1.3;
}

#profile-popover-actions {
  margin-top: 8px;
}

#profile-popover-actions button {
  min-height: 32px;
  padding: 6px 9px;
  margin-top: 5px;
  font-size: 12px;
  border-radius: 7px;
}

#profile-popover-actions .profile-action-divider {
  margin: 7px 0;
}

.brand {
display: inline-flex;
align-items: center;
gap: 8px;
}

#app-version {
font-size: 11px;
font-weight: 500;
color: #aeb8c8;
opacity: 0.85;
padding: 2px 6px;
border: 1px solid rgba(174, 184, 200, 0.25);
border-radius: 5px;
letter-spacing: 0.3px;
}
.message-sticker {
  width: 160px;
  height: 160px;
  object-fit: contain;
  display: block;
}
/* Main Chat: 入力欄の上でスクロール領域を止める */
#main-chat-view {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#main-chat-view .messages {
  flex: 1 1 auto;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  box-sizing: border-box;
  padding-bottom: 16px;
}

#main-chat-view .composer {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  flex: 0 0 auto;
  width: 100%;
  z-index: 20;
}
/* Main Chat: メッセージ欄と送信欄を完全に分離 */
#main-chat-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#main-chat-view #notice {
  flex: 0 0 auto;
}

#main-chat-view #messages {
  position: relative;
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 16px;
  box-sizing: border-box;
}

#main-chat-view #chatReconnectStatus {
  position: relative;
  flex: 0 0 auto;
}

#main-chat-view .composer {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  z-index: 20;
}
header.top a.brand {
  color: white !important;
  text-decoration: none !important;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  cursor: pointer;
}

header.top a.brand:hover,
header.top a.brand:focus,
header.top a.brand:active {
  color: white !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: none !important;
}
header.top {
  display: flex;
  align-items: center;
  width: 100%;
}

header.top .brand {
  margin-right: auto !important;
  flex-shrink: 0;
}

header.top #me,
header.top a:not(.brand),
header.top button {
  
  flex-shrink: 0;
}
header.top #me,
header.top a:not(.brand),
header.top button {
  margin-left: 1px;
}

header.top .brand {
  font-weight: 700;
}
/* Mobile sidebar controls */
.mobile-chat-controls,
.mobile-sidebar-backdrop {
  display: none;
}

@media (max-width: 760px) {
  .chat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    top: 58px;
    bottom: 0;
    width: 100%;
    max-width: none;
    padding: 0;
    gap: 0;
    overflow: hidden;
  }

  .chat {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .mobile-chat-controls {
    display: flex;
    position: absolute;
    top: 6px;
    left: 8px;
    right: 8px;
    z-index: 20;
    justify-content: space-between;
    pointer-events: none;
  }

  .mobile-chat-controls button {
    pointer-events: auto;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid var(--border-color, #555);
    border-radius: 8px;
    background: var(--panel-bg, #252525);
    color: inherit;
    cursor: pointer;
  }

  .chat {
    padding-top: 44px;
  }

  .dm-list,
  .online-panel {
    display: flex;
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 30;
    width: min(280px, 85vw);
    max-width: 85vw;
    height: 100%;
    margin: 0;
    background: var(--panel-bg, #252525);
    transition: transform 0.2s ease;
    overflow: hidden;
  }

  .dm-list {
    left: 0;
    transform: translateX(-105%);
  }

  .online-panel {
    right: 0;
    transform: translateX(105%);
  }

  .dm-list.mobile-open {
    transform: translateX(0);
  }

  .online-panel.mobile-open {
    transform: translateX(0);
  }

  .mobile-sidebar-backdrop:not([hidden]) {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.45);
  }
}

@media (max-width: 380px) {
  .mobile-chat-controls button {
    min-height: 34px;
    padding: 5px 9px;
    font-size: 12px;
  }
}
/* =========================
   Main Chat History Loader
========================= */

.main-history-loader {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 14px 10px;
  color: #aaa;
  font-size: 13px;
}

.main-history-loader[hidden] {
  display: none;
}

.main-history-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #aaa;
  border-radius: 50%;
  animation: mainHistorySpin 0.8s linear infinite;
}

@keyframes mainHistorySpin {
  to {
    transform: rotate(360deg);
  }
}
.card label {
display: block;
margin-top: 14px;
margin-bottom: 6px;
text-align: left;
font-weight: 600;
}

.card small {
display: block;
margin-top: 5px;
text-align: left;
opacity: 0.7;
}

.password-field {
display: flex;
align-items: stretch;
gap: 6px;
width: 100%;
}

.password-field input {
flex: 1;
min-width: 0;
}

.toggle-password {
width: auto;
min-width: 58px;
padding: 0 10px;
}

.switch-page {
margin-top: 20px;
line-height: 1.8;
}

.error {
white-space: normal;
overflow-wrap: anywhere;
}

#go:disabled {
opacity: 0.6;
cursor: wait;
}
.ban-stats {
  margin-bottom: 30px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 15px 0;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--border, #444);
  border-radius: 10px;
  background: var(--card, #222);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card small {
  opacity: 0.75;
}

.stat-card b {
  font-size: 25px;
}

@media (min-width: 650px) {
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #101114;
  color: #e5e7eb;
}

.app-loading-bar {
  position: relative;
  width: min(320px, 70vw);
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.app-loading-bar::before {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4dabf7, #74c0fc);
  animation: app-loading-slide 1.1s ease-in-out infinite;
}

.app-loading-text {
  font-size: 14px;
  color: #9ca3af;
}

.app-loading.is-hidden {
  display: none;
}

@keyframes app-loading-slide {
  0%   { left: -40%; }
  100% { left: 100%; }
}
.mobile-dm-unread {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e03131;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
  pointer-events: none;
}

#mobile-dm-toggle {
  position: relative;
}
@media (max-width: 760px) {
  header.top {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  header.top::-webkit-scrollbar {
    display: none;
  }

  header.top > * {
    flex-shrink: 0;
  }
}
.reply-quote-text,
.reply-preview-text,
.dm-message .reply-quote-text,
#dm-reply-preview .reply-preview-text {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  overflow: hidden;
}

.reply-quote {
  max-width: 100%;
  overflow: hidden;
}
.dm-list-header {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #e5e7eb;
  border-bottom: 1px solid #292b31;
}

#dm-threads {
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.dm-list {
  display: flex;
  flex-direction: column;
}

.dm-thread-item + .dm-thread-item {
  margin-top: 2px;
}

.dm-thread-item.active {
  background: #22242a;
}
.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 90000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.welcome-modal[hidden] {
  display: none;
}

.welcome-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.welcome-modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: min(82vh, 640px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: #17181c;
  color: #e6e7ea;
  border: 1px solid #2a2c31;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.welcome-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #9ca3af;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.welcome-modal-close:hover {
  background: #23252b;
  color: #e6e7ea;
}

.welcome-modal-body {
  padding: 26px 26px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.welcome-modal-body h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: #f1f2f4;
}

.welcome-modal-body h2 {
  margin: 22px 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: #9ca3af;
  letter-spacing: 0.04em;
}

.welcome-modal-body p {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.75;
  color: #c9ccd2;
}

.welcome-modal-body ul {
  margin: 6px 0;
  padding-left: 18px;
}

.welcome-modal-body li {
  margin: 5px 0;
  font-size: 14px;
  line-height: 1.7;
  color: #c9ccd2;
}

.welcome-modal-body li::marker {
  color: #4dabf7;
}

.welcome-version-notice {
  margin: 10px 0 2px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #1d2026;
  border-left: 3px solid #4dabf7;
  color: #a5d8ff;
  font-size: 13px;
}
.welcome-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #26282e;
}

.welcome-detail-button {
  padding: 6px 14px;
  font-size: 13px;
  color: #a5d8ff;
  background: #1d2026;
  border: 1px solid #2f3a47;
  border-radius: 6px;
  cursor: pointer;
}

.welcome-detail-button:hover {
  background: #232833;
  border-color: #3d5166;
}

.welcome-modal-site-version {
  font-size: 12px;
  color: #6b7280;
}