:root {
  font-family: system-ui, "Microsoft YaHei UI", sans-serif;
  color: #172832;
  background: #e8eff0;
  --primary: #076b5b;
  --subtle: #526870;
  --line: #dce6e6;
  --surface: #fff;
  --sidebar: #f6f9f8;
  --active: #e0f0eb;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }
.muted { color: var(--subtle); }

.workspace {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  height: 100dvh;
  width: min(100%, 1280px);
  margin-inline: auto;
  background: var(--surface);
}
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--sidebar);
  border-inline-end: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 17px; border-bottom: 1px solid var(--line); }
.brand strong { font-size: 1.16rem; letter-spacing: .05em; }
.brand-mark, .avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  color: #0a5549;
  background: #d9eee8;
  font-weight: 750;
}
.brand-mark { border-radius: 12px; }
.avatar[data-color="1"] { background: #dae9fa; color: #224b74; }
.avatar[data-color="2"] { background: #fae3cd; color: #74421d; }
.avatar[data-color="3"] { background: #e8dff3; color: #563684; }
.avatar[data-color="4"] { background: #f7dfe9; color: #67304e; }
.avatar[data-color="5"] { background: #f4ebce; color: #5e4818; }
#language { margin-inline-start: auto; max-width: 96px; }
#language, .fields :is(input, select) { border: 1px solid #aec4c4; border-radius: 7px; background: #fff; padding: .45rem .55rem; color: inherit; }
.group-actions, .group-tools, .form-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.group-actions { padding: 14px 13px 8px; }
#groups-heading { margin: 12px 17px 7px; color: var(--subtle); font-size: .875rem; font-weight: 650; }
#groups { min-height: 0; flex: 1; overflow: auto; padding: 0 8px; }
.group-item {
  display: flex;
  width: 100%;
  gap: 10px;
  align-items: center;
  margin-bottom: 3px;
  padding: 9px;
  text-align: start;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
}
.group-item:hover, .group-item[aria-current="true"] { background: var(--active); }
.group-item .avatar { width: 37px; height: 37px; }
.group-label { display: grid; gap: 2px; min-width: 0; }
.group-label :is(strong, small) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-label small { font-size: .79rem; color: var(--subtle); }
#sidebar-status { padding: 9px 13px 13px; }

.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conversation-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 11px 19px;
  border-bottom: 1px solid var(--line);
}
.heading-text { flex: 1; min-width: 0; }
.heading-text h1 { margin: 0; overflow-wrap: anywhere; font-size: 1.25rem; }
.heading-text p { margin: 3px 0 0; font-size: .875rem; }
.heading-text p:empty, .status:empty { display: none; }
.mobile-back { display: none; }
.group-tools { justify-content: flex-end; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 37px;
  padding: .43rem .72rem;
  border: 1px solid #c4d7d6;
  border-radius: 8px;
  background: #fff;
  color: #175348;
  font-size: .91rem;
  font-weight: 650;
  white-space: nowrap;
}
.button:hover:not(:disabled) { background: #eaf5f1; }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.primary:hover:not(:disabled) { background: #07574a; }

.center-view {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 23px;
  background: var(--sidebar);
}
.empty-card { width: min(100%, 435px); padding: 23px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.empty-card h2 { margin: 0 0 7px; font-size: 1.2rem; }
.empty-card p { margin: 0 0 17px; line-height: 1.6; }
.chat-view { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.timeline { flex: 1; min-height: 0; overflow-y: auto; padding: 19px clamp(12px, 3vw, 29px); }
.message { display: flex; gap: 8px; align-items: end; margin: 0 0 13px; }
.message .avatar { width: 31px; height: 31px; }
.message.outgoing { justify-content: flex-end; }
.message.outgoing .avatar { order: 1; }
.message-details { max-width: min(84%, 650px); }
.message-body { margin: 0; padding: 9px 12px; border-radius: 12px 12px 12px 4px; background: #f0f4f4; line-height: 1.48; white-space: pre-wrap; overflow-wrap: anywhere; }
.outgoing .message-body { border-radius: 12px 12px 4px 12px; background: #d7efe6; }
.message-meta { margin: 3px 1px 0; color: var(--subtle); font-size: .78rem; overflow-wrap: anywhere; }
.outgoing .message-meta { text-align: end; }
.compose {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
  padding: 11px clamp(10px, 2vw, 20px) max(11px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.composer-avatar { width: 36px; height: 36px; margin-block-end: 5px; }
.compose textarea { min-height: 46px; max-height: 30dvh; width: 100%; padding: 8px 10px; resize: vertical; border: 1px solid #d4e3e2; border-radius: 8px; background: #f6f9f9; color: inherit; }
.compose > .button { min-height: 46px; }
.compose > .status { grid-column: 2 / -1; }
.status { margin: 0; color: #244d65; font-size: .875rem; overflow-wrap: anywhere; }
.status[data-error="true"] { color: #9b252a; }
.noscript { position: fixed; inset: auto 12px 12px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

dialog { width: min(490px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 19px; border: 1px solid var(--line); border-radius: 12px; color: inherit; }
dialog::backdrop { background: rgb(13 33 49 / 42%); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-header h2 { margin: 0; font-size: 1.22rem; }
.fields { display: grid; gap: 12px; }
.fields label { display: grid; gap: 5px; min-width: 0; font-size: .91rem; }
.fields > .button { justify-self: start; }
.fields input { width: 100%; min-width: 0; }
.invite-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.invitation-preview { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: var(--active); }
.invitation-preview div { min-width: 0; overflow-wrap: anywhere; }
.invitation-preview p { margin: 0 0 3px; font-size: .82rem; }
.request-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.request-row strong { min-width: 0; overflow-wrap: anywhere; }
#requests .muted { margin: 0; }

@media (max-width: 680px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace[data-mobile-view="groups"] .conversation,
  .workspace[data-mobile-view="chat"] .sidebar { display: none; }
  .brand { padding: 14px 13px; }
  .group-item { padding: 12px 9px; }
  .conversation-header { gap: 7px; min-height: 63px; padding: 8px 9px; flex-wrap: wrap; }
  .mobile-back { display: inline-flex; min-width: 32px; padding-inline: 7px; font-size: 1.35rem; line-height: 1; }
  .header-avatar { width: 34px; height: 34px; }
  .heading-text h1 { font-size: 1rem; }
  .group-tools { gap: 4px; }
  .group-tools .button { padding-inline: .4rem; font-size: .8rem; }
  .compose textarea { font-size: 16px; }
}
