:root{
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5e6a73;
  --border: #ece7df;
  --shadow: 0 10px 30px rgba(20, 20, 20, .06);
  --accent: #d97706; /* warm amber */
  --accent-2: #b45309;
  --radius: 18px;
  --radius-sm: 12px;
  --max: 1040px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro SC", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", Arial, sans-serif;
  line-height:1.6;
  overflow-x:hidden;
  isolation:isolate;
}
body.has-ambient::before{
  content:'';
  position:fixed;
  inset:0;
  z-index:1;
  pointer-events:none;
  background:
    linear-gradient(90deg, rgba(251,250,247,.72) 0%, rgba(251,250,247,.38) 44%, rgba(251,250,247,.64) 100%),
    linear-gradient(180deg, rgba(251,250,247,.62) 0%, rgba(255,248,238,.24) 45%, rgba(251,250,247,.70) 100%);
}

.ambient-wallpaper{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  z-index:0;
  pointer-events:none;
  opacity:.9;
  mix-blend-mode:multiply;
  will-change:auto;
}

a{color:inherit; text-decoration:none}
a:hover{text-decoration:underline}

.skip{
  position:absolute; left:-999px; top:8px;
  padding:8px 10px; background:var(--surface);
  border:1px solid var(--border); border-radius:10px;
}
.skip:focus{left:12px; z-index:50}

.container{max-width:var(--max); margin:0 auto; padding:0 20px}
.home{display:flex; flex-direction:column; position:relative; z-index:2}
.home .hero{order:0}
.home #essays{order:1}
.home #projects{order:2}
.home #contact{order:3}
.home .footer{order:4}

.top{
  position:sticky; top:0; z-index:20;
  backdrop-filter:saturate(180%) blur(10px);
  -webkit-backdrop-filter:saturate(180%) blur(10px);
  background:rgba(251,250,247,.7);
  border-bottom:1px solid rgba(236,231,223,.7);
}
@media (max-width: 760px), (pointer: coarse){
  .top{
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
    background:rgba(251,250,247,.95);
  }
}
.nav{display:flex; align-items:center; justify-content:space-between; height:64px; gap:14px}

.brand{display:flex; align-items:center; gap:10px}
.brand__avatar{
  width:36px; height:36px;
  border-radius:12px;
  background:linear-gradient(180deg,#fff,#fff7ed);
  border:1px solid var(--border);
}
.brand__name{font-weight:650; letter-spacing:.2px}

.menu{display:flex; align-items:center; gap:14px; flex-wrap:wrap}
.menu a{color:var(--muted)}
.menu a:hover{color:var(--text); text-decoration:none}

.chip{
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  background:rgba(255,255,255,.65);
}

.hero{display:grid; grid-template-columns: 1.25fr .75fr; gap:22px; padding:42px 0 10px}

.kicker{margin:0 0 8px; color:var(--muted); font-size:14px}
.hero h1{margin:0 0 10px; font-size:42px; line-height:1.15; letter-spacing:-.4px}
.lede{margin:0 0 18px; color:var(--muted); font-size:16px}

.cta{display:flex; gap:10px; flex-wrap:wrap}
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:10px 14px;
  border-radius:999px;
  background:var(--text);
  color:#fff;
  border:1px solid rgba(0,0,0,.08);
  box-shadow: 0 6px 20px rgba(31,35,40,.12);
}
.btn:hover{text-decoration:none; transform:translateY(-1px)}
.btn--ghost{
  background:rgba(255,255,255,.6);
  color:var(--text);
  border:1px solid var(--border);
  box-shadow:none;
}

.meta{margin:14px 0 0; color:var(--muted); font-size:13px}

.section{padding:48px 0}
.section__head{margin-bottom:20px}
.section__head h2{margin:0 0 6px; font-size:24px; letter-spacing:-.3px}
.home #essays .section__head h2{font-size:30px}
.section--secondary{
  padding-top:24px;
  border-top:1px solid rgba(236,231,223,.78);
}

.muted{color:var(--muted)}

.card{
  background:rgba(255,255,255,.65);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
}

.hero__card .card{padding:14px}
.hero__card-title{margin:0 0 12px; font-size:20px; line-height:1.35; letter-spacing:-.2px}
.card__row{display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:10px 0; border-bottom:1px solid rgba(236,231,223,.65)}
.card__row:last-child{border-bottom:none}
.label{color:var(--muted); font-size:13px; white-space:nowrap}
.value{font-size:14px}

.writing-card .card{
  background:linear-gradient(180deg,rgba(255,255,255,.78),rgba(255,250,245,.68));
}
.writing-list{display:flex; flex-direction:column; margin-top:8px}
.writing-list__item{
  display:block;
  padding:11px 0 12px;
  border-top:1px solid rgba(236,231,223,.78);
}
.writing-list__item:hover{text-decoration:none}
.writing-list__item span{
  display:block;
  margin-bottom:4px;
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
}
.writing-list__item strong{
  display:block;
  font-size:14px;
  line-height:1.55;
}
.writing-list__item:hover strong{color:var(--accent)}
.hero__more{
  display:inline-flex;
  margin-top:12px;
  color:var(--accent);
  font-size:14px;
}
.hero__more:hover{color:var(--accent-2)}

.grid{display:grid; grid-template-columns:repeat(3, 1fr); gap:14px}
.tile{
  background:rgba(255,255,255,.65);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
  transition:transform .15s ease, box-shadow .15s ease;
}
.tile:hover{transform:translateY(-2px); box-shadow: 0 14px 36px rgba(20,20,20,.08)}
.tile h3{margin:0 0 8px; font-size:16px}
.tile p{margin:0; color:var(--muted)}
.section--secondary .tile{
  padding:13px;
  box-shadow:none;
  background:rgba(255,255,255,.48);
}
.section--secondary .tile:hover{box-shadow: var(--shadow)}
.section--secondary .tile p{
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  font-size:13px;
}
.section--secondary .tile__links{font-size:13px}

.tile--link{display:block; text-decoration:none}
.tile--link:hover{text-decoration:none}

.tile__top{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px}
.tile__links{margin-top:10px}
.tile__links a{color:var(--accent)}
.tile__links a:hover{color:var(--accent-2)}

.list{display:flex; flex-direction:column; gap:12px}
.post{
  background:rgba(255,255,255,.65);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
}
.post h3{margin:6px 0 8px; font-size:18px}
.post__meta{display:flex; align-items:center; gap:8px; flex-wrap:wrap; color:var(--muted); font-size:13px}
.dot{opacity:.6}
.tag{
  display:inline-flex; align-items:center;
  padding:2px 10px;
  border:1px solid rgba(236,231,223,.85);
  border-radius:999px;
  background:rgba(255,255,255,.55);
}

summary{cursor:pointer; color:var(--accent); margin-top:8px}
summary:hover{color:var(--accent-2)}

.prose{margin-top:10px; color:var(--muted)}
.prose strong{color:var(--text)}

.pill{
  display:inline-flex; align-items:center;
  padding:2px 10px;
  border-radius:999px;
  font-size:12px;
  border:1px solid rgba(0,0,0,.08);
}
.pill--active{background:rgba(217,119,6,.12); color:#7c2d12; border-color:rgba(217,119,6,.25)}
.pill--thinking{background:rgba(15,118,110,.10); color:#115e59; border-color:rgba(15,118,110,.22)}

.contact{display:grid; grid-template-columns:repeat(3, 1fr); gap:14px}

.footer{
  padding:32px 0 56px;
  border-top:1px solid rgba(236,231,223,.7);
  margin-top:20px;
  background:linear-gradient(180deg, var(--bg), rgba(255,250,245,.5));
}
.footer .muted{margin-bottom:6px}
.footer__motto{
  color:var(--muted);
  font-size:12px;
  opacity:.7;
  margin-top:4px;
}

/* --- Featured Essay (first post highlight) --- */
.post--featured{
  background:linear-gradient(135deg, rgba(255,255,255,.85), rgba(255,250,240,.7));
  border:1px solid rgba(217,119,6,.18);
  padding:22px 24px;
  position:relative;
}
.post--featured::before{
  content:'';
  position:absolute;
  left:0; top:12px; bottom:12px;
  width:3px;
  border-radius:2px;
  background:var(--accent);
}
.post--featured h3{font-size:22px; margin:8px 0 10px}
.post--featured .muted{font-size:15px; line-height:1.6}

/* --- Section rhythm --- */
#essays{
  background:linear-gradient(180deg, rgba(251,250,247,0) 0%, rgba(255,248,240,.35) 50%, rgba(251,250,247,0) 100%);
  border-radius:24px;
  padding:56px 0;
}
#essays .section__head{
  padding-bottom:16px;
  border-bottom:1px solid rgba(217,119,6,.12);
  margin-bottom:28px;
}

/* --- Hero enhancements --- */
.hero h1{font-weight:800}
.hero__card{
  transition:transform .2s ease, box-shadow .2s ease;
}
.hero__card:hover{
  transform:translateY(-3px) scale(1.01);
  box-shadow:0 16px 40px rgba(20,20,20,.1);
}

/* --- Project tiles compact mode --- */
.tile--compact{
  padding:10px 13px;
}
.tile--compact p{display:none}
.tile--compact .tile__top{margin-bottom:4px}
.tile--compact .tile__links{margin-top:6px}
.tile--compact h3{font-size:14px}

/* --- Projects show-more --- */
.grid .tile.hidden-tile{display:none}
.show-more-projects{
  display:inline-flex; align-items:center; gap:6px;
  margin-top:16px;
  padding:10px 20px;
  border:1px solid var(--border);
  border-radius:999px;
  background:rgba(255,255,255,.65);
  color:var(--muted);
  cursor:pointer;
  font-size:14px;
  transition:all .15s ease;
}
.show-more-projects:hover{
  background:var(--surface);
  color:var(--text);
  border-color:var(--accent);
}

/* --- Mobile Nav --- */
.nav-toggle{
  display:none;
  background:none; border:none; cursor:pointer;
  padding:8px;
  color:var(--text);
}
.nav-toggle svg{width:24px; height:24px}

/* --- Essays show-more --- */
.list .post.hidden-post{display:none}
.show-more-btn{
  display:inline-flex; align-items:center; gap:6px;
  margin-top:16px;
  padding:10px 20px;
  border:1px solid var(--border);
  border-radius:999px;
  background:rgba(255,255,255,.65);
  color:var(--muted);
  cursor:pointer;
  font-size:14px;
  transition:all .15s ease;
}
.show-more-btn:hover{
  background:var(--surface);
  color:var(--text);
  border-color:var(--accent);
}

/* --- Improved section spacing (already defined above) --- */

/* --- Smooth scroll --- */
html{scroll-behavior:smooth}

/* --- Active nav state --- */
.menu a.active{color:var(--text); font-weight:600}

/* --- Tablet breakpoint --- */
@media (max-width: 1080px){
  .grid{grid-template-columns:repeat(2, 1fr)}
}

@media (max-width: 920px){
  .hero{grid-template-columns:1fr; padding-top:26px}
  .hero h1{font-size:34px}
  .grid{grid-template-columns:1fr}
  .contact{grid-template-columns:1fr}

  .nav-toggle{display:block}
  .menu{
    position:fixed; left:0; right:0; top:64px; bottom:0;
    flex-direction:column; align-items:stretch;
    background:var(--bg);
    border-top:1px solid var(--border);
    box-shadow:0 20px 60px rgba(0,0,0,.12);
    padding:12px 20px;
    gap:0;
    opacity:0;
    pointer-events:none;
    transform:translateY(-12px);
    transition:opacity .2s ease, transform .2s ease;
    z-index:19;
    overflow-y:auto;
  }
  .menu.open{
    opacity:1;
    pointer-events:auto;
    transform:translateY(0);
  }
  .menu a{
    display:block;
    padding:14px 0;
    border-bottom:1px solid var(--border);
    font-size:16px;
    color:var(--text);
  }
  .menu a:last-child{border-bottom:none}
}

@media (max-width: 480px){
  .hero h1{font-size:26px}
  .lede{font-size:14px}
  .section{padding:32px 0}
  #essays{padding:32px 0}
  .post{padding:14px}
  .post h3{font-size:16px}
  .post--featured{padding:16px 14px}
  .post--featured h3{font-size:18px}
  .post--featured .muted{font-size:14px}
}

@media (max-width: 760px), (pointer: coarse){
  .ambient-wallpaper{display:none !important}
  body.has-ambient::before{display:none}
}

@media (prefers-reduced-motion: reduce){
  .ambient-wallpaper{opacity:.45}
  html{scroll-behavior:auto}
}
