/* 夜曲对话 · 暗色单主题 · 发丝线 · 信号红唯一强调色 · 零外部字体 */

:root {
  --bg: #070c0c;
  --raised: #0d1413;
  --overlay: #131b19;
  --border: #1f2b28;
  --accent: #e8462c;
  --accent-dim: #a63520;
  --ink: #ece9e2;
  --muted: #8f948f;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

/* ============ 口令门 ============ */
#gate { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-box { width: 100%; max-width: 340px; text-align: center; }
.gate-eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em;
  color: var(--muted); text-transform: uppercase; margin-bottom: 20px;
}
.gate-title { font-family: var(--serif); font-weight: 400; font-size: 42px; letter-spacing: 0.04em; }
.gate-title em { font-style: italic; color: var(--accent); }
.gate-sub { color: var(--muted); font-size: 13px; margin: 14px 0 30px; }
#pass-form { display: flex; gap: 10px; }
#pass-input {
  flex: 1; min-width: 0; background: transparent; border: 0;
  border-bottom: 1px solid var(--border); padding: 10px 2px; outline: none;
  letter-spacing: 0.3em; transition: border-color 0.2s;
}
#pass-input:focus { border-bottom-color: var(--accent); }
#pass-form button {
  background: var(--accent); color: #fff; border: 0; border-radius: 2px;
  padding: 10px 22px; cursor: pointer; font-size: 14px;
}
#pass-form button:active { background: var(--accent-dim); }
.gate-err { margin-top: 18px; color: var(--accent); font-size: 13px; }

/* ============ 顶栏 ============ */
#app { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-serif { font-family: var(--serif); font-size: 18px; letter-spacing: 0.08em; }
.brand-mono {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em;
  color: var(--muted); text-transform: uppercase;
}
.ghost-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 2px;
  color: var(--muted); font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  padding: 6px 12px; cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.ghost-btn:hover, .ghost-btn:focus-visible { color: var(--ink); border-color: var(--accent); }

/* ============ 会话区 ============ */
#thread { flex: 1; overflow-y: auto; padding: 20px 16px 28px; overscroll-behavior: contain; }
.thread-inner { max-width: 720px; margin: 0 auto; }
.msg { margin-bottom: 24px; }

.msg-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.msg.user .msg-head { justify-content: flex-end; }

.msg.user .bubble {
  background: var(--overlay); border: 1px solid var(--border); border-radius: 2px;
  padding: 10px 14px; max-width: 82%; margin-left: auto;
  white-space: pre-wrap; word-break: break-word;
}

.msg.assistant .body { word-break: break-word; }
.msg.assistant .body p { margin: 0 0 12px; }
.msg.assistant .body p:last-child { margin-bottom: 0; }
.msg.assistant .body h2, .msg.assistant .body h3, .msg.assistant .body h4 { font-size: 16px; margin: 18px 0 8px; font-weight: 600; }
.msg.assistant .body ul, .msg.assistant .body ol { margin: 0 0 12px; padding-left: 20px; }
.msg.assistant .body li { margin-bottom: 4px; }
.msg.assistant .body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.msg.assistant .body strong { font-weight: 600; }
.msg.assistant .body code {
  font-family: var(--mono); font-size: 13px;
  background: var(--overlay); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 2px;
}
.msg.assistant .body pre {
  background: var(--raised); border: 1px solid var(--border); border-radius: 2px;
  padding: 12px 14px; overflow-x: auto; margin: 0 0 12px;
}
.msg.assistant .body pre code { background: transparent; border: 0; padding: 0; font-size: 12.5px; line-height: 1.6; }

.caret {
  display: inline-block; width: 8px; height: 15px;
  background: var(--accent); vertical-align: -2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.msg.error .body { color: var(--accent); font-size: 13.5px; }
.msg.notice .body { color: var(--muted); font-size: 12px; font-family: var(--mono); letter-spacing: 0.08em; }

/* ============ 签名元素：五线谱呼吸（回复生成中） ============ */
.staff { width: 44px; height: 20px; flex: none; }
.staff line { stroke: var(--border); stroke-width: 1; }
.staff .note { fill: var(--accent); }
.msg.streaming .staff line { stroke: #233632; }
.msg.streaming .staff .note { animation: glide 2.4s linear infinite; }
@keyframes glide {
  from { transform: translateX(4px); }
  to   { transform: translateX(36px); }
}

/* ============ 输入区 ============ */
.composer { border-top: 1px solid var(--border); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
.composer-inner {
  max-width: 720px; margin: 0 auto;
  display: flex; gap: 10px; align-items: flex-end;
  padding: 12px 16px 6px;
}
#input {
  flex: 1; min-width: 0;
  background: var(--raised); border: 1px solid var(--border); border-radius: 2px;
  padding: 10px 12px; resize: none; max-height: 140px; outline: none;
  line-height: 1.5; transition: border-color 0.15s;
}
#input:focus { border-color: var(--accent); }
#send {
  width: 42px; height: 42px; flex: none;
  background: var(--accent); border: 0; border-radius: 2px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
#send:active { background: var(--accent-dim); }
#send svg { stroke: #fff; }
#send.stop svg { stroke: none; fill: #fff; }
.composer-note {
  max-width: 720px; margin: 0 auto;
  padding: 2px 16px 8px; text-align: center;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em;
  color: var(--muted); text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .msg.streaming .staff .note { animation: none; }
  .caret { animation: none; }
}
@media (min-width: 640px) {
  body { font-size: 16px; }
  #thread { padding-top: 28px; }
}
