:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #697681;
  --line: #d8e0e6;
  --bg: #edf3f5;
  --panel: #ffffff;
  --accent: #0f8b64;
  --accent-2: #2267a5;
  --danger: #b42318;
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
}
button.secondary, .sidebar header button, menu button:first-child { background: #e8eef2; color: var(--ink); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}
textarea { resize: none; min-height: 44px; max-height: 120px; }
.share-preview { min-height: 260px; max-height: 50vh; resize: vertical; white-space: pre-wrap; }
.hidden { display: none !important; }
.auth {
  min-height: 100svh;
  display: grid;
  place-content: center;
  gap: 18px;
  padding: 24px;
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-size: 28px;
  font-weight: 900;
}
h1, h2, p { margin: 0; }
.brand p, small, .chat-head p { color: var(--muted); }
.typing {
  min-height: 18px;
  color: var(--accent);
  font-size: 13px;
}
.panel, .dialog-body {
  width: min(440px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.dialog-body > label:not(.check) { display: grid; gap: 6px; font-weight: 700; }
.dialog-body h3 { margin: 4px 0 0; }
.error { color: var(--danger); min-height: 24px; }
.shell {
  height: 100svh;
  display: grid;
  grid-template-columns: 340px 1fr;
}
.sidebar {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #f8fbfc;
  display: flex;
  flex-direction: column;
}
.sidebar header, .chat-head {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
}
.actions button { background: var(--accent-2); }
.actions .adminOnly { grid-column: 1 / -1; }
.invite-qr-dialog { width: min(460px, calc(100vw - 32px)); justify-items: center; }
.invite-qr-image {
  width: min(320px, 78vw);
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid var(--line);
  background: white;
}
.invite-url { max-width: 100%; overflow-wrap: anywhere; color: var(--accent-2); text-align: center; }
.invite-qr-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.room-list { overflow: auto; }
.room {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  border-bottom: 1px solid var(--line);
}
.room.active { background: #dcebe6; }
.room-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.room-kind {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid #9bc8b9;
  border-radius: 6px;
  color: #176b51;
  background: #eef8f4;
  font-size: 11px;
  font-weight: 700;
}
.room small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 12px;
}
.chat {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #e7eef0;
}
.chat-head { justify-content: flex-start; }
.chat-head-main { min-width: 0; }
.pins-button {
  margin-left: auto;
  padding: 8px 10px;
  background: var(--accent-2);
  white-space: nowrap;
}
.pins-button span { font-weight: 400; }
.back { display: none; background: #e8eef2; color: var(--ink); }
.messages {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty {
  margin: auto;
  color: var(--muted);
}
.msg {
  max-width: min(680px, 78%);
  display: grid;
  gap: 5px;
}
.msg.mine { align-self: flex-end; }
.msg.other { align-self: flex-start; }
.bubble {
  padding: 10px 12px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.message-text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.copyable {
  -webkit-user-select: text;
  user-select: text;
}
.mine .bubble { background: #d8f1e9; border-color: #b8dfd2; }
.meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}
.mine .meta { justify-content: flex-end; }
.pin-toggle {
  padding: 2px 6px;
  border: 1px solid #9db4c7;
  border-radius: 6px;
  background: transparent;
  color: #315d7f;
  font-size: 11px;
}
.msg.pinned .bubble { box-shadow: inset 3px 0 #d59a16; }
.pins-dialog-body { width: min(620px, calc(100vw - 32px)); }
.dialog-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pins-list { display: grid; gap: 8px; max-height: 60vh; overflow: auto; }
.pin-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.pin-preview { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pin-preview small { display: block; margin-top: 4px; }
.pin-actions { display: flex; align-items: center; gap: 6px; }
.pin-actions button { padding: 7px 9px; }
.message-focus .bubble { outline: 3px solid #d59a16; outline-offset: 2px; }
.media {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #111;
  cursor: zoom-in;
}
.media-frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  line-height: 0;
}
.bubble > .media-frame:first-child,
.bubble > .file-attachment:first-child { margin-top: 0; }
.media-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 8px;
  background: rgb(23 33 43 / 86%);
  color: white;
  font-size: 22px;
  line-height: 1;
}
video.media { min-width: min(280px, 100%); max-height: 360px; }
.media-viewer {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: rgb(10 16 22 / 96%);
  color: white;
  box-shadow: none;
}
.media-viewer[open] { display: grid; }
.media-viewer::backdrop { background: rgb(0 0 0 / 80%); }
.media-viewer-shell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 58px 18px 18px;
}
.media-viewer-content {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
.media-viewer-content img,
.media-viewer-content video {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 110px);
  object-fit: contain;
}
.media-viewer-name {
  max-width: min(800px, calc(100vw - 36px));
  min-height: 22px;
  padding-top: 8px;
  overflow: hidden;
  color: #dce5ea;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-viewer-close {
  position: fixed;
  z-index: 1;
  top: 12px;
  right: 12px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 8px;
  background: rgb(23 33 43 / 90%);
  color: white;
  font-size: 28px;
  line-height: 1;
}
.file-attachment { margin-top: 8px; }
.file-card {
  min-width: min(360px, 70vw);
  max-width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #b9cbd5;
  border-radius: 8px;
  background: #f7fafb;
  color: var(--ink);
  text-decoration: none;
}
.file-card-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-2);
  color: white;
  font-size: 23px;
  font-weight: 800;
}
.file-card-info { min-width: 0; display: grid; gap: 3px; }
.file-card-info strong,
.file-card-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-card-action { color: var(--accent-2); font-weight: 800; }
.copy-toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 8px;
  background: #17212b;
  color: white;
  box-shadow: 0 8px 28px rgb(0 0 0 / 25%);
  font-weight: 700;
  white-space: nowrap;
}
.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: white;
}
.file {
  border-radius: 8px;
  padding: 11px 12px;
  background: #e8eef2;
  font-weight: 700;
  white-space: nowrap;
}
.file input { display: none; }
dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 70px rgb(0 0 0 / 25%);
}
dialog::backdrop { background: rgb(0 0 0 / 35%); }
.choices {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 8px;
}
.choice {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.choice input { width: auto; }
.check {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}
.check input { width: auto; }
.password-check {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}
.password-check.ok { color: var(--accent); }
.password-check.ng { color: var(--danger); }
.manage-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}
.manage-user {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.manage-user.inactive { background: #f3f5f6; }
.manage-user-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.manage-user-fields label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.manage-user-fields input { color: var(--ink); }
.manage-user-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.manage-user-actions button { background: var(--accent-2); padding: 8px 10px; }
.manage-user-actions .danger { background: var(--danger); }
.user-state { margin-right: auto; color: var(--muted); font-size: 13px; font-weight: 700; }
.password-result {
  min-height: 24px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef6f3;
  color: var(--ink);
  overflow-wrap: anywhere;
}
menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 0; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: flex; }
  .chat { display: none; }
  .shell.chat-open .sidebar { display: none; }
  .shell.chat-open .chat { display: grid; height: 100svh; }
  .back { display: inline-block; }
  .msg { max-width: 88%; }
  .composer { grid-template-columns: auto 1fr auto; }
  .file { max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
  .file-card { min-width: min(300px, 76vw); }
  .manage-user-fields { grid-template-columns: 1fr; }
}
