@font-face {
  font-family: "Living Room Serif";
  src: url("/fonts/noto-serif-sc-chinese-simplified-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Living Room Input Serif";
  src: url("/fonts/noto-serif-sc-chinese-simplified-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  size-adjust: 88%;
}

:root {
  color-scheme: light;
  --sage-900: #153d29;
  --sage-800: #22573a;
  --sage-700: #326f4b;
  --sage-600: #4b8a61;
  --sage-500: #70a97f;
  --sage-300: #a8d3b2;
  --sage-200: #cce7d1;
  --sage-100: #edf8ef;
  --paper: #ffffff;
  --canvas: #dceee0;
  --charcoal: #142019;
  --muted: #4f6256;
  --line: #bfd8c5;
  --mine: #a9d7b1;
  --warm: #d98756;
  --warm-soft: #f8e2d2;
  --danger: #bc504b;
  --shadow: 0 2px 4px rgba(21, 61, 41, .13), 0 10px 28px rgba(21, 61, 41, .10);
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; min-height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--charcoal);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
body[data-chat="gen"] {
  --canvas: #f2efe8;
  --mine: #dfe9df;
  --line: #d3d5cc;
  --shadow: 0 2px 4px rgba(31, 35, 32, .10), 0 10px 28px rgba(31, 35, 32, .07);
}
body[data-chat="kimi"] { --canvas: #d7eddb; --mine: #9fd0aa; --line: #b6d7bd; }
body[data-chat="glm"] {
  --sage-900: #252755;
  --sage-800: #343776;
  --sage-700: #5058a8;
  --sage-500: #7a83cf;
  --sage-300: #b4bae8;
  --sage-200: #d2d6f3;
  --sage-100: #eef0fb;
  --canvas: #e4e8f8;
  --mine: #b9c4ed;
  --line: #c4caeb;
  --muted: #5c6380;
  --shadow: 0 2px 4px rgba(49, 55, 117, .12), 0 10px 28px rgba(49, 55, 117, .09);
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { width: 100%; max-width: 100vw; height: 100vh; height: 100dvh; display: grid; grid-template-columns: 320px minmax(0, 1fr); overflow: hidden; }
.sidebar {
  z-index: 8;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--paper);
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 18px; border-bottom: 1px solid rgba(50,111,75,.08); }
.app-title { display: flex; align-items: center; gap: 11px; }
.app-title strong { color: var(--sage-900); font-size: 19px; letter-spacing: .015em; }
.sidebar-header-actions { display: flex; align-items: center; gap: 7px; }
.avatar-settings-button { min-height: 34px; padding: 0 11px; border-radius: 12px; background: var(--sage-100); color: var(--sage-800); font-size: 10px; font-weight: 750; }
.avatar-settings-button:hover { background: var(--sage-200); }
.icon-button { display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--sage-800); }
.sidebar-close { display: none; width: 34px; height: 34px; font-size: 25px; }
.search-box { display: flex; align-items: center; gap: 9px; height: 38px; margin: 0 12px 8px; padding: 0 13px; border-radius: 18px; background: #f1f3f0; color: #949a96; font-size: 12px; }
.search-box span:first-child { font-size: 19px; transform: rotate(-15deg); }
.feature-nav { display: grid; gap: 3px; margin: 10px 10px 7px; padding: 5px; border: 1px solid #e1ebe4; border-radius: 15px; background: #f5f8f5; }
.feature-nav-item { min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 11px; min-height: 52px; padding: 7px 10px; border: 0; border-radius: 11px; background: transparent; color: var(--charcoal); text-align: left; text-decoration: none; }
.feature-nav-item:hover { border-color: var(--sage-300); background: var(--sage-100); }
.feature-nav-item.active { background: #fff; color: var(--sage-900); box-shadow: 0 2px 10px rgba(32,91,57,.10); }
.feature-nav-item > span:last-child { min-width: 0; display: grid; gap: 3px; }
.feature-nav-item strong { font-size: 13px; }
.feature-nav-item small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.feature-nav-item.active small { color: var(--muted); }
.feature-nav-icon { position: relative; display: block; width: 32px; height: 32px; border-radius: 10px; background: #e1eee4; color: var(--sage-700); }
.feature-nav-chat::before, .feature-nav-chat::after { content: ""; position: absolute; border: 1.7px solid currentColor; }
.feature-nav-chat::before { inset: 8px 7px 10px; border-radius: 6px; }
.feature-nav-chat::after { left: 9px; bottom: 7px; width: 6px; height: 6px; border-width: 0 0 1.7px 1.7px; transform: skewY(-35deg); }
.feature-nav-moments::before { content: ""; position: absolute; inset: 7px; border: 1.7px solid currentColor; border-radius: 50%; box-shadow: inset 0 0 0 4px white; background: currentColor; }

.conversation-list { display: grid; gap: 5px; padding: 5px 10px 12px; }
.conversation-card { width: 100%; display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 11px; align-items: center; padding: 10px; border: 0; border-radius: 10px; background: transparent; color: var(--charcoal); text-align: left; }
.conversation-card:hover { background: #e4f4e8; }
.conversation-card.active { background: linear-gradient(135deg, var(--sage-700), #43845b); color: white; box-shadow: 0 5px 16px rgba(32,91,57,.20); }
.conversation-card[data-chat="gen"].active { background: #e1e3df; color: var(--charcoal); box-shadow: inset 0 0 0 1px #bfc6c0; }
.conversation-card[data-chat="gen"].active .conversation-copy > span:last-child { color: #707773; }
.conversation-card[data-chat="glm"].active { background: linear-gradient(135deg, #4d55a5, #7681d1); color: white; }
.conversation-card.disabled { cursor: default; opacity: .48; }
.conversation-avatar, .group-avatar { position: relative; flex: 0 0 auto; }
.conversation-avatar { width: 50px; height: 50px; }
.conversation-avatar i, .group-avatar i { position: absolute; display: grid; place-items: center; border-radius: 50%; color: white; font-style: normal; font-weight: 750; }
.conversation-avatar i { width: 31px; height: 31px; border: 2px solid var(--sage-700); font-size: 9px; }
.conversation-avatar i:nth-child(1), .group-avatar i:nth-child(1) { top: 0; left: 0; }
.conversation-avatar i:nth-child(2), .group-avatar i:nth-child(2) { top: 0; right: 0; }
.conversation-avatar i:nth-child(3), .group-avatar i:nth-child(3) { bottom: 0; left: 2px; }
.conversation-avatar i:nth-child(4), .group-avatar i:nth-child(4) { right: 2px; bottom: 0; }
.conversation-avatar i:nth-child(5), .group-avatar i:nth-child(5) { z-index: 2; top: 50%; left: 50%; transform: translate(-50%, -50%); }
[data-avatar-id] { background-position: center; background-size: cover; background-repeat: no-repeat; }
[data-avatar-id="okra"] { background-color: #e5a06f !important; color: #3d2518 !important; }
[data-avatar-id="gen"] { background-color: #fff !important; color: #1d2922 !important; }
[data-avatar-id="kimi"] { background-color: #4f8b62 !important; color: #fff !important; }
[data-avatar-id="glm"] { background-color: #5963b6 !important; color: #fff !important; }
[data-avatar-id="k"] { background-color: #171a18 !important; color: #fff !important; }
[data-avatar-id].has-photo {
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no-repeat !important;
  color: transparent !important;
}
.conversation-copy { min-width: 0; }
.conversation-copy > span { display: block; }
.conversation-copy > span:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conversation-copy strong { font-size: 14px; }
.conversation-copy time { color: rgba(255,255,255,.7); font-size: 9px; }
.conversation-copy > span:last-child { overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-card.active .conversation-copy > span:last-child { color: rgba(255,255,255,.76); }
.contact-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%; color: white; font-size: 15px; font-weight: 750; }
.kimi-avatar { background: linear-gradient(145deg, #62a774, #28573a); }
.gen-avatar { border: 1px solid #d7dbd8; background: linear-gradient(145deg, #fff, #eceeec); color: #252a27; box-shadow: 0 3px 12px rgba(20,22,21,.08); }
.glm-avatar { background: linear-gradient(145deg, #7e89db, #454c9c); color: white; }
.k-avatar { background: linear-gradient(145deg, #2c2e2d, #090a0a); color: white; }

.side-section { display: grid; gap: 6px; padding: 14px 12px 0; }
.section-title { display: flex; justify-content: space-between; padding: 0 7px 3px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.provider-list { display: grid; gap: 2px; }
.provider-card { position: relative; display: grid; grid-template-columns: 18px 9px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 42px; padding: 6px 8px; border-radius: 8px; transition: background 120ms ease; }
.provider-card:hover { background: var(--sage-100); }
.provider-card.disabled { opacity: .48; }
.provider-card input { appearance: none; display: grid; place-items: center; width: 15px; height: 15px; margin: 0; border: 1px solid var(--sage-300); border-radius: 50%; background: white; }
.provider-card input:checked { border-color: var(--sage-700); background: var(--sage-700); }
.provider-card input:checked::after { content: ""; width: 5px; height: 3px; border: solid white; border-width: 0 0 1.5px 1.5px; transform: translateY(-1px) rotate(-45deg); }
.presence { width: 7px; height: 7px; border-radius: 50%; background: #b7bbb8; }
.presence.online { background: #36a65e; box-shadow: 0 0 0 3px rgba(54,166,94,.12); }
.provider-main { min-width: 0; }
.provider-main strong { display: block; font-size: 12px; }
.provider-main small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }

.memory-form { display: grid; grid-template-columns: 1fr 34px; gap: 6px; }
.memory-form input { min-width: 0; height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; outline: 0; background: #fafbfa; color: var(--charcoal); font-size: 11px; }
.memory-form input:focus { border-color: var(--sage-500); background: white; }
.memory-form button { border: 0; border-radius: 9px; background: var(--sage-700); color: white; font-size: 16px; }
.memory-list { display: grid; gap: 6px; overflow-y: auto; }
.memory-empty { margin: 2px 7px; color: #a0a5a1; font-size: 10px; }
.memory-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 11px; border: 1px solid var(--sage-200); border-radius: 10px; background: var(--sage-100); color: var(--sage-900); font-size: 11px; line-height: 1.5; }
.memory-item span { overflow-wrap: anywhere; }
.memory-item button { align-self: center; padding: 3px 5px; border: 0; border-radius: 6px; background: rgba(255,255,255,.58); color: var(--muted); font-size: 8px; }
.memory-item button:hover { background: #faeceb; color: var(--danger); }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 19px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--sage-700); }

.memory-overlay { position: fixed; inset: 0; z-index: 12; border: 0; background: rgba(13,18,15,.5); }
.memory-panel { position: fixed; z-index: 13; top: 0; right: 0; width: min(420px, 92vw); height: 100vh; height: 100dvh; padding: 18px; overflow: hidden; background: #fff; box-shadow: -12px 0 36px rgba(13,18,15,.18); }
.memory-panel-header { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin-bottom: 14px; }
.memory-panel-header > div { display: flex; align-items: baseline; gap: 9px; }
.memory-panel-header strong { font-size: 18px; }
.memory-panel-header span { color: var(--muted); font-size: 11px; }
.memory-panel-header .icon-button { width: 44px; height: 44px; font-size: 27px; }
.memory-panel .memory-form { margin-bottom: 12px; grid-template-columns: 1fr 44px; }
.memory-panel .memory-form input { height: 44px; font-size: 13px; }
.memory-panel .memory-list { max-height: calc(100dvh - 132px); padding-right: 3px; }
.avatar-panel { width: min(460px, 94vw); }
.history-search-overlay { z-index: 16; }
.history-search-panel { inset: 0; z-index: 17; width: 100vw; max-width: none; height: 100vh; height: 100dvh; padding: 0; background: #f2f3f2; box-shadow: none; }
.history-search-header { height: 64px; display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; padding: 0 12px; border-bottom: 1px solid #e3e7e4; background: #fff; }
.history-search-header .icon-button { width: 44px; height: 44px; font: 36px/1 Georgia, serif; }
.history-search-header > div { min-width: 0; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.history-search-header strong { font-size: 16px; }
.history-search-header span { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.history-search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-bottom: 13px; }
.history-search-form { width: min(720px, 100%); margin: 14px auto 10px; padding: 0 15px; }
.history-search-form input { min-width: 0; height: 44px; padding: 0 13px; border: 1px solid #dce3dd; border-radius: 11px; outline: 0; background: #fff; color: var(--charcoal); font-size: 13px; }
.history-search-form input:focus { border-color: var(--sage-500); background: white; }
.history-search-form button { padding: 0 15px; border: 0; border-radius: 11px; background: var(--sage-700); color: white; font-size: 11px; font-weight: 700; }
.history-member-filter { width: min(720px, 100%); margin: 0 auto 10px; padding: 13px 15px 15px; border-top: 1px solid #e5e9e6; border-bottom: 1px solid #e5e9e6; background: #fff; }
.history-member-filter > strong { display: block; margin-bottom: 11px; color: var(--muted); font-size: 11px; font-weight: 650; }
.history-search-members { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.history-search-members::-webkit-scrollbar { display: none; }
.history-search-members button { flex: 0 0 auto; min-width: 60px; display: grid; justify-items: center; gap: 5px; padding: 7px 8px; border: 1px solid transparent; border-radius: 11px; background: #f5f7f5; color: var(--charcoal); font-size: 10px; }
.history-search-members button[aria-pressed="true"] { border-color: var(--sage-500); background: var(--sage-100); color: var(--sage-900); }
.history-search-member-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background-position: center; background-size: cover; color: #fff; font-size: 9px; font-weight: 800; }
.history-search-results { display: grid; gap: 8px; width: min(720px, 100%); max-height: calc(100dvh - 260px); margin: 0 auto; overflow-y: auto; padding: 0 15px 28px; }
.history-search-empty { padding: 60px 12px; color: var(--muted); text-align: center; font-family: "Living Room Serif", "Songti SC", serif; font-size: 13px; }
.history-search-result { display: grid; gap: 6px; width: 100%; padding: 12px 13px; border: 1px solid #d6e2d8; border-radius: 12px; background: #f7faf7; color: var(--charcoal); text-align: left; }
.history-search-result:hover { border-color: var(--sage-300); background: var(--sage-100); }
.history-search-result-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--sage-700); font-size: 10px; font-weight: 700; }
.history-search-result-meta time { color: var(--muted); font-weight: 500; }
.history-search-result-content { display: -webkit-box; overflow: hidden; color: #222b25; font-family: "Living Room Serif", "Songti SC", serif; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.avatar-editor-list { display: grid; gap: 9px; }
.avatar-editor-row { display: grid; grid-template-columns: 54px minmax(70px, 1fr) auto; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--sage-200); border-radius: 14px; background: linear-gradient(135deg, #fff, #f4faf5); }
.avatar-editor-preview { display: grid; place-items: center; width: 52px; height: 52px; grid-row: span 2; border: 2px solid white; border-radius: 50%; font-size: 13px; font-weight: 800; box-shadow: 0 4px 13px rgba(25,72,45,.16); }
.avatar-editor-row strong { align-self: end; color: var(--sage-900); font-size: 13px; }
.avatar-editor-row button { min-height: 34px; padding: 0 11px; border: 0; border-radius: 10px; background: var(--sage-700); color: white; font-size: 10px; font-weight: 700; }
.avatar-editor-row .avatar-reset { grid-column: 2 / 4; justify-self: start; min-height: 26px; padding: 0; background: transparent; color: var(--muted); font-size: 9px; font-weight: 600; }
.avatar-editor-row .avatar-reset:hover { color: var(--danger); }
.avatar-status { min-height: 22px; margin: 13px 3px 0; color: var(--sage-700); font-size: 11px; }
.avatar-crop-dialog { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(13,18,15,.72); backdrop-filter: blur(8px); }
.avatar-crop-card { width: min(430px, 100%); padding: 18px; border-radius: 22px; background: #fff; box-shadow: 0 22px 70px rgba(9,15,11,.3); }
.avatar-crop-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.avatar-crop-header > div { display: grid; gap: 3px; }
.avatar-crop-header strong { color: var(--charcoal); font-size: 18px; }
.avatar-crop-header span { color: var(--muted); font-size: 10px; }
.avatar-crop-header .icon-button { width: 42px; height: 42px; font-size: 27px; }
.avatar-crop-stage { position: relative; width: min(330px, 76vw); aspect-ratio: 1; margin: 0 auto; overflow: hidden; border-radius: 18px; background: #e8ebe8; box-shadow: inset 0 0 0 1px rgba(19,32,24,.13); }
.avatar-crop-stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; }
.avatar-crop-stage canvas.dragging { cursor: grabbing; }
.avatar-crop-guide { position: absolute; inset: 0; border: 2px solid rgba(255,255,255,.92); border-radius: 50%; box-shadow: 0 0 0 999px rgba(10,15,12,.24), inset 0 0 0 1px rgba(16,27,20,.14); pointer-events: none; }
.avatar-crop-zoom { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; margin: 16px 2px 14px; color: var(--muted); font-size: 11px; }
.avatar-crop-zoom input { width: 100%; accent-color: var(--sage-700); }
.avatar-crop-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 9px; }
.avatar-crop-actions button { min-height: 44px; border: 0; border-radius: 13px; font-size: 12px; font-weight: 750; }
.avatar-crop-cancel { background: #eef1ee; color: var(--muted); }
.avatar-crop-confirm { background: var(--sage-700); color: white; }

.chat-info-overlay { z-index: 14; }
.chat-info-panel { position: fixed; z-index: 15; top: 0; right: 0; width: min(480px, 96vw); height: 100vh; height: 100dvh; overflow: hidden; background: #f2f3f2; box-shadow: -14px 0 38px rgba(13,18,15,.2); }
.chat-info-header { height: 64px; display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; padding: 0 12px; border-bottom: 1px solid #e5e8e5; background: #fff; }
.chat-info-header .icon-button { width: 44px; height: 44px; font: 36px/1 Georgia, serif; }
.chat-info-header strong { overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.chat-info-scroll { height: calc(100dvh - 64px); overflow-y: auto; padding: 16px 0 max(28px, env(safe-area-inset-bottom)); }
.chat-info-members-section { margin-bottom: 12px; padding: 16px 18px 13px; background: #fff; }
.chat-info-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; color: var(--muted); }
.chat-info-section-title strong { color: var(--charcoal); font-size: 13px; }
.chat-info-section-title span { font-size: 10px; }
.chat-info-members { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 13px 8px; }
.chat-info-member { min-width: 0; display: grid; justify-items: center; gap: 5px; }
.chat-info-member-avatar { display: grid; place-items: center; width: 52px; height: 52px; border: 1px solid rgba(28,48,35,.10); border-radius: 13px; background-position: center; background-size: cover; color: white; font-size: 12px; font-weight: 800; box-shadow: 0 3px 12px rgba(19,40,26,.08); }
.chat-info-member strong, .chat-info-member small { width: 100%; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.chat-info-member strong { font-size: 11px; }
.chat-info-member small { color: var(--muted); font-size: 8px; }
.chat-info-member.offline { opacity: .48; }
.chat-info-group { margin-bottom: 12px; border-top: 1px solid #e6e9e6; border-bottom: 1px solid #e6e9e6; background: #fff; }
.chat-info-row { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 0 18px; border: 0; border-bottom: 1px solid #edf0ed; background: #fff; color: var(--charcoal); text-align: left; }
.chat-info-row:last-child { border-bottom: 0; }
button.chat-info-row:active { background: #f3f6f3; }
.chat-info-row > span:first-child { font-size: 13px; }
.chat-info-row > span:last-child { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; color: #8d9690; }
.chat-info-row strong { overflow: hidden; color: #667168; font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.chat-info-row small { font-size: 10px; }
.chat-info-row i { font: 25px/1 Georgia, serif; }
.chat-background-preview { width: 40px; height: 40px; border: 1px solid #d4ddd6; border-radius: 8px; background-color: var(--canvas); background-image: radial-gradient(circle at 22% 30%, rgba(255,255,255,.9) 0 2px, transparent 3px), radial-gradient(circle at 72% 64%, rgba(41,122,71,.18) 0 2px, transparent 3px); background-position: center; background-size: 31px 31px, 39px 39px; }
.chat-background-preview[data-chat="gen"] { background-color: #f7f4ee; background-image: radial-gradient(circle at 18% 28%, rgba(41,79,54,.10) 0 1px, transparent 2px), radial-gradient(circle at 74% 67%, rgba(217,135,86,.12) 0 1px, transparent 2px); }
.chat-background-preview[data-chat="glm"] { background-color: #e4e8f8; background-image: radial-gradient(circle at 18% 28%, rgba(255,255,255,.9) 0 2px, transparent 3px), radial-gradient(circle at 72% 64%, rgba(78,88,168,.18) 0 2px, transparent 3px); }
.chat-background-preview.custom { background-size: cover; }
.reset-row > span:first-child { color: #a4524c; }
.switch-row { cursor: pointer; }
.switch-row input { appearance: none; position: relative; width: 45px; height: 26px; margin: 0; border-radius: 999px; background: #d9dedb; transition: background 130ms ease; }
.switch-row input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 5px rgba(20,28,23,.22); transition: transform 130ms ease; }
.switch-row input:checked { background: var(--sage-600); }
.switch-row input:checked::after { transform: translateX(19px); }
.chat-background-status { min-height: 18px; margin: 0 20px; color: var(--sage-700); font-size: 10px; }

.main-panel { width: 100%; max-width: 100%; min-width: 0; min-height: 0; display: grid; grid-template-rows: 64px minmax(0, 1fr) auto; overflow: hidden; }
.topbar { z-index: 4; width: 100%; max-width: 100%; min-width: 0; display: flex; align-items: center; gap: 12px; overflow: hidden; padding: 0 20px; border-bottom: 1px solid #b8d5bf; background: rgba(255,255,255,.96); box-shadow: 0 3px 14px rgba(25,72,45,.10); }
.menu-button { display: none; width: 34px; height: 34px; font-size: 18px; }
.channel-title { min-width: 0; flex: 1; display: flex; align-items: center; gap: 11px; }
.channel-title > div:last-child { min-width: 0; }
.channel-title > .contact-avatar { width: 42px; height: 42px; }
.group-avatar { width: 42px; height: 42px; }
.group-avatar i { width: 26px; height: 26px; border: 2px solid white; font-size: 8px; }
.channel-title h1 { margin: 0; font-size: 15px; line-height: 1.2; }
.channel-title p { overflow: hidden; max-width: 500px; margin: 4px 0 0; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.relay-toggle { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--sage-700); font-size: 10px; white-space: nowrap; }
.relay-toggle input { appearance: none; position: relative; width: 29px; height: 17px; margin: 0; border-radius: 999px; background: var(--sage-300); transition: background 130ms ease; }
.relay-toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(20,28,23,.22); transition: transform 130ms ease; }
.relay-toggle input:checked { background: var(--sage-700); }
.relay-toggle input:checked::after { transform: translateX(12px); }
.relay-toggle input:disabled { opacity: .55; }
.topbar-action { margin-left: auto; padding: 6px 10px; border: 0; border-radius: 13px; background: var(--sage-100); color: var(--sage-700); font-size: 9px; font-weight: 750; }
.moments-link { flex: 0 0 auto; text-decoration: none; white-space: nowrap; }
.topbar-action + .topbar-action { margin-left: -6px; }
.chat-info-button { flex: 0 0 auto; width: 44px; height: 44px; margin-left: auto; padding: 0 0 6px; border: 0; background: transparent; color: var(--sage-900); font-size: 17px; font-weight: 850; letter-spacing: 2px; }

.chat {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px clamp(14px, 5vw, 64px);
  background-color: var(--canvas);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.72) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 64%, rgba(41,122,71,.15) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 18%, rgba(217,135,86,.10), transparent 28%);
  background-size: 58px 58px, 74px 74px;
}
body[data-chat="gen"] .chat {
  background-color: #f7f4ee;
  background-image:
    radial-gradient(circle at 18% 28%, rgba(41,79,54,.07) 0 1px, transparent 2px),
    radial-gradient(circle at 74% 67%, rgba(217,135,86,.08) 0 1px, transparent 2px);
}
body[data-chat="glm"] .chat {
  background-color: #e4e8f8;
  background-image:
    radial-gradient(circle at 18% 28%, rgba(255,255,255,.75) 0 2px, transparent 3px),
    radial-gradient(circle at 72% 64%, rgba(78,88,168,.14) 0 2px, transparent 3px);
}
.chat.has-chat-background,
body[data-chat="gen"] .chat.has-chat-background,
body[data-chat="glm"] .chat.has-chat-background {
  background-color: #dfe6e0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
.empty-state { width: max-content; max-width: 90%; margin: 25vh auto 0; display: grid; justify-items: center; gap: 5px; color: var(--muted); }
.empty-avatar { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 6px; border-radius: 50%; background: var(--sage-700); color: white; font-weight: 750; box-shadow: var(--shadow); }
.empty-state strong { color: var(--sage-900); font-size: 14px; }
.empty-state span { font-size: 10px; }
.kimi-setup { width: min(360px, calc(100% - 28px)); margin: 18vh auto 0; display: grid; justify-items: center; gap: 10px; padding: 22px; border-radius: 16px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.kimi-setup strong { font-size: 14px; }
.kimi-setup small { color: var(--muted); font-size: 9px; }
.key-row { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.key-row input { min-width: 0; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--charcoal); }
.key-row input:focus { border-color: var(--sage-500); }
.key-row button { padding: 0 14px; border: 0; border-radius: 9px; background: var(--sage-700); color: white; font-size: 11px; }
.messages { width: 100%; max-width: 820px; min-width: 0; margin: 0 auto; display: grid; gap: 7px; }
.load-earlier-messages { display: block; min-height: 34px; margin: -8px auto 14px; padding: 0 15px; border: 1px solid rgba(50,111,75,.18); border-radius: 999px; background: rgba(255,255,255,.78); color: var(--sage-700); font-size: 10px; box-shadow: 0 3px 12px rgba(25,72,45,.06); }
.load-earlier-messages:disabled { opacity: .55; }
.message.history-target .message-body { animation: history-highlight 1.9s ease-out; }
@keyframes history-highlight { 0%, 35% { box-shadow: 0 0 0 4px rgba(217,135,86,.38), var(--shadow); } 100% { box-shadow: var(--shadow); } }
.message { width: 100%; max-width: 100%; min-width: 0; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 7px; align-items: end; }
.message-enter { animation: rise 150ms ease-out; }
.message.user { grid-template-columns: minmax(0, 1fr); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #26322b; color: white; font-size: 10px; font-weight: 750; }
.message[data-provider="kimi"] .avatar { background: #4f8b62; }
.message[data-provider="glm"] .avatar { background: #5963b6; }
.message[data-provider="anthropic"] .avatar, .message[data-provider="claude-code"] .avatar { background: #141615; }
.message[data-provider="gen"] .avatar, .message[data-provider="codex-cli"] .avatar, .message[data-provider="openai"] .avatar { border: 1px solid #d7dbd8; background: white; color: #252a27; }
.message.user .avatar { display: none; }
.message-body { position: relative; min-width: 70px; max-width: min(76%, 650px); padding: 8px 11px 7px; border: 1px solid rgba(44,65,51,.14); border-radius: 5px 13px 13px 13px; background: var(--paper); box-shadow: var(--shadow); }
.message-body.copyable { -webkit-touch-callout: none; touch-action: pan-y; }
.message-body.copying { transform: scale(.992); filter: brightness(.97); }
.message.user .message-body { justify-self: end; border-color: rgba(34,104,61,.27); border-radius: 13px 5px 13px 13px; background: var(--mine); }
.message-meta { display: flex; align-items: baseline; gap: 7px; margin-bottom: 2px; }
.message-meta strong { color: var(--sage-700); font-size: 10px; }
.message.user .message-meta strong { display: none; }
.message-meta span { color: #929994; font-size: 8px; }
.message-content { white-space: pre-wrap; overflow-wrap: anywhere; font-family: "Living Room Serif", "Noto Serif SC", "Songti SC", STSong, SimSun, serif; font-size: 13px; font-weight: 400; line-height: 1.55; }
.message-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin: 3px 0 7px; }
.message-images:has(:only-child) { grid-template-columns: 1fr; }
.message-images a { display: block; overflow: hidden; border-radius: 9px; background: #d5ddd6; }
.message-images img { display: block; width: 100%; max-height: 340px; border-radius: 9px; object-fit: cover; cursor: zoom-in; }
.tool-calls { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 7px; }
.tool-call { padding: 4px 8px; border: 1px solid #b6c8ba; border-radius: 999px; background: #edf3ee; color: #31533c; font-size: 9px; font-weight: 700; }
.tool-call.failed { border-color: #d8b3b0; background: #f9eceb; color: #8e4743; }
.mention { color: #46634d; font-weight: 700; }
.thinking-panel { margin: 1px 0 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); color: #647068; }
.thinking-toggle { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; font: inherit; font-size: 9px; font-weight: 700; -webkit-tap-highlight-color: transparent; }
.thinking-toggle:focus { outline: none; }
.thinking-toggle:focus-visible { color: var(--sage-900); }
.thinking-toggle::before { content: "›"; display: inline-block; margin-right: 5px; transition: transform 120ms ease; }
.thinking-toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
.thinking-content { max-height: 180px; overflow-y: auto; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; color: #77817a; font-size: 10px; line-height: 1.5; }
.read-label { color: #5d7762 !important; }
.system-message { justify-self: center; padding: 5px 9px; border-radius: 10px; background: rgba(52,65,57,.62); color: white; font-size: 9px; }
.copy-toast { position: fixed; z-index: 20; left: 50%; bottom: calc(82px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 7px 12px; border-radius: 14px; background: rgba(25,27,26,.88); color: white; font-size: 11px; box-shadow: var(--shadow); pointer-events: none; }
.image-lightbox { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: max(58px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); overflow: auto; overscroll-behavior: contain; background: rgba(4,6,5,.92); backdrop-filter: blur(6px); }
.image-lightbox img { display: block; width: auto; height: auto; max-width: min(96vw, 1400px); max-height: calc(100dvh - 92px); object-fit: contain; border-radius: 4px; box-shadow: 0 18px 70px rgba(0,0,0,.42); touch-action: pinch-zoom; }
.image-lightbox-close { position: fixed; z-index: 1; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: grid; place-items: center; width: 44px; height: 44px; padding: 0 0 3px; border: 1px solid rgba(255,255,255,.28); border-radius: 50%; background: rgba(18,20,19,.7); color: white; font-size: 30px; line-height: 1; cursor: pointer; }
.image-lightbox-close:hover { background: rgba(42,46,44,.9); }

.composer-wrap { z-index: 3; width: 100%; max-width: 100%; min-width: 0; overflow: hidden; padding: 7px clamp(10px, 4vw, 44px) max(9px, env(safe-area-inset-bottom)); background: var(--canvas); }
.gen-workbar { max-width: 820px; margin: 0 auto 6px; display: flex; align-items: center; gap: 7px; }
.gen-mode-switch { display: flex; padding: 2px; border: 1px solid #d4d8d5; border-radius: 12px; background: rgba(255,255,255,.78); }
.gen-mode-switch button { min-height: 28px; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; color: #737a75; font-size: 9px; font-weight: 750; }
.gen-mode-switch button[aria-pressed="true"] { background: #252826; color: white; box-shadow: 0 2px 6px rgba(25,28,26,.16); }
.gen-workspace-wrap { min-width: 0; display: flex; align-items: center; gap: 6px; color: #747b76; font-size: 9px; }
.gen-workspace-wrap select { min-width: 0; height: 31px; max-width: 180px; padding: 0 25px 0 9px; border: 1px solid #d4d8d5; border-radius: 10px; outline: 0; background: rgba(255,255,255,.9); color: #292d2a; font-size: 10px; }
.gen-workbar[hidden], .gen-workspace-wrap[hidden] { display: none; }
.run-status { max-width: 820px; margin: 0 auto 5px; padding-left: 8px; color: var(--sage-700); font-size: 9px; }
.run-status::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.mention-bar { max-width: 820px; margin: 0 auto 5px; display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.mention-bar::-webkit-scrollbar { display: none; }
.mention-bar button { flex: 0 0 auto; padding: 4px 9px; border: 1px solid rgba(89,106,93,.18); border-radius: 12px; background: rgba(255,255,255,.76); color: var(--sage-700); font-size: 9px; }
.emoji-panel { max-width: 820px; margin: 0 auto 5px; display: flex; gap: 3px; width: max-content; padding: 5px 7px; border-radius: 12px; background: white; box-shadow: var(--shadow); }
.emoji-panel button { padding: 4px; border: 0; border-radius: 7px; background: transparent; font-size: 17px; }
.emoji-panel button:hover { background: var(--sage-100); }
.image-preview { max-width: 820px; margin: 0 auto 6px; display: flex; gap: 7px; overflow-x: auto; }
.image-preview-item { position: relative; flex: 0 0 auto; width: 68px; height: 68px; }
.image-preview-item img { width: 100%; height: 100%; border: 2px solid white; border-radius: 11px; object-fit: cover; box-shadow: var(--shadow); }
.image-preview-item button { position: absolute; top: -5px; right: -5px; width: 22px; height: 22px; padding: 0; border: 2px solid white; border-radius: 50%; background: #202522; color: white; font-size: 13px; }
.composer { width: 100%; max-width: 820px; min-width: 0; min-height: 50px; margin: 0 auto; display: flex; align-items: flex-end; gap: 5px; padding: 5px; border: 1px solid rgba(42,115,70,.26); border-radius: 17px; background: white; box-shadow: var(--shadow); }
.emoji-button, .attach-button { align-self: center; flex: 0 0 auto; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #4f5f54; font-size: 21px; }
.attach-button { font-size: 25px; font-weight: 300; }
.emoji-button:hover, .attach-button:hover { background: var(--sage-100); color: var(--sage-900); }
.composer textarea { flex: 1; min-width: 0; min-height: 38px; max-height: 130px; resize: none; padding: 9px 0 7px; border: 0; outline: 0; background: transparent; color: var(--charcoal); font-family: "Living Room Input Serif", "Living Room Serif", "Noto Serif SC", "Songti SC", STSong, SimSun, serif; font-weight: 400; line-height: 1.4; }
.composer textarea::placeholder { color: #9da39f; }
.action-buttons { display: flex; align-items: center; gap: 5px; }
.send-button, .stop-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; color: white; }
.send-button { background: linear-gradient(145deg, #3d8458, #245e3d); padding-left: 2px; font-size: 15px; box-shadow: 0 4px 11px rgba(29,91,54,.25); }
body[data-chat="gen"] .send-button { background: #2b2e2c; }
body[data-chat="gen"] .send-button:hover { background: #111312; }
body[data-chat="glm"] .send-button { background: linear-gradient(145deg, #6873ca, #414997); box-shadow: 0 4px 11px rgba(55,64,148,.25); }
.send-button:hover { background: var(--sage-800); }
.send-button:disabled { cursor: not-allowed; opacity: .45; }
.stop-button { background: var(--danger); font-size: 10px; }
.composer-wrap.locked .composer { opacity: .52; }

.sidebar-overlay { position: fixed; inset: 0; z-index: 7; border: 0; background: rgba(20,25,22,.42); }
@keyframes rise { from { opacity: 0; transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) {
  .message-enter { animation: none; }
  .thinking-toggle::before { transition: none; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 330px); transform: translateX(-102%); box-shadow: 10px 0 28px rgba(25,32,27,.16); transition: transform 180ms ease; }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close, .menu-button { display: grid; }
  .main-panel { height: 100vh; height: 100dvh; }
}

@media (max-width: 520px) {
  button { touch-action: manipulation; }
  .composer textarea { font-size: 16px; }
  .channel-title { overflow: hidden; }
  .main-panel { grid-template-rows: 58px minmax(0, 1fr) auto; }
  .topbar { padding: 0 9px; gap: 7px; }
  .group-avatar { width: 38px; height: 38px; }
  .channel-title > .contact-avatar { width: 38px; height: 38px; }
  .group-avatar i { width: 24px; height: 24px; }
  .channel-title p { max-width: 185px; }
  .menu-button, .sidebar-close { width: 44px; height: 44px; }
  .chat-info-panel { width: 100vw; }
  .chat-info-header { height: 58px; padding-top: env(safe-area-inset-top); }
  .chat-info-scroll { height: calc(100dvh - 58px); }
  .chat-info-members { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chat-info-member-avatar { width: 50px; height: 50px; }
  .history-search-form button { min-height: 42px; }
  .history-search-panel { width: 100vw; }
  .history-search-header { height: 58px; padding-top: env(safe-area-inset-top); }
  .history-search-results { max-height: calc(100dvh - 254px); }
  .conversation-card { min-height: 64px; }
  .memory-form button { min-width: 44px; min-height: 44px; }
  .memory-form input { height: 44px; font-size: 13px; }
  .memory-item { min-height: 44px; align-items: center; font-size: 11px; }
  .memory-item button { min-width: 44px; min-height: 36px; font-size: 10px; }
  .emoji-panel button { min-width: 40px; min-height: 40px; }
  .emoji-button { width: 40px; height: 40px; }
  .attach-button { width: 40px; height: 40px; }
  .send-button, .stop-button { width: 44px; height: 44px; }
  .relay-toggle span { display: none; }
  .chat { padding: 13px 8px; }
  .empty-state { margin-top: 23vh; }
  .messages { gap: 6px; }
  .message { grid-template-columns: 32px minmax(0, 1fr); gap: 6px; }
  .avatar { width: 32px; height: 32px; font-size: 9px; }
  .message-body { max-width: 84%; }
  .composer-wrap { padding: 6px max(7px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); }
  .gen-mode-switch button { min-height: 34px; padding: 0 12px; font-size: 10px; }
  .gen-workspace-wrap { flex: 1; }
  .gen-workspace-wrap span { display: none; }
  .gen-workspace-wrap select { width: 100%; max-width: none; height: 36px; font-size: 11px; }
  .composer { border-radius: 15px; }
}
