/* ═══════════════════════════════════════════
   LUMI · 技能工坊 — 完整样式表
   ═══════════════════════════════════════════ */

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-subtle: #E0E7FF;
  --bg: #F8F9FB;
  --surface: #FFFFFF;
  --text: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --accent: #059669;
  --error: #DC2626;
  --user-bubble: #EEF2FF;
  --ai-bubble: #FFFFFF;
  --font-sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10);
}

/* ── Reset ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
textarea { font: inherit; resize: none; }

/* ── View Switching ──────────────────────── */
.view { display: none; }
.view.active { display: flex; flex-direction: column; min-height: 100dvh; }

/* ═══════════════════════════════════════════
   HUB VIEW
   ═══════════════════════════════════════════ */
.hub-header {
  text-align: center;
  padding: 60px 20px 32px;
}
.logo {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.logo-accent { color: var(--primary); }
.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-top: 8px;
}
.hub-main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.skill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}
.skill-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.skill-card-icon {
  font-size: 32px;
  margin-bottom: 12px;
}
.skill-card-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.skill-card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.skill-card-placeholder {
  border-style: dashed;
  opacity: .6;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--text-muted);
  font-size: 14px;
}
.skill-card-placeholder:hover {
  transform: none;
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.hub-footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  font-size: 16px;
}

/* Skeleton loading */
.skeleton { cursor: default; pointer-events: none; }
.skeleton-line {
  height: 14px;
  background: var(--border-light);
  border-radius: 4px;
  margin-bottom: 8px;
  animation: shimmer 1.5s infinite;
}
.skeleton-line:last-child { margin-bottom: 0; }
.w-60 { width: 60%; }
.w-80 { width: 80%; }
@keyframes shimmer {
  0% { opacity: 1; }
  50% { opacity: .5; }
  100% { opacity: 1; }
}

/* ═══════════════════════════════════════════
   CHAT VIEW
   ═══════════════════════════════════════════ */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.btn-back {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-back:hover { background: var(--border-light); }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h2 {
  font-size: 17px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-new-chat {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  font-size: 20px; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.btn-new-chat:hover { background: var(--border-light); }

/* Messages */
.chat-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}
.chat-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.chat-empty-icon { font-size: 40px; margin-bottom: 12px; }

.message {
  display: flex;
  flex-direction: column;
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message-user {
  align-items: flex-end;
}
.message-ai {
  align-items: flex-start;
}
.message-bubble {
  max-width: 85%;
  padding: 12px 16px;
  line-height: 1.7;
  word-break: break-word;
}
.message-user .message-bubble {
  background: var(--user-bubble);
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
  color: var(--text);
}
.message-ai .message-bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
}
.message-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

/* Markdown in AI bubbles */
.message-ai .message-bubble h1,
.message-ai .message-bubble h2,
.message-ai .message-bubble h3 {
  margin: 16px 0 8px;
  line-height: 1.4;
}
.message-ai .message-bubble h2 { font-size: 18px; }
.message-ai .message-bubble h3 { font-size: 16px; }
.message-ai .message-bubble p { margin: 8px 0; }
.message-ai .message-bubble ul, .message-ai .message-bubble ol { margin: 8px 0; padding-left: 20px; }
.message-ai .message-bubble li { margin: 4px 0; }
.message-ai .message-bubble strong { font-weight: 600; color: var(--text); }
.message-ai .message-bubble code {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--border-light);
  padding: 2px 6px;
  border-radius: 4px;
}
.message-ai .message-bubble pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.5;
}
.message-ai .message-bubble pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}
.message-ai .message-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 14px;
}
.message-ai .message-bubble th {
  background: var(--border-light);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.message-ai .message-bubble td {
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.message-ai .message-bubble blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}
.chat-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.4s infinite both;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input */
.chat-footer {
  padding: 12px 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.chat-input-wrap {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color .2s;
}
.chat-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  line-height: 1.5;
  padding: 4px 0;
  max-height: 120px;
  color: var(--text);
}
.chat-input::placeholder { color: var(--text-muted); }
.btn-upload {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: color .2s, background .2s;
}
.btn-upload:hover { color: var(--primary); background: var(--primary-light); }
.btn-send {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .2s, opacity .2s;
}
.btn-send:hover { background: var(--primary-hover); }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }

/* Image previews */
.image-previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 800px;
  margin: 0 auto 8px;
  padding: 0 4px;
}
.image-previews:empty { display: none; }
.image-preview {
  position: relative;
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.image-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.image-preview .remove-btn {
  position: absolute;
  top: 2px; right: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.image-preview .remove-btn:hover { background: rgba(0,0,0,.8); }

/* Image in chat bubbles */
.message-bubble img {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  margin: 8px 0;
  cursor: pointer;
}

/* Error toast */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--error);
  color: #fff;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: 14px;
  z-index: 100;
  animation: toastIn .3s ease, toastOut .3s ease 3s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(-12px); } }

/* ── Responsive ──────────────────────────── */
@media (max-width: 640px) {
  .skill-grid { grid-template-columns: 1fr; }
  .hub-header { padding: 40px 16px 24px; }
  .logo { font-size: 26px; }
  .message-bubble { max-width: 92%; }
}

@media (min-width: 1024px) {
  .skill-grid { grid-template-columns: repeat(3, 1fr); }
}
