:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --line: #e4e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --user-bubble: #2563eb;
  --user-text: #ffffff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.bg-image {
  position: fixed;
  inset: 0;
  background: url("/static/hit-bg.jpg") center/cover no-repeat;
  opacity: 0.16;
  z-index: 0;
  pointer-events: none;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(37, 99, 235, 0.10), transparent 62%),
    radial-gradient(900px 480px at 108% 6%, rgba(14, 165, 233, 0.08), transparent 58%),
    radial-gradient(800px 600px at 50% 115%, rgba(59, 130, 246, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

.topbar,
.main-wrap,
.inputbar {
  position: relative;
  z-index: 1;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  font-size: 17px;
  font-weight: 600;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-label {
  font-size: 15px;
}

.user-input {
  width: 190px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--card);
}

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

.btn-ghost {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 主体: 侧栏 + 聊天 ---------- */
.main-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 20px;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  align-self: flex-start;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
}

.side-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}

.side-card h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text);
}

.side-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.side-card ul {
  margin: 0;
  padding-left: 2px;
  list-style: none;
  font-size: 12px;
  color: var(--text);
  line-height: 1.7;
}

.side-card .tech p {
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text);
}

.tip {
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.tip:last-child {
  margin-bottom: 0;
}

.tip-example {
  color: var(--muted);
  padding-left: 18px;
  margin-top: 2px;
}

/* ---------- 聊天区 ---------- */
.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 56px 16px 32px;
  animation: fadein 0.4s ease;
}

.empty-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.empty-state h2 {
  color: var(--text);
  margin: 0 0 8px;
  font-size: 22px;
}

.empty-sub {
  margin: 0 0 22px;
  font-size: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
}

.chip {
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg {
  display: flex;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.msg.assistant .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.bubble .status {
  color: var(--muted);
  font-size: 13px;
}

.bubble .cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent);
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* 来源折叠框 */
.bubble details {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.bubble summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  outline: none;
}

.bubble .sources {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.bubble .meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.bubble blockquote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

/* ---------- 输入栏 ---------- */
.inputbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0 18px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.user-hint {
  display: none;
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 7px 10px;
}

.user-hint.flash {
  animation: hintpulse 1.2s ease;
}

@keyframes hintpulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.inputbar textarea {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  max-height: 120px;
  background: var(--card);
}

.inputbar textarea:focus {
  border-color: var(--accent);
}

.btn-primary {
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.btn-primary:disabled {
  background: #c7d2fe;
  cursor: not-allowed;
}

@media (max-width: 560px) {
  .user-input { width: 130px; }
  .bubble { max-width: 92%; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  body { max-width: 880px; }
}
