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

:root {
  --bg: #0d0f14;
  --bg2: #13161e;
  --surface: #1a1d27;
  --surface2: #21253a;
  --border: rgba(255,255,255,0.07);
  --accent: #7c6af7;
  --accent2: #a78bfa;
  --accent-glow: rgba(124,106,247,0.25);
  --text: #e8eaf0;
  --text2: #9499b0;
  --text3: #5a5f7a;
  --green: #34d399;
  --orange: #fb923c;
  --radius: 16px;
  --radius-sm: 10px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Noto Serif SC', system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}
.orb-1 { width: 600px; height: 600px; background: #7c6af7; top: -200px; left: -100px; animation: drift 20s ease-in-out infinite; }
.orb-2 { width: 400px; height: 400px; background: #06b6d4; bottom: 100px; right: -100px; animation: drift 25s ease-in-out infinite reverse; }
.orb-3 { width: 300px; height: 300px; background: #f472b6; top: 50%; left: 50%; animation: drift 18s ease-in-out infinite 5s; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 0 24px;
  background: rgba(13,15,20,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  height: 60px; display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.logo-icon { font-size: 20px; color: var(--accent2); }
.logo-text { font-weight: 600; font-size: 16px; letter-spacing: 0.02em; }
.nav { display: flex; gap: 4px; }
.nav-link {
  color: var(--text2); text-decoration: none; font-size: 14px;
  padding: 6px 14px; border-radius: 8px; transition: all 0.2s;
}
.nav-link:hover { color: var(--text); background: var(--surface); }

/* 登录 */
.twin-login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; padding: 120px 24px 40px;
  display: flex; align-items: center; justify-content: center;
}
.twin-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%; max-width: 380px;
}
.login-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.login-desc { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.login-actions .btn-primary {
  display: block; width: 100%; text-align: center;
  padding: 12px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; text-decoration: none; font-size: 14px; font-weight: 500;
  border: none; cursor: pointer; margin-bottom: 16px;
}
.login-actions .btn-primary:hover { opacity: 0.9; }
.login-or { color: var(--text3); font-size: 12px; text-align: center; margin: 16px 0 12px; }
.form-group { margin-bottom: 12px; }
.form-group input {
  width: 100%; padding: 10px 14px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.twin-login-card .error-msg { margin-top: 12px; }

/* 主布局：侧边栏 + 对话 */
.twin-main { position: relative; z-index: 1; padding: 100px 24px 40px; max-width: 1100px; margin: 0 auto; }
.twin-layout { display: flex; gap: 24px; margin-top: 24px; align-items: flex-start; }
.twin-sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 180px);
}
.sidebar-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-title { font-size: 13px; font-weight: 600; color: var(--text2); }
.btn-new-conv {
  background: var(--accent);
  color: #fff; border: none;
  padding: 6px 12px; border-radius: 8px;
  font-size: 12px; cursor: pointer;
  transition: opacity 0.2s;
}
.btn-new-conv:hover { opacity: 0.9; }
.conv-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.conv-item {
  padding: 10px 16px;
  font-size: 13px; color: var(--text2);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.conv-item:hover { background: var(--surface2); color: var(--text); }
.conv-item.active { background: rgba(124,106,247,0.1); border-left-color: var(--accent); color: var(--text); }
.conv-item-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 24px;
}
.conv-item-time { font-size: 11px; color: var(--text3); margin-top: 2px; }

.conv-delete-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--text3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conv-item:hover .conv-delete-btn {
  opacity: 1;
}

.conv-delete-btn:hover {
  background: rgba(251,146,60,0.2);
  color: var(--orange);
}
.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text3);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-link { color: var(--accent2); text-decoration: none; }
.sidebar-link:hover { text-decoration: underline; }
.chat-section { flex: 1; min-width: 0; }

.twin-hero { text-align: center; margin-bottom: 40px; }
.twin-hero .hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(124,106,247,0.15); border: 1px solid rgba(124,106,247,0.3);
  color: var(--accent2); font-size: 12px; font-weight: 500; letter-spacing: 0.08em;
  padding: 5px 14px; border-radius: 100px; margin-bottom: 16px;
}
.twin-title {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 700; line-height: 1.2;
  background: linear-gradient(135deg, #fff 0%, var(--accent2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}
.twin-desc { color: var(--text2); font-size: 15px; line-height: 1.7; }

.chat-section { margin-top: 24px; }
.chat-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 420px;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 320px;
  max-height: 60vh;
}

.msg { display: flex; gap: 12px; align-items: flex-start; animation: msgIn 0.25s ease; }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-user { flex-direction: row-reverse; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.msg-user .msg-avatar { background: var(--surface2); color: var(--accent2); }
.msg-twin .msg-avatar { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.msg-bubble {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.65;
}
.msg-user .msg-bubble { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.msg-twin .msg-bubble { background: rgba(124,106,247,0.12); border: 1px solid rgba(124,106,247,0.25); color: var(--text); }
.msg-bubble p { margin-bottom: 0.5em; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-meta { font-size: 12px; color: var(--text3); margin-top: 6px; }

.loading-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.loading-bubble .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent2);
  opacity: 0.4;
  animation: twin-dot 1s infinite ease-in-out;
}
.loading-bubble .dot:nth-child(2) { animation-delay: 0.15s; }
.loading-bubble .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes twin-dot {
  0%, 100% { transform: translateY(0); opacity: 0.3; }
  50% { transform: translateY(-3px); opacity: 1; }
}

.input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.input-area textarea {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 16px;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  transition: border-color 0.2s;
}
.input-area textarea::placeholder { color: var(--text3); }
.input-area textarea:focus {
  outline: none;
  border-color: rgba(124,106,247,0.4);
}
.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.send-btn:hover { opacity: 0.9; }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.empty-hint {
  color: var(--text2);
  font-size: 14px;
  text-align: center;
  padding: 60px 20px;
  max-width: 600px;
  margin: 0 auto;
}
.empty-hint p { margin-bottom: 8px; }

.welcome-greeting {
  margin-bottom: 40px;
}

.welcome-greeting h2 {
  font-family: 'Noto Serif SC', serif;
  font-size: 28px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.welcome-greeting p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text2);
}

.topic-suggestions {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 32px;
}

.suggestion-title {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 16px;
  text-align: left;
}

.topic-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.topic-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateX(4px);
}

.topic-btn:last-child {
  margin-bottom: 0;
}

.error-msg {
  background: rgba(251,146,60,0.1);
  border: 1px solid rgba(251,146,60,0.3);
  color: var(--orange);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 8px;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }

@media (max-width: 600px) {
  .twin-main { padding: 88px 16px 24px; }
  .msg-bubble { max-width: 92%; }
}
