:root {
  --bg: #FAF6F3;
  --card: #ffffff;
  --ink: #2A2320;
  --muted: #6E5852;
  --line: #ECE2DC;
  --rose: #C0524C;
  --rose-deep: #A23F3A;
  --rose-soft: #FBEEEA;
  --ok: #2F7D54;
  --err: #B3322B;
  --shadow: 0 6px 24px rgba(80, 40, 35, .08);
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
a { color: var(--rose-deep); }

/* 显隐:由 body class 控制 */
#login, #app { display: none; }
body.state-login #login { display: flex; }
body.state-app #app { display: flex; }

/* ---- 登录 ---- */
.login { min-height: 100%; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 18px; }
.card {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px 26px; display: flex; flex-direction: column; gap: 14px;
}
.logo { margin: 0; font-size: 22px; letter-spacing: .04em; }
.sub { margin: 0 0 4px; color: var(--muted); font-size: 14px; line-height: 1.6; }
input[type=password], textarea, .site-select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  font: inherit; color: var(--ink); background: #fff; outline: none;
}
.site-select { appearance: none; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input[type=password]:focus, textarea:focus, .site-select:focus { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }
.site-label { font-size: 16px; font-weight: 600; color: var(--ink); padding: 10px 0 2px; border-bottom: 1px solid var(--line); }
#loginBtn, #sendBtn {
  border: 0; background: var(--rose); color: #fff; border-radius: 10px; padding: 12px 16px; font-weight: 600; letter-spacing: .03em;
  transition: background .15s;
}
#loginBtn:hover, #sendBtn:hover { background: var(--rose-deep); }
#loginBtn:disabled, #sendBtn:disabled { opacity: .55; cursor: default; }
.err { margin: 0; color: var(--err); font-size: 13px; }
.foot { color: var(--muted); font-size: 12px; }

/* ---- 控制台 ---- */
.app { min-height: 100%; flex-direction: column; max-width: 760px; margin: 0 auto; width: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; background: rgba(250,246,243,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.site-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live { font-size: 13px; white-space: nowrap; text-decoration: none; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }
.ghost { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 8px; padding: 7px 11px; font-size: 13px; }
.ghost:hover { color: var(--rose-deep); border-color: var(--rose); }

.banner { margin: 10px 16px -2px; background: #FFF6E6; border: 1px solid #F0DCB0; color: #8A6516; border-radius: 10px; padding: 9px 13px; font-size: 13px; }

.chat { flex: 1; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 14px; line-height: 1.6; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--rose); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.bot .status { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.msg.bot.ok { border-color: #BFE3CD; background: #F2FBF5; }
.msg.bot.bad { border-color: #F0C9C6; background: #FCF2F1; }
.msg .meta { display: block; margin-top: 7px; font-size: 12px; color: var(--muted); }
.msg .meta a { margin-right: 10px; }
.hint { align-self: center; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.7; max-width: 90%; }

.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--rose); border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg); position: sticky; bottom: 0; }
.composer textarea { resize: none; max-height: 140px; line-height: 1.5; }
#sendBtn { white-space: nowrap; height: 44px; }
.tip { margin: 0 16px 14px; color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ---- 图片附件 ---- */
.icon-btn { flex-shrink: 0; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 10px; cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
.icon-btn:hover { color: var(--rose-deep); border-color: var(--rose); background: var(--rose-soft); }
.icon-btn svg { display: block; }
.attach-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 16px 0; }
.attach-chip { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.attach-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-chip.loading { opacity: .6; }
.attach-chip.err { border-color: var(--err); }
.attach-chip .chip-badge { position: absolute; left: 0; top: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 11px; padding: 0 4px; border-bottom-right-radius: 6px; }
.attach-chip .chip-x { position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; line-height: 16px; text-align: center; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; cursor: pointer; padding: 0; }
.msg-imgs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.msg-imgs img { max-width: 140px; max-height: 140px; border-radius: 8px; display: block; }

/* ---- 顶部"未上线改动"条 ---- */
.pending-bar { position: sticky; top: 57px; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 10px 16px -2px; background: #FFF6E6; border: 1px solid #F0DCB0; color: #8A6516; border-radius: 10px; padding: 9px 13px; font-size: 13px; box-shadow: 0 4px 14px rgba(138,101,22,.10); }
.pending-btns { display: flex; align-items: center; gap: 8px; }
.pending-link { color: var(--rose-deep); text-decoration: none; font-weight: 600; }
.pending-pub { border: 0; background: var(--ok); color: #fff; border-radius: 8px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.pending-dis { border: 1px solid #E5D3A6; background: #fff; color: #8A6516; border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }

/* ---- 拖拽上传提示 ---- */
.drop-hint { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(192,82,76,.10); backdrop-filter: blur(2px); }
.drop-hint__box { border: 2px dashed var(--rose); background: #fff; color: var(--rose-deep); font-size: 16px; font-weight: 600; padding: 24px 36px; border-radius: 16px; box-shadow: var(--shadow); }

/* ---- 实时进度行 ---- */
.proglog { display: flex; flex-direction: column; gap: 4px; }
.proglog:empty { display: none; }
.progline { font-size: 13.5px; line-height: 1.55; word-break: break-word; }
.progline.act { color: var(--muted); }
.progline.say { color: var(--ink); }
.msg.bot .final { margin-top: 8px; line-height: 1.6; }
.msg.bot .proglog + .final { padding-top: 8px; border-top: 1px solid var(--line); }

/* ---- 历史抽屉 ---- */
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(380px, 88vw); background: #fff; z-index: 20;
  border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(80,40,35,.12); display: flex; flex-direction: column; padding: 16px;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.history { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.history li { padding: 11px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.history .h-sub { color: var(--ink); line-height: 1.5; }
.history .h-meta { color: var(--muted); font-size: 12px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.drawer-foot { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.scrim { position: fixed; inset: 0; background: rgba(40,25,22,.32); z-index: 15; }

@media (max-width: 480px) {
  .msg { max-width: 92%; }
  .site-name { font-size: 14px; }
}
