:root {
  color-scheme: light;
  --bg: #edf3f8;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.88);
  --surface-soft: rgba(255, 255, 255, 0.46);
  --glass-line: rgba(255, 255, 255, 0.62);
  --line: rgba(91, 111, 132, 0.18);
  --text: #111827;
  --muted: #657383;
  --muted-2: #8a97a5;
  --accent: #0f8cff;
  --accent-2: #2cc6a4;
  --accent-dark: #0568c5;
  --bubble-in: rgba(255, 255, 255, 0.78);
  --bubble-out: linear-gradient(135deg, rgba(15, 140, 255, 0.96), rgba(44, 198, 164, 0.94));
  --shadow-soft: 0 18px 50px rgba(29, 43, 62, 0.14);
  --shadow-material: 0 10px 26px rgba(29, 43, 62, 0.14), 0 2px 8px rgba(29, 43, 62, 0.08);
  --blur: saturate(170%) blur(24px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 18%, rgba(44, 198, 164, 0.30), transparent 28%),
    radial-gradient(circle at 86% 14%, rgba(15, 140, 255, 0.25), transparent 30%),
    linear-gradient(145deg, #f7fbff 0%, #eaf1f7 48%, #dfeaf3 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  padding: 0 16px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), #21a5ed);
  box-shadow: 0 8px 18px rgba(15, 140, 255, 0.24);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 140, 255, 0.28);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button.ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.78);
}

.hidden {
  display: none !important;
}

.ambient {
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.72;
}

.ambient-a {
  width: 420px;
  height: 420px;
  left: -160px;
  top: -120px;
  background: radial-gradient(circle, rgba(44, 198, 164, 0.36), transparent 64%);
}

.ambient-b {
  width: 520px;
  height: 520px;
  right: -210px;
  bottom: -180px;
  background: radial-gradient(circle, rgba(15, 140, 255, 0.30), transparent 66%);
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.sidebar,
.conversation,
dialog {
  border: 1px solid var(--glass-line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-radius: 24px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 16px;
  color: white;
  font-weight: 800;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 42%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px rgba(15, 140, 255, 0.28);
}

.brand strong,
.conversation-head strong {
  display: block;
  letter-spacing: 0;
}

.brand span,
.profile-row span,
.conversation-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.panel {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel h1 {
  font-size: 24px;
  line-height: 1.1;
  margin: 0 0 8px;
}

.panel p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(15, 140, 255, 0.62);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 0 0 4px rgba(15, 140, 255, 0.12);
}

input,
select {
  height: 46px;
  padding: 0 14px;
}

textarea {
  resize: none;
  min-height: 46px;
  max-height: 136px;
  padding: 12px 14px;
}

.hint {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.avatar {
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.avatar.has-image {
  color: transparent;
  text-indent: -999px;
}

.avatar-large {
  width: 76px;
  height: 76px;
  flex-basis: 76px;
  border-radius: 24px;
  font-size: 26px;
}

.profile-editor-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.panel button + button {
  margin-left: 8px;
}

.chat-list {
  overflow: auto;
  padding: 10px;
}

.chat-list::-webkit-scrollbar,
.messages::-webkit-scrollbar {
  width: 10px;
}

.chat-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb {
  background: rgba(101, 115, 131, 0.24);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.chat-item {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: var(--text);
  background: transparent;
  border-radius: 18px;
  text-align: left;
  padding: 11px;
  box-shadow: none;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.50);
  box-shadow: none;
}

.chat-item.active {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-material);
}

.chat-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(var(--accent), var(--accent-2));
}

.chat-item strong,
.chat-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.conversation {
  display: grid;
  grid-template-rows: 78px minmax(0, 1fr) auto;
  min-width: 0;
  overflow: hidden;
  border-radius: 28px;
}

.conversation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px 0 22px;
  background: rgba(255, 255, 255, 0.38);
  border-bottom: 1px solid var(--line);
}

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

.head-actions button,
.composer button {
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 16px;
}

.head-actions button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  box-shadow: none;
}

.messages {
  overflow: auto;
  padding: 28px 22px;
  background:
    linear-gradient(rgba(245, 249, 252, 0.40), rgba(230, 240, 248, 0.34)),
    radial-gradient(circle at 24% 18%, rgba(44, 198, 164, 0.14), transparent 32%),
    radial-gradient(circle at 76% 32%, rgba(15, 140, 255, 0.12), transparent 34%);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  width: min(420px, 90%);
  min-height: 180px;
  margin: 15vh auto 0;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  border: 1px solid var(--glass-line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.empty-state h2 {
  color: var(--text);
  font-size: 22px;
  margin: 0;
}

.empty-state p {
  margin: 0;
}

.message {
  position: relative;
  max-width: min(680px, 78%);
  margin: 0 0 10px;
  padding: 12px 14px 10px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 20px 20px 20px 8px;
  background: var(--bubble-in);
  box-shadow: 0 10px 26px rgba(29, 43, 62, 0.10);
  backdrop-filter: saturate(150%) blur(18px);
  -webkit-backdrop-filter: saturate(150%) blur(18px);
}

.message.mine {
  margin-left: auto;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.30);
  border-radius: 20px 20px 8px 20px;
  background: var(--bubble-out);
  box-shadow: 0 12px 28px rgba(15, 140, 255, 0.24);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.message.mine .message-meta {
  color: rgba(255, 255, 255, 0.76);
}

.message-actions {
  display: inline-flex;
  gap: 5px;
}

.message-actions button {
  min-height: 28px;
  padding: 0 9px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  box-shadow: none;
}

.message.mine .message-actions button {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.35);
}

.composer {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  gap: 10px;
  align-items: end;
  padding: 14px 16px 16px;
  background: rgba(255, 255, 255, 0.42);
  border-top: 1px solid var(--line);
}

.composer textarea {
  background: rgba(255, 255, 255, 0.78);
}

dialog {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.32);
  backdrop-filter: blur(8px);
}

.dialog-card {
  padding: 20px;
  background: transparent;
}

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh minmax(0, 58vh);
    height: auto;
    min-height: 100vh;
    padding: 10px;
    gap: 10px;
  }

  .sidebar,
  .conversation {
    border-radius: 22px;
  }

  .conversation {
    min-height: 58vh;
    grid-template-rows: 66px minmax(0, 1fr) auto;
  }

  .brand,
  .conversation-head {
    min-height: 66px;
  }

  .panel {
    padding: 14px;
  }

  .message {
    max-width: 92%;
  }

  .messages {
    padding: 18px 12px;
  }
}
