:root {
  --bg: #ffffff;
  --text: #171717;
  --text-muted: #737373;
  --text-faint: #a3a3a3;
  --border: #eeeeee;
  --divider: #f0f0f0;
  --max: 1100px;
  --font-sans: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
}

a {
  color: inherit;
}

/* ——— Top bar (About / Contact / Privacy) ——— */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.brand--zh {
  letter-spacing: 0.08em;
  font-weight: 600;
}

.brand:hover {
  opacity: 0.7;
}

.brand:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 4px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  line-height: 1.4;
}

.lang-switch a {
  color: var(--text-faint);
  text-decoration: none;
  font-weight: 400;
  transition: color 0.2s ease;
}

.lang-switch a:hover {
  color: var(--text-muted);
}

.lang-switch a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.lang-switch a:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 3px;
}

.lang-switch .sep {
  margin: 0 0.35rem;
  color: var(--text-faint);
  opacity: 0.55;
}

/* Footer language links: larger tap targets on small screens */
.site-footer .lang-switch a {
  padding: 0.35rem 0.15rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
}

/* ——— Page shell ——— */

.page {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 2.75rem 1.5rem 2rem;
}

@media (min-width: 768px) {
  .page {
    padding: 3.5rem 2rem 2.25rem;
  }
}

/* Home: Hero + projects as one group; Desktop places hero ~25–27vh, no strict centering */
.home-main {
  width: 100%;
}

.page--home .site-footer {
  margin-top: auto;
}

@media (min-width: 900px) {
  .page--home {
    padding-top: 0;
    padding-bottom: 1.75rem;
  }

  .home-main {
    flex: 1 1 auto;
    min-height: 0;
    /* No header bar: place hero band near ~26vh from viewport top */
    padding-top: clamp(2.5rem, 26vh, 11rem);
    padding-bottom: clamp(2rem, 6vh, 4rem);
  }

  .page--home .site-header {
    margin-bottom: clamp(6.875rem, 7vw + 2.5rem, 8.125rem); /* ~110–130px */
  }
}

/* ——— Home hero ——— */

.site-header {
  margin-bottom: 2.25rem;
  max-width: 34rem;
}

.brand-mark {
  display: inline-block;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 0.9rem;
  line-height: 1.4;
}

.brand-mark--zh {
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  font-size: 1.125rem;
}

.brand-mark:hover {
  opacity: 0.7;
}

.brand-mark:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 4px;
}

.site-title {
  font-size: clamp(1.5rem, 3.2vw, 1.875rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.3;
  color: var(--text);
}

.site-title--zh {
  letter-spacing: 0.06em;
  font-weight: 600;
}

.site-subline {
  margin-top: 0.75rem;
  font-size: 0.975rem;
  font-weight: 400;
  line-height: 1.65;
  color: var(--text-muted);
  max-width: 28rem;
}

.site-subline--zh {
  letter-spacing: 0.04em;
}

/* ——— Project directory ——— */

.entries {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 0;
  row-gap: 0;
  width: 100%;
}

@media (min-width: 900px) {
  .entries {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 3.5rem;
    row-gap: clamp(1.75rem, 3vh, 2.75rem);
  }
}

.entry {
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  padding: 1.25rem 0;
  padding-right: 1.75rem; /* reserve space so hover arrow does not shift layout */
  border-bottom: 1px solid var(--divider);
  min-height: 4.5rem;
  transition: opacity 0.15s ease;
}

.entry:active {
  opacity: 0.65;
}

.entry:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 4px;
}

.entry-body {
  min-width: 0;
}

.entry-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.3rem;
  line-height: 1.35;
  transition: color 0.18s ease;
}

.entry-subtitle {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-muted);
}

.entry-subtitle--en {
  letter-spacing: -0.01em;
}

/* Desktop only: inject ↗ on hover / keyboard focus (not in the DOM by default) */
@media (hover: hover) and (pointer: fine) {
  .entry::after {
    content: "↗";
    position: absolute;
    top: 1.35rem;
    right: 0;
    font-size: 0.95rem;
    line-height: 1;
    color: var(--text-muted);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  .entry:hover::after,
  .entry:focus-visible::after {
    opacity: 1;
  }

  .entry:hover .entry-title,
  .entry:focus-visible .entry-title {
    color: #404040;
  }
}

/* ——— Legal / inner content ——— */

.content {
  max-width: 40rem;
  margin: 0 auto;
  width: 100%;
}

.content > h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.content p,
.content li {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.75;
  color: var(--text-muted);
}

.content p + p {
  margin-top: 1rem;
}

.content a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

.content a:hover {
  color: var(--text-muted);
}

.content a:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 3px;
}

.content .updated {
  font-size: 0.875rem;
  color: var(--text-faint);
  margin: -0.5rem 0 2rem;
}

.content section {
  margin-bottom: 2.25rem;
}

.content h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.content ul {
  margin: 0.85rem 0 0;
  padding: 0 0 0 1.25rem;
}

.content li + li {
  margin-top: 0.55rem;
}

.content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: var(--text);
}

.content strong {
  font-weight: 600;
  color: var(--text);
}

.page--about .content {
  max-width: 36rem;
  text-align: center;
}

.page--about .content > h1 {
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  margin-bottom: 1.5rem;
  text-wrap: balance;
}

.page--about .content p {
  text-wrap: balance;
}

.page--contact .content {
  max-width: 28rem;
  text-align: center;
}

.page--contact .content a {
  text-decoration: none;
  font-weight: 500;
}

.page--contact .content a:hover {
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

/* ——— Footer ——— */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  padding-bottom: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.page--home .site-footer {
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  width: 100%;
}

.footer-nav {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-nav a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-nav a:hover {
  color: var(--text);
}

.footer-nav a[aria-current="page"] {
  color: var(--text);
}

.footer-nav a:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 3px;
}

.footer-nav .sep {
  margin: 0 0.55rem;
  opacity: 0.45;
}

.footer-copy {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-faint);
  line-height: 1.6;
}

.page--home .footer-copy {
  width: 100%;
}

@media (max-width: 480px) {
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .page--home .site-footer {
    align-items: stretch;
  }

  .page--home .footer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .topbar-inner {
    padding: 0.8rem 1.15rem;
  }

  .page {
    padding: 2rem 1.15rem 1.75rem;
  }

  .entry {
    padding: 1.15rem 0;
    min-height: 4.25rem;
  }
}
