:root {
  --bg: #fff4ea;
  --bg-deep: #ffd6c6;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: #fffdfb;
  --line: rgba(82, 45, 31, 0.12);
  --text: #27180f;
  --muted: #765749;
  --accent: #ff6b57;
  --accent-dark: #8d36c9;
  --accent-soft: #ffe2d8;
  --danger: #a83f2f;
  --shadow: 0 22px 44px rgba(214, 119, 73, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 34%),
    radial-gradient(circle at 18% 14%, rgba(255, 107, 87, 0.18), transparent 28%),
    radial-gradient(circle at 82% 18%, rgba(141, 54, 201, 0.16), transparent 24%),
    radial-gradient(circle at bottom right, rgba(255, 180, 86, 0.2), transparent 30%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
}

body {
  padding: 24px;
  overflow: hidden;
}

body.lightbox-open {
  overflow: hidden;
}

.context-menu {
  position: fixed;
  z-index: 50;
  min-width: 180px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(27, 34, 28, 0.96);
  box-shadow: 0 20px 45px rgba(14, 18, 15, 0.22);
}

.context-menu[hidden],
.lightbox-overlay[hidden],
.message-action-bar[hidden],
.reply-composer[hidden] {
  display: none !important;
}

.context-menu-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  color: #f6fff9;
  text-align: left;
}

.context-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 30px;
  background: rgba(14, 18, 15, 0.88);
  cursor: pointer;
}

.lightbox-image {
  max-width: min(92vw, 1200px);
  max-height: 84vh;
  border-radius: 24px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.32);
  object-fit: contain;
}

.lightbox-image-hidden {
  display: none;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  cursor: pointer;
}

.lightbox-status {
  margin: 0;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  cursor: pointer;
}

.toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 20px;
  background: rgba(27, 34, 28, 0.94);
  color: #f6fff9;
  box-shadow: 0 20px 45px rgba(14, 18, 15, 0.22);
  transform: translateY(0);
  opacity: 1;
  transition: transform 220ms ease, opacity 220ms ease;
  pointer-events: auto;
  cursor: pointer;
}

.toast-exit {
  opacity: 0;
  transform: translateY(-8px);
}

.toast-avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff7d66, #ffb24b 45%, #8d36c9);
  color: white;
  font-weight: 700;
}

.toast-copy strong,
.toast-copy p {
  display: block;
  margin: 0;
}

.toast-copy p {
  margin-top: 4px;
  color: rgba(246, 255, 249, 0.78);
}

body.locked {
  overflow: hidden;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(19, 24, 19, 0.46);
  backdrop-filter: blur(10px);
}

.overlay[hidden] {
  display: none;
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: rgba(255, 252, 246, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
  max-width: 1500px;
  margin: 0 auto;
  height: calc(100vh - 48px);
}

.sidebar,
.main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

.brand-block,
.panel,
.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-block {
  padding: 28px;
  border-radius: 30px;
}

.brand-block h1 {
  margin: 10px 0 12px;
  font-size: clamp(2.6rem, 4vw, 4.1rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.lede {
  margin: 0;
  max-width: 26ch;
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: var(--accent-dark);
}

.panel {
  padding: 20px;
  border-radius: 24px;
}

.chat-shell {
  grid-template-columns: 380px minmax(0, 1fr);
  align-items: stretch;
}

.app-sidebar,
.chat-main {
  min-height: 0;
}

.messenger-brand {
  flex: 0 0 auto;
  padding: 18px 20px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 237, 229, 0.92)),
    radial-gradient(circle at top right, rgba(141, 54, 201, 0.14), transparent 42%);
}

.messenger-brand-head {
  align-items: flex-start;
}

.messenger-brand h1 {
  margin: 4px 0 0;
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, #ff6b57, #8d36c9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.chat-sidebar-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 14px;
}

.chat-sidebar-search {
  width: 100%;
}

.chat-list-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 6px;
}

.chat-main {
  height: 100%;
}

.messenger-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.conversation-topbar {
  flex: 0 0 auto;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(41, 45, 36, 0.08);
}

.conversation-tools {
  align-items: center;
}

.messenger-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin-top: 12px;
  padding: 8px 10px 10px 2px;
}

.utility-drawer {
  display: none;
}

.panel-head,
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.message-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px 0 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 107, 87, 0.08), rgba(141, 54, 201, 0.08));
  border: 1px solid rgba(255, 107, 87, 0.14);
}

.panel-head h2,
.hero h2 {
  margin: 0;
  font-size: 1.15rem;
}

.hero {
  padding: 22px 24px;
  border-radius: 28px;
}

.hero h2 {
  font-size: clamp(1.6rem, 2vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #efe7d7;
  color: var(--text);
  font-size: 0.85rem;
}

.badge.success {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge.warning {
  background: #fff0bf;
  color: #8a6400;
}

.badge.danger {
  background: #ffd7d0;
  color: var(--danger);
}

.muted {
  margin: 0;
  color: var(--muted);
}

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

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

.search-input {
  min-width: 220px;
  border-radius: 999px;
}

.search-input-small {
  min-width: 180px;
}

.code-block {
  display: block;
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(18, 22, 18, 0.86);
  color: #d8fbe7;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-x: auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.reply-composer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-left: 4px solid rgba(255, 107, 87, 0.7);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 107, 87, 0.14), rgba(141, 54, 201, 0.08));
}

.reply-composer-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.reply-composer-copy strong {
  color: var(--accent-dark);
  font-size: 0.86rem;
}

.reply-composer-copy span {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(31, 36, 28, 0.16);
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--panel-strong);
  color: var(--text);
}

textarea {
  resize: vertical;
}

button {
  border: none;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.primary-btn,
.secondary-btn {
  padding: 13px 18px;
  border-radius: 999px;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, #ff6b57, #ff9f43 48%, #8d36c9);
  color: white;
  box-shadow: 0 14px 30px rgba(255, 107, 87, 0.26);
}

.secondary-btn {
  background: linear-gradient(135deg, rgba(255, 239, 229, 0.98), rgba(250, 233, 255, 0.96));
  color: var(--text);
}

.subtle-btn {
  padding: 10px 14px;
  font-size: 0.9rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 20px;
}

.chat-list,
.message-list,
.event-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-list {
  max-height: 620px;
  overflow: auto;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.chat-item {
  display: grid;
  grid-template-columns: 28px 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 14px;
  border-radius: 20px;
  background: var(--panel-strong);
  border: 1px solid transparent;
  text-align: left;
}

.chat-item.active {
  border-color: rgba(255, 107, 87, 0.28);
  background: linear-gradient(135deg, #fff7f1, #fff0fb 56%, #eef6ff);
}

.chat-selected {
  outline: 2px solid rgba(255, 107, 87, 0.3);
}

.chat-select-box {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  background: rgba(236, 230, 215, 0.98);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  justify-self: center;
  color: var(--accent-dark);
  opacity: 0.75;
}

.chat-side {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chat-actions {
  display: flex;
  gap: 8px;
  padding-left: 40px;
}

.tiny-btn {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(236, 230, 215, 0.95);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 74px;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(31, 143, 99, 0.12);
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.muted-chip {
  background: rgba(95, 100, 88, 0.12);
  color: var(--muted);
}

.unread-badge {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff6b57, #8d36c9);
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(141, 54, 201, 0.22);
}

.chat-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ff7d66, #ffb347 46%, #8d36c9);
  color: white;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(141, 54, 201, 0.16);
}

.chat-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.chat-copy strong {
  font-size: 1.02rem;
}

.chat-copy small {
  font-size: 0.9rem;
}

.typing-preview {
  color: #8d36c9;
  font-weight: 700;
}

.conversation-panel {
  min-height: 720px;
  display: flex;
  flex-direction: column;
}

.message-list {
  flex: 1;
  min-height: 420px;
  overflow: auto;
  padding-right: 8px;
  padding-bottom: 8px;
}

.chat-compose {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(41, 45, 36, 0.08);
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(246, 241, 231, 0.2), rgba(246, 241, 231, 0.96) 32%);
  backdrop-filter: blur(6px);
}

.chat-send-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.chat-send-form textarea {
  min-height: 64px;
  max-height: 140px;
  border-radius: 20px;
}

.message {
  width: fit-content;
  max-width: min(78%, 720px);
  min-width: 0;
  padding: 16px 18px 12px;
  border-radius: 22px;
  background: var(--panel-strong);
  box-shadow: 0 10px 28px rgba(44, 50, 33, 0.06);
  cursor: pointer;
  position: relative;
}

.message-selected {
  outline: 2px solid rgba(31, 143, 99, 0.35);
}

.message.incoming {
  background: #fffdf9;
  width: fit-content;
}

.message p {
  margin: 0 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-select-box {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.98);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-dark);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 20px rgba(44, 50, 33, 0.1);
}

.message:hover .message-select-box,
.chat-item:hover .chat-select-box {
  opacity: 1;
  pointer-events: auto;
}

.reply-action-btn {
  position: absolute;
  top: -10px;
  right: 12px;
  opacity: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.98);
  font-size: 0.78rem;
  font-weight: 700;
  transition: opacity 140ms ease, background 140ms ease;
  pointer-events: none;
  box-shadow: 0 10px 20px rgba(44, 50, 33, 0.1);
}

.reply-action-btn:hover {
  background: rgba(255, 226, 217, 0.95);
}

.message:hover .reply-action-btn,
.message:focus-within .reply-action-btn {
  opacity: 1;
  pointer-events: auto;
}

.day-separator {
  display: flex;
  justify-content: center;
  margin: 8px 0 2px;
}

.day-separator span {
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 234, 223, 0.95), rgba(244, 233, 255, 0.95));
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.message mark,
.chat-copy mark {
  background: #fff0a6;
  color: inherit;
  border-radius: 4px;
  padding: 0 2px;
}

.reply-quote {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-left: 4px solid rgba(255, 107, 87, 0.58);
  border-radius: 14px;
  background: rgba(255, 107, 87, 0.08);
}

.reply-quote strong {
  font-size: 0.82rem;
  color: var(--accent-dark);
}

.reply-quote span {
  color: var(--muted);
  font-size: 0.88rem;
}

.reply-quote-outgoing {
  background: rgba(141, 54, 201, 0.08);
}

.media-link {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.media-link:hover {
  text-decoration: underline;
}

.image-thumb-link {
  display: block;
  margin-bottom: 10px;
}

.image-thumb {
  display: block;
  width: min(100%, 320px);
  max-height: 280px;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(44, 50, 33, 0.08);
}

.voice-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(141, 54, 201, 0.08);
}

.voice-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 107, 87, 0.14);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.voice-card audio {
  width: 100%;
}

.message footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.message-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tick-set {
  display: inline-flex;
  align-items: center;
}

.tick {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 8px;
}

.tick::before,
.tick::after {
  content: "";
  position: absolute;
  width: 2px;
  background: currentColor;
  border-radius: 2px;
}

.tick::before {
  left: 2px;
  top: 4px;
  height: 4px;
  transform: rotate(45deg);
}

.tick::after {
  left: 5px;
  top: 1px;
  height: 8px;
  transform: rotate(-45deg);
}

.tick.double {
  margin-left: -2px;
}

.tick.double::after {
  box-shadow: 4px 0 0 currentColor;
}

.tick.double::before {
  box-shadow: 4px 0 0 currentColor;
}

.tick-pending {
  color: #8f928a;
}

.tick-delivered {
  color: #6f7f77;
}

.tick-read {
  color: #1f9aff;
}

.reaction-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 10px;
  flex-wrap: wrap;
}

.emoji-btn {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(236, 230, 215, 0.92);
  font-size: 0.95rem;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 107, 87, 0.16), rgba(141, 54, 201, 0.12));
  font-size: 0.95rem;
}

.message.outgoing {
  align-self: flex-end;
  background: linear-gradient(135deg, #ffe7de, #fff0f6 58%, #efe9ff);
}

.message.incoming {
  align-self: flex-start;
  background: linear-gradient(135deg, #ffffff, #fff7f1);
}

.empty-state,
.loading-card {
  display: grid;
  place-items: center;
  min-height: 220px;
  border-radius: 24px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

.loading-card.error {
  color: var(--danger);
}

.event-card {
  padding: 16px;
  border-radius: 20px;
  background: var(--panel-strong);
}

.event-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.event-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 0.82rem;
}

.inline-form {
  margin-top: 8px;
}

.code-pre {
  margin: 16px 0 0;
  padding: 16px;
  border-radius: 18px;
  min-height: 180px;
  background: rgba(18, 22, 18, 0.9);
  color: #d8fbe7;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.secondary-grid {
  margin-top: 2px;
}

.steps {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.steps li + li {
  margin-top: 8px;
}

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

  .shell,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .shell {
    height: auto;
  }

  .chat-shell {
    grid-template-columns: 1fr;
  }

  .conversation-panel {
    min-height: 500px;
  }

  .message-list,
  .chat-list {
    max-height: none;
    height: auto;
  }

  .chat-row {
    grid-template-columns: 1fr;
  }

  .chat-actions {
    padding-left: 0;
  }
}

@media (max-width: 640px) {
  body {
    padding: 14px;
    overflow: auto;
  }

  .toast-stack {
    top: 14px;
    right: 14px;
    left: 14px;
    width: auto;
  }

  .brand-block,
  .panel,
  .hero {
    border-radius: 22px;
  }

  .hero,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-head-wrap {
    align-items: flex-start;
  }

  .search-input,
  .search-input-small {
    min-width: 100%;
  }

  .message {
    max-width: 90%;
    min-width: 0;
  }

  .reply-composer {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-send-form {
    grid-template-columns: 1fr;
  }

  .message-action-bar {
    align-items: flex-start;
    flex-direction: column;
  }
}

