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

:root {
  --bg: #fff;
  --bg-2: #f8f8f8;
  --text: #111;
  --text-2: #444;
  --text-3: #888;
  --border: #e5e5e5;
  --accent: #2563eb;
  --font: system-ui, -apple-system, sans-serif;
  --mono: 'Menlo', 'Monaco', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

nav {
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
}
nav a {
  font-size: 0.8125rem;
  color: var(--text-3);
  text-decoration: none;
}
nav a:hover { color: var(--text); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 40px 80px;
}

/* Hero */
.hero {
  padding: 64px 0 56px;
  border-bottom: 1px solid var(--border);
}
.label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 20px;
}
h1 {
  font-size: 2.75rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}
.sub {
  font-size: 1rem;
  color: var(--text-2);
  max-width: 560px;
  line-height: 1.7;
}

/* Demo sections */
.demo-section {
  padding: 56px 0;
  border-bottom: 1px solid var(--border);
}
.demo-section.last { border-bottom: none; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

h2 {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.section-desc {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 28px;
  max-width: 620px;
}
code {
  font-family: var(--mono);
  font-size: 0.8125rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Skeleton shimmer ─────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #efefef 25%, #f8f8f8 50%, #efefef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

/* ── Posts grid ───────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* Skeleton post card */
.post-skel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.post-skel .skel-badge {
  width: 32px;
  height: 18px;
}
.post-skel .skel-title {
  height: 14px;
  width: 85%;
}
.post-skel .skel-title-2 {
  height: 14px;
  width: 60%;
}
.post-skel .skel-body {
  height: 12px;
  width: 100%;
}
.post-skel .skel-body-2 {
  height: 12px;
  width: 75%;
}
.post-skel .skel-link {
  height: 12px;
  width: 80px;
  margin-top: 4px;
}

/* Real post card */
.post-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}
.post-card:hover { border-color: #bbb; }

.post-id {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  width: fit-content;
}
.post-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-body {
  font-size: 0.8125rem;
  color: var(--text-2);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-link {
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
  margin-top: 4px;
}
.post-link:hover { text-decoration: underline; }

/* Error banner */
.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  font-size: 0.875rem;
}
.error-icon { font-size: 1rem; flex-shrink: 0; }
.error-msg  { flex: 1; }
.retry-btn {
  padding: 6px 14px;
  border: 1px solid #fca5a5;
  background: #fff;
  color: #991b1b;
  font-family: var(--font);
  font-size: 0.8125rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.retry-btn:hover { background: #fef2f2; }

.error-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-3);
  font-family: var(--font);
  font-size: 0.8125rem;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.error-btn:hover { border-color: #fca5a5; color: #991b1b; }

/* ── Profile area ─────────────────────────────────────────────── */
.profile-area {
  min-height: 80px;
  display: flex;
  align-items: flex-start;
}

.load-btn {
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.load-btn:hover { background: #1d4ed8; }
.load-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Profile card */
.profile-card {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
}
.profile-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.profile-detail {
  font-size: 0.8125rem;
  color: var(--text-2);
  line-height: 1.8;
}
.profile-detail a {
  color: var(--accent);
  text-decoration: none;
}
.profile-detail a:hover { text-decoration: underline; }

/* ── Search / user list ───────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.search-input {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  flex: 1;
  max-width: 400px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.match-count {
  font-size: 0.8125rem;
  color: var(--text-3);
  white-space: nowrap;
}

.user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.user-item:last-child { border-bottom: none; }

/* Skeleton user rows */
.user-skeleton span:first-child {
  width: 120px;
  height: 13px;
  border-radius: 4px;
}
.user-skeleton span:last-child {
  width: 180px;
  height: 13px;
  border-radius: 4px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.user-email {
  font-size: 0.8125rem;
  color: var(--text-3);
}

.no-results {
  padding: 32px 0;
  color: var(--text-3);
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 640px) {
  nav { padding: 16px 20px; }
  main { padding: 0 20px 60px; }
  h1 { font-size: 2rem; }
  .posts-grid { grid-template-columns: 1fr; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-input { max-width: 100%; }
}
