:root {
  --sidebar-bg: #04070d;
  --stage-bg: #060a12;
  --panel-bg: rgba(20, 23, 31, 0.96);
  --panel-soft: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.08);
  --text: #edf3fb;
  --muted: #97a0ad;
  --muted-soft: #dfe8ef;
  --accent: #7d70ff;
  --accent-2: rgba(128, 108, 255, 0.28);
  --user: #d8d5dc;
  --assistant: rgba(41, 45, 54, 0.82);
  --shadow: 0 18px 40px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body.polybuzz-chat {
  margin: 0;
  min-height: 100vh;
  background: var(--stage-bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

.chat-app-shell {
  display: flex;
  min-height: 100vh;
  background: #050a12;
}

.chat-sidebar {
  width: 240px;
  background: rgba(2, 4, 8, 0.98);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 16px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff74a8, #f4a17a);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(255, 118, 160, 0.25);
}

.brand-text {
  flex: 1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ghost-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  color: var(--muted-soft);
  cursor: pointer;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--muted-soft);
  font-size: 0.95rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

.nav-item.promo {
  color: #f5f7fb;
}

.nav-item.promo span {
  margin-left: auto;
  padding: 4px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffb678, #ef704b);
  font-size: 0.62rem;
  font-weight: 700;
}

.nav-item.promo.muted span {
  background: rgba(255,255,255,0.08);
}

.sidebar-brand {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.chat-main-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 24px 0;
  background: rgba(3, 6, 12, 0.96);
}

.character-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 16px;
}

.character-avatar {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f4f4f5, #d7d4d8 30%, #b0a9b5 70%, #726d7b 99%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
}

.avatar-ring {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.48);
  opacity: 0.9;
}

.character-header h1 {
  margin: 0;
  font-size: clamp(1.2rem, 1.4vw, 2rem);
  letter-spacing: -0.04em;
  font-weight: 700;
}

.message-stream {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 12px 8px;
  overflow-y: auto;
  min-height: 0;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.bubble {
  display: inline-block;
  max-width: min(760px, 72%);
  padding: 14px 16px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 0.98rem;
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}

.bubble-assistant {
  background: rgba(55, 59, 68, 0.92);
  color: #f5f7fb;
  border: 1px solid rgba(255,255,255,0.04);
}

.bubble-user {
  background: rgba(217, 217, 221, 0.95);
  color: #111722;
}

.message.assistant.intro .bubble { background: rgba(73, 78, 88, 0.9); }

.emoji { font-size: 1.05em; }

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: auto;
}

.composer-input-wrap {
  flex: 1;
  display: block;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

#messageInput {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

#messageInput::placeholder { color: var(--muted); }

.tiny-action,
.send-button {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
}

.send-button {
  background: linear-gradient(135deg, #8a7dff, #8552ff);
  border: 0;
  box-shadow: 0 14px 26px rgba(124, 116, 255, 0.28);
}

.profile-rail {
  width: 300px;
  background: linear-gradient(180deg, rgba(19, 15, 24, 0.96), rgba(11, 10, 18, 0.98));
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.profile-visual {
  flex: 1;
  min-height: 310px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(114, 89, 158, 0.94), rgba(62, 52, 97, 0.9));
  border-left: 1px solid rgba(255,255,255,0.05);
}

.profile-ghost {
  width: 130px;
  height: 130px;
  border-radius: 28px;
  background: rgba(255,255,255,0.16);
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18);
}

.profile-ghost::before,
.profile-ghost::after {
  content: "";
  position: absolute;
  inset: 0;
}

.profile-ghost::before {
  left: 42px;
  right: 42px;
  top: 22px;
  bottom: 50px;
  border: 10px solid rgba(255,255,255,0.28);
  border-radius: 50% 50% 45% 45%;
}

.profile-ghost::after {
  left: 28px;
  right: 28px;
  top: 86px;
  bottom: 20px;
  border-radius: 38px 38px 58px 58px;
  border: 10px solid rgba(255,255,255,0.22);
  border-top: 0;
}

.profile-card {
  padding: 18px 18px 22px;
}

.profile-card h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.profile-stats,
.profile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted-soft);
  font-size: 0.8rem;
}

.profile-meta {
  margin-top: 10px;
  justify-content: space-between;
  color: var(--muted);
}

.profile-action {
  margin-top: 18px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 1100px) {
  .chat-sidebar { width: 200px; }
  .profile-rail { width: 240px; }
}

@media (max-width: 900px) {
  .chat-app-shell { flex-direction: column; }
  .chat-sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .chat-workspace { flex-direction: column; }
  .profile-rail {
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .profile-visual { min-height: 220px; }
}

@media (max-width: 560px) {
  .chat-panel { padding: 12px 12px 0; }
  .bubble { max-width: 88%; }
  .composer { gap: 6px; }
  .tiny-action, .send-button { width: 38px; height: 38px; }
  .topbar-search { min-width: 0; }
}
