:root {
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #191919;
  background: #e5e5e5;
  font-size: 14px;
  --green: #07c160;
  --paper: #f5f5f5;
  --line: #dedede;
  --muted: #636363;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button, input, select { border: 1px solid #d4d4d4; border-radius: 5px; }
button { color: inherit; background: #fff; padding: .53rem .82rem; }
button:hover { background: #e9e9e9; }
button:disabled { opacity: .52; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #007e40; outline-offset: 2px; }
input, select { min-width: 0; background: #fff; color: inherit; padding: .58rem .68rem; width: 100%; }
label { display: grid; gap: .4rem; }
h1, h2, p { margin: 0; }
h1, h2 { font-weight: 620; }
.flat { border-color: transparent; background: transparent; color: #436250; }
.primary { background: #087642; color: #fff; border-color: #087642; }
.primary:hover { background: #065b33; }
.brand-mark { background: var(--green); color: #132b1e; border-radius: 8px; font-size: 1.22rem; font-weight: 700; display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; }
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 1.2rem; }
.login { width: min(100%, 360px); display: grid; gap: 1.12rem; padding: clamp(1.4rem, 6vw, 2.4rem); border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.brand { display: flex; gap: .8rem; align-items: center; margin-bottom: .35rem; }
.brand h1 { font-size: 1.35rem; }
.login h2 { font-size: 1.1rem; }
.error { color: #a52629; font-size: .93rem; }
.error:empty { display: none; }
.workspace { display: grid; grid-template-columns: 64px minmax(265px, 324px) minmax(0, 1fr); min-height: 100dvh; height: 100dvh; }
.rail { background: #e5e5e5; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 18px 7px; }
.sidebar { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #f1f1f1; }
.sidebar-title, .conversation-title { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .8rem 1.1rem; }
.sidebar-title h1 { font-size: 1.18rem; }
.filters { display: grid; gap: .58rem; padding: 0 1.1rem 1rem; }
.filters label { grid-template-columns: 34px 1fr; align-items: center; color: var(--muted); }
#sync-status { min-height: 1rem; font-size: .82rem; color: var(--muted); }
.chats, .messages { list-style: none; margin: 0; padding: 0; }
.chats { overflow: auto; }
.chat-button { width: 100%; display: grid; grid-template-columns: 40px minmax(0,1fr) auto; align-items: center; gap: .7rem; text-align: left; border: 0; border-radius: 0; background: transparent; min-height: 60px; padding: .68rem 1.1rem; }
.chat-button[aria-current="true"] { background: #dcdcdc; }
.chat-button:hover { background: #e7e7e7; }
.chat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { color: var(--muted); font-size: .78rem; }
.avatar { width: 38px; height: 38px; border-radius: 5px; background: #407e71; color: #fff; display: grid; place-items: center; font-size: 1.13rem; flex: 0 0 auto; }
.chats li:nth-child(4n + 2) .avatar { background: #67628b; }
.chats li:nth-child(4n + 3) .avatar { background: #526879; }
.chats li:nth-child(4n + 4) .avatar { background: #7b6158; }
.conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto 1fr auto; background: var(--paper); }
.conversation-title { border-bottom: 1px solid var(--line); justify-content: flex-start; }
.conversation-title h2 { font-size: 1.15rem; flex: 1; overflow-wrap: anywhere; }
.conversation footer { min-height: 40px; padding: .8rem 1.15rem; display: flex; gap: 1rem; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: .83rem; }
.timeline { overflow: auto; padding: 1.1rem clamp(.9rem, 3vw, 2.5rem); }
.placeholder, .list-empty { color: var(--muted); text-align: center; margin: 1.8rem .6rem; }
.messages { display: grid; gap: 1.15rem; }
.older { display: block; margin: 0 auto 1rem; }
.message { display: flex; align-items: flex-start; gap: .65rem; }
.message.mine { flex-direction: row-reverse; }
.message-content { min-width: 0; max-width: min(75%, 680px); }
.message-info { display: flex; flex-wrap: wrap; gap: .2rem .65rem; align-items: center; font-size: .78rem; color: var(--muted); margin: 0 0 .34rem; }
.mine .message-info { justify-content: flex-end; }
.bubble { display: grid; justify-items: start; max-width: 100%; width: fit-content; background: #fff; border-radius: 5px; padding: .62rem .8rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.mine .bubble { background: #95ec69; margin-left: auto; }
.bubble audio { width: min(260px, 56vw); height: 40px; }
.bubble img { display: block; object-fit: contain; max-width: 100%; max-height: 260px; }
.bubble .picture { border: 0; background: transparent; padding: 0; min-height: 30px; }
.media-note { font-size: .83rem; color: var(--muted); }
#back { display: none; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 1.35rem; width: min(420px, 92vw); }
dialog::backdrop { background: #12121277; }
dialog form, #pair-result { display: grid; gap: .8rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.image-preview { width: max-content; max-width: 92vw; }
.image-preview img { display: block; max-height: 76dvh; max-width: 84vw; margin-top: .8rem; }
@media (max-width: 700px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 49px; }
  .rail { grid-row: 2; flex-direction: row; border: 0; border-top: 1px solid var(--line); padding: .3rem 1rem; }
  .rail .brand-mark { width: 32px; height: 32px; }
  .sidebar, .conversation { grid-column: 1; grid-row: 1; }
  .sidebar { border: 0; }
  .conversation { display: none; }
  .chat-open .sidebar { display: none; }
  .chat-open .conversation { display: grid; }
  #back { display: block; min-width: 68px; }
  .timeline { padding-bottom: 1.2rem; }
}
