:root {
  --bg: #f6f6f8;
  --panel: #ffffff;
  --panel-2: #fafafc;
  --text: #1b1b20;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-2: #eef0f3;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 18, 27, .05), 0 4px 16px rgba(16, 18, 27, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
        "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand small { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 12px; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 13px;
}
.topnav a:hover { background: var(--panel-2); text-decoration: none; }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
.spacer { flex: 1; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }
.wrap.narrow { max-width: 720px; }

/* ---------- 组件 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.grid { display: grid; gap: 14px; }
.grid.cols3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.cols2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer;
  font-size: 13px; font-family: inherit;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--panel); color: var(--text);
  font: inherit; font-size: 13px;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.7; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.field { margin-bottom: 4px; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; margin-right: 6px;
}
.tag.gray { background: var(--line-2); color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.section-title { font-size: 15px; font-weight: 650; margin: 0 0 12px; }
.divider { height: 1px; background: var(--line-2); margin: 16px 0; }

.alert { padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 12px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a; }
.alert.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #a7f3d0; }
.alert.info { background: var(--accent-soft); color: var(--accent); border: 1px solid #c7d2fe; }

/* ---------- 发现页 ---------- */
.plot-card { cursor: pointer; transition: border-color .15s, transform .1s; }
.plot-card:hover { border-color: #c7cbf5; }
.plot-title { font-weight: 650; font-size: 15px; margin-bottom: 6px; }
.plot-sum { color: var(--muted); font-size: 13px; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 对话页 ---------- */
.chat-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
@media (max-width: 900px) { .chat-layout { grid-template-columns: 1fr; } }

.thread { display: flex; flex-direction: column; gap: 12px;
  max-height: 62vh; overflow-y: auto; padding: 4px; }
.msg { padding: 10px 14px; border-radius: 12px; max-width: 86%; line-height: 1.75; }
.msg.user { background: var(--accent-soft); align-self: flex-end; }
.msg.assistant { background: var(--panel-2); border: 1px solid var(--line-2); align-self: flex-start; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
/* 感知 TTFT：气泡在点击发送的瞬间就出现，不等模型第一个字。
   用户在等待期间看到的是「对方正在说」，而不是一片空白。 */
.msg.typing { color: var(--muted); }
.msg.typing .txt::after {
  content: "···"; letter-spacing: 2px; animation: typingDots 1.2s ease-in-out infinite;
}
@keyframes typingDots { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { flex: 1; min-height: 46px; }

.memory-panel { font-size: 12px; }
.memory-panel h4 { margin: 14px 0 6px; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; }
.fact-item { padding: 6px 8px; background: var(--panel-2); border-radius: 7px;
  margin-bottom: 5px; border: 1px solid var(--line-2); }
.fact-item b { font-weight: 600; }

/* ---------- 后台 ---------- */
.admin-layout { display: grid; grid-template-columns: 190px 1fr; gap: 0; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; }
.sidebar a {
  display: block; padding: 8px 12px; border-radius: 8px;
  color: var(--text); font-size: 13px; margin-bottom: 2px;
}
.sidebar a:hover { background: var(--panel-2); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.admin-main { padding: 22px 24px; max-width: 980px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--panel-2); }
tr:hover td { background: var(--panel-2); }

.kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi .card { padding: 14px; }
.kpi .v { font-size: 22px; font-weight: 680; }
.kpi .k { font-size: 12px; color: var(--muted); }

.risk-line { font-size: 12px; color: var(--danger); margin-top: 4px; }
.summary-zh { font-size: 13px; background: var(--panel-2); padding: 8px 10px;
  border-radius: 8px; border: 1px solid var(--line-2); }

.switch-row { display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: var(--panel); padding: 6px 12px;
  cursor: pointer; font-size: 12px; font-family: inherit; color: var(--muted); }
.seg button.on { background: var(--accent); color: #fff; }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- H5 手机版式（仅 C 端，#app 不存在于后台页） ----------
   95% 用户用手机访问：栅格按手机宽度固化，不再依赖视口媒体查询——
   桌面浏览器里看到的是同一个手机宽度版式（居中窄栏），与 zeta 一致。 */
#app { min-height: 100dvh; }
/* 手机宽度下 topbar 内容必须收进一栏：去副标题、压间距，防止横向溢出 */
#app .topbar { gap: 8px; padding: 0 12px; height: 52px; }
#app .brand { font-size: 15px; white-space: nowrap; }
#app .brand small { display: none; }
#app .topnav { gap: 2px; min-width: 0; }
#app .topnav a { padding: 6px 8px; font-size: 13px; white-space: nowrap; }
#app .topbar select { width: auto; flex: none; font-size: 12px; padding: 6px 6px; }
#app .chat-layout { grid-template-columns: 1fr; }        /* 记忆面板改到对话下方 */
#app .grid.cols3 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
#app .grid.cols2 { grid-template-columns: 1fr; }
#app .wrap { max-width: 560px; margin: 0 auto; padding: 16px 14px 48px; }
#app .thread { max-height: calc(100dvh - 300px); min-height: 320px; }
#app .plot-card { padding: 14px; }
#app .plot-sum { -webkit-line-clamp: 3; }
/* 发现页头部：说明文字独占一行，排序+搜索换行并排 */
#app .discover-head { flex-wrap: wrap; row-gap: 10px; }
#app .discover-head > div:first-child { flex: 1 1 100% !important; }
#app .discover-head select { width: auto; flex: none; }
#app .discover-head input { flex: 1 1 auto; width: auto !important; }
/* 窄屏（真手机）再压一档 topbar，防止导航被语言选择器挤出 */
@media (max-width: 420px) {
  #app .topbar { gap: 6px; }
  #app .topnav a { padding: 6px 6px; font-size: 12.5px; }
  #app .topbar select { font-size: 11px; padding: 5px 4px; }
}

@media (min-width: 640px) {
  /* 仅 C 端需要「手机窄栏 + 暗色留白」的外框；后台页无 #app，
     绝不能跟着变暗（否则白卡浮在黑底上，就是登录页此前显粗糙的主因）。 */
  body:has(#app) { background: #14151a; }
  #app {
    max-width: 480px; margin: 0 auto; background: var(--bg);
    box-shadow: 0 0 48px rgba(0, 0, 0, .5);
  }
  #app .topbar { padding: 0 14px; }
}

/* ==========================================================================
   运营后台 · 登录页
   --------------------------------------------------------------------------
   后台其余页面是浅色工具界面（克制好读），但登录页承担「品牌第一印象」，
   所以这里单独做一次更强的视觉表达：柔和的紫 / 琥珀氛围光 + 白卡 +
   紫色渐变主按钮 —— 与 logo（紫渐变 + 金色星芒）同源，也和后台的
   indigo 主色一脉相承。所有规则限定在 .login-page / .login-card 作用域。
   ========================================================================== */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(42rem 30rem at 10% -12%, rgba(109, 91, 246, .18), transparent 60%),
    radial-gradient(36rem 26rem at 102% 112%, rgba(217, 164, 65, .20), transparent 58%),
    linear-gradient(180deg, #f7f7fb 0%, #eceef7 100%);
}

.login-card {
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid rgba(16, 18, 27, .07);
  border-radius: 20px;
  padding: 34px 30px 24px;
  box-shadow: 0 1px 2px rgba(16, 18, 27, .05),
              0 24px 60px -24px rgba(16, 18, 27, .38);
  animation: loginRise .5s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes loginRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .login-card { animation: none; }
}

/* ---- 品牌区 ---- */
.login-brand {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; margin-bottom: 24px;
}
.login-logo {
  width: 58px; height: 58px;
  filter: drop-shadow(0 10px 20px rgba(79, 70, 229, .35));
}
.login-word {
  margin-top: 12px;
  font-family: "Fraunces", Georgia, "Songti SC", "Noto Serif SC", serif;
  font-size: 24px; font-weight: 650; letter-spacing: .01em; color: #1b1b20;
}
.login-sub {
  margin-top: 9px; display: inline-block;
  padding: 3px 12px; border-radius: 999px;
  background: #eef2ff; color: #4f46e5;
  font-size: 12px; font-weight: 600; letter-spacing: .1em;
}

/* ---- 表单 ---- */
.login-card .field { margin-bottom: 15px; }
.login-card label { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: #4b5563; }
.login-card input {
  height: 44px; border-radius: 11px; font-size: 14px;
  background: #fbfbfd; border-color: #e2e5ec;
}
.login-card input::placeholder { color: #b7bcc7; }
.login-card input:focus {
  outline: none; background: #fff;
  border-color: #6d5bf6; box-shadow: 0 0 0 4px rgba(109, 91, 246, .15);
}

.login-pass { position: relative; }
.login-pass input { padding-right: 62px; }
.login-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; cursor: pointer;
  font: 600 12px/1 inherit; color: #8b90a0;
  padding: 8px 10px; border-radius: 8px;
}
.login-eye:hover { color: #4f46e5; background: rgba(79, 70, 229, .08); }

.login-submit {
  width: 100%; height: 46px; margin-top: 19px;
  border: none; border-radius: 12px;
  font-size: 14.5px; font-weight: 650; color: #fff; letter-spacing: .06em;
  background: linear-gradient(135deg, #6d5bf6 0%, #4f46e5 100%);
  box-shadow: 0 12px 24px -12px rgba(79, 70, 229, .8);
  transition: transform .12s ease, filter .2s ease;
}
.login-submit:hover { filter: brightness(1.06); }
.login-submit:active { transform: translateY(1px); }
.login-submit:disabled { opacity: .72; cursor: default; filter: none; }

.login-msg:not(:empty) { margin-top: 14px; }
.login-msg .alert { margin-bottom: 0; }

.login-foot {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid #eef0f3;
  font-size: 12px; line-height: 1.65; color: #8b90a0; text-align: center;
}
