:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e0ec;
  --text: #172033;
  --muted: #65728a;
  --left: #2563eb;
  --right: #059669;
  --bubble: #eef3fb;
  --shadow: 0 18px 45px rgba(25, 38, 68, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── 로그인 오버레이 ─────────────────────────────────── */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.login-overlay.hidden {
  display: none;
}

.login-box {
  width: min(680px, calc(100vw - 32px));
  border-radius: 14px;
  padding: 36px 40px 40px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.login-box h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-desc {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.login-error {
  margin: 0 0 16px;
  border-radius: 8px;
  padding: 10px 14px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 600;
}

.login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.login-col h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-col label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.login-col input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.login-col input:focus {
  border-color: #7aa2f7;
  outline: 3px solid rgba(37, 99, 235, 0.15);
}

.login-btn {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 10px;
  background: #172033;
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.login-btn:hover { background: #263149; }
.login-btn:disabled { opacity: 0.6; cursor: wait; }

/* ── 상단 바 ─────────────────────────────────────────── */

.shell {
  display: flex;
  flex-direction: column;
  width: min(1180px, calc(100vw - 32px));
  height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  box-sizing: border-box;
}

.topbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar { margin-bottom: 20px; }

.eyebrow,
.panel-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1, h2 { margin: 0; }
h1 { font-size: clamp(24px, 4vw, 36px); }
h2 { font-size: 20px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reset-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.reset-button:hover {
  border-color: #fdba74;
  background: #ffedd5;
}

.server-status {
  max-width: min(720px, calc(100vw - 32px));
  margin: 8px 0 0;
  color: #b45309;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.server-status.is-online { color: #166534; }

/* ── 채팅 그리드 ──────────────────────────────────────── */

.chat-grid {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.chat-panel {
  display: grid;
  height: 100%;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.status {
  display: inline-flex;
  min-width: 78px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #eef3fb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status.is-online {
  background: #dcfce7;
  color: #166534;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 18px;
}

.empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.message {
  display: grid;
  max-width: min(82%, 420px);
  gap: 5px;
}

.message.is-own { align-self: flex-end; }
.message:not(.is-own) { align-self: flex-start; }

.meta {
  color: var(--muted);
  font-size: 12px;
}

.message.is-own .meta { text-align: right; }

.bubble {
  overflow-wrap: anywhere;
  border-radius: 8px;
  padding: 11px 13px;
  background: var(--bubble);
  line-height: 1.45;
}

.message.is-own .bubble {
  background: var(--left);
  color: #fff;
}

.chat-panel[data-panel="right"] .message.is-own .bubble {
  background: var(--right);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.composer input {
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
  font: inherit;
}

.composer input:focus {
  border-color: #7aa2f7;
  outline: 3px solid rgba(37, 99, 235, 0.15);
}

.composer button {
  min-width: 76px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.composer button:hover { background: #263149; }

/* ── 반응형 ───────────────────────────────────────────── */

@media (max-width: 820px) {
  .shell {
    width: min(100vw - 20px, 680px);
    padding: 16px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-grid { grid-template-columns: 1fr; }
  .chat-panel { height: 100%; }

  .login-grid { grid-template-columns: 1fr; }
  .login-box { padding: 24px 20px 28px; }
}
