/* ============ DeepSeek 对话平台 ============ */
:root {
  --bg: #212121;
  --bg-side: #171717;
  --bg-hover: #262626;
  --bg-active: #2f2f2f;
  --bg-input: #2a2a2a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #ececec;
  --text-2: #a6a6a6;
  --text-3: #7a7a7a;
  --accent: #4d6bfe;
  --accent-weak: rgba(77, 107, 254, 0.16);
  --danger: #e5534b;
  --radius: 12px;
  --side-w: 264px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.ic { width: 17px; height: 17px; flex: none; }
.chev { width: 14px; height: 14px; flex: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; height: 100vh; }

/* ============ 侧边栏 ============ */
#sidebar {
  width: var(--side-w);
  min-width: var(--side-w);
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 12px;
}
.side-top { padding: 2px 4px 12px; }
.btn-new {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 10px;
  border-radius: 10px; color: var(--text);
  transition: background .15s;
}
.btn-new:hover { background: var(--bg-hover); }
.btn-new .ic { width: 19px; height: 19px; color: var(--text-2); }
.btn-new span { font-size: 14.5px; font-weight: 500; }
.btn-new .kbd {
  margin-left: auto; font-size: 11px; color: var(--text-3);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}

.side-section { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 4px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 6px 6px 8px;
}
.section-title { color: var(--text-2); font-size: 13px; }
.section-tools { display: flex; gap: 2px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; }
.icon-btn:disabled:hover { background: none; color: var(--text-2); }

.search-wrap { padding: 0 2px 8px; }
#search-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; outline: none;
}
#search-input:focus { border-color: rgba(77,107,254,.55); }

#conv-list { flex: 1; overflow-y: auto; padding: 2px; }
/* 三条横线：折叠整个对话列表侧栏（侧栏整体收起，主区域占满全宽） */
body.side-hidden #sidebar { display: none; }
body.side-hidden #btn-side-open { display: inline-flex; }
.conv-item {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 6px 8px 10px; border-radius: 9px;
  cursor: pointer; user-select: none;
}
.conv-item:hover { background: var(--bg-hover); }
.conv-item.active { background: var(--bg-active); }
.conv-text { flex: 1; min-width: 0; }
.conv-title {
  font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-time { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.conv-del {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px; color: var(--text-3);
  opacity: 0; flex: none;
  transition: opacity .12s, background .12s, color .12s;
}
.conv-item:hover .conv-del, .conv-del:focus-visible { opacity: 1; }
.conv-del:hover { background: rgba(229, 83, 75, .14); color: var(--danger); }
.conv-del svg { width: 15px; height: 15px; }
.list-empty { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 26px 0; }

#side-mask { display: none; }

/* ============ 主区域 ============ */
#main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  position: relative;
}
#topbar {
  height: 52px; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 18px;
}
#top-title-wrap { display: flex; align-items: center; gap: 8px; color: var(--text-2); min-width: 0; }
#top-title-wrap .ic { width: 16px; height: 16px; }
#top-title { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-side-open { display: none; }

/* ---- 空状态 ---- */
#hero {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-bottom: 8vh;
  gap: 6px;
}
.main-empty #hero { display: flex; }
#hero.hidden { display: none; }
.hero-logo { width: 210px; opacity: .8; margin-bottom: 6px; }
.hero-logo svg { width: 100%; height: auto; }
#greeting { font-size: 30px; font-weight: 600; letter-spacing: .5px; }
.hero-sub { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }

/* ---- 消息列表 ---- */
#chat-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  display: none;
  scroll-behavior: auto;
}
.main-chat #chat-scroll { display: block; }
.main-chat #hero { display: none; }
#msg-list { max-width: 780px; margin: 0 auto; padding: 12px 20px 30px; }

.msg { margin: 26px 0; }
.msg-user .msg-main { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  background: var(--bg-active);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  max-width: 78%;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-attachments img {
  width: 108px; height: 108px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--border);
  display: block; cursor: zoom-in;
}
.msg-assistant .assistant-body { line-height: 1.75; word-break: break-word; }

/* 思考区域 */
.think {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
}
.think-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 12px;
  color: var(--text-2); font-size: 13px;
  text-align: left;
}
.think-head:hover { color: var(--text); }
.think-head .ic { width: 15px; height: 15px; }
.think-head .think-chevron { margin-left: auto; transition: transform .18s; }
.think.open .think-chevron { transform: rotate(90deg); }
.think-label-stream { color: var(--text-2); }
.think-label-stream::after {
  content: "";
  animation: dots 1.2s steps(4) infinite;
}
@keyframes dots { 0% {content: "";} 25% {content: ".";} 50% {content: "..";} 75% {content: "...";} }
.think-body { display: none; padding: 2px 14px 12px; }
.think.open .think-body { display: block; }
.think-text {
  color: var(--text-2); font-size: 13.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.think.grown .think-body { max-height: none; }        /* 生成期间不限制高度，页面跟随滚动 */
.think.clipped .think-body { max-height: 320px; overflow-y: auto; } /* 生成结束后手动展开时限高 */

/* Markdown 正文 */
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 8px; line-height: 1.4; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17.5px; } .md h3 { font-size: 15.5px; } .md h4 { font-size: 14.5px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md code.inline {
  background: rgba(255,255,255,.09); border-radius: 5px;
  padding: 1.5px 6px; font-size: 13px;
  font-family: "SF Mono", ui-monospace, Consolas, "Courier New", monospace;
}
.md pre {
  background: #16181d; border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; overflow-x: auto;
  margin: 10px 0;
}
.md pre code {
  font-family: "SF Mono", ui-monospace, Consolas, "Courier New", monospace;
  font-size: 13px; line-height: 1.6; color: #d8dee9;
}
.md table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 13.5px; }
.md th, .md td { border: 1px solid rgba(255,255,255,.14); padding: 7px 12px; text-align: left; }
.md th { background: rgba(255,255,255,.05); font-weight: 600; }
.md blockquote {
  border-left: 3px solid rgba(255,255,255,.18);
  padding: 2px 0 2px 12px; margin: 8px 0; color: var(--text-2);
}
.md a { color: #7d95ff; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* 消息操作（删除按钮常驻在消息下方） */
.msg-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.msg-foot .del {
  width: 26px; height: 26px; border-radius: 7px;
  color: var(--text-3);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.msg-foot .del:hover { color: var(--danger); background: rgba(229,83,75,.12); }
.msg-foot .del svg { width: 14.5px; height: 14.5px; }

.msg-error {
  border: 1px solid rgba(229,83,75,.4); background: rgba(229,83,75,.08);
  color: #f1a9a5; border-radius: 10px; padding: 9px 12px; font-size: 13px;
  margin-top: 8px;
}
.stream-cursor {
  display: inline-block; width: 7px; height: 15px; background: var(--text-2);
  border-radius: 2px; vertical-align: -2px; margin-left: 2px;
  animation: blink .9s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ============ 输入区 ============ */
#composer-zone { flex: none; padding: 0 20px 14px; }
.main-empty #composer-zone {
  width: 100%; max-width: 720px; margin: 0 auto;
}
#composer {
  max-width: 780px; margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 12px 14px 10px;
  transition: border-color .15s, max-width .15s;
}
#composer:focus-within { border-color: rgba(255,255,255,.2); }
#input {
  width: 100%; background: none; border: none; outline: none; resize: none;
  color: var(--text); font-size: 14.5px; line-height: 1.6;
  max-height: 200px; padding: 2px 4px 8px;
}
#input::placeholder { color: var(--text-3); }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 4px 10px; }
.attach-thumb { position: relative; width: 62px; height: 62px; }
.attach-thumb img {
  width: 62px; height: 62px; object-fit: cover; border-radius: 9px;
  border: 1px solid var(--border); display: block;
}
.attach-remove {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #3d3d3d; color: #ddd; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.attach-remove:hover { background: var(--danger); color: #fff; }

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bar-left, .bar-right { display: flex; align-items: center; gap: 6px; }
#btn-plus { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); }
#btn-plus:hover:not(:disabled) { background: rgba(255,255,255,.07); color: var(--text); }

.menu-root { position: relative; }
.menu {
  position: absolute; left: 0; bottom: calc(100% + 8px);
  background: #2c2c2c; border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 5px;
  min-width: 150px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  z-index: 50;
}
.menu.drop { bottom: auto; top: calc(100% + 6px); }
.menu-item, .menu .opt {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; text-align: left; color: var(--text);
}
.menu-item:hover, .menu .opt:hover { background: rgba(255,255,255,.07); }
.menu .opt .opt-sub { margin-left: auto; font-size: 11px; color: var(--text-3); }
.menu .opt.active { background: var(--accent-weak); color: #aebfff; }
.menu .opt .tag {
  margin-left: 2px; font-size: 10.5px; color: #8fa4ff;
  border: 1px solid rgba(143,164,255,.4); border-radius: 4px; padding: 0 4px;
}

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px; border-radius: 17px;
  color: var(--text-2); font-size: 13px;
  transition: background .15s, color .15s;
}
.pill-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }
.pill-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.pill-btn .ic { width: 15px; height: 15px; }

/* 联网开关 */
.web-toggle.on {
  color: #aebfff;
  background: var(--accent-weak);
}
.web-toggle.on .ic { color: #8fa4ff; }

/* 链接胶囊：内联附着在对应文本之后 */
.lnk-bubble {
  display: inline-flex; align-items: center; max-width: 240px;
  font-size: 12px; line-height: 1;
  color: #8fa4ff; text-decoration: none;
  background: rgba(143, 164, 255, .08);
  border: 1px solid rgba(143, 164, 255, .28);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 0 3px;
  vertical-align: baseline;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.lnk-bubble:hover {
  background: rgba(143, 164, 255, .18);
  border-color: rgba(143, 164, 255, .55);
  box-shadow: 0 1px 8px rgba(77, 107, 254, .3);
}
.lnk-bubble:focus-visible { outline: 2px solid #7d95ff; outline-offset: 1px; }
.lnk-bubble .lb-no { font-weight: 600; margin-right: 5px; color: #aebfff; }
.lnk-bubble .lb-tx { overflow: hidden; text-overflow: ellipsis; }
.net-status { color: var(--text-2); font-size: 13.5px; }

#btn-send {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: #fff; color: #111;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .15s, background .15s, transform .1s;
}
#btn-send svg { width: 17px; height: 17px; }
#btn-send:disabled { background: #454545; color: #8a8a8a; }
#btn-send:not(:disabled):active { transform: scale(.93); }
#btn-send.stop { background: var(--danger); color: #fff; }

.composer-hint {
  max-width: 780px; margin: 8px auto 0;
  text-align: center; color: var(--text-3); font-size: 11.5px;
}

/* ============ 弹窗 ============ */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.dialog {
  background: #2a2a2a; border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px; padding: 20px;
  width: 100%; max-width: 380px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
.dialog h3 { font-size: 16px; margin-bottom: 10px; }
.confirm-dialog p { color: var(--text-2); line-height: 1.7; font-size: 13.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.btn {
  padding: 8px 18px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid var(--border); color: var(--text);
  transition: background .15s;
}
.btn:hover { background: rgba(255,255,255,.07); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f5be0; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #d4423a; }

.camera-dialog { max-width: 460px; }
.camera-view {
  background: #000; border-radius: 12px; overflow: hidden;
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
}
.camera-view video { width: 100%; height: 100%; object-fit: cover; }

/* Toast */
#toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: var(--text); border: 1px solid rgba(255,255,255,.12);
  padding: 10px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 26px rgba(0,0,0,.4);
  z-index: 200; max-width: 82vw;
}
#toast.error { border-color: rgba(229,83,75,.5); color: #f1a9a5; }

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 90;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.side-open #sidebar { transform: translateX(0); }
  body.side-open #side-mask {
    display: block; position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.4);
  }
  #btn-side-open { display: inline-flex; }
  #msg-list { padding: 10px 14px 24px; }
  #composer-zone { padding: 0 12px 10px; }
  .msg-user .bubble { max-width: 92%; }
  #greeting { font-size: 24px; }
  .hero-logo { width: 150px; }
}
