:root {
  font-family: Inter,"Microsoft YaHei",system-ui,sans-serif;
  color: #26342f;
  background: #f4f7f6;
  font-synthesis: none;
  --green: #187957;
  --muted: #82908a;
  --line: #e8eeeb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,input,textarea,select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: .5;
}

button {
  border: 0;
  background: transparent;
  color: inherit;
}

input,textarea,select {
  border: 1px solid #dfe7e2;
  border-radius: 9px;
  background: #fff;
  padding: 11px 13px;
  color: #26342f;
  outline: none;
  min-width: 0;
}

input:focus,textarea:focus,select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px #18795712;
}

textarea {
  resize: vertical;
}

label {
  font-size: 13px;
}

h1,h2,h3,p {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: -.8px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.small {
  font-size: 12px;
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #8b9a92;
  margin-bottom: 13px;
}

.brand-mark {
  width: 41px;
  height: 41px;
  border-radius: 13px;
  background: #c5f2d4;
  color: #12583f;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: bold;
}

.primary {
  background: var(--green);
  color: white;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
}

.primary:hover {
  background: #126444;
}

.secondary {
  border: 1px solid #dce6df;
  border-radius: 8px;
  background: #fff;
  padding: 9px 12px;
  font-size: 12px;
}

.secondary:hover {
  background: #f0f6f2;
}

.subtle {
  display: block;
  margin: 12px auto;
  color: #7b9085;
  font-size: 12px;
  padding: 7px 16px;
}

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 15% 15%,#e1eee5,transparent 55%),#f2f5f3;
}

.login-card {
  padding: 44px;
  width: 420px;
  max-width: 95vw;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 20px 80px #1636220c;
}

.login-card .eyebrow {
  margin-top: 25px;
}

.login-card h1 {
  font-size: 32px;
  line-height: 1.45;
}

.login-card label {
  display: block;
  margin: 30px 0 10px;
}

.login-card input,.login-card .primary {
  width: 100%;
}

.login-card .primary {
  margin-top: 17px;
  display: flex;
  justify-content: space-between;
}

.login-note {
  text-align: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: #a1aba5;
  margin: 28px 0 0;
}

.workspace {
  height: 100dvh;
  display: grid;
  grid-template-columns: 76px 300px minmax(320px,1fr) 260px;
  overflow: hidden;
}

.rail {
  background: #163e30;
  padding: 24px 14px;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 20px;
}

.rail .brand-mark {
  margin-bottom: 28px;
}

.rail-button {
  color: #a4c0b3;
  font-size: 21px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.rail-button.selected,.rail-button:hover {
  background: #ffffff18;
  color: #e6ffee;
}

.rail-bottom {
  margin-top: auto;
}

.inbox {
  background: white;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.inbox header {
  padding: 29px 25px 20px;
}

.heading-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.heading-row h1 {
  margin: 0;
}

.count {
  border-radius: 7px;
  padding: 3px 7px;
  font-size: 11px;
  background: #eaf3ed;
  color: #388963;
}

.connection {
  font-size: 11px;
  color: #8a938e;
  margin-top: 15px;
}

.connection::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  margin-right: 7px;
}

.connection.online {
  color: #26805c;
}

.inbox-filters {
  padding: 0 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inbox-filters select {
  font-size: 12px;
}

.search {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  padding: 0 10px;
  color: #9eaaa3;
}

.search input {
  padding: 10px 5px;
  width: 100%;
  border: 0;
  background: none;
  font-size: 11px;
  box-shadow: none;
}

.search span {
  font-size: 24px;
}

.list-caption {
  font-size: 11px;
  color: #84948b;
  display: flex;
  justify-content: space-between;
  padding: 23px 24px 12px;
}

.list-caption span {
  font-size: 10px;
  color: #adb7b1;
}

.conversation-list {
  flex: 1;
  overflow: auto;
  padding: 0 10px;
}

.conversation-row {
  display: flex;
  width: 100%;
  text-align: left;
  padding: 17px 13px;
  gap: 11px;
  border-radius: 11px;
  margin-bottom: 3px;
}

.conversation-row:hover {
  background: #f7faf8;
}

.conversation-row.active {
  background: #edf6ef;
}

.avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: #e9eee7;
  color: #778570;
  display: grid;
  place-items: center;
  border-radius: 13px;
  font-size: 15px;
}

.conversation-row:nth-child(3n+1) .avatar {
  background: #eeece1;
  color: #9c906c;
}

.conversation-body {
  min-width: 0;
  flex: 1;
}

.conversation-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.conversation-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.conversation-time {
  font-size: 10px;
  color: #96a398;
  white-space: nowrap;
}

.conversation-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  color: #929d95;
  font-size: 11px;
  margin-top: 9px;
}

.conversation-preview span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread {
  background: var(--green);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
}

.pinned {
  font-size: 10px;
  color: #609175;
}

.inbox-footer {
  padding: 18px 12px;
  text-align: center;
  font-size: 10px;
  color: #acb7af;
  border-top: 1px solid var(--line);
}

.chat {
  min-width: 0;
  position: relative;
  background: #f5f8f6;
}

.empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #5e7467;
  padding: 30px;
}

.empty-icon {
  font-size: 35px;
  border-radius: 24px;
  background: #e7f1e9;
  width: 90px;
  height: 90px;
  display: grid;
  place-items: center;
  margin-bottom: 25px;
}

.empty h2 {
  font-size: 22px;
}

.empty p {
  font-size: 13px;
  line-height: 2;
  color: #8a9c90;
}

.active-chat {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: center;
  padding: 21px 27px;
  gap: 12px;
  background: #ffffffc9;
  border-bottom: 1px solid var(--line);
}

.chat-title {
  flex: 1;
  min-width: 0;
}

.chat-title h2 {
  font-size: 15px;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

.chat-title p {
  font-size: 10px;
  color: #94a097;
  margin: 0;
  overflow-wrap: anywhere;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 10px 30px 25px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 22px 0;
}

.message.outgoing {
  align-items: flex-end;
}

.message-meta {
  font-size: 10px;
  color: #98a59c;
  margin: 0 4px 7px;
}

.bubble {
  font-size: 13px;
  line-height: 1.8;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e9eeea;
  border-radius: 2px 13px 13px;
  max-width: 80%;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.outgoing .bubble {
  background: #dff0e5;
  border-color: #d7eadd;
  border-radius: 13px 2px 13px 13px;
}

.bubble img {
  max-width: 260px;
  max-height: 280px;
  display: block;
  border-radius: 7px;
  cursor: zoom-in;
}

.composer {
  background: white;
  border-top: 1px solid var(--line);
  padding: 15px 25px 19px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 15px;
  color: #a2aea6;
  font-size: 10px;
}

.image-button {
  font-size: 21px;
  color: #718679;
  cursor: pointer;
}

.image-button span {
  font-size: 12px;
  vertical-align: middle;
}

.composer textarea {
  border: 0;
  box-shadow: none;
  width: 100%;
  padding: 14px 0;
  resize: none;
  font-size: 13px;
  line-height: 1.7;
}

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-bottom>span {
  font-size: 10px;
  color: #a3ada7;
}

.details {
  padding: 31px 23px;
  background: #fff;
  border-left: 1px solid var(--line);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-title h2 {
  font-size: 14px;
  margin: 0;
}

.panel-title button {
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 26px;
  height: 26px;
  color: #819687;
}

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  overflow: auto;
}

.quick-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  text-align: left;
  background: #fcfdfc;
}

.quick-card:hover {
  border-color: #8bba9d;
}

.quick-card strong {
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
  font-weight: 500;
}

.quick-card p {
  color: #9aa69e;
  font-size: 11px;
  line-height: 1.7;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tip-card {
  background: #f4f7f3;
  border-radius: 12px;
  margin-top: 35px;
  padding: 20px 16px;
}

.tip-card>span {
  font-size: 10px;
  color: #839480;
}

.tip-card h3 {
  font-size: 13px;
  line-height: 1.8;
  margin: 12px 0;
}

.tip-card p {
  font-size: 11px;
  line-height: 1.9;
  color: #9ca895;
  margin: 0;
}

.settings {
  border: 1px solid var(--line);
  border-radius: 18px;
  width: 520px;
  max-width: 95vw;
  max-height: 90dvh;
  padding: 28px;
  box-shadow: 0 30px 100px #143f3033;
}

.settings::backdrop {
  background: #15342566;
  backdrop-filter: blur(3px);
}

.settings>header {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.settings>header button {
  font-size: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

.settings form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.settings form label {
  margin-top: 7px;
}

.settings-list {
  max-height: 150px;
  overflow: auto;
  margin: 15px 0;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  font-size: 12px;
}

.setting-item img {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 8px;
}

.setting-item span {
  flex: 1;
  overflow-wrap: anywhere;
}

.setting-item button {
  color: var(--green);
  font-size: 11px;
}

.form-buttons {
  display: flex;
  gap: 9px;
  margin-top: 8px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  accent-color: var(--green);
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #214333;
  color: #fff;
  padding: 13px 23px;
  border-radius: 11px;
  box-shadow: 0 10px 40px #0002;
  z-index: 100;
  font-size: 13px;
  max-width: 90vw;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none!important;
}

@media(min-width:1650px) {
  .workspace {
    grid-template-columns: 86px 340px minmax(400px,1fr) 300px;
  }
  .messages {
    padding-left: 55px;
    padding-right: 55px;
  }
}

@media(max-width:1150px) {
  .workspace {
    grid-template-columns: 65px 270px minmax(300px,1fr);
  }
  .details {
    display: none;
  }
  .rail {
    padding-inline: 10px;
  }
}

@media(max-width:730px) {
  .workspace {
    grid-template-columns: 52px 170px minmax(240px,1fr);
    overflow: auto;
  }
  .rail {
    padding-inline: 4px;
  }
  .rail .brand-mark {
    width: 35px;
    height: 35px;
  }
  .inbox header {
    padding: 22px 12px;
  }
  .inbox h1 {
    font-size: 19px;
  }
  .inbox-filters {
    padding: 0 10px;
  }
  .list-caption {
    padding: 19px 12px 10px;
  }
  .list-caption span {
    display: none;
  }
  .conversation-row {
    padding: 12px 5px;
    gap: 7px;
  }
  .conversation-row .avatar {
    display: none;
  }
  .conversation-time {
    display: none;
  }
  .chat-header {
    padding: 17px 14px;
  }
  .messages {
    padding-inline: 12px;
  }
  .composer {
    padding: 12px;
  }
  .composer-bottom>span {
    display: none;
  }
  .composer-bottom {
    justify-content: flex-end;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .settings {
    padding: 20px;
  }
  .bubble {
    max-width: 94%;
  }
  .bubble img {
    max-width: 170px;
  }
  .inbox-footer {
    font-size: 9px;
  }
}

.pinned,.unread {
  flex-shrink: 0;
  white-space: nowrap;
}

.mobile-back,#compact-replies {
  display: none;
}

@media(max-width:1150px) {
  #compact-replies {
    display: block;
    padding: 6px 8px;
    font-size: 11px;
    margin-left: auto;
    max-width: 140px;
  }
  .composer-tools>span {
    display: none;
  }
}

@media(max-width:730px) {
  .workspace {
    grid-template-columns: 52px minmax(0,1fr);
    overflow: hidden;
  }
  .workspace .chat {
    display: none;
  }
  .workspace.chat-open .inbox {
    display: none;
  }
  .workspace.chat-open .chat {
    display: block;
  }
  .mobile-back {
    display: block;
    font-size: 26px;
    padding: 0 3px;
    color: #779483;
  }
  .chat-header {
    gap: 8px;
  }
  .chat-header>.avatar {
    display: none;
  }
  .chat-header .secondary {
    white-space: nowrap;
    font-size: 10px;
  }
  .conversation-row .avatar {
    display: grid;
  }
  .conversation-time {
    display: block;
  }
  .inbox header {
    padding: 22px;
  }
  .inbox-filters {
    padding: 0 20px;
  }
  .conversation-row {
    padding: 16px 12px;
    gap: 10px;
  }
  .list-caption {
    padding: 20px 24px 10px;
  }
  .messages {
    scroll-behavior: auto;
  }
  .bubble img {
    max-width: min(230px,100%);
  }
}

.chat,.active-chat,.messages {
  min-height: 0;
}

.chat-header,.composer {
  flex-shrink: 0;
}

/* History stays bounded; fixed thumbnail space prevents scroll jumps on load. */
.messages { scroll-behavior: auto; overflow-anchor: none; }
.bubble img { width: 240px; height: 160px; object-fit: contain; background: #e6ede8; }
.latest-button { position: absolute; right: 24px; bottom: 225px; border: 1px solid #d3e4d9; background: white; color: #187957; padding: 9px 15px; border-radius: 20px; font-size: 12px; box-shadow: 0 3px 12px #183c2415; }
.danger { color: #b7473b; }
.danger-button { background: #b7473b; }
.delete-dialog { border: 1px solid #e8eeeb; border-radius: 16px; padding: 26px; max-width: min(440px,90vw); }
.delete-dialog::backdrop { background: #15342566; }
.delete-dialog p { line-height: 1.8; overflow-wrap: anywhere; }
.avatar-picker { display: flex; align-items: center; gap: 16px; min-width: 0; }
.avatar-picker img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; background: #e1eee5; flex-shrink: 0; }
.avatar-picker .form-buttons { flex-wrap: wrap; }
.avatar-picker p { margin: 10px 0 0; }
.workspace.replies-open { grid-template-columns: 76px minmax(0,1fr); }
.workspace.replies-open > .inbox,.workspace.replies-open > .chat,.workspace.replies-open > .details { display: none; }
.replies-page { min-width: 0; overflow: auto; padding: 38px clamp(20px,4vw,64px); }
.replies-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.replies-header h1 { display: flex; align-items: center; gap: 12px; }
.replies-header .muted { font-size: 13px; margin-bottom: 0; }
.replies-header > button { flex-shrink: 0; }
.replies-layout { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(280px,1fr); gap: 26px; align-items: start; max-width: 1200px; }
.reply-library,.reply-editor { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 24px; min-width: 0; }
.reply-library > .heading-row { justify-content: space-between; margin-bottom: 20px; }
.reply-library h2 { margin: 0; font-size: 16px; }
.reply-library-list { display: grid; gap: 12px; }
.reply-entry { border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.reply-entry.editing { border-color: var(--green); background: #f4faf6; }
.reply-entry h3 { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.reply-entry button { flex-shrink: 0; }
.reply-entry p { white-space: pre-wrap; overflow-wrap: anywhere; color: #73857a; font-size: 13px; line-height: 1.8; margin: 14px 0 0; max-height: 180px; overflow: auto; }
.reply-editor { position: sticky; top: 0; }
.reply-editor form { display: flex; flex-direction: column; gap: 10px; }
.reply-editor label { margin-top: 8px; }
.reply-editor textarea { width: 100%; line-height: 1.8; }
.reply-empty { font-size: 13px; padding: 30px 10px; text-align: center; }
@media(max-width:1150px) { .workspace.replies-open { grid-template-columns: 65px minmax(0,1fr); } }
@media(max-width:850px) { .replies-layout { grid-template-columns: minmax(0,1fr); } .reply-editor { position: static; } }
@media(max-width:730px) {
  .workspace.replies-open { grid-template-columns: 52px minmax(0,1fr); }
  .replies-page { padding: 24px 14px; }
  .replies-header { flex-wrap: wrap; }
  .replies-header h1 { font-size: 21px; }
  .reply-library,.reply-editor { padding: 16px; }
  .reply-entry .heading-row { flex-wrap: wrap; }
  .reply-entry h3 { flex-basis: 100%; }
}
@media(max-width:730px) { .chat-header { flex-wrap: wrap; } .chat-title { flex-basis: 40%; } .latest-button { right: 12px; bottom: 205px; } }

.conversation-item { display: flex; align-items: center; gap: 2px; }
.conversation-item .conversation-row { flex: 1; min-width: 0; width: auto; }
.conversation-delete { flex-shrink: 0; padding: 10px 6px; font-size: 12px; }

.image-status { margin: 0 0 6px; font-size: 12px; color: #52675a; }
.image-status:empty { display: none; }

.active-chat.image-dragover { outline: 3px dashed #1b8464; outline-offset: -5px; background-color: #edf8f0; }
.active-chat.image-dragover .messages { background-color: #edf8f0; }
