/* 三木森空间 · AI助手 · 三木森调性 + Kimi风格 */

:root {
  --primary: #254364;
  --primary-light: #3a5a80;
  --accent: #f0a030;
  --accent-light: #f5b860;
  --bg: #fffef8;
  --sidebar-bg: #1a2d3f;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --user-bubble: #254364;
  --ai-bubble: #f5f0e8;
  --danger: #c0392b;
  --success: #27ae60;
  --shadow: 0 2px 12px rgba(37,67,100,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin-bottom: 10px;
  object-fit: cover;
}

.sidebar-brand {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sidebar-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 1px;
  margin-top: 2px;
}

.new-chat-btn {
  margin: 16px 16px 8px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.new-chat-btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.new-chat-btn .icon {
  font-size: 18px;
  line-height: 1;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.chat-item {
  padding: 10px 12px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s;
}

.chat-item:hover,
.chat-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-link {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.footer-link:hover {
  background: rgba(255,255,255,0.08);
}

/* ===== 主区域 ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-width: 0;
}

/* 顶部栏 */
.topbar {
  height: 56px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.topbar-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.topbar-actions {
  margin-left: auto;
}

.action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* 消息区 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scroll-behavior: smooth;
}

/* 欢迎页 */
.welcome {
  max-width: 640px;
  margin: 40px auto;
  text-align: center;
}

.welcome-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-bottom: 16px;
}

.welcome h1 {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 8px;
}

.welcome p {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 24px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
}

.quick-btn {
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.quick-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* 消息气泡 */
.message {
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--primary);
}

.message.user {
  margin-left: auto;
  justify-content: flex-end;
}

.message.ai {
  margin-right: auto;
  max-width: 80%;
}

.bubble {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  flex: 1 1 auto;
  min-width: 0;
}

.message.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.ai .bubble {
  background: var(--ai-bubble);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble pre {
  background: rgba(0,0,0,0.05);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}

.bubble code {
  background: rgba(0,0,0,0.05);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.bubble p {
  margin: 6px 0;
}

.bubble ul, .bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.bubble li {
  margin: 4px 0;
}

/* 打字光标 */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 18px;
  background: var(--accent);
  animation: blink 1s infinite;
  vertical-align: middle;
  margin-left: 2px;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 输入区 */
.input-wrap {
  padding: 12px 20px 16px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,67,100,0.08);
}

.input-box textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 120px;
  outline: none;
  font-family: inherit;
  color: var(--text);
}

.input-box textarea::placeholder {
  color: #aaa;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--primary-light);
  transform: scale(1.05);
}

.send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.input-hint {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  margin-top: 8px;
}

/* 错误 */
.error {
  color: var(--danger);
  font-size: 13px;
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-btn {
    display: block;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 90%;
  }

  .topbar-title span {
    display: none;
  }
}
