/* Claude 客户端风格：暖白底、陶土橙、衬线阅读 */
:root {
  color-scheme: light;
  --paper: #FAF9F5;      /* 主背景：Claude 暖白 */
  --panel: #F5F4ED;      /* 侧栏 */
  --card: #FFFFFF;
  --ink: #141413;        /* 正文 */
  --ink-2: #5E5D59;      /* 次要文字 */
  --ink-3: #8F8D86;      /* 弱文字 */
  --line: #E8E6DC;
  --moss: #C6613F;       /* 主色：Claude 陶土橙（按钮） */
  --rose: #D97757;       /* 星芒图标色 */
  --moss-2: #B0532F;
  --moss-wash: #F0EEE6;  /* 用户气泡 */
  --danger: #B3402A;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 20px;
  --sb-w: 288px;
  --read: 48rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  /* 回答正文：衬线（Claude 风格）；中文落到苹方 */
  --read-font: "Tiempos Text", "Iowan Old Style", "Charter", Georgia, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", serif;
  --serif: "Copernicus", "Tiempos Headline", "Iowan Old Style", Georgia, "Songti SC", "Noto Serif SC", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --spark: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2048%2048%27%3E%3Cpath%20d%3D%27M26.31%2024.00L25.26%203.00A1.26%201.26%200%200%201%2022.74%203.00L21.69%2024.00ZM25.64%2025.11L34.40%2010.51A1.08%201.08%200%200%201%2032.61%209.30L22.36%2022.89ZM25.32%2026.03L43.17%2013.12A1.32%201.32%200%200%201%2041.73%2010.91L22.68%2021.97ZM23.84%2025.86L39.35%2026.37A1.02%201.02%200%200%201%2039.53%2024.33L24.16%2022.14ZM22.97%2025.94L41.10%2034.45A1.20%201.20%200%200%201%2042.22%2032.33L25.03%2022.06ZM22.14%2024.95L31.16%2040.56A1.14%201.14%200%200%201%2033.19%2039.52L25.86%2023.05ZM21.58%2024.00L22.68%2046.50A1.32%201.32%200%200%201%2025.32%2046.50L26.42%2024.00ZM22.32%2023.18L16.07%2037.93A1.02%201.02%200%200%201%2017.90%2038.83L25.68%2024.82ZM22.92%2021.96L4.87%2032.75A1.26%201.26%200%200%201%206.05%2034.97L25.08%2026.04ZM23.90%2022.02L6.47%2023.84A1.08%201.08%200%200%201%206.58%2025.99L24.10%2025.98ZM25.23%2022.18L8.50%2012.10A1.20%201.20%200%200%201%207.16%2014.09L22.77%2025.82ZM25.56%2023.07L17.12%2010.63A0.99%200.99%200%200%201%2015.43%2011.65L22.44%2024.93ZM24%2016.8a7.2%207.2%200%201%200%200%2014.4a7.2%207.2%200%201%200%200-14.4Z%27/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink);
  background: var(--paper); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--moss); }
:focus-visible { outline: 2px solid var(--moss); outline-offset: 2px; border-radius: 6px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { display: flex; height: 100dvh; overflow: hidden; }
#scrim { display: none; }

/* ---------- 侧栏 ---------- */
#sidebar {
  width: var(--sb-w); flex: none; background: var(--panel); display: flex; flex-direction: column;
  border-right: 1px solid var(--line); padding: 12px 10px calc(10px + var(--safe-b));
  transition: margin-left .3s cubic-bezier(.32,.72,0,1), transform .3s cubic-bezier(.32,.72,0,1);
}
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; color: var(--rose); stroke: none; }
.new-chat {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--radius-s);
  color: var(--moss-2); font-weight: 500; font-size: 15px;
}
.new-chat .ic { width: 26px; height: 26px; border-radius: 50%; background: var(--moss); color: #fff; display: grid; place-items: center; transition: transform .15s; }
.new-chat .ic svg { width: 16px; height: 16px; stroke-width: 2.4; }
.new-chat:hover { background: rgba(20,20,19,.05); }
.new-chat:hover .ic { transform: rotate(90deg); }
.sb-nav { display: flex; flex-direction: column; margin: 10px 0 6px; }
.sb-nav a { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: var(--radius-s); color: var(--ink-2); text-decoration: none; }
.sb-nav a:hover { background: rgba(20,20,19,.06); color: var(--ink); }
.sb-nav a.active { background: rgba(20,20,19,.08); color: var(--ink); }
.sb-search { padding: 4px 2px 8px; }
.sb-search input {
  width: 100%; padding: 7px 10px; border-radius: var(--radius-s); border: 1px solid transparent;
  background: rgba(255,255,255,.55); outline: none; font-size: 14px;
}
.sb-search input:focus { border-color: var(--line); background: #fff; }
.sb-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; -webkit-overflow-scrolling: touch; }
.sb-group { font-size: 12px; color: var(--ink-3); padding: 12px 12px 4px; }
.conv-item {
  display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; border-radius: var(--radius-s);
  color: var(--ink); text-decoration: none; font-size: 14px; position: relative;
}
.conv-item:hover { background: rgba(20,20,19,.06); }
.conv-item.active { background: rgba(20,20,19,.1); }
.conv-item .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-item .star { color: var(--moss); width: 14px; height: 14px; }
.conv-item .more { opacity: 0; color: var(--ink-3); padding: 2px; border-radius: 6px; }
.conv-item:hover .more, .conv-item.active .more, .conv-item .more:focus-visible { opacity: 1; }
.conv-item .more:hover { color: var(--ink); background: rgba(20,20,19,.08); }
.sb-empty { color: var(--ink-3); font-size: 13px; padding: 14px 12px; }

/* ---------- 主区域 ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
#topbar { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 14px; flex: none; }
.top-title { flex: 1; min-width: 0; font-size: 15px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; overflow: hidden; }
.top-title .crumb { color: var(--ink-3); text-decoration: none; white-space: nowrap; }
.top-title .crumb:hover { color: var(--moss); }
.top-title .name { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 3px 6px; border-radius: 6px; }
.top-title button.name:hover { background: rgba(20,20,19,.06); }
.top-actions { display: flex; gap: 4px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-s); color: var(--ink-2); }
.icon-btn:hover { background: rgba(20,20,19,.07); color: var(--ink); }
#sbOpen { display: none; }
body.sb-collapsed #sidebar { margin-left: calc(-1 * var(--sb-w)); }
body.sb-collapsed #sbOpen { display: inline-grid; }
#view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* ---------- 聊天 ---------- */
.chat-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.thread { max-width: var(--read); margin: 0 auto; padding: 12px 20px 32px; }
.msg { margin: 0 0 26px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  background: var(--moss-wash); padding: 10px 16px; border-radius: 16px;
  max-width: 85%; white-space: pre-wrap; word-break: break-word;
}
.msg .attach-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.msg .attach-row img { max-width: 220px; max-height: 220px; border-radius: var(--radius-m); border: 1px solid var(--line); cursor: zoom-in; object-fit: cover; }
.doc-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-m); background: var(--card); font-size: 13px; max-width: 260px;
}
.doc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-chip small { color: var(--ink-3); }
.msg-tools { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools, .msg.last .msg-tools { opacity: 1; }
.msg-tools button { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 6px; color: var(--ink-3); font-size: 12px; }
.msg-tools button:hover { color: var(--ink); background: rgba(20,20,19,.06); }
.msg-tools svg { width: 16px; height: 16px; }
.msg-tools .meta { color: var(--ink-3); font-size: 12px; padding: 4px 6px; }
.msg.assistant .body { font-family: var(--read-font); font-size: 16.5px; line-height: 1.75; word-break: break-word; color: #1F1E1D; }
.msg.assistant .body code, .msg.assistant .body pre { font-family: var(--mono); }
.msg.assistant .body .thinking, .msg.assistant .body .code-head, .msg.assistant .body .err { font-family: var(--font); }
.msg .err { margin-top: 8px; padding: 10px 14px; border-radius: var(--radius-m); background: #F7E4DE; color: var(--danger); font-size: 14px; white-space: pre-wrap; }
.msg .notice { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }

.thinking { margin: 0 0 12px; border-left: 2px solid var(--line); padding-left: 12px; }
.thinking summary { cursor: pointer; color: var(--ink-3); font-size: 14px; list-style: none; display: flex; align-items: center; gap: 6px; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary svg { width: 14px; height: 14px; transition: transform .15s; }
.thinking[open] summary svg { transform: rotate(90deg); }
.thinking .tbody { color: var(--ink-2); font-size: 14px; white-space: pre-wrap; margin-top: 6px; max-height: 360px; overflow-y: auto; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--moss); margin-left: 4px; vertical-align: middle; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.waiting { display: flex; gap: 5px; padding: 6px 0; }
.waiting i { width: 7px; height: 7px; border-radius: 50%; background: var(--moss); animation: pulse 1.1s infinite; }
.waiting i:nth-child(2) { animation-delay: .15s; } .waiting i:nth-child(3) { animation-delay: .3s; }

/* Markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--read-font); line-height: 1.35; margin: 1.3em 0 .5em; font-weight: 600; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.4em; margin: 0 0 .85em; }
.md li { margin: .2em 0; }
.md li > p { margin: 0 0 .3em; }
.md blockquote { margin: 0 0 .85em; padding: 2px 14px; border-left: 3px solid var(--moss); color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.md code { font-family: var(--mono); font-size: .88em; background: rgba(20,20,19,.07); padding: .1em .35em; border-radius: 5px; }
.md pre { margin: 0 0 1em; background: #FFFFFF; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.md pre .code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; font-size: 12px; color: var(--ink-3); border-bottom: 1px solid var(--line); font-family: var(--font); }
.md pre .code-head button { color: var(--ink-3); font-size: 12px; padding: 2px 6px; border-radius: 5px; }
.md pre .code-head button:hover { color: var(--ink); background: rgba(20,20,19,.06); }
.md pre code { display: block; padding: 12px 14px; overflow-x: auto; background: none; font-size: 13.5px; line-height: 1.6; }
.md .table-wrap { overflow-x: auto; margin: 0 0 1em; }
.md table { border-collapse: collapse; font-size: .93em; min-width: 50%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--panel); font-weight: 600; }
.md img { max-width: 100%; }
.md a { word-break: break-all; }

/* ---------- 输入框 ---------- */
.composer-wrap { flex: none; padding: 0 16px calc(14px + var(--safe-b)); }
.composer {
  max-width: var(--read); margin: 0 auto; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-l); box-shadow: 0 .25rem 1.25rem rgba(20,20,19,.035), 0 0 0 .5px rgba(20,20,19,.06);
  padding: 12px 10px 8px 16px; transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: #D9D6CB; box-shadow: 0 .25rem 1.25rem rgba(20,20,19,.06), 0 0 0 .5px rgba(20,20,19,.1); }
.composer.drag { border-color: var(--moss); background: #FBF4EF; }
.composer textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent; font-size: 16px;
  line-height: 1.55; max-height: 40vh; min-height: 26px; padding: 4px 0; display: block;
}
.composer textarea::placeholder { color: var(--ink-3); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.att { position: relative; }
.att img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); display: block; }
.att .doc-chip { height: 64px; }
.att .x {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink);
  color: #fff; display: grid; place-items: center; font-size: 13px; line-height: 1;
}
.att.loading { opacity: .5; }
.comp-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.comp-row .grow { flex: 1; }
.model-pick {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--ink-2); font-size: 13px;
  padding: 6px 22px 6px 8px; border-radius: var(--radius-s); max-width: 200px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238D8F84' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center; background-size: 14px;
}
.model-pick:hover { background-color: rgba(20,20,19,.06); }
.send-btn { width: 34px; height: 34px; border-radius: 9px; background: var(--moss); color: #fff; display: grid; place-items: center; }
.send-btn:hover { background: var(--moss-2); }
.send-btn:disabled { background: #E8B9A6; cursor: default; }
.send-btn.stop { background: var(--ink); }
.send-btn svg { stroke-width: 2.2; }
.comp-hint { max-width: var(--read); margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--ink-3); }

/* ---------- 首页 ---------- */
.home { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 0 8vh; overflow-y: auto; }
.home .composer-wrap { padding-bottom: 0; }
.greet { max-width: var(--read); margin: 0 auto 28px; padding: 0 20px; width: 100%; text-align: center; }
.greet h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(30px, 4.4vw, 42px); line-height: 1.25; margin: 0; letter-spacing: -.01em; color: #3D3D3A; }
.greet h1 .leaf { display: inline-block; width: 1.15em; height: 1.15em; color: var(--rose); vertical-align: -.2em; margin-right: .3em; stroke: none; }
.greet p { color: var(--ink-3); margin: 10px 0 0; font-size: 15px; }
.home-proj { max-width: var(--read); margin: 14px auto 0; padding: 0 20px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); font-size: 13px; }
.pill:hover { border-color: var(--moss); color: var(--moss); }
.pill.on { background: #F6E8E1; border-color: var(--moss); color: var(--moss-2); }
.pill svg { width: 15px; height: 15px; }
/* ---------- 页面（项目 / 设置） ---------- */
.page { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page-in { max-width: 60rem; margin: 0 auto; padding: 18px 24px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--serif); font-weight: 400; font-size: 32px; margin: 0; line-height: 1.2; }
.page-head p { margin: 6px 0 0; color: var(--ink-3); font-size: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--card); font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: #CFCCC1; }
.btn.primary { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.primary:hover { background: var(--moss-2); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(20,20,19,.06); }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .55; cursor: default; }

.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.proj-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; min-height: 132px; border-radius: var(--radius-m);
  background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.proj-card:hover { border-color: var(--moss); }
.proj-card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.proj-card p { margin: 0; color: var(--ink-2); font-size: 14px; flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.proj-card small { color: var(--ink-3); font-size: 12px; }
.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--radius-m); }
.empty h3 { color: var(--ink); font-weight: 500; margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 16px; font-size: 14px; }

.proj-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.proj-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; }
.box-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.box-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.box .muted { color: var(--ink-3); font-size: 13px; margin: 0; white-space: pre-wrap; max-height: 160px; overflow: hidden; }
.file-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.file-row:first-of-type { border-top: 0; }
.file-row .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.file-row .n:hover { color: var(--moss); }
.file-row small { color: var(--ink-3); }
.file-row button { color: var(--ink-3); padding: 2px; border-radius: 5px; }
.file-row button:hover { color: var(--danger); }
.file-row svg { width: 15px; height: 15px; }
.cap { height: 4px; background: var(--panel); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.cap i { display: block; height: 100%; background: var(--moss); }
.cap-t { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.proj-convs { margin-top: 22px; }
.proj-convs h2 { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px; }
.pc-row { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.pc-row:hover .t { color: var(--moss); }
.pc-row .t { font-size: 15px; }
.pc-row small { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.proj-home .composer-wrap { padding: 0; }

/* 表单 */
.field { margin: 0 0 18px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .help { font-size: 13px; color: var(--ink-3); margin: 0 0 8px; font-weight: 400; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card);
  padding: 9px 12px; outline: none; font-size: 15px;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--moss); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .input { flex: 1; min-width: 180px; }
.set-sec { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px 22px 4px; margin-bottom: 18px; max-width: 46rem; }
.set-sec h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--panel); font-size: 13px; font-family: var(--mono); }
.tag.def { background: #F6E8E1; color: var(--moss-2); }
.tag button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); }
.tag button:hover { background: rgba(20,20,19,.1); color: var(--ink); }
.tag button svg { width: 12px; height: 12px; }
.seg { display: inline-flex; background: var(--panel); border-radius: var(--radius-s); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 6px 12px; border-radius: 6px; font-size: 14px; color: var(--ink-2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(20,20,19,.08); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 400 !important; }
.check input { width: 18px; height: 18px; accent-color: var(--moss); }
.status-ok { color: var(--moss); font-size: 14px; }
.status-bad { color: var(--danger); font-size: 14px; }

/* ---------- 弹窗 / 菜单 / 提示 ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(620px, calc(100vw - 32px)); max-height: 88vh;
  background: var(--paper); color: var(--ink); box-shadow: 0 24px 60px rgba(20,20,19,.25);
}
dialog::backdrop { background: rgba(20,20,19,.32); }
.dlg { padding: 24px 24px 18px; display: flex; flex-direction: column; max-height: 88vh; }
.dlg h2 { margin: 0 0 16px; font-family: var(--serif); font-size: 22px; font-weight: 400; }
.dlg .dlg-body { overflow-y: auto; flex: 1; margin: 0 -6px; padding: 2px 6px; scrollbar-width: thin; }
.dlg .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg pre.preview { white-space: pre-wrap; font-size: 13px; background: var(--card); border: 1px solid var(--line); padding: 12px; border-radius: var(--radius-s); max-height: 60vh; overflow: auto; margin: 0; }
dialog.img-view { width: auto; max-width: 96vw; background: transparent; box-shadow: none; }
dialog.img-view img { max-width: 94vw; max-height: 90vh; border-radius: var(--radius-m); display: block; }

.menu {
  position: fixed; z-index: 50; min-width: 168px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: 0 10px 30px rgba(20,20,19,.14); padding: 5px;
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; font-size: 14px; text-align: left; }
.menu button:hover { background: var(--panel); }
.menu button.danger { color: var(--danger); }
.menu svg { width: 16px; height: 16px; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.drop-hint { position: absolute; inset: 0; background: rgba(217,119,87,.06); border: 2px dashed var(--moss); border-radius: var(--radius-l); display: grid; place-items: center; color: var(--moss-2); font-size: 18px; pointer-events: none; z-index: 30; margin: 8px; }

/* ---------- 响应式：iPad 竖屏 / 手机 ---------- */
@media (max-width: 900px) {
  .proj-layout { grid-template-columns: 1fr; }
  .proj-side { position: static; }
}
@media (max-width: 820px) {
  #sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; transform: translateX(-100%); box-shadow: none; width: min(300px, 86vw); }
  body.sb-open #sidebar { transform: none; box-shadow: 0 0 40px rgba(20,20,19,.2); }
  body.sb-collapsed #sidebar { margin-left: 0; }
  #scrim { display: block; position: fixed; inset: 0; background: rgba(20,20,19,.28); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .28s ease; -webkit-tap-highlight-color: transparent; }
  body.sb-open #scrim { opacity: 1; pointer-events: auto; }
  #sidebar { transition: transform .3s cubic-bezier(.32,.72,0,1), box-shadow .3s; }
  body.sb-dragging #sidebar, body.sb-dragging #scrim { transition: none; }
  body.sb-dragging #scrim { pointer-events: auto; }
  #sbOpen { display: inline-grid; }
  .msg-tools { opacity: 1; }
  .conv-item .more { opacity: 1; }
  .thread { padding: 8px 16px 24px; }
  .composer-wrap { padding: 0 10px calc(10px + var(--safe-b)); }
  .page-in { padding: 10px 16px 50px; }
  .page-head h1 { font-size: 25px; }
  .msg.user .bubble { max-width: 92%; }
  .comp-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 导入 md */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.label-row label { margin: 0; }
.link-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--moss-2); padding: 4px 8px; border-radius: 6px; }
.link-btn:hover { background: #F6E8E1; }
.link-btn svg { width: 15px; height: 15px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 8px; }
.pending-files .doc-chip { padding: 6px 6px 6px 10px; }
.pending-files .doc-chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); }
.pending-files .doc-chip button:hover { background: rgba(20,20,19,.08); color: var(--ink); }
.pending-files .doc-chip button svg { width: 12px; height: 12px; }
.drop-zone { border: 1px dashed var(--line); border-radius: var(--radius-m); padding: 14px; text-align: center; color: var(--ink-3); font-size: 13px; cursor: pointer; background: rgba(255,255,255,.5); }
.drop-zone:hover, .drop-zone.drag { border-color: var(--moss); color: var(--moss-2); background: #FBF4EF; }
.preview-md { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px 18px; font-family: var(--read-font); font-size: 15px; line-height: 1.7; }

/* Claude 细节 */
::selection { background: #F2DCD1; }
.cursor::after, .waiting i { background: var(--rose); }
.md blockquote { border-left-color: var(--line); }
.sb-nav a.active, .conv-item.active { background: rgba(20,20,19,.07); }
.proj-card:hover { border-color: #D9D6CB; box-shadow: 0 2px 10px rgba(20,20,19,.04); }

/* 侧栏：品牌、新对话、底部用户栏 */
.brand { font-family: var(--serif); font-size: 21px; font-weight: 500; letter-spacing: -.02em; color: #141413; }
.brand-mark { width: 22px; height: 22px; color: var(--rose); stroke: none; }
.new-chat { color: var(--ink); font-weight: 500; font-size: 15px; padding: 7px 8px; }
.new-chat .ic { width: 26px; height: 26px; background: var(--moss); }
.new-chat:hover { background: rgba(20,20,19,.05); }
.new-chat:hover .ic { transform: none; }
.sb-nav a { font-size: 15px; padding: 7px 10px; color: var(--ink); }
.sb-nav a svg { color: var(--ink-2); }
.sb-group { font-size: 12.5px; padding: 14px 10px 4px; color: var(--ink-3); }
.conv-item { padding: 7px 8px 7px 10px; font-size: 14.5px; }
.sb-search input { background: transparent; border-color: var(--line); }
.sb-search input:focus { background: #fff; }
.sb-user {
  display: flex; align-items: center; gap: 10px; margin: 8px -2px 0; padding: 10px 8px; border-top: 1px solid var(--line);
  color: var(--ink); text-decoration: none; border-radius: 0; font-size: 14px;
}
.sb-user:hover .uname { color: var(--ink); }
.sb-user .avatar { width: 30px; height: 30px; border-radius: 50%; background: #3D3D3A; color: #FAF9F5; display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.sb-user .uname { flex: 1; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user svg { width: 18px; height: 18px; color: var(--ink-3); }
.sb-user.active { background: transparent; }
.sb-user.active .uname { color: var(--ink); font-weight: 500; }

/* 首页问候：Claude 式星芒 + 衬线大字 */
.greet h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(32px, 4.6vw, 44px); letter-spacing: -.02em; color: #3D3D3A; display: inline-flex; align-items: center; gap: .35em; }
.greet h1 .leaf { width: .95em; height: .95em; color: var(--rose); margin: 0; vertical-align: 0; }
.greet p { display: none; }
.greet .hint { display: block; color: var(--ink-3); margin: 12px 0 0; font-size: 14px; }

/* 输入框：Claude 式圆角卡片、底部工具行 */
.composer { border-radius: 20px; border: .5px solid #D9D6CB; box-shadow: 0 .25rem 1.25rem rgba(20,20,19,.035); padding: 14px 12px 10px 16px; }
.composer:focus-within { border-color: #C7C4B8; box-shadow: 0 .25rem 1.25rem rgba(20,20,19,.07); }
.comp-row { margin-top: 10px; }
.comp-row [data-attach] { width: 32px; height: 32px; border: .5px solid #D9D6CB; border-radius: 8px; color: var(--ink-2); }
.comp-row [data-attach] svg { width: 18px; height: 18px; }
.model-pick { font-size: 13.5px; color: var(--ink-2); }
.send-btn { width: 32px; height: 32px; border-radius: 8px; background: var(--moss); }
.send-btn:hover { background: var(--moss-2); }
.send-btn:disabled { background: #E3A68C; opacity: .55; }
.send-btn.stop { background: #141413; }
.comp-hint { font-size: 12px; }

/* 消息 */
.msg.user .bubble { background: var(--moss-wash); border-radius: 12px; padding: 10px 16px; font-size: 16px; }
.msg.assistant .body { font-size: 16.5px; line-height: 1.7; }
.msg-tools button { color: var(--ink-3); }
.waiting { gap: 0; padding: 4px 0; }
.waiting i { display: none; }
.waiting::before {
  content: ""; width: 26px; height: 26px; background: var(--rose);
  -webkit-mask: var(--spark) center / contain no-repeat; mask: var(--spark) center / contain no-repeat;
  animation: spin 3.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.md code { background: rgba(20,20,19,.05); color: #8A3B1E; }
.md pre code { color: inherit; }
.md pre { background: #FFFFFF; border-color: var(--line); }
.md th { background: #F5F4ED; }

/* 页面标题 */
.page-head h1 { font-family: var(--serif); font-weight: 400; letter-spacing: -.02em; }
.btn.primary { background: #141413; border-color: #141413; }
.btn.primary:hover { background: #3D3D3A; }
.new-chat .ic, .send-btn { background: var(--moss); }
.tag.def { background: #F6E8E1; color: var(--moss-2); }
.gen-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rose); flex: none; animation: pulse 1.2s ease-in-out infinite; }

.cursor::after {
  content: ""; display: block; width: 22px; height: 22px; margin: 10px 0 0; border-radius: 0; background: var(--rose);
  -webkit-mask: var(--spark) center / contain no-repeat; mask: var(--spark) center / contain no-repeat;
  animation: spin 3.2s linear infinite; vertical-align: 0;
}

/* 上下文用量 / 延续对话 */
.ctx-bar {
  max-width: var(--read); margin: 0 auto 8px; padding: 8px 10px 8px 14px; display: flex; align-items: center; gap: 12px;
  background: #F5F4ED; border: 1px solid var(--line); border-radius: 12px; font-size: 13.5px; color: var(--ink-2);
}
.ctx-bar span { flex: 1; }
.ctx-bar .btn { padding: 6px 12px; font-size: 13px; }
.ctx-bar.full { background: #FBF0EA; border-color: #EBCDBE; color: #7A3A22; }
.ctx-meter { width: 44px; height: 6px; border-radius: 3px; background: #E8E6DC; overflow: hidden; flex: none; }
.ctx-meter i { display: block; height: 100%; background: var(--rose); }
#ctxSlot { padding: 0 16px; }
.carry { margin: 0 0 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.carry summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none; font-size: 14px; color: var(--ink-2); }
.carry summary::-webkit-details-marker { display: none; }
.carry summary span { flex: 1; }
.carry summary svg { width: 16px; height: 16px; color: var(--ink-3); transition: transform .15s; }
.carry summary svg:last-child { margin-left: auto; }
.carry[open] summary svg:last-child { transform: rotate(90deg); }
.carry .md { padding: 4px 16px 14px; font-family: var(--read-font); font-size: 15px; line-height: 1.7; border-top: 1px solid var(--line); max-height: 50vh; overflow-y: auto; }
.carry a { color: var(--ink); }
.err.ctx-full { background: #FBF0EA; color: #7A3A22; }
.err.ctx-full .btn { margin-top: 10px; }
@media (max-width: 820px) {
  #ctxSlot { padding: 0 10px; }
  .ctx-bar { flex-wrap: wrap; }
  .ctx-bar span { flex-basis: calc(100% - 60px); }
  .ctx-bar .btn { margin-left: auto; }
}

/* 外面访问：登录页 */
.login { position: fixed; inset: 0; z-index: 200; background: var(--paper); display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.login-card .leaf { width: 40px; height: 40px; color: var(--rose); }
.login-card h1 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 4px 0 0; letter-spacing: -.02em; }
.login-card p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.6; }
.login-card .input { margin-top: 8px; text-align: center; font-size: 16px; padding: 11px 12px; }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.login-card .lg-err { color: var(--danger); min-height: 1.4em; }
.remote-state { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; flex-wrap: wrap; }
.remote-state .dot { width: 8px; height: 8px; border-radius: 50%; background: #C9C6BB; }
.remote-state.on .dot { background: #4F9A5A; }
.remote-state .check { margin: 0; }
.remote-state .check input { margin: 0; }

/* 记忆 */
.mem-switches { display: flex; gap: 22px; flex-wrap: wrap; margin: 0 0 18px; }
.mem-add { display: flex; gap: 10px; }
.mem-add .input { flex: 1; }
.mem-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.mem-text { font-size: 15px; line-height: 1.6; word-break: break-word; }
.mem-meta { grid-column: 1; font-size: 12px; color: var(--ink-3); }
.mem-meta a { color: var(--ink-3); }
.mem-act { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; gap: 2px; opacity: .55; }
.mem-row:hover .mem-act, .mem-act:focus-within { opacity: 1; }
.mem-act .icon-btn { width: 32px; height: 32px; }
.mem-act svg { width: 17px; height: 17px; }
@media (max-width: 820px) { .mem-act { opacity: 1; } .mem-add { flex-wrap: wrap; } .mem-add .btn { margin-left: auto; } }
.mem-toast {
  position: fixed; left: 50%; top: 58px; transform: translate(-50%, -12px); opacity: 0; z-index: 90;
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px);
  padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(20,20,19,.08); color: var(--ink-2); font-size: 13.5px; text-decoration: none;
  transition: opacity .25s, transform .25s;
}
.mem-toast.show { opacity: 1; transform: translate(-50%, 0); }
.mem-toast svg { width: 16px; height: 16px; color: var(--rose); flex: none; }
.mem-toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 日期分隔线 + 消息时间 */
.day-sep { display: flex; align-items: center; gap: 12px; margin: 6px 0 22px; color: var(--ink-3); font-size: 12.5px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.day-sep span { white-space: nowrap; }
.msg.user .msg-tools .meta { order: -1; }
@media (max-width: 820px) {
  /* 手机上默认收起时间，点一下消息再显示，保持界面干净 */
  .msg .msg-tools .meta { display: none; }
  .msg.show-time .msg-tools .meta { display: inline; }
}
