:root {
  --bg-0: #edf4f6;
  --bg-1: #f8fbfb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-alt: #f4f8f9;
  --ink-900: #0f1d2e;
  --ink-700: #274059;
  --ink-500: #5c7287;
  --line: rgba(40, 80, 98, 0.15);
  --brand: #0f766e;
  --brand-strong: #0b5f58;
  --brand-soft: #d5f7f2;
  --accent: #f97316;
  --danger: #dc2626;
  --success: #059669;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow-xl: 0 26px 70px rgba(17, 32, 46, 0.16);
  --shadow-lg: 0 16px 42px rgba(17, 32, 46, 0.1);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink-900);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(90% 80% at 15% -10%, #c7f8f0 0%, transparent 55%),
    radial-gradient(65% 62% at 110% 120%, #ffd8b6 0%, transparent 58%),
    linear-gradient(160deg, var(--bg-0) 0%, var(--bg-1) 64%, #f1f7f7 100%);
}

a {
  color: inherit;
}

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

button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(160deg, var(--brand), #08928d);
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.26);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.ghost,
button.ghost:hover {
  color: var(--ink-900);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

input,
select,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--ink-900);
  background: rgba(255, 255, 255, 0.98);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.3);
  outline-offset: 1px;
}

.app-root {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.ambient-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.45;
}

.ambient-orb.a {
  width: 420px;
  height: 420px;
  left: -150px;
  top: 46px;
  background: radial-gradient(circle, #9cebdd 0%, transparent 70%);
  animation: drift 18s ease-in-out infinite;
}

.ambient-orb.b {
  width: 380px;
  height: 380px;
  right: -120px;
  bottom: -30px;
  background: radial-gradient(circle, #ffd7b5 0%, transparent 70%);
  animation: drift 22s ease-in-out infinite reverse;
}

.ambient-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right, rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 118, 110, 0.04) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at center, black 28%, transparent 85%);
}

@keyframes drift {
  0%,
  100% {
    transform: translateY(0px) translateX(0px);
  }
  50% {
    transform: translateY(-16px) translateX(9px);
  }
}

.kicker {
  margin: 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.muted {
  color: var(--ink-500);
}

.error-text {
  color: var(--danger);
  min-height: 20px;
  font-size: 0.88rem;
}

.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(540px, 100%);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.91), rgba(255, 255, 255, 0.84));
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-xl);
  padding: 34px;
  animation: slideUp 0.5s ease;
}

.login-title {
  margin: 4px 0 4px;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: clamp(2rem, 3.4vw, 2.8rem);
  line-height: 1.05;
}

.login-subtitle {
  margin: 0 0 18px;
  color: var(--ink-700);
}

.login-form {
  display: grid;
  gap: 12px;
}

.field-label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-700);
}

.workspace {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 14px;
}

.glass-card {
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-lg);
}

.sidebar,
.right-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
}

.sidebar-header,
.contacts-card,
.chat-filters,
.chat-list-shell,
.main-header,
.composer,
.events-card,
.members-card {
  padding: 14px;
}

.sidebar-header {
  border-bottom: 1px solid var(--line);
}

.user-headline {
  margin: 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 1.24rem;
}

.user-email {
  margin: 2px 0 0;
  color: var(--ink-500);
  font-size: 0.9rem;
}

.actions-row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.contacts-card {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.section-title {
  margin: 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 0.95rem;
}

.inline-form {
  display: grid;
  gap: 8px;
}

.direct-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.members-picker {
  display: grid;
  gap: 8px;
  max-height: 140px;
  overflow: auto;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}

.pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
}

.chat-filters {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
}

.filter-btn {
  flex: 1;
  color: var(--ink-700);
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
}

.filter-btn.active {
  color: #0b5f58;
  background: linear-gradient(165deg, #e5fbf7, #d2f6ef);
  border-color: rgba(15, 118, 110, 0.35);
}

.chat-list-shell {
  overflow: auto;
  min-height: 0;
}

.chat-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chat-item {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.chat-item:hover {
  transform: translateY(-1px);
}

.chat-item.active {
  border-color: rgba(15, 118, 110, 0.58);
  background: linear-gradient(145deg, #ebfcf8, #dff8f3);
}

.chat-name {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink-900);
}

.chat-meta {
  margin: 3px 0 0;
  font-size: 0.76rem;
  color: var(--ink-500);
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 7px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
}

.badge.mention {
  background: var(--accent);
}

.star-btn {
  border: 0;
  background: transparent;
  color: #b45309;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

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

.main-header {
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chat-title {
  margin: 2px 0 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: clamp(1.1rem, 1.8vw, 1.3rem);
}

.message-board {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(160deg, rgba(247, 252, 253, 0.92), rgba(241, 248, 250, 0.9)),
    radial-gradient(circle at 0% 100%, rgba(15, 118, 110, 0.06), transparent 40%);
  display: grid;
  align-content: start;
  gap: 10px;
}

.message-row {
  display: flex;
}

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

.bubble {
  width: fit-content;
  max-width: min(74%, 620px);
  padding: 9px 11px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.message-row.mine .bubble {
  border-color: rgba(15, 118, 110, 0.4);
  background: linear-gradient(145deg, #ddf9f3, #caf2e9);
}

.bubble-author {
  font-size: 0.72rem;
  color: var(--ink-500);
  margin-bottom: 4px;
}

.bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
}

.bubble-meta {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--ink-500);
}

.bubble-meta .read {
  color: #0284c7;
}

.composer {
  border-top: 1px solid var(--line);
}

.compose-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.compose-grid input {
  border-radius: 999px;
  padding: 11px 14px;
  border-color: rgba(40, 80, 98, 0.22);
}

.legend {
  margin: 0;
  padding: 0 14px 12px;
  color: var(--ink-500);
  font-size: 0.74rem;
}

.right-pane {
  min-height: 0;
}

.events-card,
.members-card {
  border-bottom: 1px solid var(--line);
}

.events-card {
  display: grid;
  gap: 10px;
}

.events-list,
.members-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.events-list {
  max-height: 250px;
  overflow: auto;
}

.event-item {
  border-radius: 12px;
  padding: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
}

.event-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
}

.event-time {
  margin: 4px 0;
  font-size: 0.78rem;
  color: var(--ink-500);
}

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

.member-item {
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  padding: 8px;
  font-size: 0.85rem;
}

.status-chip {
  margin-top: 10px;
  width: fit-content;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 10px;
}

.status-chip.connected {
  background: #d1fae5;
  color: #065f46;
}

.status-chip.disconnected {
  background: #fee2e2;
  color: #7f1d1d;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(15, 29, 46, 0.36);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: min(500px, 100%);
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xl);
  padding: 18px;
  animation: slideUp 0.25s ease;
}

.modal-title {
  margin: 0 0 12px;
  font-family: "Sora", "Manrope", sans-serif;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.empty-state {
  margin: 0;
  color: var(--ink-500);
  font-size: 0.88rem;
}

.top-banner {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 14;
  width: min(880px, calc(100vw - 22px));
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(15, 118, 110, 0.95);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  animation: slideDown 0.25s ease;
}

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

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-8px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1220px) {
  .workspace {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .right-pane {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .events-card,
  .members-card {
    border-bottom: 0;
  }

  .events-card {
    border-right: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    padding: 10px;
  }

  .sidebar {
    max-height: 420px;
  }

  .right-pane {
    grid-template-columns: 1fr;
  }

  .events-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .direct-grid,
  .compose-grid {
    grid-template-columns: 1fr;
  }

  .bubble {
    max-width: 100%;
  }
}
