* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f6f9;
  min-height: 100vh;
  padding: 32px 20px;
}

.page { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

/* ── Header ── */
.header {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left { display: flex; align-items: center; gap: 14px; }

.host-badge {
  background: #f4b942;
  color: #1a1a2e;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.header h1 { color: #fff; font-size: 18px; font-weight: 600; }

.peer-count-pill {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #34a853;
  animation: pulse 1.5s infinite;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  padding: 24px 28px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 16px;
}

/* ── Add Peer Panel ── */
.add-peer-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

textarea {
  width: 100%;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  resize: vertical;
  outline: none;
  background: #fafafa;
  transition: border-color 0.2s;
}
textarea:focus { border-color: #1a73e8; background: #fff; }

/* ── Buttons ── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary { background: #1a73e8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1557b0; }
.btn-primary:disabled { background: #a8c7fa; cursor: not-allowed; }
.btn-success { background: #34a853; color: #fff; }
.btn-success:hover { background: #1e8e3e; }
.btn-ghost { background: #f1f3f4; color: #444; }
.btn-ghost:hover { background: #e2e5e8; }

/* ── Peer Cards Grid ── */
.peers-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.no-peers {
  text-align: center;
  color: #bbb;
  font-size: 14px;
  padding: 24px 0;
}

.peer-card {
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 16px 20px;
  transition: border-color 0.3s;
}

.peer-card.connected { border-color: #34a853; background: #f8fdf9; }
.peer-card.disconnected { border-color: #ea4335; background: #fef7f6; opacity: 0.7; }
.peer-card.waiting { border-color: #fbbc04; background: #fffbf0; }

.peer-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.peer-card-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #1a1a2e;
}

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fbbc04;
}
.peer-card.connected .status-dot { background: #34a853; animation: pulse 1.5s infinite; }
.peer-card.disconnected .status-dot { background: #ea4335; }

.status-label {
  font-size: 12px;
  font-weight: 600;
  color: #888;
}
.peer-card.connected .status-label { color: #34a853; }
.peer-card.disconnected .status-label { color: #ea4335; }
.peer-card.waiting .status-label { color: #f9ab00; }

.answer-section { margin-top: 10px; }

.output-box {
  background: #f8f9fa;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  word-break: break-all;
  max-height: 70px;
  overflow-y: auto;
  color: #555;
  margin-bottom: 8px;
}

/* ── Chat ── */
.chat-box {
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  height: 240px;
  overflow-y: auto;
  padding: 12px;
  background: #fafafa;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg {
  max-width: 80%;
  padding: 7px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.msg.me { background: #1a73e8; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.from { background: #e8f0fe; color: #1a1a2e; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.system { background: transparent; color: #aaa; font-size: 12px; align-self: center; font-style: italic; }

.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.chat-input-row input:focus { border-color: #1a73e8; }

.error-msg {
  display: none;
  background: #fce8e6;
  border: 1px solid #f28b82;
  color: #c5221f;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 10px;
}

.hint { font-size: 12px; color: #888; margin-bottom: 12px; }

.spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
