:root {
  color-scheme: light;
  --fg: #111;
  --fg-muted: #666;
  --bg: #fff;
  --bg-soft: #f5f5f5;
  --line: #e5e5e5;
  --max-width: 1100px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --fg: #f0f0f0;
  --fg-muted: #8a8a8a;
  --bg: #0d0d0d;
  --bg-soft: #1a1a1a;
  --line: #262626;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fg); text-decoration: none; }
a:hover { text-decoration: underline; }

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.topnav .brand {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.topnav .links {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
  align-items: center;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--fg);
  width: 2rem;
  height: 2rem;
  padding: 0;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease;
}

.theme-toggle:hover { border-color: var(--fg); }
.theme-toggle::before { content: "\263E"; }
[data-theme="dark"] .theme-toggle::before { content: "\2600"; }

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

section {
  padding: 4rem 0;
  border-bottom: 1px solid var(--line);
}

section:last-of-type { border-bottom: 0; }

h1 {
  font-size: 2.75rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 2rem;
  letter-spacing: -0.01em;
}

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

.hero {
  padding: 5rem 0 3rem;
}

.hero .lede {
  font-size: 1.2rem;
  color: var(--fg-muted);
  margin-bottom: 0;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.work-item {
  display: block;
  color: inherit;
}

.work-item .img-wrap {
  position: relative;
  width: 100%;
  padding-top: 100%;
  background: var(--bg-soft);
  overflow: hidden;
}

.work-item .img-wrap img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s ease;
}

.work-item:hover .img-wrap img { opacity: 0.85; }
.work-item:hover { text-decoration: none; }

.work-meta {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0 0;
  font-size: 0.9rem;
}

.work-title { font-weight: 500; }
.work-client { color: var(--fg-muted); font-size: 0.85rem; }

.bio {
  max-width: 38rem;
  font-size: 1.05rem;
  color: var(--fg-muted);
}

.bio p { margin-bottom: 1rem; }

#contact .contact-line {
  font-size: 1.25rem;
  margin-top: 0;
}

#contact .contact-line a {
  border-bottom: 1px solid var(--fg);
}

.work-detail {
  padding: 2rem 0 4rem;
  max-width: 800px;
  margin: 0 auto;
}

.work-detail .back {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-bottom: 2rem;
}

.work-detail .back a { color: var(--fg-muted); }
.work-detail .back a:hover { color: var(--fg); }

.work-detail h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.work-detail .meta {
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.work-detail .hero-image {
  width: 100%;
  height: auto;
  margin-bottom: 2rem;
  display: block;
}

.work-detail .prose {
  font-size: 1.05rem;
  max-width: 38rem;
  color: var(--fg-muted);
}

footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--fg-muted);
}

footer a { color: var(--fg-muted); }
footer a:hover { color: var(--fg); }

@media (max-width: 800px) {
  h1 { font-size: 2rem; }
  .work-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { padding: 3rem 0 2rem; }
  section { padding: 3rem 0; }
}

@media (max-width: 500px) {
  .topnav { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .topnav .links { gap: 1.25rem; }
  .work-grid { grid-template-columns: 1fr; }
}
