:root {
  color-scheme: light;
  --canvas: #e7f0ea;
  --surface: #ffffff;
  --surface-soft: #f5f9f7;
  --surface-strong: #edf5f0;
  --chat-canvas: #eaf2ed;
  --primary: #176b50;
  --primary-strong: #10563f;
  --primary-soft: #dff2e8;
  --primary-pale: #eff8f3;
  --text: #17231e;
  --text-soft: #43534b;
  --muted: #738179;
  --border: #dbe7df;
  --border-strong: #ccdcd2;
  --danger: #bd3f48;
  --warning: #a5651a;
  --shadow-lg: 0 30px 80px rgb(25 70 52 / 18%);
  --shadow-sm: 0 8px 24px rgb(28 67 51 / 8%);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background:
    radial-gradient(circle at 8% 10%, rgb(255 255 255 / 90%) 0, transparent 28%),
    radial-gradient(circle at 92% 90%, rgb(111 181 145 / 26%) 0, transparent 31%),
    linear-gradient(145deg, #edf5f0 0%, #dfece4 100%);
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 320px;
  height: 320px;
  content: '';
  border: 1px solid rgb(23 107 80 / 10%);
  border-radius: 50%;
}

body::before {
  top: -190px;
  right: 14%;
}

body::after {
  bottom: -230px;
  left: 8%;
  width: 420px;
  height: 420px;
}

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

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

button:not(:disabled),
a {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid rgb(23 107 80 / 28%);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 368px minmax(0, 1fr);
  width: min(1440px, calc(100vw - 32px));
  height: min(940px, calc(100dvh - 32px));
  margin: 16px auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
}

.sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-header,
.chat-header {
  display: flex;
  min-height: 76px;
  align-items: center;
}

.sidebar-header {
  justify-content: space-between;
  padding: 14px 18px 12px 20px;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(145deg, #248564, var(--primary));
  border-radius: 14px;
  box-shadow: 0 9px 22px rgb(23 107 80 / 22%);
}

.brand-mark svg,
.empty-mark svg,
.send-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.035em;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text-soft);
  background: transparent;
  border-radius: 13px;
  transition:
    color 180ms ease,
    background 180ms ease,
    transform 180ms ease;
}

.icon-button:hover {
  color: var(--primary);
  background: var(--surface-strong);
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button svg,
.search-icon,
.clear-search svg,
.realtime-badge svg,
.dialog-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button-accent {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgb(23 107 80 / 20%);
}

.icon-button-accent:hover {
  color: #ffffff;
  background: var(--primary-strong);
}

.profile-card {
  display: flex;
  min-height: 62px;
  align-items: center;
  gap: 11px;
  margin: 0 14px 14px;
  padding: 10px 11px;
  background: var(--surface-soft);
  border: 1px solid #e7efea;
  border-radius: 17px;
}

.profile-logout {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border-radius: 9px;
  transition:
    color 180ms ease,
    background 180ms ease;
}

.profile-logout:hover {
  color: var(--danger);
  background: #fff0f1;
}

.profile-logout svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.02em;
  background: hsl(var(--avatar-hue, 153) 42% 42%);
  border-radius: 15px;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%);
}

.avatar-user {
  --avatar-hue: 153;
}

.profile-copy {
  min-width: 0;
  flex: 1;
}

.profile-copy strong,
.profile-copy span {
  display: block;
}

.profile-copy strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.presence-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  background: #25a46f;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgb(37 164 111 / 12%);
}

.connection-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  color: var(--warning);
  font-size: 10px;
  font-weight: 750;
  background: #fff5e8;
  border-radius: 999px;
}

.connection-pill[data-status='online'] {
  color: var(--primary);
  background: var(--primary-soft);
}

.connection-pill[data-status='offline'] {
  color: var(--danger);
  background: #fff0f1;
}

.search-form {
  position: relative;
  display: flex;
  height: 46px;
  align-items: center;
  margin: 0 14px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: 14px;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.search-form:focus-within {
  background: var(--surface);
  border-color: rgb(23 107 80 / 34%);
  box-shadow: 0 0 0 4px rgb(23 107 80 / 8%);
}

.search-submit {
  display: grid;
  width: 40px;
  height: 100%;
  flex: 0 0 auto;
  place-items: center;
  color: inherit;
  background: transparent;
  border-radius: 14px 0 0 14px;
}

.search-submit:hover {
  color: var(--primary);
}

.search-icon {
  width: 18px;
  height: 18px;
}

.search-form input {
  min-width: 0;
  height: 100%;
  flex: 1;
  padding: 0 8px 0 0;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-form input::placeholder {
  color: #8b9891;
}

.search-form input::-webkit-search-cancel-button {
  display: none;
}

.search-form kbd {
  margin-right: 10px;
  padding: 3px 6px;
  color: #8b9790;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 650;
  background: #e9f0ec;
  border: 1px solid #dce6e0;
  border-radius: 6px;
  box-shadow: 0 1px 0 #ffffff;
}

.clear-search {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  margin-right: 8px;
  color: var(--muted);
  background: transparent;
  border-radius: 9px;
}

.clear-search:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.clear-search svg {
  width: 16px;
  height: 16px;
}

.search-form:has(.clear-search:not([hidden])) kbd {
  display: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 21px 20px 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.095em;
  text-transform: uppercase;
}

.section-heading span:last-child {
  font-size: 9px;
  letter-spacing: 0.035em;
  text-transform: none;
}

.conversation-list-state {
  padding: 4px 10px 0;
}

.conversation-list {
  min-height: 0;
  padding: 4px 10px 20px;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-color: #cad9d0 transparent;
  scrollbar-width: thin;
}

.conversation-item + .conversation-item {
  margin-top: 3px;
}

.conversation-card {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 70px;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px;
  text-align: left;
  background: transparent;
  border-radius: 17px;
  transition:
    background 180ms ease,
    transform 180ms ease;
}

.conversation-card::before {
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 0;
  width: 3px;
  content: '';
  background: var(--primary);
  border-radius: 0 4px 4px 0;
  opacity: 0;
  transform: scaleY(0.35);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.conversation-card:hover {
  background: var(--surface-soft);
}

.conversation-card:active {
  transform: scale(0.985);
}

.conversation-card[aria-current='true'] {
  background: var(--primary-pale);
}

.conversation-card[aria-current='true']::before {
  opacity: 1;
  transform: scaleY(1);
}

.conversation-card[aria-current='true'] .avatar {
  background: var(--primary);
}

.conversation-copy {
  min-width: 0;
}

.conversation-title,
.conversation-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  letter-spacing: -0.012em;
}

.conversation-preview {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.conversation-meta {
  display: flex;
  min-width: 46px;
  align-self: stretch;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 9px;
}

.conversation-time {
  color: #849188;
  font-size: 9px;
  font-weight: 650;
  white-space: nowrap;
}

.message-count,
.unread-count {
  display: inline-grid;
  min-width: 23px;
  height: 20px;
  place-items: center;
  padding: 0 6px;
  font-size: 9px;
  font-weight: 800;
  border-radius: 999px;
}

.message-count {
  color: var(--muted);
  background: #edf2ef;
}

.unread-count {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 5px 12px rgb(23 107 80 / 20%);
}

.list-empty {
  padding: 26px 18px;
  color: var(--muted);
  text-align: center;
}

.list-empty strong,
.list-empty span {
  display: block;
}

.list-empty strong {
  color: var(--text-soft);
  font-size: 13px;
}

.list-empty span {
  margin-top: 5px;
  font-size: 11px;
}

.skeleton-conversation {
  display: grid;
  min-height: 70px;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 11px;
  padding: 10px;
}

.skeleton-avatar,
.skeleton-line,
.message-skeleton {
  position: relative;
  overflow: hidden;
  background: #edf3ef;
}

.skeleton-avatar::after,
.skeleton-line::after,
.message-skeleton::after {
  position: absolute;
  inset: 0;
  content: '';
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 72%), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}

.skeleton-avatar {
  width: 46px;
  height: 46px;
  border-radius: 15px;
}

.skeleton-lines {
  display: grid;
  gap: 8px;
}

.skeleton-line {
  width: 74%;
  height: 10px;
  border-radius: 999px;
}

.skeleton-line:last-child {
  width: 48%;
  height: 8px;
}

.chat-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 76px minmax(0, 1fr) auto;
  background: var(--chat-canvas);
}

.chat-header {
  z-index: 2;
  gap: 12px;
  padding: 0 24px;
  background: rgb(255 255 255 / 91%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.back-button {
  display: none;
  margin-left: -7px;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 15px;
}

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

.chat-heading h1,
.chat-heading p {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-heading h1 {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.018em;
}

.chat-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}

.realtime-badge {
  display: inline-flex;
  height: 34px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--warning);
  font-size: 10px;
  font-weight: 750;
  background: #fff5e8;
  border: 1px solid #f4e5cf;
  border-radius: 11px;
}

.realtime-badge[data-status='online'] {
  color: var(--primary);
  background: var(--primary-pale);
  border-color: #dceee4;
}

.realtime-badge[data-status='offline'] {
  color: var(--danger);
  background: #fff0f1;
  border-color: #f4d9dc;
}

.realtime-badge svg {
  width: 15px;
  height: 15px;
}

.messages {
  position: relative;
  min-height: 0;
  padding: 26px clamp(22px, 5vw, 74px) 30px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 1px 1px, rgb(23 107 80 / 5%) 1px, transparent 0) 0 0 / 28px 28px,
    linear-gradient(145deg, rgb(255 255 255 / 30%), transparent 45%),
    var(--chat-canvas);
  scrollbar-color: #bfcfc5 transparent;
  scrollbar-width: thin;
}

.message-rail {
  display: flex;
  width: min(100%, 820px);
  min-height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  margin: 0 auto;
}

.date-divider {
  align-self: center;
  margin: 16px 0 20px;
  padding: 5px 10px;
  color: #65756c;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgb(255 255 255 / 72%);
  border: 1px solid rgb(203 220 210 / 75%);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.message-row {
  display: flex;
  width: 100%;
  margin-top: 8px;
  animation: bubble-in 210ms ease-out both;
}

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

.message-bubble {
  position: relative;
  max-width: min(68%, 560px);
  padding: 10px 13px 7px;
  color: var(--text);
  background: rgb(255 255 255 / 94%);
  border: 1px solid rgb(211 225 217 / 86%);
  border-radius: 17px 17px 17px 6px;
  box-shadow: 0 4px 15px rgb(29 63 49 / 6%);
}

.message-row.is-own .message-bubble {
  color: #123c2e;
  background: linear-gradient(145deg, #dff3e9, #d3eddf);
  border-color: #c7e4d5;
  border-radius: 17px 17px 6px;
  box-shadow: 0 5px 16px rgb(23 107 80 / 8%);
}

.message-sender {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
}

.message-body {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.48;
  white-space: pre-wrap;
}

.message-footer {
  display: flex;
  min-height: 15px;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin: 3px -3px -1px 12px;
  color: #7b8981;
  font-size: 9px;
  font-weight: 650;
}

.message-row.is-own .message-footer {
  color: #4f7d69;
}

.delivery-check {
  color: var(--primary);
  font-size: 11px;
  letter-spacing: -0.25em;
}

.empty-state {
  display: flex;
  width: min(440px, 100%);
  min-height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  margin: 0 auto;
  padding: 38px 20px;
  text-align: center;
}

.empty-illustration {
  position: relative;
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  margin-bottom: 22px;
}

.empty-orbit {
  position: absolute;
  inset: 4px;
  border: 1px dashed rgb(23 107 80 / 24%);
  border-radius: 50%;
  animation: orbit 18s linear infinite;
}

.empty-orbit::before,
.empty-orbit::after {
  position: absolute;
  width: 9px;
  height: 9px;
  content: '';
  background: #70b798;
  border: 4px solid var(--chat-canvas);
  border-radius: 50%;
}

.empty-orbit::before {
  top: 6px;
  left: 17px;
}

.empty-orbit::after {
  right: 4px;
  bottom: 20px;
  width: 6px;
  height: 6px;
  background: var(--primary);
}

.empty-mark {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(145deg, #288665, var(--primary));
  border: 7px solid rgb(255 255 255 / 52%);
  border-radius: 22px;
  box-shadow: 0 16px 34px rgb(23 107 80 / 22%);
}

.empty-mark svg {
  width: 28px;
  height: 28px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.empty-state h2 {
  margin: 8px 0 7px;
  font-size: clamp(21px, 3vw, 27px);
  font-weight: 760;
  letter-spacing: -0.035em;
}

.empty-state > p:last-child {
  max-width: 340px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.state-action {
  min-height: 40px;
  margin-top: 18px;
  padding: 0 16px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 750;
  background: var(--primary);
  border-radius: 12px;
}

.search-results {
  display: grid;
  width: min(100%, 820px);
  align-content: start;
  gap: 9px;
  margin: 0 auto;
}

.search-summary {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.search-result {
  width: 100%;
  padding: 15px 17px;
  text-align: left;
  background: rgb(255 255 255 / 88%);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
  transition:
    border-color 180ms ease,
    transform 180ms ease;
}

.search-result:hover {
  border-color: #bcd9c8;
  transform: translateY(-1px);
}

.search-result strong,
.search-result span {
  display: block;
}

.search-result strong {
  color: var(--primary);
  font-size: 12px;
}

.search-result span {
  margin-top: 5px;
  color: var(--text-soft);
  font-size: 12px;
}

.message-loading {
  display: flex;
  width: min(100%, 820px);
  min-height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 auto;
}

.message-skeleton {
  width: min(58%, 430px);
  height: 54px;
  border-radius: 17px 17px 17px 6px;
}

.message-skeleton:nth-child(even) {
  width: min(48%, 360px);
  align-self: flex-end;
  background: #dcece3;
  border-radius: 17px 17px 6px;
}

.composer {
  z-index: 2;
  padding: 13px clamp(18px, 4vw, 58px) max(12px, env(safe-area-inset-bottom));
  background: rgb(255 255 255 / 90%);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.composer-shell {
  display: flex;
  width: min(100%, 820px);
  min-height: 50px;
  align-items: flex-end;
  gap: 9px;
  margin: 0 auto;
  padding: 5px 5px 5px 17px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.composer-shell:focus-within {
  background: #ffffff;
  border-color: rgb(23 107 80 / 38%);
  box-shadow: 0 0 0 4px rgb(23 107 80 / 7%);
}

.composer-shell:has(textarea:disabled) {
  opacity: 0.68;
}

.composer textarea {
  min-width: 0;
  max-height: 132px;
  flex: 1;
  padding: 9px 0 8px;
  overflow-y: auto;
  line-height: 1.45;
  resize: none;
  background: transparent;
  border: 0;
  outline: 0;
}

.composer textarea::placeholder {
  color: #87948d;
}

.send-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border-radius: 13px;
  box-shadow: 0 7px 16px rgb(23 107 80 / 22%);
  transition:
    background 180ms ease,
    opacity 180ms ease,
    transform 180ms ease;
}

.send-button:hover:not(:disabled) {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.send-button:active:not(:disabled) {
  transform: scale(0.94);
}

.send-button:disabled {
  opacity: 0.38;
  box-shadow: none;
}

.send-button.is-sending svg {
  animation: send-pulse 850ms ease-in-out infinite alternate;
}

.composer-hint {
  width: min(100%, 820px);
  margin: 6px auto 0;
  color: #8a978f;
  font-size: 9px;
  font-weight: 550;
  text-align: center;
}

.conversation-dialog {
  width: min(500px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 24px;
}

.conversation-dialog::backdrop {
  background: rgb(12 30 22 / 48%);
  backdrop-filter: blur(5px);
}

.conversation-dialog[open] {
  animation: dialog-in 190ms ease-out both;
}

.conversation-dialog form {
  display: flex;
  max-height: min(820px, calc(100dvh - 32px));
  flex-direction: column;
  padding: 28px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 24px;
  box-shadow: 0 28px 80px rgb(10 37 26 / 28%);
}

.dialog-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border-radius: 14px;
}

.dialog-heading {
  margin: 18px 0 22px;
}

.dialog-heading h2,
.dialog-heading p {
  margin-right: 0;
  margin-left: 0;
}

.dialog-heading h2 {
  margin-top: 7px;
  margin-bottom: 6px;
  font-size: 23px;
  font-weight: 760;
  letter-spacing: -0.03em;
}

.dialog-heading > p:last-child {
  margin-top: 0;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.conversation-dialog label {
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}

.conversation-dialog input {
  height: 48px;
  padding: 0 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: 0;
}

.conversation-dialog input:focus {
  background: #ffffff;
  border-color: rgb(23 107 80 / 42%);
  box-shadow: 0 0 0 4px rgb(23 107 80 / 8%);
}

.participant-field {
  display: flex;
  min-height: 0;
  flex-direction: column;
  margin-top: 18px;
}

.selected-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 9px;
}

.participant-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 6px;
  padding: 0 5px 0 10px;
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 700;
  background: var(--primary-soft);
  border: 1px solid #cce7d9;
  border-radius: 999px;
}

.participant-chip button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  color: var(--primary);
  font-size: 17px;
  line-height: 1;
  background: rgb(255 255 255 / 55%);
  border-radius: 50%;
}

.participant-search-shell {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 13px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 13px;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.participant-search-shell:focus-within {
  background: #ffffff;
  border-color: rgb(23 107 80 / 42%);
  box-shadow: 0 0 0 4px rgb(23 107 80 / 8%);
}

.participant-search-shell input {
  flex: 1;
  padding-left: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.participant-search-shell input:focus {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.participant-results {
  display: grid;
  max-height: 208px;
  gap: 5px;
  margin-top: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #cad9d0 transparent;
  scrollbar-width: thin;
}

.participant-result {
  display: grid;
  width: 100%;
  min-height: 58px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.participant-result:hover {
  background: var(--surface-soft);
}

.participant-result.is-selected {
  background: var(--primary-pale);
  border-color: #d2e9dd;
}

.participant-avatar {
  width: 38px;
  height: 38px;
  font-size: 11px;
  border-radius: 12px;
}

.participant-copy {
  min-width: 0;
}

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

.participant-copy strong {
  font-size: 11px;
}

.participant-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.participant-action {
  min-width: 52px;
  padding: 4px 8px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 750;
  text-align: center;
  background: var(--primary-soft);
  border-radius: 999px;
}

.participant-result.is-selected .participant-action {
  color: #ffffff;
  background: var(--primary);
}

.participant-status {
  min-height: 16px;
  margin: 7px 2px 0;
  color: var(--muted);
  font-size: 9px;
}

.auth-shell {
  display: grid;
  width: min(1160px, calc(100vw - 32px));
  min-height: min(760px, calc(100dvh - 32px));
  grid-template-columns: minmax(0, 1.05fr) minmax(430px, 0.95fr);
  margin: 16px auto;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgb(255 255 255 / 72%);
  border-radius: 30px;
  box-shadow: var(--shadow-lg);
}

.auth-story {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: clamp(34px, 5vw, 66px);
  overflow: hidden;
  color: #ffffff;
  background:
    radial-gradient(circle at 13% 12%, rgb(157 230 195 / 24%), transparent 32%),
    radial-gradient(circle at 88% 82%, rgb(31 141 103 / 52%), transparent 34%),
    linear-gradient(150deg, #153e30 0%, #0d2f23 100%);
}

.auth-story::before,
.auth-story::after {
  position: absolute;
  content: '';
  border: 1px solid rgb(159 226 197 / 12%);
  border-radius: 50%;
}

.auth-story::before {
  top: -190px;
  right: -120px;
  width: 420px;
  height: 420px;
}

.auth-story::after {
  right: -80px;
  bottom: -220px;
  width: 520px;
  height: 520px;
}

.auth-brand {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 12px;
  color: #ffffff;
  font-size: 19px;
  text-decoration: none;
}

.auth-brand .brand-mark {
  background: rgb(255 255 255 / 13%);
  border: 1px solid rgb(255 255 255 / 13%);
  box-shadow: none;
}

.auth-story-copy {
  position: relative;
  z-index: 1;
  max-width: 500px;
  margin-top: clamp(64px, 10vh, 108px);
}

.auth-story-copy .eyebrow {
  color: #86dab4;
}

.auth-story-copy h1 {
  margin: 13px 0 16px;
  font-size: clamp(34px, 4.6vw, 57px);
  font-weight: 740;
  line-height: 1.04;
  letter-spacing: -0.05em;
}

.auth-story-copy > p:last-child {
  max-width: 430px;
  margin: 0;
  color: rgb(225 242 233 / 72%);
  font-size: 13px;
  line-height: 1.7;
}

.auth-preview {
  position: relative;
  z-index: 1;
  min-height: 188px;
  margin-top: auto;
}

.auth-preview-orbit {
  position: absolute;
  right: 16%;
  bottom: 6px;
  width: 176px;
  height: 176px;
  border: 1px dashed rgb(139 218 180 / 24%);
  border-radius: 50%;
  animation: orbit 24s linear infinite;
}

.auth-preview-card {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  background: rgb(255 255 255 / 12%);
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 17px;
  box-shadow: 0 18px 50px rgb(3 18 12 / 16%);
  backdrop-filter: blur(13px);
}

.auth-preview-card-left {
  bottom: 29px;
  left: 0;
  min-width: 220px;
}

.auth-preview-card-right {
  right: 2%;
  bottom: 82px;
}

.auth-preview-card .avatar {
  width: 39px;
  height: 39px;
  border-radius: 12px;
}

.auth-preview-card strong,
.auth-preview-card small {
  display: block;
}

.auth-preview-card strong {
  font-size: 11px;
}

.auth-preview-card small {
  margin-top: 3px;
  color: rgb(225 242 233 / 63%);
  font-size: 9px;
}

.auth-preview-bubble {
  padding: 8px 11px;
  color: #163b2e;
  font-size: 10px;
  font-weight: 650;
  background: #d7f0e3;
  border-radius: 12px 12px 4px;
}

.auth-preview-bubble b {
  margin-left: 5px;
  color: var(--primary);
}

.auth-footnote {
  position: relative;
  z-index: 1;
  margin: 0;
  color: rgb(225 242 233 / 45%);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.05em;
}

.auth-panel {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: clamp(34px, 6vw, 78px);
  background: radial-gradient(circle at 100% 0, rgb(223 242 232 / 66%), transparent 32%), #ffffff;
}

.auth-loading {
  display: flex;
  align-items: center;
  flex-direction: column;
  color: var(--muted);
  text-align: center;
}

.auth-loading strong {
  margin-top: 17px;
  color: var(--text);
  font-size: 14px;
}

.auth-loading > span:last-child {
  margin-top: 4px;
  font-size: 11px;
}

.auth-spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: orbit 750ms linear infinite;
}

.auth-forms {
  width: min(100%, 390px);
}

.auth-heading {
  margin-bottom: 28px;
}

.auth-heading h2 {
  margin: 8px 0 7px;
  font-size: clamp(27px, 4vw, 35px);
  font-weight: 760;
  letter-spacing: -0.04em;
}

.auth-heading > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.auth-form label {
  margin: 14px 0 7px;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 750;
}

.auth-form label:first-child {
  margin-top: 0;
}

.auth-form input {
  height: 50px;
  padding: 0 15px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: 0;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.auth-form input:focus {
  background: #ffffff;
  border-color: rgb(23 107 80 / 42%);
  box-shadow: 0 0 0 4px rgb(23 107 80 / 8%);
}

.auth-form input::placeholder {
  color: #929f98;
}

.form-error {
  margin: 13px 1px 0;
  padding: 10px 12px;
  color: #9f323a;
  font-size: 10px;
  font-weight: 600;
  background: #fff1f2;
  border: 1px solid #f4d9dc;
  border-radius: 11px;
}

.auth-submit {
  min-height: 50px;
  margin-top: 20px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 780;
  background: linear-gradient(145deg, #248564, var(--primary));
  border-radius: 14px;
  box-shadow: 0 10px 24px rgb(23 107 80 / 20%);
  transition:
    box-shadow 180ms ease,
    opacity 180ms ease,
    transform 180ms ease;
}

.auth-submit:hover:not(:disabled) {
  box-shadow: 0 13px 30px rgb(23 107 80 / 27%);
  transform: translateY(-1px);
}

.auth-submit:disabled {
  opacity: 0.62;
}

.auth-switch {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.auth-switch button {
  padding: 4px;
  color: var(--primary);
  font-weight: 750;
  background: transparent;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 9px;
  margin-top: 24px;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  font-size: 11px;
  font-weight: 750;
  border-radius: 13px;
  transition:
    background 180ms ease,
    transform 180ms ease;
}

.button:active {
  transform: scale(0.97);
}

.button-secondary {
  color: var(--text-soft);
  background: var(--surface-strong);
}

.button-secondary:hover {
  background: #e3ede7;
}

.button-primary {
  color: #ffffff;
  background: var(--primary);
}

.button-primary:hover {
  background: var(--primary-strong);
}

.button:disabled {
  opacity: 0.55;
}

.toast-region {
  position: fixed;
  z-index: 20;
  right: 28px;
  bottom: 28px;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 9px 1fr;
  gap: 11px;
  align-items: start;
  padding: 13px 15px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 650;
  background: #21372e;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 14px;
  box-shadow: 0 15px 35px rgb(13 37 27 / 24%);
  animation: toast-in 190ms ease-out both;
}

.toast::before {
  width: 9px;
  height: 9px;
  margin-top: 3px;
  content: '';
  background: #75d3aa;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgb(117 211 170 / 12%);
}

.toast.is-error::before {
  background: #ff8f96;
  box-shadow: 0 0 0 4px rgb(255 143 150 / 12%);
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.98);
  }
}

@keyframes orbit {
  to {
    transform: rotate(360deg);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes send-pulse {
  to {
    transform: translate(2px, -2px);
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 330px minmax(0, 1fr);
  }

  .auth-shell {
    width: min(560px, calc(100vw - 32px));
    min-height: min(720px, calc(100dvh - 32px));
    grid-template-columns: 1fr;
  }

  .auth-story {
    display: none;
  }

  .realtime-badge span {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--surface);
  }

  body::before,
  body::after {
    display: none;
  }

  .app-shell {
    position: relative;
    display: block;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-shell {
    width: 100vw;
    min-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-panel {
    min-height: 100dvh;
    padding: max(34px, env(safe-area-inset-top)) 24px max(34px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .sidebar,
  .chat-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transition:
      opacity 210ms ease,
      transform 210ms ease;
  }

  .sidebar {
    z-index: 2;
    border-right: 0;
    opacity: 1;
    transform: translateX(0);
  }

  .chat-panel {
    z-index: 3;
    opacity: 0;
    pointer-events: none;
    transform: translateX(8%);
  }

  .app-shell.is-chat-open .sidebar {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-8%);
  }

  .app-shell.is-chat-open .chat-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .sidebar-header,
  .chat-header {
    min-height: calc(70px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  .profile-card {
    margin-bottom: 12px;
  }

  .conversation-list {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }

  .back-button {
    display: grid;
  }

  .chat-header {
    padding-right: 14px;
    padding-left: 11px;
  }

  .messages {
    padding: 20px 13px 24px;
  }

  .message-bubble {
    max-width: 84%;
  }

  .composer {
    padding-right: 10px;
    padding-left: 10px;
  }

  .composer-hint {
    display: none;
  }

  .toast-region {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .sidebar-header {
    padding-right: 14px;
    padding-left: 16px;
  }

  .profile-card,
  .search-form {
    margin-right: 10px;
    margin-left: 10px;
  }

  .conversation-list {
    padding-right: 6px;
    padding-left: 6px;
  }

  .connection-pill {
    display: none;
  }

  .realtime-badge {
    display: none;
  }

  .profile-card .connection-pill {
    display: none;
  }

  .auth-panel {
    padding-right: 20px;
    padding-left: 20px;
  }

  .auth-heading {
    margin-bottom: 22px;
  }
}

@media (max-width: 360px) {
  .conversation-dialog form {
    padding: 24px;
  }

  .dialog-actions {
    grid-template-columns: 0.82fr 1.5fr;
  }

  .button {
    padding-right: 10px;
    padding-left: 10px;
  }
}

@media (max-height: 650px) and (min-width: 761px) {
  .app-shell {
    height: calc(100dvh - 16px);
    margin-top: 8px;
    margin-bottom: 8px;
  }

  .sidebar-header,
  .chat-header {
    min-height: 68px;
  }

  .chat-panel {
    grid-template-rows: 68px minmax(0, 1fr) auto;
  }

  .profile-card {
    min-height: 56px;
    margin-bottom: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.search-result-meta {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

.message-row.is-highlighted .message-bubble {
  box-shadow: 0 0 0 2px var(--primary);
  transition: box-shadow 0.3s ease;
}
