:root {
  color-scheme: light;
  --canvas: #f0f1ef;
  --surface: #fcfdfc;
  --muted: #68736d;
  --ink: #17201b;
  --line: #e5e9e5;
  --green: #087c4b;
  --bright: #95ec69;
  --pale: #e4f4e9;
  --nav: #eef2ef;
  --ease: cubic-bezier(.22,.75,.24,1);
  font: 15px/1.45 "Inter", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); overscroll-behavior: none; }
button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid #149960; outline-offset: 2px; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.app { position: fixed; inset: 0; display: grid; grid-template-columns: 72px minmax(292px, 356px) minmax(0, 1fr); overflow: hidden; }
#tabs { display: flex; flex-direction: column; align-items: center; padding: 24px 8px; gap: 10px; background: var(--nav); border-right: 1px solid var(--line); z-index: 2; }
.app-icon { border-radius: 10px; margin-bottom: 21px; }
#tabs button { position: relative; display: grid; justify-items: center; gap: 2px; width: 55px; padding: 8px 0; border-radius: 10px; color: var(--muted); transition: color .18s, background .18s, transform .18s var(--ease); }
#tabs button.current { color: var(--green); background: #dcece1; font-weight: 650; }
#tabs button:active, .primary:active, .secondary:active, .icon-button:active { transform: scale(.95); }
#tabs small { font-size: 11px; }
#tabs i { position: absolute; top: 6px; right: 7px; min-width: 9px; min-height: 9px; border-radius: 99px; background: #ed5d58; border: 1px solid var(--nav); }
.list-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.list-header { display: flex; align-items: center; justify-content: space-between; min-height: 104px; padding: 19px 23px; }
.list-header h1 { font-size: 27px; font-weight: 700; letter-spacing: -.04em; }
#connection { color: var(--muted); font-size: 12px; margin-top: 5px; display: flex; align-items: center; gap: 6px; }
#connection i { width: 7px; height: 7px; border-radius: 50%; background: #a3aca6; }
#connection.online i { background: #1a9d62; }
.icon-button { display: grid; place-items: center; min-width: 39px; min-height: 39px; padding: 7px; border-radius: 9px; transition: background .16s, transform .2s var(--ease); }
.icon-button:hover { background: #e8eee9; }
.warning { display: flex; justify-content: space-between; align-items: center; margin: 0 15px 10px; padding: 10px 13px; border-radius: 8px; background: #f9efd8; color: #765216; font-size: 13px; text-align: left; }
.warning span { font-weight: 700; }
.list-content { min-height: 0; flex: 1; overflow: auto; overscroll-behavior-y: contain; }
.section-label { padding: 15px 20px 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.empty-list { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 14px; }
.conversation { position: relative; overflow: hidden; }
.row { position: relative; width: 100%; min-height: 72px; display: flex; gap: 12px; align-items: center; background: var(--surface); padding: 10px 17px 10px 20px; text-align: left; transition: background .15s, transform .28s var(--ease); touch-action: pan-y; }
.row::after { content: ""; position: absolute; bottom: 0; left: 76px; right: 0; height: 1px; background: var(--line); }
.row:hover { background: #f0f4f0; }
.row.active { background: #e5efe7; }
.row.open-actions { transform: translateX(-112px); }
.row-text { flex: 1; min-width: 0; }
.row-title, .row-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title { font-size: 15px; font-weight: 650; }
.row-preview { margin-top: 4px; color: var(--muted); font-size: 12px; }
.row-meta { align-self: stretch; text-align: right; display: grid; align-content: center; justify-items: end; gap: 5px; color: var(--muted); font-size: 11px; }
.badge { display: inline-grid; min-width: 17px; height: 17px; place-items: center; border-radius: 99px; background: #e65150; color: white; padding: 0 4px; font-size: 10px; }
.row-actions { position: absolute; inset: 0 0 0 auto; display: flex; visibility: hidden; }
.row-actions button { width: 56px; background: #697b6f; color: white; padding: 0 3px; font-size: 12px; }
.row-actions button:last-child { background: #d64e4b; }
.conversation.revealed .row-actions { visibility: visible; }
.row-menu { position: absolute; right: 6px; bottom: 3px; border-radius: 5px; color: var(--muted); opacity: 0; z-index: 1; }
.conversation:focus-within .row-menu, .conversation:hover .row-menu { opacity: 1; }
.conversation.revealed .row-menu { visibility: hidden; }
.avatar { flex: 0 0 auto; width: 42px; height: 42px; display: inline-grid; place-items: center; overflow: hidden; border-radius: 10px; font-size: 18px; font-weight: 650; background: #dceee2; color: #2d7656; }
.avatar[data-color="1"] { background: #e5eafa; color: #4e6198; }
.avatar[data-color="2"] { background: #f5e8dd; color: #986946; }
.avatar[data-color="3"] { background: #e7e7f4; color: #6b5c95; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-pane { min-height: 0; min-width: 0; background: #f1f2f0; }
.blank { height: 100%; display: grid; place-items: center; color: #d0d8d2; }
.blank svg { width: 74px; height: 74px; stroke-width: .8; }
#chat { display: flex; height: 100%; min-height: 0; flex-direction: column; }
.chat-header { display: flex; align-items: center; gap: 11px; padding: 13px 25px; min-height: 73px; background: #f8faf8; border-bottom: 1px solid #e1e6e1; }
#chat-avatar .avatar { width: 35px; height: 35px; font-size: 14px; }
.chat-header h2 { font-size: 17px; font-weight: 650; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#back { display: none; }
#thread { min-height: 0; flex: 1; overflow: auto; overscroll-behavior-y: contain; padding: 15px clamp(16px, 4vw, 50px) 18px; }
#older { display: block; margin: 0 auto 14px; }
.date { text-align: center; color: #68746c; font-size: 11px; padding: 17px 0 10px; }
.message { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; }
.message.outgoing { flex-direction: row-reverse; }
.message .avatar { width: 33px; height: 33px; border-radius: 8px; font-size: 13px; }
.message-content { min-width: 0; max-width: min(75%, 620px); }
.message.outgoing .message-content { display: flex; align-items: flex-end; flex-direction: column; }
.sender { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.bubble { background: white; border: 1px solid #e8ebe7; border-radius: 9px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 35px; }
.outgoing .bubble { background: var(--bright); border-color: transparent; }
.bubble.image { padding: 0; background: none; overflow: hidden; }
.bubble img { display: block; max-width: min(330px, 100%); max-height: 330px; object-fit: contain; cursor: zoom-in; }
.placeholder { color: var(--muted); }
.voice { display: flex; align-items: center; gap: 11px; min-width: 112px; text-align: left; }
.voice .wave { letter-spacing: 2px; color: #318651; }
.voice.playing .wave { animation: pulse 1s infinite alternate; }
.voice i { background: #ec514e; height: 7px; width: 7px; border-radius: 50%; }
.transcript { margin-top: 5px; color: #39433c; background: #f9faf8; padding: 7px 11px; border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
.quote { font-size: 12px; color: #40534a; border-left: 2px solid #609b60; padding: 4px 6px; margin-bottom: 7px; background: #e9f0e7; border-radius: 3px; }
.meta { display: flex; min-height: 18px; gap: 7px; align-items: center; margin-top: 3px; color: var(--muted); font-size: 11px; }
.message:not(.outgoing) .meta { opacity: 0; transition: opacity .16s; }
.message:not(.outgoing):focus-within .meta, .message:not(.outgoing):hover .meta { opacity: 1; }
.meta button { color: var(--muted); padding: 0 2px; }
.meta .retry { color: #9b4633; }
.receipt { width: 20px; height: 18px; display: inline-grid; place-items: center; position: relative; color: var(--green); vertical-align: middle; }
.receipt > span { grid-area: 1/1; opacity: 0; transform: scale(.55) translateY(2px); transition: opacity .2s, transform .27s var(--ease); }
.receipt[data-state="waiting"] .waiting, .receipt[data-state="downloaded"] .one, .receipt[data-state="sent"] .two { opacity: 1; transform: none; }
.receipt svg { width: 18px; height: 18px; }
.receipt .waiting { width: 12px; height: 12px; border: 1.5px solid #9eb0a3; border-top-color: var(--green); border-radius: 50%; }
.receipt[data-state="waiting"] .waiting { animation: spin .85s linear infinite; }
.composer { padding: 11px clamp(14px, 3vw, 30px) max(13px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #f8faf8; }
.input-row { display: flex; align-items: end; gap: 9px; }
#reply { display: block; flex: 1; min-width: 0; min-height: 41px; max-height: 126px; resize: none; border: 1px solid #dfe6df; border-radius: 9px; background: white; padding: 9px 11px; color: var(--ink); font-size: 16px; }
#quote-bar { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; padding: 1px 4px 4px; }
#quote-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#quote-bar button { min-height: 28px; min-width: 28px; padding: 0; font-size: 20px; }
.primary, .secondary, .danger { border-radius: 8px; padding: 8px 13px; white-space: nowrap; transition: transform .2s var(--ease), background .16s; font-weight: 650; }
.primary { background: var(--green); color: white; min-height: 41px; }
.primary:not(:disabled):hover { background: #066b41; }
.secondary { font-size: 13px; background: #e7eee8; color: #3e5146; }
.secondary:hover { background: #dde8df; }
.danger { color: #a63a37; background: #f9e9e7; }
.settings { padding: 0 17px 24px; }
.setting-group { padding: 15px 0; border-top: 1px solid var(--line); }
.setting-group h2 { font-size: 14px; margin-bottom: 10px; }
.setting-group p, .setting-note { font-size: 12px; color: var(--muted); margin: 6px 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin: 9px 0; font-size: 13px; }
.setting-row input[type="number"] { width: 65px; padding: 5px; }
.setting-row input[type="checkbox"], .picker input { accent-color: var(--green); width: 16px; height: 16px; }
.setting-row select, .setting-row input[type="number"], #login input, .dialog-input { border: 1px solid #dce4de; border-radius: 7px; background: white; color: var(--ink); }
.setting-row select { padding: 5px 6px; }
.storage-total { display: block; font-size: 23px; letter-spacing: -.04em; font-weight: 700; }
.storage-entry, .picker label { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.storage-entry span, .picker label span { flex: 1; overflow-wrap: anywhere; }
.storage-entry small { color: var(--muted); white-space: nowrap; }
.storage-entries { margin: 8px 0 14px; }
.picker { overflow: auto; max-height: 46dvh; }
.search { display: block; width: calc(100% - 34px); margin: 0 17px 8px; padding: 7px 10px; background: #f2f5f2; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
#login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: #eef3ef; }
.login-card { width: min(100%, 360px); padding: 30px; background: #fff; border: 1px solid #dfe8df; border-radius: 17px; display: grid; gap: 12px; box-shadow: 0 16px 55px #1f423012; animation: enter .3s var(--ease); }
.login-card h1 { font-size: 25px; margin-bottom: 10px; }
.login-card img { border-radius: 16px; }
.login-card label { font-size: 13px; }
#login input, .dialog-input { min-height: 41px; padding: 8px 10px; font-size: 16px; width: 100%; }
#login-error { color: #a63a37; font-size: 13px; min-height: 18px; }
dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 15px; width: min(440px, calc(100vw - 26px)); max-height: 85dvh; padding: 20px; }
dialog[open] { animation: enter .23s var(--ease); }
dialog::backdrop { background: #14271d70; }
dialog h2 { font-size: 17px; margin-bottom: 12px; }
dialog p { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.dialog-input { resize: vertical; }
.full-image { display: block; max-height: 70dvh; max-width: 100%; margin: auto; }
#toast { position: fixed; z-index: 4; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #203128; color: white; border-radius: 9px; padding: 9px 15px; max-width: calc(100vw - 24px); box-shadow: 0 4px 16px #13231c30; font-size: 13px; }
@keyframes enter { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { to { opacity: .38; } }
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0,1fr) auto; height: var(--viewport-height, 100dvh); top: var(--viewport-top, 0px); bottom: auto; }
  #tabs { grid-row: 2; flex-direction: row; justify-content: space-around; gap: 0; padding: 5px 10px max(5px, env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); background: #f6f8f6; }
  #tabs button { width: 75px; gap: 2px; padding: 3px 0; }
  #tabs button.current { background: none; }
  #tabs i { top: 1px; right: 21px; }
  #tabs .app-icon { display: none; }
  .list-pane { grid-row: 1; border-right: none; }
  .list-header { min-height: 81px; padding: max(12px, env(safe-area-inset-top)) 17px 11px; }
  .list-header h1 { font-size: 24px; }
  .detail-pane { position: absolute; z-index: 3; inset: 0; transform: translateX(100%); transition: transform .33s var(--ease), visibility .33s; visibility: hidden; }
  .app.chat-open .detail-pane { visibility: visible; transform: translateX(0); }
  .app.chat-open .list-pane { transform: translateX(-12%); }
  .list-pane { transition: transform .33s var(--ease); }
  #back { display: grid; margin-left: -8px; }
  .chat-header { min-height: 58px; padding: max(7px, env(safe-area-inset-top)) 12px 7px; gap: 7px; }
  #chat-avatar { display: none; }
  #thread { padding: 9px 13px 12px; }
  .row-menu { opacity: 0; }
  .message:not(.outgoing) .meta { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
