/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0b0e14;
  --surface:   #131926;
  --border:    #1e2a3a;
  --text:      #c8d6e5;
  --muted:     #576574;
  --accent:    #6c5ce7;
  --accent2:   #00cec9;
  --danger:    #e17055;
  --success:   #00b894;
  --radius:    10px;
  --font:      'Inter', 'Segoe UI', system-ui, sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }

/* ── Layout ── */
#app { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }

.panel { display: none; width: 100%; max-width: 440px; }
.panel.active { display: block; }
.panel--wide { max-width: 640px; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.card h1 { font-size: 1.8rem; text-align: center; }
.card h2 { font-size: 1.2rem; text-align: center; color: var(--accent2); }
.subtitle { text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ── Form ── */
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}
.field input:focus { border-color: var(--accent); }

/* ── Buttons ── */
.actions { display: flex; gap: 0.5rem; }
.btn {
  flex: 1;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(0.97); }
.btn.primary   { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--border); color: var(--text); }
.btn-icon { background: none; border: none; color: var(--text); cursor: pointer; font-size: 1.2rem; padding: 0.2rem 0.4rem; border-radius: 4px; }
.btn-icon:hover { background: var(--border); }

/* ── Room Code & Share ── */
.room-code {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: 0.08em;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
}
.share-link {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  padding: 0.5rem;
  font-size: 0.78rem;
  text-align: center;
  width: 100%;
}
.hint { text-align: center; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }

/* ── Status ── */
.status { text-align: center; color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }
.status.connected { color: var(--success); }
.status.error     { color: var(--danger); }

/* ── Chat Panel ── */
#panel-chat { max-width: 680px; }
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 2;
}
.peer-name { flex: 1; font-weight: 600; }
.encryption-badge { font-size: 0.72rem; color: var(--success); background: rgba(0,184,148,.12); padding: 0.2rem 0.5rem; border-radius: 20px; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem;
  height: calc(100vh - 130px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.msg {
  max-width: 78%;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 0.92rem;
}
.msg.sent   { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.received { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.msg-meta { font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem; }
.msg.system { align-self: center; color: var(--muted); font-size: 0.78rem; font-style: italic; }

.input-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}
.input-bar input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.92rem;
  outline: none;
}
.input-bar input:focus { border-color: var(--accent); }
.input-bar .btn { flex: 0 0 auto; padding: 0.55rem 1rem; }

/* ── Animations ── */
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel.active { animation: fade-in .2s ease; }
.msg { animation: fade-in .15s ease; }

/* ── Responsive ── */
@media (max-width: 500px) {
  .card { padding: 1.2rem; }
  .messages { height: calc(100vh - 110px); }
}
