:root {
  --bg: #050814;
  --bg-elevated: #070b1a;
  --bg-elevated-strong: #090f24;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --accent: #16a34a;
  --accent-soft: rgba(22, 163, 74, 0.16);
  --accent-strong: #22c55e;
  --accent-danger: #e11d48;
  --accent-danger-soft: rgba(225, 29, 72, 0.15);
  --text-main: #f9fafb;
  --text-soft: #9ca3af;
  --text-softer: #6b7280;
  --surface-radius: 1.25rem;
  --transition-fast: 150ms ease-out;
  --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.7);
  --shadow-strong: 0 18px 45px rgba(15, 23, 42, 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #0f172a 0, #020617 55%, #000 100%);
  color: var(--text-main);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 16px;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 640px);
  gap: 16px;
  width: 100%;
  max-width: 1200px;
  background: radial-gradient(circle at top left, #020617, #020617 60%);
  border-radius: 2rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

/* Sidebar */

.sidebar {
  background: linear-gradient(
      145deg,
      rgba(15, 23, 42, 0.94),
      rgba(15, 23, 42, 0.9) 45%,
      rgba(9, 9, 11, 0.94)
    );
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 18px 18px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #22c55e, #16a34a 55%, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #f9fafb;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.45);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-text p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.sidebar-section {
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-section-header h2 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-softer);
}

.chat-search {
  position: relative;
}

.chat-search input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast), background var(--transition-fast);
}

.chat-search input::placeholder {
  color: var(--text-softer);
}

.chat-search input:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.4);
  background: rgba(15, 23, 42, 0.98);
}

.chat-list {
  margin-top: 6px;
  flex: 1;
  overflow: auto;
  padding-right: 4px;
}

.chat-item {
  display: flex;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 14px;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.chat-item:hover {
  background: rgba(15, 23, 42, 0.9);
  transform: translateY(-1px);
}

.chat-item.active {
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.4);
}

.chat-item-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #4ade80, #22c55e 55%, #166534);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: #f9fafb;
  position: relative;
}

.chat-item-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid #020617;
}

.chat-item-main {
  flex: 1;
  min-width: 0;
}

.chat-item-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.chat-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  font-size: 0.7rem;
  color: var(--text-softer);
}

.chat-item-snippet {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-badge {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.12);
  color: var(--accent-strong);
}

/* Chat main */

.chat {
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top right, #020617 0, #020617 60%);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(14px);
  background: linear-gradient(
      90deg,
      rgba(15, 23, 42, 0.98),
      rgba(15, 23, 42, 0.9)
    );
}

.chat-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 20%, #4ade80, #16a34a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #f9fafb;
  position: relative;
}

.chat-avatar.status-online::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid #020617;
}

.chat-header-main h2 {
  margin: 0;
  font-size: 1rem;
}

.chat-header-main p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.chat-header-actions {
  display: flex;
  gap: 8px;
}

/* Messages */

.message-pane {
  flex: 1;
  padding: 14px 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  background: radial-gradient(circle at 0 0, #020617 0, #020617 65%);
}

.message-meta-day {
  align-self: center;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-softer);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.message-row {
  display: flex;
  gap: 8px;
}

.message-row.outbound {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(70%, 460px);
  border-radius: 1.2rem;
  padding: 8px 11px;
  font-size: 0.9rem;
  line-height: 1.3;
  position: relative;
  box-shadow: var(--shadow-strong);
}

.message-row.inbound .message-bubble {
  background: linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.96),
      rgba(15, 23, 42, 0.98)
    );
  border-bottom-left-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.message-row.outbound .message-bubble {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #022c22;
  border-bottom-right-radius: 0.5rem;
}

.message-text {
  margin: 0;
}

.message-meta {
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.9;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.message-row.inbound .message-meta {
  justify-content: flex-start;
  color: var(--text-softer);
}

.message-row.outbound .message-meta {
  color: rgba(15, 23, 42, 0.9);
}

.message-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
}

.message-tag {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-softer);
  margin-bottom: 2px;
}

.message-row.outbound .message-tag {
  color: rgba(15, 23, 42, 0.65);
}

/* Voice bubble */

.message-bubble.voice {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-wave {
  flex: 1;
  height: 22px;
  border-radius: 999px;
  background: radial-gradient(
      circle at 10% 50%,
      rgba(22, 163, 74, 0.25),
      rgba(22, 163, 74, 0.05)
    );
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 3px;
}

.voice-bar {
  flex: 1;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.45);
  transform-origin: center;
}

.voice-bar:nth-child(odd) {
  height: 40%;
}

.voice-bar:nth-child(even) {
  height: 70%;
}

.voice-time {
  font-size: 0.78rem;
  opacity: 0.9;
}

.voice-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-icon .icon {
  transform: translateX(1px);
}

/* Composer */

.composer {
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(
      0deg,
      rgba(15, 23, 42, 0.96) 0,
      rgba(15, 23, 42, 0.9)
    );
  backdrop-filter: blur(12px);
}

.composer-top {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.composer-main {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-input-wrapper {
  flex: 1;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 4px 10px;
  display: flex;
  align-items: center;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast), background var(--transition-fast);
}

.composer-input-wrapper:focus-within {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.4);
  background: rgba(15, 23, 42, 0.98);
}

.composer textarea {
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.3;
  max-height: 120px;
}

.composer textarea::placeholder {
  color: var(--text-softer);
}

.composer-hint {
  font-size: 0.76rem;
  color: var(--text-softer);
  padding-left: 52px;
}

/* Buttons */

button {
  font-family: inherit;
}

.icon-button {
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.icon-button-ghost {
  background: transparent;
}

.icon-button-primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  border-color: rgba(22, 163, 74, 0.4);
  box-shadow: 0 10px 22px rgba(22, 163, 74, 0.5);
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.9);
}

.icon-button-primary:hover {
  background: linear-gradient(135deg, #4ade80, #16a34a);
  box-shadow: 0 10px 30px rgba(22, 163, 74, 0.85);
}

.icon-button:active {
  transform: translateY(0);
  box-shadow: none;
}

.record-button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #22c55e, #15803d);
  box-shadow: 0 14px 34px rgba(22, 163, 74, 0.65);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    filter var(--transition-fast), background var(--transition-fast);
}

.record-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.record-button:active {
  transform: scale(0.96);
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.7);
}

.record-button.is-recording {
  background: radial-gradient(circle at 30% 20%, #fb7185, #e11d48);
  box-shadow: 0 14px 40px rgba(225, 29, 72, 0.8);
  animation: record-pulse 1.1s ease-out infinite;
}

.record-button.is-recording .record-icon svg path {
  fill: #fee2e2;
}

.record-icon {
  width: 20px;
  height: 20px;
}

.record-icon svg {
  width: 100%;
  height: 100%;
  fill: #f9fafb;
}

.pill-button {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 4px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  cursor: pointer;
  background: transparent;
  color: var(--text-soft);
  transition: background var(--transition-fast),
    border-color var(--transition-fast), color var(--transition-fast),
    transform var(--transition-fast);
}

.pill-button-primary {
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--accent-strong);
  background: rgba(22, 163, 74, 0.12);
}

.pill-button-primary:hover {
  background: rgba(22, 163, 74, 0.18);
  transform: translateY(-0.5px);
}

.chip {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast),
    border-color var(--transition-fast), color var(--transition-fast);
}

.chip-outline {
  border-color: var(--border-subtle);
}

.chip-filled {
  background: rgba(22, 163, 74, 0.16);
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--accent-strong);
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent-strong);
}

/* Icons */

.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  position: relative;
}

.icon::before,
.icon::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
}

/* Simple search icon */
.icon-search::before {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid var(--text-soft);
}

.icon-search::after {
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: var(--text-soft);
  transform: translate(7px, 5px) rotate(45deg);
}

/* Simple settings icon */
.icon-settings::before {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--text-soft);
}

.icon-settings::after {
  width: 2px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-soft);
  box-shadow: 4px 0 0 var(--text-soft), -4px 0 0 var(--text-soft);
}

/* Plus icon */
.icon-plus::before {
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: var(--text-softer);
}

.icon-plus::after {
  width: 2px;
  height: 10px;
  border-radius: 999px;
  background: var(--text-softer);
}

/* Send icon (paper plane) */
.icon-send::before {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 12px 18px;
  border-color: transparent transparent #022c22 transparent;
  transform: translate(1px, 2px);
}

.icon-send::after {
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: #022c22;
  transform: translate(1px, 7px) rotate(-18deg);
}

/* Toast */

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: rgba(15, 23, 42, 0.96);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.78rem;
  color: var(--text-main);
  border: 1px solid rgba(148, 163, 184, 0.5);
  box-shadow: var(--shadow-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Animations */

@keyframes record-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 14px 40px rgba(225, 29, 72, 0.8);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 18px 44px rgba(248, 113, 113, 0.85);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 14px 40px rgba(225, 29, 72, 0.8);
  }
}

/* Scrollbars */

.chat-list::-webkit-scrollbar,
.message-pane::-webkit-scrollbar {
  width: 6px;
}

.chat-list::-webkit-scrollbar-track,
.message-pane::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb,
.message-pane::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 999px;
}

/* Responsive */

@media (max-width: 900px) {
  body {
    padding: 0;
  }

  .app-shell {
    border-radius: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }
}

@media (max-width: 480px) {
  .chat-header {
    padding-inline: 12px;
  }

  .message-pane {
    padding-inline: 12px;
  }

  .composer {
    padding-inline: 10px;
  }

  .composer-hint {
    padding-left: 0;
  }
}
