/* 清谈（chat.boringlab.xin）— 水墨夜话配色，与青莲居同源 */
:root {
  --ink: #1f1a17;
  --paper: #f6f0e2;
  --cinnabar: #b03a2e;
  --cinnabar-dark: #8e2b21;
  --gold: #c9a86a;
  --night: #0a0f25;
  --night-2: #131a33;
  --moonlight: #fdf6e3;
  --line: rgba(201, 168, 106, 0.22);
  --font-serif: 'STKaiti', 'KaiTi', '华文楷体', 'Songti SC', 'SimSun', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--moonlight);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

/* 背景墨晕 */
.wash {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1100px 620px at 12% -6%, rgba(176, 58, 46, 0.13), transparent 62%),
    radial-gradient(900px 700px at 96% 8%, rgba(201, 168, 106, 0.10), transparent 60%),
    radial-gradient(1000px 800px at 50% 108%, rgba(58, 74, 130, 0.20), transparent 66%);
}

.wrap { width: min(860px, 100%); margin: 0 auto; padding: 0 18px; position: relative; z-index: 1; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(10, 15, 37, 0.92), rgba(10, 15, 37, 0.62));
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-seal {
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(176, 58, 46, 0.86);
  border-radius: 4px;
  color: #f7ead6;
  font-family: var(--font-serif);
  font-size: 17px;
  transform: rotate(4deg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.brand-name { font-family: var(--font-serif); font-size: 20px; letter-spacing: 3px; color: var(--moonlight); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-sub { font-family: var(--font-serif); font-size: 11px; letter-spacing: 2px; color: rgba(212, 222, 238, 0.5); }

/* ===== 消息 ===== */
.thread { padding: 26px 0 8px; display: flex; flex-direction: column; gap: 20px; }
.msg { display: flex; gap: 12px; animation: rise 0.32s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg .avatar {
  width: 30px; height: 30px; flex: none; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 14px;
}
.msg.ai .avatar { background: rgba(176, 58, 46, 0.8); color: #f7ead6; }
.msg.user .avatar { background: rgba(201, 168, 106, 0.16); color: var(--gold); border: 1px solid var(--line); }
.bubble {
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.95;
  padding: 13px 17px;
  border-radius: 3px;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.ai .bubble {
  background: linear-gradient(180deg, rgba(246, 240, 226, 0.055), rgba(246, 240, 226, 0.03));
  border: 1px solid var(--line);
  border-left: 2px solid rgba(176, 58, 46, 0.6);
  color: var(--moonlight);
  flex: 1;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .bubble {
  background: rgba(201, 168, 106, 0.10);
  border: 1px solid rgba(201, 168, 106, 0.28);
  color: #f3e9d2;
  max-width: 78%;
}
.bubble p { margin: 0 0 0.75em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble pre {
  background: rgba(6, 9, 22, 0.72);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 10px 13px;
  overflow-x: auto;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
}
.bubble code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.92em;
  background: rgba(6, 9, 22, 0.6);
  padding: 1px 5px;
  border-radius: 2px;
  color: #ecd9a8;
}
.bubble pre code { background: none; padding: 0; color: inherit; }
.bubble strong { color: var(--gold); }
.caret {
  display: inline-block; width: 7px; height: 1.05em;
  background: var(--cinnabar); vertical-align: -2px; margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.msg-err { color: #e8a89e; font-family: var(--font-serif); font-size: 14px; }

.thread-empty { text-align: center; padding: 6vh 0 2vh; }
.thread-empty .glyph { font-family: var(--font-serif); font-size: 46px; color: rgba(201, 168, 106, 0.28); letter-spacing: 8px; }
.thread-empty .line { font-family: var(--font-serif); color: rgba(212, 222, 238, 0.55); letter-spacing: 2px; margin-top: 10px; }

/* ===== 输入区 ===== */
.composer {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(19, 26, 51, 0.95), rgba(10, 15, 37, 0.97));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
}
#input {
  width: 100%;
  min-height: 46px;
  max-height: 190px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--moonlight);
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.8;
}
#input::placeholder { color: rgba(212, 222, 238, 0.38); }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.hint { font-size: 12px; color: rgba(212, 222, 238, 0.45); }

/* ===== 按钮 ===== */
.btn {
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 2px;
  padding: 8px 20px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.22s;
}
.btn-primary { background: rgba(176, 58, 46, 0.88); color: #f7ead6; }
.btn-primary:hover:not(:disabled) { background: var(--cinnabar-dark); box-shadow: 0 4px 16px rgba(176, 58, 46, 0.4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--line); color: rgba(212, 222, 238, 0.75); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-sm { padding: 5px 13px; font-size: 13px; }

/* ===== 提示条 ===== */
.notice {
  margin-top: 16px;
  padding: 11px 15px;
  border-radius: 3px;
  font-family: var(--font-serif);
  font-size: 14.5px;
}
.notice.danger { background: rgba(176, 58, 46, 0.14); border: 1px solid rgba(176, 58, 46, 0.42); color: #eec3b8; }

/* ===== 页脚 ===== */
.footer {
  text-align: center;
  padding: 34px 18px 40px;
  font-size: 12.5px;
  color: rgba(212, 222, 238, 0.42);
  position: relative;
  z-index: 1;
}
.footer a { color: rgba(212, 222, 238, 0.6); text-decoration: none; }
.footer a:hover { color: var(--gold); }
.site-lineage { margin-bottom: 8px; font-family: var(--font-serif); letter-spacing: 2px; }
.site-lineage .dot { margin: 0 9px; opacity: 0.45; }

/* ===== 访问口令 ===== */
.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 22, 0.9);
  backdrop-filter: blur(6px);
  padding: 20px;
}
.gate-card {
  width: min(360px, 100%);
  text-align: center;
  padding: 30px 26px 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(19, 26, 51, 0.98), rgba(10, 15, 37, 0.98));
}
.gate-seal {
  width: 46px; height: 46px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(176, 58, 46, 0.86);
  border-radius: 4px;
  color: #f7ead6;
  font-family: var(--font-serif);
  font-size: 23px;
  transform: rotate(4deg);
}
.gate-card h2 { font-family: var(--font-serif); font-size: 19px; letter-spacing: 3px; margin: 0 0 6px; font-weight: normal; }
.gate-card p { font-family: var(--font-serif); font-size: 13.5px; color: rgba(212, 222, 238, 0.55); margin: 0 0 18px; }
#gateInput {
  width: 100%;
  padding: 10px 13px;
  margin-bottom: 12px;
  background: rgba(6, 9, 22, 0.6);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--moonlight);
  font-family: var(--font-serif);
  font-size: 16px;
  text-align: center;
  letter-spacing: 3px;
  outline: none;
}
#gateInput:focus { border-color: var(--gold); }
#gateBtn { width: 100%; }
.gate-err { margin-top: 10px; min-height: 18px; font-size: 13px; color: #e8a89e; }

@media (max-width: 560px) {
  .msg.user .bubble { max-width: 88%; }
  .brand-sub { display: none; }
  .thread { padding-top: 18px; }
}
