/* ---------- Tokens ---------- */

:root {
  --bg: #0b0f0d;
  --surface: #121815;
  --surface-hover: #172019;
  --border: #223029;
  --text: #e4ebe7;
  --muted: #8b9a92;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --link: #6ee7a8;

  --font-sans: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 10px;
  --max-width: 960px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f9f8;
    --surface: #ffffff;
    --surface-hover: #f1f6f3;
    --border: #dde5e0;
    --text: #17201b;
    --muted: #5d6b63;
    --accent: #16a34a;
    --accent-soft: rgba(22, 163, 74, 0.1);
    --link: #15803d;
  }
}

/* ---------- Base ---------- */

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(24px, calc((100% - var(--max-width)) / 2 + 24px));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
}
.brand:hover { text-decoration: none; }

.site-header nav {
  display: flex;
  gap: 20px;
  font-size: 0.9rem;
}
.site-header nav a { color: var(--muted); }
.site-header nav a:hover { color: var(--text); text-decoration: none; }

/* ---------- Hero ---------- */

.hero {
  display: flex;
  align-items: flex-start;
  gap: 36px;
  padding: 72px 0 56px;
}

.avatar {
  flex-shrink: 0;
  width: 112px;
  height: 112px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  image-rendering: pixelated;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.handle {
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.bio {
  margin-top: 16px;
  max-width: 560px;
  font-size: 1.1rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.link-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  transition: border-color 0.15s, background-color 0.15s;
}
.link-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.link-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.stats {
  display: flex;
  gap: 32px;
  margin-top: 32px;
}
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { color: var(--muted); font-size: 0.8rem; }
.stats dd {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Sections ---------- */

.section {
  padding: 48px 0;
  border-top: 1px solid var(--border);
}

.section-head { margin-bottom: 24px; }

.eyebrow {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.section h2 {
  margin-top: 4px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Tool filters ---------- */

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.filters button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.filters button:hover { color: var(--text); }
.filters button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

/* ---------- Tool cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: var(--surface-hover);
  transform: translateY(-2px);
}
.card[hidden] { display: none; }

.card h3 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
}
.card h3 a { color: var(--text); }
/* The whole card is the link target. */
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card h3 a:hover { text-decoration: none; }

.card > p {
  flex: 1;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tags li {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.72rem;
}

.meta {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 0.8rem;
}

.lang { display: inline-flex; align-items: center; gap: 6px; }
.lang::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lang);
}

/* ---------- Papers ---------- */

.papers {
  display: grid;
  gap: 12px;
}

.paper {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.paper .meta { display: block; font-family: var(--font-mono); font-size: 0.75rem; }

.paper h3 {
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.45;
}
.paper h3 a { color: var(--text); }

.paper details { margin-top: 10px; }
.paper summary {
  width: fit-content;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.paper summary:hover { color: var(--text); }
.paper details p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---------- Skills ---------- */

.skills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.skills li {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
}

/* ---------- Activity ---------- */

.activity {
  padding: 20px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.activity img { display: block; width: 100%; min-width: 600px; height: auto; }
/* ghchart only renders a light chart (empty days are near-white). Inverting and
   rotating the hue back keeps the greens and turns the empty cells dark. */
@media (prefers-color-scheme: dark) {
  .activity img { filter: invert(1) hue-rotate(180deg) brightness(0.9); }
}

/* ---------- Footer ---------- */

.site-footer {
  padding: 32px 24px 48px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .site-header nav a:not(:last-child) { display: none; }
  .hero { flex-direction: column; gap: 24px; padding: 48px 0 40px; }
  .avatar { width: 88px; height: 88px; padding: 16px; }
  .stats { gap: 24px; }
}
