:root {
  --bg: #12130f;
  --bg-soft: #1b1c16;
  --fg: #efe9d9;
  --muted: #a6a08f;
  --line: rgba(239, 233, 217, 0.16);
  --accent: #e2502c;
  --serif: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC",
    "Source Han Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC",
    "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono",
    monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

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

/* a single quiet grain, drawn instead of downloaded */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: radial-gradient(
    rgba(239, 233, 217, 0.05) 0.5px,
    transparent 0.5px
  );
  background-size: 4px 4px;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-soft);
}
::-webkit-scrollbar-thumb {
  background: rgba(239, 233, 217, 0.26);
  border: 3px solid var(--bg-soft);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(239, 233, 217, 0.45);
}

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

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.75rem 1rem;
  background: var(--fg);
  color: var(--bg);
  z-index: 10;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 3rem));
  margin: 0 auto;
  padding: 2rem 0 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell > main {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ---------- header ---------- */
.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.3125rem;
  letter-spacing: 0.02em;
}

.top .home {
  font-size: 0.875rem;
  color: var(--muted);
  transition: color 0.2s ease;
}
.top .home:hover {
  color: var(--accent);
}

/* ---------- hero ---------- */
.hero {
  padding: clamp(2.25rem, 6vh, 3.75rem) 0 clamp(1.75rem, 4vh, 2.75rem);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 3rem;
  align-items: end;
}

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.5rem, 5.4vw, 4.5rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0;
  text-wrap: balance;
  animation: rise 0.8s var(--ease) both;
}

h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero-note {
  margin: 0;
  color: var(--muted);
  font-size: 1.0625rem;
  line-height: 1.95;
  max-width: 30ch;
  animation: rise 0.8s var(--ease) 0.08s both;
}

.hero-note .domain {
  display: block;
  margin-top: 0.9rem;
  color: var(--fg);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

/* ---------- works ---------- */
.works {
  margin-top: auto;
  border-bottom: 1px solid var(--line);
}

.work {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line);
  color: var(--fg);
  transition: color 0.3s var(--ease);
  animation: rise 0.7s var(--ease) both;
}

.work:nth-child(1) {
  animation-delay: 0.06s;
}
.work:nth-child(2) {
  animation-delay: 0.12s;
}
.work:nth-child(3) {
  animation-delay: 0.18s;
}

.work::before {
  content: "";
  position: absolute;
  inset: 0 -1.5rem;
  background: var(--fg);
  opacity: 0;
  transform: scaleY(0.84);
  transform-origin: 50% 0;
  transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
}

.work:last-child::before {
  transform-origin: 50% 100%;
}

.work:hover::before {
  opacity: 1;
  transform: none;
}

.work:hover {
  color: var(--bg);
}

.work > * {
  position: relative;
  z-index: 1;
}

.work-title {
  font-family: var(--serif);
  font-size: clamp(1.375rem, 2.2vw, 1.875rem);
  line-height: 1.3;
  margin: 0 0 0.25rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.work-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9063rem;
  max-width: 54ch;
  transition: color 0.3s var(--ease);
}

.work:hover .work-desc {
  color: rgba(18, 19, 15, 0.7);
}

.work-meta {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--muted);
  transition: color 0.3s var(--ease);
}

.work:hover .work-meta {
  color: var(--bg);
}

.work-meta .arrow {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: border-color 0.3s var(--ease), transform 0.4s var(--ease);
}

.work-meta .arrow svg {
  width: 12px;
  height: 12px;
  display: block;
}

.work:hover .work-meta .arrow {
  border-color: rgba(18, 19, 15, 0.45);
  transform: translate(3px, -3px);
}

/* ---------- footer ---------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  padding-top: 1.15rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.foot .stack {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* ---------- detail page ---------- */
.detail {
  max-width: 68ch;
  padding: clamp(2.25rem, 5vh, 3.5rem) 0 0;
}

.detail h1 {
  font-size: clamp(2.125rem, 4.4vw, 3.125rem);
  margin-bottom: 1.1rem;
}

.lede {
  font-size: 1.0313rem;
  color: var(--muted);
  margin: 0 0 2.25rem;
}

.detail h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.25rem;
  margin: 2.5rem 0 0.75rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
}

.detail p,
.detail li {
  color: var(--muted);
  font-size: 0.9688rem;
}

.detail strong {
  color: var(--fg);
  font-weight: 600;
}

.detail code {
  font-family: var(--mono);
  font-size: 0.875em;
  color: var(--fg);
  background: var(--bg-soft);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

.detail ol,
.detail ul {
  margin: 0;
  padding-left: 1.2rem;
}

.detail li + li {
  margin-top: 0.35rem;
}

pre {
  margin: 1.15rem 0 0;
  padding: 1.15rem 1.25rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: #ddd7c7;
  border-radius: 3px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.75;
}

pre code {
  font-family: inherit;
  background: none;
  padding: 0;
  color: inherit;
}

.note {
  margin-top: 1.15rem;
  padding: 0.85rem 1rem;
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2.75rem;
  font-size: 0.875rem;
  color: var(--accent);
}

.back:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.back svg {
  width: 14px;
  height: 14px;
}

/* ---------- motion ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(5px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .shell {
    width: min(100% - 2rem, 1120px);
    padding-top: 1.25rem;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: clamp(1.75rem, 6vh, 3rem) 0 1.75rem;
  }

  .hero-note {
    max-width: 40ch;
  }

  .work {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 1.35rem 0;
  }

  .work::before {
    inset: 0 -1rem;
  }

  .work-meta {
    justify-content: space-between;
  }

  .foot {
    justify-content: flex-start;
  }
}

@media (hover: none) {
  .work::before {
    display: none;
  }
  .work {
    color: var(--fg);
  }
}

/* ---------- work gallery (work 2) ---------- */
.detail.gallery {
  max-width: 1000px;
}

.chart-figure {
  margin: 2.6rem 0 0;
}

.chart-figure h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.25rem;
  margin: 0 0 0.35rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line);
}

.chart-note {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.chart-frame {
  height: 500px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.chart-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.chart-open {
  display: inline-block;
  margin-top: 0.65rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.chart-open:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gallery .note {
  margin-top: 2.5rem;
}

@media (max-width: 860px) {
  .chart-frame {
    height: 380px;
  }
}

/* ---------- app page (work 3) ---------- */
.app-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.4rem;
}

.app-icon {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  border: 1px solid var(--line);
  display: block;
}

.app-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.875rem);
}

.app-tag {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.feature-list li {
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9688rem;
}

.feature-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.feature-list strong {
  color: var(--fg);
  font-weight: 600;
  margin-right: 0.6rem;
}

.download {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.25rem;
  background: var(--fg);
  color: var(--bg);
  font-size: 0.9375rem;
  border-radius: 3px;
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}

.btn:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

.dl-note {
  color: var(--muted);
  font-size: 0.8125rem;
}

@media (max-width: 860px) {
  .app-icon {
    width: 72px;
    height: 72px;
    border-radius: 16px;
  }
}
