/* ===== AI Hub 前台样式 ===== */
:root {
  --bg: #080b14;
  --bg2: #0d1220;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.14);
  --txt: #e9ecf7;
  --txt-2: #a2abc4;
  --txt-3: #6d7690;
  --pri: #5b7cfa;
  --pri2: #8b5cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  line-height: 1.65;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 背景光晕 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(91, 124, 250, .16), transparent 60%),
    radial-gradient(800px 600px at 92% 110%, rgba(139, 92, 246, .14), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app { position: relative; z-index: 1; display: flex; height: 100vh; }

/* ================= 侧边栏 ================= */
.sidebar {
  width: 268px;
  flex: 0 0 268px;
  border-right: 1px solid var(--line);
  background: rgba(10, 14, 26, .72);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #5b7cfa, #8b5cf6);
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #fff;
  box-shadow: 0 6px 18px rgba(91, 124, 250, .38);
}
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: .3px; }
.brand span { display: block; font-size: 11px; color: var(--txt-3); font-weight: 400; }

.btn-new {
  width: 100%; padding: 11px; border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: linear-gradient(135deg, rgba(91, 124, 250, .18), rgba(139, 92, 246, .18));
  color: #dfe4ff; font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  transition: .2s;
}
.btn-new:hover { background: linear-gradient(135deg, rgba(91, 124, 250, .3), rgba(139, 92, 246, .3)); border-color: rgba(255, 255, 255, .2); }

.mode-tabs {
  display: flex; gap: 4px; margin: 14px 0 8px;
  background: rgba(255, 255, 255, .045); padding: 4px; border-radius: 11px;
}
.mode-tabs button {
  flex: 1; padding: 8px 4px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--txt-2); font-size: 13px; font-weight: 600;
  transition: .18s; display: flex; align-items: center; justify-content: center; gap: 5px;
}
.mode-tabs button.on {
  background: linear-gradient(135deg, #5b7cfa, #8b5cf6); color: #fff;
  box-shadow: 0 4px 14px rgba(91, 124, 250, .35);
}

.conv-label { font-size: 11px; color: var(--txt-3); padding: 10px 8px 6px; letter-spacing: .5px; }

.conv-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.conv-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
  color: var(--txt-2); font-size: 13px; transition: .15s; position: relative;
}
.conv-item:hover { background: rgba(255, 255, 255, .05); color: var(--txt); }
.conv-item.on { background: rgba(91, 124, 250, .13); color: #cdd8ff; }
.conv-item .ic { font-size: 13px; opacity: .8; flex: 0 0 auto; }
.conv-item .tt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .del { opacity: 0; padding: 2px 5px; border-radius: 6px; color: var(--txt-3); }
.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { background: rgba(248, 113, 113, .18); color: var(--err); }

.side-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; display: grid; gap: 6px; }
.side-foot button {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 10px;
  border: 0; background: transparent; color: var(--txt-2); font-size: 13px; cursor: pointer; text-align: left;
}
.side-foot button:hover { background: rgba(255, 255, 255, .05); color: var(--txt); }

/* ================= 主区 ================= */
main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 58px; flex: 0 0 58px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 26, .5); backdrop-filter: blur(14px);
}
.topbar .t-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .title { font-size: 14px; font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-mode {
  font-size: 11px; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
  background: rgba(91, 124, 250, .16); color: #a9bcff; border: 1px solid rgba(91, 124, 250, .3);
}
.badge-mode.agent { background: rgba(139, 92, 246, .16); color: #c9b4ff; border-color: rgba(139, 92, 246, .34); }

.topbar .t-right { display: flex; align-items: center; gap: 10px; }
.chip-credit {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); font-size: 12px; color: var(--txt-2);
  cursor: pointer;
}
.chip-credit b { color: #ffd166; font-weight: 700; }

.sel-model {
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
  color: var(--txt-2); border-radius: 9px; padding: 6px 10px; font-size: 12px; outline: none;
  max-width: 190px;
}

/* 欢迎页 */
.chat-area { flex: 1; overflow-y: auto; padding: 26px 20px 10px; scroll-behavior: smooth; }

.welcome { max-width: 820px; margin: 6vh auto 0; text-align: center; }
.welcome .hero-ic {
  width: 62px; height: 62px; margin: 0 auto 16px; border-radius: 18px;
  background: linear-gradient(135deg, #5b7cfa, #8b5cf6);
  display: grid; place-items: center; font-size: 28px;
  box-shadow: 0 14px 40px rgba(91, 124, 250, .4);
}
.welcome h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.welcome p { color: var(--txt-2); font-size: 13.5px; margin-bottom: 26px; }
.sug-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; text-align: left; }
.sug {
  padding: 14px 16px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; transition: .18s;
}
.sug:hover { border-color: rgba(91, 124, 250, .45); background: rgba(91, 124, 250, .08); transform: translateY(-2px); }
.sug b { display: block; font-size: 13.5px; margin-bottom: 4px; }
.sug span { font-size: 12px; color: var(--txt-3); line-height: 1.5; }

/* 消息 */
.messages { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; gap: 12px; animation: fadeUp .28s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.msg .avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: linear-gradient(135deg, #2b3550, #3a4460); color: #cfd8f0; }
.msg.ai .avatar { background: linear-gradient(135deg, #5b7cfa, #8b5cf6); color: #fff; box-shadow: 0 6px 16px rgba(91, 124, 250, .3); }

.msg .body { max-width: calc(100% - 50px); min-width: 0; }
.msg.user .body { align-items: flex-end; display: flex; flex-direction: column; }

.bubble-user {
  background: linear-gradient(135deg, rgba(91, 124, 250, .22), rgba(139, 92, 246, .18));
  border: 1px solid rgba(91, 124, 250, .3);
  padding: 11px 15px; border-radius: 14px 4px 14px 14px;
  white-space: pre-wrap; word-break: break-word; font-size: 14px;
}

.msg.ai .name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.msg.ai .name { font-size: 12px; color: var(--txt-3); }

/* Markdown 内容 */
.md { font-size: 14.2px; line-height: 1.78; word-break: break-word; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { font-size: 16px; margin: 16px 0 8px; font-weight: 700; }
.md h1 { font-size: 18px; }
.md h4 { font-size: 14.5px; margin: 12px 0 6px; }
.md ul, .md ol { margin: 6px 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md strong { color: #fff; font-weight: 700; }
.md em { color: var(--txt-2); }
.md a { color: #8fb0ff; text-decoration: none; border-bottom: 1px dashed rgba(143, 176, 255, .4); }
.md code.inline {
  background: rgba(255, 255, 255, .08); padding: 2px 6px; border-radius: 5px;
  font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; color: #ffd9a0;
}
.md pre {
  background: #0c1120; border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 15px; overflow-x: auto; margin: 10px 0; position: relative;
}
.md pre code { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.6; color: #c9d4ef; white-space: pre; }
.md pre .copy {
  position: absolute; top: 8px; right: 8px; padding: 3px 9px; border-radius: 6px;
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line); color: var(--txt-3);
  font-size: 11px; cursor: pointer;
}
.md pre .copy:hover { color: #fff; background: rgba(91, 124, 250, .2); }
.md table { border-collapse: collapse; margin: 10px 0; font-size: 13px; width: 100%; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line-2); padding: 7px 11px; text-align: left; }
.md th { background: rgba(255, 255, 255, .05); font-weight: 600; }
.md blockquote { border-left: 3px solid rgba(91, 124, 250, .5); padding: 6px 12px; margin: 10px 0; background: rgba(91, 124, 250, .06); color: var(--txt-2); }
.md img { max-width: 100%; border-radius: 10px; margin: 8px 0; }

/* 工具卡片 */
.tools-wrap { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.tool-card {
  border: 1px solid var(--line); background: rgba(255, 255, 255, .035);
  border-radius: 10px; padding: 9px 12px; font-size: 12.5px;
  display: flex; align-items: center; gap: 9px; animation: fadeUp .25s;
}
.tool-card .tic { font-size: 14px; width: 20px; text-align: center; }
.tool-card .tname { font-weight: 600; color: var(--txt); }
.tool-card .tsum { color: var(--txt-3); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-card .tstat { font-size: 11px; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.tool-card .tstat.run { background: rgba(251, 191, 36, .15); color: var(--warn); }
.tool-card .tstat.ok { background: rgba(52, 211, 153, .14); color: var(--ok); }
.tool-card .tstat.bad { background: rgba(248, 113, 113, .15); color: var(--err); }
.tool-card .tresult {
  display: none; width: 100%; margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--line); color: var(--txt-2);
  font-size: 12px; white-space: pre-wrap; max-height: 160px; overflow-y: auto;
}
.tool-card.open { flex-wrap: wrap; }
.tool-card.open .tresult { display: block; }

.step-tip { font-size: 11.5px; color: var(--txt-3); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.step-tip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--pri); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.reason-box { border: 1px dashed var(--line); border-radius: 9px; padding: 8px 11px; margin-bottom: 8px; }
.reason-box .rt { font-size: 11.5px; color: var(--txt-3); cursor: pointer; display: flex; justify-content: space-between; }
.reason-box .rc { font-size: 12.5px; color: var(--txt-2); white-space: pre-wrap; margin-top: 6px; max-height: 150px; overflow-y: auto; }

.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 9px; background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line); font-size: 12px; color: var(--txt-2); margin: 6px 0;
}
.file-chip a { color: #9db9ff; }

.typing { display: inline-block; width: 7px; height: 14px; background: var(--pri); vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* 输入区 */
.composer-wrap {
  flex: 0 0 auto; padding: 10px 20px 18px;
  background: linear-gradient(to top, rgba(8, 11, 20, .96), rgba(8, 11, 20, 0));
}
.composer {
  max-width: 820px; margin: 0 auto;
  background: rgba(255, 255, 255, .055);
  border: 1px solid var(--line-2); border-radius: 16px;
  padding: 10px 12px 8px;
  transition: .2s;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.composer:focus-within { border-color: rgba(91, 124, 250, .55); box-shadow: 0 0 0 4px rgba(91, 124, 250, .1); }
.attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.attach-list .a {
  display: flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 7px;
  background: rgba(91, 124, 250, .14); font-size: 11.5px; color: #b9c9ff;
}
.attach-list .a .x { cursor: pointer; opacity: .7; }
#input {
  width: 100%; min-height: 46px; max-height: 220px; resize: none;
  background: transparent; border: 0; outline: none; color: var(--txt);
  font-size: 14.2px; line-height: 1.6; padding: 8px 4px; font-family: inherit;
}
#input::placeholder { color: var(--txt-3); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 0; }
.composer-bar .left { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .04); color: var(--txt-2); cursor: pointer;
  display: grid; place-items: center; font-size: 14px; transition: .16s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.composer-bar .hint { font-size: 11px; color: var(--txt-3); }
.btn-send {
  padding: 8px 20px; border-radius: 10px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #5b7cfa, #8b5cf6); color: #fff;
  font-size: 13.5px; font-weight: 600; transition: .18s;
  display: flex; align-items: center; gap: 6px;
}
.btn-send:hover { filter: brightness(1.12); }
.btn-send:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* ================= 弹窗 ================= */
.mask {
  position: fixed; inset: 0; background: rgba(4, 6, 12, .75); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.mask.show { display: flex; }
.modal {
  width: 100%; max-width: 460px; max-height: 86vh; overflow-y: auto;
  background: #10162a; border: 1px solid var(--line-2); border-radius: 18px;
  padding: 24px; box-shadow: var(--shadow); animation: pop .24s ease;
}
.modal.wide { max-width: 720px; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-head .close { width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .06); color: var(--txt-2); cursor: pointer; font-size: 15px; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--txt-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, .05);
  color: var(--txt); font-size: 13.5px; outline: none; font-family: inherit;
}
.field input:focus { border-color: rgba(91, 124, 250, .6); }

.btn-primary {
  width: 100%; padding: 11px; border-radius: 11px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #5b7cfa, #8b5cf6); color: #fff; font-size: 14px; font-weight: 600;
  margin-top: 4px;
}
.btn-primary:hover { filter: brightness(1.1); }
.switch-line { text-align: center; font-size: 12.5px; color: var(--txt-3); margin-top: 14px; }
.switch-line a { color: #9db9ff; cursor: pointer; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button {
  padding: 9px 14px; border: 0; background: transparent; color: var(--txt-3);
  font-size: 13.5px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: #fff; border-bottom-color: var(--pri); font-weight: 600; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.plan {
  border: 1px solid var(--line-2); border-radius: 14px; padding: 16px; position: relative;
  background: rgba(255, 255, 255, .04); transition: .2s;
}
.plan.recommend { border-color: rgba(139, 92, 246, .5); background: linear-gradient(180deg, rgba(139, 92, 246, .12), rgba(91, 124, 250, .06)); }
.plan .rec {
  position: absolute; top: -10px; right: 12px; font-size: 10.5px; padding: 3px 9px;
  background: linear-gradient(135deg, #5b7cfa, #8b5cf6); border-radius: 8px; color: #fff;
}
.plan h4 { font-size: 15px; margin-bottom: 4px; }
.plan .price { font-size: 24px; font-weight: 800; color: #fff; margin: 8px 0 2px; }
.plan .price small { font-size: 12px; font-weight: 400; color: var(--txt-3); }
.plan .old { font-size: 12px; color: var(--txt-3); text-decoration: line-through; }
.plan ul { margin: 12px 0 14px; padding-left: 16px; font-size: 12px; color: var(--txt-2); }
.plan ul li { margin: 4px 0; }
.plan .buy {
  width: 100%; padding: 9px; border-radius: 9px; border: 1px solid rgba(91, 124, 250, .4);
  background: rgba(91, 124, 250, .12); color: #b9c9ff; font-size: 13px; cursor: pointer; font-weight: 600;
}
.plan .buy:hover { background: rgba(91, 124, 250, .25); color: #fff; }

.credit-box {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px;
}
.credit-box .c { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 14px; text-align: center; }
.credit-box .c b { display: block; font-size: 22px; font-weight: 800; color: #ffd166; }
.credit-box .c span { font-size: 11.5px; color: var(--txt-3); }

.list-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.list-row .l { color: var(--txt-2); }
.list-row .r { color: var(--txt-3); }

.invite-box { background: rgba(91, 124, 250, .1); border: 1px dashed rgba(91, 124, 250, .4); border-radius: 11px; padding: 13px; margin: 12px 0; }
.invite-box .u { font-size: 12px; color: #b9c9ff; word-break: break-all; margin: 5px 0 8px; }
.invite-box button { padding: 6px 14px; border-radius: 8px; border: 1px solid rgba(91, 124, 250, .5); background: transparent; color: #b9c9ff; font-size: 12px; cursor: pointer; }

/* Toast */
#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-30px); opacity: 0; z-index: 90;
  background: rgba(20, 26, 44, .95); border: 1px solid var(--line-2); color: #fff;
  padding: 10px 18px; border-radius: 11px; font-size: 13px; transition: .25s; pointer-events: none; max-width: 80vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .2); }
::-webkit-scrollbar-track { background: transparent; }

/* ================= 移动端 ================= */
.mobile-bar { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .26s ease;
    box-shadow: 20px 0 60px rgba(0, 0, 0, .5); width: 280px;
  }
  .sidebar.open { transform: none; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px; height: 52px; flex: 0 0 52px;
    padding: 0 14px; border-bottom: 1px solid var(--line); background: rgba(10, 14, 26, .8);
  }
  .mobile-bar button { width: 32px; height: 32px; border-radius: 8px; border: 0; background: rgba(255,255,255,.06); color: var(--txt-2); font-size: 16px; }
  .mobile-bar .mt { flex: 1; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { display: none; }
  .chat-area { padding: 16px 12px 8px; }
  .composer-wrap { padding: 8px 10px 14px; }
  .sug-grid { grid-template-columns: 1fr; }
  .welcome h2 { font-size: 19px; }
  .msg .body { max-width: calc(100% - 44px); }
  .modal { padding: 18px; border-radius: 16px; }
  body { font-size: 14px; }
}
