/* 一达智能体 · 前台样式（手机优先 / 亮暗双主题 / 无外部依赖） */
:root {
  --brand: #5b4bdb;
  --brand-2: #7c5cff;
  --brand-soft: rgba(91, 75, 219, .10);
  --bg: #f4f5fa;
  --panel: #ffffff;
  --fg: #16181f;
  --muted: #6b7280;
  --border: rgba(16, 18, 26, .10);
  --bubble-user: linear-gradient(135deg, var(--brand), var(--brand-2));
  --bubble-ai: #ffffff;
  --shadow: 0 6px 24px rgba(23, 26, 46, .08);
  --radius: 16px;
  --side-w: 268px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0e1016;
  --panel: #171a22;
  --fg: #e8eaf2;
  --muted: #9aa3b2;
  --border: rgba(255, 255, 255, .10);
  --bubble-ai: #1d2130;
  --brand-soft: rgba(124, 92, 255, .16);
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
button { font: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(128, 130, 150, .35); border-radius: 8px; }

.app { display: flex; height: 100dvh; overflow: hidden; }

/* ---------------- 侧栏 ---------------- */
.side {
  width: var(--side-w); flex: 0 0 var(--side-w); display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border); padding: 14px 12px;
}
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px;
  background: var(--bubble-user); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 17px; letter-spacing: .5px; box-shadow: var(--shadow);
}
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.btn-new {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 12px; color: #fff; font-weight: 600;
  background: var(--bubble-user); box-shadow: var(--shadow); transition: .18s;
}
.btn-new:hover { filter: brightness(1.06); transform: translateY(-1px); }
.side-label { font-size: 11.5px; color: var(--muted); margin: 16px 4px 6px; letter-spacing: .4px; }
.side-list { flex: 1; overflow-y: auto; margin: 0 -4px; }
.sess {
  padding: 9px 10px; border-radius: 10px; font-size: 13.5px; color: var(--fg);
  display: flex; gap: 8px; align-items: center; cursor: pointer; transition: .15s;
}
.sess:hover { background: var(--brand-soft); }
.sess.active { background: var(--brand-soft); font-weight: 600; }
.sess .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sess .x { color: var(--muted); opacity: .5; padding: 0 2px; }
.sess .x:hover { opacity: 1; color: #e5484d; }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 8px;
  font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.side-foot a { text-decoration: none; }
.side-actions { display: flex; gap: 8px; }
.chip-btn {
  flex: 1; text-align: center; padding: 7px 8px; border-radius: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--fg); font-size: 12.5px;
}
.chip-btn:hover { background: var(--brand-soft); border-color: transparent; }

/* ---------------- 主区 ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); position: sticky; top: 0; z-index: 5;
}
.top-title { font-weight: 650; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); color: var(--fg); display: grid; place-items: center;
}
.icon-btn:hover { background: var(--brand-soft); }
.burger { display: none; }

.msgs { flex: 1; overflow-y: auto; padding: 18px 16px 8px; scroll-behavior: smooth; }
.wrap { max-width: 860px; margin: 0 auto; }

/* 欢迎卡 */
.hero { text-align: center; padding: 26px 12px 6px; }
.hero .logo { width: 58px; height: 58px; border-radius: 18px; font-size: 24px; margin: 0 auto 14px; }
.hero h1 { font-size: 22px; margin: 0 0 6px; }
.hero p { color: var(--muted); margin: 0 auto 4px; max-width: 560px; font-size: 14px; white-space: pre-line; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 6px; }
.quick button {
  border: 1px solid var(--border); background: var(--panel); color: var(--fg);
  padding: 9px 14px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--shadow);
  transition: .16s;
}
.quick button:hover { transform: translateY(-2px); border-color: transparent; background: var(--brand-soft); }

/* 消息 */
.msg { display: flex; gap: 10px; margin: 16px 0; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.av {
  width: 32px; height: 32px; border-radius: 10px; flex: 0 0 32px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #fff; background: var(--bubble-user); box-shadow: var(--shadow);
}
.msg.ai .av { background: linear-gradient(135deg, #2b2f45, #4a5170); }
.body { max-width: min(78%, 660px); }
.bubble {
  padding: 12px 14px; border-radius: var(--radius); background: var(--bubble-ai);
  border: 1px solid var(--border); box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.msg.user .bubble { background: var(--bubble-user); color: #fff; border-color: transparent; }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3 { font-size: 15.5px; margin: 12px 0 6px; }
.bubble p { margin: 8px 0; }
.bubble ul, .bubble ol { margin: 8px 0; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble code { background: var(--brand-soft); padding: 1.5px 5px; border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.8px; }
.bubble pre { background: #0f1220; color: #e6e8f2; padding: 12px; border-radius: 12px; overflow-x: auto; margin: 10px 0; }
.bubble pre code { background: none; color: inherit; padding: 0; }
.bubble table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13.5px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.bubble th { background: var(--brand-soft); }
.bubble blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--brand);
  color: var(--muted); background: var(--brand-soft); border-radius: 0 8px 8px 0; }
.cursor::after { content: "▍"; margin-left: 1px; color: var(--brand); animation: blink 1s steps(2) infinite; }
@keyframes blink { 0%, 49% { opacity: 1 } 50%, 100% { opacity: 0 } }

/* 引用 / 工具 */
.cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cite {
  font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--brand-soft);
  color: var(--brand); border: 1px solid transparent; text-decoration: none; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.cite:hover { border-color: var(--brand); }
.tools { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.tool {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--border); padding: 6px 10px; border-radius: 10px;
  width: fit-content; max-width: 100%;
}
.tool .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: pulse 1.1s infinite; }
.tool.ok .dot { background: #30a46c; animation: none; }
.tool.fail .dot { background: #e5484d; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

.meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.msg.user .meta { justify-content: flex-end; }
.act { border: 0; background: none; color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.act:hover { background: var(--brand-soft); color: var(--brand); }
.act.on { color: var(--brand); }
.tag-prov { font-size: 11px; color: var(--muted); }

.err {
  margin: 10px 0; padding: 10px 12px; border-radius: 12px; font-size: 13px;
  background: rgba(229, 72, 77, .10); color: #b4242a; border: 1px solid rgba(229, 72, 77, .25);
}
html[data-theme="dark"] .err { color: #ff9b9e; }

/* 输入区 */
.composer { padding: 10px 16px 14px; border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 92%, transparent); }
.composer .wrap { max-width: 860px; }
.input-row {
  display: flex; gap: 8px; align-items: flex-end; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow); transition: .18s;
}
.input-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--fg);
  font: inherit; max-height: 168px; min-height: 24px; padding: 5px 0;
}
.send {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--bubble-user); color: #fff;
  display: grid; place-items: center; flex: 0 0 40px;
}
.send:disabled { opacity: .45; cursor: not-allowed; }
.send.stop { background: #2b2f45; }
.hint { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--muted); margin: 8px 4px 0; }
.foot-note { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* 弹层 */
.mask { position: fixed; inset: 0; background: rgba(8, 10, 18, .48); display: none; z-index: 40;
  align-items: center; justify-content: center; padding: 18px; }
.mask.on { display: flex; }
.modal { background: var(--panel); border-radius: 18px; padding: 20px; width: 100%; max-width: 440px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3); max-height: 92dvh; overflow-y: auto; }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal p.sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.field { margin-bottom: 10px; }
.field label { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--fg); font: inherit;
}
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn { padding: 10px 16px; border-radius: 11px; border: 1px solid var(--border); background: transparent;
  color: var(--fg); font-weight: 600; }
.btn.primary { background: var(--bubble-user); color: #fff; border: 0; flex: 1; }
.btn.primary:hover { filter: brightness(1.06); }
.okmsg { color: #30a46c; font-size: 13.5px; }


/* AI 生成图片卡片 */
.md-img { max-width: 100%; border-radius: 12px; display: block; margin: 8px 0; }
.genimg { margin: 10px 0 6px; }
.genimg img { max-width: min(100%, 420px); border-radius: 14px; border: 1px solid var(--border);
  display: block; box-shadow: var(--shadow); }
.genimg-bar { display: flex; justify-content: space-between; gap: 10px; align-items: center;
  font-size: 11.5px; color: var(--muted); margin-top: 6px; max-width: min(100%, 420px); }
.genimg-bar a { color: var(--brand); text-decoration: none; font-weight: 600; }

/* 手机 */
@media (max-width: 820px) {
  .side {
    position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-102%);
    transition: transform .24s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .3); width: 84vw; max-width: 320px;
  }
  .app.drawer .side { transform: none; }
  .app.drawer::after { content: ""; position: fixed; inset: 0; background: rgba(8, 10, 18, .45); z-index: 25; }
  .burger { display: grid; }
  .body { max-width: 86%; }
  .msgs { padding: 12px 10px 4px; }
  .composer { padding: 8px 10px 10px; }
  .quick button { font-size: 13px; padding: 8px 12px; }
  .hero { padding: 14px 6px 4px; }
  .hero h1 { font-size: 19px; }
}

/* ==================== 账户体系（登录 / 我的账户） ==================== */
.yd-ubtn { border: 1px solid var(--border); background: var(--panel); color: var(--fg);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.yd-ubtn:hover { border-color: var(--brand); color: var(--brand); }
.yd-user { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--panel); cursor: pointer; }
.yd-user:hover { border-color: var(--brand); }
.yd-ava { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bubble-user); color: #fff; font-size: 12px; font-weight: 700; overflow: hidden; }
.yd-ava img { width: 100%; height: 100%; object-fit: cover; }
.yd-uname { font-size: 13px; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yd-caret { font-size: 10px; color: var(--muted); }
#ydUserBar { position: relative; display: flex; align-items: center; }
.yd-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 60; }
.yd-menu.on { display: block; }
.yd-menu-hd { font-size: 12px; color: var(--muted); padding: 7px 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 4px; word-break: break-all; }
.yd-mi { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--fg);
  padding: 9px 10px; border-radius: 8px; font-size: 13px; text-decoration: none; }
.yd-mi:hover { background: var(--brand-soft); color: var(--brand); }
.yd-mi.danger { color: #e5484d; }
.yd-mi.danger:hover { background: rgba(229, 72, 77, .12); color: #e5484d; }

.yd-mask { display: none; position: fixed; inset: 0; background: rgba(12, 14, 22, .55);
  z-index: 200; align-items: center; justify-content: center; padding: 18px; }
.yd-modal { background: var(--panel); color: var(--fg); width: 100%; max-width: 400px;
  border-radius: 18px; padding: 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.yd-tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.yd-tab { border: 0; background: none; color: var(--muted); font-size: 15px; font-weight: 600;
  padding: 4px 10px; border-radius: 8px; }
.yd-tab.active { color: var(--brand); background: var(--brand-soft); }
.yd-x { margin-left: auto; cursor: pointer; color: var(--muted); padding: 2px 8px; }
.yd-sub { font-size: 12.5px; color: var(--muted); margin: 6px 0 14px; }
.yd-f { margin-bottom: 12px; }
.yd-f label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.yd-f input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--fg); font-size: 14px; }
.yd-f input:focus { outline: none; border-color: var(--brand); }
.yd-err { color: #e5484d; font-size: 12.5px; min-height: 18px; }
.yd-actions { margin-top: 6px; }
.yd-btn { width: 100%; border: 0; border-radius: 10px; padding: 11px; font-size: 14.5px; font-weight: 600; }
.yd-btn.primary { background: var(--bubble-user); color: #fff; }
.yd-btn:disabled { opacity: .6; }
.yd-tip { font-size: 11.5px; color: var(--muted); margin-top: 10px; text-align: center; }

/* ---- 我的账户页 ---- */
.acct-body { background: var(--bg); }
.acct { max-width: 1080px; margin: 0 auto; padding: 18px 16px 60px; }
.acct-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.acct-back { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--fg); font-weight: 700; }
.logo.sm { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--bubble-user); color: #fff; font-weight: 800; font-size: 14px; }
.acct-hero { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.acct-who { display: flex; align-items: center; gap: 14px; }
.acct-ava { width: 54px; height: 54px; border-radius: 16px; background: var(--bubble-user); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 800; overflow: hidden; flex: 0 0 auto; }
.acct-ava img { width: 100%; height: 100%; object-fit: cover; }
.acct-who h1 { margin: 0; font-size: 20px; }
.acct-mail { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.acct-role { margin-left: auto; font-size: 12px; padding: 4px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.acct-role.admin { background: rgba(229, 72, 77, .12); color: #e5484d; }
.acct-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.acct-stat { flex: 1 1 110px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; }
.acct-stat b { display: block; font-size: 18px; }
.acct-stat span { font-size: 12px; color: var(--muted); }
.acct-grid { display: grid; gap: 16px; }
.acct-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); }
.acct-card.guest { border-color: var(--brand); background: linear-gradient(180deg, var(--brand-soft), transparent); }
.acct-card.guest h2 { margin: 0 0 8px; font-size: 17px; }
.acct-card.guest p { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; }
.acct-card h2 { margin: 0; font-size: 16.5px; }
.acct-card h3 { margin: 18px 0 8px; font-size: 14px; }
.cnt { color: var(--muted); font-weight: 400; font-size: 13px; }
.acct-card-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.acct-tools { display: flex; gap: 8px; align-items: center; }
.acct-tools input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--fg); font-size: 13px; min-width: 190px; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.xs { padding: 5px 10px; font-size: 12.5px; }
.btn.danger { color: #e5484d; border-color: rgba(229, 72, 77, .35); }
.sess-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.sess-row { display: flex; gap: 10px; align-items: center; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--bg); cursor: pointer; }
.sess-row:hover { border-color: var(--brand); }
.sess-row.active { border-color: var(--brand); background: var(--brand-soft); }
.sr-main { min-width: 0; flex: 1; }
.sr-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { color: var(--muted); font-size: 12px; display: flex; gap: 5px; flex-wrap: wrap; }
.sr-act { display: flex; gap: 6px; flex: 0 0 auto; }
.dt-meta { color: var(--muted); font-size: 12px; display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0; }
.dt-body { display: flex; flex-direction: column; gap: 12px; max-height: 62vh; overflow: auto; padding-right: 4px; }
.dt-msg { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.dt-msg.me { background: var(--brand-soft); }
.dt-who { font-size: 12px; color: var(--muted); margin-bottom: 5px; display: flex; gap: 8px; }
.dt-msg.me .dt-who { color: var(--brand); font-weight: 600; }
.dt-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.dt-text img { max-width: 100%; border-radius: 10px; }
.dt-tools { font-size: 12px; color: var(--muted); margin-top: 6px; }
.dt-jobs { border-top: 1px dashed var(--border); padding-top: 10px; }
.dt-jobs h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.dt-job { font-size: 13px; padding: 6px 0; }
.dt-job .dim { color: var(--muted); }
.empty { color: var(--muted); font-size: 13.5px; padding: 14px 2px; }
.acct-note { font-size: 12.5px; margin-top: 10px; min-height: 16px; color: var(--muted); }
.acct-note.ok { color: #128a4b; }
.acct-note.bad { color: #e5484d; }
.acct-hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0 0; }
.acct-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 22px; }
@media (max-width: 640px) {
  .acct { padding: 12px 12px 50px; }
  .acct-role { margin-left: 0; }
  .acct-who { flex-wrap: wrap; }
  .acct-tools { width: 100%; }
  .acct-tools input { min-width: 0; flex: 1; }
  .sr-act { flex-direction: column; }
}

.side-acct { float: right; font-size: 12px; text-decoration: none; color: var(--brand); font-weight: 500; }
.side-label { display: flex; justify-content: space-between; align-items: center; }
.side-foot .side-user { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.sess-empty { color: var(--muted); font-size: 12.5px; padding: 10px 4px; }
