* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f3ef;
  color: #2c2a26;
}
button, input, textarea, select { font-family: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.gate {
  position: fixed;
  inset: 0;
  background: #f5f3ef;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 9999;
}
.gate.hidden { display: none; }
.gate-title { font-size: 18px; color: #5a4a30; letter-spacing: 4px; }
.gate input {
  padding: 12px 20px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 15px;
  width: 240px;
  text-align: center;
  background: #fff;
  outline: none;
}
.gate button {
  padding: 10px 32px;
  background: #5a4a30;
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
}
.gate .err { color: #a44; font-size: 13px; height: 18px; }

.app {
  display: none;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}
.app.show { display: flex; }
.sidebar {
  width: 270px;
  flex: 0 0 270px;
  height: 100dvh;
  background: #efe8dc;
  border-right: 1px solid #e1d5c2;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.sidebar-header {
  padding: 15px 14px;
  border-bottom: 1px solid #e1d5c2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.sidebar-title { color: #5a4a30; font-size: 15px; letter-spacing: 2px; }
.sidebar-new {
  background: #5a4a30;
  color: white;
  border: none;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.conversation-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}
.conversation-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #5a4a30;
  border-radius: 12px;
  padding: 10px 8px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}
.conversation-item:hover { background: rgba(255,255,255,0.55); }
.conversation-item.active { background: #fff; border-color: #e1d5c2; }
.conversation-title {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}
.delete-chat-btn {
  background: transparent;
  color: #aaa;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 8px;
}
.delete-chat-btn:hover { color: #a44; background: #fbe9e9; }
.sidebar-overlay { display: none; }

.main-panel {
  min-width: 0;
  flex: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.header {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e8e3d8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.header-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mobile-menu {
  display: none;
  background: transparent;
  color: #5a4a30;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 2px 7px 2px 0;
}
.header h1 {
  font-size: 16px;
  font-weight: 500;
  color: #5a4a30;
  letter-spacing: 4px;
  white-space: nowrap;
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}
.header-btn {
  font-size: 13px;
  color: #888;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 7px;
  white-space: nowrap;
}
.header-btn:hover { color: #5a4a30; }
.model-selector {
  background: #f5f3ef;
  color: #5a4a30;
  border: 1px solid #e8e3d8;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  max-width: 160px;
}
.token-badge {
  font-size: 12px;
  color: #8a7a5d;
  background: #f5f3ef;
  border: 1px solid #e8e3d8;
  padding: 4px 8px;
  border-radius: 12px;
  white-space: nowrap;
}
.sync-badge {
  font-size: 12px;
  color: #6f6048;
  background: #f5f3ef;
  border: 1px solid #e8e3d8;
  padding: 4px 8px;
  border-radius: 12px;
  white-space: nowrap;
}
.sync-badge.ok { color: #3f6b43; background: #eef7ef; border-color: #cfe6d1; }
.sync-badge.warn { color: #9a6a20; background: #fff6e5; border-color: #edd7a6; }
.sync-badge.err { color: #a44; background: #fbe9e9; border-color: #efcaca; }
.settings-panel {
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid #e8e3d8;
  padding: 16px 20px;
  display: none;
  max-height: 72dvh;
  overflow-y: auto;
}
.settings-panel.show { display: block; }
.settings-panel label {
  display: block;
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
  margin-top: 12px;
}
.settings-panel label:first-child { margin-top: 0; }
.settings-panel input, .settings-panel textarea, .settings-panel select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 7px;
  font-size: 14px;
  background: #fff;
  outline: none;
}
.settings-panel textarea { min-height: 150px; resize: vertical; }
.settings-panel .hint { color: #999; font-size: 12px; margin-top: 6px; line-height: 1.5; }
.row { display: flex; gap: 12px; }
.row > div { flex: 1; min-width: 0; }
.btn {
  margin-top: 12px;
  padding: 8px 18px;
  background: #5a4a30;
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 1px;
  margin-right: 8px;
}
.btn.danger { background: #a44; }
.btn.ghost { background: transparent; color: #5a4a30; border: 1px solid #5a4a30; }
.system-preset-row {
  display: flex;
  gap: 8px;
  margin: 6px 0 8px;
  flex-wrap: wrap;
}
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #5a4a30;
  background: #5a4a30;
  color: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}
.mini-btn.ghost {
  background: #fff;
  color: #5a4a30;
  border: 1px solid #8a7a5d;
}
.mini-btn:hover {
  filter: brightness(.96);
}
.mini-btn:active {
  transform: translateY(1px);
}
.system-preset-row .mini-btn {
  box-shadow: 0 1px 0 rgba(90,74,48,.08);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.usage-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e8e3d8;
  border-radius: 10px;
  background: #faf8f3;
  color: #5a4a30;
  font-size: 13px;
  line-height: 1.8;
}
.setting-section-title {
  margin: 18px 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4eee4;
  color: #5a4a30;
  font-size: 13px;
  letter-spacing: 1px;
  border: 1px solid #eadfce;
}
.setting-note {
  color: #9a8868;
  font-size: 12px;
  line-height: 1.6;
  margin: 6px 0;
}
textarea.compact { min-height: 110px; }
.danger-note { color: #a44; }

.usage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.usage-card { background: #fff; border: 1px solid #eee5d7; border-radius: 8px; padding: 8px; }
.usage-card b { display: block; font-size: 15px; color: #5a4a30; overflow-wrap: anywhere; }

.health-live-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e8e3d8;
  border-radius: 10px;
  background: #faf8f3;
  color: #5a4a30;
  font-size: 13px;
  line-height: 1.8;
}
.health-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.health-card { background: #fff; border: 1px solid #eee5d7; border-radius: 8px; padding: 8px; }
.health-card b { display: block; font-size: 16px; color: #5a4a30; overflow-wrap: anywhere; }
.health-watch-on { color: #a44; font-weight: 500; }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  -webkit-overflow-scrolling: touch;
}
.msg-wrapper { display: flex; flex-direction: column; max-width: 76%; gap: 4px; }
.msg-wrapper.user { align-self: flex-end; align-items: flex-end; }
.msg-wrapper.assistant { align-self: flex-start; align-items: flex-start; }
.msg {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 15px;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.user { background: #5a4a30; color: white; border-bottom-right-radius: 4px; }
.msg.assistant { background: white; border: 1px solid #e8e3d8; border-bottom-left-radius: 4px; }
.thinking-box {
  width: 100%;
  color: rgba(90,74,48,.4);
  font-size: 12px;
}
.thinking-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.thinking-label { font-size: 13px; }
.thinking-arrow { font-size: 9px; font-weight: 600; }
.thinking-body {
  display: none;
  align-items: stretch;
  gap: 14px;
  max-height: 200px;
  margin-top: 6px;
  margin-bottom: 8px;
  overflow: auto;
  text-align: left;
}
.thinking-box.is-expanded .thinking-body { display: flex; }
.thinking-box.is-expanded { margin-bottom: 4px; }
.thinking-rail {
  flex: 0 0 2px;
  width: 2px;
  border-radius: 1px;
  background: rgba(90,74,48,.28);
}
.thinking-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(90,74,48,.45);
}
.msg.generating::after { content: "▍"; opacity: .55; animation: blink 1s infinite; }
@keyframes blink { 0%, 45% { opacity: .4; } 46%, 100% { opacity: 0; } }
.msg-image { max-width: 240px; max-height: 240px; border-radius: 12px; margin-bottom: 6px; display: block; }
.file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: rgba(90,74,48,.08);
  border: 1px solid rgba(90,74,48,.14);
  font-size: 13px;
  white-space: normal;
}
.file-meta { color: #888; font-size: 12px; }
.msg-actions { display: none; gap: 6px; font-size: 11px; color: #999; }
.msg-wrapper:hover .msg-actions { display: flex; }
.msg-action-btn { background: none; border: none; color: #999; cursor: pointer; padding: 2px 6px; }
.msg-action-btn:hover { color: #a44; }
.toast {
  align-self: center;
  background: #f0eae0;
  color: #5a4a30;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 12px;
}
.toast.error { background: #fbe9e9; color: #a44; }
.empty { text-align: center; color: #aaa; font-size: 14px; padding: 40px 20px; line-height: 1.8; }

.input-area {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #e8e3d8;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.preview { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.preview-item {
  position: relative;
  min-width: 62px;
  max-width: 220px;
  min-height: 58px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #ddd;
  background: #fafafa;
  padding: 6px 22px 6px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.preview-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.preview-name { font-size: 12px; color: #5a4a30; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
}
.input-row { display: flex; gap: 8px; align-items: flex-end; }
.upload-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  background: #f0eae0;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 19px;
  color: #5a4a30;
}
.input-row textarea {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 18px;
  resize: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 118px;
  overflow-y: auto;
  outline: none;
}
.send-btn {
  padding: 0 20px;
  height: 40px;
  background: #5a4a30;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.send-btn:disabled { background: #ccc; cursor: not-allowed; }
.stop-btn { background: #a44; }
.continue-btn { background: #7b6541; }

@media (max-width: 900px) {
  .app.show { height: 100dvh; max-height: 100dvh; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 78vw;
    max-width: 310px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 10px 0 30px rgba(0,0,0,.12);
  }
  .app.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.25);
    z-index: 20;
  }
  .app.sidebar-open .sidebar-overlay { display: block; }
  .mobile-menu { display: inline-block; }
  .main-panel { width: 100%; min-width: 0; height: 100dvh; }
  .header { height: 50px; min-height: 50px; padding: 8px 10px; overflow: hidden; gap: 5px; }
  .header h1 { font-size: 14px; letter-spacing: 2px; }
  .header-actions { gap: 4px; flex: 1; justify-content: flex-end; overflow: hidden; }
  .model-selector { max-width: 96px; padding: 4px 5px; font-size: 11px; }
  .token-badge, .sync-badge { display: none; }
  .header-btn { font-size: 12px; padding: 4px 4px; }
  .settings-panel { padding: 12px; max-height: calc(100dvh - 50px); }
  .row { flex-direction: column; gap: 0; }
  .usage-grid { grid-template-columns: repeat(2, 1fr); }
  .health-grid { grid-template-columns: repeat(2, 1fr); }
  .messages { padding: 12px 10px; gap: 12px; }
  .msg-wrapper { max-width: 92%; }
  .msg { font-size: 15px; line-height: 1.55; padding: 10px 12px; }
  .msg-actions { display: flex; }
  .input-area { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .input-row { gap: 6px; }
  .upload-btn, .send-btn { height: 36px; min-width: 40px; padding: 0 10px; font-size: 13px; border-radius: 18px; }
  .input-row textarea { font-size: 16px; max-height: 100px; padding: 9px 12px; }
  .preview-item { max-width: 155px; }
}

@media (max-width: 390px) {
  .header-btn.export-top { display: none; }
  .send-btn { padding: 0 9px; }
  .upload-btn { width: 36px; }
}

/* 手机端折叠设置卡片 */
.settings-card-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.settings-card {
  border: 1px solid #eadfce;
  border-radius: 14px;
  background: #fffdf9;
  margin: 10px 0;
  overflow: hidden;
}
.settings-card-header {
  width: 100%;
  border: none;
  background: #f4eee4;
  color: #5a4a30;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 1px;
  text-align: left;
}
.settings-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.settings-card-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-card-arrow {
  flex: 0 0 auto;
  transition: transform .18s ease;
  color: #8a7a5d;
}
.settings-card.collapsed .settings-card-arrow { transform: rotate(-90deg); }
.settings-card-body {
  padding: 12px 14px 14px;
}
.settings-card.collapsed .settings-card-body { display: none; }
.settings-card .setting-section-title { display: none; }
.settings-card-body .system-preset-row {
  align-items: center;
}
.settings-card-body .btn.ghost,
.settings-card-body .btn {
  font-weight: 500;
}
.settings-card-body .btn.ghost {
  background: #fff;
}
.settings-card-body .btn.danger {
  color: #fff;
}
.settings-card-body > label:first-child,
.settings-card-body > .row:first-child,
.settings-card-body > textarea:first-child {
  margin-top: 0;
}
@media (max-width: 900px) {
  .settings-card { border-radius: 12px; margin: 8px 0; }
  .settings-card-header { padding: 11px 12px; font-size: 13px; }
  .settings-card-body { padding: 10px 12px 12px; }
  .settings-card-controls .mini-btn { flex: 1; min-width: 92px; }
}

/* ===== 青禾工作台 v3 · App shell ===== */
:root {
  --app-bg: #f7f3ed;
  --panel: rgba(255,255,255,.86);
  --panel-solid: #fffdfa;
  --ink: #2e2922;
  --muted: #8b8173;
  --accent: #665334;
  --accent-soft: #eee5d7;
  --line: rgba(102,83,52,.14);
  --shadow: 0 18px 50px rgba(68,52,31,.10);
  --radius: 22px;
}
body {
  background:
    radial-gradient(circle at 15% 0%, rgba(225,210,188,.34), transparent 30%),
    linear-gradient(180deg, #faf7f2 0%, var(--app-bg) 100%);
}
.app.show { background: transparent; }
.sidebar {
  width: 286px;
  flex-basis: 286px;
  background: rgba(239,232,220,.78);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-right: 1px solid var(--line);
}
.sidebar-header { padding: 20px 16px 14px; border-bottom: 0; }
.sidebar-title { display:flex; align-items:center; gap:10px; font-size:14px; letter-spacing:1px; font-weight:650; }
.brand-dot { width:10px; height:10px; border-radius:50%; background:#7f6844; box-shadow:0 0 0 5px rgba(127,104,68,.12); }
.sidebar-new { border-radius:999px; padding:8px 14px; box-shadow:0 7px 18px rgba(90,74,48,.18); }
.conversation-list { padding: 8px 12px 20px; }
.conversation-item { padding: 13px 12px; border-radius:16px; margin-bottom:7px; transition:.18s ease; }
.conversation-item:hover { transform:translateY(-1px); background:rgba(255,255,255,.62); }
.conversation-item.active { background:rgba(255,255,255,.94); border-color:rgba(102,83,52,.12); box-shadow:0 9px 24px rgba(71,55,32,.08); }
.header {
  min-height:68px;
  padding:12px 22px;
  background:rgba(255,253,250,.78);
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
  border-bottom:1px solid var(--line);
}
.app-title-wrap { display:flex; flex-direction:column; gap:2px; }
.header h1 { font-size:17px; letter-spacing:3px; font-weight:700; }
.app-subtitle { font-size:10px; color:var(--muted); letter-spacing:1.5px; }
.header-actions { gap:9px; }
.token-badge,.sync-badge,.model-selector { border-color:var(--line); background:rgba(255,255,255,.72); padding:7px 11px; border-radius:999px; }
.header-btn { color:#6f6558; padding:7px 9px; border-radius:10px; }
.header-btn:hover { background:var(--accent-soft); }
.messages { padding:26px clamp(18px,4vw,52px) 28px; gap:18px; }
.msg-wrapper { max-width:min(76%,820px); }
.msg { border-radius:22px; padding:16px 19px; line-height:1.72; box-shadow:0 8px 22px rgba(64,50,31,.055); }
.msg.user { background:linear-gradient(145deg,#6b5838,#58472d); border-bottom-right-radius:7px; }
.msg.assistant { background:rgba(255,255,255,.9); border:1px solid var(--line); border-bottom-left-radius:7px; }
.input-area { padding:12px 22px calc(14px + env(safe-area-inset-bottom)); background:rgba(255,253,250,.76); backdrop-filter:blur(20px); border-top:1px solid var(--line); }
.input-row { max-width:1200px; margin:0 auto; padding:7px; border:1px solid var(--line); background:rgba(255,255,255,.88); border-radius:26px; box-shadow:0 12px 30px rgba(66,51,31,.08); }
.input-row textarea { border:0; background:transparent; border-radius:18px; }
.input-row textarea:focus { box-shadow:none; }
.upload-btn { background:var(--accent-soft); }
.send-btn { border-radius:20px; min-width:72px; }

/* Settings becomes a true app drawer */
.settings-panel {
  position:fixed;
  z-index:80;
  top:0;
  right:0;
  width:min(680px,92vw);
  height:100dvh;
  max-height:none;
  padding:0 22px 34px;
  border:0;
  border-left:1px solid var(--line);
  background:rgba(250,247,242,.96);
  backdrop-filter:blur(26px);
  -webkit-backdrop-filter:blur(26px);
  box-shadow:-24px 0 70px rgba(57,44,27,.16);
  transform:translateX(105%);
  display:block;
  transition:transform .24s ease;
  overflow-y:auto;
}
.settings-panel.show { transform:translateX(0); }
body.settings-open::before { content:""; position:fixed; inset:0; z-index:70; background:rgba(38,31,23,.22); backdrop-filter:blur(2px); }
.settings-topbar { position:sticky; top:0; z-index:4; display:flex; justify-content:space-between; align-items:center; padding:20px 0 14px; background:linear-gradient(180deg,rgba(250,247,242,1) 72%,rgba(250,247,242,0)); }
.settings-kicker { font-size:10px; letter-spacing:2px; color:var(--muted); }
.settings-heading { font-size:24px; font-weight:750; margin-top:2px; }
.settings-close { width:40px; height:40px; border:1px solid var(--line); border-radius:50%; background:#fff; color:var(--ink); font-size:25px; cursor:pointer; }
.settings-overview { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:4px 0 16px; }
.overview-item { background:#fff; border:1px solid var(--line); border-radius:17px; padding:13px; }
.overview-item span { display:block; font-size:11px; color:var(--muted); margin-bottom:5px; }
.overview-item b { font-size:14px; overflow-wrap:anywhere; }
.settings-card { border-radius:20px; border-color:var(--line); background:rgba(255,255,255,.74); box-shadow:0 8px 22px rgba(67,52,31,.04); }
.settings-card-header { padding:15px 17px; background:rgba(239,230,216,.74); font-weight:650; }
.settings-card-body { padding:16px 17px 18px; }
.settings-panel input,.settings-panel textarea,.settings-panel select { border-radius:14px; padding:11px 13px; border-color:var(--line); }
.btn,.mini-btn { border-radius:999px; min-height:38px; }
.usage-box,.health-live-box { border-radius:18px; background:rgba(255,255,255,.7); border-color:var(--line); }
.usage-card,.health-card { border-radius:14px; border-color:var(--line); }
.mobile-dock { display:none; }

@media (max-width:900px) {
  .main-panel,.app.show { height:100dvh; }
  .header { height:60px; min-height:60px; padding:8px 13px; }
  .header h1 { font-size:16px; }
  .app-subtitle { display:none; }
  .header-actions .export-top { display:none; }
  .header-actions .header-btn { display:none; }
  .header-actions .model-selector { display:block; max-width:118px; padding:7px 9px; }
  .messages { padding:16px 12px 94px; }
  .msg-wrapper { max-width:94%; }
  .msg { border-radius:19px; padding:13px 14px; }
  .input-area { padding:8px 9px calc(72px + env(safe-area-inset-bottom)); }
  .input-row { padding:5px; border-radius:24px; }
  .settings-panel { width:100vw; padding:0 14px calc(90px + env(safe-area-inset-bottom)); border-left:0; }
  .settings-overview { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .overview-item { padding:10px; }
  .overview-item b { font-size:12px; }
  .mobile-dock {
    display:grid;
    grid-template-columns:repeat(4,1fr);
    position:fixed;
    z-index:95;
    left:10px;
    right:10px;
    bottom:calc(8px + env(safe-area-inset-bottom));
    height:62px;
    border:1px solid rgba(102,83,52,.13);
    border-radius:22px;
    background:rgba(255,253,250,.9);
    backdrop-filter:blur(22px);
    -webkit-backdrop-filter:blur(22px);
    box-shadow:0 18px 44px rgba(58,44,26,.18);
    padding:5px 8px;
  }
  .mobile-dock button { border:0; background:transparent; color:#6c604f; border-radius:16px; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:2px; }
  .mobile-dock button:active { background:var(--accent-soft); }
  .mobile-dock span { font-size:19px; line-height:1; }
  .mobile-dock small { font-size:10px; }
  .sidebar { padding-bottom:82px; }
}

@media (max-width:390px) {
  .settings-overview { grid-template-columns:1fr; }
  .settings-heading { font-size:21px; }
  .header-actions .model-selector { max-width:106px; }
}


/* 设置抽屉交互：固定顶栏、下滑关闭 */
.settings-topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin: 0 -18px 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.settings-drag-handle { display:none; }
@media (max-width:900px) {
  .settings-panel {
    top: 0;
    bottom: 0;
    border-radius: 22px 22px 0 0;
    overscroll-behavior: contain;
    transform: translateY(105%);
  }
  .settings-panel.show { transform:translateY(0); }
  .settings-topbar {
    margin:0 -14px 10px;
    padding:30px 14px 12px;
  }
  .settings-drag-handle {
    display:block;
    position:sticky;
    top:8px;
    z-index:10;
    width:42px;
    height:5px;
    border-radius:999px;
    background:#d2cbc0;
    margin:-20px auto 10px;
    touch-action:none;
  }
}

/* 设备与健康 */
.device-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.7);
  padding: 14px;
  margin-top: 8px;
}
.device-status-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.device-label { display:block; font-size:12px; color:var(--muted); margin-bottom:3px; }
.device-status-row b { color:var(--ink); }
.device-dot { width:11px; height:11px; border-radius:50%; background:#b9b1a6; box-shadow:0 0 0 5px rgba(185,177,166,.16); }
.device-dot.connected { background:#4f8b62; box-shadow:0 0 0 5px rgba(79,139,98,.14); }

/* V4：图片估算修复与附件预览 */
.composer-estimate { min-height: 20px; margin: 0 4px 7px; font-size: 11px; line-height: 1.45; color: #8a7a5d; white-space: normal; }
.composer-estimate.has-attachment { color: #6f5d3e; }
.preview-item.is-image { cursor: zoom-in; }
.preview-item.is-image:hover { border-color: #b8a988; }
.image-preview-modal { position: fixed; inset: 0; z-index: 10050; display: none; align-items: center; justify-content: center; padding: max(64px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom)); background: rgba(20,18,15,.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.image-preview-modal.show { display: flex; }
.image-preview-modal img { max-width: min(100%,1100px); max-height: calc(100dvh - 120px); object-fit: contain; border-radius: 14px; box-shadow: 0 18px 60px rgba(0,0,0,.34); }
.image-preview-toolbar { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fff; font-size: 13px; }
.image-preview-toolbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-preview-toolbar button { width: 38px; height: 38px; flex: 0 0 auto; border: 0; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
@media (max-width: 900px) { .composer-estimate { margin-bottom: 6px; font-size: 10.5px; } .image-preview-modal { padding-left: 8px; padding-right: 8px; } .image-preview-modal img { border-radius: 10px; } }

/* 对话重命名 */
.conversation-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.rename-chat-btn,
.delete-chat-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 10px;
  line-height: 1;
}
.rename-chat-btn {
  background: transparent;
  color: #aaa;
  border: none;
  cursor: pointer;
  font-size: 16px;
}
.rename-chat-btn:hover {
  color: #5a4a30;
  background: rgba(255,255,255,.72);
}
@media (hover: none) {
  .rename-chat-btn:active,
  .delete-chat-btn:active {
    transform: scale(.94);
  }
}

/* ===== Kli vNext · Memory Gateway ===== */
.memory-gateway-box {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line, rgba(102,83,52,.14));
  border-radius: 18px;
  background: rgba(255,255,255,.72);
}
.memory-gateway-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.memory-gateway-head b { display:block; margin-top:3px; color:var(--ink,#2e2922); font-size:14px; }
.memory-gateway-badge {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line, rgba(102,83,52,.14));
  background: #f4eee4;
  color: #7d6b50;
  font-size: 11px;
}
.memory-gateway-badge.ok { background:#eef7ef; color:#3f6b43; border-color:#cfe6d1; }
.memory-gateway-badge.busy { background:#fff6e5; color:#9a6a20; border-color:#edd7a6; }
.memory-profile-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: 7px;
  margin-bottom: 10px;
}
.memory-profile-card {
  padding: 8px;
  border: 1px solid var(--line, rgba(102,83,52,.14));
  border-radius: 12px;
  background: rgba(255,255,255,.84);
  color: #8b8173;
  font-size: 11px;
  text-align: center;
}
.memory-profile-card b { display:block; margin-top:2px; color:#5a4a30; font-size:15px; }
.memory-manager-count{font-size:12px;font-weight:500;opacity:.62;margin-left:6px}
@media (max-width:900px) {
  .memory-profile-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .memory-gateway-box { padding:12px; border-radius:15px; }
}

/* ===== Kli vNext v3 · Memory Manager ===== */
.memory-manager{margin-top:14px;padding-top:14px;border-top:1px solid rgba(70,60,45,.12)}
.memory-manager-title{font-weight:700;margin-bottom:10px}
.memory-manager-tools,.memory-add-row{display:grid;grid-template-columns:1fr 150px;gap:8px;margin-bottom:9px}
.memory-add-row{grid-template-columns:120px 90px 1fr auto}
.memory-input,.memory-select{width:100%;box-sizing:border-box;border:1px solid rgba(70,60,45,.18);border-radius:10px;padding:9px 10px;background:var(--paper,#fff);color:inherit;font:inherit}
.memory-record-list{display:flex;flex-direction:column;gap:8px;margin-top:10px;max-height:420px;overflow:auto}
.memory-record-item{border:1px solid rgba(70,60,45,.13);border-radius:12px;padding:10px;background:rgba(255,255,255,.5)}
.memory-record-top{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.memory-record-top .memory-select{width:auto;min-width:90px;padding:6px 8px}
.memory-record-content{width:100%;box-sizing:border-box;min-height:54px;resize:vertical;border:1px solid rgba(70,60,45,.15);border-radius:9px;padding:8px;font:inherit;background:var(--paper,#fff)}
.memory-record-actions{display:flex;justify-content:flex-end;gap:7px;margin-top:8px}
.memory-empty{padding:18px;text-align:center;opacity:.65}
@media(max-width:700px){.memory-manager-tools,.memory-add-row{grid-template-columns:1fr 1fr}.memory-add-row .memory-input{grid-column:1/-1}.memory-add-row .mini-btn{grid-column:1/-1}.memory-record-top{flex-wrap:wrap}}

/* v5 web search */
.web-search-btn{height:40px;min-width:58px;padding:0 10px;border:1px solid #d9cfbf;border-radius:20px;background:#f7f4ef;color:#756a5b;display:inline-flex;align-items:center;justify-content:center;gap:4px;cursor:pointer;flex:0 0 auto}.web-search-btn small{font-size:11px}.web-search-btn.active{background:#6a5637;color:#fff;border-color:#6a5637}.web-result-badge{display:inline-flex;width:max-content;margin:0 0 6px 4px;padding:4px 9px;border-radius:999px;background:#eee4d5;color:#665334;font-size:11px}.web-search-note{font-size:11px;color:#8a7d6c;margin-top:4px}@media(max-width:720px){.web-search-btn{width:40px;min-width:40px;padding:0}.web-search-btn small{display:none}}


/* ===== Kli v6.0 Stable ===== */
.sidebar-search-wrap {
  position: relative;
  padding: 10px 12px 7px;
}
.sidebar-search {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line, #e7dfd2);
  border-radius: 12px;
  padding: 0 34px 0 12px;
  background: rgba(255,255,255,.74);
  color: var(--text, #40382f);
  outline: none;
}
.sidebar-search:focus { border-color: #b9a78a; box-shadow: 0 0 0 3px rgba(105,84,53,.08); }
.sidebar-search-clear {
  position: absolute;
  right: 19px;
  top: 15px;
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #9a8f80;
  cursor: pointer;
}
.sidebar-view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 12px 9px;
}
.sidebar-view-btn {
  height: 32px;
  border: 1px solid var(--line, #e7dfd2);
  border-radius: 10px;
  background: rgba(255,255,255,.55);
  color: #7d7265;
  cursor: pointer;
}
.sidebar-view-btn.active {
  background: #e9dfd0;
  color: #55442e;
  border-color: rgba(85,68,46,.22);
}
.conversation-search-snippet {
  display: block;
  margin-top: 3px;
  color: #9a8f80;
  font-size: 10.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.favorite-count {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eee3d1;
  color: #6b5638;
  font-size: 10px;
}
.msg-action-btn.favorite-active {
  background: #eee2cf;
  border-color: rgba(104,80,45,.28);
  color: #654c2b;
}
.favorite-marker {
  margin-left: 6px;
  color: #846737;
  font-size: 12px;
}
.settings-v6-shell {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.settings-v6-nav {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-v6-nav button {
  width: 100%;
  min-height: 39px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #7e7366;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}
.settings-v6-nav button.active {
  background: #eee4d5;
  border-color: rgba(89,70,43,.12);
  color: #5d4930;
}
.settings-v6-content { min-width: 0; }
.settings-v6-panel { display: none; }
.settings-v6-panel.active { display: block; }
.settings-v6-panel > .setting-section-title:first-child { margin-top: 0; }
.settings-v6-panel .v6-panel-title {
  font-size: 18px;
  color: #453a2e;
  margin: 2px 0 13px;
}
.v6-empty-state {
  padding: 18px 12px;
  color: #9a8f80;
  font-size: 12px;
  text-align: center;
}
@media (max-width: 900px) {
  .settings-v6-shell { display: block; }
  .settings-v6-nav {
    position: sticky;
    top: 70px;
    z-index: 3;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 0;
    background: var(--surface, #f7f2ea);
  }
  .settings-v6-nav button { width: auto; min-width: max-content; text-align: center; }
}


/* ===== Kli v6.0.1 · 数据与用量整理 ===== */
.data-management-box,

.data-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 14px;
  background: #f3ecdf;
  margin-bottom: 14px;
}
.data-status-card span {
  color: #807363;
  font-size: 13px;
}
.data-status-card b {
  color: #55442e;
  font-size: 14px;
}
.data-action-group {
  padding: 13px 0;
  border-top: 1px solid rgba(105,84,53,.10);
}
.data-action-title {
  margin-bottom: 9px;
  color: #5e4c34;
  font-size: 13px;
  font-weight: 700;
}
.data-action-group .btn,
.usage-actions .btn {
  margin: 0 7px 7px 0;
}
.usage-box-v6 {
  padding: 16px;
}
.usage-primary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px;
  margin-bottom: 12px;
  border-radius: 15px;
  background: #f2eadc;
}
.usage-primary span {
  color: #776a5b;
  font-size: 13px;
}
.usage-primary b {
  color: #44372a;
  font-size: 28px;
  line-height: 1;
}
.usage-grid-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.usage-details {
  margin-top: 12px;
  border-top: 1px solid rgba(105,84,53,.10);
  border-bottom: 1px solid rgba(105,84,53,.10);
  padding: 11px 0;
}
.usage-details summary {
  cursor: pointer;
  color: #6e604f;
  font-size: 13px;
}
.usage-details[open] summary {
  margin-bottom: 9px;
}
.usage-actions {
  margin-top: 13px;
}


@media (max-width: 700px) {
  .usage-grid-compact { grid-template-columns: 1fr; }



/* ===== Kli v6.0.2 · 搜索、对话收藏与同步修正 ===== */
.conversation-favorite-btn {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #a99d8d;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.conversation-favorite-btn:hover {
  background: rgba(103,82,50,.08);
}
.conversation-favorite-btn.active {
  color: #775b2d;
  background: #eee2cf;
}
.conversation-item.is-favorite .conversation-title::after {
  content: "★";
  margin-left: 5px;
  color: #846737;
  font-size: 10px;
}
.memory-search-results {
  margin: 0 12px 8px;
  border: 1px solid var(--line, #e7dfd2);
  border-radius: 12px;
  background: rgba(255,255,255,.66);
  overflow: hidden;
}
.memory-search-heading {
  padding: 8px 10px 6px;
  color: #806f5c;
  font-size: 11px;
  font-weight: 700;
}
.memory-search-item {
  display: block;
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(105,84,53,.08);
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}
.memory-search-item:hover {
  background: rgba(103,82,50,.05);
}
.memory-search-item b {
  display: block;
  color: #5d4c36;
  font-size: 11px;
  margin-bottom: 2px;
}
.memory-search-item span {
  display: block;
  color: #8f8374;
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cloud-sync-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
}

/* ===== Kli v7.0 Alpha.1 · 搜索结果定位反馈 ===== */
.msg-wrapper.search-jump-target .msg {
  animation: kli-message-search-jump 2.35s ease;
}
.memory-record-item.search-jump-target {
  animation: kli-memory-search-jump 2.35s ease;
}
@keyframes kli-message-search-jump {
  0%, 22% {
    box-shadow: 0 0 0 4px rgba(139, 105, 56, .34), 0 14px 34px rgba(70, 52, 28, .16);
    transform: translateY(-2px);
  }
  100% {
    box-shadow: 0 8px 22px rgba(64, 50, 31, .055);
    transform: translateY(0);
  }
}
@keyframes kli-memory-search-jump {
  0%, 22% {
    box-shadow: 0 0 0 4px rgba(139, 105, 56, .28), 0 12px 28px rgba(70, 52, 28, .12);
    background: #fff8eb;
  }
  100% {
    box-shadow: none;
    background: inherit;
  }
}


/* v7.0 alpha：一键回到对话最底端 */
.scroll-bottom-btn {
  position: fixed;
  right: 28px;
  bottom: 96px;
  z-index: 48;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(102,83,52,.18);
  border-radius: 50%;
  background: rgba(255,253,250,.94);
  color: #5a4a30;
  box-shadow: 0 12px 30px rgba(58,44,26,.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px) scale(.94);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease, background .18s ease;
}
.scroll-bottom-btn.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.scroll-bottom-btn:hover { background: #fff; }
.scroll-bottom-btn:active { transform: translateY(1px) scale(.96); }
.scroll-bottom-btn:focus-visible { outline: 2px solid rgba(102,83,52,.42); outline-offset: 3px; }
.scroll-bottom-btn span { transform: translateY(-1px); }

@media (max-width: 900px) {
  .scroll-bottom-btn {
    right: 15px;
    width: 42px;
    height: 42px;
    font-size: 22px;
  }
}


/* ===== Kli v7.0 Alpha 4 · 设置自动保存与用量入口 ===== */
.settings-save-strip {
  position: sticky;
  top: 74px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line, rgba(102,83,52,.14));
  border-radius: 14px;
  background: rgba(255,253,250,.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 24px rgba(64,50,31,.06);
}
.settings-save-strip span {
  min-width: 0;
  color: var(--muted, #8b8173);
  font-size: 12px;
  line-height: 1.4;
}
.settings-save-strip span[data-state="saving"] { color: #9a6a20; }
.settings-save-strip span[data-state="saved"] { color: #3f6b43; }
.settings-save-strip .mini-btn { flex: 0 0 auto; min-height: 32px; padding: 6px 12px; }
@media (max-width: 900px) {
  .settings-save-strip { top: 67px; margin-bottom: 10px; padding: 9px 10px; }
  .settings-save-strip .mini-btn { font-size: 11px; padding: 6px 10px; }
}


/* ===== Kli v7.0 Alpha 5 · 数据管理与费用卡片修正 ===== */
.data-management-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  background: transparent;
  margin: 0;
}
.data-status-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid rgba(105,84,53,.12);
  border-radius: 16px;
  background: #f3ecdf;
}
.data-status-card span,
.data-status-card b {
  display: block;
  min-width: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
  writing-mode: horizontal-tb;
}
.data-status-card b { text-align: right; }
.data-action-group {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 9px;
  min-width: 0;
  padding: 15px;
  border: 1px solid rgba(105,84,53,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.68);
}
.data-action-title {
  margin: 0 0 2px;
  font-size: 14px;
}
.data-action-group .btn {
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 9px 12px;
  border-radius: 13px;
  white-space: normal;
  line-height: 1.35;
}
.data-management-box > .hint {
  grid-column: 1 / -1;
  margin: 0;
  padding: 2px 2px 0;
}
.overview-cost-item,
.overview-cost-item span,
.overview-cost-item b {
  text-align: center;
}
.overview-cost-item b { display: block; width: 100%; }
.usage-primary {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 7px;
}
.usage-primary span,
.usage-primary b { width: 100%; text-align: center; }
@media (max-width: 700px) {
  .data-management-box { grid-template-columns: 1fr; }
  .data-status-card { grid-column: 1; }
  .data-management-box > .hint { grid-column: 1; }
  .data-status-card { align-items: flex-start; }
  .data-status-card b { text-align: right; }
}

/* ===== Kli v7.0 Beta 1: Environment / Profile / Memory control ===== */
.profile-box {
  margin: 10px 0 16px;
  padding: 14px;
  border: 1px solid rgba(70,60,45,.13);
  border-radius: 16px;
  background: rgba(255,255,255,.52);
}
.profile-box-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}
.profile-box-head b { display:block; margin-top:3px; font-size:14px; }
.profile-grid {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.profile-grid label { min-width:0; }
.profile-grid input { width:100%; box-sizing:border-box; margin-top:5px; }
.profile-meta-row {
  display:flex;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  margin:8px 0 10px;
  font-size:12px;
  opacity:.72;
}
.memory-record-item.disabled { opacity:.65; background:rgba(235,232,225,.65); }
.memory-record-state { margin-left:auto; font-size:12px; opacity:.7; }
.memory-record-options { margin-top:8px; font-size:12px; opacity:.82; }
.memory-record-options label { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.memory-record-options input { max-width:170px; }
.memory-expiry-input { min-width:145px; }
.memory-history-box { margin-top:12px; border-top:1px solid rgba(70,60,45,.1); padding-top:10px; }
.memory-history-box summary { cursor:pointer; font-weight:650; }
.memory-history-list { display:flex; flex-direction:column; gap:8px; margin-top:9px; max-height:320px; overflow:auto; }
.memory-history-item { border:1px solid rgba(70,60,45,.12); border-radius:11px; padding:9px; background:rgba(255,255,255,.45); }
.memory-history-item > div { display:flex; justify-content:space-between; gap:8px; font-size:12px; }
.memory-history-item p { margin:7px 0; white-space:pre-wrap; word-break:break-word; }
.memory-history-item .mini-btn { margin-left:auto; display:block; }
@media(max-width:700px) {
  .profile-grid { grid-template-columns:1fr; }
  .memory-add-row { grid-template-columns:1fr 1fr; }
  .memory-expiry-input { grid-column:1/-1; }
  .memory-record-options label { align-items:flex-start; flex-direction:column; }
  .memory-record-options input { width:100%; max-width:none; }
}

/* Generated file cards */
.file-card.generated-file-card {
  min-width: min(360px, 100%);
  padding: 10px 12px;
  gap: 10px;
  background: #fbfaf7;
  border-color: #ddd4c3;
}
.file-card-icon { flex: 0 0 auto; font-size: 22px; line-height: 1; }
.file-card-info { flex: 1 1 auto; min-width: 0; }
.file-card-name { font-weight: 600; color: #4e402b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-download-btn {
  flex: 0 0 auto;
  border: 1px solid #cfc3ad;
  border-radius: 8px;
  background: #fff;
  color: #5a4a30;
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
}
.file-download-btn:hover { background: #f1ece3; }


/* User message editing and collapsible memory */
.message-edit-box { width:min(760px,92%); margin:6px 0 2px; padding:12px; border:1px solid rgba(105,86,56,.18); border-radius:14px; background:rgba(255,255,255,.78); box-sizing:border-box; }
.message-edit-textarea { width:100%; min-height:112px; max-height:46vh; resize:vertical; padding:12px; border:1px solid rgba(105,86,56,.24); border-radius:10px; background:#fff; color:inherit; font-size:15px; line-height:1.55; outline:none; box-sizing:border-box; }
.message-edit-textarea:focus { border-color:rgba(105,86,56,.55); box-shadow:0 0 0 3px rgba(105,86,56,.08); }
.message-edit-note { margin-top:8px; font-size:12px; line-height:1.5; color:#7c7468; }
.message-edit-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:10px; }
.message-edit-actions .msg-action-btn.primary { background:#6b5a40; color:#fff; border:1px solid #6b5a40; border-radius:8px; padding:6px 12px; }
.memory-manager-details { padding-top:0; }
.memory-manager-details > summary { list-style:none; cursor:pointer; display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 2px; margin:0; user-select:none; }
.memory-manager-details > summary::-webkit-details-marker { display:none; }
.memory-manager-details > summary::before { content:'▶'; display:inline-block; font-size:11px; margin-right:8px; transition:transform .18s ease; color:#6b5a40; }
.memory-manager-details[open] > summary::before { transform:rotate(90deg); }
.memory-manager-details > summary > span:first-child { flex:1 1 auto; }
.memory-collapse-hint { flex:0 0 auto; font-size:11px; font-weight:500; opacity:.55; }
.memory-manager-body { padding-top:2px; }
.memory-record-list { max-height:none; overflow:visible; }
@media(max-width:700px){ .message-edit-box{width:100%}.memory-collapse-hint{display:none} }

/* Fixed sidebar, persistent files, and file search */
.sidebar {
  width: 286px;
  min-width: 286px;
  max-width: 286px;
  flex: 0 0 286px;
  overflow-x: hidden;
}
.sidebar-search-wrap,
.sidebar-view-tabs,
.memory-search-results,
.conversation-list {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.conversation-list {
  overflow-x: hidden;
}
.conversation-item {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.conversation-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.conversation-title {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.conversation-actions {
  width: 89px;
  min-width: 89px;
  max-width: 89px;
  justify-content: flex-end;
  margin-left: auto;
  overflow: visible;
}
.sidebar-view-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.file-browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 10px;
  color: #8b7d6d;
  font-size: 11px;
}
.file-browser-refresh {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255,255,255,.72);
  color: #6b5a41;
  cursor: pointer;
}
.sidebar-file-item {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 7px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: rgba(255,255,255,.45);
  color: #5a4a30;
  cursor: pointer;
  overflow: hidden;
}
.sidebar-file-item:hover,
.sidebar-file-item:focus-visible {
  background: rgba(255,255,255,.9);
  border-color: rgba(102,83,52,.12);
  outline: none;
}
.sidebar-file-icon {
  flex: 0 0 auto;
  font-size: 19px;
}
.sidebar-file-info {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.sidebar-file-info b,
.sidebar-file-info span {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sidebar-file-info b {
  font-size: 12px;
  font-weight: 650;
}
.sidebar-file-info span {
  margin-top: 3px;
  color: #9a8f80;
  font-size: 10px;
}
.sidebar-file-download {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 1px solid rgba(102,83,52,.14);
  border-radius: 10px;
  background: #fff;
  color: #6b5638;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}
.sidebar-file-download:hover {
  background: #eee2cf;
}
@media (max-width: 900px) {
  .sidebar {
    width: min(86vw, 320px);
    min-width: 0;
    max-width: 320px;
    flex-basis: auto;
  }
}


/* Separate collapsible user and Claude profiles */
.profile-details {
  margin: 10px 0 16px;
  border: 1px solid rgba(70,60,45,.13);
  border-radius: 16px;
  background: rgba(255,255,255,.52);
  overflow: hidden;
}
.profile-box.profile-details { padding: 0; }
.profile-details-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  background: rgba(239,230,216,.58);
}
.profile-details-summary::-webkit-details-marker { display: none; }
.profile-details-summary > div { min-width: 0; }
.profile-details-summary b { display: block; margin-top: 3px; font-size: 15px; }
.profile-details-summary small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.profile-details-summary::after {
  content: '›';
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1;
  color: #7f6c4c;
  transform: rotate(90deg);
  transition: transform .18s ease;
}
.profile-details:not([open]) > .profile-details-summary::after { transform: rotate(0deg); }
.profile-details-body { padding: 14px 16px 16px; }
.profile-details-state { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.claude-profile-details { background: rgba(252,248,241,.78); }
.user-profile-details { background: rgba(255,255,255,.58); }
@media(max-width:700px) {
  .profile-details-summary { padding: 12px 13px; }
  .profile-details-body { padding: 12px 13px 14px; }
  .profile-details-state { display: none; }
}

/* Edge, proactive chat, and notification UI */
.edge-function-status {
  margin: 6px 0 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.kli-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  cursor: pointer;
}
.kli-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.kli-switch span {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(120,110,96,.22);
  position: relative;
  transition: .18s ease;
}
.kli-switch span::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(50,40,28,.18);
  transition: .18s ease;
}
.kli-switch input:checked + span { background: var(--ink); }
.kli-switch input:checked + span::after { transform: translateX(18px); }
.switch-line { min-height: 44px; }
.proactive-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.proactive-option-grid label,
.compact-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
}
.proactive-option-grid input,
.compact-check input { width: auto; }
.inline-number-unit {
  display: grid;
  grid-template-columns: minmax(0,1fr) 92px;
  gap: 8px;
}
.controls-disabled {
  opacity: .48;
  transition: opacity .18s ease;
}
.kli-inapp-notification {
  position: fixed;
  z-index: 120;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) 20px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.96);
  color: var(--ink);
  box-shadow: 0 14px 40px rgba(50,40,28,.18);
  text-align: left;
  cursor: pointer;
}
.kli-inapp-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}
.kli-inapp-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.kli-inapp-copy b,
.kli-inapp-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kli-inapp-copy small { color: var(--muted); }
.kli-inapp-close { color: var(--muted); font-size: 20px; }
@media (max-width: 640px) {
  .proactive-option-grid { grid-template-columns: 1fr; }
  .kli-inapp-notification { left: 12px; right: 12px; width: auto; }
}

/* Prevent iOS Safari zoom while editing settings fields. */
@media (max-width: 900px) {
  .settings-panel input,
  .settings-panel textarea,
  .settings-panel select,
  .profile-grid input,
  .memory-input,
  .memory-select {
    font-size: 16px;
  }
}

/* Collapsible model and cost settings */
.model-settings-details { margin-top: 12px; }
.model-settings-details > .profile-details-summary { background: rgba(239,230,216,.58); }
.model-settings-details:not([open]) { margin-bottom: 16px; }

/* Location status */
.location-action-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.setting-inline-status { font-size:13px; line-height:1.5; color:var(--muted, #777); }
.legacy-location-fields { display:none !important; }

/* Beta 1.6.4: cross-device synchronization, auth recovery, and device-level location */
.account-badge{font-size:12px;max-width:180px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted,#6f6a63)}
.header-btn.compact{padding:6px 9px;font-size:12px}
.auth-overlay{position:fixed;inset:0;z-index:9998;display:none;align-items:center;justify-content:center;padding:20px;background:rgba(244,239,231,.88);backdrop-filter:blur(14px)}
.auth-overlay.show{display:flex}
.auth-card{width:min(420px,100%);background:#fff;border:1px solid rgba(45,40,34,.12);border-radius:20px;padding:24px;box-shadow:0 22px 70px rgba(45,40,34,.16)}
.auth-card [hidden]{display:none!important}
.auth-card h2{margin:5px 0 8px;font-size:21px}.auth-card p{margin:0 0 16px;color:#746d64;font-size:13px}
.auth-card label{display:block;margin:11px 0 6px;font-size:12px;color:#5f584f}.auth-card input{width:100%;box-sizing:border-box}
.auth-kicker{font-size:11px;letter-spacing:.14em;color:#8a8177}.auth-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:14px}.auth-actions button:last-child{grid-column:1/-1}
.auth-offline{width:100%;margin-top:9px;background:transparent;border:0;text-decoration:underline;color:#71695f}.auth-card .err{min-height:20px;margin-top:8px}
.legacy-claim-box{margin-top:12px;padding:12px;border:1px dashed rgba(45,40,34,.18);border-radius:12px}.inline-action-row{display:flex;gap:8px}.inline-action-row input{min-width:0;flex:1}
@media(max-width:760px){.account-badge{display:none}.auth-card{padding:20px}.inline-action-row{align-items:stretch}.inline-action-row button{white-space:nowrap}}

/* Beta 1.6.4: explicit login/sync controls and five-button mobile dock */
.environment-badge,
.last-sync {
  font-size: 11px;
  color: var(--muted, #6f6a63);
  white-space: nowrap;
}
.environment-badge {
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid rgba(105,86,56,.14);
  background: rgba(255,255,255,.7);
}
.sync-action { cursor: pointer; font: inherit; }
.sync-action.syncing { opacity: .72; }
.last-sync { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
.auth-card { position: relative; }
.auth-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #8b8175;
  font-size: 22px;
  cursor: pointer;
}
.auth-close:hover { background: rgba(105,86,56,.08); color: #5a4a30; }
.overview-item small { display:block; margin-top:4px; color:var(--muted,#7d756c); font-size:10px; }

@media (max-width:900px) {
  .mobile-dock { grid-template-columns:repeat(5,1fr); }
  .header-actions #signInBtn { display:block; padding:6px 8px; }
  .header-actions #syncRefreshBtn,
  .header-actions #signOutBtn,
  .header-actions .environment-badge,
  .header-actions .last-sync,
  .header-actions .sync-badge { display:none; }
}

/* Beta 1.6.7: account, conversation isolation, and compact settings IA */
.settings-section {
  margin: 10px 0;
  border: 1px solid rgba(77,65,49,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.62);
  overflow: hidden;
}
.settings-section > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px;
  cursor: pointer;
  user-select: none;
}
.settings-section > summary::-webkit-details-marker { display:none; }
.settings-section > summary b { display:block; font-size:15px; color:var(--text,#342f2a); }
.settings-section > summary small { display:block; margin-top:4px; color:var(--muted,#756f68); font-size:11px; line-height:1.4; }
.settings-section > summary > span { color:var(--muted,#756f68); font-size:11px; white-space:nowrap; }
.settings-section[open] > summary > span { font-size:0; }
.settings-section[open] > summary > span::after { content:'收起'; font-size:11px; }
.settings-section-body { padding: 0 16px 16px; }

.auth-card-v167 { max-height:min(720px,calc(100dvh - 32px)); overflow:auto; }
.auth-status-card { margin:10px 0; padding:11px 12px; border-radius:12px; background:rgba(180,131,62,.10); color:#70562f; font-size:13px; }
.auth-actions-primary { grid-template-columns:repeat(2,minmax(0,1fr)); }
.auth-actions-primary .ghost { background:rgba(248,244,237,.82); }
.auth-footnote { margin-top:12px; color:var(--muted,#756f68); font-size:11px; line-height:1.5; }

.account-card,.proactive-binding-card,.summary-card,.notification-account-card {
  margin-top:10px;
  padding:14px;
  border:1px solid rgba(77,65,49,.11);
  border-radius:14px;
  background:rgba(251,248,243,.82);
}
.account-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.account-grid > div,.data-status-card { min-width:0; padding:10px; border-radius:11px; background:rgba(255,255,255,.7); }
.account-grid span,.data-status-card span,.proactive-binding-status span { display:block; color:var(--muted,#756f68); font-size:10px; }
.account-grid b,.data-status-card b,.proactive-binding-status b { display:block; margin-top:4px; overflow:hidden; text-overflow:ellipsis; font-size:12px; }
.account-actions,.data-action-group,.admin-review-toolbar,.account-review-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.admin-review { margin-top:12px; border-top:1px solid rgba(77,65,49,.1); padding-top:10px; }
.account-review-list { display:grid; gap:8px; margin-top:10px; }
.account-review-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:11px; border:1px solid rgba(77,65,49,.10); border-radius:12px; background:rgba(255,255,255,.65); }
.account-review-info { min-width:0; }
.account-review-info b,.account-review-info span { display:block; overflow:hidden; text-overflow:ellipsis; }
.account-review-info span { margin-top:4px; color:var(--muted,#756f68); font-size:11px; }
.account-review-actions { margin-top:0; flex-shrink:0; }

.proactive-binding-card > label { margin-top:0; }
.proactive-binding-card .inline-action-row select { flex:1; min-width:0; }
.proactive-binding-status { display:grid; grid-template-columns:auto 1fr auto 1fr; gap:6px 10px; align-items:center; margin-top:12px; }
.proactive-history-list { display:grid; gap:8px; margin-top:10px; }
.proactive-history-item { padding:10px 11px; border-radius:11px; background:rgba(255,255,255,.68); }
.proactive-history-item b { margin-right:8px; }
.proactive-history-item span { color:var(--muted,#756f68); font-size:11px; }
.proactive-history-item p { margin:6px 0 0; font-size:12px; line-height:1.5; white-space:pre-wrap; }

.summary-card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.summary-card-head b,.summary-card-head small,.summary-card-head span { display:block; }
.summary-card-head small { margin-top:4px; color:var(--muted,#756f68); font-size:11px; }
.summary-preview { margin-top:12px; padding:12px; border-radius:12px; background:rgba(255,255,255,.7); white-space:pre-wrap; line-height:1.55; font-size:13px; }
.summary-editor-details { margin-top:10px; }
.summary-editor-details > summary { cursor:pointer; color:var(--muted,#756f68); font-size:12px; }
.summary-editor-details textarea { min-height:150px; margin-top:10px; }

.conversation-unread-count { min-width:18px; height:18px; padding:0 5px; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; background:#6b5942; color:#fff; font-size:10px; line-height:1; }

@media (max-width:760px) {
  .settings-section > summary { padding:14px 13px; }
  .settings-section-body { padding:0 13px 14px; }
  .account-grid { grid-template-columns:1fr; }
  .account-review-row { align-items:flex-start; flex-direction:column; }
  .proactive-binding-card .inline-action-row { flex-direction:column; }
  .proactive-binding-status { grid-template-columns:auto 1fr; }
  .auth-actions-primary { grid-template-columns:1fr; }
  .auth-actions-primary button { grid-column:auto !important; }
}

/* ===== Beta 1.6.7.8 · simplified profile and memory UI ===== */
.profile-textarea {
  width: 100%;
  min-height: 180px;
  box-sizing: border-box;
  margin-top: 6px;
  padding: 12px 13px;
  resize: vertical;
  border: 1px solid rgba(70,60,45,.16);
  border-radius: 12px;
  background: rgba(255,255,255,.82);
  color: inherit;
  font: inherit;
  line-height: 1.6;
}
.profile-meta-row-simple { justify-content: flex-end; }
.memory-simple-box {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line, rgba(102,83,52,.14));
  border-radius: 18px;
  background: rgba(255,255,255,.72);
}
.memory-simple-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.memory-simple-head b { display:block; margin-top:3px; color:var(--ink,#2e2922); font-size:14px; }
.memory-simple-head small { display:block; margin-top:3px; color:var(--muted); font-size:11px; }
.memory-add-simple {
  display: grid;
  grid-template-columns: 120px 120px minmax(0,1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}
.memory-record-actions-simple { gap: 8px; }
.memory-record-actions-simple .mini-btn { min-width: 64px; }
.memory-advanced-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(70,60,45,.10);
}
.memory-advanced-box > summary { cursor:pointer; color:var(--muted); font-size:12px; }
.memory-advanced-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.mini-btn.danger { color:#a24a45; border-color:rgba(162,74,69,.22); }
@media(max-width:700px) {
  .profile-textarea { min-height: 220px; }
  .memory-simple-box { padding:12px; border-radius:15px; }
  .memory-add-simple { grid-template-columns:1fr 1fr; }
  .memory-add-simple .memory-input { grid-column:1/-1; }
  .memory-add-simple .mini-btn { grid-column:1/-1; }
  .memory-record-top { align-items:stretch; }
  .memory-record-top .memory-select { flex:1 1 calc(50% - 4px); min-width:0; }
  .memory-record-state { width:100%; margin-left:0; }
}
