:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #e2e8f1;
  --text: #1b2430;
  --muted: #6b7889;
  --accent: #2f6fd0;
  --accent-soft: #e8f0fd;
  --ok: #2e9e6b;
  --warn: #c98a22;
  --err: #c2453d;
  --shadow: 0 1px 3px rgba(20, 40, 80, .06), 0 8px 24px rgba(20, 40, 80, .05);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a22;
    --surface: #1c242f;
    --line: #2c3846;
    --text: #e6edf5;
    --muted: #93a2b4;
    --accent: #7fb0f5;
    --accent-soft: #22354d;
    --ok: #59c996;
    --warn: #e0b45c;
    --err: #f0837b;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { width: 40px; height: 40px; flex: none; }
h1 { margin: 0; font-size: 19px; letter-spacing: .2px; }
.sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.status, .dot { display: inline-flex; align-items: center; }
.status { gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.dot.off { background: var(--warn); }
#gwStatus.ready { color: var(--ok); }
#gwStatus.down { color: var(--err); }

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  padding: 20px 26px 28px;
  max-width: 1280px; margin: 0 auto;
  align-items: start;
}
.side { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.tiny { font-size: 11.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.55; }
.muted { color: var(--muted); font-weight: 400; }
.hidden { display: none; }

label { display: block; font-size: 12.5px; margin: 12px 0 5px; font-weight: 600; }
input[type=text], input[type=password], input[type=search] {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 14px; outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  border: 1px solid transparent; border-radius: 9px;
  padding: 9px 16px; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: filter .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { filter: brightness(1.06); }
.btn.primary { background: var(--accent); color: #fff; width: 100%; margin-top: 16px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); border-color: var(--line); }
#btnLogout { width: 100%; }

.emailBox { margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.emailBox summary { cursor: pointer; }
.emailBox .btn { width: auto; margin-top: 8px; padding: 6px 12px; font-size: 12px; }
.emailBox .muted { display: block; margin-top: 8px; font-size: 12px; }

.msg { margin-top: 10px; font-size: 12.5px; min-height: 18px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

.houses { list-style: none; margin: 0; padding: 0; }
.houses li { position: relative; padding: 9px 0 9px 20px; border-bottom: 1px solid var(--line); font-size: 13px; }
.houses li:last-child { border-bottom: 0; }
.houses .dot { position: absolute; left: 2px; top: 16px; }
.houses .muted { font-size: 12px; }

.caps { font-size: 12.5px; }
.cap {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.cap:last-child { border-bottom: 0; }
.cap code { color: var(--accent); }

.searchRow { display: flex; gap: 10px; }
.searchRow input { flex: 1; }
.searchRow .btn { width: auto; margin: 0; padding: 9px 24px; flex: none; }
.quick { margin: 12px 0 4px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 11px; font: inherit; font-size: 12px; cursor: pointer;
}
.meta { font-size: 12px; color: var(--muted); margin: 14px 0 8px; }
.results { display: flex; flex-direction: column; gap: 10px; }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); font-size: 13.5px; }
.hit {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; background: var(--bg);
}
.hit .title { font-size: 13px; font-weight: 650; margin-bottom: 5px; word-break: break-all; }
.hit .body { font-size: 13px; white-space: pre-wrap; word-break: break-word; max-height: 190px; overflow: auto; }
.hit .tags { margin-top: 7px; font-size: 11.5px; color: var(--muted); }
mark { background: color-mix(in srgb, var(--accent) 25%, transparent); color: inherit; padding: 0 2px; border-radius: 2px; }

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 26px 24px; font-size: 11.5px; color: var(--muted);
  max-width: 1280px; margin: 0 auto;
}
code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .topbar { padding: 14px 16px; }
  .foot { padding: 12px 16px 20px; }
}

/* ---- 聊天 ---- */
.chatLog {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 260px; max-height: 52vh; overflow-y: auto;
  padding: 14px 4px 8px;
}
.bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.bubble.me {
  align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.fish {
  align-self: flex-start; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-bottom-left-radius: 4px;
}
.chatRow { display: flex; gap: 8px; margin-top: 6px; }
.chatRow input {
  flex: 1; padding: 11px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text);
}
.settingsBox {
  margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.settingsBox summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.settingsBox label { display: block; margin: 10px 0 5px; font-size: 12.5px; color: var(--muted); }
.settingsBox input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.settingsBox .tiny { margin: 8px 0; line-height: 1.7; }
