* {
  box-sizing: border-box;
}

:root {
  --bg: #0b1020;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-2: rgba(15, 23, 42, 0.88);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --success-hover: #16a34a;
  --user-bubble: linear-gradient(135deg, #2563eb, #1d4ed8);
  --assistant-bubble: rgba(30, 41, 59, 0.92);
  --shadow: 0 10px 35px rgba(0, 0, 0, 0.35);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 22%),
    radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.12), transparent 20%),
    linear-gradient(180deg, #0b1020 0%, #0f172a 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  backdrop-filter: blur(8px);
}

.sidebar {
  width: 310px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.logo-badge {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3b82f6, #22c55e);
  color: #fff;
  font-weight: 700;
  margin-bottom: 10px;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.sidebar-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.new-chat-btn {
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.1));
  color: #fff;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s ease;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.28), rgba(59, 130, 246, 0.18));
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.chat-item {
  padding: 14px;
  border-radius: 16px;
  cursor: pointer;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.chat-item:hover {
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.chat-item.active {
  border-color: rgba(96, 165, 250, 0.85);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.15);
}

.chat-title {
  font-size: 14px;
  font-weight: 600;
  color: #f3f4f6;
  margin-bottom: 8px;
  line-height: 1.4;
}

.chat-date {
  font-size: 12px;
  color: var(--muted);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(10px);
}

.topbar h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.topbar span {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant {
  justify-content: flex-start;
}

.message {
  max-width: min(820px, 80%);
  padding: 16px 18px;
  border-radius: 20px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.message.user {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 8px;
}

.message.assistant {
  background: var(--assistant-bubble);
  color: #e5e7eb;
  border-bottom-left-radius: 8px;
}

.message.loading {
  opacity: 0.75;
  font-style: italic;
}

.chat-form {
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
}

.input-wrap {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px;
  box-shadow: var(--shadow);
}

#messageInput {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 15px;
  line-height: 1.5;
  min-height: 28px;
  max-height: 180px;
  padding: 8px 10px;
}

#messageInput::placeholder {
  color: #7c8aa3;
}

.send-btn {
  border: none;
  background: linear-gradient(135deg, var(--success), #16a34a);
  color: white;
  padding: 14px 18px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  min-width: 105px;
  transition: 0.2s ease;
}

.send-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, var(--success-hover), #15803d);
}

.send-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 520px;
}

.empty-state h3 {
  margin: 0 0 10px;
  font-size: 28px;
  color: #f8fafc;
}

.empty-state p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .sidebar {
    width: 240px;
  }

  .message {
    max-width: 90%;
  }
}

@media (max-width: 700px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .messages {
    padding: 18px;
  }

  .chat-form {
    padding: 14px;
  }

  .input-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .send-btn {
    width: 100%;
  }

  .message {
    max-width: 100%;
  }
}
.message-box {
  position: relative;
  display: inline-block;
  max-width: min(820px, 80%);
}

.message {
  max-width: 100%;
}

.delete-message-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: none;
}

.message-row:hover .delete-message-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.delete-message-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.message.user,
.message.assistant {
  padding-top: 18px;
  padding-right: 42px;
}

.chat-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chat-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.delete-chat-btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-item:hover .delete-chat-btn {
  display: inline-flex;
}

.delete-chat-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}