:root {
  --green: #138b65;
  --line: #e8edf1;
  --muted: #87919c;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #202a36;
  background: #f1f4f7;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; }
button, input, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
button:disabled { cursor: default; opacity: .5; }
input, textarea { outline: none; }
input:focus, textarea:focus { border-color: #21a47a !important; box-shadow: 0 0 0 3px #16a37112; }
a { color: var(--green); text-decoration: none; }
[hidden] { display: none !important; }

.shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-height: 550px;
  overflow: hidden;
  background: #fff;
}

.rail {
  width: 70px;
  background: #15332e;
  color: #fff;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 23px 0 18px;
  gap: 18px;
  flex-shrink: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #1baa7e;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.rail-tag {
  writing-mode: vertical-rl;
  letter-spacing: 5px;
  font-size: 12px;
  color: #97b4aa;
  margin-top: 10px;
}

.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}

.icon-button {
  display: grid;
  place-items: center;
  min-width: 34px;
  min-height: 34px;
  border-radius: 8px;
  color: #b4cbbf;
  font-size: 16px;
}

.icon-button:hover { background: #ffffff12; color: #fff; }

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

.side-head { padding: 26px 22px 18px; flex-shrink: 0; }
.side-head h2 { margin: 0 0 12px; font-size: 20px; font-weight: 650; }

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.status:before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a1aab1;
}

.status.online:before { background: #1faa7f; }

.mobile-sidebar-actions, .mobile-only, .drawer-scrim { display: none; }

.section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 8px;
  color: #99a2ac;
  font-size: 11px;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.public-section-label { padding: 14px 16px 8px; }

.group-section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 0 5px;
  font-size: 11px;
  text-align: left;
  color: #8b9991;
  letter-spacing: .4px;
}

.group-section-heading {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

#public-group-count {
  font-size: 10px;
  white-space: nowrap;
  background: #edf3ef;
  padding: 2px 6px;
  border-radius: 4px;
  color: #7f9489;
  letter-spacing: 0;
}

.group-toggle-action {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #608a75;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0;
}

.group-toggle-action > span:last-child {
  font-size: 16px;
  display: inline-block;
  transition: transform .12s;
}

.group-section-toggle[aria-expanded="false"] .group-toggle-action > span:last-child {
  transform: rotate(180deg);
}

.chat-list { padding: 0 12px; }
#public-chats {
  max-height: clamp(72px, 26vh, 220px);
  overflow: auto;
  flex: 0 1 auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.sidebar :is(#system-notifications, #poll-center, #feedback-center) {
  padding: 0 12px;
  flex: 0 0 auto;
  background: #f7f9fa;
}

.conversation {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 11px;
  border-radius: 9px;
  text-align: left;
  margin: 3px 0;
}

.sidebar :is(#system-notifications, #poll-center, #feedback-center) > .conversation {
  min-height: 64px;
  padding: 12px 10px;
  margin: 2px 0;
  border-radius: 10px;
}

.conversation:hover { background: #edf2f0; }
.conversation.selected { background: #e5f0eb; }

.avatar {
  width: 39px;
  height: 39px;
  flex-shrink: 0;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 600;
  background: #e6ecef;
  color: #52706b;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.group { background: #15956f; color: #fff; }
.avatar.small { width: 33px; height: 33px; font-size: 13px; border-radius: 9px; }
.avatar.c1 { background: #d9efe6; color: #1d7a5c; }
.avatar.c2 { background: #e4eef8; color: #3d6494; }
.avatar.c3 { background: #f8eee4; color: #9a6232; }
.avatar.c4 { background: #efe8f6; color: #6d4e8c; }
.avatar.system-avatar { background: #fff1d6; color: #cf810e; }
.sidebar #system-notifications > .conversation.selected .system-avatar { background: #ffebbc; color: #bb6e03; }
.avatar.poll-avatar { background: #e6f3ed; color: #108b68; }
.avatar.feedback-avatar { background: #e3f2ed; color: #13916c; }
.entry-icon { display: block; width: 24px; height: 24px; flex-shrink: 0; }

.conversation-info { overflow: hidden; flex: 1; min-width: 0; }
.conversation-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.conversation-title > span:first-child,
.conversation-title .title-text {
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview {
  font-size: 11px;
  color: #8d989f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 6px;
}

.badge {
  font-size: 9px;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 4px;
  background: #e6f1eb;
  color: #22835f;
  white-space: nowrap;
  flex-shrink: 0;
}

.private-section-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.section-label .clear-private {
  width: auto;
  font-size: 11px;
  line-height: 22px;
  padding: 0 4px;
  color: #81958a;
  letter-spacing: 0;
}
.section-label .clear-private:hover { color: #ba544f; }

.private-search { flex: 0 0 auto; padding: 2px 14px 8px; }
.private-search input {
  width: 100%;
  border: 1px solid #e2e9e5;
  border-radius: 7px;
  background: #fff;
  padding: 8px 10px;
  font-size: 12px;
}

#private-chats { flex: 1 1 0; min-height: 0; overflow-y: auto; }
.conversation-row { position: relative; }
.conversation-row > .conversation { padding-right: 29px; }
.hide-dialog {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 23px;
  height: 25px;
  font-size: 18px;
  color: #94a29a;
  border-radius: 5px;
  opacity: 0;
}
.conversation-row:hover .hide-dialog,
.conversation-row:focus-within .hide-dialog { opacity: 1; }
.hide-dialog:hover { background: #f9e9e8; color: #bc514d; }

.side-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 18px 21px;
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 72px;
  flex-shrink: 0;
}

.self-profile {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
}
.self-profile > span:nth-child(2) { min-width: 0; flex: 1; }
.self-profile strong {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.self-profile small { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.profile-edit-symbol { color: #8a9c90; font-size: 16px; }

.chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.chat-header {
  height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  gap: 15px;
  flex-shrink: 0;
  background: #fff;
}

.heading-with-avatar { display: flex; gap: 12px; align-items: center; min-width: 0; }
.heading-with-avatar > div { min-width: 0; }
.chat-header h2 {
  font-size: 17px;
  margin: 0 0 7px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header p { font-size: 11px; color: var(--muted); margin: 0; }

.header-actions { display: flex; gap: 6px; flex-shrink: 0; }
.subtle-button {
  padding: 8px 11px;
  color: #66746d;
  background: #f5f8f6;
  border: 1px solid #e5ede8;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}
.subtle-button:hover { background: #eaf2ed; }
.primary {
  background: var(--green);
  color: #fff;
  border-radius: 8px;
  padding: 11px 20px;
  font-weight: 600;
}
.header-actions .primary { font-size: 12px; padding: 8px 12px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 25px 35px;
  background: #fcfdfd;
  min-height: 0;
}

.history-button {
  display: block;
  margin: 0 auto 20px;
  color: #8c9993;
  font-size: 11px;
  padding: 6px 15px;
}
.history-button:hover { color: var(--green); }

.welcome { text-align: center; margin: 26px auto 30px; color: #9ba5a0; font-size: 11px; }
.welcome strong { display: block; font-size: 14px; font-weight: 500; color: #6d7d74; margin-bottom: 8px; }
.date-label {
  display: table;
  margin: 22px auto;
  font-size: 10px;
  color: #9aa39e;
  background: #f1f4f2;
  padding: 4px 10px;
  border-radius: 5px;
}

.message {
  display: flex;
  gap: 11px;
  max-width: 80%;
  margin: 22px 0;
  align-items: flex-start;
}
.message.mine { margin-left: auto; flex-direction: row-reverse; }
.message-body { min-width: 0; }
.message-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #8c9791;
  font-size: 10px;
  margin-bottom: 7px;
}
.mine .message-meta { justify-content: flex-end; }
.bubble {
  font-size: 13px;
  line-height: 1.8;
  border: 1px solid #e8ede9;
  border-radius: 1px 10px 10px 10px;
  padding: 10px 15px;
  background: #fff;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  min-width: 40px;
}
.mine .bubble { background: #e4f1e9; border-color: #dbece1; border-radius: 10px 1px 10px 10px; }
.bubble.image-bubble { padding: 4px; overflow: hidden; }
.message-image {
  display: block;
  max-width: 300px;
  max-height: 280px;
  border-radius: 6px;
  cursor: zoom-in;
}
.file-card { display: flex; gap: 12px; align-items: center; text-align: left; max-width: 280px; }
.file-symbol { font-size: 23px; color: #619481; }
.file-card strong { display: block; font-size: 12px; overflow-wrap: anywhere; }
.file-card small { font-size: 10px; color: #8a9690; }

.system-notification-card {
  max-width: 760px;
  margin: 12px auto 24px;
  padding: 22px 26px;
  border: 1px solid #e3e9ee;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 12px #20302808;
}
.notification-card-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.notification-label {
  font-size: 11px;
  color: #5276ae;
  background: #edf2fc;
  border-radius: 5px;
  padding: 4px 8px;
}
.notification-card-heading time { font-size: 11px; color: #98a3ae; }
.system-notification-card h3 { font-size: 18px; color: #283747; margin: 18px 0 14px; overflow-wrap: anywhere; }
.notification-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.95;
  color: #45535f;
}
.system-notification-card footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #edf0f3;
  color: #96a2ad;
  font-size: 11px;
}

.panel-page { max-width: 760px; margin: 0 auto; }
.panel-intro { color: #84968d; font-size: 12px; line-height: 1.8; margin: 4px 0 18px; }

.poll-card, .feed-card, .feedback-form {
  background: #fff;
  border: 1px solid #deebe4;
  border-radius: 14px;
  padding: 22px 24px;
  margin-bottom: 16px;
}
.poll-card h3, .feed-card h3 { font-size: 18px; color: #193d32; line-height: 1.6; margin: 12px 0; }
.poll-card-meta, .feed-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #87978e;
  font-size: 11px;
  flex-wrap: wrap;
}
.poll-status, .feed-status {
  background: #e3f5eb;
  color: #0b855e;
  border-radius: 5px;
  padding: 4px 9px;
}
.poll-options { display: grid; gap: 8px; }
.poll-option {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: 1px solid #dbe8e1;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.poll-option .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: #e7f6ef;
  z-index: 0;
}
.poll-option b, .poll-option em { position: relative; z-index: 1; font-style: normal; font-weight: 600; }
.poll-option em { color: #5d7b6e; font-size: 12px; }
.poll-option.chosen { border-color: #1aa37a; }
.poll-option:disabled { cursor: default; }

.feedback-form { display: grid; gap: 12px; }
.feedback-form h3 { margin: 0; font-size: 16px; color: #193d32; }
.field { display: grid; gap: 6px; font-size: 12px; color: #5d6873; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid #dfe5e8;
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  resize: vertical;
}
.form-actions { display: flex; justify-content: flex-end; }
.feed-card p { margin: 0; white-space: pre-wrap; line-height: 1.8; color: #45535f; font-size: 14px; }

.jump-latest {
  position: absolute;
  right: 28px;
  bottom: 132px;
  background: #fff;
  border: 1px solid #dce7e1;
  color: var(--green);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  box-shadow: 0 8px 24px #16322814;
}

.composer { padding: 14px 30px 20px; border-top: 1px solid var(--line); background: #fff; flex-shrink: 0; }
.toolbar { display: flex; gap: 7px; align-items: center; height: 32px; }
.tool {
  font-size: 17px;
  min-width: 30px;
  height: 30px;
  color: #8a9890;
  border-radius: 5px;
}
.tool:hover { background: #f0f6f2; color: var(--green); }
.composer-note { margin-left: auto; font-size: 10px; color: #adb5b0; }
.composer textarea {
  resize: none;
  width: 100%;
  height: 75px;
  border: 0;
  line-height: 1.8;
  padding: 9px 4px;
  font-size: 13px;
  box-shadow: none !important;
  background: transparent;
}
.composer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.composer-bottom small { color: #b1b9b3; font-size: 10px; }
.composer-bottom .primary { font-size: 12px; padding: 9px 24px; }
.emoji-row { display: flex; gap: 5px; padding: 8px 0 2px; flex-wrap: wrap; }
.emoji-row button { font-size: 21px; padding: 4px; border-radius: 6px; }
.emoji-row button:hover { background: #f0f6f2; }

.drawer {
  width: 285px;
  border-left: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.drawer-head { padding: 27px 20px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { font-size: 15px; margin: 0 0 16px; display: flex; justify-content: space-between; align-items: center; }
#close-drawer { width: 32px; height: 32px; font-size: 22px; color: #708078; border-radius: 8px; }
#close-drawer:hover { background: #f3f6f4; }
.drawer-head input {
  width: 100%;
  border: 1px solid #e6ebe8;
  border-radius: 7px;
  padding: 10px 11px;
  font-size: 12px;
  background: #fafcfb;
}
.member-list { overflow-y: auto; padding: 12px; flex: 1; }
.member { display: flex; gap: 10px; padding: 12px 7px; align-items: center; border-bottom: 1px solid #f3f5f3; }
.member-info { flex: 1; min-width: 0; }
.member-info strong { font-size: 12px; font-weight: 500; display: flex; gap: 5px; align-items: center; }
.member-info small { font-size: 10px; color: #a0aaa4; display: block; margin-top: 5px; }
.member-actions button { font-size: 11px; color: var(--green); white-space: nowrap; }
.drawer-footer {
  padding: 16px 20px;
  font-size: 11px;
  line-height: 1.8;
  color: #a1aaa4;
  border-top: 1px solid var(--line);
}

#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  background: #243c33;
  color: #fff;
  max-width: 80vw;
  padding: 12px 21px;
  border-radius: 9px;
  font-size: 12px;
  box-shadow: 0 5px 30px #0002;
  z-index: 40;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #13241e66;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: 0 20px 60px #10241c33;
}
.modal-card h3 { margin: 0 0 8px; font-size: 18px; color: #1d3b32; }
.modal-card p { margin: 0 0 16px; color: #5d7368; font-size: 13px; line-height: 1.8; white-space: pre-wrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.file-list { display: grid; gap: 8px; margin: 12px 0 16px; }
.file-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e5ede8;
  border-radius: 8px;
  background: #f8fbf9;
  font-size: 13px;
}
.image-view {
  position: fixed;
  inset: 0;
  background: #13241ee8;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 50px;
  cursor: zoom-out;
}
.image-view img { max-width: 95%; max-height: 90vh; object-fit: contain; }
.image-view button { position: absolute; right: 24px; top: 16px; font-size: 30px; color: #fff; }

@media (max-width: 1050px) {
  .sidebar { width: 235px; }
  .drawer { width: 245px; }
  .chat-header { padding: 0 22px; }
  .messages { padding: 20px; }
  .composer { padding: 12px 20px 18px; }
  .message { max-width: 90%; }
}

@media (max-width: 750px) {
  .shell { min-height: 0; }
  .shell > .rail { display: none; }
  .shell > .sidebar, .shell > .chat { width: 100%; height: 100%; flex: 1 1 100%; border: 0; }
  .shell[data-mobile-view="list"] > .chat { display: none; }
  .shell[data-mobile-view="chat"] > .sidebar { display: none; }
  .mobile-only { display: flex; }
  .side-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 12px;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 12px;
  }
  .side-head h2 { font-size: 22px; margin: 0; }
  .mobile-sidebar-actions { display: flex; grid-column: 2; grid-row: 1 / 3; align-items: center; gap: 4px; }
  .mobile-sidebar-actions button {
    min-width: 44px;
    min-height: 44px;
    font-size: 13px;
    color: #55756a;
    border-radius: 9px;
  }
  .conversation { min-height: 72px; padding: 12px; }
  .conversation .avatar { width: 44px; height: 44px; border-radius: 12px; }
  .conversation-title { font-size: 15px; }
  .preview { font-size: 12px; }
  .chat-header {
    height: auto;
    min-height: 64px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
    gap: 8px;
  }
  .heading-with-avatar > .avatar { display: none; }
  #mobile-back {
    align-items: center;
    gap: 2px;
    min-width: 66px;
    min-height: 44px;
    color: var(--green);
    font-size: 14px;
  }
  .mobile-back-arrow { font-size: 34px; line-height: 1; margin-top: -3px; }
  #mobile-more {
    flex: 0 0 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #55756a;
    border-radius: 8px;
  }
  .header-actions {
    display: none;
    position: absolute;
    right: 10px;
    top: calc(100% - 3px);
    width: min(240px, calc(100vw - 20px));
    flex-direction: column;
    gap: 3px;
    padding: 7px;
    background: #fff;
    border: 1px solid #e3eae6;
    border-radius: 12px;
    box-shadow: 0 10px 35px #163a2524;
    z-index: 8;
  }
  .header-actions.mobile-menu-open { display: flex; }
  .header-actions button { min-height: 44px; font-size: 14px; text-align: left; }
  .messages { padding: 12px 12px 18px; }
  .message { max-width: 96%; }
  .bubble { font-size: 15px; }
  .composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    padding: 4px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .toolbar, .emoji-row { grid-column: 1 / -1; }
  .composer-note, .composer-bottom small { display: none; }
  .composer textarea {
    grid-column: 1;
    height: 44px;
    min-height: 44px;
    font-size: 16px;
    padding: 10px 11px;
    border-radius: 10px;
    background: #f4f7f5;
  }
  .composer-bottom { grid-column: 2; align-self: end; margin: 0; }
  .composer-bottom .primary { min-height: 44px; min-width: 64px; }
  .jump-latest { right: 12px; bottom: 118px; }
  .drawer {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(100%, 420px);
    z-index: 12;
    box-shadow: -10px 0 40px #112d2226;
  }
  .drawer-scrim.show { display: block; position: fixed; inset: 0; background: #12352755; z-index: 11; }
  .hide-dialog { opacity: 1; }
  .system-notification-card { padding: 16px; }
}

@media (hover: none) {
  .hide-dialog { opacity: 1; }
}
