:root {
  --sage: #AEBCB5;
  --mint: #CFDFDB;
  --bg: #FFFFFF;
  --bg-soft: #F7FAF9;
  --text: #2E3A36;
  --text-light: #6B7A75;
  --border: #E3EBE8;
  --danger: #C76B6B;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg-soft);
  color: var(--text);
}

.hidden { display: none !important; }

.screen { width: 100%; height: 100vh; }

/* 로그인 */
#login-screen { background: var(--bg); }
.login-split { display: flex; width: 100%; height: 100vh; }

.brand-panel {
  flex: 1.1;
  background: linear-gradient(150deg, var(--sage) 0%, var(--mint) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.brand-panel::before {
  content: "";
  position: absolute;
  width: 480px; height: 480px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  top: -120px; right: -140px;
}
.brand-panel::after {
  content: "";
  position: absolute;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
  bottom: -100px; left: -80px;
}
.brand-inner { position: relative; z-index: 1; text-align: center; color: white; padding: 0 40px; }
.brand-inner .logo { color: white; font-size: 44px; letter-spacing: 6px; margin: 0; }
.brand-tagline { margin-top: 16px; font-size: 15px; line-height: 1.6; opacity: 0.92; }

.form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box { width: 320px; text-align: center; }
.form-title { font-size: 22px; margin: 0 0 6px; color: var(--text); }
.sub { color: var(--text-light); margin: 0 0 24px; font-size: 14px; }

@media (max-width: 760px) {
  .login-split { flex-direction: column; }
  .brand-panel { flex: none; height: 220px; }
  .brand-inner .logo { font-size: 32px; }
}

input, select {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--text);
  outline: none;
}
input:focus, select:focus { border-color: var(--sage); background: var(--bg); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--sage);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #98A89F; }

.btn-secondary {
  width: 100%;
  padding: 10px;
  background: var(--mint);
  color: var(--text);
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background .15s;
}
.btn-secondary:hover { background: #BFD4CE; }

.btn-text {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 13px;
  cursor: pointer;
}
.btn-text:hover { color: var(--text); }

.error-text { color: var(--danger); font-size: 12px; margin-top: 6px; min-height: 14px; }

/* 레이아웃 */
.layout { display: flex; height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}
.sidebar-top { margin-bottom: 20px; }
.logo-small { color: var(--sage); margin: 0 0 12px; letter-spacing: 2px; }
.user-card {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 10px 12px;
}
.user-name { font-weight: 700; font-size: 14px; }
.user-role { font-size: 12px; color: var(--sage); font-weight: 600; margin-top: 2px; }

.sidebar-section { flex: 1; overflow-y: auto; margin-bottom: 12px; }
.sidebar-section-title { font-size: 12px; color: var(--text-light); margin: 8px 0; font-weight: 600; }

.room-list { display: flex; flex-direction: column; gap: 4px; }
.room-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.room-item:hover { background: var(--bg-soft); }
.room-item.active { background: var(--mint); font-weight: 700; }
.room-item .room-lock { font-size: 11px; color: var(--text-light); }

.sidebar-actions { border-top: 1px solid var(--border); padding-top: 12px; }

.main-area { flex: 1; display: flex; flex-direction: column; background: var(--bg); }

.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-light); }

.chat-view { display: flex; flex-direction: column; height: 100%; }
.chat-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.chat-title { font-size: 16px; font-weight: 700; }
.chat-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.code-row { display: flex; gap: 8px; align-items: flex-start; }
.code-row input { flex: 1; margin-bottom: 12px; }
.btn-mini {
  padding: 11px 12px;
  background: var(--mint);
  border: none;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini:hover { background: #BFD4CE; }

.btn-danger {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 14px;
}
.btn-danger:hover { background: var(--danger); color: white; }

.messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }

.msg { max-width: 60%; padding: 10px 14px; border-radius: 14px; background: var(--bg-soft); position: relative; }
.msg.mine { align-self: flex-end; background: var(--mint); }
.msg-author { font-size: 11px; font-weight: 700; color: var(--sage); margin-bottom: 3px; }
.msg-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg-meta { font-size: 10px; color: var(--text-light); margin-top: 4px; }
.msg-actions { display: none; gap: 6px; margin-top: 6px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions span { font-size: 11px; color: var(--text-light); cursor: pointer; }
.msg-actions span:hover { color: var(--danger); }

.send-form { display: flex; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }
.send-form input { margin-bottom: 0; flex: 1; }
.send-form button { width: 90px; }

/* 모달 */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(46,58,54,0.25);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--bg);
  padding: 28px;
  border-radius: 16px;
  width: 320px;
}
.modal-box.modal-wide { width: 420px; max-height: 70vh; overflow-y: auto; }
.modal-box h3 { margin-top: 0; color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn-text, .modal-actions .btn-primary { margin-bottom: 0; }

.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--bg-soft); border-radius: 10px;
}
.member-info { font-size: 13px; }
.member-info .m-role { color: var(--sage); font-weight: 700; font-size: 11px; }
.member-item button {
  background: none; border: 1px solid var(--danger); color: var(--danger);
  border-radius: 8px; padding: 4px 10px; font-size: 11px; cursor: pointer;
}
.member-item button:hover { background: var(--danger); color: white; }
