﻿:root {
  --bg: #eef3f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #52606d;
  --border: #d9e2ec;
  --primary: #0b6bcb;
  --primary-hover: #0958a8;
  --live: #e94235;
  --connector: #9fb8d0;
  --hot: #ffd98a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top right, #f9fbfd, var(--bg) 50%);
  color: var(--text);
}

.site-header {
  padding: 1.5rem;
  text-align: center;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.site-header h1 { margin: 0; }
.site-header p { margin: 0.5rem 0 0; color: var(--muted); }

.layout { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.view { display: none; }
.view.active { display: block; }

.hero {
  background: linear-gradient(135deg, #ffffff, #f3f8fc);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.hero h2 { margin: 0; font-size: 1.8rem; }
.hero p { margin: 0.45rem 0 0.9rem; color: var(--muted); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.stat-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fff;
}

.stat-box span { display: block; font-size: 1.2rem; font-weight: 700; }
.stat-box small { color: var(--muted); }

.tag-row {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.tag-chip {
  display: inline-flex;
  border: 1px solid #c8daeb;
  color: #244e74;
  border-radius: 999px;
  padding: 0.18rem 0.58rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: #f2f8fe;
}

.tag-chip.small { font-size: 0.72rem; }

.stream-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0.8rem;
  margin-bottom: 1rem;
}

.activity-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.market-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0.8rem;
}

.market-panel h3 {
  margin: 0;
}

.market-subtitle {
  margin: 0.3rem 0 0.7rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.people-roster {
  display: grid;
  gap: 0.35rem;
  max-height: 360px;
  overflow: auto;
}

.market-person {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid #e4edf6;
  background: #f9fbfd;
  border-radius: 8px;
  padding: 0.28rem 0.45rem;
}

.market-name {
  font-size: 0.86rem;
  color: #20394f;
}

.market-role {
  font-size: 0.72rem;
  color: #496987;
  border: 1px solid #cfe0ef;
  border-radius: 999px;
  padding: 1px 6px;
  background: #eef6fd;
}

.role-avatar {
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  user-select: none;
  vertical-align: middle;
}

.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 0.62rem;
}

.avatar-md {
  width: 28px;
  height: 28px;
  font-size: 0.68rem;
  margin: 0 0.32rem;
}

.avatar-lg {
  width: 34px;
  height: 34px;
  font-size: 0.78rem;
}

.role-staff_sales {
  color: #0e3f6b;
  background: #e9f3ff;
  border-color: #8fb7df;
  box-shadow: 0 0 0 2px rgba(123, 170, 216, 0.15);
}

.role-staff_president {
  color: #f5f8ff;
  background: #1f3652;
  border-color: #0f243e;
  box-shadow: 0 0 0 2px rgba(179, 198, 223, 0.35);
}

.role-staff_csr {
  color: #1f5d46;
  background: #e8f8ef;
  border-color: #8ed0aa;
}

.role-staff_engineer {
  color: #4d2c70;
  background: repeating-linear-gradient(
    45deg,
    #f0e9fb,
    #f0e9fb 4px,
    #ebe2f8 4px,
    #ebe2f8 8px
  );
  border-color: #b9a2da;
}

.role-visitor {
  color: #495a6a;
  background: #f1f4f7;
  border-color: #c9d3dc;
}

.stream-panel h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.message-stream {
  display: grid;
  gap: 0.25rem;
}

.stream-line {
  font-size: 0.88rem;
  color: #2e3f50;
  padding: 0.28rem 0.4rem;
  border-radius: 6px;
  background: #f7fafc;
  opacity: 1;
  transform: none;
}

.stream-new {
  opacity: 0;
  transform: translateX(-6px);
  animation: tickerIn 0.26s ease forwards, streamFlash 0.2s ease;
  animation-delay: 0s, 0s;
}
.stream-reply {
  margin-left: 28px;
  padding-left: 10px;
  border-left: 2px solid #b8cde2;
  background: #f2f7fc;
}

.stream-reply-mark {
  color: #6b88a8;
  font-weight: 700;
  margin-right: 4px;
}

.stream-room {
  color: #0a4c84;
  font-weight: 700;
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.rooms-scene {
  position: relative;
}

.scene-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.scene-line-active {
  stroke: #8fb5d9;
  stroke-width: 2;
  opacity: 0.9;
  animation: sceneLineFade 1.4s ease forwards;
}

.room-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  position: relative;
  overflow: visible;
  isolation: isolate;
}

.hot-room {
  box-shadow: 0 0 0 1px var(--hot), 0 8px 24px rgba(245, 177, 67, 0.14);
}

.bump {
  animation: bumpCard 0.38s ease;
}

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.room-card h3 { margin: 0.5rem 0 0.4rem; }
.room-meta { margin: 0.25rem 0; color: var(--muted); }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #ffd0cc;
  background: #fff3f2;
  color: #b53127;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.5s ease-in-out infinite;
}

.recent-messages {
  margin-top: 0.6rem;
  border-top: 1px solid #ecf1f6;
  padding-top: 0.5rem;
  min-height: 72px;
}

.recent-line {
  color: #3d4b5a;
  font-size: 0.9rem;
  margin: 0.3rem 0;
  opacity: 0;
  transform: translateY(5px);
  animation: liftIn 0.4s ease forwards;
  animation-delay: var(--d, 0s);
}
.recent-reply {
  margin-left: 14px;
  padding-left: 8px;
  border-left: 1px solid #d8e3ee;
}

.avatar-cluster {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

.room-avatar {
  position: absolute;
  left: var(--ax);
  top: var(--ay);
  transform: translate(-50%, -50%);
  animation: avatarDrift 6.5s ease-in-out infinite alternate;
  z-index: 13;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  border: 1px solid #9bb8d5;
  background: #f3f8fd;
  color: #173c5d;
  box-shadow: 0 1px 3px rgba(14, 44, 76, 0.16);
}

.avatar-staff .avatar-dot {
  width: 26px;
  height: 26px;
  border: 2px solid #3f709e;
  background: #e7f1fb;
  box-shadow: 0 2px 5px rgba(31, 71, 112, 0.25);
}

.avatar-staff-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  font-weight: 700;
  color: #315f8b;
  background: #eaf3fc;
  border: 1px solid #c7ddef;
  border-radius: 6px;
  padding: 1px 4px;
}

.state-observing .avatar-dot {
  opacity: 0.72;
  filter: saturate(0.7);
}

.state-idle .avatar-dot {
  opacity: 0.9;
}

.state-asking .avatar-dot,
.state-replying .avatar-dot {
  background: #e8f3ff;
  border-color: #8eb2d6;
}

.avatar-pulse .avatar-dot {
  animation: avatarPulse 1s ease-in-out 2;
}

.card-actions {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

.btn.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }

.people-zone {
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fcfdff;
  position: relative;
}

.people-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}

.people-header h3 { margin: 0; }
.people-header p { margin: 0; color: var(--muted); }

.avatar-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 44px;
  position: relative;
  z-index: 3;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #c8d6e5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #14324f;
  background: linear-gradient(145deg, #dbe9f7, #b9d1ea);
}

.connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.connector-path {
  fill: none;
  stroke: var(--connector);
  stroke-width: 1.4;
  stroke-dasharray: 4 5;
  opacity: 0.7;
}

.room-header, .messages-panel, .moderator-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.room-header { margin-bottom: 1rem; }
.room-content { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.participants-summary {
  margin: 0 0 0.5rem;
  color: #425567;
  font-size: 0.9rem;
}
.observe-state {
  margin-bottom: 0.6rem;
  border: 1px solid #d7e6f5;
  background: #f3f8fd;
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
}

.messages {
  height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem;
  background: #fff;
}

.message-item {
  padding: 0.45rem 0.2rem;
  border-bottom: 1px solid #eef2f7;
  border-radius: 6px;
}
.message-reply {
  margin-left: 20px;
  padding-left: 12px;
  border-left: 2px solid #c8d9ea;
}
.message-item:last-child { border-bottom: none; }
.message-item-new {
  animation: messageIn 0.26s ease, messageGlow 0.65s ease;
}
.message-role-staff .message-meta {
  color: #0b4f89;
}
.message-role-staff .message-text {
  color: #17324b;
  font-weight: 500;
}
.message-role-system {
  background: #f6f8fb;
}
.message-role-system .message-meta {
  color: #607486;
}
.message-meta {
  font-size: 0.84rem;
  color: #32485f;
  font-weight: 600;
}
.message-time {
  font-size: 0.78rem;
  color: #7b8a9b;
  font-weight: 500;
}
.message-text {
  margin-top: 0.16rem;
  color: #1f2933;
}
.typing-indicator {
  min-height: 1rem;
  margin-top: 0.45rem;
  font-size: 0.82rem;
  color: #6c7f92;
}
.message-form { margin-top: 0.8rem; display: flex; gap: 0.5rem; }
.message-form input { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem; }
.join-request { border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; margin-bottom: 0.6rem; }
.hidden { display: none; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #1f2f3f;
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

@keyframes liftIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tickerIn {
  to { opacity: 1; transform: translateX(0); }
}

@keyframes streamFlash {
  0% { background: rgba(147, 197, 253, 0.45); }
  100% { background: #f7fafc; }
}

@keyframes bumpCard {
  0% { transform: scale(1); }
  45% { transform: scale(1.018); }
  100% { transform: scale(1); }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes messageGlow {
  0% { background: rgba(11, 107, 203, 0.1); }
  100% { background: transparent; }
}

@keyframes avatarDrift {
  from { transform: translate(-50%, -50%) translate(0, 0); }
  to { transform: translate(-50%, -50%) translate(var(--dx), var(--dy)); }
}

@keyframes avatarPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}

@keyframes sceneLineFade {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

@media (max-width: 900px) {
  .stats-row { grid-template-columns: 1fr; }
  .activity-layout { grid-template-columns: 1fr; }
  .room-content { grid-template-columns: 1fr; }
  .people-header { flex-direction: column; gap: 0.2rem; }
  .observe-state { flex-direction: column; align-items: flex-start; }
}
