:root {
  --bg: #f7f1e6;
  --bg-accent: #e7f2f1;
  --panel: #ffffff;
  --panel-strong: #fef7ef;
  --text: #1d1f21;
  --muted: #596467;
  --accent: #e56b3a;
  --accent-strong: #cf5223;
  --teal: #2d8a8f;
  --border: rgba(29, 31, 33, 0.08);
  --shadow: 0 18px 50px rgba(16, 24, 32, 0.12);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(circle at top left, #fff7e1 0%, var(--bg) 48%, var(--bg-accent) 100%);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
  background:
    radial-gradient(circle at 20% 20%, rgba(229, 107, 58, 0.16), transparent 42%),
    radial-gradient(circle at 80% 0%, rgba(45, 138, 143, 0.2), transparent 38%),
    radial-gradient(circle at 70% 90%, rgba(229, 107, 58, 0.12), transparent 45%);
}

.app {
  position: relative;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  padding: 28px;
  z-index: 1;
  min-height: 100vh;
}

.sidebar,
.chat {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: lift 600ms ease;
}

.sidebar {
  background: linear-gradient(180deg, #fff 0%, #fff7f0 100%);
}

.sidebar-header {
  padding: 20px 22px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.3px;
}

.sidebar-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-controls {
  padding: 0 22px 16px;
  display: grid;
  gap: 10px;
}

.sidebar-controls input {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.status {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0 6px 18px;
  overflow-y: auto;
  flex: 1;
}

.conversation-list li {
  margin: 8px 8px 0;
}

.conversation-button {
  width: 100%;
  border: none;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 6px;
  border: 1px solid transparent;
  transition: border-color 150ms ease, transform 150ms ease;
}

.conversation-button:hover {
  border-color: rgba(229, 107, 58, 0.4);
  transform: translateY(-1px);
}

.conversation-button.active {
  background: var(--panel-strong);
  border-color: rgba(229, 107, 58, 0.6);
}

.conversation-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
}

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

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  display: inline-block;
  margin-left: 6px;
}

.chat {
  padding: 0;
}

.chat-header {
  padding: 20px 26px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chat-header h2 {
  margin: 0;
  font-size: 20px;
}

.chat-header p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.pill {
  background: rgba(45, 138, 143, 0.12);
  color: var(--teal);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.message-list {
  flex: 1;
  padding: 18px 22px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
  animation: fadeUp 250ms ease;
}

.message.agent {
  align-self: flex-end;
  background: linear-gradient(135deg, #f7a76c, #e56b3a);
  color: #fff;
}

.message.member {
  align-self: flex-start;
  background: #f5f5f5;
  color: var(--text);
}

.message .meta {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.7;
}

.message-form {
  display: flex;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.message-form input {
  flex: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 14px;
}

.message-form button,
.sidebar-header button {
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.message-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.message-form button:hover,
.sidebar-header button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.placeholder,
.empty {
  font-size: 14px;
  color: var(--muted);
  padding: 18px;
}

.login-panel {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 24, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 5;
  backdrop-filter: blur(4px);
}

.login-card {
  background: #fff;
  padding: 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: min(420px, 90vw);
  display: grid;
  gap: 14px;
}

.login-card h2 {
  margin: 0;
  font-size: 22px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-card label {
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.login-card input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

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

.login-error {
  color: #b33030;
  font-size: 12px;
  min-height: 16px;
}

.hidden {
  display: none !important;
}

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

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

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .sidebar {
    order: 1;
  }
}
