:root {
  --bg: #ffffff; --bg-soft: #f7f7f8; --bg-hover: #ececef; --fg: #1b1c1f; --fg2: #6b6f76; --fg3: #9a9ea6;
  --line: #e5e7eb; --accent: #2f6fed; --accent-hover: #1f5bd6; --accent-fg: #ffffff;
  --user-bg: #f0f2f5; --err: #c62828; --err-bg: #fdeeee;
  --code-bg: #0d1117; --code-head: #161b22; --code-fg: #e6edf3; --shadow: 0 2px 14px rgba(20, 24, 33, .08);
  --ic-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.8'%3E%3Crect x='3' y='4' width='18' height='16' rx='3.5'/%3E%3Ccircle cx='9' cy='10' r='1.7'/%3E%3Cpath d='M21 16.5l-5-5-9 8.5'/%3E%3C/svg%3E");
  --ic-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5'%3E%3Cpath d='M12 19V5M5.5 11.5 12 5l6.5 6.5'/%3E%3C/svg%3E");
  --ic-stop: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6.5' y='6.5' width='11' height='11' rx='2.6' fill='black'/%3E%3C/svg%3E");
  --ic-out: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.9'%3E%3Cpath d='M9 21H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3'/%3E%3Cpath d='M16 17l5-5-5-5M21 12H9'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517; --bg-soft: #1a1b1e; --bg-hover: #25272b; --fg: #e8e9ec; --fg2: #9a9ea6; --fg3: #6b6f76;
    --line: #2b2d32; --accent: #5b8def; --accent-hover: #7aa1f5; --accent-fg: #0b0d10;
    --user-bg: #24262b; --err: #ff8a80; --err-bg: #3a1f1f;
    --code-bg: #0b0d10; --code-head: #14171b; --code-fg: #e6edf3; --shadow: 0 2px 14px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, select, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg3); }

/* 登录 */
.login { height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(ellipse at 50% 38%, rgba(0, 0, 0, .16), rgba(0, 0, 0, .52)), url("/ss1.png") center / cover no-repeat, #15161a; }
.login-box { position: relative; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; padding: 38px 32px 30px; color: #fff; border-radius: 28px; border: 1px solid rgba(255, 255, 255, .2); background: linear-gradient(145deg, rgba(255, 255, 255, .17), rgba(255, 255, 255, .05)); -webkit-backdrop-filter: blur(26px) saturate(1.6); backdrop-filter: blur(26px) saturate(1.6); box-shadow: 0 28px 70px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .34), inset 0 -1px 0 rgba(255, 255, 255, .06); animation: rise .7s cubic-bezier(.2, .7, .2, 1) both; }
.login-box::before { content: ""; align-self: center; width: 68px; height: 68px; margin-bottom: 4px; border-radius: 50%; background: url("/ss.png") center / cover no-repeat, linear-gradient(135deg, #4f46e5, #7c5cf0); box-shadow: 0 0 0 3px rgba(255, 255, 255, .3), 0 12px 28px rgba(0, 0, 0, .4); }
.login-box h1 { margin: 6px 0 0; font-size: 24px; font-weight: 600; text-align: center; letter-spacing: .22em; text-indent: .22em; text-shadow: 0 2px 12px rgba(0, 0, 0, .35); }
.login-box h1::after { content: "没有困难的工作只有勇敢的牛马"; display: block; margin-top: 8px; font-size: 12.5px; font-weight: 400; letter-spacing: .08em; text-indent: 0; color: rgba(255, 255, 255, .62); text-shadow: none; }
.login-box input { padding: 14px 16px; color: #fff; caret-color: #fff; border: 1px solid rgba(255, 255, 255, .22); border-radius: 14px; background: rgba(255, 255, 255, .1); outline: none; transition: border-color .2s, background .2s, box-shadow .2s; }
.login-box input::placeholder { color: rgba(255, 255, 255, .5); }
.login-box input:focus { border-color: rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .16); box-shadow: 0 0 0 4px rgba(255, 255, 255, .12); }
.login-box input:-webkit-autofill { -webkit-text-fill-color: #fff; box-shadow: 0 0 0 100px rgba(60, 60, 70, .55) inset; transition: background-color 9999s; }
.login-box .btn.primary { padding: 14px; margin-top: 2px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .94); color: #14151a; font-weight: 600; letter-spacing: .3em; text-indent: .3em; box-shadow: 0 10px 26px rgba(0, 0, 0, .3); transition: transform .15s, background .15s, box-shadow .15s; }
.login-box .btn.primary:hover { background: #fff; transform: translateY(-1px); box-shadow: 0 14px 30px rgba(0, 0, 0, .36); }
.login-box .btn.primary:active { transform: scale(.98); }
.login-box .btn.primary:disabled { opacity: .6; }
.login-err { min-height: 20px; margin: 0; color: #ffb3ad; font-size: 13px; text-align: center; }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .login-box { animation: none; } }

/* 按钮 */
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px 14px; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 500; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; }
.icon-btn { border: 0; background: transparent; font-size: 19px; width: 36px; height: 36px; border-radius: 10px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; color: var(--fg2); }
.icon-btn:hover { background: var(--bg-hover); color: var(--fg); }
#attachBtn { font-size: 0; width: 40px; height: 40px; border-radius: 50%; flex: none; }
#attachBtn::before { content: ""; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ic-img) center / contain no-repeat; mask: var(--ic-img) center / contain no-repeat; }

/* 布局 */
.app { display: flex; height: 100dvh; }
.sidebar { width: 272px; flex: none; display: flex; flex-direction: column; background: var(--bg-soft); border-right: 1px solid var(--line); }
.side-top { padding: 16px 14px 10px; }
.side-top::before { content: "落榜美术生"; display: block; font-weight: 700; font-size: 16px; letter-spacing: .3px; margin: 2px 4px 14px; }
.side-top .btn { width: 100%; text-align: left; padding: 10px 14px; }
.side-bottom { padding: 10px 12px 14px; border-top: 1px solid var(--line); }
.side-bottom .btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; font-size: 14px; color: var(--fg2); text-align: left; border-radius: 12px; }
.side-bottom .btn::before { content: ""; width: 18px; height: 18px; flex: none; background: currentColor; -webkit-mask: var(--ic-out) center / contain no-repeat; mask: var(--ic-out) center / contain no-repeat; }
.side-bottom .btn:hover { background: var(--err-bg); color: var(--err); }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 10px; }
.chat-item { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--fg2); transition: background .12s; }
.chat-item:hover { background: var(--bg-hover); color: var(--fg); }
.chat-item.active { background: var(--bg-hover); color: var(--fg); font-weight: 500; }
.ct { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cdel { border: 0; background: transparent; color: var(--fg3); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px; opacity: 0; }
.chat-item:hover .cdel, .chat-item.active .cdel { opacity: 1; }
.cdel:hover { color: var(--err); background: var(--err-bg); }
.scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); min-height: 54px; }
.menu-btn { display: none; }
#modelSel {
  appearance: none; -webkit-appearance: none; max-width: 62%; padding: 7px 32px 7px 14px; border: 1px solid var(--line); border-radius: 999px; background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%239a9ea6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; font-weight: 500; cursor: pointer; outline: none;
}
#modelSel:hover, #modelSel:focus { border-color: var(--fg3); }
.title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg3); font-size: 13px; }

/* 消息 */
.messages { flex: 1; overflow-y: auto; padding: 8px 18px 12px; scroll-behavior: auto; }
.messages > * { max-width: 780px; margin-left: auto; margin-right: auto; }
.welcome { text-align: center; color: var(--fg2); margin-top: 13vh; }
.welcome::before { content: ""; display: block; width: 84px; height: 84px; margin: 0 auto 20px; border-radius: 24px; background: url("/ss.png") center / cover no-repeat, linear-gradient(135deg, #4f46e5, #7c5cf0); box-shadow: 0 10px 28px rgba(0, 0, 0, .18); }
.welcome h2 { color: var(--fg); font-size: 28px; letter-spacing: 3px; margin: 0 0 10px; }
.welcome p { margin: 0 0 28px; font-size: 15px; letter-spacing: .5px; }
.suggs { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.sugg { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 16px; font-size: 14px; color: var(--fg2); transition: all .15s; }
.sugg:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-soft); }
.msg { margin-bottom: 26px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.imgs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.imgs img { max-width: 200px; max-height: 200px; border-radius: 14px; border: 1px solid var(--line); object-fit: cover; }
.utext { max-width: 86%; background: var(--user-bg); padding: 10px 16px; border-radius: 20px 20px 6px 20px; white-space: pre-wrap; word-break: break-word; }
.head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.av { width: 22px; height: 22px; border-radius: 7px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; background: var(--fg3); }
.av-claude { background: #d97757; }
.av-gpt { background: #10a37f; }
.who { font-size: 12.5px; color: var(--fg2); }
.think { margin: 2px 0 10px; font-size: 13px; color: var(--fg2); background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.think summary { cursor: pointer; user-select: none; }
.think-body { white-space: pre-wrap; margin-top: 8px; max-height: 260px; overflow-y: auto; }
.md { word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.35; font-weight: 650; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 1.55em; }
.md li { margin: 3px 0; }
.md blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 3px solid var(--line); color: var(--fg2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md a { color: var(--accent); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md code { background: var(--bg-hover); padding: 1.5px 6px; border-radius: 6px; font: 0.88em ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.code { margin: 14px 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); border: 1px solid rgba(128, 128, 128, .18); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; background: var(--code-head); font-size: 12px; color: #8b949e; }
.copy-code { border: 0; background: transparent; color: #8b949e; font-size: 12px; padding: 3px 9px; border-radius: 6px; }
.copy-code:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--code-fg); font-size: 13px; line-height: 1.6; }
.code code { background: transparent; padding: 0; font: 13px/1.6 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; color: inherit; white-space: pre; border-radius: 0; }
.tk-c { color: #8b949e; font-style: italic; } .tk-s { color: #a5d6ff; } .tk-n { color: #79c0ff; }
.tk-k { color: #ff7b72; } .tk-t { color: #7ee787; } .tk-a { color: #d2a8ff; }
.table-wrap { overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; font-size: 14px; width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 8px 12px; text-align: left; }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--bg-soft); font-weight: 600; }
.md .al-c { text-align: center; } .md .al-r { text-align: right; }
.err { margin-top: 8px; padding: 10px 14px; background: var(--err-bg); color: var(--err); border-radius: 12px; font-size: 14px; }
.note { margin-top: 6px; font-size: 12px; color: var(--fg3); }
.actions { display: flex; gap: 2px; margin-top: 8px; }
.act { border: 0; background: transparent; color: var(--fg3); font-size: 12px; padding: 4px 9px; border-radius: 8px; }
.act:hover { background: var(--bg-hover); color: var(--fg); }
.err .act { color: var(--err); text-decoration: underline; padding: 0 4px; }
.streaming .actions { display: none; }
@media (hover: hover) {
  .msg.assistant .actions { opacity: 0; transition: opacity .15s; }
  .msg.assistant:hover .actions, .msg.assistant:last-child .actions { opacity: 1; }
}
.streaming .md > p:last-child::after { content: ""; display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: text-bottom; background: var(--fg2); border-radius: 2px; animation: caret 1s steps(2) infinite; }
.waiting .md::after { content: "●●●"; letter-spacing: 4px; color: var(--fg3); animation: blink 1.2s infinite; }
@keyframes caret { 50% { opacity: 0; } }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* 输入区 */
.composer { padding: 6px 18px calc(12px + env(safe-area-inset-bottom)); }
.composer > * { max-width: 780px; margin-left: auto; margin-right: auto; }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; }
.attachments:not(:empty) { margin-bottom: 10px; }
.chip { position: relative; }
.chip img { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.chip button { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #2b2d32; color: #fff; font-size: 13px; line-height: 20px; padding: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.input-row { display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--line); border-radius: 26px; padding: 7px 8px 7px 8px; background: var(--bg); box-shadow: var(--shadow); transition: border-color .15s; }
.input-row:focus-within { border-color: var(--fg3); }
#input { flex: 1; resize: none; border: 0; background: transparent; outline: none; padding: 7px 4px; max-height: 200px; line-height: 1.55; }
#input::placeholder { color: var(--fg3); }
.send { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 0; flex: none; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 38%, transparent); transition: transform .12s, opacity .15s, background .15s, box-shadow .15s; }
.send::before { content: ""; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--ic-send) center / contain no-repeat; mask: var(--ic-send) center / contain no-repeat; }
.send:hover { transform: translateY(-1px); }
.send:active { transform: scale(.94); }
.send[data-mode="stop"] { background: var(--fg); border-color: var(--fg); color: var(--bg); box-shadow: none; }
.send[data-mode="stop"]::before { -webkit-mask-image: var(--ic-stop); mask-image: var(--ic-stop); }
.composer:has(#input:placeholder-shown):not(:has(.chip)) .send[data-mode="send"] { opacity: .35; box-shadow: none; pointer-events: none; }
.hint { margin-top: 6px; font-size: 12px; color: var(--fg3); text-align: center; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #1f2124; color: #fff; padding: 9px 16px; border-radius: 12px; font-size: 13px; z-index: 50; max-width: 90vw; box-shadow: var(--shadow); }
.drag .composer .input-row { border-color: var(--accent); border-style: dashed; }

/* 手机 */
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; padding-top: env(safe-area-inset-top); }
  .side-open .sidebar { transform: none; box-shadow: 6px 0 30px rgba(0, 0, 0, .25); }
  .side-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .38); }
  .hint { display: none; }
  .messages { padding: 4px 14px 10px; }
  .composer { padding: 4px 12px calc(10px + env(safe-area-inset-bottom)); }
  .imgs img { max-width: 140px; max-height: 140px; }
  .cdel { opacity: 1; }
  .welcome { margin-top: 10vh; }
  .welcome h2 { font-size: 24px; }
  .utext { max-width: 92%; }
}

/* HTML 预览 */
.code-head .lang { flex: none; }
.tabs { display: inline-flex; gap: 2px; margin: 0 auto; background: rgba(255, 255, 255, .06); padding: 2px; border-radius: 8px; }
.tab { border: 0; background: transparent; color: #8b949e; font-size: 12px; padding: 3px 12px; border-radius: 6px; }
.tab:hover { color: #fff; }
.tab.on { background: rgba(255, 255, 255, .14); color: #fff; }
.tools { display: inline-flex; gap: 2px; flex: none; }
.open-pv { border: 0; background: transparent; color: #8b949e; font-size: 12px; padding: 3px 9px; border-radius: 6px; }
.open-pv:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.preview { background: #fff; }
.preview iframe { display: block; width: 100%; height: 480px; border: 0; background: #fff; resize: vertical; overflow: auto; min-height: 160px; }
.streaming .tabs { opacity: .4; pointer-events: none; }
.code.pv .code-head { gap: 10px; }