:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222c;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #6aa6ff;
  --user: #2b3a55;
  --bot: #1b1f28;
  --err: #ff7a7a;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }

/* 登录注册 */
.auth-wrap {
  max-width: 420px;
  margin: 8vh auto;
  padding: 28px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.brand h1 { margin: 0; font-size: 26px; letter-spacing: 2px; }
.brand .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 8px; margin: 20px 0 16px; }

.tab {
  flex: 1;
  padding: 8px 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.tab.active { color: var(--text); border-color: var(--accent); background: rgba(106, 166, 255, 0.08); }

.panel { display: flex; flex-direction: column; gap: 12px; }

.seg { display: flex; gap: 4px; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }

.seg-btn {
  flex: 1;
  padding: 7px 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.seg-btn.active { background: var(--panel); color: var(--text); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field.grow { flex: 1; }

input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}

input:focus { border-color: var(--accent); }

.row { display: flex; gap: 10px; align-items: flex-end; }

.hint { font-size: 12px; color: var(--muted); min-height: 16px; }
.hint.bad { color: var(--err); }
.hint.good { color: #7ddc9a; }

.msg { min-height: 20px; margin: 0; font-size: 13px; color: var(--err); }
.msg.ok { color: #7ddc9a; }

button { font-family: inherit; }

.primary {
  padding: 11px 0;
  background: var(--accent);
  color: #08101f;
  border: 0;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.primary:disabled { opacity: 0.5; cursor: default; }

.ghost {
  padding: 10px 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}

.ghost:disabled { opacity: 0.45; cursor: default; }
.ghost.small { padding: 6px 10px; font-size: 13px; }

.foot { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* 滑块拼图 */
.veil {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.captcha-box {
  width: 344px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.captcha-title { margin: 0 0 10px; font-size: 13px; color: var(--muted); }

.captcha-stage {
  position: relative;
  width: 320px;
  height: 160px;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  user-select: none;
  touch-action: none;
}

.captcha-stage img { width: 100%; height: 100%; display: block; }

.captcha-piece {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.captcha-track {
  position: relative;
  margin-top: 12px;
  height: 40px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.captcha-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(106, 166, 255, 0.22); }

.captcha-handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 52px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #08101f;
  font-weight: 700;
  border-radius: 9px;
  cursor: grab;
}

.captcha-handle:active { cursor: grabbing; }

.captcha-text { position: absolute; right: 12px; top: 9px; font-size: 12px; color: var(--muted); }

.captcha-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }

/* 对话页 */
.chat-body { display: flex; flex-direction: column; height: 100vh; }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.chat-title { display: flex; align-items: baseline; gap: 10px; }
.chat-title .sub { font-size: 12px; color: var(--muted); }
.chat-actions { display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: var(--muted); }

.log { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.log > #load-more { align-self: center; margin-bottom: 4px; }

.intro { color: var(--muted); font-size: 13px; text-align: center; margin-top: 8vh; }
.intro p { margin: 4px 0; }

.bubble { max-width: 72%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.bot.pending::after { content: "●"; color: var(--muted); animation: blink 1.1s infinite; }
.bubble.error { align-self: center; color: var(--err); font-size: 13px; background: transparent; border: 0; }

@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

.composer { display: flex; gap: 10px; padding: 14px 18px 18px; border-top: 1px solid var(--line); background: var(--panel); }

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  padding: 11px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  outline: none;
}

.composer textarea:focus { border-color: var(--accent); }
.composer .primary { width: 88px; }

.link {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover { color: var(--text); }

.panel-title { margin: 0 0 4px; font-size: 15px; }

.dialog {
  width: 344px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-title { margin: 0; font-size: 16px; }

.sect { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }

.sect h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dialog.wide { width: 400px; max-height: 86vh; overflow-y: auto; }

.device-list { display: flex; flex-direction: column; gap: 8px; }

.device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}

.device .meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.device .meta small { color: var(--muted); font-size: 12px; }
.device .tag { color: #7ddc9a; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.primary.small { padding: 8px 16px; font-size: 13px; width: auto; }
h1 { letter-spacing: 2px; }
