:root {
  --bg: #ffffff;
  --fg: #202124;
  --muted: #5f6368;
  --border: #dfe1e5;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --visited: #609;
  --url-color: #006621;
  --card-bg: #f8f9fa;
  --mark-bg: #fff3b0;
  --shadow: rgba(32, 33, 36, 0.28);
  --radius: 24px;
  --font: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  --success: #0f9d58;
  --error: #d93025;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --border: #3c4043;
    --accent: #8ab4f8;
    --accent-hover: #aecbfa;
    --visited: #c58af9;
    --url-color: #6dd58c;
    --card-bg: #303134;
    --mark-bg: #5c4a12;
    --shadow: rgba(0, 0, 0, 0.5);
    --success: #5bb974;
    --error: #f28b82;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--card-bg); padding: 0.1em 0.35em; border-radius: 4px; }
pre code { background: none; padding: 0; }
small { color: var(--muted); font-size: 0.85em; }

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.8rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar-nav { display: flex; gap: 1rem; margin-left: auto; }
.topbar-nav a { color: var(--muted); font-size: 0.9rem; }
.topbar-nav a:hover { color: var(--fg); }

.logo { font-weight: 500; color: var(--fg); letter-spacing: -0.3px; }
.logo--large { font-size: 2.5rem; margin-bottom: 1.5rem; text-align: center; }
.logo--small { font-size: 1.15rem; white-space: nowrap; }

/* ── Hero / Home ────────────────────────────────────────────── */
.hero { min-height: 85vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.hero-inner { text-align: center; max-width: 720px; }
.hero h1 { font-size: 3rem; font-weight: 700; margin-bottom: 0.5rem; }
.hero-subtitle { font-size: 1.2rem; color: var(--muted); margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 3rem; }
.hero-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; text-align: left; }
.feature { background: var(--card-bg); border-radius: 12px; padding: 1.25rem; }
.feature h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.feature p { font-size: 0.9rem; color: var(--muted); }

/* ── Buttons ───────────────────────────────────────────────── */
.button {
  display: inline-block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 1.25rem;
  color: var(--fg);
  font-size: 0.95rem;
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.button:hover { border-color: var(--accent); box-shadow: 0 1px 3px var(--shadow); text-decoration: none; }
.button--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button--full { width: 100%; text-align: center; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.3rem; font-size: 0.9rem; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 0.95rem;
  font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15); }
.form-group small { display: block; margin-top: 0.25rem; }

/* ── Auth ──────────────────────────────────────────────────── */
.auth-page { display: flex; flex-direction: column; min-height: 100vh; }
.auth-form { flex: 1; max-width: 400px; margin: 3rem auto; padding: 0 1.5rem; text-align: center; }
.auth-form h1 { margin-bottom: 0.3rem; }
.auth-desc { color: var(--muted); margin-bottom: 1.5rem; }
.auth-alt { margin-top: 1.5rem; font-size: 0.9rem; color: var(--muted); }

.alert { padding: 0.6rem 1rem; border-radius: 6px; font-size: 0.9rem; margin-bottom: 1rem; }
.alert--error { background: #fce8e6; color: var(--error); border: 1px solid var(--error); }
@media (prefers-color-scheme: dark) {
  .alert--error { background: #3c1a18; }
}

/* ── Dashboard layout with sidebar ──────────────────────────── */
.dashboard { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.dashboard h1 { margin-bottom: 1.5rem; }

/* ── Three-column responsive grid ──────────────────────────── */
.dashboard-layout-3col {
  display: grid;
  grid-template-columns: 0.5fr 1fr 0.75fr;
  gap: 1.25rem;
  align-items: start;
}
.dcol { min-width: 0; }
.dcol-heading {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Tablet: 2 columns, left spans full */
@media (max-width: 1024px) {
  .dashboard-layout-3col {
    grid-template-columns: 1fr 1fr;
  }
  .dcol-left {
    grid-column: 1 / -1;
  }
}

/* Phone: 1 column */
@media (max-width: 640px) {
  .dashboard-layout-3col {
    grid-template-columns: 1fr;
  }
  .dcol-left {
    grid-column: auto;
  }
}

/* ── Download hero ──────────────────────────────────────────── */
.download-hero-card {
  background: var(--card-bg);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.download-hero-card h3 { font-size: 1.1rem; margin-bottom: 0.3rem; }
.download-hero-card p { font-size: 0.88rem; color: var(--muted); margin-bottom: 0.75rem; }

/* ── News feed ─────────────────────────────────────────────── */
.news-feed { display: flex; flex-direction: column; gap: 0.75rem; }
.news-feed--empty { gap: 0; }
.news-empty { color: var(--muted); font-size: 0.9rem; }

.news-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.news-card:hover {
  border-color: var(--accent);
  box-shadow: 0 1px 4px var(--shadow);
  text-decoration: none;
}

.news-card-img {
  position: relative;
  width: 100%;
  aspect-ratio: 400 / 168;
  overflow: hidden;
  background: var(--border);
}
.news-card-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.news-card-body {
  padding: 0.7rem 0.9rem;
}
.news-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.news-card-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--muted);
}
.news-card-source {
  font-weight: 500;
  color: var(--fg);
}
.news-card-time {
  white-space: nowrap;
}
.news-grade {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-weight: 500;
}

/* ── Dashboard main area (legacy, kept for reference) ───────── */
.dashboard-main { flex: 1; min-width: 0; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; }
.dashboard-card { background: var(--card-bg); border-radius: 12px; padding: 1.25rem; border: 1px solid var(--border); }
.dashboard-card h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.dashboard-card p { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }
.dashboard-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.75rem; font-size: 0.85rem; }
.dashboard-card dt { color: var(--muted); }
.dashboard-card dd { margin: 0; }

/* ── Profile card ──────────────────────────────────────────── */
.profile-card { display: flex; gap: 1.5rem; align-items: flex-start; background: var(--card-bg); border-radius: 12px; padding: 1.5rem; border: 1px solid var(--border); margin-bottom: 1.5rem; }
.profile-avatar img, .avatar-placeholder { width: 96px; height: 96px; border-radius: 50%; flex-shrink: 0; }
.avatar-placeholder { background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 600; }
.profile-info { flex: 1; min-width: 0; }
.profile-info h2 { margin-bottom: 0.15rem; font-size: 1.4rem; }
.profile-email { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.profile-bio { font-size: 0.95rem; margin-bottom: 0.75rem; line-height: 1.45; color: var(--fg); }
.profile-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.meta-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 16px; padding: 0.2rem 0.65rem; font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.meta-chip a { color: var(--accent); }
.role-badge { font-weight: 500; }
.role--admin { border-color: var(--accent); color: var(--accent); }

/* ── Stats grid ────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border-radius: 10px; padding: 1rem; text-align: center; border: 1px solid var(--border); }
.stat-card-link { display: block; cursor: pointer; color: inherit; text-decoration: none; }
.stat-card-link:hover { border-color: var(--accent); box-shadow: 0 1px 4px var(--shadow); text-decoration: none; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { display: block; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 0.15rem; }

/* ── Badges ────────────────────────────────────────────────── */
.badges-section { margin-bottom: 1.5rem; }
.badges-section h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.badges-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.badge-chip { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; padding: 0.25rem 0.7rem; border-radius: 12px; font-size: 0.82rem; font-weight: 500; }
@media (prefers-color-scheme: dark) {
  .badge-chip { background: linear-gradient(135deg, #5a6fd6, #6a3d9a); }
}

/* ── Dashboard actions ─────────────────────────────────────── */
.dashboard-actions { margin-bottom: 1.5rem; }
.dashboard-actions h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.action-card { background: var(--card-bg); border-radius: 12px; padding: 1.25rem; border: 1px solid var(--border); }
.action-card h4 { font-size: 1rem; margin-bottom: 0.4rem; }
.action-card p { font-size: 0.88rem; color: var(--muted); margin-bottom: 1rem; }

/* ── Download ──────────────────────────────────────────────── */
.download-page { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-desc { color: var(--muted); margin-bottom: 2rem; }
.build-card { background: var(--card-bg); border-radius: 12px; padding: 1.5rem; border: 1px solid var(--border); margin-bottom: 1.5rem; }
.build-card h3 { margin-bottom: 0.5rem; }
.build-card p { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }

.build-progress { text-align: center; padding: 2rem; background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border); margin-bottom: 1.5rem; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 0.5rem; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }

.build-result, .build-error { background: var(--card-bg); border-radius: 12px; padding: 1.5rem; border: 1px solid var(--border); margin-bottom: 1.5rem; }
.build-result h3 { color: var(--success); }
.build-error h3 { color: var(--error); }
.download-links { display: flex; gap: 0.75rem; margin: 1rem 0; flex-wrap: wrap; }
.install-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.install-section pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin: 0.5rem 0; overflow-x: auto; }

/* ── Gateway ───────────────────────────────────────────────── */
.gateway-page { max-width: 800px; margin: 0 auto; padding: 2rem 1.5rem; }
.gateway-info { background: var(--card-bg); border-radius: 12px; padding: 1.25rem; margin: 1.5rem 0; border: 1px solid var(--border); }
.gateway-info h3 { margin-bottom: 0.3rem; }
.gateway-info pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin: 0.5rem 0; overflow-x: auto; font-size: 0.88rem; }
.gateway-playground { margin-top: 2rem; }
.gateway-playground textarea { min-height: 100px; }
.playground-response { margin-top: 1rem; }
.playground-response pre { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; max-height: 400px; overflow-y: auto; }

/* ── Contributions section (profile-style) ──────────────────── */
.contrib-section { margin-bottom: 1.5rem; }
.contrib-section > h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.contrib-group { margin-bottom: 1.25rem; }
.contrib-group-title { font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.contrib-items { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.contrib-item { display: flex; justify-content: space-between; align-items: center; padding: 0.7rem 1rem; gap: 0.5rem; color: var(--fg); text-decoration: none; cursor: pointer; transition: background 0.1s; }
.contrib-item:hover { background: var(--card-bg); text-decoration: none; }
.contrib-item + .contrib-item { border-top: 1px solid var(--border); }
.contrib-item-title { font-size: 0.9rem; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contrib-item-meta { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; font-size: 0.78rem; }
.contrib-topic,
.contrib-status,
.contrib-lang { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.1rem 0.45rem; white-space: nowrap; }
.contrib-topic--random { background: #e8f0fe; border-color: #c5d9f7; color: #1a73e8; }
.contrib-topic--rant { background: #fce8e6; border-color: #f5c6c2; color: #d93025; }
.contrib-topic--devlog { background: #e6f4ea; border-color: #b7e1c8; color: #0f9d58; }
.contrib-topic--fun { background: #fef7e0; border-color: #fce8b2; color: #e37400; }
@media (prefers-color-scheme: dark) {
  .contrib-topic--random { background: #1a2a4a; border-color: #2a3a5a; color: #8ab4f8; }
  .contrib-topic--rant { background: #3c1a18; border-color: #5c2a28; color: #f28b82; }
  .contrib-topic--devlog { background: #1a3a2a; border-color: #2a4a3a; color: #5bb974; }
  .contrib-topic--fun { background: #3c2a10; border-color: #5c4a20; color: #fdd663; }
}
.contrib-stars { color: var(--muted); white-space: nowrap; }
.contrib-time { color: var(--muted); white-space: nowrap; }
.contrib-empty { background: var(--card-bg); border-radius: 10px; padding: 1.5rem; text-align: center; color: var(--muted); font-size: 0.88rem; border: 1px solid var(--border); }
.contrib-status--active { background: #e6f4ea; border-color: #b7e1c8; color: #0f9d58; }
.contrib-status--released { background: #e8f0fe; border-color: #c5d9f7; color: #1a73e8; }
.contrib-status--in-development { background: #fef7e0; border-color: #fce8b2; color: #e37400; }
@media (prefers-color-scheme: dark) {
  .contrib-status--active { background: #1a3a2a; border-color: #2a4a3a; color: #5bb974; }
  .contrib-status--released { background: #1a2a4a; border-color: #2a3a5a; color: #8ab4f8; }
  .contrib-status--in-development { background: #3c2a10; border-color: #5c4a20; color: #fdd663; }
}

/* ── Footer ────────────────────────────────────────────────── */
.footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); }
.footer a { color: var(--muted); }

/* ── Presence sidebar ──────────────────────────────────────── */
.presence-sidebar { width: 280px; flex-shrink: 0; position: sticky; top: 1rem; }
.presence-card { background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.presence-header { padding: 1rem 1.15rem 0.75rem; border-bottom: 1px solid var(--border); }
.presence-header h3 { font-size: 0.95rem; margin-bottom: 0.15rem; }
.presence-header p { font-size: 0.78rem; color: var(--muted); line-height: 1.35; }
.presence-list { list-style: none; padding: 0; margin: 0; }
.presence-item { display: flex; gap: 0.65rem; padding: 0.65rem 1.15rem; align-items: flex-start; color: inherit; cursor: pointer; text-decoration: none; }
.presence-item:hover { background: var(--card-bg); filter: brightness(0.97); text-decoration: none; }
.presence-item + .presence-item { border-top: 1px solid var(--border); }
.presence-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 600; overflow: hidden; }
.presence-avatar img { width: 100%; height: 100%; object-fit: cover; }
.presence-body { flex: 1; min-width: 0; }
.presence-name { font-size: 0.88rem; font-weight: 500; color: var(--fg); line-height: 1.3; }
.presence-bio { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.presence-level { font-size: 0.72rem; color: var(--accent); }
.presence-online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 0.25rem; vertical-align: middle; }
.presence-empty { padding: 1.5rem 1.15rem; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ── Sidebar section (contributions in sidebar) ───────── */
.sidebar-section { margin-bottom: 1rem; }
.sidebar-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 0.75rem; background: var(--card-bg); }
.sidebar-card-title { font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); padding: 0.6rem 0.9rem 0.4rem; border-bottom: 1px solid var(--border); }
.sidebar-items { list-style: none; padding: 0; margin: 0; }
.sidebar-item { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.5rem 0.9rem; color: var(--fg); text-decoration: none; cursor: pointer; transition: background 0.1s; }
.sidebar-item:hover { background: var(--bg); text-decoration: none; }
.sidebar-item + .sidebar-item { border-top: 1px solid var(--border); }
.sidebar-item-title { font-size: 0.83rem; font-weight: 500; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item-meta { display: flex; gap: 0.4rem; align-items: center; font-size: 0.72rem; color: var(--muted); flex-wrap: wrap; }

/* ── Responsive tweaks (three-column aware) ────────────────── */
@media (max-width: 1024px) {
  .dashboard { padding: 1.5rem 1rem; }
}
@media (max-width: 640px) {
  .dashboard { padding: 1rem 0.75rem; }
  .profile-card { flex-direction: column; align-items: center; text-align: center; }
  .profile-meta { justify-content: center; }
}
