:root {
  --bg: #0d1118;
  --card: #121a29;
  --line: #2d3a52;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --accent: #2563eb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(circle at 15% 10%, #1d4ed82c, transparent 32%), var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', sans-serif;
}

.chat-shell {
  width: min(1320px, calc(100vw - 1rem));
  margin: 0 auto;
  padding: 0.7rem 0 1.1rem;
}

.chat-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.chat-topbar h1 {
  margin: 0;
  font-family: 'Do Hyeon', sans-serif;
  letter-spacing: 0.01em;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.back-link,
.admin-link {
  color: #cbd5e1;
  text-decoration: none;
  border: 1px solid #465269;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  background: #101726;
}

.chat-layout {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(0, 2fr);
  gap: 0.7rem;
}

.card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--card) 0%, #0d1422 100%);
  border-radius: 14px;
  padding: 0.75rem;
}

h2, h3 {
  margin: 0 0 0.45rem;
  font-family: 'Do Hyeon', sans-serif;
  font-weight: 400;
}

.room-form {
  display: grid;
  gap: 0.45rem;
}

.inline-fields {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  color: #dbeafe;
  font-size: 0.9rem;
}

input, textarea, select, button {
  font: inherit;
}

input, textarea, select {
  width: 100%;
  border: 1px solid #37465f;
  border-radius: 9px;
  background: #0b1220;
  color: #e2e8f0;
  padding: 0.42rem 0.52rem;
}

button {
  border: 1px solid #375a9d;
  background: #1d4ed8;
  color: #eff6ff;
  border-radius: 9px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

.room-list {
  margin-top: 0.5rem;
  display: grid;
  gap: 0.42rem;
  max-height: 56dvh;
  overflow: auto;
}

.room-item {
  border: 1px solid #34445f;
  border-radius: 10px;
  background: #0b1220;
  padding: 0.5rem;
}

.room-item h4 {
  margin: 0;
  font-size: 0.98rem;
}

.room-item-meta {
  margin: 0.2rem 0 0.35rem;
  font-size: 0.82rem;
  color: #93c5fd;
}

.room-item-desc {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.9rem;
  line-height: 1.35;
}

.room-header p {
  margin: 0.2rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.message-list {
  border: 1px solid #36445d;
  border-radius: 10px;
  background: #0b1220;
  min-height: 46dvh;
  max-height: 58dvh;
  overflow: auto;
  padding: 0.52rem;
}

.message-item {
  border-bottom: 1px solid #283548;
  padding: 0.42rem 0;
}

.message-item:last-child { border-bottom: 0; }

.message-meta {
  margin: 0;
  font-size: 0.8rem;
  color: #93c5fd;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.message-body {
  margin: 0.2rem 0 0;
  white-space: pre-wrap;
  line-height: 1.45;
  color: #e5e7eb;
}

.message-actions {
  margin-top: 0.2rem;
}

.tiny-btn {
  border: 1px solid #475569;
  background: #0f172a;
  color: #cbd5e1;
  border-radius: 999px;
  font-size: 0.75rem;
  padding: 0.16rem 0.45rem;
}

.message-form {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
}

.message-form textarea {
  min-height: 2.5rem;
}

.status-text {
  margin: 0.42rem 0 0;
  font-size: 0.86rem;
  color: #9ca3af;
}

.manager-panel {
  margin: 0 0 0.6rem;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #0a1324;
  padding: 0.55rem;
}

.manager-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.42rem;
}

.invite-panel {
  margin-top: 0.55rem;
  border: 1px solid #2d3b52;
  border-radius: 10px;
  background: #0b1220;
  padding: 0.45rem;
}

.invite-panel h4 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}

.invite-create-row {
  display: grid;
  grid-template-columns: 120px 120px auto;
  gap: 0.4rem;
}

.invite-list {
  margin-top: 0.4rem;
  display: grid;
  gap: 0.35rem;
}

.invite-item {
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  padding: 0.35rem 0.45rem;
  font-size: 0.82rem;
}

.invite-item p {
  margin: 0.16rem 0;
}

.help-text {
  margin: 0.22rem 0 0;
  color: #93c5fd;
  font-size: 0.8rem;
}

.member-list {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.3rem;
}

.member-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #2d3b52;
  border-radius: 8px;
  background: #0b1220;
  padding: 0.36rem 0.5rem;
  font-size: 0.86rem;
}

.join-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.join-modal[hidden] {
  display: none !important;
}

.join-backdrop {
  position: absolute;
  inset: 0;
  background: #000000a8;
}

.join-dialog {
  position: relative;
  width: min(420px, calc(100vw - 1rem));
  border: 1px solid #334155;
  border-radius: 12px;
  background: #0f172a;
  padding: 0.75rem;
}

.join-actions {
  margin-top: 0.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

@media (max-width: 980px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .manager-grid {
    grid-template-columns: 1fr 1fr;
  }

  .invite-create-row {
    grid-template-columns: 1fr 1fr;
  }
}
