/* multi-agent-service — 登录页与聊天页共用。颜色全是 token,深浅色各一套。 */
:root {
  --bg: #eef1f3;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --line: #d9dfe3;
  --text: #1d2428;
  --muted: #64707a;
  --accent: #2f6d62;
  --accent-text: #ffffff;
  --accent-soft: #e2efec;
  --her-bubble: #ffffff;
  --her-text: #1d2428;
  --me-bubble: #2f6d62;
  --me-text: #f4faf8;
  --danger: #b4423a;
  --danger-soft: #fbeceb;
  --shadow: 0 1px 2px rgba(20, 32, 40, 0.06);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Noto Sans CJK SC", "Source Han Sans SC", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121618;
    --surface: #1a1f22;
    --surface-2: #20262a;
    --line: #2d3539;
    --text: #e4e9ec;
    --muted: #8d9aa3;
    --accent: #5fa697;
    --accent-text: #0e1513;
    --accent-soft: #1d2f2b;
    --her-bubble: #232a2e;
    --her-text: #e4e9ec;
    --me-bubble: #2c5e55;
    --me-text: #eef7f4;
    --danger: #e0786f;
    --danger-soft: #3a2220;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121618; --surface: #1a1f22; --surface-2: #20262a; --line: #2d3539; --text: #e4e9ec; --muted: #8d9aa3;
  --accent: #5fa697; --accent-text: #0e1513; --accent-soft: #1d2f2b; --her-bubble: #232a2e; --her-text: #e4e9ec;
  --me-bubble: #2c5e55; --me-text: #eef7f4; --danger: #e0786f; --danger-soft: #3a2220; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.55; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px 24px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.login-card h1 { font-size: 22px; margin: 0; letter-spacing: 0.02em; text-wrap: balance; }
.login-card .sub { margin: -8px 0 4px; color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; }
.field input {
  height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); outline: none;
}
.field input:focus { border-color: var(--accent); background: var(--surface); }
.btn {
  height: 44px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-text);
  font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.form-error { min-height: 1.4em; margin: -4px 0 0; color: var(--danger); font-size: 14px; }

/* ---------- 聊天 ---------- */
.app { height: 100%; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto;
       background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.who .name { font-weight: 600; }
.who .status { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status[data-tone="ok"]::before, .status[data-tone="warn"]::before, .status[data-tone="off"]::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px;
  vertical-align: 1px; background: var(--muted);
}
.status[data-tone="ok"]::before { background: var(--accent); }
.status[data-tone="warn"]::before { background: #c08a2b; }
.topbar .me { font-size: 13px; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 4px; }
.link-btn:hover { color: var(--text); }

.banner { display: none; padding: 6px 16px; font-size: 13px; background: var(--danger-soft); color: var(--danger);
          text-align: center; }
.banner.show { display: block; }

.messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 4px;
            overscroll-behavior: contain; }
.older { align-self: center; font-size: 12px; color: var(--muted); padding: 4px 0 8px; }
.timesep { align-self: center; font-size: 12px; color: var(--muted); margin: 12px 0 6px;
           font-variant-numeric: tabular-nums; }
.sysline { align-self: center; font-size: 12px; color: var(--muted); margin: 8px 0; text-align: center;
           max-width: 80%; overflow-wrap: anywhere; }
.row { display: flex; }
.row.me { justify-content: flex-end; }
.row.her { justify-content: flex-start; }
.bubble {
  max-width: min(78%, 520px); padding: 8px 12px; border-radius: var(--radius); white-space: pre-wrap;
  overflow-wrap: anywhere; box-shadow: var(--shadow);
}
.row.her .bubble { background: var(--her-bubble); color: var(--her-text); border: 1px solid var(--line);
                   border-top-left-radius: 6px; }
.row.me .bubble { background: var(--me-bubble); color: var(--me-text); border-top-right-radius: 6px; }
.row.me.pending .bubble { opacity: 0.6; }
.row.me.failed .bubble { background: var(--danger-soft); color: var(--danger); }
.row + .row.her, .row + .row.me { margin-top: 2px; }
.row.her + .row.me, .row.me + .row.her { margin-top: 10px; }
.note { font-size: 12px; color: var(--danger); text-align: right; margin: 2px 4px 6px; }
.bubble.enter { animation: rise 180ms ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.typing .bubble { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.typing .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.toast { display: none; margin: 0 16px 8px; padding: 8px 12px; border-radius: 10px; font-size: 14px;
         background: var(--danger-soft); color: var(--danger); }
.toast.show { display: block; }

.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
            border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea {
  flex: 1; min-height: 44px; max-height: 160px; resize: none; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); outline: none; line-height: 1.45;
}
.composer textarea:focus { border-color: var(--accent); background: var(--surface); }
.composer .btn { padding: 0 18px; flex: none; }
.empty { margin: auto; color: var(--muted); font-size: 14px; text-align: center; padding: 24px; }

@media (prefers-reduced-motion: reduce) {
  .bubble.enter { animation: none; }
  .typing .dot { animation: none; opacity: 0.6; }
}
@media (min-width: 761px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
