:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --font-mono: 'Fira Code', 'Consolas', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* 导航栏 */
.navbar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  position: sticky;
  top: 16px;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
  margin-right: auto;
}
.nav-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav-btn {
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-light);
  transition: all 0.2s;
}
.nav-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.nav-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.user-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.user-badge {
  background: #f1f5f9;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.btn-login, .btn-logout {
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-login {
  background: var(--primary);
  color: white;
  border: none;
}
.btn-login:hover { background: var(--primary-dark); }
.btn-logout {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-logout:hover { background: #fef2f2; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card h2 { font-size: 1.4rem; margin-bottom: 16px; color: var(--text); }
.card h3 { font-size: 1.1rem; margin: 12px 0 8px; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-light);
  font-size: 14px;
}
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border 0.2s, box-shadow 0.2s;
  background: #fafbfc;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  background: white;
}
textarea { resize: vertical; min-height: 120px; }
.code-editor {
  font-family: var(--font-mono);
  background: #1e293b;
  color: #e2e8f0;
  border: none;
  min-height: 300px;
  padding: 16px;
  border-radius: 8px;
}
.btn {
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s, transform 0.1s;
  display: inline-block;
}
.btn:hover { background: var(--primary-light); }
.btn:active { transform: scale(0.97); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: #eef2ff; }

/* 网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.app-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.app-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-child { background: #d1fae5; color: #065f46; }
.badge-adult { background: #fee2e2; color: #991b1b; }
.app-meta { font-size: 12px; color: var(--text-light); display: flex; justify-content: space-between; }
.app-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* 评论区 */
.comment-list { list-style: none; margin-top: 12px; }
.comment-item {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  border-left: 3px solid var(--primary-light);
}
.comment-author {
  font-weight: 600;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.comment-author .time { font-size: 12px; color: var(--text-light); font-weight: 400; }
.comment-content { color: var(--text); margin-top: 4px; }
.reply-form { margin-top: 8px; padding-left: 16px; }
.reply-form textarea { width: 100%; margin-bottom: 4px; min-height: 40px; }

/* 聊天 */
.chat-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.chat-msg { padding: 8px 12px; margin-bottom: 8px; border-radius: 8px; background: white; box-shadow: var(--shadow); }
.chat-msg strong { color: var(--primary); margin-right: 8px; }
.chat-input { display: flex; gap: 8px; }
.chat-input input { flex: 1; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; margin-left: 6px; }
.tag-open { background: #fef3c7; color: #92400e; }
.tag-closed { background: #e0e7ff; color: #3730a3; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-content {
  background: white; border-radius: var(--radius);
  padding: 24px; width: 90%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 24px; border-radius: 8px; color: white;
  font-weight: 600; z-index: 9999; animation: slideIn 0.3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.markdown-body { padding: 10px 0; line-height: 1.6; color: var(--text); }
.markdown-body h1, .markdown-body h2 { margin-top: 12px; margin-bottom: 8px; }
.markdown-body code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.markdown-body pre {
  background: #1e293b; color: #e2e8f0;
  padding: 12px; border-radius: 8px; overflow-x: auto;
}

@media (max-width: 768px) {
  .navbar { flex-direction: column; align-items: flex-start; }
  .grid { grid-template-columns: 1fr; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }