/* ========== Comic Style 组件库（style-tokens.md 落地） ========== */

/* 半调网点背景 */
.halftone {
  background-image: radial-gradient(circle, rgba(26, 26, 26, 0.18) 1px, transparent 1px);
  background-size: 6px 6px;
}

/* 墨线卡片 */
.comic-card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* 墨线面板（页面主容器） */
.comic-panel {
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ========== 按钮 ========== */
.comic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 4px solid var(--ink);
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 14px;
  box-shadow: var(--shadow);
  transition: all 0.15s ease-out;
  user-select: none;
}
.comic-btn:hover { transform: scale(1.05) rotate(-2deg); box-shadow: 6px 6px 0 0 var(--ink); }
.comic-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.comic-btn:disabled { opacity: 0.6; pointer-events: none; }
.comic-btn-yellow { background: var(--yellow); color: var(--ink); }
.comic-btn-blue { background: var(--blue); color: #fff; }
.comic-btn-ghost { background: transparent; color: var(--ink); box-shadow: none; }
.comic-btn-ghost:hover { background: var(--yellow); transform: scale(1.05) rotate(-2deg); box-shadow: 3px 3px 0 0 var(--ink); }
.comic-btn-sm { padding: 6px 12px; font-size: 12px; border-width: 3px; box-shadow: 3px 3px 0 0 rgba(26,26,26,1); }

/* ========== 输入框 ========== */
.comic-input {
  width: 100%;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: box-shadow 0.15s;
}
.comic-input:focus { box-shadow: var(--shadow); }
.comic-input::placeholder { color: #4a4a4a; opacity: 0.6; }

/* ========== 对话气泡 ========== */
.bubble {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.bubble-user {
  max-width: min(72%, 720px); /* 用户短消息保持紧凑 */
}
.bubble-ai {
  align-self: stretch; /* 拉伸消息区可用宽度（max-width 内），长内容不再缩成窄条 */
  max-width: min(94%, 860px);
}
.bubble-user {
  background: var(--red);
  color: #fff;
  align-self: flex-end;
}
.bubble-ai {
  background: #fff;
  color: var(--ink);
}

/* ========== 思考中动效 ========== */
.bubble.thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #666;
  padding: 14px 18px;
}
.td { display: inline-flex; gap: 4px; }
.td i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #999;
  animation: tk-bounce 1.2s infinite ease-in-out;
}
.td i:nth-child(2) { animation-delay: 0.15s; }
.td i:nth-child(3) { animation-delay: 0.3s; }
@keyframes tk-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ========== 气泡内 Markdown 渲染 ========== */
.bubble-ai p, .bubble-ai li, .bubble-ai h1, .bubble-ai h2, .bubble-ai h3, .bubble-ai blockquote { white-space: normal; }
.bubble-ai :is(h1, h2, h3) { margin: 0.5em 0 0.3em; line-height: 1.3; }
.bubble-ai ul, .bubble-ai ol { margin: 0.4em 0; padding-left: 1.5em; }
.bubble-ai li { margin: 0.15em 0; }
.bubble-ai code {
  background: rgba(0, 0, 0, 0.09);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9em;
  color: #b3233a;
}
.bubble-ai pre {
  background: #1e2329;
  border-radius: 10px;
  padding: 9px 12px;
  overflow-x: auto;
  margin: 0.45em 0;
  white-space: pre;
}
.bubble-ai pre code {
  background: none;
  padding: 0;
  color: #e6e6e6;
  font-size: 12px;
  line-height: 1.5;
}
.bubble-ai a { color: var(--blue, #2b6cb0); text-decoration: underline; word-break: break-all; }
.bubble-ai img { max-width: 100%; border-radius: 8px; }
.bubble-ai table { border-collapse: collapse; margin: 0.5em 0; width: 100%; table-layout: auto; }
.bubble-ai th, .bubble-ai td { border: 1px solid #e2e2e2; padding: 5px 8px; text-align: left; }
.bubble-ai blockquote {
  border-left: 5px solid var(--yellow, #ffd60a);
  padding-left: 12px;
  color: #555;
  margin: 0.5em 0;
}
.bubble-ai hr { border: none; border-top: 3px dashed #ccc; margin: 0.6em 0; }
.bubble-user code {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9em;
}
.bubble-user a { color: #fff; text-decoration: underline; }

/* ========== 徽章 / LOGO / 顶栏 ========== */
.tag {
  display: inline-block;
  background: var(--yellow);
  border: 3px solid var(--ink);
  font-weight: 900;
  padding: 2px 10px;
  transform: rotate(-2deg);
  font-size: 12px;
}
.logo {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 22px;
  line-height: 1;
}
.logo .hl { color: var(--red); }
.logo .spark { color: var(--blue); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  border-bottom: 3px solid var(--ink);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* ========== 会话列表项 ========== */
.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s ease-out;
  font-weight: 700;
  font-size: 13px;
}
.conv-item:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 0 var(--ink); }
.conv-item.active { background: var(--yellow); box-shadow: var(--shadow); }
.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-del {
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 900;
  color: var(--ink);
  padding: 0 4px;
  opacity: 0.5;
}
.conv-item .conv-del:hover { opacity: 1; color: var(--red); }

/* ========== 打字指示 ========== */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
  width: 8px; height: 8px;
  background: var(--ink);
  border-radius: 50%;
  animation: blink 1s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

/* 弹出动画 */
@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.pop-in { animation: pop-in 0.25s ease-out both; }

/* ========== 表单页布局 ========== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tab {
  flex: 1;
  padding: 8px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: transparent;
  font-weight: 900;
  text-transform: uppercase;
  font-size: 13px;
  transition: all 0.15s;
}
.auth-tab.active { background: var(--yellow); box-shadow: 3px 3px 0 0 var(--ink); }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-weight: 900; font-size: 12px; margin-bottom: 6px; text-transform: uppercase; }
.auth-err { margin-top: 12px; color: #fff; background: var(--red); border: 3px solid var(--ink); border-radius: 8px; padding: 8px 12px; font-weight: 700; font-size: 13px; }
.auth-ok { margin-top: 12px; color: var(--ink); background: var(--green); border: 3px solid var(--ink); border-radius: 8px; padding: 8px 12px; font-weight: 700; font-size: 13px; }
