:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel2: #fbfcff;
  --text: #0d1320;
  --muted: #5b6b7f;
  --border: rgba(13,19,32,.10);
  --shadow: 0 18px 45px rgba(18, 25, 40, .12);

  --inputBg: #ffffff;
  --inputBorder: rgba(13,19,32,.16);

  --msgBg: rgba(13,19,32,.045);
  --msgBorder: rgba(13,19,32,.08);

  --btnBg: rgba(13,19,32,.06);
  --btnBgHover: rgba(13,19,32,.10);

  --warnBg: rgba(255, 180, 0, .10);
  --warnBorder: rgba(255, 180, 0, .25);

  --systemCenterBg: rgba(0,0,0,.55);
  --systemCenterText: #ffffff;
}
:root[data-theme="dark"]{
  --bg: #0b0f1a;
  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.04);
  --text: #eef0fc;
  --muted: rgba(233,238,252,0.72);
  --border: rgba(255,255,255,0.12);
  --shadow: 0 20px 60px rgba(0,0,0,0.45);

  --inputBg: rgba(0,0,0,0.25);
  --inputBorder: rgba(255,255,255,0.14);

  --msgBg: rgba(0,0,0,0.26);
  --msgBorder: rgba(255,255,255,0.10);

  --btnBg: rgba(255,255,255,0.08);
  --btnBgHover: rgba(255,255,255,0.12);

  --warnBg: rgba(255, 200, 0, .10);
  --warnBorder: rgba(255, 200, 0, .22);

  --systemCenterBg: rgba(0,0,0,.62);
  --systemCenterText: #ffffff;
}
*{ box-sizing:border-box; }
html, body{ height:100%; }

body{
  margin:0;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans JP",sans-serif;
  background:var(--bg);
  color:var(--text);
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:12px;
}
a{ color:inherit; }

.app{
  width:min(1180px, 98vw);
  height:min(820px, 94vh);
  display:flex;
  gap:12px;
}
.sidebar{
  width:270px;
  border-radius:18px;
  background:linear-gradient(180deg, var(--panel), var(--panel2));
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:10px;
  min-width:0;
  overflow:auto;
}
.titleRow{
  display:flex;
  align-items:flex-start;
  justify-content:flex-start;
  gap:10px;
}
.titleBlock{ min-width:0; }
h1{
  margin:0;
  font-size:26px;
  line-height:1.2;
  letter-spacing:.01em;
}
.sub{
  margin:7px 0 0;
  color:var(--muted);
  font-size:13px;
  line-height:1.55;
}
.btn, .smallBtn{
  border:1px solid var(--border);
  background:var(--btnBg);
  color:var(--text);
  border-radius:12px;
  padding:9px 12px;
  cursor:pointer;
  font-size:13px;
  white-space:nowrap;
  transition:all .15s ease;
}
.btn:hover, .smallBtn:hover{
  background:var(--btnBgHover);
  transform:translateY(-1px);
}
.backBtn{
  width:100%;
  text-align:center;
}
.settingsWrap{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.settingsToggle{
  width:100%;
}
.settingsBox{
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.settingsBox.hidden{
  display:none;
}
.settingsTitle{
  font-size:12px;
  font-weight:800;
  color:var(--muted);
  letter-spacing:.02em;
  margin-bottom:2px;
}
.settingsRow{
  display:flex;
  flex-direction:column;
  gap:5px;
}
.settingsLabel{
  font-size:12px;
  color:var(--muted);
  line-height:1.3;
}
.select, .textInput{
  width:100%;
  border:1px solid var(--inputBorder);
  background:var(--inputBg);
  color:var(--text);
  border-radius:12px;
  padding:9px 11px;
  font-size:14px;
  outline:none;
}
.settingsInline{
  display:flex;
  gap:8px;
  align-items:center;
}
.settingsInline .select,
.settingsInline .textInput{
  flex:1;
  min-width:0;
}
.meInline{
  font-size:13px;
  color:var(--muted);
  line-height:1.4;
}
.meInline b{
  color:var(--text);
}
.settingsBottom{
  margin-top:2px;
  padding-top:2px;
}

.chat{
  flex:1;
  min-width:0;
  border-radius:18px;
  background:linear-gradient(180deg, var(--panel), var(--panel2));
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height:0;
  position:relative;
}
.chatHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  gap:12px;
}
.chatHeaderLeft{ min-width:0; }
.roomName{
  font-weight:900;
  font-size:15px;
}
.hint{
  font-size:12px;
  color:var(--muted);
  text-align:right;
}
.topStatus{
  padding:10px 16px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,0.03);
  display:flex;
  align-items:center;
  gap:14px;
  font-size:13px;
  color:var(--text);
  line-height:1.2;
  white-space:nowrap;
  overflow-x:auto;
  scrollbar-width:none;
}
.topStatus::-webkit-scrollbar{
  display:none;
}
.topStatus b{
  display:inline-flex;
  align-items:center;
  gap:5px;
  font-weight:700;
  color:var(--text);
}


.fullNotice{
  display:none;
  margin:12px 16px 0;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid var(--warnBorder);
  background:var(--warnBg);
  font-size:13px;
  line-height:1.6;
}
.fullNotice.show{ display:block; }

.replyBar{
  display:none;
  padding:9px 12px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  align-items:center;
  gap:10px;
}
.replyBar.show{ display:flex; }

.replyLabel{
  font-size:12px;
  color:var(--muted);
  flex:1;
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.replyCancel{
  padding:6px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--btnBg);
  cursor:pointer;
  color:var(--text);
}
.replyCancel:hover{ background:var(--btnBgHover); }

.uploadPreviewBar{
  display:none;
  padding:8px 12px;
  border-top:1px solid var(--border);
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,0.03);
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.uploadPreviewBar.show{
  display:flex;
}
.uploadPreviewInner{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
  flex:1;
}
.uploadPreviewThumb{
  width:54px;
  height:54px;
  object-fit:cover;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  flex:0 0 auto;
}
.uploadPreviewMeta{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:2px;
}
.uploadPreviewName{
  font-size:12px;
  font-weight:700;
  color:var(--text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.uploadPreviewSize{
  font-size:11px;
  color:var(--muted);
}
.clearImageBtn{
  width:34px;
  height:34px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--btnBg);
  color:var(--text);
  cursor:pointer;
  font-size:18px;
  line-height:1;
  flex:0 0 auto;
}
.clearImageBtn:hover{
  background:var(--btnBgHover);
}

.chatBox{
  flex:1;
  overflow:auto;
  padding:12px 14px;
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:0;
}
.message{
  max-width:920px;
  display:flex;
  flex-direction:column;
  gap:4px;
  padding-left:8px;
  border-left:4px solid rgba(0,0,0,0.12);
}
.message.me{
  align-self:flex-end;
align-items:flex-end;
  padding-left:0;
  padding-right:8px;
  border-left:none;
  border-right:4px solid rgba(0,0,0,0.12);
}
.meta{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
  justify-content:flex-start;
}
.message.me .meta{
  justify-content:flex-end;
}
.name{
  font-weight:900;
  font-size:13px;
}
.time{
  font-size:12px;
  color:var(--muted);
}
.actions{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  align-items:center;
}
.actionBtn{
  width:34px;
  height:34px;
  padding:0 9px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--btnBg);
  cursor:pointer;
  color:var(--text);
  font-size:13px;
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  vertical-align:middle;
}
.actionBtn:hover{ background:var(--btnBgHover); }
.actionBtn.danger{ opacity:.9; }

.iconBtn{
  width:34px;
  height:34px;
  padding:0 8px;
  font-size:15px;
}

.actionBtn.emoji{
  width:34px;
  height:34px;
  padding:0 8px;
  font-size:16px;
  line-height:1;
}

.iconBtn[aria-label="翻訳"]{
  font-size:14px;
}

.iconBtn[aria-label="返信"]{
  font-size:16px;
  font-weight:800;
}

.iconBtn[aria-label="削除"]{
  font-size:16px;
  font-weight:700;
}

.replyQuote{
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  padding:6px 9px;
  border-radius:10px;
  cursor:pointer;
  max-width:920px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.replyQuote:hover{
  filter:brightness(1.05);
}
.bubble{
  display:inline-block;
  width:fit-content;
  max-width:920px;
  padding:8px 11px;
  border-radius:14px;
  background:var(--msgBg);
  border:1px solid var(--msgBorder);
  line-height:1.5;
  font-size:15px;
  white-space:pre-wrap;
  word-break:break-word;
}
.deleted{
  font-style:italic;
  color:var(--muted);
}

.bubbleImageWrap{
  margin-top:6px;
  max-width:min(300px, 78vw);
  display:grid;
  gap:5px;
}
.bubbleImageWrap.imageCount1{
  display:block;
}
.bubbleImageWrap.imageCount2,
.bubbleImageWrap.imageCount3,
.bubbleImageWrap.imageCount4{
  grid-template-columns:repeat(2, minmax(0, 1fr));
}
.bubbleImageWrap.imageCount3 .bubbleImage:first-child{
  grid-row:span 2;
}
.bubbleImage{
  display:block;
  width:100%;
  max-width:300px;
  max-height:220px;
  height:auto;
  object-fit:contain;
  border-radius:14px;
  border:1px solid var(--msgBorder);
  cursor:pointer;
  background:rgba(255,255,255,0.04);
}
.bubbleImageWrap.imageCount2 .bubbleImage,
.bubbleImageWrap.imageCount3 .bubbleImage,
.bubbleImageWrap.imageCount4 .bubbleImage{
  aspect-ratio:1 / 1;
  height:auto;
  max-height:none;
}
.bubbleImage:hover{
  filter:brightness(1.03);
}

/* reaction */
.reactionArea{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:2px;
  width:fit-content;
  max-width:920px;
}
.reactionSummaryBtn{
  width:fit-content;
  max-width:100%;
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
  padding:6px 8px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  cursor:pointer;
  color:var(--text);
  font-size:12px;
  line-height:1.2;
}
.reactionSummaryBtn:hover{
  background:var(--btnBgHover);
}
.reactionChip{
  display:inline-flex;
  align-items:center;
  gap:4px;
  padding:4px 7px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--btnBg);
  font-size:12px;
  line-height:1;
}
.reactionChip.mine{
  font-weight:800;
}
.reactionPanel{
  display:none;
  flex-direction:column;
  gap:8px;
  padding:8px 9px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  max-width:920px;
}
.reactionPanel.show{
  display:flex;
}
.reactionPicker{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.reactionPickBtn{
  min-width:38px;
  height:34px;
  padding:0 10px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--btnBg);
  cursor:pointer;
  color:var(--text);
  font-size:18px;
  line-height:1;
}
.reactionPickBtn:hover{
  background:var(--btnBgHover);
}
.reactionPickBtn.active{
  transform:translateY(-1px);
  box-shadow:0 0 0 1px rgba(255,255,255,0.06) inset;
}
.reactionDetails{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.reactionDetailRow{
  font-size:12px;
  line-height:1.45;
  color:var(--muted);
  word-break:break-word;
}
.reactionDetailRow b{
  color:var(--text);
  margin-right:6px;
}
.reactionHelp{
  font-size:11px;
  color:var(--muted);
  line-height:1.4;
}

.attachBtn{
  width:56px;
  height:56px;
  border-radius:14px;
  border:1px solid var(--border);
  background:var(--btnBg);
  color:var(--text);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
  line-height:1;
  flex:0 0 auto;
  user-select:none;
}
.attachBtn:hover{
  background:var(--btnBgHover);
}
.imageInput{
  display:none;
}
.chat.dragover{
  box-shadow:inset 0 0 0 2px rgba(110,160,255,0.65);
}

.safetyNotice{
  padding:6px 10px;
  color:var(--muted);
  font-size:12px;
  line-height:1.4;
  text-align:center;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}


.composer{
  padding:10px 12px;
  border-top:1px solid var(--border);
  display:flex;
  gap:10px;
  align-items:flex-end;
}
#chatInput{
  flex:1;
  min-width:0;
  resize:none;
  min-height:48px;
  max-height:200px;
  padding:11px 13px;
  border-radius:14px;
  border:1px solid var(--inputBorder);
  background:var(--inputBg);
  color:var(--text);
  outline:none;
  line-height:1.4;
  font-size:15px;
}
#chatInput:focus{
  filter:brightness(1.03);
}
.sendBtn{
  min-width:64px;
  height:56px;
  padding:0 16px;
  border-radius:16px;
  border:1px solid var(--border);
  background:var(--btnBg);
  color:var(--text);
  cursor:pointer;
  font-weight:800;
  font-size:14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
}
.sendBtn:hover{ background:var(--btnBgHover); }

.sendBtn:disabled,
#chatInput:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.imageViewer{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  z-index:5000;
}
.imageViewer.show{
  display:flex;
}
.imageViewerBackdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0.82);
}
.imageViewerDialog{
  position:relative;
  z-index:1;
  width:min(92vw, 1200px);
  max-height:92vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}
.imageViewerImg{
  display:block;
  max-width:100%;
  max-height:calc(92vh - 36px);
  border-radius:16px;
  box-shadow:0 24px 80px rgba(0,0,0,0.35);
  background:#111;
}
.imageViewerClose{
  position:absolute;
  top:6px;
  right:6px;
  width:40px;
  height:40px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.22);
  background:rgba(0,0,0,0.45);
  color:#fff;
  cursor:pointer;
  font-size:24px;
  line-height:1;
}
.imageViewerClose:hover{
  background:rgba(0,0,0,0.62);
}

.systemCenterNotice{
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  padding:22px 34px;
  border-radius:18px;
  background:var(--systemCenterBg);
  color:var(--systemCenterText);
  font-size:24px;
  font-weight:700;
  text-align:center;
  z-index:4000;
  pointer-events:none;
  opacity:0;
  transition:opacity .35s ease;
  max-width:min(76%, 700px);
  line-height:1.6;
  backdrop-filter:blur(6px);
}
.systemCenterNotice.show{
  opacity:1;
}
.systemCenterNotice.minute{
  font-size:18px;
  padding:18px 28px;
  z-index:3900;
}

.fadeEnding{
  position:fixed;
  inset:0;
  background:#000;
  opacity:0;
  pointer-events:none;
  z-index:3500;
}

/* =========================
   Mobile compact UI
========================= */
@media (max-width: 860px){
  body{
    padding:0;
    align-items:stretch;
    justify-content:stretch;
  }

  .app{
    width:100vw;
    height:100vh;
    max-width:none;
    max-height:none;
    display:grid;
    grid-template-rows:auto 1fr;
    gap:6px;
    padding:6px;
  }

  .sidebar{
    width:100%;
    min-width:0;
    border-radius:16px;
    padding:8px 10px;
    gap:0;
    overflow:visible;
    position:relative;
    display:grid;
    grid-template-columns:minmax(0,1fr) 36px 36px;
    align-items:center;
    column-gap:8px;
    row-gap:6px;
  }

  .titleRow{
    grid-column:1;
    min-width:0;
    align-items:center;
    gap:0;
  }

  .titleBlock{
    min-width:0;
    width:100%;
  }

  h1{
    margin:0;
    font-size:13px;
    line-height:1.2;
    font-weight:800;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    letter-spacing:0;
  }

  .sub{
    display:none;
  }

  .backBtn{
    grid-column:2;
    width:36px;
    min-width:36px;
    height:36px;
    padding:0;
    border-radius:11px;
    font-size:0;
    line-height:0;
    text-align:center;
    overflow:hidden;
  }
  .backBtn::before{
    content:"←";
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    height:100%;
    font-size:18px;
    line-height:1;
  }

  .settingsWrap{
    display:contents;
  }

  #toggleSettingsBtn{
    grid-column:3;
    width:36px;
    min-width:36px;
    height:36px;
    padding:0;
    border-radius:11px;
    font-size:0;
    line-height:0;
    overflow:hidden;
  }
  #toggleSettingsBtn::before{
    content:"⚙";
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    height:100%;
    font-size:17px;
    line-height:1;
  }

  #settingsBox{
    grid-column:1 / -1;
    margin-top:2px;
    max-height:min(64vh, 520px);
    overflow:auto;
  }

  .settingsBottom{
    padding-top:4px;
  }

  #closeSettingsBtn{
    width:100%;
  }

  .chat{
    border-radius:16px;
    min-height:0;
  }

  /* 部屋名の重複を防ぐ */
  .chatHeader{
    display:none;
  }
  .topStatus{
    padding:8px 10px;
    gap:10px;
    font-size:12px;
    line-height:1.2;
  }

  #statusMeName{
    max-width:42vw;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }

  .fullNotice{
    margin:10px 10px 0;
    padding:10px 12px;
    font-size:12px;
  }

  .replyBar{
    padding:8px 10px;
  }

  .replyLabel{
    font-size:11px;
  }

  .chatBox{
    padding:10px 10px;
    gap:7px;
  }

  .message,
  .message.me{
    max-width:100%;
    gap:3px;
  }

  .meta{
    gap:5px;
    align-items:center;
  }

  .name{
    font-size:12px;
  }

  .time{
    font-size:11px;
  }

  .actions{
    gap:5px;
  }

  .actionBtn{
    min-width:32px;
    height:30px;
    padding:0 7px;
    font-size:12px;
    border-radius:9px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    line-height:1;
  }

  .iconBtn{
    min-width:32px;
    height:30px;
    padding:0 6px;
    font-size:14px;
  }

  .actionBtn.emoji{
    min-width:32px;
    height:30px;
    padding:0 6px;
    font-size:14px;
  }

  .iconBtn[aria-label="翻訳"]{
    font-size:13px;
  }

  .iconBtn[aria-label="返信"]{
    font-size:15px;
    font-weight:800;
  }

  .iconBtn[aria-label="削除"]{
    font-size:13px;
  }

  .replyQuote{
    padding:5px 8px;
    font-size:11px;
  }

  .bubble{
    max-width:min(88vw, 560px);
    font-size:14px;
    padding:7px 10px;
    line-height:1.45;
  }

  .reactionArea{
    max-width:min(88vw, 560px);
  }

  .reactionSummaryBtn{
    font-size:11px;
    padding:5px 7px;
  }

  .reactionChip{
    font-size:11px;
    padding:4px 6px;
  }

  .reactionPickBtn{
    min-width:34px;
    height:32px;
    font-size:16px;
  }

  .reactionDetailRow{
    font-size:11px;
  }

  .uploadPreviewBar{
    padding:8px 10px;
  }

  .uploadPreviewThumb{
    width:48px;
    height:48px;
  }

  .attachBtn{
    width:48px;
    height:48px;
    font-size:20px;
    border-radius:13px;
  }

  .bubbleImageWrap{
    max-width:min(280px, 74vw);
  }

  .bubbleImage{
    max-width:280px;
    max-height:210px;
  }

  .composer{
    padding:9px 10px calc(9px + env(safe-area-inset-bottom));
    align-items:stretch;
  }

  #chatInput{
    min-height:46px;
    max-height:130px;
    font-size:16px;
    padding:10px 12px;
  }

  .sendBtn{
    min-width:62px;
    height:48px;
    font-size:14px;
    padding:0 14px;
    border-radius:14px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    line-height:1;
  }

  .systemCenterNotice{
    width:min(84vw, 560px);
    font-size:22px;
    padding:18px 22px;
  }

  .systemCenterNotice.minute{
    font-size:16px;
    padding:15px 20px;
  }
}

@media (max-width: 560px){
  .app{
    gap:6px;
    padding:6px;
  }

  .sidebar{
    padding:8px 9px;
    grid-template-columns:minmax(0,1fr) 34px 34px;
    column-gap:7px;
  }

  h1{
    font-size:12px;
  }

  .backBtn,
  #toggleSettingsBtn{
    width:34px;
    min-width:34px;
    height:34px;
    border-radius:10px;
  }

  .backBtn::before{
    font-size:17px;
  }

  #toggleSettingsBtn::before{
    font-size:16px;
  }

  .settingsInline{
    flex-direction:column;
    align-items:stretch;
  }
  .topStatus{
    padding:7px 9px;
    gap:8px;
    font-size:11px;
  }

  .topStatus > b:first-of-type::after,
  .topStatus > b:nth-of-type(2)::before,

  #statusMeName{
    max-width:40vw;
  }

  .chatBox{
    padding:8px;
    gap:6px;
  }

  .meta{
    gap:4px;
  }

  .name{
    font-size:12px;
  }

  .time{
    font-size:11px;
  }

  .actions{
    gap:4px;
  }

  .actionBtn{
    min-width:32px;
    height:30px;
    padding:0 6px;
    font-size:12px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    line-height:1;
  }

  .iconBtn{
    min-width:32px;
    height:30px;
    padding:0 6px;
    font-size:13px;
  }

  .actionBtn.emoji{
    min-width:32px;
    height:30px;
    padding:0 6px;
    font-size:14px;
  }

  .iconBtn[aria-label="翻訳"]{
    font-size:12px;
  }

  .iconBtn[aria-label="返信"]{
    font-size:14px;
    font-weight:800;
  }

  .iconBtn[aria-label="削除"]{
    font-size:12px;
  }

  .bubble{
    max-width:82vw;
    padding:7px 9px;
    font-size:14px;
  }

  .reactionArea{
    max-width:82vw;
  }

  .reactionSummaryBtn{
    padding:5px 7px;
    font-size:11px;
  }

  .reactionPickBtn{
    min-width:32px;
    height:30px;
    font-size:15px;
  }

  .uploadPreviewBar{
    padding:7px 8px;
    gap:8px;
  }

  .uploadPreviewInner{
    gap:8px;
  }

  .uploadPreviewThumb{
    width:42px;
    height:42px;
    border-radius:10px;
  }

  .uploadPreviewName{
    font-size:11px;
  }

  .uploadPreviewSize{
    font-size:10px;
  }

  .clearImageBtn{
    width:32px;
    height:32px;
    font-size:16px;
  }

  .attachBtn{
    width:46px;
    height:46px;
    font-size:19px;
    border-radius:12px;
  }

  .bubbleImageWrap{
    max-width:min(260px, 72vw);
  }

  .bubbleImage{
    max-width:260px;
    max-height:190px;
    border-radius:12px;
  }

  .composer{
    gap:8px;
    padding:9px;
  }

  #chatInput{
    padding:10px 11px;
  }

  .sendBtn{
    min-width:58px;
    height:46px;
    padding:0 12px;
    font-size:13px;
    border-radius:13px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    line-height:1;
  }

  .systemCenterNotice{
    font-size:20px;
    padding:16px 18px;
  }

  .systemCenterNotice.minute{
    font-size:15px;
    padding:14px 16px;
  }
}


/* =========================
   入力欄1行化 + 警告文非表示（スマホ）
========================= */
/* =========================
   📱 スマホ専用：入力欄固定 + 送信アイコン最適化
========================= */
/* =========================
   スマホ：入力欄固定 + 紙飛行機 + 複数行対応
   + Android TWA画像プレビュー修正
========================= */
@media (max-width: 860px){
  .chatBox{
    padding-bottom:238px !important;
  }

  .uploadPreviewBar.show{
    position:fixed !important;
    left:8px !important;
    right:8px !important;
    bottom:calc(96px + env(safe-area-inset-bottom)) !important;
    z-index:1001 !important;

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

    border-radius:16px !important;
    border:1px solid var(--border) !important;
    background:linear-gradient(180deg, var(--panel), var(--panel2)) !important;
    box-shadow:0 10px 26px rgba(18, 25, 40, .14) !important;
  }


  .safetyNotice{
    position:fixed !important;
    left:8px !important;
    right:8px !important;
    bottom:calc(66px + env(safe-area-inset-bottom)) !important;
    z-index:1000 !important;

    padding:4px 8px !important;

    font-size:10.5px !important;
    line-height:1.35 !important;
    white-space:nowrap !important;
    overflow:hidden !important;
    text-overflow:ellipsis !important;
  }

  .composer{
    position:fixed !important;
    left:8px !important;
    right:8px !important;
    bottom:8px !important;
    z-index:1000 !important;

    display:flex !important;
    align-items:flex-end !important;
    gap:8px !important;

    padding:6px 8px calc(6px + env(safe-area-inset-bottom)) !important;

    border-radius:16px !important;
    border:1px solid var(--border) !important;
    background:linear-gradient(180deg, var(--panel), var(--panel2)) !important;
    box-shadow:0 10px 26px rgba(18, 25, 40, .12) !important;
  }

  .attachBtn{
    width:46px !important;
    height:46px !important;
    min-width:46px !important;
    border-radius:14px !important;
    font-size:19px !important;
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    flex:0 0 auto !important;
  }

  #chatInput{
    flex:1 !important;
    min-width:0 !important;

    min-height:46px !important;
    max-height:138px !important;
    padding:10px 12px !important;
    font-size:16px !important;
    line-height:1.45 !important;
    border-radius:14px !important;
    resize:none !important;
    box-sizing:border-box !important;
    display:block !important;
  }

  .sendBtn{
    width:46px !important;
    height:46px !important;
    min-width:46px !important;
    padding:0 !important;
    border-radius:14px !important;
    font-size:0 !important;
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    flex:0 0 auto !important;
  }

  .sendBtn svg{
    width:20px !important;
    height:20px !important;
    display:block !important;
    fill:currentColor !important;
    pointer-events:none !important;
  }
}







/* ===== room chat status icon fix ===== */

#statusCount::before,
#statusMeName::before{
  content:"" !important;
  display:inline-block !important;
  width:14px !important;
  height:14px !important;
  background-size:contain !important;
  background-repeat:no-repeat !important;
  background-position:center !important;
  margin-right:2px !important;
  flex:none !important;
}

#statusCount::before{
  background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%0A%3Ccircle%20cx%3D%2712%27%20cy%3D%278%27%20r%3D%275%27%20fill%3D%27%2363e27d%27/%3E%0A%3Cpath%20d%3D%27M4%2022c0-4.5%203.5-8%208-8s8%203.5%208%208%27%20fill%3D%27%2363e27d%27/%3E%0A%3C/svg%3E") !important;
}

#statusMeName::before{
  background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%3E%0A%3Ccircle%20cx%3D%2712%27%20cy%3D%278%27%20r%3D%275%27%20fill%3D%27%23cfcfcf%27/%3E%0A%3Cpath%20d%3D%27M4%2022c0-4.5%203.5-8%208-8s8%203.5%208%208%27%20fill%3D%27%23cfcfcf%27/%3E%0A%3C/svg%3E") !important;
}

#statusTime::before{
  content:"🕒" !important;
}

@media (max-width:860px){
  #statusCount::before,
  #statusMeName::before{
    width:13px !important;
    height:13px !important;
  }
}

/* ===== status timer width fix ===== */

#statusTime{
  display:inline-flex !important;
  align-items:center !important;
  min-width:92px !important;
  font-variant-numeric:tabular-nums !important;
  font-feature-settings:"tnum" !important;
}


/* =========================
   iOS / iPadOS Safari only
   Android / PC / Android TWAには影響させない
========================= */
html.ios-device,
html.ios-device body{
  height:100%;
  min-height:100%;
  -webkit-text-size-adjust:100%;
}

html.ios-device body{
  overscroll-behavior-y:none;
}

@media (max-width:860px){
  html.ios-device body{
    min-height:var(--room-visual-height, 100dvh);
  }

  html.ios-device .app{
    height:var(--room-visual-height, 100dvh) !important;
    min-height:var(--room-visual-height, 100dvh) !important;
    overflow:hidden !important;
  }

  html.ios-device .chat{
    min-height:0 !important;
    overflow:hidden !important;
  }

  html.ios-device .chatBox{
    -webkit-overflow-scrolling:touch;
    padding-bottom:calc(158px + env(safe-area-inset-bottom)) !important;
    overscroll-behavior:contain;
  }


  html.ios-device .safetyNotice{
    left:max(8px, env(safe-area-inset-left)) !important;
    right:max(8px, env(safe-area-inset-right)) !important;
    bottom:calc(66px + env(safe-area-inset-bottom)) !important;
    transform:translateZ(0);
    -webkit-transform:translateZ(0);
  }

  html.ios-device.ios-keyboard-open .safetyNotice{
    bottom:66px !important;
  }

  html.ios-device .composer{
    left:max(8px, env(safe-area-inset-left)) !important;
    right:max(8px, env(safe-area-inset-right)) !important;
    bottom:max(8px, env(safe-area-inset-bottom)) !important;
    padding:6px 8px !important;
    transform:translateZ(0);
    -webkit-transform:translateZ(0);
  }

  html.ios-device.ios-keyboard-open .composer{
    bottom:8px !important;
  }

  html.ios-device #chatInput,
  html.ios-device .textInput,
  html.ios-device .select{
    font-size:16px !important;
  }

  html.ios-device #chatInput{
    -webkit-appearance:none;
  }

  html.ios-device .imageViewer{
    height:var(--room-visual-height, 100dvh) !important;
  }
}

/* =========================
   Settings compact layout v1
   設定画面の縦スクロール削減：言語/通知/名前のみ横並び化
========================= */
.langBox{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:8px;
}
.langBox .langBtn{
  width:100%;
  min-width:0;
  padding-left:6px;
  padding-right:6px;
}
.soundInline{
  flex-direction:row;
  align-items:center;
}
.soundInline #soundType{
  flex:1 1 auto;
  min-width:0;
}
.soundInline #testSoundBtn{
  flex:0 0 auto;
}
.soundInline .soundEnabledSelect{
  flex:0 0 72px;
  width:72px;
  min-width:72px;
}
.nameInline{
  flex-direction:row;
  align-items:center;
}
.nameInline .textInput{
  flex:1 1 auto;
  min-width:0;
}
.nameInline #saveNameBtn{
  flex:0 0 auto;
}

@media (max-width: 560px){
  .langBox,
  .soundInline,
  .nameInline{
    flex-direction:row !important;
    align-items:center !important;
  }

  .langBox{
    display:grid !important;
    grid-template-columns:repeat(4, minmax(0, 1fr)) !important;
  }

  .soundInline{
    gap:6px !important;
  }

  .soundInline #soundType{
    flex:1 1 auto !important;
    min-width:0 !important;
  }

  .soundInline #testSoundBtn{
    flex:0 0 auto !important;
    padding-left:10px !important;
    padding-right:10px !important;
  }

  .soundInline .soundEnabledSelect{
    flex:0 0 64px !important;
    width:64px !important;
    min-width:64px !important;
    padding-left:9px !important;
    padding-right:9px !important;
  }

  .nameInline{
    gap:6px !important;
  }
}

/* =========================
   画像添付プレビュー改善（最大4枚 / サムネ / 追加）
========================= */
.uploadPreviewBar.multiImagePreviewBar{
  display:flex;
  align-items:stretch;
  justify-content:stretch;
  padding:9px 12px;
}
.uploadPreviewPanel{
  width:100%;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.uploadPreviewList{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  overflow-x:auto;
  scrollbar-width:none;
}
.uploadPreviewList::-webkit-scrollbar{
  display:none;
}
.uploadPreviewItem{
  position:relative;
  width:62px;
  height:62px;
  flex:0 0 auto;
  border-radius:13px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  overflow:hidden;
}
.uploadPreviewItemThumb{
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  background:rgba(0,0,0,0.04);
}
.uploadPreviewRemoveBtn{
  position:absolute;
  top:3px;
  right:3px;
  width:22px;
  height:22px;
  border:1px solid rgba(255,255,255,.38);
  border-radius:999px;
  background:rgba(0,0,0,.62);
  color:#fff;
  cursor:pointer;
  font-size:16px;
  line-height:1;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
}
.uploadPreviewAddBtn{
  width:62px;
  height:62px;
  flex:0 0 auto;
  border-radius:13px;
  border:1px dashed var(--border);
  background:var(--btnBg);
  color:var(--text);
  cursor:pointer;
  font-size:12px;
  font-weight:800;
  line-height:1.2;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:6px;
}
.uploadPreviewAddBtn:hover,
.uploadPreviewClearAllBtn:hover{
  background:var(--btnBgHover);
}
.uploadPreviewFooter{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  min-width:0;
}
.uploadPreviewCount{
  min-width:0;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.uploadPreviewClearAllBtn{
  flex:0 0 auto;
  border:1px solid var(--border);
  background:var(--btnBg);
  color:var(--text);
  border-radius:999px;
  cursor:pointer;
  font-size:12px;
  padding:6px 10px;
}

@media (max-width: 860px){
  .uploadPreviewBar.multiImagePreviewBar{
    padding:8px 10px !important;
    align-items:stretch !important;
  }
  .uploadPreviewPanel{
    gap:7px;
  }
  .uploadPreviewList{
    gap:7px;
  }
  .uploadPreviewItem,
  .uploadPreviewAddBtn{
    width:54px;
    height:54px;
    border-radius:12px;
  }
  .uploadPreviewAddBtn{
    font-size:11px;
  }
  .uploadPreviewRemoveBtn{
    width:21px;
    height:21px;
    font-size:15px;
  }
  .uploadPreviewFooter{
    gap:8px;
  }
  .uploadPreviewCount,
  .uploadPreviewClearAllBtn{
    font-size:11px;
  }
  .uploadPreviewClearAllBtn{
    padding:5px 9px;
  }
}

@media (max-width: 560px){
  .uploadPreviewItem,
  .uploadPreviewAddBtn{
    width:50px;
    height:50px;
  }
}
